[empathy] UOA: Use the new libaccounts-glib APIs
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] UOA: Use the new libaccounts-glib APIs
- Date: Fri, 11 Jan 2013 12:17:41 +0000 (UTC)
commit 02db084adde59fc94129ebd7ea5c2c24fad7c07a
Author: Alberto Mardegan <alberto mardegan canonical com>
Date: Thu Jan 10 12:20:12 2013 +0100
UOA: Use the new libaccounts-glib APIs
The APIs based on GValue are now deprecated.
https://bugzilla.gnome.org/show_bug.cgi?id=691469
configure.ac | 2 +-
.../empathy-accounts-plugin-widget.c | 22 +++----
.../mc-plugin/mcp-account-manager-uoa.c | 59 +++++++++----------
3 files changed, 39 insertions(+), 44 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 141a813..f873cd6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,7 +76,7 @@ NAUTILUS_SENDTO_REQUIRED=2.90.0
NETWORK_MANAGER_REQUIRED=0.7.0
CHAMPLAIN_REQUIRED=0.12.1
CHEESE_GTK_REQUIRED=3.4.0
-LIBACCOUNTS_REQUIRED=1.1
+LIBACCOUNTS_REQUIRED=1.4
LIBSIGNON_REQUIRED=1.1
MC_PLUGINS_REQUIRED=5.13.1
diff --git a/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin-widget.c b/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin-widget.c
index 3472996..28b4716 100644
--- a/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin-widget.c
+++ b/ubuntu-online-accounts/cc-plugins/account-plugins/empathy-accounts-plugin-widget.c
@@ -102,7 +102,7 @@ create_account_settings (AgAccount *account)
AgService *service;
GList *services;
AgAccountService *account_service;
- GValue v = G_VALUE_INIT;
+ GVariant *v;
gchar *manager = NULL, *protocol = NULL;
EmpathyAccountSettings *settings;
@@ -114,17 +114,15 @@ create_account_settings (AgAccount *account)
account_service = ag_account_service_new (account, service);
- g_value_init (&v, G_TYPE_STRING);
- if (ag_account_service_get_value (account_service,
- "telepathy/manager", &v) != AG_SETTING_SOURCE_NONE)
- manager = g_value_dup_string (&v);
- g_value_unset (&v);
-
- g_value_init (&v, G_TYPE_STRING);
- if (ag_account_service_get_value (account_service,
- "telepathy/protocol", &v) != AG_SETTING_SOURCE_NONE)
- protocol = g_value_dup_string (&v);
- g_value_unset (&v);
+ v = ag_account_service_get_variant (account_service,
+ "telepathy/manager", NULL);
+ if (v != NULL)
+ manager = g_variant_dup_string (v, NULL);
+
+ v = ag_account_service_get_variant (account_service,
+ "telepathy/protocol", NULL);
+ if (v != NULL)
+ protocol = g_variant_dup_string (v, NULL);
g_return_val_if_fail (manager != NULL, NULL);
g_return_val_if_fail (protocol != NULL, NULL);
diff --git a/ubuntu-online-accounts/mc-plugin/mcp-account-manager-uoa.c b/ubuntu-online-accounts/mc-plugin/mcp-account-manager-uoa.c
index 304e4f3..8919065 100644
--- a/ubuntu-online-accounts/mc-plugin/mcp-account-manager-uoa.c
+++ b/ubuntu-online-accounts/mc-plugin/mcp-account-manager-uoa.c
@@ -86,15 +86,14 @@ _service_dup_tp_value (AgAccountService *service,
const gchar *key)
{
gchar *real_key = g_strdup_printf (KEY_PREFIX "%s", key);
- GValue value = { 0, };
- gchar *ret;
+ GVariant *value;
- g_value_init (&value, G_TYPE_STRING);
- ag_account_service_get_value (service, real_key, &value);
- ret = g_value_dup_string (&value);
- g_value_unset (&value);
+ value = ag_account_service_get_variant (service, real_key, NULL);
+ g_free (real_key);
+ if (value == NULL)
+ return NULL;
- return ret;
+ return g_variant_dup_string (value, NULL);
}
static void
@@ -106,18 +105,14 @@ _service_set_tp_value (AgAccountService *service,
if (value != NULL)
{
- GValue gvalue = { 0, };
-
- g_value_init (&gvalue, G_TYPE_STRING);
- g_value_set_string (&gvalue, value);
- ag_account_service_set_value (service, real_key, &gvalue);
- g_value_unset (&gvalue);
- g_free (real_key);
+ GVariant *gvariant = g_variant_new_string (value);
+ ag_account_service_set_variant (service, real_key, gvariant);
}
else
{
- ag_account_service_set_value (service, real_key, NULL);
+ ag_account_service_set_variant (service, real_key, NULL);
}
+ g_free (real_key);
}
/* Returns NULL if the account never has been imported into MC before */
@@ -171,15 +166,20 @@ _service_changed_cb (AgAccountService *service,
}
static void
-_account_stored_cb (AgAccount *account,
- const GError *error,
+_account_stored_cb (GObject *source_object,
+ GAsyncResult *res,
gpointer user_data)
{
- if (error != NULL)
+ AgAccount *account = AG_ACCOUNT(source_object);
+ GError *error = NULL;
+
+ if (!ag_account_store_finish (account, res, &error))
{
+ g_assert (error != NULL);
DEBUG ("Error storing UOA account '%s': %s",
ag_account_get_display_name (account),
error->message);
+ g_error_free (error);
}
}
@@ -261,7 +261,7 @@ _account_created_cb (AgManager *manager,
cm_name, protocol_name, params);
_service_set_tp_account_name (service, account_name);
- ag_account_store (account, _account_stored_cb, self);
+ ag_account_store_async (account, NULL, _account_stored_cb, self);
g_hash_table_unref (params);
}
@@ -479,16 +479,16 @@ account_manager_uoa_get (const McpAccountStorage *storage,
{
AgAccountSettingIter iter;
const gchar *k;
- const GValue *v;
+ GVariant *v;
ag_account_service_settings_iter_init (service, &iter, KEY_PREFIX);
- while (ag_account_service_settings_iter_next (&iter, &k, &v))
+ while (ag_account_settings_iter_get_next (&iter, &k, &v))
{
- if (!G_VALUE_HOLDS_STRING (v))
+ if (!g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
continue;
mcp_account_manager_set_value (am, account_name,
- k, g_value_get_string (v));
+ k, g_variant_get_string (v, NULL));
}
}
@@ -676,7 +676,7 @@ account_manager_uoa_commit (const McpAccountStorage *storage,
AgAccountService *service = value;
AgAccount *account = ag_account_service_get_account (service);
- ag_account_store (account, _account_stored_cb, self);
+ ag_account_store_async (account, NULL, _account_stored_cb, self);
}
return TRUE;
@@ -781,7 +781,7 @@ account_manager_uoa_get_restrictions (const McpAccountStorage *storage,
McpAccountManagerUoa *self = (McpAccountManagerUoa *) storage;
AgAccountService *service;
guint restrictions = TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_SERVICE;
- GValue value = G_VALUE_INIT;
+ GVariant *value;
g_return_val_if_fail (self->priv->manager != NULL, 0);
@@ -790,15 +790,12 @@ account_manager_uoa_get_restrictions (const McpAccountStorage *storage,
if (service == NULL)
return G_MAXUINT;
- g_value_init (&value, G_TYPE_BOOLEAN);
- ag_account_service_get_value (service,
- KEY_PREFIX KEY_READONLY_PARAMS, &value);
+ value = ag_account_service_get_variant (service,
+ KEY_PREFIX KEY_READONLY_PARAMS, NULL);
- if (g_value_get_boolean (&value))
+ if (value != NULL && g_variant_get_boolean (value))
restrictions |= TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS;
- g_value_unset (&value);
-
/* FIXME: We can't set Icon either, but there is no flag for that */
return restrictions;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]