diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-22 11:50:39 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-05-07 09:43:47 +0100 |
commit | 4f087c183930ca215e0406ca9c6ecef65a7cc073 (patch) | |
tree | 5fdd679ad0dbdb90dfbcafe41b756701df07d537 | |
parent | bdf5c7251f4fc907914d5fef5ab0fe50662a16fa (diff) | |
download | telepathy-glib-4f087c183930ca215e0406ca9c6ecef65a7cc073.tar.gz |
TpBaseContactList: only implement Blocking1 if we can_block()
This is what Gabble wants - a core-only XMPP server can't block contacts,
so we need to perform feature discovery before we can say whether we
can block anyone.
We now provide two opportunities to implement Blocking1. The one used in
telepathy-glib's own regression tests is appropriate for a proprietary
protocol where there is only one deployed server, so either there's a
way to block contacts, or there isn't - in this case, we can start
implementing the interface as soon as the Connection is constructed.
The second opportunity is used by Gabble, and is the last possible
chance to say Blocking1 is implemented, just before StatusChanged
is emitted on D-Bus.
Reviewed-by: Xavier Claessens <xavier.claessens@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77189
-rw-r--r-- | telepathy-glib/base-contact-list.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/telepathy-glib/base-contact-list.c b/telepathy-glib/base-contact-list.c index 6ab8663e2..ec7ef1cff 100644 --- a/telepathy-glib/base-contact-list.c +++ b/telepathy-glib/base-contact-list.c @@ -483,6 +483,8 @@ enum { N_PROPS }; +static void _tp_base_contact_list_implement_contact_blocking ( + TpBaseContactList *self); static void tp_base_contact_list_contacts_changed_internal (TpBaseContactList *self, TpHandleSet *changed, TpHandleSet *removed, gboolean is_initial_roster); @@ -646,6 +648,10 @@ status_changed_cb (TpBaseConnection *conn, { update_immutable_contact_list_properties (self); update_immutable_contact_groups_properties (self); + + /* last chance to implement blocking */ + if (tp_base_contact_list_can_block (self)) + _tp_base_contact_list_implement_contact_blocking (self); } else if (status == TP_CONNECTION_STATUS_DISCONNECTED) { @@ -657,8 +663,6 @@ static void _tp_base_contact_list_implement_contact_list ( TpBaseContactList *self); static void _tp_base_contact_list_implement_contact_groups ( TpBaseContactList *self); -static void _tp_base_contact_list_implement_contact_blocking ( - TpBaseContactList *self); static void tp_base_contact_list_constructed (GObject *object) @@ -716,7 +720,10 @@ tp_base_contact_list_constructed (GObject *object) g_return_if_fail (iface->unblock_contacts_async != NULL); g_return_if_fail (iface->unblock_contacts_finish != NULL); - _tp_base_contact_list_implement_contact_blocking (self); + /* maybe we implement blocking unconditionally? if so, + * no need to wait until status-changed */ + if (tp_base_contact_list_can_block (self)) + _tp_base_contact_list_implement_contact_blocking (self); } self->priv->contact_repo = tp_base_connection_get_handles (self->priv->conn, @@ -4928,6 +4935,9 @@ _tp_base_contact_list_implement_contact_blocking (TpBaseContactList *self) TpBlockableContactListInterface *iface; guint flags = 0; + if (self->priv->contact_blocking_skeleton != NULL) + return; + self->priv->contact_blocking_skeleton = _tp_gdbus_connection_interface_contact_blocking1_skeleton_new (); |