summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-09-19 12:02:45 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-09-19 13:01:11 +0200
commit93fa6f4eeb668896c683e928845eabafc8106a62 (patch)
treeaca069e21b6e4b6fdc3242c3ba57b738423b34e8
parentca5fa44a7d74dc1450b0409bbf91c08c453a94df (diff)
protocol: implement get_avatar_details()
https://bugs.freedesktop.org/show_bug.cgi?id=69508
-rw-r--r--src/connection.c34
-rw-r--r--src/connection.h9
-rw-r--r--src/protocol.c16
-rw-r--r--tests/twisted/cm/protocol.py9
4 files changed, 68 insertions, 0 deletions
diff --git a/src/connection.c b/src/connection.c
index 4886414c..186997bd 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 f843ba3a..d33e1921 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 453adf82..9dfcad58 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 46db537a..e7630497 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)