From 2781c3b8df7bb6c3038af15292fee1a613de6f8b Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 17 Sep 2013 15:23:05 +0200 Subject: [PATCH 5/5] protocol: fix 'ConnectionInterfaces' Return the set of interfaces actually supported for this specific protocol rather than claiming to support everything. https://bugs.freedesktop.org/show_bug.cgi?id=69466 --- src/connection.c | 22 ++++++++++++++++------ src/connection.h | 4 +++- src/protocol.c | 8 ++++++-- tests/twisted/cm/protocols.py | 8 ++++++++ 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/connection.c b/src/connection.c index 9413519..32324ef 100644 --- a/src/connection.c +++ b/src/connection.c @@ -107,12 +107,6 @@ static const gchar * implemented_interfaces[] = { NULL }; -const gchar ** -haze_connection_get_implemented_interfaces (void) -{ - return implemented_interfaces; -} - static void add_always_present_connection_interfaces (GPtrArray *interfaces) { @@ -136,6 +130,22 @@ haze_connection_get_interfaces_always_present (TpBaseConnection *base) return interfaces; } +static void add_optionnal_connection_interfaces (GPtrArray *ifaces, + PurplePluginProtocolInfo *prpl_info); + +GPtrArray * +haze_connection_dup_implemented_interfaces (PurplePluginProtocolInfo *prpl_info) +{ + GPtrArray *ifaces; + + ifaces = g_ptr_array_new (); + add_always_present_connection_interfaces (ifaces); + add_optionnal_connection_interfaces (ifaces, prpl_info); + g_ptr_array_add (ifaces, NULL); + + return ifaces; +} + struct _HazeConnectionPrivate { gchar *username; diff --git a/src/connection.h b/src/connection.h index 1677bf1..0eef922 100644 --- a/src/connection.h +++ b/src/connection.h @@ -98,7 +98,9 @@ GType haze_connection_get_type (void); const gchar *haze_get_fallback_group (void); -const gchar **haze_connection_get_implemented_interfaces (void); +GPtrArray * haze_connection_dup_implemented_interfaces ( + PurplePluginProtocolInfo *prpl_info); + const gchar **haze_connection_get_guaranteed_interfaces (void); void haze_connection_request_password (PurpleAccount *account, diff --git a/src/protocol.c b/src/protocol.c index df56071..66917e2 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -905,8 +905,12 @@ haze_protocol_get_connection_details (TpBaseProtocol *base, if (connection_interfaces != NULL) { - *connection_interfaces = g_strdupv ( - (gchar **) haze_connection_get_implemented_interfaces ()); + GPtrArray *ifaces; + + ifaces = haze_connection_dup_implemented_interfaces ( + self->priv->prpl_info); + + *connection_interfaces = (gchar **) g_ptr_array_free (ifaces, FALSE); } if (channel_manager_types != NULL) diff --git a/tests/twisted/cm/protocols.py b/tests/twisted/cm/protocols.py index 4dc3f19..d296710 100644 --- a/tests/twisted/cm/protocols.py +++ b/tests/twisted/cm/protocols.py @@ -94,6 +94,10 @@ def test(q, bus, conn, stream): protocol_iface.IdentifyAccount({ 'account': 'smcv', 'server': 'irc.debian.org'})) + + assertDoesNotContain(cs.CONN_IFACE_AVATARS, flat_props['ConnectionInterfaces']) + assertDoesNotContain(cs.CONN_IFACE_CONTACT_BLOCKING, flat_props['ConnectionInterfaces']) + assertDoesNotContain(cs.CONN_IFACE_MAIL_NOTIFICATION + '.DRAFT', flat_props['ConnectionInterfaces']) elif name == 'myspace': assertEquals('x-myspace', flat_props['VCardField']) assertEquals('im-myspace', flat_props['Icon']) @@ -139,6 +143,10 @@ def test(q, bus, conn, stream): 'embrace-and-extend': r'WORKGROUP\Bill', 'password': 'letmein'}) q.expect('dbus-error', name=cs.INVALID_ARGUMENT) + + assertContains(cs.CONN_IFACE_AVATARS, flat_props['ConnectionInterfaces']) + assertContains(cs.CONN_IFACE_CONTACT_BLOCKING, flat_props['ConnectionInterfaces']) + assertContains(cs.CONN_IFACE_MAIL_NOTIFICATION + '.DRAFT', flat_props['ConnectionInterfaces']) elif name == 'qq': assertEquals('x-qq', flat_props['VCardField']) assertEquals('im-qq', flat_props['Icon']) -- 1.8.3.1