[telepathy-mission-control/master] Setup property monitoring
Alberto Mardegan
alberto.mardegan at nokia.com
Tue Aug 11 06:13:27 PDT 2009
This will update the local preoperties when MC daemon emits the
CompatPropertyChanged signal.
---
libmcclient/mc-account-compat.c | 33 ++++++++++++++++++++++++++++++---
1 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/libmcclient/mc-account-compat.c b/libmcclient/mc-account-compat.c
index 81ed32f..858a328 100644
--- a/libmcclient/mc-account-compat.c
+++ b/libmcclient/mc-account-compat.c
@@ -37,11 +37,12 @@ struct _McAccountCompatProps {
};
static void create_props (TpProxy *proxy, GHashTable *props);
+static void setup_props_monitor (TpProxy *proxy, GQuark interface);
static McIfaceDescription iface_description = {
G_STRUCT_OFFSET (McAccountPrivate, compat_props),
create_props,
- NULL,
+ setup_props_monitor,
};
@@ -134,9 +135,13 @@ mc_account_compat_call_when_ready (McAccount *account,
iface_data.props_data_ptr = (gpointer)&account->priv->compat_props;
iface_data.create_props = create_props;
- _mc_iface_call_when_ready_int ((TpProxy *)account,
+ if (_mc_iface_call_when_ready_int ((TpProxy *)account,
(McIfaceWhenReadyCb)callback, user_data,
- &iface_data);
+ &iface_data))
+ {
+ setup_props_monitor ((TpProxy *)account,
+ MC_IFACE_QUARK_ACCOUNT_INTERFACE_COMPAT);
+ }
}
/**
@@ -188,6 +193,28 @@ mc_account_compat_get_secondary_vcard_fields (McAccount *account)
account->priv->compat_props->secondary_vcard_fields;
}
+static void
+on_compat_property_changed (TpProxy *proxy, GHashTable *properties,
+ gpointer user_data, GObject *weak_object)
+{
+ McAccount *account = MC_ACCOUNT (proxy);
+ McAccountPrivate *priv = account->priv;
+
+ /* if the GetAll method hasn't returned yet, we do nothing */
+ if (G_UNLIKELY (!priv->compat_props)) return;
+
+ _mc_iface_update_props (account_compat_properties, properties, account);
+}
+
+static void
+setup_props_monitor (TpProxy *proxy, GQuark interface)
+{
+ McAccount *account = MC_ACCOUNT (proxy);
+
+ mc_cli_account_interface_compat_connect_to_compat_property_changed
+ (account, on_compat_property_changed, NULL, NULL, NULL, NULL);
+}
+
/**
* mc_account_avatar_set:
* @account: the #McAccount.
--
1.5.6.5
More information about the telepathy-commits
mailing list