From 1d0c3ca25472ab9191be7c01d8d050b8a7a5ba4d Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Sat, 27 Oct 2001 04:25:42 +0000 Subject: add prototypes for addressbook_config_database, and 2001-10-26 Chris Toshok * 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. svn path=/trunk/; revision=14200 --- addressbook/ChangeLog | 11 +++++++++ addressbook/gui/component/addressbook.c | 43 +++++++++++++++++++++++++++++++++ addressbook/gui/component/addressbook.h | 6 +++++ 3 files changed, 60 insertions(+) (limited to 'addressbook') 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 + + * 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 * 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 +#include #include #include @@ -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 +#include +#include +#include #include +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); -- cgit v1.2.3