[evolution] Bug #570730 - Get rid of gnome-config in Evolution



commit 8f2b4f9c6554698af19a39223acc33f965e2dfca
Author: Milan Crha <mcrha redhat com>
Date:   Thu Apr 30 16:56:58 2009 +0200

    Bug #570730 - Get rid of gnome-config in Evolution
---
 addressbook/conduit/address-conduit.c              |  147 +++++++++++++++---
 calendar/conduits/calendar/calendar-conduit.c      |   27 +--
 .../conduits/common/libecalendar-common-conduit.c  |  166 ++++++++++++++++++++
 .../conduits/common/libecalendar-common-conduit.h  |    6 +
 calendar/conduits/memo/memo-conduit.c              |   28 +---
 calendar/conduits/todo/todo-conduit.c              |   28 +---
 mail/em-migrate.c                                  |  100 ------------
 mail/mail-session.c                                |    1 -
 8 files changed, 321 insertions(+), 182 deletions(-)

diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c
index 4cf0c12..6340b99 100644
--- a/addressbook/conduit/address-conduit.c
+++ b/addressbook/conduit/address-conduit.c
@@ -44,7 +44,6 @@
 #include <gpilotd/gnome-pilot-conduit-sync-abs.h>
 #include <libgpilotdCM/gnome-pilot-conduit-management.h>
 #include <libgpilotdCM/gnome-pilot-conduit-config.h>
-#include <libgnome/gnome-config.h>
 #include <e-dialog-widgets.h>
 #include <e-pilot-map.h>
 #include <e-pilot-settings.h>
@@ -346,6 +345,119 @@ void e_pilot_remote_category_to_local(int pilotCategory,
 	}
 }
 
+static char *
+build_setup_path (const char *path, const char *key)
+{
+	return g_strconcat ("/apps/evolution/conduit", "/", path, "/", key, NULL);
+}
+
+static gboolean
+e_pilot_setup_get_bool (const char *path, const char *key, gboolean def)
+{
+	gboolean res = def;
+	char *full_path;
+	GConfValue *value;
+	GConfClient *gconf;
+
+	g_return_val_if_fail (path != NULL, res);
+	g_return_val_if_fail (key != NULL, res);
+
+	gconf = gconf_client_get_default ();
+	full_path = build_setup_path (path, key);
+
+	value = gconf_client_get (gconf, full_path, NULL);
+	if (value) {
+		if (value->type == GCONF_VALUE_BOOL)
+			res = gconf_value_get_bool (value);
+
+		gconf_value_free (value);
+	}
+
+	g_free (full_path);
+	g_object_unref (gconf);
+
+	return res;
+}
+
+static void
+e_pilot_setup_set_bool (const char *path, const char *key, gboolean value)
+{
+	GError *error = NULL;
+	char *full_path;
+	GConfClient *gconf;
+
+	g_return_if_fail (path != NULL);
+	g_return_if_fail (key != NULL);
+
+	gconf = gconf_client_get_default ();
+	full_path = build_setup_path (path, key);
+
+	gconf_client_set_bool (gconf, full_path, value, &error);
+
+	g_free (full_path);
+	g_object_unref (gconf);
+
+	if (error) {
+		g_message ("%s: Failed to write: %s", G_STRFUNC, error->message);
+		g_error_free (error);
+	}
+}
+
+static char *
+e_pilot_setup_get_string (const char *path, const char *key, const char *def)
+{
+	char *res = g_strdup (def);
+	char *full_path;
+	GConfValue *value;
+	GConfClient *gconf;
+
+	g_return_val_if_fail (path != NULL, res);
+	g_return_val_if_fail (key != NULL, res);
+
+	gconf = gconf_client_get_default ();
+	full_path = build_setup_path (path, key);
+
+	value = gconf_client_get (gconf, full_path, NULL);
+	if (value) {
+		if (value->type == GCONF_VALUE_STRING) {
+			g_free (res);
+			res = g_strdup (gconf_value_get_string (value));
+		}
+
+		gconf_value_free (value);
+	}
+
+	g_free (full_path);
+	g_object_unref (gconf);
+
+	return res;
+}
+
+static void
+e_pilot_setup_set_string (const char *path, const char *key, const char *value)
+{
+	GError *error = NULL;
+	char *full_path;
+	GConfClient *gconf;
+
+	g_return_if_fail (path != NULL);
+	g_return_if_fail (key != NULL);
+	g_return_if_fail (value != NULL);
+
+	gconf = gconf_client_get_default ();
+	full_path = build_setup_path (path, key);
+
+	gconf_client_set_string (gconf, full_path, value, &error);
+
+	g_free (full_path);
+	g_object_unref (gconf);
+
+	if (error) {
+		g_message ("%s: Failed to write: %s", G_STRFUNC, error->message);
+		g_error_free (error);
+	}
+}
+
 static EAddrConduitCfg *
 addrconduit_load_configuration (guint32 pilot_id)
 {
@@ -353,8 +465,7 @@ addrconduit_load_configuration (guint32 pilot_id)
 	GnomePilotConduitManagement *management;
 	GnomePilotConduitConfig *config;
 	gchar *address, prefix[256];
-	g_snprintf (prefix, 255, "/gnome-pilot.d/e-address-conduit/Pilot_%u/",
-		    pilot_id);
+	g_snprintf (prefix, 255, "e-address-conduit/Pilot_%u", pilot_id);
 
 	c = g_new0 (EAddrConduitCfg,1);
 	g_assert (c != NULL);
@@ -370,8 +481,6 @@ addrconduit_load_configuration (guint32 pilot_id)
 	g_object_unref (management);
 
 	/* Custom settings */
-	gnome_config_push_prefix (prefix);
-
 	if (!e_book_get_addressbooks (&c->source_list, NULL))
 		c->source_list = NULL;
 	if (c->source_list) {
@@ -386,18 +495,16 @@ addrconduit_load_configuration (guint32 pilot_id)
 		}
 	}
 
