comparison libpurple/protocols/jabber/si.c @ 31933:6b3bc0947068

merged from im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 21 Apr 2011 20:36:02 +0900
parents 7281d151e492 b671728e6ee9
children 380f530c3f86
comparison
equal deleted inserted replaced
31895:8b9e9c61d061 31933:6b3bc0947068
277 277
278 /* TODO: Deal with zeroconf */ 278 /* TODO: Deal with zeroconf */
279 279
280 if(dstjid != NULL && streamhost->host && streamhost->port > 0) { 280 if(dstjid != NULL && streamhost->host && streamhost->port > 0) {
281 char *dstaddr, *hash; 281 char *dstaddr, *hash;
282 PurpleAccount *account;
282 jsx->gpi = purple_proxy_info_new(); 283 jsx->gpi = purple_proxy_info_new();
283 purple_proxy_info_set_type(jsx->gpi, PURPLE_PROXY_SOCKS5); 284 purple_proxy_info_set_type(jsx->gpi, PURPLE_PROXY_SOCKS5);
284 purple_proxy_info_set_host(jsx->gpi, streamhost->host); 285 purple_proxy_info_set_host(jsx->gpi, streamhost->host);
285 purple_proxy_info_set_port(jsx->gpi, streamhost->port); 286 purple_proxy_info_set_port(jsx->gpi, streamhost->port);
286 287
293 jsx->js->user->node, jsx->js->user->domain, jsx->js->user->resource); 294 jsx->js->user->node, jsx->js->user->domain, jsx->js->user->resource);
294 295
295 /* Per XEP-0065, the 'host' must be SHA1(SID + from JID + to JID) */ 296 /* Per XEP-0065, the 'host' must be SHA1(SID + from JID + to JID) */
296 hash = jabber_calculate_data_hash(dstaddr, strlen(dstaddr), "sha1"); 297 hash = jabber_calculate_data_hash(dstaddr, strlen(dstaddr), "sha1");
297 298
298 jsx->connect_data = purple_proxy_connect_socks5(NULL, jsx->gpi, 299 account = purple_connection_get_account(jsx->js->gc);
299 hash, 0, 300 jsx->connect_data = purple_proxy_connect_socks5_account(NULL, account,
301 jsx->gpi, hash, 0,
300 jabber_si_bytestreams_connect_cb, xfer); 302 jabber_si_bytestreams_connect_cb, xfer);
301 g_free(hash); 303 g_free(hash);
302 g_free(dstaddr); 304 g_free(dstaddr);
303 305
304 /* When selecting a streamhost, timeout after STREAMHOST_CONNECT_TIMEOUT seconds, otherwise it takes forever */ 306 /* When selecting a streamhost, timeout after STREAMHOST_CONNECT_TIMEOUT seconds, otherwise it takes forever */
1694 { 1696 {
1695 JabberSIXfer *jsx; 1697 JabberSIXfer *jsx;
1696 PurpleXfer *xfer; 1698 PurpleXfer *xfer;
1697 xmlnode *file, *feature, *x, *field, *option, *value, *thumbnail; 1699 xmlnode *file, *feature, *x, *field, *option, *value, *thumbnail;
1698 const char *stream_id, *filename, *filesize_c, *profile; 1700 const char *stream_id, *filename, *filesize_c, *profile;
1701 guint64 filesize_64 = 0;
1699 size_t filesize = 0; 1702 size_t filesize = 0;
1700 1703
1701 if(!(profile = xmlnode_get_attrib(si, "profile")) || 1704 if(!(profile = xmlnode_get_attrib(si, "profile")) ||
1702 strcmp(profile, NS_SI_FILE_TRANSFER)) 1705 strcmp(profile, NS_SI_FILE_TRANSFER))
1703 return; 1706 return;
1710 1713
1711 if(!(filename = xmlnode_get_attrib(file, "name"))) 1714 if(!(filename = xmlnode_get_attrib(file, "name")))
1712 return; 1715 return;
1713 1716
1714 if((filesize_c = xmlnode_get_attrib(file, "size"))) 1717 if((filesize_c = xmlnode_get_attrib(file, "size")))
1715 filesize = strtoul(filesize_c, NULL, 10); 1718 filesize_64 = g_ascii_strtoull(filesize_c, NULL, 10);
1719 /* TODO 3.0.0: When the core uses a guint64, this is redundant.
1720 * See #8477.
1721 */
1722 if (filesize_64 > G_MAXSIZE) {
1723 /* Should this pop up a warning? */
1724 purple_debug_warning("jabber", "Unable to transfer file (too large)"
1725 " -- see #8477 for more details.");
1726 return;
1727 }
1728 filesize = filesize_64;
1716 1729
1717 if(!(feature = xmlnode_get_child(si, "feature"))) 1730 if(!(feature = xmlnode_get_child(si, "feature")))
1718 return; 1731 return;
1719 1732
1720 if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data"))) 1733 if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data")))