/pidgin/main: 64f331a1eaa0: Drop remote smileys in favor of remo...

Tomasz Wasilczyk twasilczyk at pidgin.im
Sat Apr 12 19:33:58 EDT 2014


Changeset: 64f331a1eaa0327fe7fcf3476c2899990d14717c
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-13 01:33 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/64f331a1eaa0

Description:

Drop remote smileys in favor of remote images

diffstat:

 doc/reference/libpurple/libpurple-docs.xml |    1 -
 libpurple/Makefile.am                      |    2 -
 libpurple/Makefile.mingw                   |    1 -
 libpurple/conversation.c                   |   35 +---
 libpurple/conversation.h                   |    5 +-
 libpurple/image-store.c                    |   19 ++
 libpurple/image-store.h                    |    3 +
 libpurple/protocols/jabber/message.c       |   17 +-
 libpurple/protocols/msn/msg.c              |   10 +-
 libpurple/smiley-list.c                    |   18 +-
 libpurple/smiley-remote.c                  |  243 -----------------------------
 libpurple/smiley-remote.h                  |  131 ---------------
 libpurple/smiley.c                         |   59 ++----
 libpurple/smiley.h                         |   24 +-
 pidgin/gtkconv.c                           |  185 +++++++++++++--------
 pidgin/themes/Contents/Resources/main.css  |   17 +-
 pidgin/themes/Template.html                |   15 +-
 17 files changed, 217 insertions(+), 568 deletions(-)

diffs (truncated from 1210 to 300 lines):

diff --git a/doc/reference/libpurple/libpurple-docs.xml b/doc/reference/libpurple/libpurple-docs.xml
--- a/doc/reference/libpurple/libpurple-docs.xml
+++ b/doc/reference/libpurple/libpurple-docs.xml
@@ -116,7 +116,6 @@
       <title>Smiley APIs</title>
 
         <xi:include href="xml/smiley.xml" />
-        <xi:include href="xml/smiley-remote.xml" />
         <xi:include href="xml/smiley-custom.xml" />
         <xi:include href="xml/smiley-list.xml" />
         <xi:include href="xml/smiley-theme.xml" />
diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -105,7 +105,6 @@ purple_coresources = \
 	smiley-custom.c \
 	smiley-list.c \
 	smiley-parser.c \
-	smiley-remote.c \
 	smiley-theme.c \
 	smiley.c \
 	dnsquery.c \
@@ -186,7 +185,6 @@ purple_coreheaders = \
 	smiley-custom.h \
 	smiley-list.h \
 	smiley-parser.h \
-	smiley-remote.h \
 	smiley-theme.h \
 	smiley.h \
 	dnsquery.h \
diff --git a/libpurple/Makefile.mingw b/libpurple/Makefile.mingw
--- a/libpurple/Makefile.mingw
+++ b/libpurple/Makefile.mingw
@@ -127,7 +127,6 @@ C_SRC =	\
 			smiley-custom.c \
 			smiley-list.c \
 			smiley-parser.c \
-			smiley-remote.c \
 			smiley-theme.c \
 			sound-theme-loader.c \
 			sound-theme.c \
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -941,13 +941,12 @@ purple_conversation_get_max_message_size
 	return prpl_info->get_max_message_size(conv);
 }
 
