[evolution-data-server] libedata-book cleanups.



commit f0eef4fd9501eb26048afff9623a21f8552b4f1c
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Jun 27 09:24:33 2011 -0400

    libedata-book cleanups.

 addressbook/libedata-book/Makefile.am           |  126 ++++++------
 addressbook/libedata-book/e-data-book-factory.c |  243 ++++++++++++++---------
 2 files changed, 213 insertions(+), 156 deletions(-)
---
diff --git a/addressbook/libedata-book/Makefile.am b/addressbook/libedata-book/Makefile.am
index 1fdb207..f25c1d6 100644
--- a/addressbook/libedata-book/Makefile.am
+++ b/addressbook/libedata-book/Makefile.am
@@ -8,38 +8,38 @@ ENUM_GENERATED = e-data-book-enumtypes.h e-data-book-enumtypes.c
 # The library
 lib_LTLIBRARIES = libedata-book-1.2.la
 
-libedata_book_1_2_la_CPPFLAGS =				\
-	$(AM_CPPFLAGS)					\
-	-DG_LOG_DOMAIN=\"libedata-book\"		\
-	-DLIBEXECDIR=\"$(libexecdir)\"			\
-	-I$(top_srcdir)					\
-	-I$(top_srcdir)/addressbook			\
-	-I$(top_srcdir)/addressbook/libegdbus		\
-	-I$(top_builddir)				\
-	-I$(top_builddir)/addressbook			\
-	$(DB_CFLAGS)					\
-	$(SQLITE3_CFLAGS)					\
+libedata_book_1_2_la_CPPFLAGS = \
+	$(AM_CPPFLAGS) \
+	-DG_LOG_DOMAIN=\"libedata-book\" \
+	-DLIBEXECDIR=\"$(libexecdir)\" \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/addressbook \
+	-I$(top_srcdir)/addressbook/libegdbus \
+	-I$(top_builddir) \
+	-I$(top_builddir)/addressbook \
+	$(DB_CFLAGS) \
+	$(SQLITE3_CFLAGS) \
 	$(EVOLUTION_ADDRESSBOOK_CFLAGS)
 
-libedata_book_1_2_la_SOURCES =				\
-	e-book-backend-factory.c			\
-	e-book-backend-sexp.c				\
-	e-book-backend-summary.c			\
-	e-book-backend-cache.c                          \
-	e-book-backend-db-cache.c                       \
-	e-book-backend-sqlitedb.c			\
-	e-book-backend-sync.c				\
-	e-book-backend.c				\
-	e-data-book-view.c				\
-	e-data-book.c					\
-	ximian-vcard.h					\
+libedata_book_1_2_la_SOURCES = \
+	e-book-backend-factory.c \
+	e-book-backend-sexp.c \
+	e-book-backend-summary.c \
+	e-book-backend-cache.c \
+	e-book-backend-db-cache.c \
+	e-book-backend-sqlitedb.c \
+	e-book-backend-sync.c \
+	e-book-backend.c \
+	e-data-book-view.c \
+	e-data-book.c \
+	ximian-vcard.h \
 	$(ENUM_GENERATED)
 
-libedata_book_1_2_la_LIBADD =					\
-	$(top_builddir)/addressbook/libegdbus/libegdbus-book.la	\
-	$(top_builddir)/addressbook/libebook/libebook-1.2.la	\
-	$(top_builddir)/libedataserver/libedataserver-1.2.la	\
-	$(top_builddir)/libebackend/libebackend-1.2.la	\
+libedata_book_1_2_la_LIBADD = \
+	$(top_builddir)/addressbook/libegdbus/libegdbus-book.la \
+	$(top_builddir)/addressbook/libebook/libebook-1.2.la \
+	$(top_builddir)/libedataserver/libedataserver-1.2.la \
+	$(top_builddir)/libebackend/libebackend-1.2.la \
 	$(DB_LIBS) \
 	$(SQLITE3_LIBS) \
 	$(EVOLUTION_ADDRESSBOOK_LIBS)
@@ -49,55 +49,55 @@ libedata_book_1_2_la_LDFLAGS = \
 
 libedata_bookincludedir = $(privincludedir)/libedata-book
 