-	c->secret = gnome_config_get_bool ("secret=FALSE");
-	address = gnome_config_get_string ("default_address=business");
-	if (!strcmp (address, "business"))
+	c->secret = e_pilot_setup_get_bool (prefix, "secret", FALSE);
+	address = e_pilot_setup_get_string (prefix, "default_address", "business");
+	if (!address || !strcmp (address, "business"))
 		c->default_address = E_CONTACT_ADDRESS_WORK;
 	else if (!strcmp (address, "home"))
 		c->default_address = E_CONTACT_ADDRESS_HOME;
 	else if (!strcmp (address, "other"))
 		c->default_address = E_CONTACT_ADDRESS_OTHER;
 	g_free (address);
-	c->last_uri = gnome_config_get_string ("last_uri");
-
-	gnome_config_pop_prefix ();
+	c->last_uri = e_pilot_setup_get_string (prefix, "last_uri", NULL);
 
 	return c;
 }
@@ -407,30 +514,24 @@ addrconduit_save_configuration (EAddrConduitCfg *c)
 {
 	gchar prefix[256];
 
-	g_snprintf (prefix, 255, "/gnome-pilot.d/e-address-conduit/Pilot_%u/",
-		    c->pilot_id);
+	g_snprintf (prefix, 255, "e-address-conduit/Pilot_%u", c->pilot_id);
 
-	gnome_config_push_prefix (prefix);
 	e_pilot_set_sync_source (c->source_list, c->source);
-	gnome_config_set_bool ("secret", c->secret);
+	e_pilot_setup_set_bool (prefix, "secret", c->secret);
 	switch (c->default_address) {
 	case E_CONTACT_ADDRESS_WORK:
-		gnome_config_set_string ("default_address", "business");
+		e_pilot_setup_set_string (prefix, "default_address", "business");
 		break;
 	case E_CONTACT_ADDRESS_HOME:
-		gnome_config_set_string ("default_address", "home");
+		e_pilot_setup_set_string (prefix, "default_address", "home");
 		break;
 	case E_CONTACT_ADDRESS_OTHER:
-		gnome_config_set_string ("default_address", "other");
+		e_pilot_setup_set_string (prefix, "default_address", "other");
 		break;
 	default:
 		g_warning ("Unknown default_address value");
 	}
-	gnome_config_set_string ("last_uri", c->last_uri);
-	gnome_config_pop_prefix ();
-
-	gnome_config_sync ();
-	gnome_config_drop_all ();
+	e_pilot_setup_set_string (prefix, "last_uri", c->last_uri ? c->last_uri : "");
 }
 
 static EAddrConduitCfg*
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index f936e33..e7e5f57 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -28,7 +28,6 @@
 #define G_LOG_DOMAIN "ecalconduit"
 
 #include <glib/gi18n.h>
