[evolution-mapi] Adapt to libebackend changes.



commit b0e4878dfd54c166c10b5784d02d85586072bac0
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Sep 11 12:31:52 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-mapi-contacts.c |    2 +-
 src/addressbook/e-book-backend-mapi-factory.c  |   77 +++++++--
 src/addressbook/e-book-backend-mapi.c          |   29 ++--
 src/calendar/Makefile.am                       |    1 -
 src/calendar/e-cal-backend-mapi-factory.c      |  206 +++++++-----------------
 src/calendar/e-cal-backend-mapi-factory.h      |   38 -----
 src/calendar/e-cal-backend-mapi.c              |   52 +++---
 7 files changed, 165 insertions(+), 240 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-mapi-contacts.c b/src/addressbook/e-book-backend-mapi-contacts.c
index 1279be6..753da97 100644
--- a/src/addressbook/e-book-backend-mapi-contacts.c
+++ b/src/addressbook/e-book-backend-mapi-contacts.c
@@ -648,7 +648,7 @@ fetch_contacts_uids_cb (FetchItemsCallbackData *item_data, gpointer data)
 static void
 ebbm_contacts_open (EBookBackendMAPI *ebma, GCancellable *cancellable, gboolean only_if_exists, GError **perror)
 {
-	ESource *source = e_book_backend_get_source (E_BOOK_BACKEND (ebma));
+	ESource *source = e_backend_get_source (E_BACKEND (ebma));
 	EBookBackendMAPIContactsPrivate *priv = ((EBookBackendMAPIContacts *) ebma)->priv;
 	GError *err = NULL;
 
diff --git a/src/addressbook/e-book-backend-mapi-factory.c b/src/addressbook/e-book-backend-mapi-factory.c
index 18fec2c..ef10df5 100644
--- a/src/addressbook/e-book-backend-mapi-factory.c
+++ b/src/addressbook/e-book-backend-mapi-factory.c
@@ -21,36 +21,79 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
-#include <libebackend/e-data-server-module.h>
 #include <libedata-book/e-book-backend-factory.h>
-
 #include "e-book-backend-mapi-contacts.h"
 #include "e-book-backend-mapi-gal.h"
 
-E_BOOK_BACKEND_FACTORY_SIMPLE (mapi,    MAPI,    e_book_backend_mapi_contacts_new)
-E_BOOK_BACKEND_FACTORY_SIMPLE (mapigal, MAPIGAL, e_book_backend_mapi_gal_new)
+typedef EBookBackendFactory EBookBackendMapiContactsFactory;
+typedef EBookBackendFactoryClass EBookBackendMapiContactsFactoryClass;
+
+typedef EBookBackendFactory EBookBackendMapiGalFactory;
+typedef EBookBackendFactoryClass EBookBackendMapiGalFactoryClass;
+
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
+
+/* Forward Declarations */
+GType e_book_backend_mapi_contacts_factory_get_type ();
+GType e_book_backend_mapi_gal_factory_get_type ();
+
+G_DEFINE_DYNAMIC_TYPE (
+	EBookBackendMapiContactsFactory,
+	e_book_backend_mapi_contacts_factory,
+	E_TYPE_BOOK_BACKEND_FACTORY)
+
+G_DEFINE_DYNAMIC_TYPE (
+	EBookBackendMapiGalFactory,
+	e_book_backend_mapi_gal_factory,
+	E_TYPE_BOOK_BACKEND_FACTORY)
 
-static GType mapi_type[2];
+static void
+e_book_backend_mapi_contacts_factory_class_init (EBookBackendFactoryClass *class)
+{
+	class->factory_name = "mapi";
+	class->backend_type = E_TYPE_BOOK_BACKEND_MAPI_CONTACTS;
+}
+
+static void
+e_book_backend_mapi_contacts_factory_class_finalize (EBookBackendFactoryClass *class)
+{
+}
 
-void
-eds_module_initialize (GTypeModule *module)
+static void
+e_book_backend_mapi_contacts_factory_init (EBookBackendFactory *factory)
 {
-	mapi_type[0] = _mapi_factory_get_type (module);
-	mapi_type[1] = _mapigal_factory_get_type (module);
 }
 
-void
-eds_module_shutdown (void)
+static void
+e_book_backend_mapi_gal_factory_class_init (EBookBackendFactoryClass *class)
 {
+	class->factory_name = "mapigal";
+	class->backend_type = E_TYPE_BOOK_BACKEND_MAPI_GAL;
 }
 
-void
-eds_module_list_types (const GType **types, gint *num_types)
+static void
+e_book_backend_mapi_gal_factory_class_finalize (EBookBackendFactoryClass *class)
 {
-	*types = mapi_type;
-	*num_types = G_N_ELEMENTS (mapi_type);
 }
+
+static void
+e_book_backend_mapi_gal_factory_init (EBookBackendFactory *factory)
+{
+}
+
+G_MODULE_EXPORT void
+e_module_load (GTypeModule *type_module)
+{
+	e_book_backend_mapi_contacts_factory_register_type (type_module);
+	e_book_backend_mapi_gal_factory_register_type (type_module);
+}
+
+G_MODULE_EXPORT void
+e_module_unload (GTypeModule *type_module)
+{
+}
+
diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index a2ae71a..abc27f3 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -391,7 +391,7 @@ ebbm_connect_user (EBookBackendMAPI *ebma, GCancellable *cancellable, const gcha
 	GError *mapi_error = NULL;
 	ExchangeMapiConnection *old_conn;
 
-	if (!e_book_backend_is_online (E_BOOK_BACKEND (ebma))) {
+	if (!e_backend_get_online (E_BACKEND (ebma))) {
 		ebbm_notify_connection_status (ebma, FALSE);
 	} else {
 		if (priv->update_cache_thread) {
@@ -456,7 +456,7 @@ static void
 ebbm_open (EBookBackendMAPI *ebma, GCancellable *cancellable, gboolean only_if_exists, GError **perror)
 {
 	EBookBackendMAPIPrivate *priv = ebma->priv;
-	ESource *source = e_book_backend_get_source (E_BOOK_BACKEND (ebma));
+	ESource *source = e_backend_get_source (E_BACKEND (ebma));
 	const gchar *offline;
 	const gchar *cache_dir, *krb_sso;
 	GError *error = NULL;
@@ -493,10 +493,10 @@ ebbm_open (EBookBackendMAPI *ebma, GCancellable *cancellable, gboolean only_if_e
 
 	e_book_backend_notify_readonly (E_BOOK_BACKEND (ebma), TRUE);
 
-	ebbm_notify_connection_status (ebma, e_book_backend_is_online (E_BOOK_BACKEND (ebma)));
+	ebbm_notify_connection_status (ebma, e_backend_get_online (E_BACKEND (ebma)));
 
 	/* Either we are in Online mode or this is marked for offline */
-	if (!e_book_backend_is_online (E_BOOK_BACKEND (ebma)) &&
+	if (!e_backend_get_online (E_BACKEND (ebma)) &&
 	    !priv->marked_for_offline) {
 		g_propagate_error (perror, EDB_ERROR (OFFLINE_UNAVAILABLE));
 		e_book_backend_notify_opened (E_BOOK_BACKEND (ebma), EDB_ERROR (OFFLINE_UNAVAILABLE));
@@ -504,7 +504,7 @@ ebbm_open (EBookBackendMAPI *ebma, GCancellable *cancellable, gboolean only_if_e
 	}
 
 	/* Once aunthentication in address book works this can be removed */
-	if (!e_book_backend_is_online (E_BOOK_BACKEND (ebma))) {
+	if (!e_backend_get_online (E_BACKEND (ebma))) {
 		e_book_backend_notify_online (E_BOOK_BACKEND (ebma), FALSE);
 		e_book_backend_notify_opened (E_BOOK_BACKEND (ebma), NULL /* Success */);
 		return;
@@ -597,7 +597,7 @@ ebbm_authenticate_user (EBookBackendMAPI *ebma, GCancellable *cancellable, ECred
 {
 	const gchar *password;
 
-	if (!e_book_backend_is_online (E_BOOK_BACKEND (ebma))) {
+	if (!e_backend_get_online (E_BACKEND (ebma))) {
 		ebbm_notify_connection_status (ebma, FALSE);
 	} else {
 		password = e_credentials_peek (credentials, E_CREDENTIALS_KEY_PASSWORD);
@@ -606,19 +606,22 @@ ebbm_authenticate_user (EBookBackendMAPI *ebma, GCancellable *cancellable, ECred
 }
 
 static void
-ebbm_set_online (EBookBackend *backend, gboolean is_online)
+ebbm_notify_online_cb (EBookBackend *backend, GParamSpec *pspec)
 {
 	EBookBackendMAPI *ebma = E_BOOK_BACKEND_MAPI (backend);
 	EBookBackendMAPIPrivate *priv = ebma->priv;
 	ESource *esource;
 	const gchar *krb_sso = NULL;
+	gboolean online;
 
-	e_book_backend_notify_online (backend, is_online);
+	online = e_backend_get_online (E_BACKEND (backend));
+
+	e_book_backend_notify_online (backend, online);
 	if (e_book_backend_is_opened (backend)) {
 		e_book_backend_mapi_lock_connection (ebma);
 
-		esource = e_book_backend_get_source (E_BOOK_BACKEND (ebma));
-		if (!is_online) {
+		esource = e_backend_get_source (E_BACKEND (ebma));
+		if (!online) {
 			e_book_backend_notify_readonly (backend, TRUE);
 			ebbm_notify_connection_status (ebma, FALSE);
 
@@ -1299,6 +1302,10 @@ e_book_backend_mapi_init (EBookBackendMAPI *ebma)
 
 	ebma->priv->update_cache = g_cancellable_new ();
 	ebma->priv->update_cache_thread = NULL;
+
+	g_signal_connect (
+		ebma, "notify::online",
+		G_CALLBACK (ebbm_notify_online_cb), NULL);
 }
 
 static void
@@ -1362,8 +1369,6 @@ e_book_backend_mapi_class_init (EBookBackendMAPIClass *klass)
 	backend_class->stop_book_view             = ebbm_op_stop_book_view;
 	backend_class->authenticate_user          = ebbm_op_authenticate_user;
 	backend_class->get_backend_property	  = ebbm_op_get_backend_property;
-	backend_class->set_online                 = ebbm_set_online;
-
 	klass->op_open				  = ebbm_open;
 	klass->op_remove                          = ebbm_remove;
 	klass->op_authenticate_user               = ebbm_authenticate_user;
diff --git a/src/calendar/Makefile.am b/src/calendar/Makefile.am
index f29f072..9d2f759 100644
--- a/src/calendar/Makefile.am
+++ b/src/calendar/Makefile.am
@@ -12,7 +12,6 @@ ecal_backend_LTLIBRARIES = libecalbackendmapi.la
 
 libecalbackendmapi_la_SOURCES =			\
 	e-cal-backend-mapi-factory.c		\
-	e-cal-backend-mapi-factory.h		\
 	e-cal-backend-mapi.c			\
 	e-cal-backend-mapi.h
 
diff --git a/src/calendar/e-cal-backend-mapi-factory.c b/src/calendar/e-cal-backend-mapi-factory.c
index 2172551..a5e6460 100644
--- a/src/calendar/e-cal-backend-mapi-factory.c
+++ b/src/calendar/e-cal-backend-mapi-factory.c
@@ -21,194 +21,110 @@
  *
  */
 
-#include "e-cal-backend-mapi-factory.h"
+#include <config.h>
+
+#include <libedata-cal/e-cal-backend-factory.h>
 #include "e-cal-backend-mapi.h"
 
-#define d(x) 
+#define FACTORY_NAME "mapi"
 
-typedef struct {
-	ECalBackendFactory            parent_object;
-} ECalBackendMAPIFactory;
+typedef ECalBackendFactory ECalBackendMapiEventsFactory;
+typedef ECalBackendFactoryClass ECalBackendMapiEventsFactoryClass;
 
-typedef struct {
-	ECalBackendFactoryClass parent_class;
-} ECalBackendMAPIFactoryClass;
+typedef ECalBackendFactory ECalBackendMapiJournalFactory;
+typedef ECalBackendFactoryClass ECalBackendMapiJournalFactoryClass;
 
-static void
-e_cal_backend_mapi_factory_instance_init (ECalBackendMAPIFactory *factory)
-{
-}
+typedef ECalBackendFactory ECalBackendMapiTodosFactory;
+typedef ECalBackendFactoryClass ECalBackendMapiTodosFactoryClass;
 
-static const gchar *
-_get_protocol (ECalBackendFactory *factory)
-{
-	return "mapi";
-}
+/* Module Entry Points */
+void e_module_load (GTypeModule *type_module);
+void e_module_unload (GTypeModule *type_module);
 
-static ECalBackend*
-_todos_new_backend (ECalBackendFactory *factory, ESource *source)
-{
-	return g_object_new (e_cal_backend_mapi_get_type (),
-			     "source", source,
-			     "kind", ICAL_VTODO_COMPONENT,
-			     NULL);
-}
+/* Forward Declarations */
+GType e_cal_backend_mapi_events_factory_get_type (void);
+GType e_cal_backend_mapi_journal_factory_get_type (void);
+GType e_cal_backend_mapi_todos_factory_get_type (void);
 
-static icalcomponent_kind
-_todos_get_kind (ECalBackendFactory *factory)
-{
-	return ICAL_VTODO_COMPONENT;
-}
+G_DEFINE_DYNAMIC_TYPE (
+	ECalBackendMapiEventsFactory,
+	e_cal_backend_mapi_events_factory,
+	E_TYPE_CAL_BACKEND_FACTORY)
 
-static void
-todos_backend_factory_class_init (ECalBackendMAPIFactoryClass *klass)
-{
-	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;
-}
+G_DEFINE_DYNAMIC_TYPE (
+	ECalBackendMapiJournalFactory,
+	e_cal_backend_mapi_journal_factory,
+	E_TYPE_CAL_BACKEND_FACTORY)
 
-static GType
-todos_backend_factory_get_type (GTypeModule *module)
-{
-	GType type;
-
-	GTypeInfo info = {
-		sizeof (ECalBackendMAPIFactoryClass),
-		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_mapi_factory_instance_init
-	};
-
-	type = g_type_module_register_type (module,
-					    E_TYPE_CAL_BACKEND_FACTORY,
-					    "ECalBackendMAPITodosFactory",
-					    &info, 0);
-
-	return type;
-}
+G_DEFINE_DYNAMIC_TYPE (
+	ECalBackendMapiTodosFactory,
+	e_cal_backend_mapi_todos_factory,
+	E_TYPE_CAL_BACKEND_FACTORY)
 
-static ECalBackend*
-_events_new_backend (ECalBackendFactory *factory, ESource *source)
+static void
+e_cal_backend_mapi_events_factory_class_init (ECalBackendFactoryClass *class)
 {
-	return g_object_new (e_cal_backend_mapi_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_MAPI;
 }
 
-static icalcomponent_kind
-_events_get_kind (ECalBackendFactory *factory)
+static void
+e_cal_backend_mapi_events_factory_class_finalize (ECalBackendFactoryClass *class)
 {
-	return ICAL_VEVENT_COMPONENT;
 }
 
 static void
-events_backend_factory_class_init (ECalBackendMAPIFactoryClass *klass)
+e_cal_backend_mapi_events_factory_init (ECalBackendFactory *factory)
 {
-	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;
 }
 
-static GType
-events_backend_factory_get_type (GTypeModule *module)
+static void
+e_cal_backend_mapi_journal_factory_class_init (ECalBackendFactoryClass *class)
 {
-	GType type;
-
-	GTypeInfo info = {
-		sizeof (ECalBackendMAPIFactoryClass),
-		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_mapi_factory_instance_init
-	};
-
-	type = g_type_module_register_type (module,
-					    E_TYPE_CAL_BACKEND_FACTORY,
-					    "ECalBackendMAPIEventsFactory",
-					    &info, 0);
-
-	return type;
+	class->factory_name = FACTORY_NAME;
+	class->component_kind = ICAL_VJOURNAL_COMPONENT;
+	class->backend_type = E_TYPE_CAL_BACKEND_MAPI;
 }
 
-/* NOTE: Outlook "Notes" = Evolution "Memos" */
-static ECalBackend*
-_journal_new_backend (ECalBackendFactory *factory, ESource *source)
+static void
+e_cal_backend_mapi_journal_factory_class_finalize (ECalBackendFactoryClass *class)
 {
-	return g_object_new (e_cal_backend_mapi_get_type (),
-			     "source", source,
-			     "kind", ICAL_VJOURNAL_COMPONENT,
-			     NULL);
 }
 
-static icalcomponent_kind
-_journal_get_kind (ECalBackendFactory *factory)
+static void
+e_cal_backend_mapi_journal_factory_init (ECalBackendFactory *factory)
 {
-	return ICAL_VJOURNAL_COMPONENT;
 }
 
 static void
-journal_backend_factory_class_init (ECalBackendMAPIFactoryClass *klass)
+e_cal_backend_mapi_todos_factory_class_init (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;
+	class->factory_name = FACTORY_NAME;
+	class->component_kind = ICAL_VTODO_COMPONENT;
+	class->backend_type = E_TYPE_CAL_BACKEND_MAPI;
 }
 
-static GType
-journal_backend_factory_get_type (GTypeModule *module)
+static void
+e_cal_backend_mapi_todos_factory_class_finalize (ECalBackendFactoryClass *class)
 {
-	GType type;
-
-	GTypeInfo info = {
-		sizeof (ECalBackendMAPIFactoryClass),
-		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_mapi_factory_instance_init
-	};
-
-	type = g_type_module_register_type (module,
-					    E_TYPE_CAL_BACKEND_FACTORY,
-					    "ECalBackendMAPIJournalFactory",
-					    &info, 0);
-
-	return type;
 }
 
-static GType mapi_types[3];
-
-void
-eds_module_initialize (GTypeModule *module)
+static void
+e_cal_backend_mapi_todos_factory_init (ECalBackendFactory *factory)
 {
-	mapi_types[0] = todos_backend_factory_get_type (module);
-	mapi_types[1] = events_backend_factory_get_type (module);
-	mapi_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_mapi_events_factory_register_type (type_module);
+	e_cal_backend_mapi_journal_factory_register_type (type_module);
+	e_cal_backend_mapi_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 = mapi_types;
-	*num_types = 3;
 }
 
diff --git a/src/calendar/e-cal-backend-mapi.c b/src/calendar/e-cal-backend-mapi.c
index 790b096..b71a3d8 100644
--- a/src/calendar/e-cal-backend-mapi.c
+++ b/src/calendar/e-cal-backend-mapi.c
@@ -264,9 +264,9 @@ ecbm_remove (ECalBackend *backend, EDataCal *cal, GCancellable *cancellable, GEr
 	cbmapi = E_CAL_BACKEND_MAPI (backend);
 	priv = cbmapi->priv;
 
-	source = e_cal_backend_get_source (E_CAL_BACKEND (cbmapi));
+	source = e_backend_get_source (E_BACKEND (cbmapi));
 
-	if (!e_cal_backend_is_online (backend) || !priv->conn || !exchange_mapi_connection_connected (priv->conn)) {
+	if (!e_backend_get_online (E_BACKEND (backend)) || !priv->conn || !exchange_mapi_connection_connected (priv->conn)) {
 		g_propagate_error (perror, EDC_ERROR (RepositoryOffline));
 		return;
 	}
@@ -341,7 +341,7 @@ notify_view_progress (ECalBackendMAPI *cbmapi, guint64 index, guint64 total)
 
 	/* To translators: This message is displayed on the status bar when calendar/tasks/memo items are being fetched from the server. */
 	progress_string = g_strdup_printf (_("Loading items in folder %s"),
-				e_source_peek_name (e_cal_backend_get_source (E_CAL_BACKEND (cbmapi))));
+				e_source_peek_name (e_backend_get_source (E_BACKEND (cbmapi))));
 
 	pd.msg = progress_string;
 
@@ -617,8 +617,8 @@ get_deltas (gpointer handle)
 	cbmapi = (ECalBackendMAPI *) handle;
 	priv= cbmapi->priv;
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbmapi));
-	source = e_cal_backend_get_source (E_CAL_BACKEND (cbmapi));
-	if (!e_cal_backend_is_online (E_CAL_BACKEND (cbmapi)))
+	source = e_backend_get_source (E_BACKEND (cbmapi));
+	if (!e_backend_get_online (E_BACKEND (cbmapi)))
 		return FALSE;
 
 	g_mutex_lock (priv->updating_mutex);
@@ -1106,7 +1106,7 @@ populate_cache (ECalBackendMAPI *cbmapi, GError **perror)
 	priv->populating_cache = TRUE;
 	g_mutex_unlock (priv->mutex);
 
-	source = e_cal_backend_get_source (E_CAL_BACKEND (cbmapi));
+	source = e_backend_get_source (E_BACKEND (cbmapi));
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbmapi));
 
 	itt_current = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
@@ -1288,7 +1288,7 @@ ecbm_open (ECalBackend *backend, EDataCal *cal, GCancellable *cancellable, gbool
 	cbmapi = E_CAL_BACKEND_MAPI (backend);
 	priv = cbmapi->priv;
 
-	esource = e_cal_backend_get_source (E_CAL_BACKEND (cbmapi));
+	esource = e_backend_get_source (E_BACKEND (cbmapi));
 	fid = e_source_get_property (esource, "folder-id");
 	if (!(fid && *fid)) {
 		g_propagate_error (perror, EDC_ERROR_EX (OtherError, "No folder ID set"));
@@ -1332,7 +1332,7 @@ ecbm_open (ECalBackend *backend, EDataCal *cal, GCancellable *cancellable, gbool
 	e_cal_backend_store_load (priv->store);
 
 	/* Not for remote */
-	if (!e_cal_backend_is_online (backend)) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		const gchar *display_contents = NULL;
 
 		cbmapi->priv->read_only = TRUE;
@@ -1574,7 +1574,7 @@ ecbm_create_object (ECalBackend *backend, EDataCal *cal, GCancellable *cancellab
 	e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
 	e_return_data_cal_error_if_fail (new_object != NULL, InvalidArg);
 
-	if (!e_cal_backend_is_online (backend)) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		g_propagate_error (error, EDC_ERROR (RepositoryOffline));
 		return;
 	}
@@ -1629,7 +1629,7 @@ ecbm_create_object (ECalBackend *backend, EDataCal *cal, GCancellable *cancellab
 	cbdata.get_tz_data = cbmapi;
 
 	/* Check if object exists */
-	if (e_cal_backend_is_online (backend)) {
+	if (e_backend_get_online (E_BACKEND (backend))) {
 		/* Create an appointment */
 		cbdata.comp = comp;
 		cbdata.is_modify = FALSE;
@@ -1769,7 +1769,7 @@ ecbm_modify_object (ECalBackend *backend, EDataCal *cal, GCancellable *cancellab
 	e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
 	e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
 
-	if (!e_cal_backend_is_online (backend)) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		g_propagate_error (error, EDC_ERROR (RepositoryOffline));
 		return;
 	}
@@ -1827,7 +1827,7 @@ ecbm_modify_object (ECalBackend *backend, EDataCal *cal, GCancellable *cancellab
 	cbdata.get_timezone = (icaltimezone * (*)(gpointer data, const gchar *tzid)) ecbm_internal_get_timezone;
 	cbdata.get_tz_data = cbmapi;
 
-	if (e_cal_backend_is_online (backend)) {
+	if (e_backend_get_online (E_BACKEND (backend))) {
 		/* when online, send the item to the server */
 		/* check if the object exists */
 		cache_comp = e_cal_backend_store_get_component (priv->store, uid, rid);
@@ -1927,7 +1927,7 @@ ecbm_remove_object (ECalBackend *backend, EDataCal *cal, GCancellable *cancellab
 
 	e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
 
-	if (!e_cal_backend_is_online (backend)) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		g_propagate_error (error, EDC_ERROR (RepositoryOffline));
 		return;
 	}
@@ -2028,7 +2028,7 @@ ecbm_send_objects (ECalBackend *backend, EDataCal *cal, GCancellable *cancellabl
 	e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
 	e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
 
-	if (!e_cal_backend_is_online (backend)) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		g_propagate_error (error, EDC_ERROR (RepositoryOffline));
 		return;
 	}
@@ -2224,7 +2224,7 @@ ecbm_receive_objects (ECalBackend *backend, EDataCal *cal, GCancellable *cancell
 	e_return_data_cal_error_if_fail (E_IS_CAL_BACKEND_MAPI (cbmapi), InvalidArg);
 	e_return_data_cal_error_if_fail (calobj != NULL, InvalidArg);
 
-	if (!e_cal_backend_is_online (backend)) {
+	if (!e_backend_get_online (E_BACKEND (backend))) {
 		g_propagate_error (error, EDC_ERROR (RepositoryOffline));
 		return;
 	}
@@ -2476,32 +2476,29 @@ ecbm_start_view (ECalBackend *backend, EDataCalView *view)
 }
 
 static void
-ecbm_set_online (ECalBackend *backend, gboolean is_online)
+ecbm_notify_online_cb (ECalBackend *backend, GParamSpec *pspec)
 {
 	ECalBackendMAPI *cbmapi;
 	ECalBackendMAPIPrivate *priv;
 	ESource *esource = NULL;
-	gboolean re_open = FALSE;
 	const gchar *krb_sso = NULL;
+	gboolean online;
 
 	cbmapi = E_CAL_BACKEND_MAPI (backend);
 	priv = cbmapi->priv;
 
-	if ((e_cal_backend_is_online (backend) ? 1 : 0) == (is_online ? 1 : 0)) {
-		return;
-	}
+	online = e_backend_get_online (E_BACKEND (backend));
 
 	g_mutex_lock (priv->mutex);
 
-	esource = e_cal_backend_get_source (E_CAL_BACKEND (cbmapi));
+	esource = e_backend_get_source (E_BACKEND (cbmapi));
 	krb_sso = e_source_get_property (esource, "kerberos");
-	re_open = (e_cal_backend_is_online (backend) ? 1 : 0) < (is_online ? 1 : 0);
-	e_cal_backend_notify_online (backend, is_online);
+	e_cal_backend_notify_online (backend, online);
 
 	priv->mode_changed = TRUE;
-	if (is_online) {
+	if (online) {
 		priv->read_only = FALSE;
-		if (e_cal_backend_is_opened (backend) && re_open
+		if (e_cal_backend_is_opened (backend)
 		    && ! (krb_sso && g_str_equal (krb_sso, "required"))) {
 			e_cal_backend_notify_auth_required (backend, TRUE, NULL);
 		}
@@ -3457,7 +3454,6 @@ e_cal_backend_mapi_class_init (ECalBackendMAPIClass *class)
 	backend_class->start_view = ecbm_op_start_view;
 
 	/* functions done synchronously */
-	backend_class->set_online = ecbm_set_online;
 	backend_class->internal_get_timezone = ecbm_internal_get_timezone;
 }
 
@@ -3478,4 +3474,8 @@ e_cal_backend_mapi_init (ECalBackendMAPI *cbmapi)
 	priv->op_queue = em_operation_queue_new ((EMOperationQueueFunc) ecbm_operation_cb, cbmapi);
 
 	cbmapi->priv = priv;
+
+	g_signal_connect (
+		cbmapi, "notify::online",
+		G_CALLBACK (ecbm_notify_online_cb), NULL);
 }



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