aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/ebook
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2002-06-11 05:13:11 +0800
committerChris Lahey <clahey@src.gnome.org>2002-06-11 05:13:11 +0800
commit524e3509c4a17958387308b3674548f7166610d6 (patch)
tree569904a6b6969ebf6927b792c4755db53fc0c5ae /addressbook/backend/ebook
parentb17c20520eb4b1c6a8ad6acd227a4ba08b29a8c2 (diff)
downloadgsoc2013-evolution-524e3509c4a17958387308b3674548f7166610d6.tar.gz
gsoc2013-evolution-524e3509c4a17958387308b3674548f7166610d6.tar.zst
gsoc2013-evolution-524e3509c4a17958387308b3674548f7166610d6.zip
Made expand_uri a bit more robust and readable.
2002-06-10 Christopher James Lahey <clahey@ximian.com> * 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
Diffstat (limited to 'addressbook/backend/ebook')
-rw-r--r--addressbook/backend/ebook/e-book-util.c36
1 files changed, 18 insertions, 18 deletions
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);