-#include <libgnome/gnome-config.h>
 #include <libecal/e-cal-types.h>
 #include <libecal/e-cal.h>
 #include <libecal/e-cal-time-util.h>
@@ -134,8 +133,7 @@ calconduit_load_configuration (guint32 pilot_id)
 	g_object_unref (management);
 
 	/* Custom settings */
-	g_snprintf (prefix, 255, "/gnome-pilot.d/e-calendar-conduit/Pilot_%u/", pilot_id);
-	gnome_config_push_prefix (prefix);
+	g_snprintf (prefix, 255, "e-calendar-conduit/Pilot_%u", pilot_id);
 
 	if (!e_cal_get_sources (&c->source_list, E_CAL_SOURCE_TYPE_EVENT, NULL))
 		c->source_list = NULL;
@@ -150,9 +148,9 @@ calconduit_load_configuration (guint32 pilot_id)
 			c->source_list = NULL;
 		}
 	}
-	c->secret = gnome_config_get_bool ("secret=FALSE");
-	c->multi_day_split = gnome_config_get_bool ("multi_day_split=TRUE");
-	if ((c->last_uri = gnome_config_get_string ("last_uri")) && !strncmp (c->last_uri, "file://", 7)) {
+	c->secret = e_pilot_setup_get_bool (prefix, "secret", FALSE);
+	c->multi_day_split = e_pilot_setup_get_bool (prefix, "multi_day_split", TRUE);
+	if ((c->last_uri = e_pilot_setup_get_string (prefix, "last_uri", NULL)) && !strncmp (c->last_uri, "file://", 7)) {
 		char *filename = g_filename_from_uri (c->last_uri, NULL, NULL);
 		const char *path = filename;
 		const char *home;
@@ -178,8 +176,6 @@ calconduit_load_configuration (guint32 pilot_id)
 		g_free (filename);
 	}
 
-	gnome_config_pop_prefix ();
-
 	return c;
 }
 
@@ -188,18 +184,13 @@ calconduit_save_configuration (ECalConduitCfg *c)
 {
 	gchar prefix[256];
 
-	g_snprintf (prefix, 255, "/gnome-pilot.d/e-calendar-conduit/Pilot_%u/", c->pilot_id);
-	gnome_config_push_prefix (prefix);
+	g_snprintf (prefix, 255, "e-calendar-conduit/Pilot_%u", c->pilot_id);
 
 	e_pilot_set_sync_source (c->source_list, c->source);
-	gnome_config_set_bool ("secret", c->secret);
-	gnome_config_set_bool ("multi_day_split", c->multi_day_split);
-	gnome_config_set_string ("last_uri", c->last_uri);
-
-	gnome_config_pop_prefix ();
-
-	gnome_config_sync ();
-	gnome_config_drop_all ();
+	
+	e_pilot_setup_set_bool (prefix, "secret", c->secret);
+	e_pilot_setup_set_bool (prefix, "multi_day_split", c->multi_day_split);
+	e_pilot_setup_set_string (prefix, "last_uri", c->last_uri ? c->last_uri : "");
 }
 
 static ECalConduitCfg*
diff --git a/calendar/conduits/common/libecalendar-common-conduit.c b/calendar/conduits/common/libecalendar-common-conduit.c
index 1b7013b..fbbe027 100644
--- a/calendar/conduits/common/libecalendar-common-conduit.c
+++ b/calendar/conduits/common/libecalendar-common-conduit.c
@@ -29,6 +29,7 @@
 #include <e-pilot-util.h>
 #include <pi-appinfo.h>
 #include <glib.h>
+#include <gconf/gconf-client.h>
 
 #include "libecalendar-common-conduit.h"
 
@@ -204,3 +205,168 @@ void e_pilot_remote_category_to_local(int pilotCategory, ECalComponent *comp, st
 		e_cal_component_free_categories_list(c_list);
 	}
 }
