diff options
Diffstat (limited to 'addressbook/backend/pas')
-rw-r--r-- | addressbook/backend/pas/pas-backend-file.c | 52 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-ldap.c | 19 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.c | 44 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.h | 11 |
4 files changed, 111 insertions, 15 deletions
diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c index 9de1b1c421..56a0fd4652 100644 --- a/addressbook/backend/pas/pas-backend-file.c +++ b/addressbook/backend/pas/pas-backend-file.c @@ -8,6 +8,7 @@ #include "config.h" #include <gtk/gtksignal.h> +#include <unistd.h> #include <fcntl.h> #include <time.h> #ifdef HAVE_DB_185_H @@ -816,6 +817,45 @@ pas_backend_file_process_check_connection (PASBackend *backend, pas_book_report_connection (book, bf->priv->file_db != NULL); } +static char * +pas_backend_file_extract_path_from_uri (const char *uri) +{ + g_assert (strncasecmp (uri, "file:", 5) == 0); + + return g_strdup (uri + 5); +} + +static gboolean +can_write (PASBackend *backend) +{ + PASBackendFile *bf = PAS_BACKEND_FILE (backend); + char *path = pas_backend_file_extract_path_from_uri (bf->priv->uri); + gboolean retval; + + retval = (access (path, W_OK) != -1); + + g_free (path); + + return retval; +} + +static gboolean +pas_backend_file_can_write (PASBook *book) +{ + PASBackend* backend = pas_book_get_backend (book); + + return can_write(backend); +} + +static gboolean +pas_backend_file_can_write_card (PASBook *book, + const char *id) +{ + PASBackend* backend = pas_book_get_backend (book); + + return can_write(backend); +} + static void pas_backend_file_process_client_requests (PASBook *book) { @@ -895,14 +935,6 @@ pas_backend_file_get_vcard (PASBook *book, const char *id) } } -static char * -pas_backend_file_extract_path_from_uri (const char *uri) -{ - g_assert (strncasecmp (uri, "file:", 5) == 0); - - return g_strdup (uri + 5); -} - static gboolean pas_backend_file_upgrade_db (PASBackendFile *bf, char *old_version) { @@ -1033,7 +1065,9 @@ pas_backend_file_add_client (PASBackend *backend, book = pas_book_new ( backend, listener, - pas_backend_file_get_vcard); + pas_backend_file_get_vcard, + pas_backend_file_can_write, + pas_backend_file_can_write_card); if (!book) { if (!bf->priv->clients) diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c index 845ef31e16..2f32661cca 100644 --- a/addressbook/backend/pas/pas-backend-ldap.c +++ b/addressbook/backend/pas/pas-backend-ldap.c @@ -207,6 +207,7 @@ pas_backend_ldap_build_all_cards_list(PASBackend *backend, if (ldap) { ldap->ld_sizelimit = LDAP_MAX_SEARCH_RESPONSES; + ldap->ld_deref = LDAP_DEREF_ALWAYS; if ((ldap_error = ldap_search_s (ldap, bl->priv->ldap_rootdn, @@ -729,6 +730,7 @@ pas_backend_ldap_search (PASBackendLDAP *bl, if (ldap) { ldap->ld_sizelimit = LDAP_MAX_SEARCH_RESPONSES; + ldap->ld_deref = LDAP_DEREF_ALWAYS; if ((view->search_msgid = ldap_search (ldap, bl->priv->ldap_rootdn, @@ -802,6 +804,19 @@ pas_backend_ldap_process_check_connection (PASBackend *backend, pas_book_report_connection (book, bl->priv->connected); } +static gboolean +pas_backend_ldap_can_write (PASBook *book) +{ + return FALSE; /* XXX */ +} + +static gboolean +pas_backend_ldap_can_write_card (PASBook *book, + const char *id) +{ + return FALSE; /* XXX */ +} + static void pas_backend_ldap_process_client_requests (PASBook *book) { @@ -927,7 +942,9 @@ pas_backend_ldap_add_client (PASBackend *backend, book = pas_book_new ( backend, listener, - pas_backend_ldap_get_vcard); + pas_backend_ldap_get_vcard, + pas_backend_ldap_can_write, + pas_backend_ldap_can_write_card); if (!book) { if (!bl->priv->clients) diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c index 2601d3d9d0..55caf1dce7 100644 --- a/addressbook/backend/pas/pas-book.c +++ b/addressbook/backend/pas/pas-book.c @@ -23,6 +23,8 @@ struct _PASBookPrivate { PASBackend *backend; Evolution_BookListener listener; PASBookGetVCardFn get_vcard; + PASBookCanWriteFn can_write; + PASBookCanWriteCardFn can_write_card; GList *request_queue; gint idle_id; @@ -154,6 +156,31 @@ impl_Evolution_Book_get_vcard (PortableServer_Servant servant, return retval; } +static CORBA_boolean +impl_Evolution_Book_can_write (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); + CORBA_boolean retval; + + retval = (book->priv->can_write) (book); + + return retval; +} + +static CORBA_boolean +impl_Evolution_Book_can_write_card (PortableServer_Servant servant, + const Evolution_CardId id, + CORBA_Environment *ev) +{ + PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); + CORBA_boolean retval; + + retval = (book->priv->can_write_card) (book, (const char *) id); + + return retval; +} + static void impl_Evolution_Book_create_card (PortableServer_Servant servant, const Evolution_VCard vcard, @@ -452,7 +479,9 @@ static gboolean pas_book_construct (PASBook *book, PASBackend *backend, Evolution_BookListener listener, - PASBookGetVCardFn get_vcard) + PASBookGetVCardFn get_vcard, + PASBookCanWriteFn can_write, + PASBookCanWriteCardFn can_write_card) { POA_Evolution_Book *servant; CORBA_Environment ev; @@ -462,6 +491,8 @@ pas_book_construct (PASBook *book, g_assert (PAS_IS_BOOK (book)); g_assert (listener != CORBA_OBJECT_NIL); g_assert (get_vcard != NULL); + g_assert (can_write != NULL); + g_assert (can_write_card != NULL); servant = (POA_Evolution_Book *) g_new0 (BonoboObjectServant, 1); servant->vepv = &pas_book_vepv; @@ -497,6 +528,8 @@ pas_book_construct (PASBook *book, book->priv->listener = listener; book->priv->get_vcard = get_vcard; + book->priv->can_write = can_write; + book->priv->can_write_card = can_write_card; book->priv->backend = backend; return TRUE; @@ -508,7 +541,9 @@ pas_book_construct (PASBook *book, PASBook * pas_book_new (PASBackend *backend, Evolution_BookListener listener, - PASBookGetVCardFn get_vcard) + PASBookGetVCardFn get_vcard, + PASBookCanWriteFn can_write, + PASBookCanWriteCardFn can_write_card) { PASBook *book; @@ -517,7 +552,8 @@ pas_book_new (PASBackend *backend, book = gtk_type_new (pas_book_get_type ()); - if (! pas_book_construct (book, backend, listener, get_vcard)) { + if (! pas_book_construct (book, backend, listener, + get_vcard, can_write, can_write_card)) { gtk_object_unref (GTK_OBJECT (book)); return NULL; @@ -563,6 +599,8 @@ pas_book_get_epv (void) epv = g_new0 (POA_Evolution_Book__epv, 1); epv->get_vcard = impl_Evolution_Book_get_vcard; + epv->can_write = impl_Evolution_Book_can_write; + epv->can_write_card = impl_Evolution_Book_can_write_card; epv->create_card = impl_Evolution_Book_create_card; epv->remove_card = impl_Evolution_Book_remove_card; epv->modify_card = impl_Evolution_Book_modify_card; diff --git a/addressbook/backend/pas/pas-book.h b/addressbook/backend/pas/pas-book.h index 094df79857..43a94b6600 100644 --- a/addressbook/backend/pas/pas-book.h +++ b/addressbook/backend/pas/pas-book.h @@ -52,11 +52,15 @@ typedef struct { void (*requests_queued) (void); } PASBookClass; -typedef char * (*PASBookGetVCardFn) (PASBook *book, const char *id); +typedef char * (*PASBookGetVCardFn) (PASBook *book, const char *id); +typedef gboolean (*PASBookCanWriteFn) (PASBook *book); +typedef gboolean (*PASBookCanWriteCardFn) (PASBook *book, const char *id); PASBook *pas_book_new (PASBackend *backend, Evolution_BookListener listener, - PASBookGetVCardFn get_vcard); + PASBookGetVCardFn get_vcard, + PASBookCanWriteFn can_write, + PASBookCanWriteCardFn can_write_card); PASBackend *pas_book_get_backend (PASBook *book); Evolution_BookListener pas_book_get_listener (PASBook *book); int pas_book_check_pending (PASBook *book); @@ -80,6 +84,9 @@ void pas_book_respond_get_book_view (PASBook void pas_book_report_connection (PASBook *book, gboolean connected); +gboolean pas_book_can_write (PASBook *book); +gboolean pas_book_can_write_card (PASBook *book, + const char *id); GtkType pas_book_get_type (void); #define PAS_BOOK_TYPE (pas_book_get_type ()) |