aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/bbdb
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@gnome-db.org>2011-11-18 00:19:48 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-11-18 00:19:48 +0800
commit73656ae57ee8a42678e09b07c5d85fe45b9844a6 (patch)
treeb8e127c47eea456c27c9d534384801c74c9e7cfe /plugins/bbdb
parent30f7d3788f7dad3dee700d36570baa11f4612634 (diff)
downloadgsoc2013-evolution-73656ae57ee8a42678e09b07c5d85fe45b9844a6.tar
gsoc2013-evolution-73656ae57ee8a42678e09b07c5d85fe45b9844a6.tar.gz
gsoc2013-evolution-73656ae57ee8a42678e09b07c5d85fe45b9844a6.tar.bz2
gsoc2013-evolution-73656ae57ee8a42678e09b07c5d85fe45b9844a6.tar.lz
gsoc2013-evolution-73656ae57ee8a42678e09b07c5d85fe45b9844a6.tar.xz
gsoc2013-evolution-73656ae57ee8a42678e09b07c5d85fe45b9844a6.tar.zst
gsoc2013-evolution-73656ae57ee8a42678e09b07c5d85fe45b9844a6.zip
Port autocontacts plugin to GSettings
Diffstat (limited to 'plugins/bbdb')
-rw-r--r--plugins/bbdb/bbdb.c141
-rw-r--r--plugins/bbdb/bbdb.h16
-rw-r--r--plugins/bbdb/gaimbuddies.c29
3 files changed, 83 insertions, 103 deletions
diff --git a/plugins/bbdb/bbdb.c b/plugins/bbdb/bbdb.c
index d24e75480c..f03c189b21 100644
--- a/plugins/bbdb/bbdb.c
+++ b/plugins/bbdb/bbdb.c
@@ -110,29 +110,15 @@ find_esource_by_uri (ESourceList *source_list,
static gint
get_check_interval (void)
{
- GConfClient *gconf;
- GConfValue *value;
+ GSettings *settings;
gint res = BBDB_BLIST_DEFAULT_CHECK_INTERVAL;
- gconf = gconf_client_get_default ();
- value = gconf_client_get (gconf, GCONF_KEY_GAIM_CHECK_INTERVAL, NULL);
-
- if (value) {
- if (value->type == GCONF_VALUE_INT) {
- gint interval = gconf_value_get_int (value);
-
- if (interval > 0)
- res = interval * 60;
- else
- res = interval;
- }
-
- gconf_value_free (value);
- }
+ settings = g_settings_new (CONF_SCHEMA);
+ res = g_settings_get_int (settings, CONF_KEY_GAIM_CHECK_INTERVAL);
- g_object_unref (gconf);
+ g_object_unref (settings);
- return res;
+ return res * 60;
}
gint
@@ -310,12 +296,12 @@ bbdb_handle_send (EPlugin *ep,
EMEventTargetComposer *target)
{
EComposerHeaderTable *table;
- GConfClient *gconf;
+ GSettings *settings;
gboolean enable;
- gconf = gconf_client_get_default ();
- enable = gconf_client_get_bool (gconf, GCONF_KEY_ENABLE, NULL);
- g_object_unref (gconf);
+ settings = g_settings_new (CONF_SCHEMA);
+ enable = g_settings_get_boolean (settings, CONF_KEY_ENABLE);
+ g_object_unref (settings);
if (!enable)
return;
@@ -423,28 +409,29 @@ bbdb_do_it (EBookClient *client,
EBookClient *
bbdb_create_book_client (gint type)
{
- GConfClient *gconf;
+ GSettings *settings;
gchar *uri;
EBookClient *client = NULL;
GError *error = NULL;
gboolean enable = TRUE;
- gconf = gconf_client_get_default ();
+
+ settings = g_settings_new (CONF_SCHEMA);
/* Check to see if we're supposed to be running */
if (type == AUTOMATIC_CONTACTS_ADDRESSBOOK)
- enable = gconf_client_get_bool (gconf, GCONF_KEY_ENABLE, NULL);
+ enable = g_settings_get_boolean (settings, CONF_KEY_ENABLE);
if (!enable) {
- g_object_unref (G_OBJECT (gconf));
+ g_object_unref (G_OBJECT (settings));
return NULL;
}
/* Open the appropriate addresbook. */
if (type == GAIM_ADDRESSBOOK)
- uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK_GAIM, NULL);
+ uri = g_settings_get_string (settings, CONF_KEY_WHICH_ADDRESSBOOK_GAIM);
else
- uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK, NULL);
- g_object_unref (G_OBJECT (gconf));
+ uri = g_settings_get_string (settings, CONF_KEY_WHICH_ADDRESSBOOK);
+ g_object_unref (G_OBJECT (settings));
if (uri == NULL)
client = e_book_client_new_system (&error);
@@ -486,13 +473,13 @@ bbdb_open_book_client (EBookClient *client)
gboolean
bbdb_check_gaim_enabled (void)
{
- GConfClient *gconf;
- gboolean gaim_enabled;
+ GSettings *settings;
+ gboolean gaim_enabled;
- gconf = gconf_client_get_default ();
- gaim_enabled = gconf_client_get_bool (gconf, GCONF_KEY_ENABLE_GAIM, NULL);
+ settings = g_settings_new (CONF_SCHEMA);
+ gaim_enabled = g_settings_get_boolean (settings, CONF_KEY_ENABLE_GAIM);
- g_object_unref (G_OBJECT (gconf));
+ g_object_unref (G_OBJECT (settings));
return gaim_enabled;
}
@@ -518,36 +505,30 @@ enable_toggled_cb (GtkWidget *widget,
gboolean active;
ESource *selected_source;
gchar *addressbook;
+ GSettings *settings = g_settings_new (CONF_SCHEMA);
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
- /* Save the new setting to gconf */
- gconf_client_set_bool (stuff->target->gconf, GCONF_KEY_ENABLE, active, NULL);
+ /* Save the new setting to GSettings */
+ g_settings_set_boolean (settings, CONF_KEY_ENABLE, active);
gtk_widget_set_sensitive (stuff->combo_box, active);
- addressbook = gconf_client_get_string (stuff->target->gconf, GCONF_KEY_WHICH_ADDRESSBOOK, NULL);
+ addressbook = g_settings_get_string (settings, CONF_KEY_WHICH_ADDRESSBOOK);
if (active && !addressbook) {
const gchar *uri = NULL;
- GError *error = NULL;
selected_source = e_source_combo_box_get_active (
E_SOURCE_COMBO_BOX (stuff->combo_box));
if (selected_source != NULL)
uri = e_source_get_uri (selected_source);
- gconf_client_set_string (
- stuff->target->gconf,
- GCONF_KEY_WHICH_ADDRESSBOOK,
- uri ? uri : "", &error);
-
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
+ g_settings_set_string (settings, CONF_KEY_WHICH_ADDRESSBOOK, uri ? uri : "");
}
+
g_free (addressbook);
+ g_object_unref (settings);
}
static void
@@ -558,21 +539,23 @@ enable_gaim_toggled_cb (GtkWidget *widget,
gboolean active;
ESource *selected_source;
gchar *addressbook_gaim;
+ GSettings *settings = g_settings_new (CONF_SCHEMA);
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
- /* Save the new setting to gconf */
- gconf_client_set_bool (stuff->target->gconf, GCONF_KEY_ENABLE_GAIM, active, NULL);
+ /* Save the new setting to GSettings */
+ g_settings_set_boolean (settings, CONF_KEY_ENABLE_GAIM, active);
- addressbook_gaim = gconf_client_get_string (stuff->target->gconf, GCONF_KEY_WHICH_ADDRESSBOOK_GAIM, NULL);
+ addressbook_gaim = g_settings_get_string (settings, CONF_KEY_WHICH_ADDRESSBOOK_GAIM);
gtk_widget_set_sensitive (stuff->gaim_combo_box, active);
if (active && !addressbook_gaim) {
selected_source = e_source_combo_box_get_active (
E_SOURCE_COMBO_BOX (stuff->gaim_combo_box));
- gconf_client_set_string (stuff->target->gconf, GCONF_KEY_WHICH_ADDRESSBOOK_GAIM, e_source_get_uri (selected_source), NULL);
+ g_settings_set_string (settings, CONF_KEY_WHICH_ADDRESSBOOK_GAIM, e_source_get_uri (selected_source));
}
g_free (addressbook_gaim);
+ g_object_unref (settings);
}
static void
@@ -586,19 +569,16 @@ source_changed_cb (ESourceComboBox *source_combo_box,
struct bbdb_stuff *stuff)
{
ESource *source;
- GError *error = NULL;
+ GSettings *settings = g_settings_new (CONF_SCHEMA);
source = e_source_combo_box_get_active (source_combo_box);
- gconf_client_set_string (
- stuff->target->gconf,
- GCONF_KEY_WHICH_ADDRESSBOOK,
- source ? e_source_get_uri (source) : "", &error);
+ g_settings_set_string (
+ settings,
+ CONF_KEY_WHICH_ADDRESSBOOK,
+ source ? e_source_get_uri (source) : "");
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
+ g_object_unref (settings);
}
static void
@@ -606,19 +586,16 @@ gaim_source_changed_cb (ESourceComboBox *source_combo_box,
struct bbdb_stuff *stuff)
{
ESource *source;
- GError *error = NULL;
+ GSettings *settings = g_settings_new (CONF_SCHEMA);
source = e_source_combo_box_get_active (source_combo_box);
- gconf_client_set_string (
- stuff->target->gconf,
- GCONF_KEY_WHICH_ADDRESSBOOK_GAIM,
- source ? e_source_get_uri (source) : "", &error);
+ g_settings_set_string (
+ settings,
+ CONF_KEY_WHICH_ADDRESSBOOK_GAIM,
+ source ? e_source_get_uri (source) : "");
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- }
+ g_object_unref (settings);
}
static GtkWidget *
@@ -628,17 +605,18 @@ create_addressbook_combo_box (struct bbdb_stuff *stuff,
GtkWidget *combo_box;
ESourceList *source_list;
ESource *selected_source;
- gchar *selected_source_uri;
-
- GConfClient *gconf = stuff->target->gconf;
+ gchar *selected_source_uri;
+ GConfClient *gconf;
+ GSettings *settings = g_settings_new (CONF_SCHEMA);
+ gconf = gconf_client_get_default ();
source_list = e_source_list_new_for_gconf (gconf, "/apps/evolution/addressbook/sources");
combo_box = e_source_combo_box_new (source_list);
if (type == GAIM_ADDRESSBOOK)
- selected_source_uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK_GAIM, NULL);
+ selected_source_uri = g_settings_get_string (settings, CONF_KEY_WHICH_ADDRESSBOOK_GAIM);
else
- selected_source_uri = gconf_client_get_string (gconf, GCONF_KEY_WHICH_ADDRESSBOOK, NULL);
+ selected_source_uri = g_settings_get_string (settings, CONF_KEY_WHICH_ADDRESSBOOK);
selected_source = find_esource_by_uri (
source_list, selected_source_uri);
g_free (selected_source_uri);
@@ -651,6 +629,8 @@ create_addressbook_combo_box (struct bbdb_stuff *stuff,
stuff->source_list = source_list;
+ g_object_unref (settings);
+
return combo_box;
}
@@ -675,6 +655,7 @@ bbdb_page_factory (EPlugin *ep,
GtkWidget *gaim_label;
GtkWidget *button;
gchar *str;
+ GSettings *settings = g_settings_new (CONF_SCHEMA);
/* A structure to pass some stuff around */
stuff = g_new0 (struct bbdb_stuff, 1);
@@ -708,7 +689,7 @@ bbdb_page_factory (EPlugin *ep,
/* Enable BBDB checkbox */
check = gtk_check_button_new_with_mnemonic (_("Create _address book entries when sending mails"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), gconf_client_get_bool (target->gconf, GCONF_KEY_ENABLE, NULL));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), g_settings_get_boolean (settings, CONF_KEY_ENABLE));
g_signal_connect (GTK_TOGGLE_BUTTON (check), "toggled", G_CALLBACK (enable_toggled_cb), stuff);
gtk_box_pack_start (GTK_BOX (inner_vbox), check, FALSE, FALSE, 0);
stuff->check = check;
@@ -719,7 +700,7 @@ bbdb_page_factory (EPlugin *ep,
/* Source selection combo box */
combo_box = create_addressbook_combo_box (stuff, AUTOMATIC_CONTACTS_ADDRESSBOOK);
g_signal_connect (combo_box, "changed", G_CALLBACK (source_changed_cb), stuff);
- gtk_widget_set_sensitive (combo_box, gconf_client_get_bool (target->gconf, GCONF_KEY_ENABLE, NULL));
+ gtk_widget_set_sensitive (combo_box, g_settings_get_boolean (settings, CONF_KEY_ENABLE));
gtk_box_pack_start (GTK_BOX (inner_vbox), combo_box, FALSE, FALSE, 0);
stuff->combo_box = combo_box;
@@ -744,7 +725,7 @@ bbdb_page_factory (EPlugin *ep,
/* Enable Gaim Checkbox */
check_gaim = gtk_check_button_new_with_mnemonic (_("_Synchronize contact info and images from Pidgin buddy list"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_gaim), gconf_client_get_bool (target->gconf, GCONF_KEY_ENABLE_GAIM, NULL));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_gaim), g_settings_get_boolean (settings, CONF_KEY_ENABLE_GAIM));
g_signal_connect (GTK_TOGGLE_BUTTON (check_gaim), "toggled", G_CALLBACK (enable_gaim_toggled_cb), stuff);
gtk_box_pack_start (GTK_BOX (inner_vbox), check_gaim, FALSE, FALSE, 0);
stuff->check_gaim = check_gaim;
@@ -755,7 +736,7 @@ bbdb_page_factory (EPlugin *ep,
/* Gaim Source Selection Combo Box */
gaim_combo_box = create_addressbook_combo_box (stuff, GAIM_ADDRESSBOOK);
g_signal_connect (gaim_combo_box, "changed", G_CALLBACK (gaim_source_changed_cb), stuff);
- gtk_widget_set_sensitive (gaim_combo_box, gconf_client_get_bool (target->gconf, GCONF_KEY_ENABLE_GAIM, NULL));
+ gtk_widget_set_sensitive (gaim_combo_box, g_settings_get_boolean (settings, CONF_KEY_ENABLE_GAIM));
gtk_box_pack_start (GTK_BOX (inner_vbox), gaim_combo_box, FALSE, FALSE, 0);
stuff->gaim_combo_box = gaim_combo_box;
@@ -769,6 +750,8 @@ bbdb_page_factory (EPlugin *ep,
gtk_widget_show_all (page);
+ g_object_unref (settings);
+
return page;
}
diff --git a/plugins/bbdb/bbdb.h b/plugins/bbdb/bbdb.h
index 82951a7566..3bd8cce880 100644
--- a/plugins/bbdb/bbdb.h
+++ b/plugins/bbdb/bbdb.h
@@ -22,14 +22,14 @@
#define __BBDB_H__
/* Where to store the config values */
-#define GCONF_ROOT_PATH "/apps/evolution/autocontacts"
-#define GCONF_KEY_ENABLE GCONF_ROOT_PATH "/enable_autocontacts"
-#define GCONF_KEY_ENABLE_GAIM GCONF_ROOT_PATH "/auto_sync_gaim"
-#define GCONF_KEY_WHICH_ADDRESSBOOK GCONF_ROOT_PATH "/addressbook_source"
-#define GCONF_KEY_WHICH_ADDRESSBOOK_GAIM GCONF_ROOT_PATH "/gaim_addressbook_source"
-#define GCONF_KEY_GAIM_LAST_SYNC_TIME GCONF_ROOT_PATH "/gaim_last_sync_time"
-#define GCONF_KEY_GAIM_LAST_SYNC_MD5 GCONF_ROOT_PATH "/gaim_last_sync_md5"
-#define GCONF_KEY_GAIM_CHECK_INTERVAL GCONF_ROOT_PATH "/gaim_check_interval"
+#define CONF_SCHEMA "org.gnome.evolution.eplugin.autocontacts"
+#define CONF_KEY_ENABLE "enable"
+#define CONF_KEY_ENABLE_GAIM "auto-sync-gaim"
+#define CONF_KEY_WHICH_ADDRESSBOOK "addressbook-source"
+#define CONF_KEY_WHICH_ADDRESSBOOK_GAIM "gaim-addressbook-source"
+#define CONF_KEY_GAIM_LAST_SYNC_TIME "gaim-last-sync-time"
+#define CONF_KEY_GAIM_LAST_SYNC_MD5 "gaim-last-sync-md5"
+#define CONF_KEY_GAIM_CHECK_INTERVAL "gaim-check-interval"
/* How often to poll the buddy list for changes (every two minutes is default) */
#define BBDB_BLIST_DEFAULT_CHECK_INTERVAL (2 * 60)
diff --git a/plugins/bbdb/gaimbuddies.c b/plugins/bbdb/gaimbuddies.c
index d2e3c0016c..68e71eed02 100644
--- a/plugins/bbdb/gaimbuddies.c
+++ b/plugins/bbdb/gaimbuddies.c
@@ -112,12 +112,12 @@ get_md5_as_string (const gchar *filename)
void
bbdb_sync_buddy_list_check (void)
{
- GConfClient *gconf;
struct stat statbuf;
time_t last_sync_time;
gchar *md5;
gchar *blist_path;
gchar *last_sync_str;
+ GSettings *settings = g_settings_new (CONF_SCHEMA);
blist_path = get_buddy_filename ();
if (stat (blist_path, &statbuf) < 0) {
@@ -125,11 +125,8 @@ bbdb_sync_buddy_list_check (void)
return;
}
- gconf = gconf_client_get_default ();
-
/* Reprocess the buddy list if it's been updated. */
- last_sync_str = gconf_client_get_string (
- gconf, GCONF_KEY_GAIM_LAST_SYNC_TIME, NULL);
+ last_sync_str = g_settings_get_string (settings, CONF_KEY_GAIM_LAST_SYNC_TIME);
if (last_sync_str == NULL || !strcmp ((const gchar *)last_sync_str, ""))
last_sync_time = (time_t) 0;
else
@@ -138,15 +135,15 @@ bbdb_sync_buddy_list_check (void)
g_free (last_sync_str);
if (statbuf.st_mtime <= last_sync_time) {
- g_object_unref (G_OBJECT (gconf));
+ g_object_unref (G_OBJECT (settings));
g_free (blist_path);
return;
}
- last_sync_str = gconf_client_get_string (
- gconf, GCONF_KEY_GAIM_LAST_SYNC_MD5, NULL);
+ last_sync_str = g_settings_get_string (
+ settings, CONF_KEY_GAIM_LAST_SYNC_MD5);
- g_object_unref (gconf);
+ g_object_unref (settings);
md5 = get_md5_as_string (blist_path);
@@ -164,7 +161,7 @@ bbdb_sync_buddy_list_check (void)
static gboolean
store_last_sync_idle_cb (gpointer data)
{
- GConfClient *gconf;
+ GSettings *settings;
gchar *md5;
gchar *blist_path = get_buddy_filename ();
time_t last_sync;
@@ -175,13 +172,13 @@ store_last_sync_idle_cb (gpointer data)
md5 = get_md5_as_string (blist_path);
- gconf = gconf_client_get_default ();
- gconf_client_set_string (
- gconf, GCONF_KEY_GAIM_LAST_SYNC_TIME, last_sync_time, NULL);
- gconf_client_set_string (
- gconf, GCONF_KEY_GAIM_LAST_SYNC_MD5, md5, NULL);
+ settings = g_settings_new (CONF_SCHEMA);
+ g_settings_set_string (
+ settings, CONF_KEY_GAIM_LAST_SYNC_TIME, last_sync_time);
+ g_settings_set_string (
+ settings, CONF_KEY_GAIM_LAST_SYNC_MD5, md5);
- g_object_unref (G_OBJECT (gconf));
+ g_object_unref (G_OBJECT (settings));
g_free (last_sync_time);
g_free (blist_path);