+
+static char *
+build_setup_path (const char *path, const char *key)
+{
+	return g_strconcat ("/apps/evolution/conduit", "/", path, "/", key, NULL);
+}
+
+gboolean
+e_pilot_setup_get_bool (const char *path, const char *key, gboolean def)
+{
+	gboolean res = def;
+	char *full_path;
+	GConfValue *value;
+	GConfClient *gconf;
+
+	g_return_val_if_fail (path != NULL, res);
+	g_return_val_if_fail (key != NULL, res);
+
+	gconf = gconf_client_get_default ();
+	full_path = build_setup_path (path, key);
+
+	value = gconf_client_get (gconf, full_path, NULL);
+	if (value) {
+		if (value->type == GCONF_VALUE_BOOL)
+			res = gconf_value_get_bool (value);
+
+		gconf_value_free (value);
+	}
+
+	g_free (full_path);
+	g_object_unref (gconf);
+
+	return res;
+}
+
+void
+e_pilot_setup_set_bool (const char *path, const char *key, gboolean value)
+{
+	GError *error = NULL;
+	char *full_path;
+	GConfClient *gconf;
+
+	g_return_if_fail (path != NULL);
+	g_return_if_fail (key != NULL);
+
+	gconf = gconf_client_get_default ();
+	full_path = build_setup_path (path, key);
+
+	gconf_client_set_bool (gconf, full_path, value, &error);
+
+	g_free (full_path);
+	g_object_unref (gconf);
+
+	if (error) {
+		g_message ("%s: Failed to write: %s", G_STRFUNC, error->message);
+		g_error_free (error);
+	}
+}
+
+int
+e_pilot_setup_get_int (const char *path, const char *key, int def)
+{
+	int res = def;
+	char *full_path;
+	GConfValue *value;
+	GConfClient *gconf;
+
+	g_return_val_if_fail (path != NULL, res);
+	g_return_val_if_fail (key != NULL, res);
+
+	gconf = gconf_client_get_default ();
+	full_path = build_setup_path (path, key);
+
+	value = gconf_client_get (gconf, full_path, NULL);
+	if (value) {
+		if (value->type == GCONF_VALUE_INT)
+			res = gconf_value_get_int (value);
+
+		gconf_value_free (value);
+	}
+
+	g_free (full_path);
+	g_object_unref (gconf);
+
+	return res;
+}
+
+void
+e_pilot_setup_set_int (const char *path, const char *key, int value)
+{
+	GError *error = NULL;
+	char *full_path;
+	GConfClient *gconf;
+
+	g_return_if_fail (path != NULL);
+	g_return_if_fail (key != NULL);
+
+	gconf = gconf_client_get_default ();
+	full_path = build_setup_path (path, key);
+
+	gconf_client_set_int (gconf, full_path, value, &error);
+
+	g_free (full_path);
+	g_object_unref (gconf);
+
+	if (error) {
+		g_message ("%s: Failed to write: %s", G_STRFUNC, error->message);
+		g_error_free (error);
+	}
+}
+
+char *
+e_pilot_setup_get_string (const char *path, const char *key, const char *def)
+{
+	char *res = g_strdup (def);
+	char *full_path;
+	GConfValue *value;
+	GConfClient *gconf;
+
+	g_return_val_if_fail (path != NULL, res);
+	g_return_val_if_fail (key != NULL, res);
+
+	gconf = gconf_client_get_default ();
+	full_path = build_setup_path (path, key);
+
+	value = gconf_client_get (gconf, full_path, NULL);
+	if (value) {
+		if (value->type == GCONF_VALUE_STRING) {
+			g_free (res);
+			res = g_strdup (gconf_value_get_string (value));
+		}
+
+		gconf_value_free (value);
+	}
+
+	g_free (full_path);
+	g_object_unref (gconf);
+
+	return res;
+}
+
+void
+e_pilot_setup_set_string (const char *path, const char *key, const char *value)
+{
+	GError *error = NULL;
+	char *full_path;
+	GConfClient *gconf;
+
+	g_return_if_fail (path != NULL);
+	g_return_if_fail (key != NULL);
+	g_return_if_fail (value != NULL);
+
+	gconf = gconf_client_get_default ();
+	full_path = build_setup_path (path, key);
+
+	gconf_client_set_string (gconf, full_path, value, &error);
+
+	g_free (full_path);
+	g_object_unref (gconf);
+
+	if (error) {
+		g_message ("%s: Failed to write: %s", G_STRFUNC, error->message);
+		g_error_free (error);
+	}
+}
diff --git a/calendar/conduits/common/libecalendar-common-conduit.h b/calendar/conduits/common/libecalendar-common-conduit.h
index e168e00..0641ec3 100644
--- a/calendar/conduits/common/libecalendar-common-conduit.h
+++ b/calendar/conduits/common/libecalendar-common-conduit.h
@@ -29,3 +29,9 @@ int e_pilot_add_category_if_possible(char *cat_to_add, struct CategoryAppInfo *c
 void e_pilot_local_category_to_remote(int * pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category);
 void e_pilot_remote_category_to_local(int   pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category);
 
+gboolean e_pilot_setup_get_bool (const char *path, const char *key, gboolean def);
+void e_pilot_setup_set_bool (const char *path, const char *key, gboolean value);
+int e_pilot_setup_get_int (const char *path, const char *key, int def);
+void e_pilot_setup_set_int (const char *path, const char *key, int value);
+char *e_pilot_setup_get_string (const char *path, const char *key, const char *def);
+void e_pilot_setup_set_string (const char *path, const char *key, const char *value);
diff --git a/calendar/conduits/memo/memo-conduit.c b/calendar/conduits/memo/memo-conduit.c
index ecaa07f..4d599a6 100644
--- a/calendar/conduits/memo/memo-conduit.c
+++ b/calendar/conduits/memo/memo-conduit.c
@@ -30,7 +30,6 @@
 #define G_LOG_DOMAIN "ememoconduit"
 
 #include <glib/gi18n.h>
-#include <libgnome/gnome-config.h>
 #include <libecal/e-cal-types.h>
 #include <libecal/e-cal.h>
 #include <libecal/e-cal-time-util.h>
@@ -120,8 +119,7 @@ memoconduit_load_configuration (guint32 pilot_id)
 	gchar prefix[256];
 
 
-	g_snprintf (prefix, 255, "/gnome-pilot.d/e-memo-conduit/Pilot_%u/",
-		    pilot_id);
+	g_snprintf (prefix, 255, "e-memo-conduit/Pilot_%u", pilot_id);
 
 	c = g_new0 (EMemoConduitCfg,1);
 	g_assert (c != NULL);
@@ -138,8 +136,6 @@ memoconduit_load_configuration (guint32 pilot_id)
 	g_object_unref (management);
 
 	/* Custom settings */
-	gnome_config_push_prefix (prefix);
-
 	if (!e_cal_get_sources (&c->source_list, E_CAL_SOURCE_TYPE_JOURNAL, NULL))
 		c->source_list = NULL;
 	if (c->source_list) {
@@ -154,11 +150,9 @@ memoconduit_load_configuration (guint32 pilot_id)
 		}
 	}
 
