/dev/tomkiewicz/new-smileys: 3610871f39ab: Custom smileys: make ...

Tomasz Wasilczyk twasilczyk at pidgin.im
Fri Apr 4 20:05:02 EDT 2014


Changeset: 3610871f39aba264902e705b0ab6fea7ae44212e
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-05 02:04 +0200
Branch:	 default
URL: https://hg.pidgin.im/dev/tomkiewicz/new-smileys/rev/3610871f39ab

Description:

Custom smileys: make them working with MSN

diffstat:

 libpurple/protocols/msn/msn.c     |  43 +++++---------------------------------
 libpurple/protocols/msn/slpcall.c |  14 ++++++------
 2 files changed, 13 insertions(+), 44 deletions(-)

diffs (145 lines):

diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -37,6 +37,7 @@
 #include "prefs.h"
 #include "session.h"
 #include "smiley.h"
+#include "smiley-custom.h"
 #include "state.h"
 #include "util.h"
 #include "cmds.h"
@@ -1468,7 +1469,9 @@ static void msn_emoticon_destroy(MsnEmot
 
 static GSList* msn_msg_grab_emoticons(const char *msg, const char *username)
 {
-#if 0
+	//TODO: replace it with:
+	//found_smileys = purple_smiley_find(purple_smiley_custom_get_list(), xhtml)
+	//but: is it xhtml?
 	GSList *list;
 	GList *smileys;
 	PurpleSmiley *smiley;
@@ -1478,7 +1481,7 @@ static GSList* msn_msg_grab_emoticons(co
 	int length;
 
 	list = NULL;
-	smileys = purple_smileys_get_all();
+	smileys = purple_smiley_list_get_all(purple_smiley_custom_get_list());
 	length = strlen(msg);
 
 	for (; smileys; smileys = g_list_delete_link(smileys, smileys)) {
@@ -1489,7 +1492,7 @@ static GSList* msn_msg_grab_emoticons(co
 		if (!ptr)
 			continue;
 
-		img = purple_smiley_get_stored_image(smiley);
+		img = purple_smiley_get_image(smiley);
 
 		emoticon = g_new0(MsnEmoticon, 1);
 		emoticon->smile = g_strdup(purple_smiley_get_shortcut(smiley));
@@ -1498,14 +1501,10 @@ static GSList* msn_msg_grab_emoticons(co
 				purple_imgstore_get_filename(img),
 				username, MSN_OBJECT_EMOTICON);
 
-		purple_imgstore_unref(img);
 		list = g_slist_prepend(list, emoticon);
 	}
 
 	return list;
-#else
-	return NULL;
-#endif
 }
 
 void
@@ -2029,9 +2028,6 @@ msn_chat_send(PurpleConnection *gc, int 
 	char *msgformat;
 	char *msgtext;
 	size_t msglen;
-	MsnEmoticon *smile;
-	GSList *smileys;
-	GString *emoticons = NULL;
 
 	account = purple_connection_get_account(gc);
 	session = purple_connection_get_protocol_data(gc);
@@ -2060,33 +2056,6 @@ msn_chat_send(PurpleConnection *gc, int 
 	msg = msn_message_new_plain(msgtext);
 	msn_message_set_header(msg, "X-MMS-IM-Format", msgformat);
 
-#if 0
-	smileys = msn_msg_grab_emoticons(msg->body, username);
-	while (smileys) {
-		smile = (MsnEmoticon *)smileys->data;
-		emoticons = msn_msg_emoticon_add(emoticons, smile);
-		if (purple_conversation_custom_smiley_add(swboard->conv, smile->smile,
-		                                  "sha1", purple_smiley_get_checksum(smile->ps),
-		                                  FALSE)) {
-			gconstpointer data;
-			size_t len;
-			data = purple_smiley_get_data(smile->ps, &len);
-			purple_conversation_custom_smiley_write(swboard->conv, smile->smile, data, len);
-			purple_conversation_custom_smiley_close(swboard->conv, smile->smile);
-		}
-		msn_emoticon_destroy(smile);
-		smileys = g_slist_delete_link(smileys, smileys);
-	}
-#else
-	(void)smile;
-	(void)smileys;
-#endif
-
-	if (emoticons) {
-		msn_send_emoticons(swboard, emoticons);
-		g_string_free(emoticons, TRUE);
-	}
-
 	msn_switchboard_send_msg(swboard, msg, FALSE);
 	msn_message_unref(msg);
 
diff --git a/libpurple/protocols/msn/slpcall.c b/libpurple/protocols/msn/slpcall.c
--- a/libpurple/protocols/msn/slpcall.c
+++ b/libpurple/protocols/msn/slpcall.c
@@ -25,6 +25,7 @@
 #include "internal.h"
 #include "debug.h"
 #include "smiley.h"
+#include "smiley-custom.h"
 
 #include "msnutils.h"
 #include "slpcall.h"
@@ -235,28 +236,27 @@ get_token(const char *str, const char *s
 static PurpleStoredImage *
 find_valid_emoticon(PurpleAccount *account, const char *path)
 {
-#if 0
 	GList *smileys;
 
 	if (!purple_account_get_bool(account, "custom_smileys", TRUE))
 		return NULL;
-	smileys = purple_smileys_get_all();
+	smileys = purple_smiley_list_get_all(purple_smiley_custom_get_list());
+
+	// TODO: rewrite it with XXX
 
 	for (; smileys; smileys = g_list_delete_link(smileys, smileys)) {
 		PurpleSmiley *smiley;
 		PurpleStoredImage *img;
 
 		smiley = smileys->data;
-		img = purple_smiley_get_stored_image(smiley);
+		img = purple_smiley_get_image(smiley);
 
-		if (purple_strequal(path, purple_imgstore_get_filename(img))) {
+		if (g_strcmp0(path, purple_smiley_get_path(smiley)) == 0) {
 			g_list_free(smileys);
+			purple_imgstore_ref(img);
 			return img;
 		}
-
-		purple_imgstore_unref(img);
 	}
-#endif
 
 	purple_debug_error("msn", "Received illegal request for file %s\n", path);
 	return NULL;



More information about the Commits mailing list