diff options
author | Chris Toshok <toshok@ximian.com> | 2001-03-18 06:30:06 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2001-03-18 06:30:06 +0800 |
commit | b16a04e98d4d6afd4507fcd8e9bf31358f1b6344 (patch) | |
tree | 712f5da2d44ad0655e4356eda3d2e3eed0628265 /addressbook/backend/pas | |
parent | c768305c2f2203cf1fb9262a9f22b5a5f2dafebb (diff) | |
download | gsoc2013-evolution-b16a04e98d4d6afd4507fcd8e9bf31358f1b6344.tar.gz gsoc2013-evolution-b16a04e98d4d6afd4507fcd8e9bf31358f1b6344.tar.zst gsoc2013-evolution-b16a04e98d4d6afd4507fcd8e9bf31358f1b6344.zip |
new function. (impl_BookListener_report_writable): new function.
2001-03-17 Chris Toshok <toshok@ximian.com>
* backend/ebook/e-book-listener.c
(e_book_listener_queue_writable_status): new function.
(impl_BookListener_report_writable): new function.
(e_book_listener_get_epv): fill in epv->notifyWritable.
* backend/ebook/e-book-listener.h: add writable status entries.
* backend/ebook/e-book.c (e_book_do_writable_event): new function.
(e_book_check_listener_queue): add WritableStatusEvent to the
switch.
(e_book_class_init): register writable_status signal.
* backend/ebook/e-book.h: add writable_status signal.
* backend/idl/addressbook.idl: add notifyWritable method to
BookListener.
* gui/widgets/e-minicard.c (e_minicard_class_init): add "editable"
arg.
(e_minicard_init): init editable.
(e_minicard_set_arg): loop over the minicard fields setting their
"editable".
(e_minicard_get_arg): add editable.
(supported_fields_cb): use editable when creating the
contact_editor.
(add_field): set "editable" when creatin the e_minicard.
* gui/widgets/e-minicard.h (struct _EMinicard): add "editable".
* gui/widgets/e-minicard-view.c (e_minicard_view_class_init): add
editable arg.
(e_minicard_view_init): init editable.
(create_card): pass editable to e_minicard canvas item.
(e_minicard_view_set_arg): bit of a hack - loop over all the
canvas items setting their "editable."
(e_minicard_view_get_arg): add editable.
(supported_fields_cb): use editable when creating the contact
editor.
* gui/widgets/e-minicard-view.h (struct _EMinicardView): add
"editable."
* gui/widgets/e-minicard-view-widget.c
(e_minicard_view_widget_class_init): add "editable" field.
(e_minicard_view_widget_init): init editable to FALSE.
(e_minicard_view_widget_set_arg): save editable, and pass it along
the e-minicard-view.
(e_minicard_view_widget_realize): same.
(e_minicard_view_widget_get_arg): add editable.
* gui/widgets/e-minicard-view-widget.h (struct
_EMinicardViewWidget): add "editable" field.
* gui/widgets/e-minicard-label.h (struct _EMinicardLabel): add
"editable" field.
* gui/widgets/e-minicard-label.c (e_minicard_label_class_init):
add "editable" arg.
(e_minicard_label_set_arg): editable, set it on the e_text too.
(e_minicard_label_get_arg): editable.
(e_minicard_label_construct): set the "editable" field when we
create the e_text cavas item
* gui/widgets/e-addressbook-view.c (e_addressbook_view_init):
default editable to FALSE.
(book_writable_cb): new function, set our editable field and
gtk_object_set it on the active view.
(e_addressbook_view_set_arg): set the active view's editable when
we set the view's book, and connect the "writable_status" signal
to book_writable_cb.
(change_view_type): same.
(supported_fields_cb): use our "editable" when creating the
contact editor.
* gui/widgets/e-addressbook-view.h (struct _EAddressbookView): add
editable field.
* gui/widgets/e-addressbook-model.c (e_addressbook_model_init):
change the default of editable to FALSE.
* backend/pas/pas-book.c (pas_book_report_writable): new function.
* backend/pas/pas-book.h: prototype for pas_book_report_writable.
* backend/pas/pas-backend-file.c (pas_backend_file_load_uri): if
we open the file O_RDWR (or create it) report it as writable. if
we can't open it as O_RDWR, try opening it read-only before we
attempt to create it.
* backend/pas/pas-backend-ldap.c
(pas_backend_ldap_process_authenticate_user): if we authenticate
successfully, grant write permissions (this is lacking but there's
really nothing we can do to determine the extent of the access
afforded a user.)
svn path=/trunk/; revision=8787
Diffstat (limited to 'addressbook/backend/pas')
-rw-r--r-- | addressbook/backend/pas/pas-backend-file.c | 48 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-ldap.c | 3 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.c | 22 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.h | 3 |
4 files changed, 62 insertions, 14 deletions
diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c index 74b8613d3d..a42a1fa499 100644 --- a/addressbook/backend/pas/pas-backend-file.c +++ b/addressbook/backend/pas/pas-backend-file.c @@ -1330,30 +1330,43 @@ pas_backend_file_load_uri (PASBackend *backend, { PASBackendFile *bf = PAS_BACKEND_FILE (backend); char *filename; + gboolean writable = FALSE; + GList *l; g_assert (bf->priv->loaded == FALSE); filename = pas_backend_file_extract_path_from_uri (uri); bf->priv->file_db = dbopen (filename, O_RDWR, 0666, DB_HASH, NULL); - if (bf->priv->file_db == NULL) { - bf->priv->file_db = dbopen (filename, O_RDWR | O_CREAT, 0666, DB_HASH, NULL); + if (bf->priv->file_db) { + writable = TRUE; + } + else { + /* try to open the file read-only */ + bf->priv->file_db = dbopen (filename, O_RDONLY, 0666, DB_HASH, NULL); - if (bf->priv->file_db) { - char *create_initial_file; - char *dir; + if (!bf->priv->file_db) { + /* lastly, try and create the file */ + bf->priv->file_db = dbopen (filename, O_RDWR | O_CREAT, 0666, DB_HASH, NULL); - dir = g_dirname(filename); - create_initial_file = g_concat_dir_and_file(dir, "create-initial"); + if (bf->priv->file_db) { + char *create_initial_file; + char *dir; - if (g_file_exists(create_initial_file)) { - char *id; - id = do_create(backend, INITIAL_VCARD, NULL); - g_free (id); - } + dir = g_dirname(filename); + create_initial_file = g_concat_dir_and_file(dir, "create-initial"); + + if (g_file_exists(create_initial_file)) { + char *id; + id = do_create(backend, INITIAL_VCARD, NULL); + g_free (id); + } - g_free(create_initial_file); - g_free(dir); + g_free(create_initial_file); + g_free(dir); + + writable = TRUE; + } } } @@ -1369,6 +1382,13 @@ pas_backend_file_load_uri (PASBackend *backend, } else return FALSE; + /* report the writable status of the book to all its clients */ + for (l = bf->priv->clients; l; l = g_list_next (l)) { + PASBook *book = l->data; + + pas_book_report_writable (book, writable); + } + return TRUE; } diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c index 0478c59ece..0fb5347ca3 100644 --- a/addressbook/backend/pas/pas-backend-ldap.c +++ b/addressbook/backend/pas/pas-backend-ldap.c @@ -2036,6 +2036,9 @@ pas_backend_ldap_process_authenticate_user (PASBackend *backend, pas_book_respond_authenticate_user (book, ldap_error_to_response (ldap_error)); + if (ldap_error == LDAP_SUCCESS) + pas_book_report_writable (book, TRUE); + if (!bl->priv->evolutionPersonChecked) check_schema_support (bl); } diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c index 6add0987fc..d115e9062f 100644 --- a/addressbook/backend/pas/pas-book.c +++ b/addressbook/backend/pas/pas-book.c @@ -656,6 +656,28 @@ pas_book_report_connection (PASBook *book, CORBA_exception_free (&ev); } +/** + * pas_book_report_writable: + */ +void +pas_book_report_writable (PASBook *book, + gboolean writable) +{ + CORBA_Environment ev; + + CORBA_exception_init (&ev); + + GNOME_Evolution_Addressbook_BookListener_notifyWritable ( + book->priv->listener, (CORBA_boolean) writable, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("pas_book_report_writable: Exception " + "responding to BookListener!\n"); + } + + CORBA_exception_free (&ev); +} + static gboolean pas_book_construct (PASBook *book, PASBackend *backend, diff --git a/addressbook/backend/pas/pas-book.h b/addressbook/backend/pas/pas-book.h index 1d401d33a4..12c780e282 100644 --- a/addressbook/backend/pas/pas-book.h +++ b/addressbook/backend/pas/pas-book.h @@ -100,6 +100,9 @@ void pas_book_respond_get_changes (PASBook void pas_book_report_connection (PASBook *book, gboolean connected); +void pas_book_report_writable (PASBook *book, + gboolean writable); + gboolean pas_book_can_write (PASBook *book); gboolean pas_book_can_write_card (PASBook *book, const char *id); |