[telepathy-mission-control/master] mcd-account: make Parameters an async property
Jonny Lamb
jonny.lamb at collabora.co.uk
Mon Sep 14 11:09:16 PDT 2009
This finally unbreaks the Parameters property by implementing an async
get function for it.
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
src/mcd-account.c | 50 ++++++++++++++++++++++++++++++++++++--------------
1 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 427b2a3..ae79928 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -1173,21 +1173,43 @@ get_avatar (TpSvcDBusProperties *self, const gchar *name, GValue *value)
g_value_take_string (va->values + 1, mime_type);
}
+typedef struct
+{
+ mcddbus_get_cb callback;
+ gpointer user_data;
+} GetParametersPropData;
+
static void
-get_parameters (TpSvcDBusProperties *self, const gchar *name, GValue *value)
+get_parameters_dup_parameters_cb (McdAccount *account,
+ GHashTable *params, gpointer user_data)
{
- GHashTable *parameters = NULL;
+ TpSvcDBusProperties *self = TP_SVC_DBUS_PROPERTIES (account);
+ GetParametersPropData *data = (GetParametersPropData *) user_data;
+ GValue *value;
- /* TODO FIXME RIGHT NOW: move to async dbus properties solution
- * so we can call dup_parameters
- * parameters = _mcd_account_dup_parameters (account);
- * For now, just return an empty asv.
- */
- parameters = g_hash_table_new_full (g_str_hash, g_str_equal,
- NULL, (GDestroyNotify) tp_g_value_slice_free);
+ value = tp_g_value_slice_new_take_boxed (TP_HASH_TYPE_STRING_VARIANT_MAP,
+ params);
+
+ if (data->callback != NULL)
+ data->callback (self, value, NULL, data->user_data);
+
+ tp_g_value_slice_free (value);
+ g_slice_free (GetParametersPropData, data);
+}
+
+static void
+get_parameters_async (TpSvcDBusProperties *self, const gchar *name,
+ mcddbus_get_cb callback, gpointer user_data)
+{
+ McdAccount *account = MCD_ACCOUNT (self);
+ GetParametersPropData *data;
+
+ data = g_slice_new0 (GetParametersPropData);
+ data->callback = callback;
+ data->user_data = user_data;
- g_value_init (value, TP_HASH_TYPE_STRING_VARIANT_MAP);
- g_value_take_boxed (value, parameters);
+ _mcd_account_dup_parameters (account, get_parameters_dup_parameters_cb,
+ data);
}
static gboolean
@@ -1518,7 +1540,7 @@ static const McdDBusProp account_properties[] = {
{ "Valid", NULL, get_valid },
{ "Enabled", set_enabled, get_enabled },
{ "Nickname", set_nickname, get_nickname },
- { "Parameters", NULL, get_parameters },
+ { "Parameters", NULL, NULL, get_parameters_async },
{ "AutomaticPresence", set_automatic_presence, get_automatic_presence },
{ "ConnectAutomatically", set_connect_automatically, get_connect_automatically },
{ "Connection", NULL, get_connection },
--
1.5.6.5
More information about the telepathy-commits
mailing list