aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2001-12-19 23:16:32 +0800
committerJP Rosevear <jpr@src.gnome.org>2001-12-19 23:16:32 +0800
commitb64f547cdd71098035e9b055ee7f0ec4de2b9e1c (patch)
tree08ca63a7b0166c5bbe565f44a55ba0aef6997fd9
parentd7e3011f5135db26ab911a65e8e5d6ad4faa45df (diff)
downloadgsoc2013-evolution-b64f547cdd71098035e9b055ee7f0ec4de2b9e1c.tar
gsoc2013-evolution-b64f547cdd71098035e9b055ee7f0ec4de2b9e1c.tar.gz
gsoc2013-evolution-b64f547cdd71098035e9b055ee7f0ec4de2b9e1c.tar.bz2
gsoc2013-evolution-b64f547cdd71098035e9b055ee7f0ec4de2b9e1c.tar.lz
gsoc2013-evolution-b64f547cdd71098035e9b055ee7f0ec4de2b9e1c.tar.xz
gsoc2013-evolution-b64f547cdd71098035e9b055ee7f0ec4de2b9e1c.tar.zst
gsoc2013-evolution-b64f547cdd71098035e9b055ee7f0ec4de2b9e1c.zip
go slow and clear the map if the last uri and the current uri do not match
2001-12-18 JP Rosevear <jpr@ximian.com> * conduit/address-conduit.c (check_for_slow_setting): go slow and clear the map if the last uri and the current uri do not match (post_sync): save the last uri * conduits/address-conduit-config.h: handle a last uri config option 2001-12-18 Chris Toshok <toshok@ximian.com> * gui/component/addressbook.c (addressbook_default_book_open): change this to match its e-book counterpart, and only failover to the local addressbook if the protocol wasn't supported. that way errors like "failure to connect" are still reported to the user. * backend/ebook/e-book-util.h: add prototypes for e_book_load_default_book and e_book_get_config_database. * backend/ebook/e-book-util.c (e_book_default_book_open): new function, basically cut and paste addressbook_default_book_open from addressbook.c here. (e_book_load_default_book): cut and past addressbook_load_default_book here, pretty much, except leave off the auth stuff. (e_book_get_config_database): new function, returns the Bonobo_ConfigDatabase for e_book_load_default_book to use. * conduit/address-conduit.c (start_addressbook_server): use e_book_load_default_book here. svn path=/trunk/; revision=15178
-rw-r--r--addressbook/ChangeLog31
-rw-r--r--addressbook/backend/ebook/e-book-util.c74
-rw-r--r--addressbook/backend/ebook/e-book-util.h10
-rw-r--r--addressbook/conduit/address-conduit-config.h11
-rw-r--r--addressbook/conduit/address-conduit.c33
-rw-r--r--addressbook/gui/component/addressbook.c7
6 files changed, 151 insertions, 15 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 63aeffcfdd..370e4c0569 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,34 @@
+2001-12-18 JP Rosevear <jpr@ximian.com>
+
+ * conduit/address-conduit.c (check_for_slow_setting): go slow and
+ clear the map if the last uri and the current uri do not match
+ (post_sync): save the last uri
+
+ * conduits/address-conduit-config.h: handle a last uri config
+ option
+
+2001-12-18 Chris Toshok <toshok@ximian.com>
+
+ * gui/component/addressbook.c (addressbook_default_book_open):
+ change this to match its e-book counterpart, and only failover to
+ the local addressbook if the protocol wasn't supported. that way
+ errors like "failure to connect" are still reported to the user.
+
+ * backend/ebook/e-book-util.h: add prototypes for
+ e_book_load_default_book and e_book_get_config_database.
+
+ * backend/ebook/e-book-util.c (e_book_default_book_open): new
+ function, basically cut and paste addressbook_default_book_open
+ from addressbook.c here.
+ (e_book_load_default_book): cut and past
+ addressbook_load_default_book here, pretty much, except leave off
+ the auth stuff.
+ (e_book_get_config_database): new function, returns the
+ Bonobo_ConfigDatabase for e_book_load_default_book to use.
+
+ * conduit/address-conduit.c (start_addressbook_server): use
+ e_book_load_default_book here.
+
2001-12-17 Chris Toshok <toshok@ximian.com>
[ fixes bug 17355 ]
diff --git a/addressbook/backend/ebook/e-book-util.c b/addressbook/backend/ebook/e-book-util.c
index f141deb791..04f8a88131 100644
--- a/addressbook/backend/ebook/e-book-util.c
+++ b/addressbook/backend/ebook/e-book-util.c
@@ -33,6 +33,17 @@
#include <libgnome/gnome-util.h>
#include "e-card-compare.h"
+Bonobo_ConfigDatabase
+e_book_get_config_database (CORBA_Environment *ev)
+{
+ static Bonobo_ConfigDatabase config_db;
+
+ if (config_db == NULL)
+ config_db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", ev);
+
+ return config_db;
+}
+
gboolean
e_book_load_local_address_book (EBook *book, EBookCallback open_response, gpointer closure)
{
@@ -120,6 +131,69 @@ e_book_use_local_address_book (EBookCommonCallback cb, gpointer closure)
}
}
+typedef struct {
+ gpointer closure;
+ EBookCallback open_response;
+} DefaultBookClosure;
+
+static void
+e_book_default_book_open (EBook *book, EBookStatus status, gpointer closure)
+{
+ DefaultBookClosure *default_book_closure = closure;
+ gpointer user_closure = default_book_closure->closure;
+ EBookCallback user_response = default_book_closure->open_response;
+
+ g_free (default_book_closure);
+
+ /* special case the protocol not supported error, since we
+ really only want to failover to the local book in the case
+ where there's no installed backend for that protocol. all
+ other errors (failure to connect, etc.) should get reported
+ to the caller as normal. */
+ if (status == E_BOOK_STATUS_PROTOCOL_NOT_SUPPORTED) {
+ e_book_load_local_address_book (book, user_response, user_closure);
+ }
+ else {
+ user_response (book, status, user_closure);
+ }
+}
+
+gboolean
+e_book_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 = e_book_get_config_database (&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;
+ rv = e_book_load_uri (book, val,
+ e_book_default_book_open, default_book_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;
+}
+
/*
*
* Simple Query Stuff
diff --git a/addressbook/backend/ebook/e-book-util.h b/addressbook/backend/ebook/e-book-util.h
index 2fad0d9e9c..39e32e633d 100644
--- a/addressbook/backend/ebook/e-book-util.h
+++ b/addressbook/backend/ebook/e-book-util.h
@@ -29,6 +29,9 @@
#include <libgnome/gnome-defs.h>
#include "e-book.h"
+#include <bonobo-conf/bonobo-config-database.h>
+#include <bonobo/bonobo-object.h>
+#include <bonobo/bonobo-moniker-util.h>
BEGIN_GNOME_DECLS
@@ -43,6 +46,13 @@ gboolean e_book_load_local_address_book (EBook *book,
void e_book_use_local_address_book (EBookCommonCallback cb, gpointer closure);
+gboolean e_book_load_default_book (EBook *book,
+ EBookCallback open_response,
+ gpointer closure);
+
+/* Bonoboconf database interface. */
+Bonobo_ConfigDatabase e_book_get_config_database (CORBA_Environment *ev);
+
/* Simple Query Interface. */
guint e_book_simple_query (EBook *book,
diff --git a/addressbook/conduit/address-conduit-config.h b/addressbook/conduit/address-conduit-config.h
index 4042eff423..2387f67ef3 100644
--- a/addressbook/conduit/address-conduit-config.h
+++ b/addressbook/conduit/address-conduit-config.h
@@ -32,9 +32,11 @@
/* Configuration info */
typedef struct _EAddrConduitCfg EAddrConduitCfg;
struct _EAddrConduitCfg {
- gboolean open_secret;
guint32 pilot_id;
- GnomePilotConduitSyncType sync_type; /* only used by capplet */
+ GnomePilotConduitSyncType sync_type;
+
+ gboolean open_secret;
+ gchar *last_uri;
};
#ifdef ADDR_CONFIG_LOAD
@@ -63,6 +65,7 @@ addrconduit_load_configuration (EAddrConduitCfg **c, guint32 pilot_id)
gnome_config_push_prefix (prefix);
(*c)->open_secret = gnome_config_get_bool ("open_secret=FALSE");
+ (*c)->last_uri = gnome_config_get_string ("last_uri");
gnome_config_pop_prefix ();
}
@@ -80,6 +83,7 @@ addrconduit_save_configuration (EAddrConduitCfg *c)
gnome_config_push_prefix (prefix);
gnome_config_set_bool ("open_secret", c->open_secret);
+ gnome_config_set_string ("last_uri", c->last_uri);
gnome_config_pop_prefix ();
gnome_config_sync ();
@@ -99,7 +103,9 @@ addrconduit_dupe_configuration (EAddrConduitCfg *c)
retval = g_new0 (EAddrConduitCfg, 1);
retval->sync_type = c->sync_type;
retval->open_secret = c->open_secret;
+
retval->pilot_id = c->pilot_id;
+ retval->last_uri = g_strdup (c->last_uri);
return retval;
}
@@ -113,6 +119,7 @@ addrconduit_destroy_configuration (EAddrConduitCfg **c)
g_return_if_fail (c != NULL);
g_return_if_fail (*c != NULL);
+ g_free ((*c)->last_uri);
g_free (*c);
*c = NULL;
}
diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c
index 6791d0e445..3d6e3eca1f 100644
--- a/addressbook/conduit/address-conduit.c
+++ b/addressbook/conduit/address-conduit.c
@@ -31,6 +31,7 @@
#include <pi-file.h>
#include <pi-dlp.h>
#include <ebook/e-book.h>
+#include <ebook/e-book-util.h>
#include <ebook/e-card-types.h>
#include <ebook/e-card-cursor.h>
#include <ebook/e-card.h>
@@ -38,9 +39,11 @@
#include <e-pilot-util.h>
#define ADDR_CONFIG_LOAD 1
+#define ADDR_CONFIG_SAVE 1
#define ADDR_CONFIG_DESTROY 1
#include "address-conduit-config.h"
#undef ADDR_CONFIG_LOAD
+#undef ADDR_CONFIG_SAVE
#undef ADDR_CONFIG_DESTROY
#include "address-conduit.h"
@@ -311,25 +314,18 @@ book_open_cb (EBook *book, EBookStatus status, gpointer closure)
static int
start_addressbook_server (EAddrConduitContext *ctxt)
{
- gchar *uri, *path;
-
+ gboolean result;
+
g_return_val_if_fail(ctxt!=NULL,-2);
ctxt->ebook = e_book_new ();
- path = g_concat_dir_and_file (g_get_home_dir (),
- "evolution/local/Contacts/addressbook.db");
- uri = g_strdup_printf ("file://%s", path);
- g_free (path);
-
- e_book_load_uri (ctxt->ebook, uri, book_open_cb, ctxt);
-
+ result = e_book_load_default_book (ctxt->ebook, book_open_cb, ctxt);
+
/* run a sub event loop to turn ebook's async loading into a
synchronous call */
gtk_main ();
- g_free (uri);
-
if (ctxt->address_load_success)
return 0;
@@ -956,11 +952,20 @@ check_for_slow_setting (GnomePilotConduit *c, EAddrConduitContext *ctxt)
{
GnomePilotConduitStandard *conduit = GNOME_PILOT_CONDUIT_STANDARD (c);
int map_count;
-
+ const char *uri;
+
map_count = g_hash_table_size (ctxt->map->pid_map);
if (map_count == 0)
gnome_pilot_conduit_standard_set_slow (conduit, TRUE);
+ /* Or if the URI's don't match */
+ uri = e_book_get_uri (ctxt->ebook);
+ LOG(" Current URI %s (%s)\n", uri, ctxt->cfg->last_uri ? ctxt->cfg->last_uri : "<NONE>");
+ if (ctxt->cfg->last_uri != NULL && strcmp (ctxt->cfg->last_uri, uri)) {
+ gnome_pilot_conduit_standard_set_slow (conduit, TRUE);
+ e_pilot_map_clear (ctxt->map);
+ }
+
if (gnome_pilot_conduit_standard_get_slow (conduit)) {
ctxt->map->write_touched_only = TRUE;
LOG (" doing slow sync\n");
@@ -1148,6 +1153,10 @@ post_sync (GnomePilotConduit *conduit,
LOG ("post_sync: Address Conduit v.%s", CONDUIT_VERSION);
+ g_free (ctxt->cfg->last_uri);
+ ctxt->cfg->last_uri = g_strdup (e_book_get_uri (ctxt->ebook));
+ addrconduit_save_configuration (ctxt->cfg);
+
filename = map_name (ctxt);
e_pilot_map_write (filename, ctxt->map);
g_free (filename);
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 4741e5196a..619a89cdd5 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -699,7 +699,12 @@ addressbook_default_book_open (EBook *book, EBookStatus status, gpointer closure
g_free (default_book_closure);
- if (status != E_BOOK_STATUS_SUCCESS) {
+ /* special case the protocol not supported error, since we
+ really only want to failover to the local book in the case
+ where there's no installed backend for that protocol. all
+ other errors (failure to connect, etc.) should get reported
+ to the caller as normal. */
+ if (status == E_BOOK_STATUS_PROTOCOL_NOT_SUPPORTED) {
e_book_load_local_address_book (book, user_response, user_closure);
}
else {