aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--addressbook/ChangeLog11
-rw-r--r--addressbook/gui/component/addressbook.c43
-rw-r--r--addressbook/gui/component/addressbook.h6
3 files changed, 60 insertions, 0 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 72ca85d4c7..e4169c4c7e 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,14 @@
+2001-10-26 Chris Toshok <toshok@ximian.com>
+
+ * gui/component/addressbook.h: add prototypes for
+ addressbook_config_database, and addressbook_load_default_book.
+
+ * gui/component/addressbook.c (addressbook_config_database): new
+ function, so we aren't activating the db everywhere we need to use
+ it.
+ (addressbook_load_default_book): load the default book, after
+ getting the uri from bonobo-config.
+
2001-10-26 Jon Trowbridge <trow@ximian.com>
* backend/ebook/e-book-util.c (simple_query_card_added_cb): Return
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 804154fb88..4cc967276a 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -41,6 +41,7 @@
#include "addressbook/printing/e-contact-print.h"
#include <ebook/e-book.h>
+#include <ebook/e-book-util.h>
#include <widgets/misc/e-search-bar.h>
#include <widgets/misc/e-filter-bar.h>
@@ -664,6 +665,38 @@ addressbook_load_uri (EBook *book, const char *uri,
return rv;
}
+gboolean
+addressbook_load_default_book (EBook *book, EBookCallback open_response, gpointer closure)
+{
+ char *val;
+ gboolean rv;
+ CORBA_Environment ev;
+ Bonobo_ConfigDatabase config_db;
+
+ 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);
+
+ CORBA_exception_init (&ev);
+ config_db = addressbook_config_database (&ev);
+ val = bonobo_config_get_string (config_db, "/Addressbook/default_book_uri", &ev);
+ CORBA_exception_free (&ev);
+
+ if (val) {
+ rv = addressbook_load_uri (book, val, open_response, closure);
+ g_free (val);
+ }
+ else {
+ rv = e_book_load_local_address_book (book, open_response, closure);
+ }
+
+ if (!rv) {
+ g_warning ("Couldn't load default addressbook");
+ }
+
+ return rv;
+}
+
static void
set_prop (BonoboPropertyBag *bag,
const BonoboArg *arg,
@@ -920,7 +953,17 @@ set_folder_bar_label (EAddressbookView *eav, const char *message, AddressbookVie
CORBA_exception_free (&ev);
}
+/* Our global singleton config database */
+static Bonobo_ConfigDatabase config_db = NULL;
+Bonobo_ConfigDatabase
+addressbook_config_database (CORBA_Environment *ev)
+{
+ if (config_db == NULL)
+ config_db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", ev);
+
+ return config_db;
+}
BonoboControl *
addressbook_factory_new_control (void)
diff --git a/addressbook/gui/component/addressbook.h b/addressbook/gui/component/addressbook.h
index 5cf14dba12..9a99589578 100644
--- a/addressbook/gui/component/addressbook.h
+++ b/addressbook/gui/component/addressbook.h
@@ -2,14 +2,20 @@
#define __ADDRESSBOOK_H__
#include <bonobo/bonobo-control.h>
+#include <bonobo-conf/bonobo-config-database.h>
+#include <bonobo/bonobo-object.h>
+#include <bonobo/bonobo-moniker-util.h>
#include <ebook/e-book.h>
+Bonobo_ConfigDatabase addressbook_config_database (CORBA_Environment *ev);
+
/* expand file:///foo/foo/ to file:///foo/foo/addressbook.db */
char * addressbook_expand_uri (const char *uri);
/* use this instead of e_book_load_uri everywhere where you want the
authentication to be handled for you. */
gboolean addressbook_load_uri (EBook *book, const char *uri, EBookCallback cb, gpointer closure);
+gboolean addressbook_load_default_book (EBook *book, EBookCallback open_response, gpointer closure);
BonoboControl *addressbook_factory_new_control (void);
void addressbook_factory_init (void);