cpw.malu.xmpp.jingle_ft: b8f49218: Remove left-over file transfer thumbnail...
malu at pidgin.im
malu at pidgin.im
Sun Jun 20 16:55:51 EDT 2010
-----------------------------------------------------------------
Revision: b8f492180651b61175e947f75144c809fafc1c25
Ancestor: 874bf9f058856f28c2ed428b8ec9825c7ba59f05
Author: malu at pidgin.im
Date: 2010-06-20T20:52:42
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/b8f492180651b61175e947f75144c809fafc1c25
Modified files:
libpurple/protocols/jabber/data.c
libpurple/protocols/jabber/jingle/file-transfer.c
libpurple/protocols/jabber/si.c
ChangeLog:
Remove left-over file transfer thumbnail (if the receiver haven't picked it
up when the tranfer is finished), avoids leaking BoB objects when sending
stuff to non-thumbnail-aware clients.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/data.c 6fda9e25126487bc940d6926f96d328c0c9202b1
+++ libpurple/protocols/jabber/data.c 8286c9d5f5926f57cabb5b0c429b6129c1c2ffff
@@ -117,7 +117,20 @@ jabber_data_destroy(JabberData *data)
void
jabber_data_destroy(JabberData *data)
{
- jabber_data_delete(data);
+ GList *alt_refs = g_hash_table_get_keys(local_data_by_alt);
+ GList *iter;
+
+ for (iter = alt_refs ; iter ; iter = g_list_next(iter)) {
+ const gchar *alt = iter->data;
+ JabberData *d = jabber_data_find_local_by_alt(alt);
+
+ if (purple_strequal(jabber_data_get_cid(d), jabber_data_get_cid(data))) {
+ g_hash_table_remove(local_data_by_alt, alt);
+ }
+ }
+
+ g_hash_table_remove(local_data_by_cid, jabber_data_get_cid(data));
+ g_hash_table_remove(remote_data_by_cid, jabber_data_get_cid(data));
}
const char *
============================================================
--- libpurple/protocols/jabber/jingle/file-transfer.c e743cda192113a9e3df57256b126990056f4bbb4
+++ libpurple/protocols/jabber/jingle/file-transfer.c 5624537ab3de04e0953a64f640c7fd99b10c6b40
@@ -16,6 +16,7 @@
#include "internal.h"
+#include "data.h"
#include "jingle.h"
#include "file-transfer.h"
#include "ibbs.h"
@@ -126,6 +127,16 @@ jingle_file_transfer_finalize (GObject *
priv->xfer->data = NULL;
}
+ if (priv->thumbnail_cid) {
+ JabberData *thumbnail =
+ jabber_data_find_local_by_cid(priv->thumbnail_cid);
+
+ if (thumbnail) {
+ purple_debug_info("jingle-ft", "disposing left-over thumbnail\n");
+ jabber_data_destroy(priv->thumbnail_cid);
+ }
+ }
+
G_OBJECT_CLASS(parent_class)->finalize(ft);
}
============================================================
--- libpurple/protocols/jabber/si.c 5b9a60008f2fe230051d80b7db1dcd68983b2033
+++ libpurple/protocols/jabber/si.c 271d270608089a320a02d4520081d0220b59ef85
@@ -72,6 +72,11 @@ typedef struct _JabberSIXfer {
JabberIBBSession *ibb_session;
guint ibb_timeout_handle;
PurpleCircBuffer *ibb_buffer;
+
+#if ENABLE_FT_THUMBNAILS
+ /* CID for thumbnail */
+ const gchar *thumbnail_cid;
+#endif
} JabberSIXfer;
/* some forward declarations */
@@ -954,12 +959,11 @@ static void jabber_si_xfer_send_request(
JabberSIXfer *jsx = xfer->data;
JabberIq *iq;
xmlnode *si, *feature, *x, *field, *option, *value;
- const gchar *thumbnail_cid = NULL;
xfer->filename = g_path_get_basename(xfer->local_filename);
#if ENABLE_FT_THUMBNAILS
- thumbnail_cid = jabber_xfer_add_thumbnail(jsx->js, xfer);
+ jsx->thumbnail_cid = jabber_xfer_add_thumbnail(jsx->js, xfer);
#endif
iq = jabber_iq_new(jsx->js, JABBER_IQ_SET);
@@ -971,7 +975,7 @@ static void jabber_si_xfer_send_request(
xmlnode_set_attrib(si, "profile",
"http://jabber.org/protocol/si/profile/file-transfer");
xmlnode_insert_child(si,
- jabber_xfer_create_file_element(xfer, thumbnail_cid));
+ jabber_xfer_create_file_element(xfer, jsx->thumbnail_cid));
feature = xmlnode_new_child(si, "feature");
xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
x = xmlnode_new_child(feature, "x");
@@ -1044,6 +1048,18 @@ static void jabber_si_xfer_free(PurpleXf
purple_circ_buffer_destroy(jsx->ibb_buffer);
}
+#if ENABLE_FT_THUMBNAILS
+ if (jsx->thumbnail_cid) {
+ JabberData *thumbnail =
+ jabber_data_find_local_by_cid(jsx->thumbnail_cid);
+
+ if (thumbnail) {
+ purple_debug_info("jabber", "disposing left-over thumbnail\n");
+ jabber_data_destroy(thumbnail);
+ }
+ }
+#endif
+
purple_debug_info("jabber", "jabber_si_xfer_free(): freeing jsx %p\n", jsx);
g_free(jsx->stream_id);
More information about the Commits
mailing list