From 9ba2e2d4613f0874ab95cc635139f4ffd090bb24 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Tue, 1 Apr 2003 06:58:27 +0000 Subject: new function, just return the local uri. (set_default_book_uri_local): use 2003-03-31 Chris Toshok * backend/ebook/e-book-util.c (get_local_book_uri): new function, just return the local uri. (set_default_book_uri_local): use get_local_book_uri. (e_book_default_book_open): only try and reload the default book if it's not already the local book. svn path=/trunk/; revision=20610 --- addressbook/backend/ebook/e-book-util.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'addressbook/backend/ebook/e-book-util.c') diff --git a/addressbook/backend/ebook/e-book-util.c b/addressbook/backend/ebook/e-book-util.c index 0fd50f7d5c..cc00d045f4 100644 --- a/addressbook/backend/ebook/e-book-util.c +++ b/addressbook/backend/ebook/e-book-util.c @@ -178,16 +178,28 @@ e_book_use_default_book (EBookCommonCallback cb, gpointer closure) static char *default_book_uri; -static void -set_default_book_uri_local (void) +static char* +get_local_book_uri (void) { char *filename; + char *uri; filename = g_build_filename (g_get_home_dir(), "evolution/local/Contacts/addressbook.db", NULL); - default_book_uri = g_strdup_printf ("file://%s", filename); + uri = g_strdup_printf ("file://%s", filename); + g_free (filename); + + return uri; +} + +static void +set_default_book_uri_local (void) +{ + g_free (default_book_uri); + + default_book_uri = get_local_book_uri (); } static void @@ -250,13 +262,20 @@ e_book_default_book_open (EBook *book, EBookStatus status, gpointer closure) g_free (default_book_closure); /* 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 the old default folder has disappeared, fall back to the + * local contacts folder instead, except when the default + * folder is also the local folder. */ 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); + char *local_uri = get_local_book_uri(); + if (strcmp (local_uri, default_book_uri)) { + set_default_book_uri_local (); + e_book_load_default_book (book, user_response, user_closure); + } + else + user_response (book, status, user_closure); + g_free (local_uri); } else { user_response (book, status, user_closure); } -- cgit v1.2.3