summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-01-07 17:29:45 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-01-09 14:04:58 +0100
commit18dd2cc616621f796bf1d1987e55b51eedca00b8 (patch)
tree08be253a7ed81c8827bff3bbd54ade8a5f963035
parent15b8eea5133e683ac14c79734dfbea6747af6e5f (diff)
TpAccount: implement change notification on uri-schemes property
-rw-r--r--telepathy-glib/account.c42
-rw-r--r--tests/dbus/account.c9
-rw-r--r--tests/lib/simple-account.c15
3 files changed, 66 insertions, 0 deletions
diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c
index c49699c48..3b4d44f4b 100644
--- a/telepathy-glib/account.c
+++ b/telepathy-glib/account.c
@@ -1020,6 +1020,42 @@ _tp_account_got_all_cb (TpProxy *proxy,
}
static void
+addressing_props_changed (TpAccount *self,
+ GHashTable *changed_properties)
+{
+ const gchar * const * v;
+
+ if (self->priv->uri_schemes == NULL)
+ /* We did not fetch the initial value yet, ignoring */
+ return;
+
+ v = tp_asv_get_strv (changed_properties, "URISchemes");
+ if (v == NULL)
+ return;
+
+ g_strfreev (self->priv->uri_schemes);
+ self->priv->uri_schemes = g_strdupv ((GStrv) v);
+
+ g_object_notify (G_OBJECT (self), "uri-schemes");
+}
+
+static void
+dbus_properties_changed_cb (TpProxy *proxy,
+ const gchar *interface_name,
+ GHashTable *changed_properties,
+ const gchar **invalidated_properties,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ TpAccount *self = TP_ACCOUNT (weak_object);
+
+ if (!tp_strdiff (interface_name, TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING))
+ {
+ addressing_props_changed (self, changed_properties);
+ }
+}
+
+static void
_tp_account_constructed (GObject *object)
{
TpAccount *self = TP_ACCOUNT (object);
@@ -1059,6 +1095,9 @@ _tp_account_constructed (GObject *object)
tp_cli_account_connect_to_account_property_changed (self,
_tp_account_properties_changed, NULL, NULL, object, NULL);
+ tp_cli_dbus_properties_connect_to_properties_changed (self,
+ dbus_properties_changed_cb, NULL, NULL, object, NULL);
+
tp_cli_dbus_properties_call_get_all (self, -1, TP_IFACE_ACCOUNT,
_tp_account_got_all_cb, NULL, NULL, G_OBJECT (self));
}
@@ -2047,6 +2086,9 @@ tp_account_class_init (TpAccountClass *klass)
* protocol (for instance, "xmpp" for XMPP, or "sip" or "sips" for SIP),
* since it should be assumed to be useful for those schemes in any case.
*
+ * The notify::uri-schemes signal cannot be relied on if the Account Manager
+ * is Mission Control version 5.14.0 or older.
+ *
* Since: UNRELEASED
*/
g_object_class_install_property (object_class, PROP_URI_SCHEMES,
diff --git a/tests/dbus/account.c b/tests/dbus/account.c
index dc27ac102..b921f4068 100644
--- a/tests/dbus/account.c
+++ b/tests/dbus/account.c
@@ -678,6 +678,15 @@ test_addressing (Test *test,
"telnet"));
g_assert (!tp_account_associated_with_uri_scheme (test->account,
"xmpp"));
+
+ g_signal_connect (test->account, "notify::uri-schemes",
+ G_CALLBACK (notify_cb), test);
+
+ tp_tests_simple_account_add_uri_scheme (test->account_service, "xmpp");
+ g_main_loop_run (test->mainloop);
+
+ g_assert (tp_account_associated_with_uri_scheme (test->account,
+ "xmpp"));
}
static void
diff --git a/tests/lib/simple-account.c b/tests/lib/simple-account.c
index 892e0e5db..dc0912057 100644
--- a/tests/lib/simple-account.c
+++ b/tests/lib/simple-account.c
@@ -603,5 +603,20 @@ void
tp_tests_simple_account_add_uri_scheme (TpTestsSimpleAccount *self,
const gchar *uri_scheme)
{
+ GHashTable *changed;
+ GStrv schemes;
+
g_ptr_array_add (self->priv->uri_schemes, g_strdup (uri_scheme));
+
+ g_object_get (self, "uri-schemes", &schemes, NULL);
+
+ changed = tp_asv_new (
+ "URISchemes", G_TYPE_STRV, schemes,
+ NULL);
+
+ tp_svc_dbus_properties_emit_properties_changed (self,
+ TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING, changed, NULL);
+
+ g_strfreev (schemes);
+ g_hash_table_unref (changed);
}