Mercurial > pidgin
comparison libpurple/protocols/yahoo/yahoo_filexfer.c @ 27111:510f07e1f5c1
Strip trailing whitespace and comment #endif marcos that close #ifdef macros
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 18 Jun 2009 19:08:24 +0000 |
parents | fac90dbe196d |
children | d078048fb03a |
comparison
equal
deleted
inserted
replaced
27110:455e679ea0db | 27111:510f07e1f5c1 |
---|---|
378 300, 268, | 378 300, 268, |
379 27, filename, | 379 27, filename, |
380 28, xfer->size, | 380 28, xfer->size, |
381 301, 268, | 381 301, 268, |
382 303, 268); | 382 303, 268); |
383 g_free(filename); | 383 g_free(filename); |
384 } else { | 384 } else { |
385 if(xfer_data->firstoflist == TRUE) { | 385 if(xfer_data->firstoflist == TRUE) { |
386 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_15, | 386 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_15, |
387 YAHOO_STATUS_AVAILABLE, yd->session_id); | 387 YAHOO_STATUS_AVAILABLE, yd->session_id); |
388 | 388 |
389 yahoo_packet_hash(pkt, "sssi", | 389 yahoo_packet_hash(pkt, "sssi", |
390 1, purple_normalize(account, purple_account_get_username(account)), | 390 1, purple_normalize(account, purple_account_get_username(account)), |
391 5, xfer->who, | 391 5, xfer->who, |
392 265, xfer_data->xfer_peer_idstring, | 392 265, xfer_data->xfer_peer_idstring, |
393 222, 3); | 393 222, 3); |
394 } else { | 394 } else { |
395 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_ACC_15, | 395 pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_ACC_15, |
396 YAHOO_STATUS_AVAILABLE, yd->session_id); | 396 YAHOO_STATUS_AVAILABLE, yd->session_id); |
397 | 397 |
398 yahoo_packet_hash(pkt, "sssi", | 398 yahoo_packet_hash(pkt, "sssi", |
399 1, purple_normalize(account, purple_account_get_username(account)), | 399 1, purple_normalize(account, purple_account_get_username(account)), |
400 5, xfer->who, | 400 5, xfer->who, |
401 265, xfer_data->xfer_peer_idstring, | 401 265, xfer_data->xfer_peer_idstring, |
402 271, 1); | 402 271, 1); |
621 if (written < 0 && errno == EAGAIN) | 621 if (written < 0 && errno == EAGAIN) |
622 written = 0; | 622 written = 0; |
623 else if (written <= 0) | 623 else if (written <= 0) |
624 purple_debug_info("yahoo", "p2p filetransfer: Unable to write HTTP OK"); | 624 purple_debug_info("yahoo", "p2p filetransfer: Unable to write HTTP OK"); |
625 | 625 |
626 /* close connection */ | 626 /* close connection */ |
627 close(xfer->fd); | 627 close(xfer->fd); |
628 xfer->fd = -1; | 628 xfer->fd = -1; |
629 g_free(tx); | 629 g_free(tx); |
630 } | 630 } |
631 | 631 |
642 && xfer_data->filename_list) { | 642 && xfer_data->filename_list) { |
643 | 643 |
644 /* Send HTTP OK in case of p2p transfer, when we act as server */ | 644 /* Send HTTP OK in case of p2p transfer, when we act as server */ |
645 if((xfer_data->xfer_url != NULL) && (xfer_old->fd >=0) && (purple_xfer_get_status(xfer_old) == PURPLE_XFER_STATUS_DONE)) | 645 if((xfer_data->xfer_url != NULL) && (xfer_old->fd >=0) && (purple_xfer_get_status(xfer_old) == PURPLE_XFER_STATUS_DONE)) |
646 yahoo_p2p_ft_server_send_OK(xfer_old); | 646 yahoo_p2p_ft_server_send_OK(xfer_old); |
647 | 647 |
648 /* removing top of filename & size list completely */ | 648 /* removing top of filename & size list completely */ |
649 g_free( xfer_data->filename_list->data ); | 649 g_free( xfer_data->filename_list->data ); |
650 g_free( xfer_data->size_list->data ); | 650 g_free( xfer_data->size_list->data ); |
651 | 651 |
652 xfer_data->filename_list->data = NULL; | 652 xfer_data->filename_list->data = NULL; |
653 xfer_data->size_list->data = NULL; | 653 xfer_data->size_list->data = NULL; |
654 | 654 |
655 xfer_data->filename_list = g_slist_delete_link(xfer_data->filename_list, xfer_data->filename_list); | 655 xfer_data->filename_list = g_slist_delete_link(xfer_data->filename_list, xfer_data->filename_list); |
656 xfer_data->size_list = g_slist_delete_link(xfer_data->size_list, xfer_data->size_list); | 656 xfer_data->size_list = g_slist_delete_link(xfer_data->size_list, xfer_data->size_list); |
657 | 657 |
658 /* if there are still more files */ | 658 /* if there are still more files */ |
659 if(xfer_data->filename_list) | 659 if(xfer_data->filename_list) |
695 xfer_old->data = NULL; | 695 xfer_old->data = NULL; |
696 | 696 |
697 /* Build the file transfer handle. */ | 697 /* Build the file transfer handle. */ |
698 xfer = purple_xfer_new(gc->account, PURPLE_XFER_RECEIVE, xfer_old->who); | 698 xfer = purple_xfer_new(gc->account, PURPLE_XFER_RECEIVE, xfer_old->who); |
699 | 699 |
700 | 700 |
701 if (xfer) { | 701 if (xfer) { |
702 /* Set the info about the incoming file. */ | 702 /* Set the info about the incoming file. */ |
703 char *utf8_filename = yahoo_string_decode(gc, filename, TRUE); | 703 char *utf8_filename = yahoo_string_decode(gc, filename, TRUE); |
704 purple_xfer_set_filename(xfer, utf8_filename); | 704 purple_xfer_set_filename(xfer, utf8_filename); |
705 g_free(utf8_filename); | 705 g_free(utf8_filename); |
706 purple_xfer_set_size(xfer, filesize); | 706 purple_xfer_set_size(xfer, filesize); |
707 | 707 |
708 xfer->data = xfer_data; | 708 xfer->data = xfer_data; |
709 | 709 |
710 /* Setup our I/O op functions */ | 710 /* Setup our I/O op functions */ |
711 purple_xfer_set_init_fnc(xfer, yahoo_xfer_init_15); | 711 purple_xfer_set_init_fnc(xfer, yahoo_xfer_init_15); |
712 purple_xfer_set_start_fnc(xfer, yahoo_xfer_start); | 712 purple_xfer_set_start_fnc(xfer, yahoo_xfer_start); |
713 purple_xfer_set_end_fnc(xfer, yahoo_xfer_end); | 713 purple_xfer_set_end_fnc(xfer, yahoo_xfer_end); |
714 purple_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send); | 714 purple_xfer_set_cancel_send_fnc(xfer, yahoo_xfer_cancel_send); |
1001 { | 1001 { |
1002 purple_debug_error("yahoo", "Unable to find an IP address for relay.msg.yahoo.com\n"); | 1002 purple_debug_error("yahoo", "Unable to find an IP address for relay.msg.yahoo.com\n"); |
1003 purple_xfer_cancel_remote(xfer); | 1003 purple_xfer_cancel_remote(xfer); |
1004 return; | 1004 return; |
1005 } | 1005 } |
1006 | 1006 |
1007 /* Discard the length... */ | 1007 /* Discard the length... */ |
1008 hosts = g_slist_remove(hosts, hosts->data); | 1008 hosts = g_slist_remove(hosts, hosts->data); |
1009 if(!hosts) | 1009 if(!hosts) |
1010 { | 1010 { |
1011 purple_debug_error("yahoo", "Unable to find an IP address for relay.msg.yahoo.com\n"); | 1011 purple_debug_error("yahoo", "Unable to find an IP address for relay.msg.yahoo.com\n"); |
1012 purple_xfer_cancel_remote(xfer); | 1012 purple_xfer_cancel_remote(xfer); |
1013 return; | 1013 return; |
1014 } | 1014 } |
1015 | 1015 |
1016 /* TODO:actually, u must try with addr no.1 , if its not working addr no.2 ..... */ | 1016 /* TODO:actually, u must try with addr no.1 , if its not working addr no.2 ..... */ |
1017 addr = hosts->data; | 1017 addr = hosts->data; |
1018 actaddr = addr->sin_addr.s_addr; | 1018 actaddr = addr->sin_addr.s_addr; |
1019 d = actaddr % 256; | 1019 d = actaddr % 256; |
1020 actaddr = (actaddr - d) / 256; | 1020 actaddr = (actaddr - d) / 256; |
1111 | 1111 |
1112 buf=g_strnfill(1000, 0); | 1112 buf=g_strnfill(1000, 0); |
1113 while((did = read(source, buf, 998)) > 0) | 1113 while((did = read(source, buf, 998)) > 0) |
1114 { | 1114 { |
1115 xd->txbuflen += did; | 1115 xd->txbuflen += did; |
1116 buf[did] = '\0'; | 1116 buf[did] = '\0'; |
1117 t = xd->txbuf; | 1117 t = xd->txbuf; |
1118 xd->txbuf = g_strconcat(t,buf,NULL); | 1118 xd->txbuf = g_strconcat(t,buf,NULL); |
1119 g_free(t); | 1119 g_free(t); |
1120 } | 1120 } |
1121 g_free(buf); | 1121 g_free(buf); |
1274 xd->host, | 1274 xd->host, |
1275 (long int)xfer->size); | 1275 (long int)xfer->size); |
1276 } | 1276 } |
1277 } | 1277 } |
1278 else if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE && xd->status_15 == STARTED) | 1278 else if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE && xd->status_15 == STARTED) |
1279 { | 1279 { |
1280 if(xd->info_val_249 == 1) | 1280 if(xd->info_val_249 == 1) |
1281 { | 1281 { |
1282 /* receiving file via p2p, connected as client */ | 1282 /* receiving file via p2p, connected as client */ |
1283 xd->txbuf = g_strdup_printf("HEAD /%s HTTP/1.1\r\n" | 1283 xd->txbuf = g_strdup_printf("HEAD /%s HTTP/1.1\r\n" |
1284 "Accept: */*\r\n" | 1284 "Accept: */*\r\n" |
1590 unsigned long filesize = 0L; | 1590 unsigned long filesize = 0L; |
1591 GSList *l; | 1591 GSList *l; |
1592 GSList *filename_list = NULL; | 1592 GSList *filename_list = NULL; |
1593 GSList *size_list = NULL; | 1593 GSList *size_list = NULL; |
1594 int nooffiles = 0; | 1594 int nooffiles = 0; |
1595 | 1595 |
1596 yd = gc->proto_data; | 1596 yd = gc->proto_data; |
1597 | 1597 |
1598 for (l = pkt->hash; l; l = l->next) { | 1598 for (l = pkt->hash; l; l = l->next) { |
1599 struct yahoo_pair *pair = l->data; | 1599 struct yahoo_pair *pair = l->data; |
1600 | 1600 |
1615 case 28: | 1615 case 28: |
1616 size_list = g_slist_prepend(size_list, g_strdup(pair->value)); | 1616 size_list = g_slist_prepend(size_list, g_strdup(pair->value)); |
1617 break; | 1617 break; |
1618 case 222: | 1618 case 222: |
1619 val_222 = atol(pair->value); | 1619 val_222 = atol(pair->value); |
1620 /* 1=send, 2=cancel, 3=accept, 4=reject */ | 1620 /* 1=send, 2=cancel, 3=accept, 4=reject */ |
1621 break; | 1621 break; |
1622 | 1622 |
1623 /* check for p2p and imviron .... not sure it comes by this service packet. Since it was bundled with filexfer in old ymsg version, still keeping it. */ | 1623 /* check for p2p and imviron .... not sure it comes by this service packet. Since it was bundled with filexfer in old ymsg version, still keeping it. */ |
1624 case 49: | 1624 case 49: |
1625 service = pair->value; | 1625 service = pair->value; |
1653 * supposed to mention the ip address... | 1653 * supposed to mention the ip address... |
1654 * purple connect does not give me a way of finding the ip address... | 1654 * purple connect does not give me a way of finding the ip address... |
1655 * so, purple dnsquery is used... but retries, trying with next ip | 1655 * so, purple dnsquery is used... but retries, trying with next ip |
1656 * address etc. is not implemented..TODO | 1656 * address etc. is not implemented..TODO |
1657 */ | 1657 */ |
1658 | 1658 |
1659 /* To send through p2p */ | 1659 /* To send through p2p */ |
1660 if( g_hash_table_lookup(yd->peers, from) ) { | 1660 if( g_hash_table_lookup(yd->peers, from) ) { |
1661 /* send p2p file transfer information */ | 1661 /* send p2p file transfer information */ |
1662 yahoo_p2p_client_send_ft_info(gc, xfer); | 1662 yahoo_p2p_client_send_ft_info(gc, xfer); |
1663 return; | 1663 return; |
1683 */ | 1683 */ |
1684 if (from && imv && service && (strcmp("IMVIRONMENT", service) == 0)) { | 1684 if (from && imv && service && (strcmp("IMVIRONMENT", service) == 0)) { |
1685 g_hash_table_replace(yd->imvironments, g_strdup(from), g_strdup(imv)); | 1685 g_hash_table_replace(yd->imvironments, g_strdup(from), g_strdup(imv)); |
1686 return; | 1686 return; |
1687 } | 1687 } |
1688 | 1688 |
1689 if (pkt->service == YAHOO_SERVICE_P2PFILEXFER) { | 1689 if (pkt->service == YAHOO_SERVICE_P2PFILEXFER) { |
1690 if (service && (strcmp("FILEXFER", service) != 0)) { | 1690 if (service && (strcmp("FILEXFER", service) != 0)) { |
1691 purple_debug_misc("yahoo", "unhandled service 0x%02x\n", pkt->service); | 1691 purple_debug_misc("yahoo", "unhandled service 0x%02x\n", pkt->service); |
1692 return; | 1692 return; |
1693 } | 1693 } |
1708 xfer_data->firstoflist = TRUE; | 1708 xfer_data->firstoflist = TRUE; |
1709 xfer_data->gc = gc; | 1709 xfer_data->gc = gc; |
1710 xfer_data->xfer_peer_idstring = g_strdup(xfer_peer_idstring); | 1710 xfer_data->xfer_peer_idstring = g_strdup(xfer_peer_idstring); |
1711 xfer_data->filename_list = filename_list; | 1711 xfer_data->filename_list = filename_list; |
1712 xfer_data->size_list = size_list; | 1712 xfer_data->size_list = size_list; |
1713 | 1713 |
1714 /* Build the file transfer handle. */ | 1714 /* Build the file transfer handle. */ |
1715 xfer = purple_xfer_new(gc->account, PURPLE_XFER_RECEIVE, from); | 1715 xfer = purple_xfer_new(gc->account, PURPLE_XFER_RECEIVE, from); |
1716 xfer->message = NULL; | 1716 xfer->message = NULL; |
1717 | 1717 |
1718 if (xfer) | 1718 if (xfer) |
1737 purple_xfer_set_request_denied_fnc(xfer,yahoo_xfer_cancel_recv); | 1737 purple_xfer_set_request_denied_fnc(xfer,yahoo_xfer_cancel_recv); |
1738 | 1738 |
1739 g_hash_table_insert(yd->xfer_peer_idstring_map, | 1739 g_hash_table_insert(yd->xfer_peer_idstring_map, |
1740 xfer_data->xfer_peer_idstring, | 1740 xfer_data->xfer_peer_idstring, |
1741 xfer); | 1741 xfer); |
1742 | 1742 |
1743 if(nooffiles > 1) { | 1743 if(nooffiles > 1) { |
1744 gchar* message; | 1744 gchar* message; |
1745 message = g_strdup_printf(_("%s is trying to send you a group of %d files.\n"), xfer->who, nooffiles); | 1745 message = g_strdup_printf(_("%s is trying to send you a group of %d files.\n"), xfer->who, nooffiles); |
1746 purple_xfer_conversation_write(xfer, message, FALSE); | 1746 purple_xfer_conversation_write(xfer, message, FALSE); |
1747 g_free(message); | 1747 g_free(message); |
1823 if(val_249 == 1 || val_249 == 3) { | 1823 if(val_249 == 1 || val_249 == 3) { |
1824 if (!purple_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL)) { | 1824 if (!purple_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL)) { |
1825 purple_xfer_cancel_remote(xfer); | 1825 purple_xfer_cancel_remote(xfer); |
1826 return; | 1826 return; |
1827 } | 1827 } |
1828 | 1828 |
1829 account = purple_connection_get_account(xfer_data->gc); | 1829 account = purple_connection_get_account(xfer_data->gc); |
1830 | 1830 |
1831 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_ACC_15, | 1831 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_ACC_15, |
1832 YAHOO_STATUS_AVAILABLE, yd->session_id); | 1832 YAHOO_STATUS_AVAILABLE, yd->session_id); |
1833 yahoo_packet_hash(pkt_to_send, "ssssisi", | 1833 yahoo_packet_hash(pkt_to_send, "ssssisi", |
1914 } | 1914 } |
1915 | 1915 |
1916 xfer_data = xfer->data; | 1916 xfer_data = xfer->data; |
1917 if(url) | 1917 if(url) |
1918 purple_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL); | 1918 purple_url_parse(url, &(xfer_data->host), &(xfer_data->port), &(xfer_data->path), NULL, NULL); |
1919 | 1919 |
1920 xfer_data->xfer_idstring_for_relay = g_strdup(xfer_idstring_for_relay); | 1920 xfer_data->xfer_idstring_for_relay = g_strdup(xfer_idstring_for_relay); |
1921 xfer_data->status_15 = ACCEPTED; | 1921 xfer_data->status_15 = ACCEPTED; |
1922 account = purple_connection_get_account(gc); | 1922 account = purple_connection_get_account(gc); |
1923 | 1923 |
1924 if (purple_proxy_connect(NULL, account, xfer_data->host, xfer_data->port, | 1924 if (purple_proxy_connect(NULL, account, xfer_data->host, xfer_data->port, |