telepathy-gabble: client-types: implement RequestClientTypes()

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Fri Oct 4 08:55:56 PDT 2013


Module: telepathy-gabble
Branch: master
Commit: 5fd2fb86a32ae2f0a8f81d0090ec662cf2fc61c8
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=5fd2fb86a32ae2f0a8f81d0090ec662cf2fc61c8

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Fri Oct  4 16:10:55 2013 +0200

client-types: implement RequestClientTypes()

There is no reason to no implement it. Furthermore, that's the only remaining
method on this interface in Telepathy 1.0.

https://bugs.freedesktop.org/show_bug.cgi?id=70134

---

 src/conn-client-types.c       |   39 +++++++++++++++++++++++++++++++++++++++
 tests/twisted/client-types.py |    9 ++++++++-
 tests/twisted/servicetest.py  |    1 +
 3 files changed, 48 insertions(+), 1 deletions(-)

diff --git a/src/conn-client-types.c b/src/conn-client-types.c
index 1a5ff1e..2947534 100644
--- a/src/conn-client-types.c
+++ b/src/conn-client-types.c
@@ -132,6 +132,44 @@ client_types_get_client_types (TpSvcConnectionInterfaceClientTypes *iface,
   g_hash_table_unref (client_types);
 }
 
+static void
+client_types_request_client_types (TpSvcConnectionInterfaceClientTypes *iface,
+    TpHandle contact,
+    DBusGMethodInvocation *context)
+{
+  GabbleConnection *conn = GABBLE_CONNECTION (iface);
+  TpBaseConnection *base = (TpBaseConnection *) conn;
+  TpHandleRepoIface *contact_handles;
+  GError *error = NULL;
+  gchar **types;
+
+  /* Validate contact */
+  contact_handles = tp_base_connection_get_handles (base,
+      TP_HANDLE_TYPE_CONTACT);
+
+  if (!tp_handle_is_valid (contact_handles, contact, &error))
+    {
+      dbus_g_method_return_error (context, error);
+      g_error_free (error);
+      return;
+    }
+
+  DEBUG ("RequestClientTypes called on the following handle: %u", contact);
+
+  if (!get_client_types_from_handle (conn, contact, &types))
+    {
+      /* FIXME fdo#70140 : we should wait for the disco reply before
+       * returning. */
+      static gchar *empty[] = { NULL };
+      types = g_strdupv (empty);
+    }
+
+  tp_svc_connection_interface_client_types_return_from_request_client_types (
+      context, (const gchar **) types);
+
+  g_strfreev (types);
+}
+
 void
 conn_client_types_iface_init (gpointer g_iface,
     gpointer iface_data)
@@ -141,6 +179,7 @@ conn_client_types_iface_init (gpointer g_iface,
 #define IMPLEMENT(x) tp_svc_connection_interface_client_types_implement_##x \
   (klass, client_types_##x)
   IMPLEMENT (get_client_types);
+  IMPLEMENT (request_client_types);
 #undef IMPLEMENT
 }
 
diff --git a/tests/twisted/client-types.py b/tests/twisted/client-types.py
index 9c7ba7a..aee1064 100644
--- a/tests/twisted/client-types.py
+++ b/tests/twisted/client-types.py
@@ -3,7 +3,8 @@ Test Conn.I.ClientTypes
 """
 from functools import partial
 
-from servicetest import EventPattern, assertEquals, assertLength, assertContains, assertSameSets
+from servicetest import (EventPattern, assertEquals, assertLength,
+        assertContains, assertSameSets, call_async)
 from gabbletest import exec_test, make_presence, sync_stream
 import constants as cs
 import ns
@@ -98,6 +99,12 @@ def test(q, bus, conn, stream):
     assertLength(1, types[meredith_handle])
     assertEquals('pc', types[meredith_handle][0])
 
+    types = conn.RequestClientTypes(meredith_handle,
+            dbus_interface=cs.CONN_IFACE_CLIENT_TYPES)
+
+    assertLength(1, types)
+    assertEquals('pc', types[0])
+
     # Two now becomes more available
     stream.send(make_presence(meredith_two, show='chat'))
 
diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py
index dafdb64..c98bc70 100644
--- a/tests/twisted/servicetest.py
+++ b/tests/twisted/servicetest.py
@@ -632,6 +632,7 @@ def wrap_connection(conn):
          ('ContactGroups', cs.CONN_IFACE_CONTACT_GROUPS),
          ('PowerSaving', cs.CONN_IFACE_POWER_SAVING),
          ('Addressing', cs.CONN_IFACE_ADDRESSING),
+         ('ClientTypes', cs.CONN_IFACE_CLIENT_TYPES),
         ]))
 
 def wrap_channel(chan, type_, extra=None):



More information about the telepathy-commits mailing list