telepathy-haze: protocol: claim that we implement Avatars

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Wed Sep 18 05:59:48 PDT 2013


Module: telepathy-haze
Branch: master
Commit: d9dd5549573b1423a117744cc4d7573de6619b34
URL:    http://cgit.freedesktop.org/telepathy/telepathy-haze/commit/?id=d9dd5549573b1423a117744cc4d7573de6619b34

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Tue Sep 17 14:08:59 2013 +0200

protocol: claim that we implement Avatars

---

 src/protocol.c                |   17 +++++++++++++++++
 tests/twisted/cm/protocols.py |    7 +++++++
 tests/twisted/constants.py    |    1 +
 3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/protocol.c b/src/protocol.c
index e0a7b46..9089e0d 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -885,11 +885,28 @@ haze_protocol_identify_account (TpBaseProtocol *base,
 static GPtrArray *
 haze_protocol_get_interfaces_array (TpBaseProtocol *base)
 {
+  HazeProtocol *self = HAZE_PROTOCOL (base);
   GPtrArray *interfaces;
+  GPtrArray *tmp;
+  guint i;
 
   interfaces = TP_BASE_PROTOCOL_CLASS (
       haze_protocol_parent_class)->get_interfaces_array (base);
 
+  /* Claim to implement Avatars only if we support avatars for this
+   * protocol. */
+  tmp = haze_connection_dup_implemented_interfaces (self->priv->prpl_info);
+  for (i = 0; i < tmp->len; i++)
+    {
+      if (!tp_strdiff (g_ptr_array_index (tmp, i),
+            TP_IFACE_CONNECTION_INTERFACE_AVATARS))
+        {
+          g_ptr_array_add (interfaces, TP_IFACE_PROTOCOL_INTERFACE_AVATARS);
+          break;
+        }
+    }
+  g_ptr_array_unref (tmp);
+
   return interfaces;
 }
 
diff --git a/tests/twisted/cm/protocols.py b/tests/twisted/cm/protocols.py
index d296710..d0c67ce 100644
--- a/tests/twisted/cm/protocols.py
+++ b/tests/twisted/cm/protocols.py
@@ -28,6 +28,13 @@ def test(q, bus, conn, stream):
         protocol_props = dbus.Interface(protocol, cs.PROPERTIES_IFACE)
         flat_props = protocol_props.GetAll(cs.PROTOCOL)
 
+        # Protocol is supposed to implement Interface.Avatars iff the
+        # connection implements Avatars as well.
+        if cs.CONN_IFACE_AVATARS in flat_props['ConnectionInterfaces']:
+            assertContains(cs.PROTOCOL_IFACE_AVATARS, props[cs.PROTOCOL + '.Interfaces'])
+        else:
+            assertDoesNotContain(cs.PROTOCOL_IFACE_AVATARS, props[cs.PROTOCOL + '.Interfaces'])
+
         parameters = cm_iface.GetParameters(name)
         assertEquals(parameters, props[cs.PROTOCOL + '.Parameters'])
         assertEquals(parameters, flat_props['Parameters'])
diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
index 37d6d52..7bba99b 100644
--- a/tests/twisted/constants.py
+++ b/tests/twisted/constants.py
@@ -481,6 +481,7 @@ class SendError(object):
 PROTOCOL = 'org.freedesktop.Telepathy.Protocol'
 PROTOCOL_IFACE_PRESENCES = PROTOCOL + '.Interface.Presence'
 PROTOCOL_IFACE_ADDRESSING = PROTOCOL + '.Interface.Addressing'
+PROTOCOL_IFACE_AVATARS = PROTOCOL + '.Interface.Avatars'
 
 PARAM_REQUIRED = 1
 PARAM_REGISTER = 2



More information about the telepathy-commits mailing list