-	c->secret = gnome_config_get_bool ("secret=FALSE");
-	c->priority = gnome_config_get_int ("priority=3");
-	c->last_uri = gnome_config_get_string ("last_uri");
-
-	gnome_config_pop_prefix ();
+	c->secret = e_pilot_setup_get_bool (prefix, "secret", FALSE);
+	c->priority = e_pilot_setup_get_int (prefix, "priority", 3);
+	c->last_uri = e_pilot_setup_get_string (prefix, "last_uri", NULL);
 
 	return c;
 }
@@ -168,18 +162,12 @@ memoconduit_save_configuration (EMemoConduitCfg *c)
 {
 	gchar prefix[256];
 
-	g_snprintf (prefix, 255, "/gnome-pilot.d/e-memo-conduit/Pilot_%u/",
-		    c->pilot_id);
+	g_snprintf (prefix, 255, "e-memo-conduit/Pilot_%u", c->pilot_id);
 
-	gnome_config_push_prefix (prefix);
 	e_pilot_set_sync_source (c->source_list, c->source);
-	gnome_config_set_bool ("secret", c->secret);
-	gnome_config_set_int ("priority", c->priority);
-	gnome_config_set_string ("last_uri", c->last_uri);
-	gnome_config_pop_prefix ();
-
-	gnome_config_sync ();
-	gnome_config_drop_all ();
+	e_pilot_setup_set_bool (prefix, "secret", c->secret);
+	e_pilot_setup_set_int (prefix, "priority", c->priority);
+	e_pilot_setup_set_string (prefix, "last_uri", c->last_uri ? c->last_uri : "");
 }
 
 static EMemoConduitCfg*
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
index 620e9ec..f40bc82 100644
--- a/calendar/conduits/todo/todo-conduit.c
+++ b/calendar/conduits/todo/todo-conduit.c
@@ -30,7 +30,6 @@
 #define G_LOG_DOMAIN "etodoconduit"
 
 #include <glib/gi18n.h>
