comparison libpurple/protocols/yahoo/yahoo_filexfer.c @ 32459:fcf841ffd620

Convert yahoo prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data()
author andrew.victor@mxit.com
date Tue, 30 Aug 2011 20:03:11 +0000
parents b6defcebfe4b
children f22bc8b5b9dc
comparison
equal deleted inserted replaced
32458:1a3723704543 32459:fcf841ffd620
83 YahooData *yd; 83 YahooData *yd;
84 PurpleXfer *xfer; 84 PurpleXfer *xfer;
85 GSList *l; 85 GSList *l;
86 86
87 gc = xd->gc; 87 gc = xd->gc;
88 yd = gc->proto_data; 88 yd = purple_connection_get_protocol_data(gc);
89 89
90 /* remove entry from map */ 90 /* remove entry from map */
91 if(xd->xfer_peer_idstring) { 91 if(xd->xfer_peer_idstring) {
92 xfer = g_hash_table_lookup(yd->xfer_peer_idstring_map, xd->xfer_peer_idstring); 92 xfer = g_hash_table_lookup(yd->xfer_peer_idstring_map, xd->xfer_peer_idstring);
93 if(xfer) 93 if(xfer)
253 xfer->fd = source; 253 xfer->fd = source;
254 254
255 /* Assemble the tx buffer */ 255 /* Assemble the tx buffer */
256 gc = xd->gc; 256 gc = xd->gc;
257 account = purple_connection_get_account(gc); 257 account = purple_connection_get_account(gc);
258 yd = gc->proto_data; 258 yd = purple_connection_get_protocol_data(gc);
259 259
260 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER, 260 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANSFER,
261 YAHOO_STATUS_AVAILABLE, yd->session_id); 261 YAHOO_STATUS_AVAILABLE, yd->session_id);
262 262
263 size = g_strdup_printf("%" G_GSIZE_FORMAT, purple_xfer_get_size(xfer)); 263 size = g_strdup_printf("%" G_GSIZE_FORMAT, purple_xfer_get_size(xfer));
314 PurpleAccount *account; 314 PurpleAccount *account;
315 YahooData *yd; 315 YahooData *yd;
316 316
317 xfer_data = purple_xfer_get_protocol_data(xfer); 317 xfer_data = purple_xfer_get_protocol_data(xfer);
318 gc = xfer_data->gc; 318 gc = xfer_data->gc;
319 yd = gc->proto_data; 319 yd = purple_connection_get_protocol_data(gc);
320 account = purple_connection_get_account(gc); 320 account = purple_connection_get_account(gc);
321 321
322 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { 322 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
323 if (yd->jp) { 323 if (yd->jp) {
324 if (purple_proxy_connect(gc, account, purple_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), 324 if (purple_proxy_connect(gc, account, purple_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST),
358 YahooData *yd; 358 YahooData *yd;
359 struct yahoo_packet *pkt; 359 struct yahoo_packet *pkt;
360 360
361 xfer_data = purple_xfer_get_protocol_data(xfer); 361 xfer_data = purple_xfer_get_protocol_data(xfer);
362 gc = xfer_data->gc; 362 gc = xfer_data->gc;
363 yd = gc->proto_data; 363 yd = purple_connection_get_protocol_data(gc);
364 account = purple_connection_get_account(gc); 364 account = purple_connection_get_account(gc);
365 365
366 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { 366 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
367 gchar *filename; 367 gchar *filename;
368 filename = g_path_get_basename(purple_xfer_get_local_filename(xfer)); 368 filename = g_path_get_basename(purple_xfer_get_local_filename(xfer));
525 PurpleAccount *account; 525 PurpleAccount *account;
526 YahooData *yd; 526 YahooData *yd;
527 struct yahoo_packet *pkt; 527 struct yahoo_packet *pkt;
528 528
529 gc = xfer_data->gc; 529 gc = xfer_data->gc;
530 yd = gc->proto_data; 530 yd = purple_connection_get_protocol_data(gc);
531 account = purple_connection_get_account(gc); 531 account = purple_connection_get_account(gc);
532 if(xfer_data->xfer_idstring_for_relay) /* hack to see if file trans acc/info packet has been received */ 532 if(xfer_data->xfer_idstring_for_relay) /* hack to see if file trans acc/info packet has been received */
533 { 533 {
534 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_INFO_15, 534 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_INFO_15,
535 YAHOO_STATUS_DISCONNECTED, 535 YAHOO_STATUS_DISCONNECTED,
573 PurpleAccount *account; 573 PurpleAccount *account;
574 YahooData *yd; 574 YahooData *yd;
575 struct yahoo_packet *pkt; 575 struct yahoo_packet *pkt;
576 576
577 gc = xfer_data->gc; 577 gc = xfer_data->gc;
578 yd = gc->proto_data; 578 yd = purple_connection_get_protocol_data(gc);
579 account = purple_connection_get_account(gc); 579 account = purple_connection_get_account(gc);
580 if(!xfer_data->xfer_idstring_for_relay) /* hack to see if file trans acc/info packet has been received */ 580 if(!xfer_data->xfer_idstring_for_relay) /* hack to see if file trans acc/info packet has been received */
581 { 581 {
582 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_15, 582 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_15,
583 YAHOO_STATUS_AVAILABLE, 583 YAHOO_STATUS_AVAILABLE,
660 660
661 filename = xfer_data->filename_list->data; 661 filename = xfer_data->filename_list->data;
662 filesize = atol( xfer_data->size_list->data ); 662 filesize = atol( xfer_data->size_list->data );
663 663
664 gc = xfer_data->gc; 664 gc = xfer_data->gc;
665 yd = gc->proto_data; 665 yd = purple_connection_get_protocol_data(gc);
666 666
667 /* setting up xfer_data for next file's tranfer */ 667 /* setting up xfer_data for next file's tranfer */
668 g_free(xfer_data->host); 668 g_free(xfer_data->host);
669 g_free(xfer_data->path); 669 g_free(xfer_data->path);
670 g_free(xfer_data->txbuf); 670 g_free(xfer_data->txbuf);
803 char *service = NULL; 803 char *service = NULL;
804 char *filename = NULL; 804 char *filename = NULL;
805 unsigned long filesize = 0L; 805 unsigned long filesize = 0L;
806 GSList *l; 806 GSList *l;
807 807
808 yd = gc->proto_data; 808 yd = purple_connection_get_protocol_data(gc);
809 809
810 for (l = pkt->hash; l; l = l->next) { 810 for (l = pkt->hash; l; l = l->next) {
811 struct yahoo_pair *pair = l->data; 811 struct yahoo_pair *pair = l->data;
812 812
813 switch (pair->key) { 813 switch (pair->key) {
994 return; 994 return;
995 if (!(xd = purple_xfer_get_protocol_data(xfer))) 995 if (!(xd = purple_xfer_get_protocol_data(xfer)))
996 return; 996 return;
997 gc = xd->gc; 997 gc = xd->gc;
998 account = purple_connection_get_account(gc); 998 account = purple_connection_get_account(gc);
999 yd = gc->proto_data; 999 yd = purple_connection_get_protocol_data(gc);
1000 1000
1001 if(!hosts) 1001 if(!hosts)
1002 { 1002 {
1003 purple_debug_error("yahoo", "Unable to find an IP address for relay.msg.yahoo.com\n"); 1003 purple_debug_error("yahoo", "Unable to find an IP address for relay.msg.yahoo.com\n");
1004 purple_xfer_cancel_remote(xfer); 1004 purple_xfer_cancel_remote(xfer);
1074 } 1074 }
1075 1075
1076 void yahoo_send_file(PurpleConnection *gc, const char *who, const char *file) 1076 void yahoo_send_file(PurpleConnection *gc, const char *who, const char *file)
1077 { 1077 {
1078 struct yahoo_xfer_data *xfer_data; 1078 struct yahoo_xfer_data *xfer_data;
1079 YahooData *yd = gc->proto_data; 1079 YahooData *yd = purple_connection_get_protocol_data(gc);
1080 PurpleXfer *xfer = yahoo_new_xfer(gc, who); 1080 PurpleXfer *xfer = yahoo_new_xfer(gc, who);
1081 1081
1082 g_return_if_fail(xfer != NULL); 1082 g_return_if_fail(xfer != NULL);
1083 1083
1084 /* if we don't have a p2p connection, try establishing it now */ 1084 /* if we don't have a p2p connection, try establishing it now */
1247 /* The first time we get here, assemble the tx buffer */ 1247 /* The first time we get here, assemble the tx buffer */
1248 if (xd->txbuflen == 0) 1248 if (xd->txbuflen == 0)
1249 { 1249 {
1250 gchar* cookies; 1250 gchar* cookies;
1251 gchar* initial_buffer; 1251 gchar* initial_buffer;
1252 YahooData *yd = gc->proto_data; 1252 YahooData *yd = purple_connection_get_protocol_data(gc);
1253 1253
1254 /* cookies = yahoo_get_cookies(gc); 1254 /* cookies = yahoo_get_cookies(gc);
1255 * This doesn't seem to be working. The function is returning NULL, which yahoo servers don't like 1255 * This doesn't seem to be working. The function is returning NULL, which yahoo servers don't like
1256 * For now let us not use this function */ 1256 * For now let us not use this function */
1257 1257
1503 purple_xfer_cancel_remote(xfer); 1503 purple_xfer_cancel_remote(xfer);
1504 return; 1504 return;
1505 } 1505 }
1506 1506
1507 if( (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) || (xd->status_15 != P2P_HEAD_REPLIED) ) { 1507 if( (purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) || (xd->status_15 != P2P_HEAD_REPLIED) ) {
1508 yd = xd->gc->proto_data; 1508 yd = purple_connection_get_protocol_data(xd->gc);
1509 account = purple_connection_get_account(xd->gc); 1509 account = purple_connection_get_account(xd->gc);
1510 local_ip = purple_network_get_my_ip(listenfd); 1510 local_ip = purple_network_get_my_ip(listenfd);
1511 xd->yahoo_local_p2p_ft_server_port = purple_network_get_port_from_fd(listenfd); 1511 xd->yahoo_local_p2p_ft_server_port = purple_network_get_port_from_fd(listenfd);
1512 1512
1513 filename = g_path_get_basename(purple_xfer_get_local_filename(xfer)); 1513 filename = g_path_get_basename(purple_xfer_get_local_filename(xfer));
1564 1564
1565 if (!(xd = purple_xfer_get_protocol_data(xfer))) 1565 if (!(xd = purple_xfer_get_protocol_data(xfer)))
1566 return; 1566 return;
1567 1567
1568 account = purple_connection_get_account(gc); 1568 account = purple_connection_get_account(gc);
1569 yd = gc->proto_data; 1569 yd = purple_connection_get_protocol_data(gc);
1570 1570
1571 p2p_data = g_hash_table_lookup(yd->peers, purple_xfer_get_remote_user(xfer)); 1571 p2p_data = g_hash_table_lookup(yd->peers, purple_xfer_get_remote_user(xfer));
1572 if( p2p_data->connection_type == YAHOO_P2P_WE_ARE_SERVER ) 1572 if( p2p_data->connection_type == YAHOO_P2P_WE_ARE_SERVER )
1573 if(purple_network_listen_range(0, 0, SOCK_STREAM, yahoo_p2p_ft_server_listen_cb, xfer)) 1573 if(purple_network_listen_range(0, 0, SOCK_STREAM, yahoo_p2p_ft_server_listen_cb, xfer))
1574 return; 1574 return;
1605 GSList *l; 1605 GSList *l;
1606 GSList *filename_list = NULL; 1606 GSList *filename_list = NULL;
1607 GSList *size_list = NULL; 1607 GSList *size_list = NULL;
1608 int nooffiles = 0; 1608 int nooffiles = 0;
1609 1609
1610 yd = gc->proto_data; 1610 yd = purple_connection_get_protocol_data(gc);
1611 1611
1612 for (l = pkt->hash; l; l = l->next) { 1612 for (l = pkt->hash; l; l = l->next) {
1613 struct yahoo_pair *pair = l->data; 1613 struct yahoo_pair *pair = l->data;
1614 1614
1615 switch (pair->key) { 1615 switch (pair->key) {
1784 char *xfer_idstring_for_relay = NULL; 1784 char *xfer_idstring_for_relay = NULL;
1785 GSList *l; 1785 GSList *l;
1786 struct yahoo_packet *pkt_to_send; 1786 struct yahoo_packet *pkt_to_send;
1787 struct yahoo_p2p_data *p2p_data; 1787 struct yahoo_p2p_data *p2p_data;
1788 1788
1789 yd = gc->proto_data; 1789 yd = purple_connection_get_protocol_data(gc);
1790 1790
1791 for (l = pkt->hash; l; l = l->next) { 1791 for (l = pkt->hash; l; l = l->next) {
1792 struct yahoo_pair *pair = l->data; 1792 struct yahoo_pair *pair = l->data;
1793 1793
1794 switch (pair->key) { 1794 switch (pair->key) {
1890 PurpleAccount *account; 1890 PurpleAccount *account;
1891 long val_66 = 0; 1891 long val_66 = 0;
1892 gchar *url = NULL; 1892 gchar *url = NULL;
1893 int val_249 = 0; 1893 int val_249 = 0;
1894 1894
1895 yd = gc->proto_data; 1895 yd = purple_connection_get_protocol_data(gc);
1896 for (l = pkt->hash; l; l = l->next) { 1896 for (l = pkt->hash; l; l = l->next) {
1897 struct yahoo_pair *pair = l->data; 1897 struct yahoo_pair *pair = l->data;
1898 1898
1899 switch (pair->key) { 1899 switch (pair->key) {
1900 case 251: 1900 case 251: