telepathy-salut: protocol: implement Presences

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Thu Sep 19 05:30:52 PDT 2013


Module: telepathy-salut
Branch: master
Commit: 0979408634389bb28853820c2f7cfc840f74c026
URL:    http://cgit.freedesktop.org/telepathy/telepathy-salut/commit/?id=0979408634389bb28853820c2f7cfc840f74c026

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Thu Sep 19 13:43:13 2013 +0200

protocol: implement Presences

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

---

 src/connection.c             |    6 ++++++
 src/connection.h             |    2 ++
 src/protocol.c               |    7 +++++++
 tests/twisted/cm/protocol.py |    8 ++++++++
 4 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 186997b..00a6d56 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -4203,3 +4203,9 @@ salut_connection_dup_avatar_requirements (GStrv *supported_mime_types,
   if (max_bytes != NULL)
     *max_bytes = AVATAR_MAX_BYTES;
 }
+
+const TpPresenceStatusSpec *
+salut_connection_get_presence_statuses (void)
+{
+  return presence_statuses;
+}
diff --git a/src/connection.h b/src/connection.h
index d33e192..dcc0128 100644
--- a/src/connection.h
+++ b/src/connection.h
@@ -118,6 +118,8 @@ void salut_connection_dup_avatar_requirements (GStrv *supported_mime_types,
     guint *max_width,
     guint *max_bytes);
 
+const TpPresenceStatusSpec * salut_connection_get_presence_statuses (void);
+
 G_END_DECLS
 
 #endif /* #ifndef __SALUT_CONNECTION_H__*/
diff --git a/src/protocol.c b/src/protocol.c
index 1ab5f3d..2b805c8 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -302,6 +302,12 @@ get_avatar_details (TpBaseProtocol *base,
       min_width, rec_height, rec_width, max_height, max_width, max_bytes);
 }
 
+static const TpPresenceStatusSpec *
+get_presence_statuses (TpBaseProtocol *self)
+{
+  return salut_connection_get_presence_statuses ();
+}
+
 static void
 salut_protocol_class_init (SalutProtocolClass *klass)
 {
@@ -318,6 +324,7 @@ salut_protocol_class_init (SalutProtocolClass *klass)
   base_class->get_connection_details = get_connection_details;
   base_class->get_interfaces_array = get_interfaces_array;
   base_class->get_avatar_details = get_avatar_details;
+  base_class->get_statuses = get_presence_statuses;
 
   object_class->get_property = salut_protocol_get_property;
   object_class->set_property = salut_protocol_set_property;
diff --git a/tests/twisted/cm/protocol.py b/tests/twisted/cm/protocol.py
index 05cffc4..51bf6d6 100644
--- a/tests/twisted/cm/protocol.py
+++ b/tests/twisted/cm/protocol.py
@@ -74,5 +74,13 @@ def test(q, bus, conn):
 
     assertContains(cs.PROTOCOL_IFACE_PRESENCES, proto_props['Interfaces'])
 
+    expected_status = {'available': (cs.PRESENCE_AVAILABLE,     True,  True),
+                       'dnd'      : (cs.PRESENCE_BUSY,          True,  True),
+                       'away'     : (cs.PRESENCE_AWAY,          True,  True),
+                       'offline'  : (cs.PRESENCE_OFFLINE,       False, False)}
+
+    presences = proto_prop_iface.Get(cs.PROTOCOL_IFACE_PRESENCES, 'Statuses');
+    assertEquals(expected_status, presences)
+
 if __name__ == '__main__':
     exec_test(test)



More information about the telepathy-commits mailing list