-#include <libgnome/gnome-config.h>
 #include <libecal/e-cal-types.h>
 #include <libecal/e-cal.h>
 #include <libecal/e-cal-time-util.h>
@@ -122,8 +121,7 @@ todoconduit_load_configuration (guint32 pilot_id)
 	gchar prefix[256];
 
 
-	g_snprintf (prefix, 255, "/gnome-pilot.d/e-todo-conduit/Pilot_%u/",
-		    pilot_id);
+	g_snprintf (prefix, 255, "e-todo-conduit/Pilot_%u", pilot_id);
 
 	c = g_new0 (EToDoConduitCfg,1);
 	g_assert (c != NULL);
@@ -140,8 +138,6 @@ todoconduit_load_configuration (guint32 pilot_id)
 	g_object_unref (management);
 
 	/* Custom settings */
-	gnome_config_push_prefix (prefix);
-
 	if (!e_cal_get_sources (&c->source_list, E_CAL_SOURCE_TYPE_TODO, NULL))
 		c->source_list = NULL;
 	if (c->source_list) {
@@ -156,11 +152,9 @@ todoconduit_load_configuration (guint32 pilot_id)
 		}
 	}
 
-	c->secret = gnome_config_get_bool ("secret=FALSE");
-	c->priority = gnome_config_get_int ("priority=3");
-	c->last_uri = gnome_config_get_string ("last_uri");
-
-	gnome_config_pop_prefix ();
+	c->secret = e_pilot_setup_get_bool (prefix, "secret", FALSE);
+	c->priority = e_pilot_setup_get_int (prefix, "priority", 3);
+	c->last_uri = e_pilot_setup_get_string (prefix, "last_uri", NULL);
 
 	return c;
 }
@@ -170,18 +164,12 @@ todoconduit_save_configuration (EToDoConduitCfg *c)
 {
 	gchar prefix[256];
 
-	g_snprintf (prefix, 255, "/gnome-pilot.d/e-todo-conduit/Pilot_%u/",
-		    c->pilot_id);
+	g_snprintf (prefix, 255, "e-todo-conduit/Pilot_%u", c->pilot_id);
 
-	gnome_config_push_prefix (prefix);
 	e_pilot_set_sync_source (c->source_list, c->source);
-	gnome_config_set_bool ("secret", c->secret);
-	gnome_config_set_int ("priority", c->priority);
-	gnome_config_set_string ("last_uri", c->last_uri);
-	gnome_config_pop_prefix ();
-
-	gnome_config_sync ();
-	gnome_config_drop_all ();
+	e_pilot_setup_set_bool (prefix, "secret", c->secret);
+	e_pilot_setup_set_int (prefix, "priority", c->priority);
+	e_pilot_setup_set_string (prefix, "last_uri", c->last_uri ? c->last_uri : "");
 }
 
 static EToDoConduitCfg*
diff --git a/mail/em-migrate.c b/mail/em-migrate.c
index 97a05c8..8338bf5 100644
--- a/mail/em-migrate.c
+++ b/mail/em-migrate.c
@@ -42,7 +42,6 @@
 #include <gtk/gtk.h>
 
 #include <gconf/gconf-client.h>
-#include <libgnome/gnome-config.h>
 
 #include <camel/camel.h>
 #include <camel/camel-store.h>