-PurpleRemoteSmiley *
+PurpleSmiley *
 purple_conversation_add_remote_smiley(PurpleConversation *conv,
 	const gchar *shortcut)
 {
 	PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
 	PurpleSmiley *smiley;
-	PurpleRemoteSmiley *rsmiley;
 
 	g_return_val_if_fail(priv != NULL, NULL);
 	g_return_val_if_fail(shortcut != NULL, NULL);
@@ -961,41 +960,30 @@ purple_conversation_add_remote_smiley(Pu
 
 	smiley = purple_smiley_list_get_by_shortcut(
 		priv->remote_smileys, shortcut);
-	if (smiley && !PURPLE_IS_REMOTE_SMILEY(smiley)) {
-		purple_debug_warning("conversation", "Invalid type of smiley "
-			"stored in remote smileys list");
-		return NULL;
-	}
 
 	/* smiley was already added */
 	if (smiley)
 		return NULL;
 
-	rsmiley = g_object_new(PURPLE_TYPE_REMOTE_SMILEY,
-		"shortcut", shortcut,
-		"is-ready", FALSE,
-		NULL);
+	smiley = purple_smiley_new_remote(shortcut);
 
-	if (!purple_smiley_list_add(priv->remote_smileys,
-		PURPLE_SMILEY(rsmiley)))
-	{
+	if (!purple_smiley_list_add(priv->remote_smileys, smiley)) {
 		purple_debug_error("conversation", "failed adding remote "
 			"smiley to the list");
-		g_object_unref(rsmiley);
+		g_object_unref(smiley);
 		return NULL;
 	}
 
 	/* priv->remote_smileys holds the only one ref */
-	g_object_unref(rsmiley);
-	return rsmiley;
+	g_object_unref(smiley);
+	return smiley;
 }
 
-PurpleRemoteSmiley *
+PurpleSmiley *
 purple_conversation_get_remote_smiley(PurpleConversation *conv,
 	const gchar *shortcut)
 {
 	PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
-	PurpleSmiley *smiley;
 
 	g_return_val_if_fail(priv != NULL, NULL);
 	g_return_val_if_fail(shortcut != NULL, NULL);
@@ -1004,15 +992,8 @@ purple_conversation_get_remote_smiley(Pu
 	if (priv->remote_smileys == NULL)
 		return NULL;
 
-	smiley = purple_smiley_list_get_by_shortcut(
+	return purple_smiley_list_get_by_shortcut(
 		priv->remote_smileys, shortcut);
-	if (smiley && !PURPLE_IS_REMOTE_SMILEY(smiley)) {
-		purple_debug_warning("conversation", "Invalid type of smiley "
-			"stored in remote smileys list");
-		return NULL;
-	}
-
-	return PURPLE_REMOTE_SMILEY(smiley);
 }
 
 PurpleSmileyList *
diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -196,7 +196,6 @@ struct _PurpleConversationClass {
 #include "e2ee.h"
 #include "log.h"
 #include "smiley-list.h"
-#include "smiley-remote.h"
 
 /**************************************************************************/
 /** PurpleConversationUiOps                                               */
@@ -686,7 +685,7 @@ purple_conversation_get_max_message_size
  * Returns: (transfer none): New smiley, or %NULL if it's already being
  *          retrieved (or possibly, in case of error).
  */
-PurpleRemoteSmiley *
+PurpleSmiley *
 purple_conversation_add_remote_smiley(PurpleConversation *conv,
 	const gchar *shortcut);
 
@@ -703,7 +702,7 @@ purple_conversation_add_remote_smiley(Pu
  *
  * Returns: (transfer none): The smiley, or %NULL if it doesn't exists.
  */
-PurpleRemoteSmiley *
+PurpleSmiley *
 purple_conversation_get_remote_smiley(PurpleConversation *conv,
 	const gchar *shortcut);
 
diff --git a/libpurple/image-store.c b/libpurple/image-store.c
--- a/libpurple/image-store.c
+++ b/libpurple/image-store.c
@@ -191,6 +191,25 @@ purple_image_store_get_from_uri(const gc
 	return purple_image_store_get(id);
 }
 
+gchar *
+purple_image_store_get_uri(PurpleImage *image)
+{
+	gboolean is_ready;
+	const gchar *path;
+	guint img_id;
+
+	g_return_val_if_fail(PURPLE_IS_IMAGE(image), NULL);
+
+	is_ready = purple_image_is_ready(image);
+	path = purple_image_get_path(image);
+
+	if (is_ready && path)
+		return g_filename_to_uri(path, NULL, NULL);
+
+	img_id = purple_image_store_add_weak(image);
+	return g_strdup_printf(PURPLE_IMAGE_STORE_PROTOCOL "%u", img_id);
+}
+
 void
 _purple_image_store_init(void)
 {
diff --git a/libpurple/image-store.h b/libpurple/image-store.h
--- a/libpurple/image-store.h
+++ b/libpurple/image-store.h
@@ -56,6 +56,9 @@ purple_image_store_get(guint id);
 PurpleImage *
 purple_image_store_get_from_uri(const gchar *uri);
 
+gchar *
+purple_image_store_get_uri(PurpleImage *image);
+
 void
 _purple_image_store_init(void);
 
diff --git a/libpurple/protocols/jabber/message.c b/libpurple/protocols/jabber/message.c
--- a/libpurple/protocols/jabber/message.c
+++ b/libpurple/protocols/jabber/message.c
@@ -489,19 +489,20 @@ jabber_message_add_remote_smileys(Jabber
 static void
 jabber_message_remote_smiley_got(JabberData *data, gchar *alt, gpointer _smiley)
 {
-	PurpleRemoteSmiley *smiley = _smiley;
+	PurpleSmiley *smiley = _smiley;
+	PurpleImage *image = purple_smiley_get_image(smiley);
 
 	g_free(alt); /* we really don't need it */
 
 	if (data) {
 		purple_debug_info("jabber",
 			"smiley data retrieved successfully");
-		purple_remote_smiley_write(smiley, jabber_data_get_data(data),
+		purple_image_transfer_write(image, jabber_data_get_data(data),
 			jabber_data_get_size(data));
-		purple_remote_smiley_close(smiley);
+		purple_image_transfer_close(image);
 	} else {
 		purple_debug_error("jabber", "failed retrieving smiley data");
-		purple_remote_smiley_failed(smiley);
+		purple_image_transfer_failed(image);
 	}
 
 	g_object_unref(smiley);
@@ -511,7 +512,7 @@ static void
 jabber_message_remote_smiley_add(JabberStream *js, PurpleConversation *conv,
 	const gchar *from, const gchar *shortcut, const gchar *cid)
 {
-	PurpleRemoteSmiley *smiley;
+	PurpleSmiley *smiley;
 	const JabberData *jdata;
 
 	purple_debug_misc("jabber", "about to add remote smiley %s to the conv",
@@ -527,11 +528,13 @@ jabber_message_remote_smiley_add(JabberS
 
 	jdata = jabber_data_find_remote_by_cid(js, from, cid);
 	if (jdata) {
+		PurpleImage *image = purple_smiley_get_image(smiley);
+
 		purple_debug_info("jabber", "smiley data is already known");
 
-		purple_remote_smiley_write(smiley, jabber_data_get_data(jdata),
+		purple_image_transfer_write(image, jabber_data_get_data(jdata),
 			jabber_data_get_size(jdata));
-		purple_remote_smiley_close(smiley);
+		purple_image_transfer_close(image);
 	} else {
 		gchar *alt = g_strdup(shortcut); /* it it really necessary? */
 
diff --git a/libpurple/protocols/msn/msg.c b/libpurple/protocols/msn/msg.c
--- a/libpurple/protocols/msn/msg.c
+++ b/libpurple/protocols/msn/msg.c
@@ -900,7 +900,8 @@ static void
 got_emoticon(MsnSlpCall *slpcall, const guchar *data, gsize size)
 {
 	PurpleConversation *conv;
-	PurpleRemoteSmiley *smiley;
+	PurpleSmiley *smiley;
+	PurpleImage *image;
 	MsnSwitchBoard *swboard;
 	const gchar *shortcut;
 
@@ -915,13 +916,14 @@ got_emoticon(MsnSlpCall *slpcall, const 
 
 	smiley = purple_conversation_get_remote_smiley(conv, shortcut);
 	g_return_if_fail(smiley);
+	image = purple_smiley_get_image(smiley);
 
 	/* FIXME: it would be better if we wrote the data as we received it
 	 * instead of all at once, calling write multiple times and close once
 	 * at the very end.
 	 */
-	purple_remote_smiley_write(smiley, data, size);
-	purple_remote_smiley_close(smiley);
+	purple_image_transfer_write(image, (gpointer)data, size);
+	purple_image_transfer_close(image);
 }
 
 void msn_emoticon_msg(MsnCmdProc *cmdproc, MsnMessage *msg)
@@ -958,7 +960,7 @@ void msn_emoticon_msg(MsnCmdProc *cmdpro
 	g_free(body_str);
 
 	for (tok = 0; tok < 9; tok += 2) {
-		PurpleRemoteSmiley *smiley;
+		PurpleSmiley *smiley;
 
 		if (tokens[tok] == NULL || tokens[tok + 1] == NULL) {
 			break;
diff --git a/libpurple/smiley-list.c b/libpurple/smiley-list.c
--- a/libpurple/smiley-list.c
+++ b/libpurple/smiley-list.c
@@ -97,9 +97,13 @@ purple_smiley_list_new(void)
 }
 
 static void
-remote_smiley_failed(PurpleSmiley *smiley, gpointer _list)
+remote_smiley_failed(PurpleImage *smiley_img, gpointer _list)
 {
 	PurpleSmileyList *list = _list;
+	PurpleSmiley *smiley;
+



More information about the Commits mailing list