telepathy-haze: protocol: fix 'ConnectionInterfaces'
Guillaume Desmottes
gdesmott at kemper.freedesktop.org
Wed Sep 18 04:10:36 PDT 2013
Module: telepathy-haze
Branch: master
Commit: cc57a8a5138386ba7658d46dd7f0b46e2533c7c1
URL: http://cgit.freedesktop.org/telepathy/telepathy-haze/commit/?id=cc57a8a5138386ba7658d46dd7f0b46e2533c7c1
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Tue Sep 17 15:23:05 2013 +0200
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 | 23 +++++++++++++++++------
src/connection.h | 4 +++-
src/protocol.c | 19 +++++++++++++++++--
tests/twisted/cm/protocols.py | 8 ++++++++
4 files changed, 45 insertions(+), 9 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index e7f1994..8e1c0fc 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,23 @@ haze_connection_get_interfaces_always_present (TpBaseConnection *base)
return interfaces;
}
+static void add_optional_connection_interfaces (GPtrArray *ifaces,
+ PurplePluginProtocolInfo *prpl_info);
+
+/* Returns a (transfer container) not NULL terminated of (const gchar *)
+ * interface names. */
+GPtrArray *
+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);
+
+ 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..e0a7b46 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -905,8 +905,23 @@ haze_protocol_get_connection_details (TpBaseProtocol *base,
if (connection_interfaces != NULL)
{
- *connection_interfaces = g_strdupv (
- (gchar **) haze_connection_get_implemented_interfaces ());
+ GPtrArray *tmp, *ifaces;
+ guint i;
+
+ tmp = haze_connection_dup_implemented_interfaces (
+ self->priv->prpl_info);
+
+ /* @connection_interfaces takes a NULL terminated (transfer full)
+ * gchar ** so we have to dup each string and append NULL. */
+ ifaces = g_ptr_array_new ();
+
+ for (i = 0; i < tmp->len; i++)
+ g_ptr_array_add (ifaces, g_strdup (g_ptr_array_index (tmp, i)));
+
+ g_ptr_array_add (ifaces, NULL);
+
+ *connection_interfaces = (gchar **) g_ptr_array_free (ifaces, FALSE);
+ g_ptr_array_unref (tmp);
}
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'])
More information about the telepathy-commits
mailing list