From 79a4d5a123547b18d9e513e3fb02eb4bf9999451 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 13 Aug 2002 01:01:58 +0000 Subject: If invoked from a non-contact folder, add the contact to the default * gui/component/addressbook-component.c (user_create_new_item_cb): If invoked from a non-contact folder, add the contact to the default contact folder, not the local one. If invoked from a contact folder, don't append "addressbook.db" to the URI, let ebook do the right thing. Fixes #28327 and #28325. * backend/idl/addressbook.idl (CallStatus): Add NoSuchBook. (Initially intended as part of a fix for #28327, but the other changes make it so the error code never ends up getting used any more, but it's still good to have.) * gui/widgets/e-addressbook-util.c (e_addressbook_error_dialog): Handle NO_SUCH_BOOK. * backend/ebook/e-book-types.h (EBookStatus): Add E_BOOK_STATUS_NO_SUCH_BOOK. * backend/ebook/e-book-listener.c (e_book_listener_convert_status): add case for NoSuchBook. * backend/ebook/e-book-util.c (e_book_load_local_address_book): Kill this. Nothing should ever explicitly load the local addressbook. (e_book_use_default_book): Replaces e_book_use_local_address_book, using the default book instead. (e_book_default_book_open): Fall back to local contact folder on E_BOOK_STATUS_NO_SUCH_BOOK too. (e_book_query_address_default): Use default book, not local. * gui/component/e-address-widget.c (query_idle_fn): Use the default book, not the local book. * gui/component/select-names/e-select-names-popup.c (edit_contact_info_cb): Use the default book, not the local book. * backend/ebook/e-destination.c (e_destination_cardify): Use the default book, not the local book. (e_destination_touch): Query the default book, not the local book. * backend/ebook/e-card-compare.c (e_card_locate_match, e_card_locate_match_full): Use the default book, not the local book. svn path=/trunk/; revision=17764 --- addressbook/gui/component/addressbook-component.c | 25 ++++------------------ addressbook/gui/component/e-address-widget.c | 2 +- .../component/select-names/e-select-names-popup.c | 2 +- addressbook/gui/widgets/e-addressbook-util.c | 1 + 4 files changed, 7 insertions(+), 23 deletions(-) (limited to 'addressbook/gui') diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c index 1ef6b1675c..e60c383cb9 100644 --- a/addressbook/gui/component/addressbook-component.c +++ b/addressbook/gui/component/addressbook-component.c @@ -395,7 +395,7 @@ owner_unset_cb (EvolutionShellComponent *shell_component, /* FIXME We should perhaps take the time to figure out if the book is editable. */ static void -local_addressbook_cb (EBook *book, gpointer closure) +new_item_cb (EBook *book, gpointer closure) { gboolean is_list = GPOINTER_TO_INT (closure); if (book == NULL) @@ -406,15 +406,6 @@ local_addressbook_cb (EBook *book, gpointer closure) e_addressbook_show_contact_editor (book, e_card_new(""), TRUE, TRUE); } -static void -nonlocal_addressbook_cb (EBook *book, EBookStatus status, gpointer closure) -{ - if (status == E_BOOK_STATUS_SUCCESS) - local_addressbook_cb (book, closure); - else - local_addressbook_cb (NULL, closure); -} - static void user_create_new_item_cb (EvolutionShellComponent *shell_component, const char *id, @@ -432,18 +423,10 @@ user_create_new_item_cb (EvolutionShellComponent *shell_component, return; } if (IS_CONTACT_TYPE (parent_folder_type)) { - EBook *book; - gchar *uri; - - book = e_book_new (); - uri = g_strdup_printf ("%s/addressbook.db", parent_folder_physical_uri); - - if (addressbook_load_uri (book, uri, nonlocal_addressbook_cb, GINT_TO_POINTER (is_contact_list)) == 0) - g_warning ("Couldn't load addressbook %s", uri); - - g_free (uri); + e_book_use_address_book_by_uri (parent_folder_physical_uri, + new_item_cb, GINT_TO_POINTER (is_contact_list)); } else { - e_book_use_local_address_book (local_addressbook_cb, GINT_TO_POINTER (is_contact_list)); + e_book_use_default_book (new_item_cb, GINT_TO_POINTER (is_contact_list)); } } diff --git a/addressbook/gui/component/e-address-widget.c b/addressbook/gui/component/e-address-widget.c index d044ddf7b9..d01999d34f 100644 --- a/addressbook/gui/component/e-address-widget.c +++ b/addressbook/gui/component/e-address-widget.c @@ -298,7 +298,7 @@ query_idle_fn (gpointer ptr) if (common_book) { e_address_widget_do_query (addr); } else { - e_book_load_local_address_book (e_book_new (), book_ready_cb, addr); + e_book_load_default_book (e_book_new (), book_ready_cb, addr); } addr->query_idle_tag = 0; diff --git a/addressbook/gui/component/select-names/e-select-names-popup.c b/addressbook/gui/component/select-names/e-select-names-popup.c index 442a00b6c1..927bdff769 100644 --- a/addressbook/gui/component/select-names/e-select-names-popup.c +++ b/addressbook/gui/component/select-names/e-select-names-popup.c @@ -123,7 +123,7 @@ edit_contact_info_cb (GtkWidget *w, gpointer user_data) return; gtk_object_ref (GTK_OBJECT (info->dest)); - e_book_use_local_address_book (make_contact_editor_cb, (gpointer) info->dest); + e_book_use_default_book (make_contact_editor_cb, (gpointer) info->dest); } static void diff --git a/addressbook/gui/widgets/e-addressbook-util.c b/addressbook/gui/widgets/e-addressbook-util.c index f0f0e8dfe6..cdb17086a3 100644 --- a/addressbook/gui/widgets/e-addressbook-util.c +++ b/addressbook/gui/widgets/e-addressbook-util.c @@ -43,6 +43,7 @@ e_addressbook_error_dialog (const gchar *msg, EBookStatus status) N_("Authentication Failed"), N_("Authentication Required"), N_("TLS not Available"), + N_("Addressbook does not exist"), N_("Other error") }; char *error_msg; -- cgit v1.2.3