aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/ebook/e-book-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/backend/ebook/e-book-util.c')
-rw-r--r--addressbook/backend/ebook/e-book-util.c108
1 files changed, 10 insertions, 98 deletions
diff --git a/addressbook/backend/ebook/e-book-util.c b/addressbook/backend/ebook/e-book-util.c
index d3de9840f8..04f8a88131 100644
--- a/addressbook/backend/ebook/e-book-util.c
+++ b/addressbook/backend/ebook/e-book-util.c
@@ -33,93 +33,6 @@
#include <libgnome/gnome-util.h>
#include "e-card-compare.h"
-typedef struct _CommonBookInfo CommonBookInfo;
-struct _CommonBookInfo {
- EBookCommonCallback cb;
- gpointer closure;
-};
-
-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;
- /* 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);
- g_free(file_name);
- }
- }
- else {
- new_uri = g_strdup (uri);
- }
-
- return new_uri;
-}
-
-static void
-got_uri_book_cb (EBook *book, EBookStatus status, gpointer closure)
-{
- CommonBookInfo *info = (CommonBookInfo *) closure;
-
- if (status == E_BOOK_STATUS_SUCCESS) {
- info->cb (book, info->closure);
- } else {
- info->cb (NULL, info->closure);
- }
- g_free (info);
-}
-
-gboolean
-e_book_load_address_book_by_uri (EBook *book, const char *uri, EBookCallback open_response, gpointer closure)
-{
- gboolean rv;
- char *real_uri;
-
- 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);
-
- real_uri = e_book_expand_uri (uri);
-
- rv = e_book_load_uri (book, real_uri, open_response, closure);
-
- if (!rv) {
- g_warning ("Couldn't load addressbook %s", real_uri);
- }
-
- g_free (real_uri);
-
- return rv;
-}
-
-void
-e_book_use_address_book_by_uri (const char *uri, EBookCommonCallback cb, gpointer closure)
-{
- EBook *book;
- CommonBookInfo *info;
-
- g_return_if_fail (cb != NULL);
-
- info = g_new0 (CommonBookInfo, 1);
- info->cb = cb;
- info->closure = closure;
-
- book = e_book_new ();
- if (! e_book_load_address_book_by_uri (book, uri, got_uri_book_cb, info)) {
- gtk_object_unref (GTK_OBJECT (book));
- g_free (info);
- }
-}
-
Bonobo_ConfigDatabase
e_book_get_config_database (CORBA_Environment *ev)
{
@@ -130,7 +43,7 @@ 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)
{
@@ -159,6 +72,12 @@ e_book_load_local_address_book (EBook *book, EBookCallback open_response, gpoint
static EBook *common_local_book = NULL;
+typedef struct _CommonBookInfo CommonBookInfo;
+struct _CommonBookInfo {
+ EBookCommonCallback cb;
+ gpointer closure;
+};
+
static void
got_local_book_cb (EBook *book, EBookStatus status, gpointer closure)
{
@@ -242,7 +161,7 @@ e_book_default_book_open (EBook *book, EBookStatus status, gpointer closure)
gboolean
e_book_load_default_book (EBook *book, EBookCallback open_response, gpointer closure)
{
- char *val, *uri;
+ char *val;
gboolean rv;
CORBA_Environment ev;
Bonobo_ConfigDatabase config_db;
@@ -253,22 +172,15 @@ e_book_load_default_book (EBook *book, EBookCallback open_response, gpointer clo
CORBA_exception_init (&ev);
config_db = e_book_get_config_database (&ev);
- val = bonobo_config_get_string (config_db, "/DefaultFolders/contacts_uri", &ev);
+ val = bonobo_config_get_string (config_db, "/Addressbook/default_book_uri", &ev);
CORBA_exception_free (&ev);
if (val) {
DefaultBookClosure *default_book_closure = g_new (DefaultBookClosure, 1);
default_book_closure->closure = closure;
default_book_closure->open_response = open_response;
-
- /* Sigh. FIXME. */
- if (!strncmp (val, "file:", 5))
- uri = g_strconcat (val, "/addressbook.db", NULL);
- else
- uri = g_strdup (val);
- rv = e_book_load_uri (book, uri,
+ rv = e_book_load_uri (book, val,
e_book_default_book_open, default_book_closure);
- g_free (uri);
g_free (val);
}
else {