pidgin: 864b50e5: ft: Fix a bunch of uses of 0 as an 'inva...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Mon Aug 10 22:46:16 EDT 2009
-----------------------------------------------------------------
Revision: 864b50e56d376132989db9f91db76555f9d76b42
Ancestor: c16910f9501709e93fca69bbfa44975763db46ae
Author: darkrain42 at pidgin.im
Date: 2009-08-11T02:41:09
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/864b50e56d376132989db9f91db76555f9d76b42
Modified files:
libpurple/ft.c libpurple/ft.h
libpurple/protocols/jabber/si.c
libpurple/protocols/msn/slplink.c
libpurple/protocols/msnp9/slplink.c
ChangeLog:
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
purple_xfer_start still accepts it to mean "Don't set up any watches"
to maintain backward compatibility with third-party prpls, since old
versions of libpurple won't work with -1.
-------------- next part --------------
============================================================
--- libpurple/ft.c fe00c06864711f5f577548ddeaa9f5661714da6b
+++ libpurple/ft.c be22627fce1aee64b6129bec41e4db10e0d1a5e1
@@ -1085,7 +1085,7 @@ begin_transfer(PurpleXfer *xfer, PurpleI
fseek(xfer->dest_fp, xfer->bytes_sent, SEEK_SET);
}
- if (xfer->fd)
+ if (xfer->fd != -1)
xfer->watcher = purple_input_add(xfer->fd, cond, transfer_cb, xfer);
xfer->start_time = time(NULL);
@@ -1143,6 +1143,13 @@ purple_xfer_start(PurpleXfer *xfer, int
purple_xfer_set_status(xfer, PURPLE_XFER_STATUS_STARTED);
+ /*
+ * FIXME 3.0.0 -- there's too much broken code depending on fd == 0
+ * meaning "don't use a real fd"
+ */
+ if (fd == 0)
+ fd = -1;
+
if (type == PURPLE_XFER_RECEIVE) {
cond = PURPLE_INPUT_READ;
@@ -1189,7 +1196,7 @@ purple_xfer_end(PurpleXfer *xfer)
xfer->watcher = 0;
}
- if (xfer->fd != 0)
+ if (xfer->fd != -1)
close(xfer->fd);
if (xfer->dest_fp != NULL) {
@@ -1252,7 +1259,7 @@ purple_xfer_cancel_local(PurpleXfer *xfe
xfer->watcher = 0;
}
- if (xfer->fd != 0)
+ if (xfer->fd != -1)
close(xfer->fd);
if (xfer->dest_fp != NULL) {
@@ -1317,7 +1324,7 @@ purple_xfer_cancel_remote(PurpleXfer *xf
xfer->watcher = 0;
}
- if (xfer->fd != 0)
+ if (xfer->fd != -1)
close(xfer->fd);
if (xfer->dest_fp != NULL) {
============================================================
--- libpurple/ft.h 9761ac804b3e5f1fdb3cf6fa43ddc4b966c5c07d
+++ libpurple/ft.h 6324b78c116985dc27147503d6d733e8423c53de
@@ -587,6 +587,12 @@ gssize purple_xfer_write(PurpleXfer *xfe
* file receive transfer. On send, @a fd must be specified, and
* @a ip and @a port are ignored.
*
+ * Prior to libpurple 2.6.0, passing '0' to @a fd was special-cased to
+ * allow the protocol plugin to facilitate the file transfer itself. As of
+ * 2.6.0, this is supported (for backward compatibility), but will be
+ * removed in libpurple 3.0.0. If a prpl detects that the running libpurple
+ * is running 2.6.0 or higher, it should use the invalid fd '-1'.
+ *
* @param xfer The file transfer.
* @param fd The file descriptor for the socket.
* @param ip The IP address to connect to.
============================================================
--- libpurple/protocols/jabber/si.c 82802a7bd534a71353e535746666c03a6b4ee33a
+++ libpurple/protocols/jabber/si.c ed90adbfd032860e2258e555955fc7fe8863a144
@@ -1070,7 +1070,7 @@ jabber_si_xfer_ibb_open_cb(JabberStream
jsx->ibb_session = sess;
/* start the transfer */
- purple_xfer_start(xfer, 0, NULL, 0);
+ purple_xfer_start(xfer, -1, NULL, 0);
return TRUE;
} else {
/* failed to create IBB session */
@@ -1153,7 +1153,7 @@ jabber_si_xfer_ibb_opened_cb(JabberIBBSe
return;
}
- purple_xfer_start(xfer, 0, NULL, 0);
+ purple_xfer_start(xfer, -1, NULL, 0);
purple_xfer_set_bytes_sent(xfer, 0);
purple_xfer_update_progress(xfer);
jabber_si_xfer_ibb_send_data(sess);
============================================================
--- libpurple/protocols/msn/slplink.c 8545314bddf319cd7d45fd0593c04b9d089bb618
+++ libpurple/protocols/msn/slplink.c c9067bc51fc08b6bfa6d9028430d666339d27c0c
@@ -456,7 +456,7 @@ send_file_cb(MsnSlpCall *slpcall)
slpmsg->info = "SLP FILE";
xfer = (PurpleXfer *)slpcall->xfer;
- purple_xfer_start(slpcall->xfer, 0, NULL, 0);
+ purple_xfer_start(slpcall->xfer, -1, NULL, 0);
slpmsg->fp = xfer->dest_fp;
if (g_stat(purple_xfer_get_local_filename(xfer), &st) == 0)
slpmsg->size = st.st_size;
@@ -537,7 +537,7 @@ msn_slplink_process_msg(MsnSlpLink *slpl
if (xfer != NULL)
{
purple_xfer_ref(xfer);
- purple_xfer_start(xfer, 0, NULL, 0);
+ purple_xfer_start(xfer, -1, NULL, 0);
if (xfer->data == NULL) {
purple_xfer_unref(xfer);
============================================================
--- libpurple/protocols/msnp9/slplink.c f7c4bfd2a46f538ff73b29cc55cc6f1494bf954a
+++ libpurple/protocols/msnp9/slplink.c f8e8e8930009537d78896b001d6a295979c9e78d
@@ -496,7 +496,7 @@ send_file_cb(MsnSlpSession *slpsession)
slpmsg->info = "SLP FILE";
#endif
xfer = (PurpleXfer *)slpcall->xfer;
- purple_xfer_start(slpcall->xfer, 0, NULL, 0);
+ purple_xfer_start(slpcall->xfer, -1, NULL, 0);
slpmsg->fp = xfer->dest_fp;
if (g_stat(purple_xfer_get_local_filename(xfer), &st) == 0)
slpmsg->size = st.st_size;
@@ -561,7 +561,7 @@ msn_slplink_process_msg(MsnSlpLink *slpl
if (xfer != NULL)
{
purple_xfer_ref(xfer);
- purple_xfer_start(xfer, 0, NULL, 0);
+ purple_xfer_start(xfer, -1, NULL, 0);
if (xfer->data == NULL) {
purple_xfer_unref(xfer);
More information about the Commits
mailing list