summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-09-18 08:53:47 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-09-18 13:22:14 +0200
commit984690b5876ea02f88e4e6e39a4666e8dc351a35 (patch)
tree3862dc9daf13e73cf72c7ddf63b49e1a9024d769
parentd3d5a783e375764e9b8508ca4b90baee3f265d2f (diff)
downloadtelepathy-haze-984690b5876ea02f88e4e6e39a4666e8dc351a35.tar.gz
avatars: factor out haze_connection_get_icon_spec_requirements()
-rw-r--r--src/connection-avatars.c38
-rw-r--r--src/connection-avatars.h12
2 files changed, 47 insertions, 3 deletions
diff --git a/src/connection-avatars.c b/src/connection-avatars.c
index 198bf7d..f4dca89 100644
--- a/src/connection-avatars.c
+++ b/src/connection-avatars.c
@@ -159,6 +159,36 @@ haze_connection_avatars_properties_getter (GObject *object,
}
}
+void
+haze_connection_get_icon_spec_requirements (PurpleBuddyIconSpec *icon_spec,
+ GStrv *mime_types,
+ guint *min_height,
+ guint *min_width,
+ guint *rec_height,
+ guint *rec_width,
+ guint *max_height,
+ guint *max_width,
+ guint *max_bytes)
+{
+ if (mime_types != NULL)
+ *mime_types = dup_mime_types (icon_spec);
+ if (min_height != NULL)
+ *min_height = icon_spec->min_height;
+ if (min_width != NULL)
+ *min_width = icon_spec->min_width;
+ /* libpurple has no recommendation */
+ if (rec_height != NULL)
+ *rec_height = 0;
+ if (rec_width != NULL)
+ *rec_width = 0;
+ if (max_height != NULL)
+ *max_height = icon_spec->max_height;
+ if (max_width != NULL)
+ *max_width = icon_spec->max_width;
+ if (max_bytes != NULL)
+ *max_bytes = icon_spec->max_filesize;
+}
+
static void
haze_connection_get_avatar_requirements (TpSvcConnectionInterfaceAvatars *self,
DBusGMethodInvocation *context)
@@ -167,6 +197,7 @@ haze_connection_get_avatar_requirements (TpSvcConnectionInterfaceAvatars *self,
TpBaseConnection *base = TP_BASE_CONNECTION (conn);
PurplePluginProtocolInfo *prpl_info;
PurpleBuddyIconSpec *icon_spec;
+ guint min_height, min_width, max_height, max_width, max_bytes;
TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
@@ -176,11 +207,12 @@ haze_connection_get_avatar_requirements (TpSvcConnectionInterfaceAvatars *self,
/* If the spec or the formats are null, this iface wasn't implemented. */
g_assert (icon_spec != NULL && icon_spec->format != NULL);
+ haze_connection_get_icon_spec_requirements (icon_spec, NULL, &min_height,
+ &min_width, NULL, NULL, &max_height, &max_width, &max_bytes);
+
tp_svc_connection_interface_avatars_return_from_get_avatar_requirements (
context, (const gchar **) _get_acceptable_mime_types (conn),
- icon_spec->min_width, icon_spec->min_height,
- icon_spec->max_width, icon_spec->max_height,
- icon_spec->max_filesize);
+ min_width, min_height, max_width, max_height, max_bytes);
}
static GArray *
diff --git a/src/connection-avatars.h b/src/connection-avatars.h
index e7ce3ce..8ac37ab 100644
--- a/src/connection-avatars.h
+++ b/src/connection-avatars.h
@@ -25,6 +25,8 @@
#include <glib-object.h>
#include <telepathy-glib/telepathy-glib.h>
+#include <libpurple/purple.h>
+
void haze_connection_avatars_iface_init (gpointer g_iface, gpointer iface_data);
void haze_connection_avatars_class_init (GObjectClass *object_class);
void haze_connection_avatars_init (GObject *object);
@@ -33,4 +35,14 @@ extern TpDBusPropertiesMixinPropImpl *haze_connection_avatars_properties;
void haze_connection_avatars_properties_getter (GObject *object,
GQuark interface, GQuark name, GValue *value, gpointer getter_data);
+void haze_connection_get_icon_spec_requirements (PurpleBuddyIconSpec *icon_spec,
+ GStrv *mime_types,
+ guint *min_height,
+ guint *min_width,
+ guint *rec_height,
+ guint *rec_width,
+ guint *max_height,
+ guint *max_width,
+ guint *max_bytes);
+
#endif