changeset 24061:fba7c73c8f02

Fixed a memory error, which was due to me destroying some hashtables in the wrong place... Removed the inclusion of data packets of size < 1024 directly in <message/> stanzas. The reason for this is there could be a lot of small smileys in one message. Thus hitting stanza limits. So rather than trying to keep track of the overall size, I let the receiver always request data it hasn't cached. Put back creation of the PurpleConversation when sening a message if purple_find_conversation_with_account returns NULL. This is needed for purple_conv_custom_smiley_add
author Marcus Lundblad <ml@update.uu.se>
date Mon, 08 Sep 2008 20:48:16 +0000
parents 0952f73a452c
children f1ead28fcc5a
files libpurple/protocols/jabber/data.c libpurple/protocols/jabber/libxmpp.c libpurple/protocols/jabber/message.c
diffstat 3 files changed, 21 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/data.c	Mon Sep 08 16:36:38 2008 +0000
+++ b/libpurple/protocols/jabber/data.c	Mon Sep 08 20:48:16 2008 +0000
@@ -160,24 +160,30 @@
 const JabberData *
 jabber_data_find_local_by_alt(const gchar *alt)
 {
+	purple_debug_info("jabber", "looking up local smiley with alt = %s\n", alt);
 	return g_hash_table_lookup(local_data_by_alt, alt);
 }
 
 const JabberData *
 jabber_data_find_local_by_cid(const gchar *cid)
 {
+	purple_debug_info("jabber", "lookup local smiley with cid = %s\n", cid);
 	return g_hash_table_lookup(local_data_by_cid, cid);
 }
 
 const JabberData *
 jabber_data_find_remote_by_cid(const gchar *cid)
 {
+	purple_debug_info("jabber", "lookup remote smiley with cid = %s\n", cid);
+	
 	return g_hash_table_lookup(remote_data_by_cid, cid);
 }
 
 void
 jabber_data_associate_local(JabberData *data, const gchar *alt)
 {
+	purple_debug_info("jabber", "associating local smiley\n alt = %s, cid = %s\n",
+		alt, jabber_data_get_cid(data));
 	g_hash_table_insert(local_data_by_alt, g_strdup(alt), data);
 	g_hash_table_insert(local_data_by_cid, g_strdup(jabber_data_get_cid(data)), 
 		data);
@@ -186,6 +192,8 @@
 void
 jabber_data_associate_remote(JabberData *data)
 {
+	purple_debug_info("jabber", "associating remote smiley, cid = %s\n",
+		jabber_data_get_cid(data));
 	g_hash_table_insert(remote_data_by_cid, g_strdup(jabber_data_get_cid(data)), 
 		data);
 }
--- a/libpurple/protocols/jabber/libxmpp.c	Mon Sep 08 16:36:38 2008 +0000
+++ b/libpurple/protocols/jabber/libxmpp.c	Mon Sep 08 20:48:16 2008 +0000
@@ -137,8 +137,6 @@
 			     purple_marshal_VOID__POINTER_POINTER, NULL, 2,
 			     purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
 			     purple_value_new_outgoing(PURPLE_TYPE_STRING));
-			   
-	jabber_data_uninit();
 	
 	return TRUE;
 }
@@ -151,6 +149,8 @@
 	
 	purple_signal_unregister(plugin, "jabber-sending-text");
 	
+	jabber_data_uninit();
+	
 	return TRUE;
 }
 
--- a/libpurple/protocols/jabber/message.c	Mon Sep 08 16:36:38 2008 +0000
+++ b/libpurple/protocols/jabber/message.c	Mon Sep 08 20:48:16 2008 +0000
@@ -606,6 +606,11 @@
 						conv =
 							purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY,
 								who, account);
+						if (!conv) {
+							/* we need to create the conversation here */
+							conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
+								account, who);
+						}
 					}
 
 					/* process any newly provided smileys */
@@ -631,18 +636,24 @@
 					const gchar *cid = ref->cid;
 					const gchar *alt = ref->alt;
 
+					purple_debug_info("jabber", 
+						"about to add custom smiley %s to the conv\n", alt);
 					if (purple_conv_custom_smiley_add(conv, alt, "cid", cid,
 						    TRUE)) {
 						const JabberData *data =
 								jabber_data_find_remote_by_cid(cid);
 						/* if data is already known, we add write it immediatly */
 						if (data) {
+							purple_debug_info("jabber", 
+								"data is already known\n"); 
 							purple_conv_custom_smiley_write(conv, alt,
 								jabber_data_get_data(data),
 								jabber_data_get_size(data));
 							purple_conv_custom_smiley_close(conv, alt);
 						} else {
 							/* we need to request the smiley (data) */
+							purple_debug_info("jabber",
+								"data is unknown, need to request it\n");
 							jabber_message_send_data_request(js, conv, cid, who,
 								alt);
 						}
@@ -1033,11 +1044,6 @@
 							"cache local smiley alt = %s, cid = %s\n",
 							shortcut, jabber_data_get_cid(new_data));
 						jabber_data_associate_local(new_data, shortcut);
-						/* if the size of the data is small enough, include it */
-						if (jabber_data_get_size(new_data) <= 1024) {
-							xmlnode_insert_child(message,
-								jabber_data_get_xml_definition(new_data));
-						}
 					}
 				}