aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog45
-rw-r--r--addressbook/backend/ebook/e-book-listener.c2
-rw-r--r--addressbook/backend/ebook/e-book-types.h1
-rw-r--r--addressbook/backend/ebook/e-book-util.c127
-rw-r--r--addressbook/backend/ebook/e-book-util.h9
-rw-r--r--addressbook/backend/ebook/e-card-compare.c6
-rw-r--r--addressbook/backend/ebook/e-destination.c6
-rw-r--r--addressbook/backend/idl/addressbook.idl2
-rw-r--r--addressbook/gui/component/addressbook-component.c25
-rw-r--r--addressbook/gui/component/e-address-widget.c2
-rw-r--r--addressbook/gui/component/select-names/e-select-names-popup.c2
-rw-r--r--addressbook/gui/widgets/e-addressbook-util.c1
12 files changed, 124 insertions, 104 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 1de3d2d49b..8bd5f347b8 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,48 @@
+2002-08-12 Dan Winship <danw@ximian.com>
+
+ * 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.
+
2002-08-08 Chris Toshok <toshok@ximian.com>
* backend/pas/pas-backend-summary.c (pas_backend_summary_init):
diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c
index 99875c6c48..ca366386f2 100644
--- a/addressbook/backend/ebook/e-book-listener.c
+++ b/addressbook/backend/ebook/e-book-listener.c
@@ -634,6 +634,8 @@ e_book_listener_convert_status (const GNOME_Evolution_Addressbook_BookListener_C
return E_BOOK_STATUS_AUTHENTICATION_REQUIRED;
case GNOME_Evolution_Addressbook_BookListener_TLSNotAvailable:
return E_BOOK_STATUS_TLS_NOT_AVAILABLE;
+ case GNOME_Evolution_Addressbook_BookListener_NoSuchBook:
+ return E_BOOK_STATUS_NO_SUCH_BOOK;
case GNOME_Evolution_Addressbook_BookListener_OtherError:
return E_BOOK_STATUS_OTHER_ERROR;
default:
diff --git a/addressbook/backend/ebook/e-book-types.h b/addressbook/backend/ebook/e-book-types.h
index 05c28b6ea8..ac8350b878 100644
--- a/addressbook/backend/ebook/e-book-types.h
+++ b/addressbook/backend/ebook/e-book-types.h
@@ -28,6 +28,7 @@ typedef enum {
E_BOOK_STATUS_AUTHENTICATION_FAILED,
E_BOOK_STATUS_AUTHENTICATION_REQUIRED,
E_BOOK_STATUS_TLS_NOT_AVAILABLE,
+ E_BOOK_STATUS_NO_SUCH_BOOK,
E_BOOK_STATUS_OTHER_ERROR
} EBookStatus;
diff --git a/addressbook/backend/ebook/e-book-util.c b/addressbook/backend/ebook/e-book-util.c
index ff388105f0..e113e8c607 100644
--- a/addressbook/backend/ebook/e-book-util.c
+++ b/addressbook/backend/ebook/e-book-util.c
@@ -131,53 +131,27 @@ e_book_get_config_database (CORBA_Environment *ev)
return config_db;
}
-gboolean
-e_book_load_local_address_book (EBook *book, EBookCallback open_response, gpointer closure)
-{
- gchar *filename;
- gchar *uri;
- gboolean rv;
-
- g_return_val_if_fail (book != NULL, FALSE);
- g_return_val_if_fail (E_IS_BOOK (book), FALSE);
- g_return_val_if_fail (open_response != NULL, FALSE);
-
- filename = gnome_util_prepend_user_home ("evolution/local/Contacts/addressbook.db");
- uri = g_strdup_printf ("file://%s", filename);
-
- rv = e_book_load_uri (book, uri, open_response, closure);
-
- if (!rv) {
- g_warning ("Couldn't load local addressbook %s", uri);
- }
-
- g_free (filename);
- g_free (uri);
-
- return rv;
-}
-
-static EBook *common_local_book = NULL;
+static EBook *common_default_book = NULL;
static void
-got_local_book_cb (EBook *book, EBookStatus status, gpointer closure)
+got_default_book_cb (EBook *book, EBookStatus status, gpointer closure)
{
CommonBookInfo *info = (CommonBookInfo *) closure;
if (status == E_BOOK_STATUS_SUCCESS) {
/* We try not to leak in a race condition where the
- local book got loaded twice. */
+ default book got loaded twice. */
- if (common_local_book) {
+ if (common_default_book) {
gtk_object_unref (GTK_OBJECT (book));
- book = common_local_book;
+ book = common_default_book;
}
info->cb (book, info->closure);
- if (common_local_book == NULL) {
- common_local_book = book;
+ if (common_default_book == NULL) {
+ common_default_book = book;
}
} else {
@@ -189,15 +163,15 @@ got_local_book_cb (EBook *book, EBookStatus status, gpointer closure)
}
void
-e_book_use_local_address_book (EBookCommonCallback cb, gpointer closure)
+e_book_use_default_book (EBookCommonCallback cb, gpointer closure)
{
EBook *book;
CommonBookInfo *info;
g_return_if_fail (cb != NULL);
- if (common_local_book != NULL) {
- cb (common_local_book, closure);
+ if (common_default_book != NULL) {
+ cb (common_default_book, closure);
return;
}
@@ -206,12 +180,46 @@ e_book_use_local_address_book (EBookCommonCallback cb, gpointer closure)
info->closure = closure;
book = e_book_new ();
- if (! e_book_load_local_address_book (book, got_local_book_cb, info)) {
+ if (! e_book_load_default_book (book, got_default_book_cb, info)) {
gtk_object_unref (GTK_OBJECT (book));
g_free (info);
}
}
+static char *default_book_uri;
+
+static void
+set_default_book_uri_local (void)
+{
+ char *filename;
+
+ if (default_book_uri)
+ g_free (default_book_uri);
+
+ filename = gnome_util_prepend_user_home ("evolution/local/Contacts/addressbook.db");
+ default_book_uri = g_strdup_printf ("file://%s", filename);
+ g_free (filename);
+}
+
+static void
+set_default_book_uri_from_bonobo_conf (void)
+{
+ CORBA_Environment ev;
+ char *val;
+ Bonobo_ConfigDatabase config_db;
+
+ CORBA_exception_init (&ev);
+ config_db = e_book_get_config_database (&ev);
+ val = bonobo_config_get_string (config_db, "/DefaultFolders/contacts_uri", &ev);
+ CORBA_exception_free (&ev);
+
+ if (val) {
+ default_book_uri = e_book_expand_uri (val);
+ g_free (val);
+ } else
+ set_default_book_uri_local ();
+}
+
typedef struct {
gpointer closure;
EBookCallback open_response;
@@ -226,15 +234,15 @@ e_book_default_book_open (EBook *book, EBookStatus status, gpointer closure)
g_free (default_book_closure);
- /* special case the protocol not supported error, since we
- really only want to failover to the local book in the case
- where there's no installed backend for that protocol. all
- other errors (failure to connect, etc.) should get reported
- to the caller as normal. */
- if (status == E_BOOK_STATUS_PROTOCOL_NOT_SUPPORTED) {
- e_book_load_local_address_book (book, user_response, user_closure);
- }
- else {
+ /* If there's a transient error, report it to the caller, but
+ * if the old default folder has disappeared, fall back to
+ * the local contacts folder instead.
+ */
+ if (status == E_BOOK_STATUS_PROTOCOL_NOT_SUPPORTED ||
+ status == E_BOOK_STATUS_NO_SUCH_BOOK) {
+ set_default_book_uri_local ();
+ e_book_load_default_book (book, user_response, user_closure);
+ } else {
user_response (book, status, user_closure);
}
}
@@ -259,7 +267,6 @@ e_book_load_default_book (EBook *book, EBookCallback open_response, gpointer clo
rv = e_book_load_uri (book, uri,
e_book_default_book_open, default_book_closure);
- g_free (uri);
if (!rv) {
g_warning ("Couldn't load default addressbook");
@@ -271,26 +278,10 @@ e_book_load_default_book (EBook *book, EBookCallback open_response, gpointer clo
char*
e_book_get_default_book_uri ()
{
- CORBA_Environment ev;
- char *val, *uri;
- Bonobo_ConfigDatabase config_db;
-
- CORBA_exception_init (&ev);
- config_db = e_book_get_config_database (&ev);
- val = bonobo_config_get_string (config_db, "/DefaultFolders/contacts_uri", &ev);
- CORBA_exception_free (&ev);
-
- if (val) {
- uri = e_book_expand_uri (val);
- g_free (val);
- } else {
- char *filename;
- filename = gnome_util_prepend_user_home ("evolution/local/Contacts/addressbook.db");
- uri = g_strdup_printf ("file://%s", filename);
- g_free (filename);
- }
+ if (!default_book_uri)
+ set_default_book_uri_from_bonobo_conf ();
- return uri;
+ return default_book_uri;
}
/*
@@ -752,7 +743,7 @@ have_address_book_open_cb (EBook *book, gpointer closure)
}
void
-e_book_query_address_locally (const gchar *email,
+e_book_query_address_default (const gchar *email,
EBookHaveAddressCallback cb,
gpointer closure)
{
@@ -766,5 +757,5 @@ e_book_query_address_locally (const gchar *email,
info->cb = cb;
info->closure = closure;
- e_book_use_local_address_book (have_address_book_open_cb, info);
+ e_book_use_default_book (have_address_book_open_cb, info);
}
diff --git a/addressbook/backend/ebook/e-book-util.h b/addressbook/backend/ebook/e-book-util.h
index fe80b7e02c..c1c07564cd 100644
--- a/addressbook/backend/ebook/e-book-util.h
+++ b/addressbook/backend/ebook/e-book-util.h
@@ -51,10 +51,7 @@ void e_book_use_address_book_by_uri (const char
EBookCommonCallback cb,
gpointer closure);
-gboolean e_book_load_local_address_book (EBook *book,
- EBookCallback open_response,
- gpointer closure);
-void e_book_use_local_address_book (EBookCommonCallback cb,
+void e_book_use_default_book (EBookCommonCallback cb,
gpointer closure);
gboolean e_book_load_default_book (EBook *book,
EBookCallback open_response,
@@ -84,8 +81,8 @@ guint e_book_nickname_query (EBook
gpointer closure);
/* Returns the ECard associated to email in the callback,
- or NULL if no match is found in the local address book. */
-void e_book_query_address_locally (const gchar *email,
+ or NULL if no match is found in the default address book. */
+void e_book_query_address_default (const gchar *email,
EBookHaveAddressCallback cb,
gpointer closure);
diff --git a/addressbook/backend/ebook/e-card-compare.c b/addressbook/backend/ebook/e-card-compare.c
index fb88603552..b8866e7e81 100644
--- a/addressbook/backend/ebook/e-card-compare.c
+++ b/addressbook/backend/ebook/e-card-compare.c
@@ -668,12 +668,12 @@ e_card_locate_match (ECard *card, ECardMatchQueryCallback cb, gpointer closure)
info->closure = closure;
info->avoid = NULL;
- e_book_use_local_address_book (use_common_book_cb, info);
+ e_book_use_default_book (use_common_book_cb, info);
}
/**
* e_card_locate_match_full:
- * @book: The book to look in. If this is NULL, use the main local
+ * @book: The book to look in. If this is NULL, use the default
* addressbook.
* @card: The card to compare to.
* @avoid: A list of cards to not match. These will not show up in the search.
@@ -701,6 +701,6 @@ e_card_locate_match_full (EBook *book, ECard *card, GList *avoid, ECardMatchQuer
if (book)
use_common_book_cb (book, info);
else
- e_book_use_local_address_book (use_common_book_cb, info);
+ e_book_use_default_book (use_common_book_cb, info);
}
diff --git a/addressbook/backend/ebook/e-destination.c b/addressbook/backend/ebook/e-destination.c
index 5cb5fa859f..c83d908e9b 100644
--- a/addressbook/backend/ebook/e-destination.c
+++ b/addressbook/backend/ebook/e-destination.c
@@ -1034,7 +1034,7 @@ launch_cardify_query (EDestination *dest)
}
static void
-use_local_book_cb (EBook *book, gpointer closure)
+use_default_book_cb (EBook *book, gpointer closure)
{
EDestination *dest = E_DESTINATION (closure);
if (dest->priv->cardify_book == NULL) {
@@ -1108,7 +1108,7 @@ e_destination_cardify (EDestination *dest, EBook *book)
if (dest->priv->cardify_book != NULL) {
launch_cardify_query (dest);
} else {
- e_book_use_local_address_book (use_local_book_cb, dest);
+ e_book_use_default_book (use_default_book_cb, dest);
}
}
@@ -1673,7 +1673,7 @@ e_destination_touch (EDestination *dest)
email = e_destination_get_email (dest);
if (email)
- e_book_query_address_locally (email, touch_cb, NULL);
+ e_book_query_address_default (email, touch_cb, NULL);
}
}
diff --git a/addressbook/backend/idl/addressbook.idl b/addressbook/backend/idl/addressbook.idl
index 1d597189c5..9e1ee8766f 100644
--- a/addressbook/backend/idl/addressbook.idl
+++ b/addressbook/backend/idl/addressbook.idl
@@ -108,8 +108,8 @@ module Addressbook {
AuthenticationFailed,
AuthenticationRequired,
UnsupportedField,
-
TLSNotAvailable,
+ NoSuchBook,
OtherError
};
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)
@@ -407,15 +407,6 @@ local_addressbook_cb (EBook *book, gpointer closure)
}
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,
const char *parent_folder_physical_uri,
@@ -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;