telepathy-salut: protocol: implement get_avatar_details()

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Thu Sep 19 04:01:32 PDT 2013


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

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

protocol: implement get_avatar_details()

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

---

 src/connection.c             |   34 ++++++++++++++++++++++++++++++++++
 src/connection.h             |    9 +++++++++
 src/protocol.c               |   16 ++++++++++++++++
 tests/twisted/cm/protocol.py |    9 +++++++++
 4 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 4886414..186997b 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -4169,3 +4169,37 @@ salut_connection_get_name (SalutPluginConnection *plugin_connection)
 
   return connection->name;
 }
+
+void
+salut_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/connection.h b/src/connection.h
index f843ba3..d33e192 100644
--- a/src/connection.h
+++ b/src/connection.h
@@ -109,6 +109,15 @@ WockySession * salut_connection_get_session (SalutPluginConnection *connection);
 
 const gchar * salut_connection_get_name (SalutPluginConnection *connection);
 
+void salut_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 /* #ifndef __SALUT_CONNECTION_H__*/
diff --git a/src/protocol.c b/src/protocol.c
index 453adf8..9dfcad5 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -287,6 +287,21 @@ get_interfaces_array (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)
+{
+  salut_connection_dup_avatar_requirements (supported_mime_types, min_height,
+      min_width, rec_height, rec_width, max_height, max_width, max_bytes);
+}
+
+static void
 salut_protocol_class_init (SalutProtocolClass *klass)
 {
   TpBaseProtocolClass *base_class = (TpBaseProtocolClass *) klass;
@@ -301,6 +316,7 @@ salut_protocol_class_init (SalutProtocolClass *klass)
   base_class->identify_account = identify_account;
   base_class->get_connection_details = get_connection_details;
   base_class->get_interfaces_array = get_interfaces_array;
+  base_class->get_avatar_details = get_avatar_details;
 
   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 46db537..e763049 100644
--- a/tests/twisted/cm/protocol.py
+++ b/tests/twisted/cm/protocol.py
@@ -62,6 +62,15 @@ def test(q, bus, conn):
     assertEquals('', acc_name)
 
     assertContains(cs.PROTOCOL_IFACE_AVATARS, proto_props['Interfaces'])
+    avatar_props = unwrap(proto_prop_iface.GetAll(cs.PROTOCOL_IFACE_AVATARS))
+    assertEquals(65535, avatar_props['MaximumAvatarBytes'])
+    assertEquals(0, avatar_props['MaximumAvatarHeight'])
+    assertEquals(0, avatar_props['MaximumAvatarWidth'])
+    assertEquals(0, avatar_props['MinimumAvatarHeight'])
+    assertEquals(0, avatar_props['MinimumAvatarWidth'])
+    assertEquals(64, avatar_props['RecommendedAvatarHeight'])
+    assertEquals(64, avatar_props['RecommendedAvatarWidth'])
+    assertEquals(['image/png', 'image/jpeg'], avatar_props['SupportedAvatarMIMETypes'])
 
 if __name__ == '__main__':
     exec_test(test)



More information about the telepathy-commits mailing list