[evolution-groupwise] Adapt to libebackend changes.



commit 586635a96e76e3066bba07c35060b35ced731737
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Sep 11 11:22:54 2011 -0400

    Adapt to libebackend changes.
    
    Address book and calendar backends now use the EModule / EExtension
    framework promoted from Evolution, instead of e-data-server-module.c.

 src/addressbook/e-book-backend-groupwise-factory.c |   51 ++++--
 src/addressbook/e-book-backend-groupwise.c         |   43 +++--
 src/calendar/Makefile.am                           |    1 -
 src/calendar/e-cal-backend-groupwise-factory.c     |  211 ++++++--------------
 src/calendar/e-cal-backend-groupwise-factory.h     |   37 ----
 src/calendar/e-cal-backend-groupwise-utils.c       |    2 +-
 src/calendar/e-cal-backend-groupwise.c             |   83 ++++----
 7 files changed, 161 insertions(+), 267 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-groupwise-factory.c b/src/addressbook/e-book-backend-groupwise-factory.c
index b2ccfb9..7789ae4 100644
--- a/src/addressbook/e-book-backend-groupwise-factory.c
+++ b/src/addressbook/e-book-backend-groupwise-factory.c
@@ -21,34 +21,53 @@
  * Authors: Chris Toshok <toshok ximian com>
  */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
-#include "libebackend/e-data-server-module.h"
-#include "libedata-book/e-book-backend-factory.h"
+#include <libedata-book/e-book-backend-factory.h>
 #include "e-book-backend-groupwise.h"
 
-E_BOOK_BACKEND_FACTORY_SIMPLE (groupwise, Groupwise, e_book_backend_groupwise_new)
+#define FACTORY_NAME "groupwise"
 
-static GType  groupwise_type;
+typedef EBookBackendFactory EBookBackendGroupwiseFactory;
+typedef EBookBackendFactoryClass EBookBackendGroupwiseFactoryClass;
 
-void
-eds_module_initialize (GTypeModule *module)
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
+
+/* Forward Declarations */
+GType e_book_backend_groupwise_factory_get_type (void);
+
+G_DEFINE_DYNAMIC_TYPE (
+	EBookBackendGroupwiseFactory,
+	e_book_backend_groupwise_factory,
+	E_TYPE_BOOK_BACKEND_FACTORY)
+
+static void
+e_book_backend_groupwise_factory_class_init (EBookBackendFactoryClass *class)
+{
+	class->factory_name = FACTORY_NAME;
+	class->backend_type = E_TYPE_BOOK_BACKEND_GROUPWISE;
+}
+
+static void
+e_book_backend_groupwise_factory_class_finalize (EBookBackendFactoryClass *class)
+{
+}
+
+static void
+e_book_backend_groupwise_factory_init (EBookBackendFactory *factory)
 {
-	groupwise_type = _groupwise_factory_get_type (module);
 }
 
-void
-eds_module_shutdown (void)
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
 {
+	e_book_backend_groupwise_factory_register_type (type_module);
 }
 
-void
-eds_module_list_types (const GType **types,
-                       gint *num_types)
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
 {
-	*types = & groupwise_type;
-	*num_types = 1;
 }
 