-libedata_bookinclude_HEADERS =				\
-	e-book-backend-factory.h			\
-	e-book-backend-sexp.h				\
-	e-book-backend-summary.h			\
-	e-book-backend-sync.h				\
-	e-book-backend.h				\
-	e-data-book-factory.h				\
-	e-data-book-types.h				\
-	e-data-book-view.h				\
-	e-data-book.h                                   \
-	e-book-backend-cache.h 				\
-	e-book-backend-sqlitedb.h			\
+libedata_bookinclude_HEADERS = \
+	e-book-backend-factory.h \
+	e-book-backend-sexp.h \
+	e-book-backend-summary.h \
+	e-book-backend-sync.h \
+	e-book-backend.h \
+	e-data-book-factory.h \
+	e-data-book-types.h \
+	e-data-book-view.h \
+	e-data-book.h \
+	e-book-backend-cache.h \
+	e-book-backend-sqlitedb.h \
 	e-book-backend-db-cache.h
 
 factorydir = $(libexecdir)
 
 noinst_PROGRAMS = e-book-backend-sqlitedb-test
 
-e_book_backend_sqlitedb_test_CPPFLAGS =					\
+e_book_backend_sqlitedb_test_CPPFLAGS = \
 	$(libedata_book_1_2_la_CPPFLAGS)
 e_book_backend_sqlitedb_test_SOURCES =	e-book-backend-sqlitedb-test.c
-e_book_backend_sqlitedb_test_LDADD = 					\
-	libedata-book-1.2.la                                    \
+e_book_backend_sqlitedb_test_LDADD = \
+	$(top_builddir)/addressbook/libedata-book/libedata-book-1.2.la \
 	$(libedata_book_1_2_la_LIBADD)
 
 factory_PROGRAMS = e-addressbook-factory
 
 e_addressbook_factory_CPPFLAGS = \
-	$(AM_CPPFLAGS)				\
-	$(EVOLUTION_ADDRESSBOOK_CFLAGS)		\
-	-DG_LOG_DOMAIN=\"libedata-book\"	\
-	-DE_PRGNAME=\"e-addressbook-factory\"	\
-	-DBACKENDDIR=\"$(ebook_backenddir)\"	\
-	-I$(top_srcdir)				\
-	-I$(top_srcdir)/addressbook		\
-	-I$(top_srcdir)/addressbook/libegdbus	\
-	-I$(top_builddir)			\
-	-I$(top_builddir)/addressbook
+	$(AM_CPPFLAGS) \
+	-DG_LOG_DOMAIN=\"libedata-book\" \
+	-DE_PRGNAME=\"e-addressbook-factory\" \
+	-DBACKENDDIR=\"$(ebook_backenddir)\" \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/addressbook \
+	-I$(top_srcdir)/addressbook/libegdbus \
+	-I$(top_builddir) \
+	-I$(top_builddir)/addressbook \
+	$(EVOLUTION_ADDRESSBOOK_CFLAGS)
 
 e_addressbook_factory_SOURCES = \
 	e-data-book-factory.c \
 	e-data-book-factory.h \
 	e-data-book-migrate-basedir.c
 
-e_addressbook_factory_LDADD =					\
-	libedata-book-1.2.la					\
-	$(EVOLUTION_ADDRESSBOOK_LIBS)				\
-	$(top_builddir)/libedataserver/libedataserver-1.2.la	\
-	$(top_builddir)/libebackend/libebackend-1.2.la
+e_addressbook_factory_LDADD = \
+	$(top_builddir)/addressbook/libedata-book/libedata-book-1.2.la \
+	$(top_builddir)/libedataserver/libedataserver-1.2.la \
+	$(top_builddir)/libebackend/libebackend-1.2.la \
+	$(EVOLUTION_ADDRESSBOOK_LIBS)
 
 %-$(API_VERSION).pc: %.pc
 	 cp $< $@
@@ -114,11 +114,11 @@ BUILT_SOURCES = $(ENUM_GENERATED)
 CLEANFILES = $(BUILT_SOURCES) $(service_DATA)
 DISTCLEANFILES = $(pkgconfig_DATA)
 
-EXTRA_DIST = 						\
-	e-data-book-factory.xml				\
-	e-data-book-view.xml				\
-	e-data-book.xml					\
-	$(pkgconfig_DATA:-$(API_VERSION).pc=.pc.in)	\
+EXTRA_DIST = \
+	e-data-book-factory.xml \
+	e-data-book-view.xml \
+	e-data-book.xml \
+	$(pkgconfig_DATA:-$(API_VERSION).pc=.pc.in) \
 	$(service_in_files)
 
 -include $(top_srcdir)/git.mk
