telepathy-gabble: protocol: implement get_avatar_details()

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Wed Sep 18 03:21:23 PDT 2013


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

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Wed Sep 18 10:44:46 2013 +0200

protocol: implement get_avatar_details()

---

 src/conn-avatars.c           |   34 ++++++++++++++++++++++++++++++++++
 src/conn-avatars.h           |    9 +++++++++
 src/protocol.c               |   17 +++++++++++++++++
 tests/twisted/cm/protocol.py |    9 +++++++++
 4 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/src/conn-avatars.c b/src/conn-avatars.c
index a905551..681a04d 100644
--- a/src/conn-avatars.c
+++ b/src/conn-avatars.c
@@ -991,3 +991,37 @@ conn_avatars_properties_getter (GObject *object,
       g_value_set_uint (value, GPOINTER_TO_UINT (getter_data));
     }
 }
+
+void
+gabble_connection_dup_avatar_requirements (GStrv *supported_mime_types,
+    guint *min_height,
+    guint *min_width,
+    guint *rec_height,
+    guint *rec_width,
+    guint *max_height,
+    guint *max_width,
+    guint *max_bytes)
+{
+  if (supported_mime_types != NULL)
+    {
+      *supported_mime_types = g_strdupv ((gchar **) mimetypes);
+    }
+
+  if (min_height != NULL)
+    *min_height = AVATAR_MIN_PX;
+  if (min_width != NULL)
+    *min_width = AVATAR_MIN_PX;
+
+  if (rec_height != NULL)
+    *rec_height = AVATAR_REC_PX;
+  if (rec_width != NULL)
+    *rec_width = AVATAR_REC_PX;
+
+  if (max_height != NULL)
+    *max_height = AVATAR_MAX_PX;
+  if (max_width != NULL)
+    *max_width = AVATAR_MAX_PX;
+
+  if (max_bytes != NULL)
+    *max_bytes = AVATAR_MAX_BYTES;
+}
diff --git a/src/conn-avatars.h b/src/conn-avatars.h
index 0e2899f..a26506d 100644
--- a/src/conn-avatars.h
+++ b/src/conn-avatars.h
@@ -32,6 +32,15 @@ extern TpDBusPropertiesMixinPropImpl *conn_avatars_properties;
 void conn_avatars_properties_getter (GObject *object, GQuark interface,
     GQuark name, GValue *value, gpointer getter_data);
 
+void gabble_connection_dup_avatar_requirements (GStrv *supported_mime_types,
+    guint *min_height,
+    guint *min_width,
+    guint *rec_height,
+    guint *rec_width,
+    guint *max_height,
+    guint *max_width,
+    guint *max_bytes);
+
 G_END_DECLS
 
 #endif /* __CONN_AVATARS_H__ */
diff --git a/src/protocol.c b/src/protocol.c
index 22b8444..d89b8a1 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -30,6 +30,7 @@
 
 #include "extensions/extensions.h"
 
+#include "conn-avatars.h"
 #include "conn-presence.h"
 
 #include "connection.h"
@@ -455,6 +456,21 @@ addressing_normalize_contact_uri (TpBaseProtocol *self,
 }
 
 static void
+get_avatar_details (TpBaseProtocol *base,
+    GStrv *supported_mime_types,
+    guint *min_height,
+    guint *min_width,
+    guint *rec_height,
+    guint *rec_width,
+    guint *max_height,
+    guint *max_width,
+    guint *max_bytes)
+{
+  gabble_connection_dup_avatar_requirements (supported_mime_types, min_height,
+      min_width, rec_height, rec_width, max_height, max_width, max_bytes);
+}
+
+static void
 gabble_jabber_protocol_class_init (GabbleJabberProtocolClass *klass)
 {
   TpBaseProtocolClass *base_class =
@@ -468,6 +484,7 @@ gabble_jabber_protocol_class_init (GabbleJabberProtocolClass *klass)
   base_class->get_connection_details = get_connection_details;
   base_class->get_statuses = get_presence_statuses;
   base_class->dup_authentication_types = dup_authentication_types;
+  base_class->get_avatar_details = get_avatar_details;
 }
 
 TpBaseProtocol *
diff --git a/tests/twisted/cm/protocol.py b/tests/twisted/cm/protocol.py
index 264692e..c30946a 100644
--- a/tests/twisted/cm/protocol.py
+++ b/tests/twisted/cm/protocol.py
@@ -67,6 +67,15 @@ def test(q, bus, conn, stream):
     assertEquals(test_params['account'], acc_name)
 
     assertContains(cs.PROTOCOL_IFACE_AVATARS, proto_props['Interfaces'])
+    avatar_props = unwrap(proto_prop_iface.GetAll(cs.PROTOCOL_IFACE_AVATARS))
+    assertEquals(8192, avatar_props['MaximumAvatarBytes'])
+    assertEquals(96, avatar_props['MaximumAvatarHeight'])
+    assertEquals(96, avatar_props['MaximumAvatarWidth'])
+    assertEquals(32, avatar_props['MinimumAvatarHeight'])
+    assertEquals(32, avatar_props['MinimumAvatarWidth'])
+    assertEquals(64, avatar_props['RecommendedAvatarHeight'])
+    assertEquals(64, avatar_props['RecommendedAvatarWidth'])
+    assertEquals(['image/png', 'image/jpeg', 'image/gif'], avatar_props['SupportedAvatarMIMETypes'])
 
     conn.Connect()
     q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTING, cs.CSR_REQUESTED])



More information about the telepathy-commits mailing list