From 524e3509c4a17958387308b3674548f7166610d6 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 10 Jun 2002 21:13:11 +0000 Subject: Made expand_uri a bit more robust and readable. 2002-06-10 Christopher James Lahey * backend/ebook/e-book-util.c (e_book_expand_uri): Made expand_uri a bit more robust and readable. (e_book_get_default_book_uri): Made e_book_get_default_book_uri use e_book_expand_uri if using the bonobo_config value. * gui/component/e-address-popup.c (start_query): Handle the failure state here by acting as if there are no matches. svn path=/trunk/; revision=17159 --- addressbook/backend/ebook/e-book-util.c | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'addressbook/backend/ebook') diff --git a/addressbook/backend/ebook/e-book-util.c b/addressbook/backend/ebook/e-book-util.c index 62694a8563..ff388105f0 100644 --- a/addressbook/backend/ebook/e-book-util.c +++ b/addressbook/backend/ebook/e-book-util.c @@ -42,27 +42,27 @@ struct _CommonBookInfo { char * e_book_expand_uri (const char *uri) { - char *new_uri; - if (!strncmp (uri, "file:", 5)) { - if (strlen (uri + 7) > 3 - && !strcmp (uri + strlen(uri) - 3, ".db")) { - /* it's a .db file */ - new_uri = g_strdup (uri); - } - else { - char *file_name; + int length = strlen (uri); + int offset = 5; + + if (!strncmp (uri, "file://", 7)) + offset = 7; + + if (length < 3 || strcmp (uri + length - 3, ".db")) { /* we assume it's a dir and glom addressbook.db onto the end. */ - file_name = g_concat_dir_and_file(uri + 7, "addressbook.db"); - new_uri = g_strdup_printf("file://%s", file_name); + + char *ret_val; + char *file_name; + + file_name = g_concat_dir_and_file(uri + offset, "addressbook.db"); + ret_val = g_strdup_printf("file://%s", file_name); g_free(file_name); + return ret_val; } } - else { - new_uri = g_strdup (uri); - } - return new_uri; + return g_strdup (uri); } static void @@ -281,9 +281,9 @@ e_book_get_default_book_uri () CORBA_exception_free (&ev); if (val) { - uri = val; - } - else { + 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); -- cgit v1.2.3