diff --git a/addressbook/libedata-book/e-data-book-factory.c b/addressbook/libedata-book/e-data-book-factory.c
index f26012f..d395f0b 100644
--- a/addressbook/libedata-book/e-data-book-factory.c
+++ b/addressbook/libedata-book/e-data-book-factory.c
@@ -54,19 +54,25 @@
 
 #define d(x)
 
+#define E_DATA_BOOK_FACTORY_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_DATA_BOOK_FACTORY, EDataBookFactoryPrivate))
+
 static GMainLoop *loop;
 
 /* Keep running after the last client is closed. */
 static gboolean opt_keep_running = FALSE;
 
 /* Convenience macro to test and set a GError/return on failure */
-#define g_set_error_val_if_fail(test, returnval, error, domain, code) G_STMT_START{ \
-		if G_LIKELY (test) {} else {					\
-			g_set_error_literal (error, domain, code, #test);	\
-			g_warning (#test " failed");				\
-			return (returnval);					\
-		}								\
-	}G_STMT_END
+#define g_set_error_val_if_fail(test, returnval, error, domain, code) \
+	G_STMT_START {							\
+	if G_LIKELY (test) {						\
+	} else {							\
+		g_set_error_literal (error, domain, code, #test);	\
+		g_warning (#test " failed");				\
+		return (returnval);					\
+	}								\
+	} G_STMT_END
 
 G_DEFINE_TYPE (EDataBookFactory, e_data_book_factory, G_TYPE_OBJECT);
 
@@ -91,7 +97,7 @@ struct _EDataBookFactoryPrivate {
 	guint exit_timeout;
 
 	/* whether should be online */
-        gboolean is_online;
+	gboolean is_online;
 };
 
 /* Forward Declarations */
@@ -147,11 +153,15 @@ e_data_book_factory_register_backend (EDataBookFactory *book_factory,
 static void
 e_data_book_factory_register_backends (EDataBookFactory *book_factory)
 {
-	GList *factories, *f;
+	GType type;
+	GList *factories;
+	GList *iter;
+
+	type = E_TYPE_BOOK_BACKEND_FACTORY;
+	factories = e_data_server_get_extensions_for_type (type);
 
-	factories = e_data_server_get_extensions_for_type (E_TYPE_BOOK_BACKEND_FACTORY);
-	for (f = factories; f; f = f->next) {
-		EBookBackendFactory *backend_factory = f->data;
+	for (iter = factories; iter != NULL; iter = g_list_next (iter)) {
+		EBookBackendFactory *backend_factory = iter->data;
 
 		e_data_book_factory_register_backend (
 			book_factory, g_object_ref (backend_factory));
@@ -161,16 +171,6 @@ e_data_book_factory_register_backends (EDataBookFactory *book_factory)
 	e_data_server_module_remove_unused ();
 }
 
-static void
-set_backend_online_status (gpointer key, gpointer value, gpointer data)
-{
-	EBookBackend *backend = E_BOOK_BACKEND (value);
-
-	g_return_if_fail (backend != NULL);
-
-	e_book_backend_set_online (backend,  GPOINTER_TO_INT (data));
-}
-
 /**
  * e_data_book_factory_set_backend_online:
  * @factory: A bookendar factory.
@@ -179,16 +179,23 @@ set_backend_online_status (gpointer key, gpointer value, gpointer data)
  * Sets the online mode for all backends created by the given factory.
  */
 void
-e_data_book_factory_set_backend_online (EDataBookFactory *factory, gboolean is_online)
+e_data_book_factory_set_backend_online (EDataBookFactory *factory,
+                                        gboolean is_online)
 {
+	GHashTableIter iter;
+	gpointer value;
+
 	g_return_if_fail (E_IS_DATA_BOOK_FACTORY (factory));
 
 	factory->priv->is_online = is_online;
 	g_mutex_lock (factory->priv->backends_lock);
-	g_hash_table_foreach (
-		factory->priv->backends,
-		set_backend_online_status,
-		GINT_TO_POINTER (factory->priv->is_online));
+
+	g_hash_table_iter_init (&iter, factory->priv->backends);
+	while (g_hash_table_iter_next (&iter, NULL, &value))
+		e_book_backend_set_online (
+			E_BOOK_BACKEND (value),
+			factory->priv->is_online);
+
 	g_mutex_unlock (factory->priv->backends_lock);
 }
 
@@ -247,7 +254,8 @@ remove_dead_pointer_cb (gpointer path, gpointer live, gpointer dead)
 }
 
 static void
-book_freed_cb (EDataBookFactory *factory, GObject *dead)
+book_freed_cb (EDataBookFactory *factory,
+               GObject *dead)
 {
 	EDataBookFactoryPrivate *priv = factory->priv;
 	GHashTableIter iter;
@@ -255,7 +263,8 @@ book_freed_cb (EDataBookFactory *factory, GObject *dead)
 
 	d (g_debug ("in factory %p (%p) is dead", factory, dead));
 
-	g_hash_table_foreach_remove (priv->books, remove_dead_pointer_cb, dead);
+	g_hash_table_foreach_remove (
+		priv->books, remove_dead_pointer_cb, dead);
 
 	g_hash_table_iter_init (&iter, priv->connections);
 	while (g_hash_table_iter_next (&iter, &hkey, &hvalue)) {
@@ -284,20 +293,24 @@ book_freed_cb (EDataBookFactory *factory, GObject *dead)
 }
 
 static void
-backend_gone_cb (EDataBookFactory *factory, GObject *dead)
+backend_gone_cb (EDataBookFactory *factory,
+                 GObject *dead)
 {
 	EDataBookFactoryPrivate *priv = factory->priv;
 
 	g_mutex_lock (priv->backends_lock);
-	g_hash_table_foreach_remove (priv->backends, remove_dead_pointer_cb, dead);
+	g_hash_table_foreach_remove (
+		priv->backends, remove_dead_pointer_cb, dead);
 	g_mutex_unlock (priv->backends_lock);
 }
 
 static void
-last_client_gone_cb (EBookBackend *backend, EDataBookFactory *factory)
+last_client_gone_cb (EBookBackend *backend,
+                     EDataBookFactory *factory)
 {
 	backend_gone_cb (factory, (GObject *) backend);
-	g_object_weak_unref (G_OBJECT (backend), (GWeakNotify) backend_gone_cb, factory);
+	g_object_weak_unref (
+		G_OBJECT (backend), (GWeakNotify) backend_gone_cb, factory);
 	g_object_unref (backend);
 }
 
@@ -310,6 +323,7 @@ impl_BookFactory_get_book (EGdbusBookFactory *object,
 	EDataBook *book;
 	EBookBackend *backend;
 	EDataBookFactoryPrivate *priv = factory->priv;
+	GDBusConnection *connection;
 	ESource *source;
 	gchar *path;
 	gchar *uri;
@@ -317,8 +331,14 @@ impl_BookFactory_get_book (EGdbusBookFactory *object,
 	GList *list;
 	GError *error = NULL;
 
+	sender = g_dbus_method_invocation_get_sender (invocation);
+	connection = g_dbus_method_invocation_get_connection (invocation);
+
 	if (in_source == NULL || in_source[0] == '\0') {
-		error = g_error_new (E_DATA_BOOK_ERROR, E_DATA_BOOK_STATUS_NO_SUCH_BOOK, _("Empty URI"));
+		error = g_error_new (
+			E_DATA_BOOK_ERROR,
+			E_DATA_BOOK_STATUS_NO_SUCH_BOOK,
+			_("Empty URI"));
 		g_dbus_method_invocation_return_gerror (invocation, error);
 		g_error_free (error);
 
@@ -331,7 +351,10 @@ impl_BookFactory_get_book (EGdbusBookFactory *object,
 	if (!source) {
 		g_mutex_unlock (priv->backends_lock);
 
-		error = g_error_new (E_DATA_BOOK_ERROR, E_DATA_BOOK_STATUS_NO_SUCH_BOOK, _("Invalid source"));
+		error = g_error_new (
+			E_DATA_BOOK_ERROR,
+			E_DATA_BOOK_STATUS_NO_SUCH_BOOK,
+			_("Invalid source"));
 		g_dbus_method_invocation_return_gerror (invocation, error);
 		g_error_free (error);
 
@@ -345,7 +368,10 @@ impl_BookFactory_get_book (EGdbusBookFactory *object,
 		g_object_unref (source);
 		g_free (uri);
 
-		error = g_error_new (E_DATA_BOOK_ERROR, E_DATA_BOOK_STATUS_NO_SUCH_BOOK, _("Empty URI"));
+		error = g_error_new (
+			E_DATA_BOOK_ERROR,
+			E_DATA_BOOK_STATUS_NO_SUCH_BOOK,
+			_("Empty URI"));
 		g_dbus_method_invocation_return_gerror (invocation, error);
 		g_error_free (error);
 
@@ -403,14 +429,13 @@ impl_BookFactory_get_book (EGdbusBookFactory *object,
 	book = e_data_book_new (backend, source);
 	g_hash_table_insert (priv->books, g_strdup (path), book);
 	e_book_backend_add_client (backend, book);
-	e_data_book_register_gdbus_object (book, g_dbus_method_invocation_get_connection (invocation), path, &error);
+	e_data_book_register_gdbus_object (book, connection, path, &error);
 	g_object_weak_ref (
 		G_OBJECT (book), (GWeakNotify)
 		book_freed_cb, factory);
 
 	/* Update the hash of open connections */
 	g_mutex_lock (priv->connections_lock);
-	sender = g_dbus_method_invocation_get_sender (invocation);
 	list = g_hash_table_lookup (priv->connections, sender);
 	list = g_list_prepend (list, book);
 	g_hash_table_insert (priv->connections, g_strdup (sender), list);
@@ -422,7 +447,8 @@ impl_BookFactory_get_book (EGdbusBookFactory *object,
 	g_object_unref (source);
 	g_free (uri);
 
-	e_gdbus_book_factory_complete_get_book (object, invocation, path, error);
+	e_gdbus_book_factory_complete_get_book (
+		object, invocation, path, error);
 
 	if (error)
 		g_error_free (error);
@@ -448,20 +474,75 @@ remove_data_book_cb (gpointer data_bk, gpointer user_data)
 }
 
 static void
+e_data_book_factory_dispose (GObject *object)
+{
+	EDataBookFactoryPrivate *priv;
+
+	priv = E_DATA_BOOK_FACTORY_GET_PRIVATE (object);
+
+	if (priv->gdbus_object != NULL) {
+		g_object_unref (priv->gdbus_object);
+		priv->gdbus_object = NULL;
+	}
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_data_book_factory_parent_class)->dispose (object);
+}
+
+static void
+e_data_book_factory_finalize (GObject *object)
+{
+	EDataBookFactoryPrivate *priv;
+
+	priv = E_DATA_BOOK_FACTORY_GET_PRIVATE (object);
+
+	g_hash_table_destroy (priv->factories);
+	g_hash_table_destroy (priv->backends);
+	g_hash_table_destroy (priv->books);
+	g_hash_table_destroy (priv->connections);
+
+	g_mutex_free (priv->backends_lock);
+	g_mutex_free (priv->books_lock);
+	g_mutex_free (priv->connections_lock);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (e_data_book_factory_parent_class)->finalize (object);
+}
+
+static void
+e_data_book_factory_class_init (EDataBookFactoryClass *class)
+{
+	GObjectClass *object_class;
+
+	g_type_class_add_private (class, sizeof (EDataBookFactoryPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->dispose = e_data_book_factory_dispose;
+	object_class->finalize = e_data_book_factory_finalize;
+}
+
+static void
 e_data_book_factory_init (EDataBookFactory *factory)
 {
 	GError *error = NULL;
 
-	factory->priv = G_TYPE_INSTANCE_GET_PRIVATE (
-		factory, E_TYPE_DATA_BOOK_FACTORY, EDataBookFactoryPrivate);
+	factory->priv = E_DATA_BOOK_FACTORY_GET_PRIVATE (factory);
 
 	factory->priv->gdbus_object = e_gdbus_book_factory_stub_new ();
-	g_signal_connect (factory->priv->gdbus_object, "handle-get-book", G_CALLBACK (impl_BookFactory_get_book), factory);
+	g_signal_connect (
+		factory->priv->gdbus_object, "handle-get-book",
+		G_CALLBACK (impl_BookFactory_get_book), factory);
 
-	factory->priv->factories = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+	factory->priv->factories = g_hash_table_new_full (
+		g_str_hash, g_str_equal,
+		(GDestroyNotify) g_free,
+		(GDestroyNotify) NULL);
 
 	factory->priv->backends_lock = g_mutex_new ();
-	factory->priv->backends = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+	factory->priv->backends = g_hash_table_new_full (
+		g_str_hash, g_str_equal,
+		(GDestroyNotify) g_free,
+		(GDestroyNotify) NULL);
 
 	factory->priv->books_lock = g_mutex_new ();
 	factory->priv->books = g_hash_table_new_full (
@@ -481,73 +562,49 @@ e_data_book_factory_init (EDataBookFactory *factory)
 	e_data_book_factory_register_backends (factory);
 }
 
-static void
-e_data_book_factory_finalize (GObject *object)
-{
-	EDataBookFactory *factory = E_DATA_BOOK_FACTORY (object);
-
-	g_return_if_fail (factory != NULL);
-
-	g_object_unref (factory->priv->gdbus_object);
-
-	g_hash_table_destroy (factory->priv->factories);
-	g_hash_table_destroy (factory->priv->backends);
-	g_hash_table_destroy (factory->priv->books);
-	g_hash_table_destroy (factory->priv->connections);
-
-	g_mutex_free (factory->priv->backends_lock);
-	g_mutex_free (factory->priv->books_lock);
-	g_mutex_free (factory->priv->connections_lock);
-
-	/* Chain up to parent's finalize() method. */
-	G_OBJECT_CLASS (e_data_book_factory_parent_class)->finalize (object);
-}
-
-static void
-e_data_book_factory_class_init (EDataBookFactoryClass *klass)
-{
-	GObjectClass *object_class;
-
-	g_type_class_add_private (klass, sizeof (EDataBookFactoryPrivate));
-
-	object_class = G_OBJECT_CLASS (klass);
-	object_class->finalize = e_data_book_factory_finalize;
-}
-
 static guint
-e_data_book_factory_register_gdbus_object (EDataBookFactory *factory, GDBusConnection *connection, const gchar *object_path, GError **error)
+e_data_book_factory_register_gdbus_object (EDataBookFactory *factory,
+                                           GDBusConnection *connection,
+                                           const gchar *object_path,
+                                           GError **error)
 {
-	g_return_val_if_fail (factory != NULL, 0);
 	g_return_val_if_fail (E_IS_DATA_BOOK_FACTORY (factory), 0);
 	g_return_val_if_fail (connection != NULL, 0);
 	g_return_val_if_fail (object_path != NULL, 0);
 
-	return e_gdbus_book_factory_register_object (factory->priv->gdbus_object, connection, object_path, error);
+	return e_gdbus_book_factory_register_object (
+		factory->priv->gdbus_object, connection, object_path, error);
 }
 
 /* Convenience function to print an error and exit */
 G_GNUC_NORETURN static void
 die (const gchar *prefix, GError *error)
 {
-	g_error("%s: %s", prefix, error->message);
+	g_error ("%s: %s", prefix, error->message);
 	g_error_free (error);
 	exit (1);
 }
 
 static void
-offline_state_changed_cb (EOfflineListener *eol, EDataBookFactory *factory)
+offline_state_changed_cb (EOfflineListener *eol,
+                          EDataBookFactory *factory)
 {
-	EOfflineListenerState state = e_offline_listener_get_state (eol);
-
-	g_return_if_fail (state == EOL_STATE_ONLINE || state == EOL_STATE_OFFLINE);
-
-	e_data_book_factory_set_backend_online (factory, state == EOL_STATE_ONLINE);
+	switch (e_offline_listener_get_state (eol)) {
+		case EOL_STATE_OFFLINE:
+			e_data_book_factory_set_backend_online (factory, FALSE);
+			break;
+		case EOL_STATE_ONLINE:
+			e_data_book_factory_set_backend_online (factory, TRUE);
+			break;
+		default:
+			g_warn_if_reached ();
+	}
 }
 
 static void
 on_bus_acquired (GDBusConnection *connection,
-                 const gchar     *name,
-                 gpointer         user_data)
+                 const gchar *name,
+                 gpointer user_data)
 {
 	EDataBookFactory *factory = user_data;
 	guint registration_id;
@@ -567,15 +624,15 @@ on_bus_acquired (GDBusConnection *connection,
 
 static void
 on_name_acquired (GDBusConnection *connection,
-                  const gchar     *name,
-                  gpointer         user_data)
+                  const gchar *name,
+                  gpointer user_data)
 {
 }
 
 static void
 on_name_lost (GDBusConnection *connection,
-              const gchar     *name,
-              gpointer         user_data)
+              const gchar *name,
+              gpointer user_data)
 {
 	GList *list = NULL;
 	gchar *key;



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