From cc417f28ea6ac78686a3ade9807f79276fc918db Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 17 Sep 2013 15:23:05 +0200 Subject: [PATCH] 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 | 4 ++-- tests/twisted/cm/protocols.py | 8 ++++++++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/connection.c b/src/connection.c index e7f1994..0f031e3 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_optional_connection_interfaces (GPtrArray *ifaces, + PurplePluginProtocolInfo *prpl_info); + +gchar ** +haze_connection_dup_implemented_interfaces (PurplePluginProtocolInfo *prpl_info) +{ + GPtrArray *ifaces; + + ifaces = g_ptr_array_new (); + add_always_present_connection_interfaces (ifaces); + add_optional_connection_interfaces (ifaces, prpl_info); + g_ptr_array_add (ifaces, NULL); + + return (gchar **) g_ptr_array_free (ifaces, FALSE); +} + struct _HazeConnectionPrivate { gchar *username; diff --git a/src/connection.h b/src/connection.h index 1677bf1..4a7e430 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); +gchar ** 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..1c4d4e4 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -905,8 +905,8 @@ haze_protocol_get_connection_details (TpBaseProtocol *base, if (connection_interfaces != NULL) { - *connection_interfaces = g_strdupv ( - (gchar **) haze_connection_get_implemented_interfaces ()); + *connection_interfaces = haze_connection_dup_implemented_interfaces ( + self->priv->prpl_info); } 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