summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Mardegan <alberto.mardegan@nokia.com>2009-08-11 16:11:28 +0300
committerAlberto Mardegan <alberto.mardegan@nokia.com>2009-08-12 12:23:37 +0300
commit6561d2a2899dd570ea2f1ffe22fe8aea871e1c2f (patch)
tree0a2b752ef28177eb78e2647a063a3842184cb8bf
parentcc37784f1e70a4ab078653dc4d0bf36a0b4b1a16 (diff)
Update the Compat interface code
Use the new internal APIs to update the properties.
-rw-r--r--libmcclient/mc-account-compat.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/libmcclient/mc-account-compat.c b/libmcclient/mc-account-compat.c
index 1db32aa4..d697146e 100644
--- a/libmcclient/mc-account-compat.c
+++ b/libmcclient/mc-account-compat.c
@@ -63,39 +63,52 @@ _mc_account_compat_props_free (McAccountCompatProps *props)
}
static void
-update_property (gpointer key, gpointer ht_value, gpointer user_data)
+update_profile (const gchar *name, const GValue *value, gpointer user_data)
{
- McAccount *account = user_data;
+ McAccount *account = MC_ACCOUNT (user_data);
McAccountCompatProps *props = account->priv->compat_props;
- GValue *value = ht_value;
- const gchar *name = key;
-
- if (strcmp (name, "Profile") == 0)
- {
- g_free (props->profile);
- props->profile = g_value_dup_string (value);
- }
- else if (strcmp (name, "AvatarFile") == 0)
- {
- g_free (props->avatar_file);
- props->avatar_file = g_value_dup_string (value);
- }
- else if (strcmp (name, "SecondaryVCardFields") == 0)
- {
- g_strfreev ((gchar **)props->secondary_vcard_fields);
- props->secondary_vcard_fields = g_value_get_boxed (value);
- _mc_gvalue_stolen (value);
- }
+
+ g_free (props->profile);
+ props->profile = g_value_dup_string (value);
+}
+
+static void
+update_avatar_file (const gchar *name, const GValue *value, gpointer user_data)
+{
+ McAccount *account = MC_ACCOUNT (user_data);
+ McAccountCompatProps *props = account->priv->compat_props;
+
+ g_free (props->avatar_file);
+ props->avatar_file = g_value_dup_string (value);
}
static void
+update_secondary_vcard_fields (const gchar *name, const GValue *value,
+ gpointer user_data)
+{
+ McAccount *account = MC_ACCOUNT (user_data);
+ McAccountCompatProps *props = account->priv->compat_props;
+
+ g_strfreev ((gchar **)props->secondary_vcard_fields);
+ props->secondary_vcard_fields = g_value_dup_boxed (value);
+}
+
+static const McIfaceProperty account_compat_properties[] =
+{
+ { "Profile", "s", update_profile },
+ { "AvatarFile", "s", update_avatar_file },
+ { "SecondaryVCardFields", "as", update_secondary_vcard_fields },
+ { NULL, NULL, NULL }
+};
+
+static void
create_props (TpProxy *proxy, GHashTable *props)
{
McAccount *account = MC_ACCOUNT (proxy);
McAccountPrivate *priv = account->priv;
priv->compat_props = g_slice_new0 (McAccountCompatProps);
- g_hash_table_foreach (props, update_property, account);
+ _mc_iface_update_props (account_compat_properties, props, account);
}
/**