xmpp.custom_smiley: 90c3fd08: Fixed a memory error, which was due to m...
malu at pidgin.im
malu at pidgin.im
Mon Sep 8 16:50:34 EDT 2008
-----------------------------------------------------------------
Revision: 90c3fd089e8c0f0acd6f0fda1f862fbfec2fcc2f
Ancestor: 70e776bd48010fe9a03f99145b62006f971319ea
Author: malu at pidgin.im
Date: 2008-09-08T20:48:16
Branch: im.pidgin.xmpp.custom_smiley
URL: http://d.pidgin.im/viewmtn/revision/info/90c3fd089e8c0f0acd6f0fda1f862fbfec2fcc2f
Modified files:
libpurple/protocols/jabber/data.c
libpurple/protocols/jabber/libxmpp.c
libpurple/protocols/jabber/message.c
ChangeLog:
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
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/data.c b28f021faa6c62a3b8b84f9860977a9e93929e3c
+++ libpurple/protocols/jabber/data.c 244dcce069806028c4bbc3f1554c6a06ab688799
@@ -160,24 +160,30 @@ jabber_data_find_local_by_alt(const gcha
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 @@ jabber_data_associate_remote(JabberData
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);
}
============================================================
--- libpurple/protocols/jabber/libxmpp.c 9a06006ad08d53731970b6166ec19f07eb8d52dd
+++ libpurple/protocols/jabber/libxmpp.c 31613decdb030de3b53c0cc7925068de5f40deb2
@@ -137,8 +137,6 @@ static gboolean load_plugin(PurplePlugin
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 @@ static gboolean unload_plugin(PurplePlug
purple_signal_unregister(plugin, "jabber-sending-text");
+ jabber_data_uninit();
+
return TRUE;
}
============================================================
--- libpurple/protocols/jabber/message.c 5adb5ae2631ff98a1c3a1f2bd90dfd1fbd89f5d9
+++ libpurple/protocols/jabber/message.c 306b31c48906f4a3f333db8adafaa728378a5d79
@@ -606,6 +606,11 @@ void jabber_message_parse(JabberStream *
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 @@ void jabber_message_parse(JabberStream *
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 @@ void jabber_message_send(JabberMessage *
"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));
- }
}
}
More information about the Commits
mailing list