cpw.malu.xmpp.ibb_ft: 3de5eea9: Make the IBB-handling code in si.c "stea...
malu at pidgin.im
malu at pidgin.im
Wed Jan 14 13:46:31 EST 2009
-----------------------------------------------------------------
Revision: 3de5eea959151773885ba601f681aec2431dd47d
Ancestor: 8669ca67ea8c7629241fefd2acec0493a9a7988f
Author: malu at pidgin.im
Date: 2009-01-14T18:42:17
Branch: im.pidgin.cpw.malu.xmpp.ibb_ft
URL: http://d.pidgin.im/viewmtn/revision/info/3de5eea959151773885ba601f681aec2431dd47d
Modified files:
libpurple/protocols/jabber/si.c
ChangeLog:
Make the IBB-handling code in si.c "steal" the dest_fp from PurpleXfer in the
same manner as is done the MSN prpl. This saves having to open the same file
twice and risking a duplicate fclose.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/si.c dbb250a80fdf7f556d7ba080ffa2ded30cd1605f
+++ libpurple/protocols/jabber/si.c bd2e04fbe3b1b1f7fb82c66991ebb90340f91c4b
@@ -1029,21 +1029,14 @@ jabber_si_xfer_ibb_open_cb(JabberStream
JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
JabberIBBSession *sess =
jabber_ibb_session_create_from_xmlnode(js, packet, xfer);
- const char *filename;
jabber_si_bytestreams_ibb_timeout_remove(jsx);
if (sess) {
- /* open the file to write to */
- filename = purple_xfer_get_local_filename(xfer);
- jsx->fp = g_fopen(filename, "wb");
- if (jsx->fp == NULL) {
- purple_debug_error("jabber", "failed to open file %s for writing: %s\n",
- filename, g_strerror(errno));
- purple_xfer_cancel_remote(xfer);
- return FALSE;
- }
-
+ jsx->fp = xfer->dest_fp;
+ xfer->dest_fp = NULL;
+ /* the FD we get from xfer should never be NULL (see ft.c) */
+
/* setup callbacks here...*/
jabber_ibb_session_set_data_received_callback(sess,
jabber_si_xfer_ibb_recv_data_cb);
@@ -1125,18 +1118,10 @@ jabber_si_xfer_ibb_opened_cb(JabberIBBSe
PurpleAccount *account = purple_connection_get_account(gc);
if (jabber_ibb_session_get_state(sess) == JABBER_IBB_SESSION_OPENED) {
- const char *filename = purple_xfer_get_local_filename(xfer);
- jsx->fp = g_fopen(filename, "rb");
- if (jsx->fp == NULL) {
- purple_debug_error("jabber", "Failed to open file %s for reading: %s\n",
- filename, g_strerror(errno));
- purple_xfer_error(purple_xfer_get_type(xfer), account,
- jabber_ibb_session_get_who(sess),
- _("Failed to open the file"));
- purple_xfer_cancel_local(xfer);
- return;
- }
-
+ jsx->fp = xfer->dest_fp;
+ xfer->dest_fp = NULL; /* disable double fclose */
+ /* the FD we get from xfer should never be NULL (see ft.c) */
+
purple_xfer_start(xfer, 0, NULL, 0);
purple_xfer_set_bytes_sent(xfer, 0);
purple_xfer_update_progress(xfer);
More information about the Commits
mailing list