diff src/protocols/msn/slp.c @ 10526:55e7d72fc09a

[gaim-migrate @ 11843] maquina writes: This patch implements a custom smiley API, and it also implements custom smileys for the msn protocol. As it stands, it is not able to cache custom smileys, and is not able to redefine a custom smiley without opening a new conversation. I modified it quite a bit, and didn't test it at all, so it probably doesn't work anymore. I'm not quite done with it yet either. Also, this is just receiving custom smileys. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Tue, 18 Jan 2005 18:31:32 +0000
parents bec9130b24d2
children 507c680b573e
line wrap: on
line diff
--- a/src/protocols/msn/slp.c	Tue Jan 18 15:36:39 2005 +0000
+++ b/src/protocols/msn/slp.c	Tue Jan 18 18:31:32 2005 +0000
@@ -739,18 +739,24 @@
 got_emoticon(MsnSlpCall *slpcall,
 			 const char *data, long long size)
 {
-	gaim_debug_info("msn", "Got smiley: %s\n", slpcall->data_info);
+
+	GaimConversation *conv;
+	GaimConnection *gc;
+	const char *who;
 
-#if 0
-	serv_got_smiley(slpcall->slplink->session->account->gc, 
-		slpcall->slplink->remote_user, slpcall->data_info, data, size);
-#endif
+	gc = slpcall->slplink->session->account->gc;
+	who = slpcall->slplink->remote_user;
+	
+	conv = gaim_find_conversation_with_account(GAIM_CONV_ANY, who, gc->account);
 
-#if 0
-	GaimConversation *conv;
-	GaimConnection *gc = slpsession->swboard->servconn->session->account->gc;
-	serv_got_smiley(gc, info, data, size);
-#endif
+	/* 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
+	*/
+	gaim_conv_custom_smiley_write(conv, slpcall->data_info, data, size);
+	gaim_conv_custom_smiley_close(conv, slpcall->data_info );
+ 
+	gaim_debug_info("msn", "Got smiley: %s\n", slpcall->data_info);
 }
 
 void
@@ -763,6 +769,9 @@
 	char *smile;
 	const char *who;
 
+	GaimConversation *conversation;
+	GaimConnection *gc;
+
 	session = cmdproc->servconn->session;
 
 	tokens = g_strsplit(msg->body, "\t", 2);
@@ -774,7 +783,13 @@
 
 	slplink = msn_session_get_slplink(session, who);
 
-	msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj);
+	gc = slplink->session->account->gc;
+
+	conversation = gaim_find_conversation_with_account(GAIM_CONV_ANY, who, gc->account);
+
+	if (gaim_conv_custom_smiley_add(conversation, smile, "sha1" /* i think it's a sha1 checksum? */, "base64 encoded checksum here, shx should fix this!")) {
+		msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj);
+	}
 
 	g_strfreev(tokens);
 }