aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-04-30 22:56:58 +0800
committerMilan Crha <mcrha@redhat.com>2009-04-30 22:56:58 +0800
commit8f2b4f9c6554698af19a39223acc33f965e2dfca (patch)
tree4a66ec23024087aa1b7dc54a63ccb115f0e91509 /addressbook
parenta4bc46297551d65f2fbffb853b773f857e14edf2 (diff)
downloadgsoc2013-evolution-8f2b4f9c6554698af19a39223acc33f965e2dfca.tar
gsoc2013-evolution-8f2b4f9c6554698af19a39223acc33f965e2dfca.tar.gz
gsoc2013-evolution-8f2b4f9c6554698af19a39223acc33f965e2dfca.tar.bz2
gsoc2013-evolution-8f2b4f9c6554698af19a39223acc33f965e2dfca.tar.lz
gsoc2013-evolution-8f2b4f9c6554698af19a39223acc33f965e2dfca.tar.xz
gsoc2013-evolution-8f2b4f9c6554698af19a39223acc33f965e2dfca.tar.zst
gsoc2013-evolution-8f2b4f9c6554698af19a39223acc33f965e2dfca.zip
Bug #570730 - Get rid of gnome-config in Evolution
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/conduit/address-conduit.c147
1 files changed, 124 insertions, 23 deletions
diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c
index 4cf0c126d7..6340b999f4 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*