summaryrefslogtreecommitdiff
path: root/telepathy-glib/account.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-09-26 14:28:40 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-09-26 16:30:46 +0100
commitaa407653e274480ae63b21017869e07de3a1aa4e (patch)
tree457aa101d5ddb7e5d50bcee1b805478067460967 /telepathy-glib/account.c
parente6ac4848a0e613087b024af9f4c21fec3ee509ef (diff)
downloadtelepathy-glib-aa407653e274480ae63b21017869e07de3a1aa4e.tar.gz
Make more use of tp_value_array_unpack, tp_value_array_build
As well as being less code, they're not flagged as deprecated. This requires a bit of extra copying, because there's no tp_value_array_unpack_dup() or tp_value_array_build_take(), but it seems worth it. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69849 Reviewed-by: Xavier Claessens <xavier.claessens@collabora.co.uk>
Diffstat (limited to 'telepathy-glib/account.c')
-rw-r--r--telepathy-glib/account.c52
1 files changed, 31 insertions, 21 deletions
diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index 24dbd001a..0ad6d8305 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -631,6 +631,8 @@ _tp_account_update (TpAccount *account,
TpConnectionStatus old_s = priv->connection_status;
gboolean status_changed = FALSE;
gboolean presence_changed = FALSE;
+ const gchar *status;
+ const gchar *message;
tp_proxy_add_interfaces (proxy, tp_asv_get_strv (properties, "Interfaces"));
@@ -721,29 +723,30 @@ _tp_account_update (TpAccount *account,
presence_changed = TRUE;
arr = tp_asv_get_boxed (properties, "CurrentPresence",
TP_STRUCT_TYPE_SIMPLE_PRESENCE);
- priv->cur_presence = g_value_get_uint (g_value_array_get_nth (arr, 0));
+ tp_value_array_unpack (arr, 3,
+ &priv->cur_presence,
+ &status,
+ &message);
g_free (priv->cur_status);
- priv->cur_status = g_value_dup_string (g_value_array_get_nth (arr, 1));
-
+ priv->cur_status = g_strdup (status);
g_free (priv->cur_message);
- priv->cur_message = g_value_dup_string (g_value_array_get_nth (arr, 2));
+ priv->cur_message = g_strdup (message);
}
if (g_hash_table_lookup (properties, "RequestedPresence") != NULL)
{
arr = tp_asv_get_boxed (properties, "RequestedPresence",
TP_STRUCT_TYPE_SIMPLE_PRESENCE);
- priv->requested_presence =
- g_value_get_uint (g_value_array_get_nth (arr, 0));
+ tp_value_array_unpack (arr, 3,
+ &priv->requested_presence,
+ &status,
+ &message);
g_free (priv->requested_status);
- priv->requested_status =
- g_value_dup_string (g_value_array_get_nth (arr, 1));
-
+ priv->requested_status = g_strdup (status);
g_free (priv->requested_message);
- priv->requested_message =
- g_value_dup_string (g_value_array_get_nth (arr, 2));
+ priv->requested_message = g_strdup (message);
g_object_notify (G_OBJECT (account), "requested-presence-type");
g_object_notify (G_OBJECT (account), "requested-status");
@@ -754,16 +757,15 @@ _tp_account_update (TpAccount *account,
{
arr = tp_asv_get_boxed (properties, "AutomaticPresence",
TP_STRUCT_TYPE_SIMPLE_PRESENCE);
- priv->auto_presence =
- g_value_get_uint (g_value_array_get_nth (arr, 0));
+ tp_value_array_unpack (arr, 3,
+ &priv->auto_presence,
+ &status,
+ &message);
g_free (priv->auto_status);
- priv->auto_status =
- g_value_dup_string (g_value_array_get_nth (arr, 1));
-
+ priv->auto_status = g_strdup (status);
g_free (priv->auto_message);
- priv->auto_message =
- g_value_dup_string (g_value_array_get_nth (arr, 2));
+ priv->auto_message = g_strdup (message);
g_object_notify (G_OBJECT (account), "automatic-presence-type");
g_object_notify (G_OBJECT (account), "automatic-status");
@@ -3551,8 +3553,6 @@ _tp_account_got_avatar_cb (TpProxy *proxy,
GObject *weak_object)
{
GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
- GValueArray *avatar;
- GArray *res;
if (error != NULL)
{
@@ -3567,8 +3567,18 @@ _tp_account_got_avatar_cb (TpProxy *proxy,
}
else
{
+ GValueArray *avatar;
+ GArray *res;
+ const GArray *tmp;
+ const gchar *mime_type;
+
avatar = g_value_get_boxed (out_Value);
- res = g_value_dup_boxed (g_value_array_get_nth (avatar, 0));
+ tp_value_array_unpack (avatar, 2,
+ &tmp,
+ &mime_type);
+
+ res = g_array_sized_new (FALSE, FALSE, 1, tmp->len);
+ g_array_append_vals (res, tmp->data, tmp->len);
g_simple_async_result_set_op_res_gpointer (result, res,
(GDestroyNotify) g_array_unref);
}