changeset 11518:922782381027

[gaim-migrate @ 13763] The MSN specific parts of patch 1280944 from Francesco Fracassi to improve our support for custom smilies. (the UI part of that patch, or some derivative, is still required) committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 11 Sep 2005 17:22:28 +0000
parents d37a45a53106
children 0dfda214df89
files COPYRIGHT ChangeLog src/protocols/msn/slp.c src/protocols/msn/switchboard.c
diffstat 4 files changed, 39 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Sun Sep 11 17:15:16 2005 +0000
+++ b/COPYRIGHT	Sun Sep 11 17:22:28 2005 +0000
@@ -78,6 +78,7 @@
 Chris J. Friesen
 Free Software Foundation
 Decklin Foster
+Francesco Fracassi
 Adam Fritzler
 Max G.
 François Gagné
--- a/ChangeLog	Sun Sep 11 17:15:16 2005 +0000
+++ b/ChangeLog	Sun Sep 11 17:22:28 2005 +0000
@@ -19,7 +19,7 @@
 	* Add a "Last Seen" field to tooltips for buddies in your buddy
 	  list (Richard Laager)
 	* Buddy icons in buddy list tooltips (Felipe Contreras)
-	* Custom smileys for MSN (Irving Cordova)
+	* Custom smileys for MSN (Irving Cordova & Francesco Fracassi)
 	* Entries in the text replacement plugin are now sorted alphabetically
 	  (Richard Laager)
 	* Ability to set ICQ "require authorization" and "web aware"
--- a/src/protocols/msn/slp.c	Sun Sep 11 17:15:16 2005 +0000
+++ b/src/protocols/msn/slp.c	Sun Sep 11 17:22:28 2005 +0000
@@ -789,36 +789,57 @@
 	char **tokens;
 	char *smile, *body_str;
 	const char *body, *who, *sha1c;
+	guint tok;
 	size_t body_len;
 
-	GaimConversation *conversation;
-	GaimConnection *gc;
+	GaimConversation *conv;
 
 	session = cmdproc->servconn->session;
 
 	body = msn_message_get_bin_data(msg, &body_len);
 	body_str = g_strndup(body, body_len);
 
-	tokens = g_strsplit(body_str, "\t", 2);
+	/* MSN Messenger 7 may send more than one MSNObject in a single message...
+	 * Maybe 10 tokens is a reasonable max value. */
+	tokens = g_strsplit(body_str, "\t", 10);
 
 	g_free(body_str);
 
-	smile = tokens[0];
-	obj = msn_object_new_from_string(gaim_url_decode(tokens[1]));
+	for (tok = 0; tok < 9; tok += 2) {
+		if (tokens[tok] == NULL || tokens[tok + 1] == NULL) {
+			break;
+		}
+
+		smile = tokens[tok];
+		obj = msn_object_new_from_string(gaim_url_decode(tokens[tok + 1]));
 
-	who = msn_object_get_creator(obj);
-	sha1c = msn_object_get_sha1c(obj);
+		who = msn_object_get_creator(obj);
+		sha1c = msn_object_get_sha1c(obj);
 
-	slplink = msn_session_get_slplink(session, who);
+		slplink = msn_session_get_slplink(session, who);
+
+		conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, who,
+												   session->account);
 
-	gc = slplink->session->account->gc;
-
-	conversation = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, who, gc->account);
+		/* If the conversation doesn't exist then this is a custom smiley
+		 * used in the first message in a MSN conversation: we need to create
+		 * the conversation now, otherwise the custom smiley won't be shown.
+		 * This happens because every GtkIMHtml has its own smiley tree: if
+		 * the conversation doesn't exist then we cannot associate the new
+		 * smiley with its GtkIMHtml widget. */
+		if (!conv) {
+			conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, session->account, who);
+		}
 
-	if (gaim_conv_custom_smiley_add(conversation, smile, "sha1", sha1c)) {
-		msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj);
+		if (gaim_conv_custom_smiley_add(conv, smile, "sha1", sha1c)) {
+			msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj);
+		}
+
+		msn_object_destroy(obj);
+		obj =   NULL;
+		who =   NULL;
+		sha1c = NULL;
 	}
-
 	g_strfreev(tokens);
 }
 
--- a/src/protocols/msn/switchboard.c	Sun Sep 11 17:15:16 2005 +0000
+++ b/src/protocols/msn/switchboard.c	Sun Sep 11 17:22:28 2005 +0000
@@ -1233,6 +1233,8 @@
 						   msn_p2p_msg);
 	msn_table_add_msg_type(cbs_table, "text/x-mms-emoticon",
 						   msn_emoticon_msg);
+	msn_table_add_msg_type(cbs_table, "text/x-mms-animemoticon",
+	                                           msn_emoticon_msg);
 	msn_table_add_msg_type(cbs_table, "text/x-msnmsgr-datacast",
 						   nudge_msg);
 #if 0