From 47e104d55a6a86e153bcf94f55d05d23fe3a0c58 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 17 Sep 2013 17:22:35 +0200 Subject: [PATCH 2/4] avatars: factor out dup_mime_types() --- src/connection-avatars.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/connection-avatars.c b/src/connection-avatars.c index a955049..198bf7d 100644 --- a/src/connection-avatars.c +++ b/src/connection-avatars.c @@ -32,6 +32,25 @@ #include "debug.h" static gchar ** +dup_mime_types (PurpleBuddyIconSpec *icon_spec) +{ + gchar **mime_types, **i; + gchar *format; + + mime_types = g_strsplit (icon_spec->format, ",", 0); + + for (i = mime_types; *i != NULL; i++) + { + format = *i; + /* FIXME: image/ico is not the correct mime type. */ + *i = g_strconcat ("image/", format, NULL); + g_free (format); + } + + return mime_types; +} + +static gchar ** _get_acceptable_mime_types (HazeConnection *self) { PurplePluginProtocolInfo *prpl_info = HAZE_CONNECTION_GET_PRPL_INFO (self); @@ -40,20 +59,8 @@ _get_acceptable_mime_types (HazeConnection *self) if (self->acceptable_avatar_mime_types == NULL) { - gchar **mime_types, **i; - gchar *format; - - mime_types = g_strsplit (prpl_info->icon_spec.format, ",", 0); - - for (i = mime_types; *i != NULL; i++) - { - format = *i; - /* FIXME: image/ico is not the correct mime type. */ - *i = g_strconcat ("image/", format, NULL); - g_free (format); - } - - self->acceptable_avatar_mime_types = mime_types; + self->acceptable_avatar_mime_types = dup_mime_types ( + &prpl_info->icon_spec); } return self->acceptable_avatar_mime_types; -- 1.8.3.1