@@ -732,104 +731,6 @@ em_upgrade_xml_1_2 (xmlDocPtr doc)
 	return upgrade_xml_1_2_rec (root);
 }
 
-/* converts passwords from ~/evolution/private/config.xmldb to gnome_private() */
-static int
-upgrade_passwords_1_2(void)
-{
-	xmlNodePtr root, entry;
-	char *filename;
-	xmlDocPtr priv_doc = NULL;
-	struct stat st;
-	int work = 0, res = -1;
-
-	filename =  g_build_filename(g_get_home_dir(), "evolution/private/config.xmldb", NULL);
-	if (lstat(filename, &st) == 0 && S_ISREG(st.st_mode))
-		priv_doc = xmlParseFile(filename);
-	g_free(filename);
-
-	if (priv_doc == NULL)
-		return 0;
-
-	root = priv_doc->children;
-	if (strcmp((char *)root->name, "bonobo-config") != 0) {
-		xmlFreeDoc(priv_doc);
-		return 0;
-	}
-
-	root = root->children;
-	while (root) {
-		if (!strcmp((char *)root->name, "section")) {
-			char *path = (char *)xmlGetProp(root, (const unsigned char *)"path");
-
-			/* All sections of form
-			   <section path="/Passwords/COMPONENT">
-			    <entry name="base64name" value="hexvalue">
-			  Are converted to:
-			  /Evolution/Passwords-COMPONENT/name = value
-			*/
-
-			if (path && !strncmp(path, "/Passwords/", 11)) {
-				entry = root->children;
-				while (entry) {
-					if (!strcmp((char *)entry->name, "entry")) {
-						char *namep = (char *)xmlGetProp(entry, (const unsigned char *)"name"),
-						     *valuep = (char *)xmlGetProp(entry, (const unsigned char *)"value");
-
-						if (namep && valuep) {
-							char *value = e_bconf_hex_decode(valuep);
-							guchar *decoded;
-							char *p, *new;
-							gsize len;
-
-							decoded = g_base64_decode (namep, &len);
-							memcpy (namep, decoded, len);
-							g_free (decoded);
-							namep[len] = 0;
-							p = namep;
-
-							d(printf("Found password entry '%s' = '%s'\n", namep, value));
-
-							while (*p) {
-								if (*p == '/' || *p == '=')
-									*p = '_';
-								p++;
-							}
-
-							p = g_strdup_printf("/Evolution/Passwords-%s/%s", path+11, namep);
-							new = gnome_config_private_get_string_with_default(p, NULL);
-							if (new == NULL) {
-								d(printf("password not there, setting '%s' = '%s'\n", p, value));
-								gnome_config_private_set_string(p, value);
-								work = TRUE;
-							} else {
-								d(printf("password already there, leaving\n"));
-							}
-							g_free(p);
-							g_free(value);
-						}
-						xmlFree(namep);
-						xmlFree(valuep);
-					}
-					entry = entry->next;
-				}
-			}
-			xmlFree(path);
-		}
-		root = root->next;
-	}
-
-	xmlFreeDoc(priv_doc);
-
-	if (work) {
-		if (gnome_config_private_sync_file("/Evolution"))
-			res = 0;
-	} else {
-		res = 0;
-	}
-
-	return res;
-}
-
 /* ********************************************************************** */
 /*  Tables for converting flat bonobo conf -> gconf xml blob		  */
 /* ********************************************************************** */
@@ -1126,7 +1027,6 @@ em_migrate_1_2(const char *evolution_dir, xmlDocPtr config_xmldb, xmlDocPtr filt
 
 	em_upgrade_xml_1_2(filters);
 	em_upgrade_xml_1_2(vfolders);
-	upgrade_passwords_1_2();
 
 	return 0;
 }
diff --git a/mail/mail-session.c b/mail/mail-session.c
index e02ea41..03277b4 100644
--- a/mail/mail-session.c
+++ b/mail/mail-session.c
@@ -33,7 +33,6 @@
 
 #include <gconf/gconf-client.h>
 
-#include <libgnome/gnome-config.h>
 #include <libgnome/gnome-sound.h>
 
 #include <libedataserverui/e-passwords.h>



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