Mercurial > pidgin.yaz
diff libpurple/protocols/jabber/si.c @ 32827:4a34689eeb33 default tip
merged from im.pidgin.pidgin
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 19 Nov 2011 14:42:54 +0900 |
parents | 0f94ec89f0bc fb5b5f6cf111 |
children |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/si.c Mon Sep 26 14:57:21 2011 +0900 +++ b/libpurple/protocols/jabber/si.c Sat Nov 19 14:42:54 2011 +0900 @@ -395,8 +395,8 @@ if (jsx->rxlen < jsx->rxmaxlen) return; - purple_input_remove(xfer->watcher); - xfer->watcher = 0; + purple_input_remove(purple_xfer_get_watcher(xfer)); + purple_xfer_set_watcher(xfer, 0); g_free(jsx->rxqueue); jsx->rxqueue = NULL; @@ -464,8 +464,8 @@ if(jsx->rxlen - 5 < jsx->rxqueue[4] + 2) return; - purple_input_remove(xfer->watcher); - xfer->watcher = 0; + purple_input_remove(purple_xfer_get_watcher(xfer)); + purple_xfer_set_watcher(xfer, 0); dstaddr = g_strdup_printf("%s%s@%s/%s%s", jsx->stream_id, jsx->js->user->node, jsx->js->user->domain, @@ -510,8 +510,8 @@ jsx->rxqueue[5+strlen(host)] = 0x00; jsx->rxqueue[6+strlen(host)] = 0x00; - xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE, - jabber_si_xfer_bytestreams_send_read_again_resp_cb, xfer); + purple_xfer_set_watcher(xfer, purple_input_add(source, PURPLE_INPUT_WRITE, + jabber_si_xfer_bytestreams_send_read_again_resp_cb, xfer)); jabber_si_xfer_bytestreams_send_read_again_resp_cb(xfer, source, PURPLE_INPUT_WRITE); } @@ -541,9 +541,9 @@ /* If we sent a "Success", wait for a response, otherwise give up and cancel */ if (jsx->rxqueue[1] == 0x00) { - purple_input_remove(xfer->watcher); - xfer->watcher = purple_input_add(source, PURPLE_INPUT_READ, - jabber_si_xfer_bytestreams_send_read_again_cb, xfer); + purple_input_remove(purple_xfer_get_watcher(xfer)); + purple_xfer_set_watcher(xfer, purple_input_add(source, PURPLE_INPUT_READ, + jabber_si_xfer_bytestreams_send_read_again_cb, xfer)); g_free(jsx->rxqueue); jsx->rxqueue = NULL; jsx->rxlen = 0; @@ -565,7 +565,7 @@ purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_read_cb\n"); - xfer->fd = source; + purple_xfer_set_fd(xfer, source); /** Try to read the SOCKS5 header */ if(jsx->rxlen < 2) { @@ -621,10 +621,10 @@ jsx->rxqueue = g_malloc(jsx->rxmaxlen); jsx->rxqueue[0] = 0x05; jsx->rxqueue[1] = 0x00; - purple_input_remove(xfer->watcher); - xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE, + purple_input_remove(purple_xfer_get_watcher(xfer)); + purple_xfer_set_watcher(xfer, purple_input_add(source, PURPLE_INPUT_WRITE, jabber_si_xfer_bytestreams_send_read_response_cb, - xfer); + xfer)); jabber_si_xfer_bytestreams_send_read_response_cb(xfer, source, PURPLE_INPUT_WRITE); jsx->rxqueue = NULL; @@ -639,9 +639,9 @@ jsx->rxqueue = g_malloc(jsx->rxmaxlen); jsx->rxqueue[0] = 0x05; jsx->rxqueue[1] = 0xFF; - purple_input_remove(xfer->watcher); - xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE, - jabber_si_xfer_bytestreams_send_read_response_cb, xfer); + purple_input_remove(purple_xfer_get_watcher(xfer)); + purple_xfer_set_watcher(xfer, purple_input_add(source, PURPLE_INPUT_WRITE, + jabber_si_xfer_bytestreams_send_read_response_cb, xfer)); jabber_si_xfer_bytestreams_send_read_response_cb(xfer, source, PURPLE_INPUT_WRITE); } @@ -676,7 +676,7 @@ return; } - purple_input_remove(xfer->watcher); + purple_input_remove(purple_xfer_get_watcher(xfer)); close(source); jsx->local_streamhost_fd = -1; @@ -686,8 +686,8 @@ fcntl(acceptfd, F_SETFD, FD_CLOEXEC); #endif - xfer->watcher = purple_input_add(acceptfd, PURPLE_INPUT_READ, - jabber_si_xfer_bytestreams_send_read_cb, xfer); + purple_xfer_set_watcher(xfer, purple_input_add(acceptfd, PURPLE_INPUT_READ, + jabber_si_xfer_bytestreams_send_read_cb, xfer)); } static void @@ -763,7 +763,7 @@ jsx->js->user->domain, jsx->js->user->resource); if (!strcmp(jid, my_jid)) { purple_debug_info("jabber", "Got local SOCKS5 streamhost-used.\n"); - purple_xfer_start(xfer, xfer->fd, NULL, -1); + purple_xfer_start(xfer, purple_xfer_get_fd(xfer), NULL, -1); } else { /* if available, try to revert to IBB... */ if (jsx->stream_method & STREAM_METHOD_IBB) { @@ -787,9 +787,9 @@ } /* Clean up the local streamhost - it isn't going to be used.*/ - if (xfer->watcher > 0) { - purple_input_remove(xfer->watcher); - xfer->watcher = 0; + if (purple_xfer_get_watcher(xfer) > 0) { + purple_input_remove(purple_xfer_get_watcher(xfer)); + purple_xfer_set_watcher(xfer, 0); } if (jsx->local_streamhost_fd >= 0) { close(jsx->local_streamhost_fd); @@ -847,7 +847,7 @@ jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node, jsx->js->user->domain, jsx->js->user->resource); - xfer->local_port = purple_network_get_port_from_fd(sock); + purple_xfer_set_local_port(xfer, purple_network_get_port_from_fd(sock)); g_snprintf(port, sizeof(port), "%hu", purple_xfer_get_local_port(xfer)); public_ip = purple_network_get_my_ip(jsx->js->fd); @@ -878,8 +878,8 @@ g_free(jid); /* The listener for the local proxy */ - xfer->watcher = purple_input_add(sock, PURPLE_INPUT_READ, - jabber_si_xfer_bytestreams_send_connected_cb, xfer); + purple_xfer_set_watcher(xfer, purple_input_add(sock, PURPLE_INPUT_READ, + jabber_si_xfer_bytestreams_send_connected_cb, xfer)); } for (tmp = jsx->js->bs_proxies; tmp; tmp = tmp->next) { @@ -1101,7 +1101,7 @@ jabber_si_xfer_ibb_sent_cb(JabberIBBSession *sess) { PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess); - gsize remaining = purple_xfer_get_bytes_remaining(xfer); + goffset remaining = purple_xfer_get_bytes_remaining(xfer); if (remaining == 0) { /* close the session */ @@ -1254,7 +1254,7 @@ file = xmlnode_new_child(si, "file"); xmlnode_set_namespace(file, NS_SI_FILE_TRANSFER); xmlnode_set_attrib(file, "name", purple_xfer_get_filename(xfer)); - g_snprintf(buf, sizeof(buf), "%" G_GSIZE_FORMAT, purple_xfer_get_size(xfer)); + g_snprintf(buf, sizeof(buf), "%" G_GOFFSET_FORMAT, purple_xfer_get_size(xfer)); xmlnode_set_attrib(file, "size", buf); /* maybe later we'll do hash and date attribs */ @@ -1318,9 +1318,9 @@ jabber_iq_remove_callback_by_id(js, jsx->iq_id); if (jsx->local_streamhost_fd >= 0) close(jsx->local_streamhost_fd); - if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND && xfer->fd >= 0) { + if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND && purple_xfer_get_fd(xfer) >= 0) { purple_debug_info("jabber", "remove port mapping\n"); - purple_network_remove_port_mapping(xfer->fd); + purple_network_remove_port_mapping(purple_xfer_get_fd(xfer)); } if (jsx->connect_timeout > 0) purple_timeout_remove(jsx->connect_timeout); @@ -1575,7 +1575,7 @@ purple_request_fields(jsx->js->gc, _("Select a Resource"), msg, NULL, fields, _("Send File"), G_CALLBACK(resource_select_ok_cb), _("Cancel"), G_CALLBACK(resource_select_cancel_cb), - jsx->js->gc->account, purple_xfer_get_remote_user(xfer), NULL, xfer); + purple_connection_get_account(jsx->js->gc), purple_xfer_get_remote_user(xfer), NULL, xfer); g_free(msg); } @@ -1631,7 +1631,7 @@ js = purple_connection_get_protocol_data(gc); - xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); + xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_SEND, who); if (xfer) { jsx = g_new0(JabberSIXfer, 1); @@ -1690,8 +1690,7 @@ xmlnode *thumbnail; #endif const char *stream_id, *filename, *filesize_c, *profile; - guint64 filesize_64 = 0; - size_t filesize = 0; + goffset filesize = 0; if(!(profile = xmlnode_get_attrib(si, "profile")) || strcmp(profile, NS_SI_FILE_TRANSFER)) @@ -1707,17 +1706,7 @@ return; if((filesize_c = xmlnode_get_attrib(file, "size"))) - filesize_64 = g_ascii_strtoull(filesize_c, NULL, 10); - /* TODO 3.0.0: When the core uses a guint64, this is redundant. - * See #8477. - */ - if (filesize_64 > G_MAXSIZE) { - /* Should this pop up a warning? */ - purple_debug_warning("jabber", "Unable to transfer file (too large)" - " -- see #8477 for more details."); - return; - } - filesize = filesize_64; + filesize = g_ascii_strtoull(filesize_c, NULL, 10); if(!(feature = xmlnode_get_child(si, "feature"))) return; @@ -1768,7 +1757,7 @@ jsx->stream_id = g_strdup(stream_id); jsx->iq_id = g_strdup(id); - xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE, from); + xfer = purple_xfer_new(purple_connection_get_account(js->gc), PURPLE_XFER_RECEIVE, from); g_return_if_fail(xfer != NULL); purple_xfer_set_protocol_data(xfer, jsx);