Mercurial > pidgin
changeset 27874:6adbdd4b2963
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.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Tue, 11 Aug 2009 02:41:09 +0000 |
parents | 5a38fab8c199 |
children | 7754717d574c |
files | libpurple/ft.c libpurple/ft.h libpurple/protocols/jabber/si.c libpurple/protocols/msn/slplink.c libpurple/protocols/msnp9/slplink.c |
diffstat | 5 files changed, 23 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/ft.c Mon Aug 10 23:24:39 2009 +0000 +++ b/libpurple/ft.c Tue Aug 11 02:41:09 2009 +0000 @@ -1085,7 +1085,7 @@ 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_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 @@ xfer->watcher = 0; } - if (xfer->fd != 0) + if (xfer->fd != -1) close(xfer->fd); if (xfer->dest_fp != NULL) { @@ -1252,7 +1259,7 @@ xfer->watcher = 0; } - if (xfer->fd != 0) + if (xfer->fd != -1) close(xfer->fd); if (xfer->dest_fp != NULL) { @@ -1317,7 +1324,7 @@ xfer->watcher = 0; } - if (xfer->fd != 0) + if (xfer->fd != -1) close(xfer->fd); if (xfer->dest_fp != NULL) {
--- a/libpurple/ft.h Mon Aug 10 23:24:39 2009 +0000 +++ b/libpurple/ft.h Tue Aug 11 02:41:09 2009 +0000 @@ -587,6 +587,12 @@ * 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.
--- a/libpurple/protocols/jabber/si.c Mon Aug 10 23:24:39 2009 +0000 +++ b/libpurple/protocols/jabber/si.c Tue Aug 11 02:41:09 2009 +0000 @@ -1070,7 +1070,7 @@ 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 @@ 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);
--- a/libpurple/protocols/msn/slplink.c Mon Aug 10 23:24:39 2009 +0000 +++ b/libpurple/protocols/msn/slplink.c Tue Aug 11 02:41:09 2009 +0000 @@ -456,7 +456,7 @@ 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 @@ 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);
--- a/libpurple/protocols/msnp9/slplink.c Mon Aug 10 23:24:39 2009 +0000 +++ b/libpurple/protocols/msnp9/slplink.c Tue Aug 11 02:41:09 2009 +0000 @@ -496,7 +496,7 @@ 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 @@ 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);