[evolution-data-server] Bug 669487 - Fix up online notification (part 1)



commit 9604329b68d2029b7e39a2d609480bd072e0ce84
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Feb 7 09:21:01 2012 -0600

    Bug 669487 - Fix up online notification (part 1)
    
    Make E-D-S listen to the "start-offline" GSettings key (not GConf),
    since Evolution no longer sets the GConf key.
    
    Unfortunately we can't rely on the schema from Evolution, so we install
    our own minimal schema that refers to the same DConf path as the
    Evolution one.  This allows us to share state with no dependency issues.
    
    This is a temporary solution for 3.4 only, to be removed in 3.5.

 configure.ac                                       |    2 +
 libebackend/Makefile.am                            |    6 ++
 libebackend/e-data-factory.c                       |   57 ++++++--------------
 .../org.gnome.evolution.eds-shell.gschema.xml      |   14 +++++
 4 files changed, 39 insertions(+), 40 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c7bbc5d..a911456 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,6 +55,8 @@ EDS_MAJOR_VERSION=eds_major_version
 EDS_MINOR_VERSION=eds_minor_version
 EDS_MICRO_VERSION=eds_micro_version
 
+GLIB_GSETTINGS
+
 dnl ******************************
 dnl D-Bus versioning
 dnl ******************************
diff --git a/libebackend/Makefile.am b/libebackend/Makefile.am
index 562afce..56f7154 100644
--- a/libebackend/Makefile.am
+++ b/libebackend/Makefile.am
@@ -55,7 +55,13 @@ libebackendinclude_HEADERS =		\
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libebackend-$(API_VERSION).pc
 
+gsettings_SCHEMAS = \
+	org.gnome.evolution.eds-shell.gschema.xml
+
+ GSETTINGS_RULES@
+
 EXTRA_DIST = 						\
+	$(gsettings_SCHEMAS)				\
 	$(pkgconfig_DATA:-$(API_VERSION).pc=.pc.in)
 
 DISTCLEANFILES = $(pkgconfig_DATA)
diff --git a/libebackend/e-data-factory.c b/libebackend/e-data-factory.c
index 8975575..f596e42 100644
--- a/libebackend/e-data-factory.c
+++ b/libebackend/e-data-factory.c
@@ -25,7 +25,6 @@
 #include "e-data-factory.h"
 
 #include <config.h>
-#include <gconf/gconf-client.h>
 
 #include <libebackend/e-extensible.h>
 #include <libebackend/e-backend-factory.h>
@@ -47,8 +46,7 @@ struct _EDataFactoryPrivate {
 	/* Hash Key -> EBackendFactory */
 	GHashTable *backend_factories;
 
-	GConfClient *gconf_client;
-	guint gconf_cnxn_id;
+	GSettings *settings;
 
 	gboolean online;
 };
@@ -67,16 +65,14 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (
 	G_IMPLEMENT_INTERFACE (E_TYPE_EXTENSIBLE, NULL))
 
 static void
-data_factory_online_changed (GConfClient *client,
-                             guint cnxn_id,
-                             GConfEntry *entry,
+data_factory_online_changed (GSettings *settings,
+                             const gchar *key,
                              EDataFactory *factory)
 {
-	GConfValue *value;
 	gboolean start_offline;
 
-	value = gconf_entry_get_value (entry);
-	start_offline = gconf_value_get_bool (value);
+	start_offline = g_settings_get_boolean (
+		factory->priv->settings, "start-offline");
 
 	e_data_factory_set_online (factory, !start_offline);
 }
@@ -84,8 +80,8 @@ data_factory_online_changed (GConfClient *client,
 static void
 data_factory_init_online_monitoring (EDataFactory *factory)
 {
+	const gchar *schema;
 	gboolean start_offline;
-	GError *error = NULL;
 
 	/* XXX For the record, we're doing this completely wrong.
 	 *     EDataFactory should monitor network availability itself
@@ -93,34 +89,17 @@ data_factory_init_online_monitoring (EDataFactory *factory)
 	 *     to tell us when we're offline.  But I'll deal with this
 	 *     at some later date. */
 
-	factory->priv->gconf_client = gconf_client_get_default ();
+	schema = "org.gnome.evolution.eds-shell";
+	factory->priv->settings = g_settings_new (schema);
 
-	gconf_client_add_dir (
-		factory->priv->gconf_client,
-		"/apps/evolution/shell",
-		GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
-
-	gconf_client_notify_add (
-		factory->priv->gconf_client,
-		"/apps/evolution/shell/start_offline",
-		(GConfClientNotifyFunc) data_factory_online_changed,
-		factory, (GFreeFunc) NULL, &error);
-
-	if (error != NULL) {
-		g_warning ("%s", error->message);
-		g_clear_error (&error);
-	}
+	g_signal_connect (
+		factory->priv->settings, "changed::start-offline",
+		G_CALLBACK (data_factory_online_changed), factory);
 
-	start_offline = gconf_client_get_bool (
-		factory->priv->gconf_client,
-		"/apps/evolution/shell/start_offline", &error);
+	start_offline = g_settings_get_boolean (
+		factory->priv->settings, "start-offline");
 
-	if (error == NULL) {
-		e_data_factory_set_online (factory, !start_offline);
-	} else {
-		g_warning ("%s", error->message);
-		g_clear_error (&error);
-	}
+	e_data_factory_set_online (factory, !start_offline);
 }
 
 static void
@@ -183,11 +162,9 @@ data_factory_dispose (GObject *object)
 	g_hash_table_remove_all (priv->backends);
 	g_hash_table_remove_all (priv->backend_factories);
 
-	if (priv->gconf_client != NULL) {
-		gconf_client_notify_remove (
-			priv->gconf_client, priv->gconf_cnxn_id);
-		g_object_unref (priv->gconf_client);
-		priv->gconf_client = NULL;
+	if (priv->settings != NULL) {
+		g_object_unref (priv->settings);
+		priv->settings = NULL;
 	}
 
 	/* Chain up to parent's dispose() method. */
diff --git a/libebackend/org.gnome.evolution.eds-shell.gschema.xml b/libebackend/org.gnome.evolution.eds-shell.gschema.xml
new file mode 100644
index 0000000..cc7a367
--- /dev/null
+++ b/libebackend/org.gnome.evolution.eds-shell.gschema.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+  <!-- This is a partial copy of org.gnome.evolution.shell, with just the start-offline key, refering
+       to the same path, so that this state can be shared without having to depend on the schemas
+       from the full evolution.
+       This will be removed in later releases of e-d-s -->
+  <schema path="/org/gnome/evolution/shell/" id="org.gnome.evolution.eds-shell">
+    <key type="b" name="start-offline">
+      <default>false</default>
+      <summary>Start in offline mode</summary>
+      <description>Whether Evolution will start up in offline mode instead of online mode.</description>
+    </key>
+  </schema>
+</schemalist>



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