[network-manager-applet] applet: migrate preferences from GConf to GSettings



commit 7863ecb8e6e994477d3ae4230cb86ca39f5286ca
Author: Dan Williams <dcbw redhat com>
Date:   Wed Jul 25 18:54:20 2012 -0500

    applet: migrate preferences from GConf to GSettings

 src/gconf-helpers/gconf-helpers.c |    2 -
 src/gconf-helpers/gconf-helpers.h |    1 +
 src/migration-tool.c              |   56 +++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 2 deletions(-)
---
diff --git a/src/gconf-helpers/gconf-helpers.c b/src/gconf-helpers/gconf-helpers.c
index c244671..7df5015 100644
--- a/src/gconf-helpers/gconf-helpers.c
+++ b/src/gconf-helpers/gconf-helpers.c
@@ -75,8 +75,6 @@
 #define DBUS_TYPE_G_IP6_ROUTE               (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
 #define DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE      (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_IP6_ROUTE))
 
-#define APPLET_PREFS_PATH "/apps/nm-applet"
-
 /* The stamp is a mechanism for determining which applet version last
  * updated GConf for various GConf update tasks in newer applet versions.
  */
diff --git a/src/gconf-helpers/gconf-helpers.h b/src/gconf-helpers/gconf-helpers.h
index 2a1aca0..0833c7b 100644
--- a/src/gconf-helpers/gconf-helpers.h
+++ b/src/gconf-helpers/gconf-helpers.h
@@ -30,6 +30,7 @@
 #include "utils.h"
 
 #define GCONF_PATH_CONNECTIONS "/system/networking/connections"
+#define APPLET_PREFS_PATH "/apps/nm-applet"
 
 #define KEYRING_UUID_TAG "connection-uuid"
 #define KEYRING_SN_TAG "setting-name"
diff --git a/src/migration-tool.c b/src/migration-tool.c
index f7e44ad..903eb43 100644
--- a/src/migration-tool.c
+++ b/src/migration-tool.c
@@ -29,6 +29,7 @@
 #include <nm-remote-settings.h>
 
 #include "gconf-helpers.h"
+#include "applet.h"
 
 gboolean success = TRUE;
 
@@ -62,6 +63,59 @@ import_cb (NMConnection *connection, gpointer user_data)
 	}
 }
 
+#define GC_PREF_DISABLE_CONNECTED_NOTIFICATIONS      APPLET_PREFS_PATH "/disable-connected-notifications"
+#define GC_PREF_DISABLE_DISCONNECTED_NOTIFICATIONS   APPLET_PREFS_PATH "/disable-disconnected-notifications"
+#define GC_PREF_DISABLE_VPN_NOTIFICATIONS            APPLET_PREFS_PATH "/disable-vpn-notifications"
+#define GC_PREF_DISABLE_WIFI_CREATE                  APPLET_PREFS_PATH "/disable-wifi-create"
+#define GC_PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE APPLET_PREFS_PATH "/suppress-wireless-networks-available"
+
+typedef struct {
+	const char *gc_path;
+	const char *gs_name;
+} Items;
+
+static const Items convert[] = {
+	{ GC_PREF_DISABLE_CONNECTED_NOTIFICATIONS,      PREF_DISABLE_CONNECTED_NOTIFICATIONS },
+	{ GC_PREF_DISABLE_DISCONNECTED_NOTIFICATIONS,   PREF_DISABLE_DISCONNECTED_NOTIFICATIONS },
+	{ GC_PREF_DISABLE_VPN_NOTIFICATIONS,            PREF_DISABLE_VPN_NOTIFICATIONS },
+	{ GC_PREF_DISABLE_WIFI_CREATE,                  PREF_DISABLE_WIFI_CREATE },
+	{ GC_PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE, PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE },
+};
+
+static void
+convert_prefs (void)
+{
+	GSettings *gs;
+	GConfClient *gc;
+	int stamp;
+	gboolean b;
+	GError *error = NULL;
+	guint i;
+
+	gc = gconf_client_get_default ();
+	if (!gc)
+		return;
+
+	gs = g_settings_new (APPLET_PREFS_SCHEMA);
+	g_assert (gs);
+	stamp = g_settings_get_int (gs, "stamp");
+	if (stamp == 0) {
+		for (i = 0; i < G_N_ELEMENTS (convert); i++) {
+			b = gconf_client_get_bool (gc, convert[i].gc_path, &error);
+			if (!error)
+				g_settings_set_boolean (gs, convert[i].gs_name, b);
+			g_clear_error (&error);
+		}
+
+		/* stamps start back at 1 with GSettings */
+		g_settings_set_int (gs, "stamp", 1);
+		g_settings_sync ();
+	}
+
+	g_object_unref (gc);
+	g_object_unref (gs);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -93,6 +147,8 @@ main (int argc, char **argv)
 	g_object_unref (settings);
 	dbus_g_connection_unref (bus);
 
+	convert_prefs ();
+
 	return success ? 0 : 1;
 }
 



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