diff options
author | Chris Toshok <toshok@src.gnome.org> | 2000-05-17 01:50:28 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-05-17 01:50:28 +0800 |
commit | d6db70c32dafe0acde40893893d37eb05564967c (patch) | |
tree | fa4f7e1bb16ff35f4a8ec231a6157aa30a763c09 | |
parent | f8cb586400f551b3ade8594890a6ffdd991ae673 (diff) | |
download | gsoc2013-evolution-d6db70c32dafe0acde40893893d37eb05564967c.tar gsoc2013-evolution-d6db70c32dafe0acde40893893d37eb05564967c.tar.gz gsoc2013-evolution-d6db70c32dafe0acde40893893d37eb05564967c.tar.bz2 gsoc2013-evolution-d6db70c32dafe0acde40893893d37eb05564967c.tar.lz gsoc2013-evolution-d6db70c32dafe0acde40893893d37eb05564967c.tar.xz gsoc2013-evolution-d6db70c32dafe0acde40893893d37eb05564967c.tar.zst gsoc2013-evolution-d6db70c32dafe0acde40893893d37eb05564967c.zip |
add typedefs for the can_write functions, and add parameters to
* backend/pas/pas-book.h: add typedefs for the can_write
functions, and add parameters to pas_book_new.
* backend/pas/pas-book.c (pas_book_construct): add can_write/can_write_card params.
(pas_book_new): same.
(impl_Evolution_Book_can_write): new function.
(impl_Evolution_Book_can_write_card): same.
(pas_book_get_epv): assign the can_write/can_write_card slots in the epv.
* backend/pas/pas-backend-ldap.c (pas_backend_ldap_can_write): new function.
(pas_backend_ldap_can_write_card): same.
(pas_backend_ldap_add_client): add can_write/can_write_card to pas_book_new call.
* backend/pas/pas-backend-file.c (pas_backend_file_can_write_card): new function, calls can_write.
(pas_backend_file_can_write): same.
(can_write): return TRUE if we can write to the addressbook file.
(pas_backend_file_add_client): add can_write/can_write_card to pas_book_new call.
* backend/idl/addressbook.idl (Evolution): add can_write and
can_write_card permission requests.
svn path=/trunk/; revision=3093
-rw-r--r-- | addressbook/ChangeLog | 23 | ||||
-rw-r--r-- | addressbook/backend/idl/addressbook.idl | 12 | ||||
-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 |
6 files changed, 146 insertions, 15 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 50df303b87..95afe05cb7 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,26 @@ +2000-05-16 Chris Toshok <toshok@helixcode.com> + + * backend/pas/pas-book.h: add typedefs for the can_write + functions, and add parameters to pas_book_new. + + * backend/pas/pas-book.c (pas_book_construct): add can_write/can_write_card params. + (pas_book_new): same. + (impl_Evolution_Book_can_write): new function. + (impl_Evolution_Book_can_write_card): same. + (pas_book_get_epv): assign the can_write/can_write_card slots in the epv. + + * backend/pas/pas-backend-ldap.c (pas_backend_ldap_can_write): new function. + (pas_backend_ldap_can_write_card): same. + (pas_backend_ldap_add_client): add can_write/can_write_card to pas_book_new call. + + * backend/pas/pas-backend-file.c (pas_backend_file_can_write_card): new function, calls can_write. + (pas_backend_file_can_write): same. + (can_write): return TRUE if we can write to the addressbook file. + (pas_backend_file_add_client): add can_write/can_write_card to pas_book_new call. + + * backend/idl/addressbook.idl (Evolution): add can_write and + can_write_card permission requests. + 2000-05-16 Christopher James Lahey <clahey@helixcode.com> * backend/ebook/e-card.c (e_card_get_vcard): Fixed a large memory leak. diff --git a/addressbook/backend/idl/addressbook.idl b/addressbook/backend/idl/addressbook.idl index b3bcb5ea87..9a7743f974 100644 --- a/addressbook/backend/idl/addressbook.idl +++ b/addressbook/backend/idl/addressbook.idl @@ -44,6 +44,18 @@ module Evolution { VCard get_vcard (in CardId id); /* + * Permissions. the first form is general write + * permission (whether or not the user can add or + * remove or modify any entry in the addressbook.) + * + * if can_write returns TRUE, can_write_card can still + * return FALSE if the user doesn't have permission to + * modify/remove that specific card. + */ + boolean can_write (); + boolean can_write_card (in CardId Id); + + /* * Adding and deleting cards in the book. */ void create_card (in VCard vcard); 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 ()) |