diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2013-09-18 09:16:41 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2013-09-18 13:24:46 +0200 |
commit | 65d38a3105b091cc32aa6227e90a68026b138bb4 (patch) | |
tree | 0b8a4bc674a9f8f1239dc876761df5e616e78207 | |
parent | 984690b5876ea02f88e4e6e39a4666e8dc351a35 (diff) | |
download | telepathy-haze-65d38a3105b091cc32aa6227e90a68026b138bb4.tar.gz |
protocol: implement get_avatar_details()
-rw-r--r-- | src/protocol.c | 37 | ||||
-rw-r--r-- | tests/twisted/cm/protocols.py | 21 |
2 files changed, 58 insertions, 0 deletions
diff --git a/src/protocol.c b/src/protocol.c index 9089e0d..dc2fa64 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -31,6 +31,7 @@ #include <telepathy-glib/telepathy-glib.h> #include "connection.h" +#include "connection-avatars.h" #include "debug.h" G_DEFINE_TYPE (HazeProtocol, haze_protocol, TP_TYPE_BASE_PROTOCOL) @@ -995,6 +996,41 @@ haze_protocol_dup_authentication_types (TpBaseProtocol *base) } static void +haze_protocol_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) +{ + HazeProtocol *self = HAZE_PROTOCOL (base); + PurpleBuddyIconSpec *icon_spec; + + icon_spec = &(self->priv->prpl_info->icon_spec); + + if (icon_spec->format == NULL) + { + /* We don't support avatar for this protocol */ + *supported_mime_types = NULL; + *min_height = 0; + *min_width = 0; + *rec_height = 0; + *rec_width = 0; + *max_height = 0; + *max_width = 0; + *max_bytes = 0; + return; + } + + haze_connection_get_icon_spec_requirements (icon_spec, supported_mime_types, + min_height, min_width, rec_height, rec_width, max_height, max_width, + max_bytes); +} + +static void haze_protocol_class_init (HazeProtocolClass *cls) { GObjectClass *object_class = (GObjectClass *) cls; @@ -1009,6 +1045,7 @@ haze_protocol_class_init (HazeProtocolClass *cls) base_class->get_connection_details = haze_protocol_get_connection_details; base_class->dup_authentication_types = haze_protocol_dup_authentication_types; + base_class->get_avatar_details = haze_protocol_get_avatar_details; g_type_class_add_private (cls, sizeof (HazeProtocolPrivate)); object_class->get_property = haze_protocol_get_property; diff --git a/tests/twisted/cm/protocols.py b/tests/twisted/cm/protocols.py index d0c67ce..1e8d3a7 100644 --- a/tests/twisted/cm/protocols.py +++ b/tests/twisted/cm/protocols.py @@ -27,6 +27,7 @@ def test(q, bus, conn, stream): protocol_iface = dbus.Interface(protocol, cs.PROTOCOL) protocol_props = dbus.Interface(protocol, cs.PROPERTIES_IFACE) flat_props = protocol_props.GetAll(cs.PROTOCOL) + protocol_avatar_props = protocol_props.GetAll(cs.PROTOCOL_IFACE_AVATARS) # Protocol is supposed to implement Interface.Avatars iff the # connection implements Avatars as well. @@ -105,6 +106,16 @@ def test(q, bus, conn, stream): assertDoesNotContain(cs.CONN_IFACE_AVATARS, flat_props['ConnectionInterfaces']) assertDoesNotContain(cs.CONN_IFACE_CONTACT_BLOCKING, flat_props['ConnectionInterfaces']) assertDoesNotContain(cs.CONN_IFACE_MAIL_NOTIFICATION + '.DRAFT', flat_props['ConnectionInterfaces']) + + # Avatar not supported + assertEquals(0, protocol_avatar_props['MaximumAvatarBytes']) + assertEquals(0, protocol_avatar_props['MaximumAvatarHeight']) + assertEquals(0, protocol_avatar_props['MaximumAvatarWidth']) + assertEquals(0, protocol_avatar_props['MinimumAvatarHeight']) + assertEquals(0, protocol_avatar_props['MinimumAvatarWidth']) + assertEquals(0, protocol_avatar_props['RecommendedAvatarHeight']) + assertEquals(0, protocol_avatar_props['RecommendedAvatarWidth']) + assertEquals([], protocol_avatar_props['SupportedAvatarMIMETypes']) elif name == 'myspace': assertEquals('x-myspace', flat_props['VCardField']) assertEquals('im-myspace', flat_props['Icon']) @@ -154,6 +165,16 @@ def test(q, bus, conn, stream): assertContains(cs.CONN_IFACE_AVATARS, flat_props['ConnectionInterfaces']) assertContains(cs.CONN_IFACE_CONTACT_BLOCKING, flat_props['ConnectionInterfaces']) assertContains(cs.CONN_IFACE_MAIL_NOTIFICATION + '.DRAFT', flat_props['ConnectionInterfaces']) + + # libpurple currently says there's no max size + assertEquals(0, protocol_avatar_props['MaximumAvatarBytes']) + assertEquals(96, protocol_avatar_props['MaximumAvatarHeight']) + assertEquals(96, protocol_avatar_props['MaximumAvatarWidth']) + assertEquals(32, protocol_avatar_props['MinimumAvatarHeight']) + assertEquals(32, protocol_avatar_props['MinimumAvatarWidth']) + assertEquals(0, protocol_avatar_props['RecommendedAvatarHeight']) + assertEquals(0, protocol_avatar_props['RecommendedAvatarWidth']) + assertEquals(['image/png'], protocol_avatar_props['SupportedAvatarMIMETypes']) elif name == 'qq': assertEquals('x-qq', flat_props['VCardField']) assertEquals('im-qq', flat_props['Icon']) |