diff --git a/src/addressbook/e-book-backend-groupwise.c b/src/addressbook/e-book-backend-groupwise.c
index dbf5bbc..9e7a945 100644
--- a/src/addressbook/e-book-backend-groupwise.c
+++ b/src/addressbook/e-book-backend-groupwise.c
@@ -83,7 +83,6 @@ struct _EBookBackendGroupwisePrivate {
 	gboolean is_summary_ready;
 	gboolean marked_for_offline;
 	gchar *use_ssl;
-	gboolean is_online;
 	EBookBackendSummary *summary;
 	GMutex *update_cache_mutex;
 	GMutex *update_mutex;
@@ -1236,7 +1235,7 @@ e_book_backend_groupwise_create_contact (EBookBackend *backend,
 
 	egwb = E_BOOK_BACKEND_GROUPWISE (backend);
 
-	if (!egwb->priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		e_data_book_respond_create (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
 		return;
 	}
@@ -1306,7 +1305,7 @@ e_book_backend_groupwise_remove_contacts (EBookBackend *backend,
 
 	ebgw = E_BOOK_BACKEND_GROUPWISE (backend);
 
-	if (!ebgw->priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		e_data_book_respond_remove_contacts (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
 		return;
 	}
@@ -1392,7 +1391,7 @@ e_book_backend_groupwise_modify_contact (EBookBackend *backend,
 		printf ("\ne_book_backend_groupwise_modify_contact...\n");
 	egwb = E_BOOK_BACKEND_GROUPWISE (backend);
 
-	if (!egwb->priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		e_data_book_respond_modify (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
 		return;
 	}
@@ -1478,7 +1477,7 @@ e_book_backend_groupwise_get_contact (EBookBackend *backend,
 
 	gwb =  E_BOOK_BACKEND_GROUPWISE (backend);
 
-	if (!gwb->priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		contact = e_book_backend_db_cache_get_contact (gwb->priv->file_db, id);
 		vcard =  e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30);
 		if (contact) {
@@ -1947,7 +1946,7 @@ e_book_backend_groupwise_get_contact_list (EBookBackend *backend,
 	if (enable_debug)
 		printf ("\ne_book_backend_groupwise_get_contact_list...\n");
 
-	if (!egwb->priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		if (!egwb->priv->file_db) {
 			e_data_book_respond_get_contact_list (book, opid, EDB_ERROR (REPOSITORY_OFFLINE), NULL);
 			return;
@@ -2173,7 +2172,7 @@ book_view_thread (gpointer data)
 	query = e_data_book_view_get_card_query (book_view);
 	if (enable_debug)
 		printf ("get view for query %s \n", query);
-	if (!gwb->priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (gwb))) {
 		if (!gwb->priv->file_db) {
 			e_data_book_view_notify_complete (book_view, NULL /* Success */);
 			return NULL;
@@ -3221,7 +3220,7 @@ e_book_backend_groupwise_authenticate_user (EBookBackend *backend,
 			printf("book_name:%s\n", priv->book_name);
 	}
 
-	if (!ebgw->priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		/* load summary file for offline use */
 		g_mkdir_with_parents (g_path_get_dirname (priv->summary_file_name), 0700);
 		priv->summary = e_book_backend_summary_new (priv->summary_file_name,
@@ -3400,9 +3399,10 @@ e_book_backend_groupwise_open (EBookBackend *backend,
 	EUri *parsed_uri;
 	const gchar *use_ssl;
 	const gchar *offline;
+	gboolean online;
 
 	cache_dir = e_book_backend_get_cache_dir (backend);
-	source = e_book_backend_get_source (backend);
+	source = e_backend_get_source (E_BACKEND (backend));
 
 	if (enable_debug)
 		printf("\ne_book_backend_groupwise_load_source.. \n");
@@ -3556,7 +3556,9 @@ e_book_backend_groupwise_open (EBookBackend *backend,
 		return;
 	}
 
-	if (!priv->is_online &&  !priv->marked_for_offline ) {
+	online = e_backend_get_online (E_BACKEND (backend));
+
+	if (!online &&  !priv->marked_for_offline ) {
 		e_data_book_respond_open (book, opid, EDB_ERROR (OFFLINE_UNAVAILABLE));
 		return;
 	}
@@ -3565,9 +3567,9 @@ e_book_backend_groupwise_open (EBookBackend *backend,
 	priv->only_if_exists = only_if_exists;
 
 	e_book_backend_notify_readonly (backend, TRUE);
-	e_book_backend_notify_online (backend, priv->is_online);
+	e_book_backend_notify_online (backend, online);
 
-	if (!priv->is_online)
+	if (!online)
 		if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
 			g_free (uri);
 			e_uri_free (parsed_uri);
@@ -3589,7 +3591,7 @@ e_book_backend_groupwise_open (EBookBackend *backend,
 	}*/
 
 	e_data_book_respond_open (book, opid, NULL /* Success */);
-	if (!priv->is_online)
+	if (!online)
 		e_book_backend_notify_opened (backend, NULL /* Success */);
 }
 
@@ -3675,17 +3677,19 @@ e_book_backend_groupwise_get_backend_property (EBookBackend *backend,
 }
 
 static void
-e_book_backend_groupwise_set_online (EBookBackend *backend,
-                                     gboolean is_online)
+e_book_backend_groupwise_notify_online_cb (EBookBackend *backend,
+                                           GParamSpec *pspec)
 {
 	EBookBackendGroupwise *bg;
+	gboolean online;
+
+	online = e_backend_get_online (E_BACKEND (backend));
 
 	if (enable_debug)
 		printf ("\ne_book_backend_groupwise_set_mode...\n");
 	bg = E_BOOK_BACKEND_GROUPWISE (backend);
-	bg->priv->is_online = is_online;
 	if (e_book_backend_is_opened (backend)) {
-		if (!is_online) {
+		if (!online) {
 			e_book_backend_notify_readonly (backend, TRUE);
 			e_book_backend_notify_online (backend, FALSE);
 			if (bg->priv->cnc) {
@@ -3835,7 +3839,6 @@ e_book_backend_groupwise_class_init (EBookBackendGroupwiseClass *klass)
 	parent_class->stop_book_view		= e_book_backend_groupwise_stop_book_view;
 	parent_class->authenticate_user		= e_book_backend_groupwise_authenticate_user;
 	parent_class->remove			= e_book_backend_groupwise_remove;
-	parent_class->set_online		= e_book_backend_groupwise_set_online;
 
 	object_class->dispose			= e_book_backend_groupwise_dispose;
 }
@@ -3870,4 +3873,8 @@ e_book_backend_groupwise_init (EBookBackendGroupwise *backend)
 		else
 			enable_debug = FALSE;
 	}
+
+	g_signal_connect (
+		backend, "notify::online",
+		G_CALLBACK (e_book_backend_groupwise_notify_online_cb), NULL);
 }
diff --git a/src/calendar/Makefile.am b/src/calendar/Makefile.am
index 0f9b604..d7b175d 100644
--- a/src/calendar/Makefile.am
+++ b/src/calendar/Makefile.am
@@ -18,7 +18,6 @@ libecalbackendgroupwise_la_CPPFLAGS = \
 
 libecalbackendgroupwise_la_SOURCES =		\
 	e-cal-backend-groupwise-factory.c	\
-	e-cal-backend-groupwise-factory.h	\
 	e-cal-backend-groupwise.c		\
 	e-cal-backend-groupwise.h		\
 	e-cal-backend-groupwise-utils.c		\
diff --git a/src/calendar/e-cal-backend-groupwise-factory.c b/src/calendar/e-cal-backend-groupwise-factory.c
index d750761..db960f8 100644
--- a/src/calendar/e-cal-backend-groupwise-factory.c
+++ b/src/calendar/e-cal-backend-groupwise-factory.c
@@ -7,201 +7,110 @@
  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
  */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
-#include <string.h>
-
-#include "e-cal-backend-groupwise-factory.h"
+#include <libedata-cal/e-cal-backend-factory.h>
 #include "e-cal-backend-groupwise.h"
 
-typedef struct {
-	ECalBackendFactory            parent_object;
-} ECalBackendGroupwiseFactory;
+#define FACTORY_NAME "groupwise"
 
-typedef struct {
-	ECalBackendFactoryClass parent_class;
-} ECalBackendGroupwiseFactoryClass;
+typedef ECalBackendFactory ECalBackendGroupwiseEventsFactory;
+typedef ECalBackendFactoryClass ECalBackendGroupwiseEventsFactoryClass;
 
-static void
-e_cal_backend_groupwise_factory_instance_init (ECalBackendGroupwiseFactory *factory)
-{
-}
+typedef ECalBackendFactory ECalBackendGroupwiseJournalFactory;
+typedef ECalBackendFactoryClass ECalBackendGroupwiseJournalFactoryClass;
 
-static const gchar *
-_get_protocol (ECalBackendFactory *factory)
-{
-	return "groupwise";
-}
+typedef ECalBackendFactory ECalBackendGroupwiseTodosFactory;
+typedef ECalBackendFactoryClass ECalBackendGroupwiseTodosFactoryClass;
 
-static ECalBackend *
-_todos_new_backend (ECalBackendFactory *factory,
-                    ESource *source)
-{
-	return g_object_new (e_cal_backend_groupwise_get_type (),
-			     "source", source,
-			     "kind", ICAL_VTODO_COMPONENT,
-			     NULL);
-}
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
 
-static icalcomponent_kind
-_todos_get_kind (ECalBackendFactory *factory)
-{
-	return ICAL_VTODO_COMPONENT;
-}
+/* Forward Declarations */
+GType e_cal_backend_groupwise_events_factory_get_type (void);
+GType e_cal_backend_groupwise_journal_factory_get_type (void);
+GType e_cal_backend_groupwise_todos_factory_get_type (void);
 
-static ECalBackend *
-_journal_new_backend (ECalBackendFactory *factory,
-                      ESource *source)
-{
-	return g_object_new (e_cal_backend_groupwise_get_type (),
-			     "source", source,
-			     "kind", ICAL_VJOURNAL_COMPONENT,
-			     NULL);
-}
+G_DEFINE_DYNAMIC_TYPE (
+	ECalBackendGroupwiseEventsFactory,
+	e_cal_backend_groupwise_events_factory,
+	E_TYPE_CAL_BACKEND_FACTORY)
 
-static icalcomponent_kind
-_journal_get_kind (ECalBackendFactory *factory)
-{
-	return ICAL_VJOURNAL_COMPONENT;
-}
+G_DEFINE_DYNAMIC_TYPE (
+	ECalBackendGroupwiseJournalFactory,
+	e_cal_backend_groupwise_journal_factory,
+	E_TYPE_CAL_BACKEND_FACTORY)
+
+G_DEFINE_DYNAMIC_TYPE (
+	ECalBackendGroupwiseTodosFactory,
+	e_cal_backend_groupwise_todos_factory,
+	E_TYPE_CAL_BACKEND_FACTORY)
 
-static ECalBackend *
-_events_new_backend (ECalBackendFactory *factory,
-                     ESource *source)
+static void
+e_cal_backend_groupwise_events_factory_class_init (ECalBackendFactoryClass *class)
 {
-	return g_object_new (e_cal_backend_groupwise_get_type (),
-			     "source", source,
-			     "kind", ICAL_VEVENT_COMPONENT,
-			     NULL);
+	class->factory_name = FACTORY_NAME;
+	class->component_kind = ICAL_VEVENT_COMPONENT;
+	class->backend_type = E_TYPE_CAL_BACKEND_GROUPWISE;
 }
 
-static icalcomponent_kind
-_events_get_kind (ECalBackendFactory *factory)
+static void
+e_cal_backend_groupwise_events_factory_class_finalize (ECalBackendFactoryClass *class)
 {
-	return ICAL_VEVENT_COMPONENT;
 }
 
 static void
-todos_backend_factory_class_init (ECalBackendGroupwiseFactoryClass *klass)
+e_cal_backend_groupwise_events_factory_init (ECalBackendFactory *factory)
 {
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_protocol = _get_protocol;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_kind     = _todos_get_kind;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->new_backend  = _todos_new_backend;
 }
 
 static void
-events_backend_factory_class_init (ECalBackendGroupwiseFactoryClass *klass)
+e_cal_backend_groupwise_journal_factory_class_init (ECalBackendFactoryClass *class)
 {
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_protocol = _get_protocol;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_kind     = _events_get_kind;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->new_backend  = _events_new_backend;
+	class->factory_name = FACTORY_NAME;
+	class->component_kind = ICAL_VJOURNAL_COMPONENT;
+	class->backend_type = E_TYPE_CAL_BACKEND_GROUPWISE;
 }
 
 static void
-journal_backend_factory_class_init (ECalBackendGroupwiseFactoryClass *klass)
+e_cal_backend_groupwise_journal_factory_class_finalize (ECalBackendFactoryClass *class)
 {
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_protocol = _get_protocol;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->get_kind     = _journal_get_kind;
-	E_CAL_BACKEND_FACTORY_CLASS (klass)->new_backend  = _journal_new_backend;
 }
 
-static GType
-events_backend_factory_get_type (GTypeModule *module)
+static void
+e_cal_backend_groupwise_journal_factory_init (ECalBackendFactory *factory)
 {
-	GType type;
-
-	GTypeInfo info = {
-		sizeof (ECalBackendGroupwiseFactoryClass),
-		NULL, /* base_class_init */
-		NULL, /* base_class_finalize */
-		(GClassInitFunc)  events_backend_factory_class_init,
-		NULL, /* class_finalize */
-		NULL, /* class_data */
-		sizeof (ECalBackend),
-		0,    /* n_preallocs */
-		(GInstanceInitFunc) e_cal_backend_groupwise_factory_instance_init
-	};
-
-	type = g_type_module_register_type (module,
-					    E_TYPE_CAL_BACKEND_FACTORY,
-					    "ECalBackendGroupwiseEventsFactory",
-					    &info, 0);
-
-	return type;
 }
 
-static GType
-todos_backend_factory_get_type (GTypeModule *module)
+static void
+e_cal_backend_groupwise_todos_factory_class_init (ECalBackendFactoryClass *class)
 {
-	GType type;
-
-	GTypeInfo info = {
-		sizeof (ECalBackendGroupwiseFactoryClass),
-		NULL, /* base_class_init */
-		NULL, /* base_class_finalize */
-		(GClassInitFunc)  todos_backend_factory_class_init,
-		NULL, /* class_finalize */
-		NULL, /* class_data */
-		sizeof (ECalBackend),
-		0,    /* n_preallocs */
-		(GInstanceInitFunc) e_cal_backend_groupwise_factory_instance_init
-	};
-
-	type = g_type_module_register_type (module,
-					    E_TYPE_CAL_BACKEND_FACTORY,
-					    "ECalBackendGroupwiseTodosFactory",
-					    &info, 0);
-
-	return type;
+	class->factory_name = FACTORY_NAME;
+	class->component_kind = ICAL_VTODO_COMPONENT;
+	class->backend_type = E_TYPE_CAL_BACKEND_GROUPWISE;
 }
 
-static GType
-journal_backend_factory_get_type (GTypeModule *module)
+static void
+e_cal_backend_groupwise_todos_factory_class_finalize (ECalBackendFactoryClass *class)
 {
-	GType type;
-
-	GTypeInfo info = {
-		sizeof (ECalBackendGroupwiseFactoryClass),
-		NULL, /* base_class_init */
-		NULL, /* base_class_finalize */
-		(GClassInitFunc)  journal_backend_factory_class_init,
-		NULL, /* class_finalize */
-		NULL, /* class_data */
-		sizeof (ECalBackend),
-		0,    /* n_preallocs */
-		(GInstanceInitFunc) e_cal_backend_groupwise_factory_instance_init
-	};
-
-	type = g_type_module_register_type (module,
-					    E_TYPE_CAL_BACKEND_FACTORY,
-					    "ECalBackendGroupwiseJournalFactory",
-					    &info, 0);
-
-	return type;
 }
-
-
-static GType groupwise_types[3];
 
-void
-eds_module_initialize (GTypeModule *module)
+static void
+e_cal_backend_groupwise_todos_factory_init (ECalBackendFactory *factory)
 {
-	groupwise_types[0] = todos_backend_factory_get_type (module);
-	groupwise_types[1] = events_backend_factory_get_type (module);
-	groupwise_types[2] = journal_backend_factory_get_type (module);
 }
 
-void
-eds_module_shutdown (void)
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
 {
+	e_cal_backend_groupwise_events_factory_register_type (type_module);
+	e_cal_backend_groupwise_journal_factory_register_type (type_module);
+	e_cal_backend_groupwise_todos_factory_register_type (type_module);
 }
 
-void
-eds_module_list_types (const GType **types,
-                       gint *num_types)
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
 {
-	*types = groupwise_types;
-	*num_types = 3;
 }
+
diff --git a/src/calendar/e-cal-backend-groupwise-utils.c b/src/calendar/e-cal-backend-groupwise-utils.c
index d671db5..6770014 100644
--- a/src/calendar/e-cal-backend-groupwise-utils.c
+++ b/src/calendar/e-cal-backend-groupwise-utils.c
@@ -2200,7 +2200,7 @@ e_cal_backend_groupwise_store_settings (GwSettings *hold)
 
 	cbgw = hold->cbgw;
 	opts = hold->opts;
-	source = e_cal_backend_get_source (E_CAL_BACKEND (cbgw));
+	source = e_backend_get_source (E_BACKEND (cbgw));
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
 
 	/* TODO implement send options for Notes */
diff --git a/src/calendar/e-cal-backend-groupwise.c b/src/calendar/e-cal-backend-groupwise.c
index b24ccb8..091b82f 100644
--- a/src/calendar/e-cal-backend-groupwise.c
+++ b/src/calendar/e-cal-backend-groupwise.c
@@ -82,8 +82,6 @@ struct _ECalBackendGroupwisePrivate {
 	gchar *uri;
 	ECredentials *credentials;
 	gchar *container_id;
-	gboolean is_online;
-	gboolean is_online_changed;
 	GHashTable *categories_by_id;
 	GHashTable *categories_by_name;
 
@@ -453,7 +451,8 @@ get_deltas (gpointer handle)
 
 	cbgw = (ECalBackendGroupwise *) handle;
 	priv = cbgw->priv;
-	if (!priv->is_online)
+
+	if (!e_backend_get_online (E_BACKEND (cbgw)))
 		return FALSE;
 
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
@@ -758,7 +757,7 @@ get_cache_refresh_interval (ECalBackendGroupwise *cbgw)
 	ESource *source;
 
 	time_interval = CACHE_REFRESH_INTERVAL;
-	source = e_cal_backend_get_source (backend);
+	source = e_backend_get_source (E_BACKEND (backend));
 
 	time_interval_string = g_getenv ("GETQM_TIME_INTERVAL");
 
@@ -853,7 +852,7 @@ e_cal_backend_groupwise_refresh_calendar (ECalBackendGroupwise *cbgw)
 	ECalBackendGroupwisePrivate *priv = cbgw->priv;
 	gboolean delta_started = FALSE;
 
-	if (!priv->is_online)
+	if (!e_backend_get_online (E_BACKEND (cbgw)))
 		return;
 
 	PRIV_LOCK (priv);
@@ -926,8 +925,6 @@ cache_init (ECalBackendGroupwise *cbgw)
 		g_warning (G_STRLOC ": Could not get the categories from the server");
 	}
 
-	priv->is_online = TRUE;
-
 	/* We poke the cache for a default timezone. Its
 	 * absence indicates that the cache file has not been
 	 * populated before. */
@@ -969,6 +966,7 @@ set_container_id_with_count (ECalBackendGroupwise *cbgw,
 	GList *container_list = NULL, *l;
 	EGwConnectionStatus status;
 	icalcomponent_kind kind;
+	ESource *source;
 
 	priv = cbgw->priv;
 
@@ -978,7 +976,8 @@ set_container_id_with_count (ECalBackendGroupwise *cbgw,
 	case ICAL_VEVENT_COMPONENT:
 	case ICAL_VTODO_COMPONENT:
 	case ICAL_VJOURNAL_COMPONENT:
-		e_source_set_name (e_cal_backend_get_source (E_CAL_BACKEND (cbgw)), _("Calendar"));
+		source = e_backend_get_source (E_BACKEND (cbgw));
+		e_source_set_name (source, _("Calendar"));
 		break;
 	default:
 		priv->container_id = NULL;
@@ -1033,6 +1032,7 @@ connect_to_server (ECalBackendGroupwise *cbgw,
 	gchar *parent_user = NULL;
 	icalcomponent_kind kind;
 	EGwConnectionErrors errors;
+	gboolean online;
 
 	priv = cbgw->priv;
 
@@ -1041,7 +1041,7 @@ connect_to_server (ECalBackendGroupwise *cbgw,
 		return;
 	}
 
-	source = e_cal_backend_get_source (E_CAL_BACKEND (cbgw));
+	source = e_backend_get_source (E_BACKEND (cbgw));
 	real_uri = NULL;
 	if (source)
 		real_uri = form_uri (source);
@@ -1106,13 +1106,13 @@ connect_to_server (ECalBackendGroupwise *cbgw,
 	g_free (real_uri);
 
 	e_cal_backend_notify_readonly (E_CAL_BACKEND (cbgw), cbgw->priv->read_only);
-	e_cal_backend_notify_online (E_CAL_BACKEND (cbgw), priv->is_online);
+
+	online = e_backend_get_online (E_BACKEND (cbgw));
+	e_cal_backend_notify_online (E_CAL_BACKEND (cbgw), online);
 
 	if (priv->cnc ) {
 		if (priv->store && priv->container_id) {
-			priv->is_online = TRUE;
-			if (priv->is_online_changed && !priv->dthread) {
-				priv->is_online_changed = FALSE;
+			if (!priv->dthread) {
 				fetch_deltas (cbgw);
 			}
 
@@ -1132,7 +1132,6 @@ connect_to_server (ECalBackendGroupwise *cbgw,
 			g_free (errors.description);
 		return;
 	}
-	priv->is_online_changed = FALSE;
 
 	if (E_IS_GW_CONNECTION (priv->cnc)) {
 		ECalBackend *backend;
@@ -1291,7 +1290,7 @@ e_cal_backend_groupwise_get_backend_property (ECalBackendSync *backend,
 		cbgw = E_CAL_BACKEND_GROUPWISE (backend);
 		priv = cbgw->priv;
 
-		if (priv->is_online) {
+		if (e_backend_get_online (E_BACKEND (cbgw))) {
 			if (priv->user_email)
 				g_free (priv->user_email);
 
@@ -1370,6 +1369,7 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend,
 	ECalBackendGroupwise *cbgw;
 	ECalBackendGroupwisePrivate *priv;
 	const gchar *cache_dir;
+	gboolean online;
 
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
 	priv = cbgw->priv;
@@ -1379,16 +1379,18 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend,
 	PRIV_LOCK (priv);
 
 	cbgw->priv->read_only = FALSE;
-	e_cal_backend_notify_online (E_CAL_BACKEND (backend), priv->is_online);
 
-	if (!priv->is_online) {
+	online = e_backend_get_online (E_BACKEND (backend));
+	e_cal_backend_notify_online (E_CAL_BACKEND (backend), online);
+
+	if (!online) {
 		ESource *esource;
 		const gchar *display_contents = NULL;
 
 		cbgw->priv->read_only = TRUE;
 		e_cal_backend_notify_readonly (E_CAL_BACKEND (cbgw), cbgw->priv->read_only);
 
-		esource = e_cal_backend_get_source (E_CAL_BACKEND (cbgw));
+		esource = e_backend_get_source (E_BACKEND (cbgw));
 		display_contents = e_source_get_property (esource, "offline_sync");
 
 		if (!display_contents || !g_str_equal (display_contents, "1")) {
@@ -1485,27 +1487,23 @@ e_cal_backend_groupwise_remove (ECalBackendSync *backend,
 
 /* Set_mode handler for the file backend */
 static void
-e_cal_backend_groupwise_set_online (ECalBackend *backend,
-                                    gboolean is_online)
+e_cal_backend_groupwise_notify_online_cb (ECalBackend *backend,
+                                          GParamSpec *pspec)
 {
 	ECalBackendGroupwise *cbgw;
 	ECalBackendGroupwisePrivate *priv;
+	gboolean online;
 
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
 	priv = cbgw->priv;
 
-	if ((priv->is_online ? 1 : 0) == (is_online ? 1 : 0)) {
-		e_cal_backend_notify_online (backend, priv->is_online);
-		return;
-	}
+	online = e_backend_get_online (E_BACKEND (backend));
 
 	PRIV_LOCK (priv);
 
-	priv->is_online = is_online;
-	priv->is_online_changed = TRUE;
-	if (is_online) {
+	if (online) {
 		priv->read_only = FALSE;
-		e_cal_backend_notify_online (backend, priv->is_online);
+		e_cal_backend_notify_online (backend, online);
 		e_cal_backend_notify_readonly (backend, priv->read_only);
 		if (e_cal_backend_is_opened (backend))
 			e_cal_backend_notify_auth_required (backend, TRUE, priv->credentials);
@@ -1513,7 +1511,7 @@ e_cal_backend_groupwise_set_online (ECalBackend *backend,
 		/* FIXME: make sure we update the cache before closing the connection */
 		in_offline (cbgw);
 		e_cal_backend_notify_readonly (backend, priv->read_only);
-		e_cal_backend_notify_online (backend, priv->is_online);
+		e_cal_backend_notify_online (backend, online);
 	}
 
 	PRIV_UNLOCK (priv);
@@ -1713,7 +1711,7 @@ e_cal_backend_groupwise_get_free_busy (ECalBackendSync *backend,
 
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
 
-	if (!cbgw->priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		in_offline (cbgw);
 		g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
 		return;
@@ -1830,7 +1828,7 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend,
 	e_return_data_cal_error_if_fail (in_calobj != NULL, InvalidArg);
 	e_return_data_cal_error_if_fail (new_calobj != NULL, InvalidArg);
 
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		in_offline (cbgw);
 		g_propagate_error (error, EDC_ERROR (RepositoryOffline));
 		return;
@@ -1853,7 +1851,7 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend,
 	e_cal_component_set_icalcomponent (comp, icalcomp);
 
 	/* check if the object exists */
-	if (priv->is_online) {
+	if (e_backend_get_online (E_BACKEND (backend))) {
 		/* when online, send the item to the server */
 		status = e_gw_connection_create_appointment (priv->cnc, priv->container_id, cbgw, comp, &uid_list);
 
@@ -1958,7 +1956,7 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend,
 	e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), InvalidArg);
 	e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
 
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		in_offline (cbgw);
 		g_propagate_error (error, EDC_ERROR (RepositoryOffline));
 		return;
@@ -1976,7 +1974,7 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend,
 	rid = e_cal_component_get_recurid_as_string (comp);
 
 	/* check if the object exists */
-	if (priv->is_online) {
+	if (e_backend_get_online (E_BACKEND (backend))) {
 		while (1) {
 			/* when online, send the item to the server */
 			cache_comp = e_cal_backend_store_get_component (priv->store, uid, rid);
@@ -2121,7 +2119,7 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend,
 	*old_object = *object = NULL;
 
 	/* if online, remove the item from the server */
-	if (priv->is_online) {
+	if (e_backend_get_online (E_BACKEND (backend))) {
 		const gchar *id_to_remove = NULL;
 		icalcomponent *icalcomp;
 
@@ -2480,15 +2478,13 @@ e_cal_backend_groupwise_receive_objects (ECalBackendSync *backend,
                                          GError **perror)
 {
 	ECalBackendGroupwise *cbgw;
-	ECalBackendGroupwisePrivate *priv;
 	icalcomponent *icalcomp, *subcomp;
 	icalcomponent_kind kind;
 	GError *err = NULL;
 
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
-	priv = cbgw->priv;
 
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		in_offline (cbgw);
 		g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
 		return;
@@ -2552,7 +2548,7 @@ send_object (ECalBackendGroupwise *cbgw,
 		return;
 	}
 
-	if (priv->is_online) {
+	if (e_backend_get_online (E_BACKEND (cbgw))) {
 		if (method == ICAL_METHOD_CANCEL) {
 			const gchar *retract_comment = NULL;
 			gboolean all_instances = FALSE;
@@ -2593,16 +2589,14 @@ e_cal_backend_groupwise_send_objects (ECalBackendSync *backend,
 	icalcomponent_kind kind;
 	icalproperty_method method;
 	ECalBackendGroupwise *cbgw;
-	ECalBackendGroupwisePrivate *priv;
 	GError *err = NULL;
 
 	*users = NULL;
 	*modified_calobj = NULL;
 
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
-	priv = cbgw->priv;
 
-	if (!priv->is_online) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		in_offline (cbgw);
 		g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
 		return;
@@ -2682,6 +2676,10 @@ e_cal_backend_groupwise_init (ECalBackendGroupwise *cbgw)
 	cbgw->priv = priv;
 
 	e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbgw), TRUE);
+
+	g_signal_connect (
+		cbgw, "notify::online",
+		G_CALLBACK (e_cal_backend_groupwise_notify_online_cb), NULL);
 }
 
 /* Class initialization function for the gw backend */
@@ -2716,7 +2714,6 @@ e_cal_backend_groupwise_class_init (ECalBackendGroupwiseClass *class)
 	sync_class->get_free_busy_sync		= e_cal_backend_groupwise_get_free_busy;
 
 	backend_class->start_view		= e_cal_backend_groupwise_start_view;
-	backend_class->set_online		= e_cal_backend_groupwise_set_online;
 	backend_class->internal_get_timezone	= e_cal_backend_groupwise_internal_get_timezone;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]