Changeset 5ebff60 for protocols/yahoo
- Timestamp:
- 2015-02-20T22:50:54Z (10 years ago)
- Branches:
- master
- Children:
- 0b9daac, 3d45471, 7733b8c
- Parents:
- af359b4
- git-author:
- Indent <please@…> (19-02-15 05:47:20)
- git-committer:
- dequis <dx@…> (20-02-15 22:50:54)
- Location:
- protocols/yahoo
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/yahoo/libyahoo2.c
raf359b4 r5ebff60 3 3 * 4 4 * Some code copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net> 5 * YMSG16 code copyright (C) 2009, 6 * 5 * YMSG16 code copyright (C) 2009, 6 * Siddhesh Poyarekar <siddhesh dot poyarekar at gmail dot com> 7 7 * 8 8 * Yahoo Search copyright (C) 2003, Konstantin Klyagin <konst AT konst.org.ua> 9 9 * 10 10 * Much of this code was taken and adapted from the yahoo module for 11 * gaim released under the GNU GPL. This code is also released under the 11 * gaim released under the GNU GPL. This code is also released under the 12 12 * GNU GPL. 13 13 * … … 30 30 * 31 31 * YMSG16 authentication code based mostly on write-up at: 32 * 32 * http://www.carbonize.co.uk/ymsg16.html 33 33 * 34 34 * This program is free software; you can redistribute it and/or modify … … 60 60 # define strrchr rindex 61 61 # endif 62 char *strchr (), *strrchr();62 char *strchr(), *strrchr(); 63 63 # if !HAVE_MEMCPY 64 # define memcpy(d, s, n) bcopy 65 # define memmove(d, s, n) bcopy 64 # define memcpy(d, s, n) bcopy((s), (d), (n)) 65 # define memmove(d, s, n) bcopy((s), (d), (n)) 66 66 # endif 67 67 #endif … … 100 100 } 101 101 102 #define YAHOO_CALLBACK(x) 102 #define YAHOO_CALLBACK(x) yc->x 103 103 #else 104 #define YAHOO_CALLBACK(x) 104 #define YAHOO_CALLBACK(x) x 105 105 #endif 106 106 … … 113 113 char out[1024]; 114 114 va_list ap; 115 115 116 va_start(ap, fmt); 116 117 vsnprintf(out, sizeof(out), fmt, ap); 117 118 va_end(ap); 118 return YAHOO_CALLBACK (ext_yahoo_log) ("%s", out);119 return YAHOO_CALLBACK (ext_yahoo_log) ("%s", out); 119 120 } 120 121 … … 129 130 { 130 131 enum yahoo_log_level l = log_level; 132 131 133 log_level = level; 132 134 return l; … … 134 136 135 137 /* default values for servers */ 136 static char *default_pager_hosts[] = { 137 138 139 140 NULL};138 static char *default_pager_hosts[] = { "scs.msg.yahoo.com", 139 "scsa.msg.yahoo.com", 140 "scsb.msg.yahoo.com", 141 "scsc.msg.yahoo.com", 142 NULL }; 141 143 142 144 static int pager_port = 5050; … … 222 224 223 225 static void yahoo_process_filetransfer(struct yahoo_input_data *yid, 224 226 struct yahoo_packet *pkt); 225 227 static void yahoo_process_filetransferinfo(struct yahoo_input_data *yid, 226 228 struct yahoo_packet *pkt); 227 229 static void yahoo_process_filetransferaccept(struct yahoo_input_data *yid, 228 230 struct yahoo_packet *pkt); 229 231 230 232 static void yahoo_https_auth(struct yahoo_input_data *yid, const char *seed, const char *sn); … … 233 235 { 234 236 struct yahoo_server_settings *yss = 235 237 y_new0(struct yahoo_server_settings, 1); 236 238 237 239 /* Give preference to the default host list 238 * Make sure that only one of the two is set at any time 240 * Make sure that only one of the two is set at any time 239 241 */ 240 242 yss->pager_host = NULL; … … 263 265 while (1) { 264 266 key = va_arg(ap, char *); 265 if (key == NULL) 266 break; 267 if (key == NULL) { 268 break; 269 } 267 270 268 271 if (!strcmp(key, "pager_host")) { … … 306 309 } else { 307 310 WARNING(("Unknown key passed to yahoo_init, " 308 309 311 "perhaps you didn't terminate the list " 312 "with NULL")); 310 313 } 311 314 } … … 316 319 static void yahoo_free_server_settings(struct yahoo_server_settings *yss) 317 320 { 318 if (!yss) 319 return; 321 if (!yss) { 322 return; 323 } 320 324 321 325 free(yss->pager_host); … … 340 344 { 341 345 YList *l; 346 342 347 for (l = conns; l; l = y_list_next(l)) { 343 348 struct yahoo_data *yd = l->data; 344 if (yd->client_id == id) 349 if (yd->client_id == id) { 345 350 return yd; 351 } 346 352 } 347 353 return NULL; … … 357 363 static struct yahoo_input_data * find_input_by_id(int id) 358 364 { 359 360 361 362 363 364 365 365 YList *l; 366 for(l = inputs; l; l = y_list_next(l)) { 367 struct yahoo_input_data *yid = l->data; 368 if(yid->yd->client_id == id) 369 return yid; 370 } 371 return NULL; 366 372 } 367 373 */ … … 369 375 #if 0 370 376 static struct yahoo_input_data *find_input_by_id_and_webcam_user(int id, 371 377 const char *who) 372 378 { 373 379 YList *l; 380 374 381 LOG(("find_input_by_id_and_webcam_user")); 375 382 for (l = inputs; l; l = y_list_next(l)) { 376 383 struct yahoo_input_data *yid = l->data; 377 384 if (yid->type == YAHOO_CONNECTION_WEBCAM 378 379 380 381 || !(yid->wcm->user && !who)))385 && yid->yd->client_id == id && yid->wcm && ((who 386 && yid->wcm->user 387 && !strcmp(who, yid->wcm->user)) 388 || !(yid->wcm->user && !who))) { 382 389 return yid; 390 } 383 391 } 384 392 return NULL; … … 387 395 388 396 static struct yahoo_input_data *find_input_by_id_and_type(int id, 389 397 enum yahoo_connection_type type) 390 398 { 391 399 YList *l; 400 392 401 LOG(("find_input_by_id_and_type")); 393 402 for (l = inputs; l; l = y_list_next(l)) { 394 403 struct yahoo_input_data *yid = l->data; 395 if (yid->type == type && yid->yd->client_id == id) 404 if (yid->type == type && yid->yd->client_id == id) { 396 405 return yid; 406 } 397 407 } 398 408 return NULL; … … 402 412 { 403 413 YList *l; 414 404 415 LOG(("find_input_by_id_and_fd")); 405 416 for (l = inputs; l; l = y_list_next(l)) { 406 417 struct yahoo_input_data *yid = l->data; 407 if (yid->fd == fd && yid->yd->client_id == id) 418 if (yid->fd == fd && yid->yd->client_id == id) { 408 419 return yid; 420 } 409 421 } 410 422 return NULL; … … 415 427 int c = 0; 416 428 YList *l; 429 417 430 LOG(("counting %d", id)); 418 431 for (l = inputs; l; l = y_list_next(l)) { 419 432 struct yahoo_input_data *yid = l->data; 420 if (yid->yd->client_id == id) 433 if (yid->yd->client_id == id) { 421 434 c++; 435 } 422 436 } 423 437 LOG(("%d", c)); … … 432 446 for (l = list; l; l = l->next) { 433 447 struct yahoo_buddy *bud = l->data; 434 if (!bud) 448 if (!bud) { 435 449 continue; 450 } 436 451 437 452 FREE(bud->group); … … 503 518 504 519 static struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, 505 520 enum ypacket_status status, int id) 506 521 { 507 522 struct yahoo_packet *pkt = y_new0(struct yahoo_packet, 1); … … 515 530 516 531 static void yahoo_packet_hash(struct yahoo_packet *pkt, int key, 517 532 const char *value) 518 533 { 519 534 struct yahoo_pair *pair = y_new0(struct yahoo_pair, 1); 535 520 536 pair->key = key; 521 537 pair->value = strdup(value); … … 545 561 546 562 #define yahoo_put16(buf, data) ( \ 547 (*(buf) = (unsigned char)((data)>>8)&0xff), \548 (*((buf)+1) = (unsigned char)(data)&0xff), \549 550 #define yahoo_get16(buf) ((((*(buf)) &0xff)<<8) + ((*((buf)+1)) & 0xff))563 (*(buf) = (unsigned char) ((data) >> 8) & 0xff), \ 564 (*((buf) + 1) = (unsigned char) (data) & 0xff), \ 565 2) 566 #define yahoo_get16(buf) ((((*(buf)) & 0xff) << 8) + ((*((buf) + 1)) & 0xff)) 551 567 #define yahoo_put32(buf, data) ( \ 552 (*((buf)) = (unsigned char)((data)>>24)&0xff), \553 (*((buf)+1) = (unsigned char)((data)>>16)&0xff), \554 (*((buf)+2) = (unsigned char)((data)>>8)&0xff), \555 (*((buf)+3) = (unsigned char)(data)&0xff), \556 557 #define yahoo_get32(buf) ((((*(buf) )&0xff)<<24) + \558 (((*((buf)+1))&0xff)<<16) + \559 (((*((buf)+2))&0xff)<< 8) + \560 (((*((buf)+3))&0xff)))568 (*((buf)) = (unsigned char) ((data) >> 24) & 0xff), \ 569 (*((buf) + 1) = (unsigned char) ((data) >> 16) & 0xff), \ 570 (*((buf) + 2) = (unsigned char) ((data) >> 8) & 0xff), \ 571 (*((buf) + 3) = (unsigned char) (data) & 0xff), \ 572 4) 573 #define yahoo_get32(buf) ((((*(buf)) & 0xff) << 24) + \ 574 (((*((buf) + 1)) & 0xff) << 16) + \ 575 (((*((buf) + 2)) & 0xff) << 8) + \ 576 (((*((buf) + 3)) & 0xff))) 561 577 562 578 static void yahoo_packet_read(struct yahoo_packet *pkt, unsigned char *data, 563 579 int len) 564 580 { 565 581 int pos = 0; … … 575 591 x = 0; 576 592 while (pos + 1 < len) { 577 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) 593 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) { 578 594 break; 595 } 579 596 key[x++] = data[pos++]; 580 597 } … … 583 600 pair->key = strtol(key, NULL, 10); 584 601 free(key); 585 602 586 603 /* Libyahoo2 developer(s) don't seem to have the time to fix 587 604 this problem, so for now try to work around it: 588 605 589 606 Sometimes we receive an invalid packet with not any more 590 607 data at this point. I don't know how to handle this in a 591 608 clean way, but let's hope this is clean enough: */ 592 609 593 610 if (pos + 1 < len) { 594 accept = x; 611 accept = x; 595 612 /* if x is 0 there was no key, so don't accept it */ 596 if (accept) 613 if (accept) { 597 614 value = malloc(len - pos + 1); 615 } 598 616 x = 0; 599 617 while (pos + 1 < len) { 600 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) 618 if (data[pos] == 0xc0 && data[pos + 1] == 0x80) { 601 619 break; 602 if (accept) 620 } 621 if (accept) { 603 622 value[x++] = data[pos++]; 623 } 604 624 } 605 if (accept) 625 if (accept) { 606 626 value[x] = 0; 627 } 607 628 pos += 2; 608 629 } else { 609 630 accept = 0; 610 631 } 611 632 612 633 if (accept) { 613 634 pair->value = strdup(value); … … 615 636 pkt->hash = y_list_append(pkt->hash, pair); 616 637 DEBUG_MSG(("Key: %d \tValue: %s", pair->key, 617 638 pair->value)); 618 639 } else { 619 640 FREE(pair); … … 631 652 unsigned char buf[100]; 632 653 633 snprintf((char *) buf, sizeof(buf), "%d", pair->key);634 strcpy((char *) data + pos, (char *)buf);635 pos += strlen((char *) buf);654 snprintf((char *) buf, sizeof(buf), "%d", pair->key); 655 strcpy((char *) data + pos, (char *) buf); 656 pos += strlen((char *) buf); 636 657 data[pos++] = 0xc0; 637 658 data[pos++] = 0x80; 638 659 639 strcpy((char *) data + pos, pair->value);660 strcpy((char *) data + pos, pair->value); 640 661 pos += strlen(pair->value); 641 662 data[pos++] = 0xc0; … … 660 681 int i; 661 682 for (i = 0; i < len; i++) { 662 if ((i % 8 == 0) && i) 663 YAHOO_CALLBACK(ext_yahoo_log) (" "); 664 if ((i % 16 == 0) && i) 665 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 666 YAHOO_CALLBACK(ext_yahoo_log) ("%02x ", data[i]); 667 } 668 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 683 if ((i % 8 == 0) && i) { 684 YAHOO_CALLBACK (ext_yahoo_log) (" "); 685 } 686 if ((i % 16 == 0) && i) { 687 YAHOO_CALLBACK (ext_yahoo_log) ("\n"); 688 } 689 YAHOO_CALLBACK (ext_yahoo_log) ("%02x ", data[i]); 690 } 691 YAHOO_CALLBACK (ext_yahoo_log) ("\n"); 669 692 for (i = 0; i < len; i++) { 670 if ((i % 8 == 0) && i) 671 YAHOO_CALLBACK(ext_yahoo_log) (" "); 672 if ((i % 16 == 0) && i) 673 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 674 if (isprint(data[i])) 675 YAHOO_CALLBACK(ext_yahoo_log) (" %c ", data[i]); 676 else 677 YAHOO_CALLBACK(ext_yahoo_log) (" . "); 678 } 679 YAHOO_CALLBACK(ext_yahoo_log) ("\n"); 693 if ((i % 8 == 0) && i) { 694 YAHOO_CALLBACK (ext_yahoo_log) (" "); 695 } 696 if ((i % 16 == 0) && i) { 697 YAHOO_CALLBACK (ext_yahoo_log) ("\n"); 698 } 699 if (isprint(data[i])) { 700 YAHOO_CALLBACK (ext_yahoo_log) (" %c ", data[i]); 701 } else { 702 YAHOO_CALLBACK (ext_yahoo_log) (" . "); 703 } 704 } 705 YAHOO_CALLBACK (ext_yahoo_log) ("\n"); 680 706 } 681 707 } … … 703 729 704 730 static void yahoo_add_to_send_queue(struct yahoo_input_data *yid, void *data, 705 731 int length) 706 732 { 707 733 struct data_queue *tx = y_new0(struct data_queue, 1); 734 708 735 tx->queue = y_new0(unsigned char, length); 709 736 tx->len = length; … … 712 739 yid->txqueues = y_list_append(yid->txqueues, tx); 713 740 714 if (!yid->write_tag) 741 if (!yid->write_tag) { 715 742 yid->write_tag = 716 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd-> 717 client_id, yid->fd, YAHOO_INPUT_WRITE, yid); 743 YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd-> 744 client_id, yid->fd, YAHOO_INPUT_WRITE, yid); 745 } 718 746 } 719 747 720 748 static void yahoo_send_packet(struct yahoo_input_data *yid, 721 749 struct yahoo_packet *pkt, int extra_pad) 722 750 { 723 751 int pktlen = yahoo_packet_length(pkt); … … 726 754 int pos = 0; 727 755 728 if (yid->fd < 0) 729 return; 756 if (yid->fd < 0) { 757 return; 758 } 730 759 731 760 data = y_new0(unsigned char, len + 1); … … 733 762 memcpy(data + pos, "YMSG", 4); 734 763 pos += 4; 735 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); 736 pos += yahoo_put16(data + pos, 0x0000); 737 pos += yahoo_put16(data + pos, pktlen + extra_pad); 738 pos += yahoo_put16(data + pos, pkt->service); 739 pos += yahoo_put32(data + pos, pkt->status); 740 pos += yahoo_put32(data + pos, pkt->id); 764 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); /* version [latest 12 0x000c] */ 765 pos += yahoo_put16(data + pos, 0x0000); /* HIWORD pkt length??? */ 766 pos += yahoo_put16(data + pos, pktlen + extra_pad); /* LOWORD pkt length? */ 767 pos += yahoo_put16(data + pos, pkt->service); /* service */ 768 pos += yahoo_put32(data + pos, pkt->status); /* status [4bytes] */ 769 pos += yahoo_put32(data + pos, pkt->id); /* session [4bytes] */ 741 770 742 771 yahoo_packet_write(pkt, data + pos); … … 744 773 yahoo_packet_dump(data, len); 745 774 746 if (yid->type == YAHOO_CONNECTION_FT) 775 if (yid->type == YAHOO_CONNECTION_FT) { 747 776 yahoo_send_data(yid->fd, data, len); 748 else777 } else { 749 778 yahoo_add_to_send_queue(yid, data, len); 779 } 750 780 FREE(data); 751 781 } … … 770 800 int e; 771 801 772 if (fd == NULL) 802 if (fd == NULL) { 773 803 return -1; 804 } 774 805 775 806 yahoo_packet_dump(data, len); 776 807 777 808 do { 778 ret = YAHOO_CALLBACK (ext_yahoo_write) (fd, data, len);809 ret = YAHOO_CALLBACK (ext_yahoo_write) (fd, data, len); 779 810 } while (ret == -1 && errno == EINTR); 780 811 e = errno; … … 793 824 { 794 825 struct yahoo_data *yd = find_conn_by_id(id); 795 if (!yd) 796 return; 826 827 if (!yd) { 828 return; 829 } 797 830 798 831 del_from_list(yd); 799 832 800 833 yahoo_free_data(yd); 801 if (id == last_id) 834 if (id == last_id) { 802 835 last_id--; 836 } 803 837 } 804 838 … … 808 842 809 843 LOG(("yahoo_input_close(read)")); 810 YAHOO_CALLBACK (ext_yahoo_remove_handler) (yid->yd->client_id,811 844 YAHOO_CALLBACK (ext_yahoo_remove_handler) (yid->yd->client_id, 845 yid->read_tag); 812 846 LOG(("yahoo_input_close(write)")); 813 YAHOO_CALLBACK (ext_yahoo_remove_handler) (yid->yd->client_id,814 847 YAHOO_CALLBACK (ext_yahoo_remove_handler) (yid->yd->client_id, 848 yid->write_tag); 815 849 yid->read_tag = yid->write_tag = 0; 816 if (yid->fd) 817 YAHOO_CALLBACK(ext_yahoo_close) (yid->fd); 850 if (yid->fd) { 851 YAHOO_CALLBACK (ext_yahoo_close) (yid->fd); 852 } 818 853 yid->fd = 0; 819 854 FREE(yid->rxqueue); … … 823 858 } 824 859 yahoo_free_webcam(yid->wcm); 825 if (yid->wcd) 860 if (yid->wcd) { 826 861 FREE(yid->wcd); 862 } 827 863 if (yid->ys) { 828 864 FREE(yid->ys->lsearch_text); … … 846 882 char *cookieend; 847 883 848 if (strlen(rawcookie) < 2) 884 if (strlen(rawcookie) < 2) { 849 885 return NULL; 886 } 850 887 851 888 tmpcookie = strdup(rawcookie + 2); 852 889 cookieend = strchr(tmpcookie, ';'); 853 890 854 if (cookieend) 891 if (cookieend) { 855 892 *cookieend = '\0'; 893 } 856 894 857 895 cookie = strdup(tmpcookie); … … 872 910 tmp = strdup(tmpend + 2); 873 911 tmpend = strchr(tmp, '&'); 874 if (tmpend) 912 if (tmpend) { 875 913 *tmpend = '\0'; 914 } 876 915 login_cookie = strdup(tmp); 877 916 FREE(tmp); … … 882 921 883 922 static void yahoo_process_notify(struct yahoo_input_data *yid, 884 923 struct yahoo_packet *pkt) 885 924 { 886 925 struct yahoo_data *yd = yid->yd; … … 892 931 char *ind = NULL; 893 932 YList *l; 933 894 934 for (l = pkt->hash; l; l = l->next) { 895 935 struct yahoo_pair *pair = l->data; 896 if (pair->key == 4) 936 if (pair->key == 4) { 897 937 from = pair->value; 898 if (pair->key == 5) 938 } 939 if (pair->key == 5) { 899 940 to = pair->value; 900 if (pair->key == 49) 941 } 942 if (pair->key == 49) { 901 943 msg = pair->value; 902 if (pair->key == 13) 944 } 945 if (pair->key == 13) { 903 946 stat = atoi(pair->value); 904 if (pair->key == 14) 947 } 948 if (pair->key == 14) { 905 949 ind = pair->value; 906 if (pair->key == 16) { /* status == -1 */ 950 } 951 if (pair->key == 16) { /* status == -1 */ 907 952 NOTICE((pair->value)); 908 953 return; … … 911 956 } 912 957 913 if (!msg) 914 return; 915 916 if (!strncasecmp(msg, "TYPING", strlen("TYPING"))) 917 YAHOO_CALLBACK(ext_yahoo_typing_notify) (yd->client_id, to, 918 from, stat); 919 else if (!strncasecmp(msg, "GAME", strlen("GAME"))) 920 YAHOO_CALLBACK(ext_yahoo_game_notify) (yd->client_id, to, from, 921 stat, ind); 922 else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) { 958 if (!msg) { 959 return; 960 } 961 962 if (!strncasecmp(msg, "TYPING", strlen("TYPING"))) { 963 YAHOO_CALLBACK (ext_yahoo_typing_notify) (yd->client_id, to, 964 from, stat); 965 } else if (!strncasecmp(msg, "GAME", strlen("GAME"))) { 966 YAHOO_CALLBACK (ext_yahoo_game_notify) (yd->client_id, to, from, 967 stat, ind); 968 } else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) { 923 969 if (!strcmp(ind, " ")) { 924 YAHOO_CALLBACK (ext_yahoo_webcam_invite) (yd->client_id,925 970 YAHOO_CALLBACK (ext_yahoo_webcam_invite) (yd->client_id, 971 to, from); 926 972 } else { 927 973 accept = atoi(ind); 928 974 /* accept the invitation (-1 = deny 1 = accept) */ 929 if (accept < 0) 975 if (accept < 0) { 930 976 accept = 0; 931 YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply) (yd-> 932 client_id, to, from, accept); 933 } 934 } else 977 } 978 YAHOO_CALLBACK (ext_yahoo_webcam_invite_reply) (yd-> 979 client_id, to, from, accept); 980 } 981 } else { 935 982 LOG(("Got unknown notification: %s", msg)); 983 } 936 984 } 937 985 938 986 static void yahoo_process_conference(struct yahoo_input_data *yid, 939 987 struct yahoo_packet *pkt) 940 988 { 941 989 struct yahoo_data *yd = yid->yd; … … 951 999 for (l = pkt->hash; l; l = l->next) { 952 1000 struct yahoo_pair *pair = l->data; 953 if (pair->key == 50) 1001 if (pair->key == 50) { 954 1002 host = pair->value; 955 956 if (pair->key == 52) { /* invite */ 1003 } 1004 1005 if (pair->key == 52) { /* invite */ 957 1006 members = y_list_append(members, strdup(pair->value)); 958 1007 } 959 if (pair->key == 53) 1008 if (pair->key == 53) { /* logon */ 960 1009 who = pair->value; 961 if (pair->key == 54) /* decline */ 1010 } 1011 if (pair->key == 54) { /* decline */ 962 1012 who = pair->value; 963 if (pair->key == 55) /* unavailable (status == 2) */ 1013 } 1014 if (pair->key == 55) { /* unavailable (status == 2) */ 964 1015 who = pair->value; 965 if (pair->key == 56) /* logoff */ 1016 } 1017 if (pair->key == 56) { /* logoff */ 966 1018 who = pair->value; 967 968 if (pair->key == 57) 1019 } 1020 1021 if (pair->key == 57) { 969 1022 room = pair->value; 970 971 if (pair->key == 58) /* join message */ 1023 } 1024 1025 if (pair->key == 58) { /* join message */ 972 1026 msg = pair->value; 973 if (pair->key == 14) /* decline/conf message */ 1027 } 1028 if (pair->key == 14) { /* decline/conf message */ 974 1029 msg = pair->value; 975 976 if (pair->key == 13) 1030 } 1031 1032 if (pair->key == 13) { 977 1033 ; 978 if (pair->key == 16) /* error */ 1034 } 1035 if (pair->key == 16) { /* error */ 979 1036 msg = pair->value; 980 981 if (pair->key == 1) /* my id */ 1037 } 1038 1039 if (pair->key == 1) { /* my id */ 982 1040 id = pair->value; 983 if (pair->key == 3) /* message sender */ 1041 } 1042 if (pair->key == 3) { /* message sender */ 984 1043 who = pair->value; 985 986 if (pair->key == 97) 1044 } 1045 1046 if (pair->key == 97) { 987 1047 utf8 = atoi(pair->value); 988 } 989 990 if (!room) 991 return; 1048 } 1049 } 1050 1051 if (!room) { 1052 return; 1053 } 992 1054 993 1055 if (host) { 994 1056 for (l = members; l; l = l->next) { 995 1057 char *w = l->data; 996 if (!strcmp(w, host)) 1058 if (!strcmp(w, host)) { 997 1059 break; 998 } 999 if (!l) 1060 } 1061 } 1062 if (!l) { 1000 1063 members = y_list_append(members, strdup(host)); 1064 } 1001 1065 } 1002 1066 /* invite, decline, join, left, message -> status == 1 */ … … 1004 1068 switch (pkt->service) { 1005 1069 case YAHOO_SERVICE_CONFINVITE: 1006 if (pkt->status == 2) ; 1007 else if (members) 1008 YAHOO_CALLBACK(ext_yahoo_got_conf_invite) (yd-> 1009 client_id, id, host, room, msg, members); 1010 else if (msg) 1011 YAHOO_CALLBACK(ext_yahoo_error) (yd->client_id, msg, 0, 1012 E_CONFNOTAVAIL); 1070 if (pkt->status == 2) { 1071 ; 1072 } else if (members) { 1073 YAHOO_CALLBACK (ext_yahoo_got_conf_invite) (yd-> 1074 client_id, id, host, room, msg, members); 1075 } else if (msg) { 1076 YAHOO_CALLBACK (ext_yahoo_error) (yd->client_id, msg, 0, 1077 E_CONFNOTAVAIL); 1078 } 1013 1079 break; 1014 1080 case YAHOO_SERVICE_CONFADDINVITE: 1015 if (pkt->status == 1) 1016 YAHOO_CALLBACK(ext_yahoo_got_conf_invite) (yd-> 1017 client_id, id, host, room, msg, members); 1081 if (pkt->status == 1) { 1082 YAHOO_CALLBACK (ext_yahoo_got_conf_invite) (yd-> 1083 client_id, id, host, room, msg, members); 1084 } 1018 1085 break; 1019 1086 case YAHOO_SERVICE_CONFDECLINE: 1020 if (who) 1021 YAHOO_CALLBACK(ext_yahoo_conf_userdecline) (yd-> 1022 client_id, id, who, room, msg); 1087 if (who) { 1088 YAHOO_CALLBACK (ext_yahoo_conf_userdecline) (yd-> 1089 client_id, id, who, room, msg); 1090 } 1023 1091 break; 1024 1092 case YAHOO_SERVICE_CONFLOGON: 1025 if (who) 1026 YAHOO_CALLBACK(ext_yahoo_conf_userjoin) (yd->client_id, 1027 id, who, room); 1093 if (who) { 1094 YAHOO_CALLBACK (ext_yahoo_conf_userjoin) (yd->client_id, 1095 id, who, room); 1096 } 1028 1097 break; 1029 1098 case YAHOO_SERVICE_CONFLOGOFF: 1030 if (who) 1031 YAHOO_CALLBACK(ext_yahoo_conf_userleave) (yd->client_id, 1032 id, who, room); 1099 if (who) { 1100 YAHOO_CALLBACK (ext_yahoo_conf_userleave) (yd->client_id, 1101 id, who, room); 1102 } 1033 1103 break; 1034 1104 case YAHOO_SERVICE_CONFMSG: 1035 if (who) 1036 YAHOO_CALLBACK(ext_yahoo_conf_message) (yd->client_id, 1037 id, who, room, msg, utf8); 1105 if (who) { 1106 YAHOO_CALLBACK (ext_yahoo_conf_message) (yd->client_id, 1107 id, who, room, msg, utf8); 1108 } 1038 1109 break; 1039 1110 } … … 1041 1112 1042 1113 static void yahoo_process_chat(struct yahoo_input_data *yid, 1043 1114 struct yahoo_packet *pkt) 1044 1115 { 1045 1116 char *msg = NULL; … … 1087 1158 if (pkt->service == YAHOO_SERVICE_CHATJOIN) { 1088 1159 currentmember = 1089 1160 y_new0(struct yahoo_chat_member, 1); 1090 1161 currentmember->id = strdup(pair->value); 1091 1162 members = y_list_append(members, currentmember); … … 1095 1166 if (pair->key == 110) { 1096 1167 /* age */ 1097 if (pkt->service == YAHOO_SERVICE_CHATJOIN) 1168 if (pkt->service == YAHOO_SERVICE_CHATJOIN) { 1098 1169 currentmember->age = atoi(pair->value); 1170 } 1099 1171 } 1100 1172 1101 1173 if (pair->key == 113) { 1102 1174 /* attribs */ 1103 if (pkt->service == YAHOO_SERVICE_CHATJOIN) 1175 if (pkt->service == YAHOO_SERVICE_CHATJOIN) { 1104 1176 currentmember->attribs = atoi(pair->value); 1177 } 1105 1178 } 1106 1179 1107 1180 if (pair->key == 141) { 1108 1181 /* alias */ 1109 if (pkt->service == YAHOO_SERVICE_CHATJOIN) 1182 if (pkt->service == YAHOO_SERVICE_CHATJOIN) { 1110 1183 currentmember->alias = strdup(pair->value); 1184 } 1111 1185 } 1112 1186 1113 1187 if (pair->key == 142) { 1114 1188 /* location */ 1115 if (pkt->service == YAHOO_SERVICE_CHATJOIN) 1189 if (pkt->service == YAHOO_SERVICE_CHATJOIN) { 1116 1190 currentmember->location = strdup(pair->value); 1191 } 1117 1192 } 1118 1193 … … 1139 1214 1140 1215 if (!room) { 1141 if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { 1142 YAHOO_CALLBACK (ext_yahoo_chat_yahoologout) (yid->yd->1143 1216 if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */ 1217 YAHOO_CALLBACK (ext_yahoo_chat_yahoologout) (yid->yd-> 1218 client_id, id); 1144 1219 return; 1145 1220 } 1146 1221 if (pkt->service == YAHOO_SERVICE_COMMENT && chaterr) { 1147 YAHOO_CALLBACK (ext_yahoo_chat_yahooerror) (yid->yd->1148 1222 YAHOO_CALLBACK (ext_yahoo_chat_yahooerror) (yid->yd-> 1223 client_id, id); 1149 1224 return; 1150 1225 } … … 1160 1235 } 1161 1236 if (firstjoin && members) { 1162 YAHOO_CALLBACK (ext_yahoo_chat_join) (yid->yd->client_id,1163 1237 YAHOO_CALLBACK (ext_yahoo_chat_join) (yid->yd->client_id, 1238 id, room, topic, members, yid->fd); 1164 1239 } else if (who) { 1165 1240 if (y_list_length(members) != 1) { … … 1170 1245 YList *n = members->next; 1171 1246 currentmember = members->data; 1172 YAHOO_CALLBACK (ext_yahoo_chat_userjoin) (yid->1173 1247 YAHOO_CALLBACK (ext_yahoo_chat_userjoin) (yid-> 1248 yd->client_id, id, room, currentmember); 1174 1249 y_list_free_1(members); 1175 1250 members = n; … … 1179 1254 case YAHOO_SERVICE_CHATEXIT: 1180 1255 if (who) { 1181 YAHOO_CALLBACK (ext_yahoo_chat_userleave) (yid->yd->1182 1256 YAHOO_CALLBACK (ext_yahoo_chat_userleave) (yid->yd-> 1257 client_id, id, room, who); 1183 1258 } 1184 1259 break; 1185 1260 case YAHOO_SERVICE_COMMENT: 1186 1261 if (who) { 1187 YAHOO_CALLBACK (ext_yahoo_chat_message) (yid->yd->1188 1262 YAHOO_CALLBACK (ext_yahoo_chat_message) (yid->yd-> 1263 client_id, id, who, room, msg, msgtype, utf8); 1189 1264 } 1190 1265 break; … … 1193 1268 1194 1269 static void yahoo_process_message(struct yahoo_input_data *yid, 1195 1270 struct yahoo_packet *pkt) 1196 1271 { 1197 1272 struct yahoo_data *yd = yid->yd; … … 1213 1288 struct yahoo_pair *pair = l->data; 1214 1289 if (pair->key == 1 || pair->key == 4) { 1215 if (!message->from) 1290 if (!message->from) { 1216 1291 message->from = pair->value; 1217 } else if (pair->key == 5) 1292 } 1293 } else if (pair->key == 5) { 1218 1294 message->to = pair->value; 1219 else if (pair->key == 15)1295 } else if (pair->key == 15) { 1220 1296 message->tm = strtol(pair->value, NULL, 10); 1221 else if (pair->key == 97)1297 } else if (pair->key == 97) { 1222 1298 message->utf8 = atoi(pair->value); 1299 } 1223 1300 /* This comes when the official client sends us a message */ 1224 else if (pair->key == 429) 1301 else if (pair->key == 429) { 1225 1302 message->gunk = pair->value; 1303 } 1226 1304 /* user message *//* sys message */ 1227 else if (pair->key == 14 || pair->key == 16) 1305 else if (pair->key == 14 || pair->key == 16) { 1228 1306 message->msg = pair->value; 1229 else if (pair->key == 31) {1307 } else if (pair->key == 31) { 1230 1308 if (message->i_31) { 1231 1309 messages = y_list_append(messages, message); … … 1233 1311 } 1234 1312 message->i_31 = atoi(pair->value); 1235 } else if (pair->key == 32) 1313 } else if (pair->key == 32) { 1236 1314 message->i_32 = atoi(pair->value); 1237 else 1238 LOG(("yahoo_process_message: status: %d, key: %d, value: %s", pkt->status, pair->key, pair->value)); 1315 } else { 1316 LOG(("yahoo_process_message: status: %d, key: %d, value: %s", pkt->status, pair->key, 1317 pair->value)); 1318 } 1239 1319 } 1240 1320 … … 1244 1324 message = l->data; 1245 1325 if (pkt->service == YAHOO_SERVICE_SYSMESSAGE) { 1246 YAHOO_CALLBACK (ext_yahoo_system_message) (yd->client_id,1247 1326 YAHOO_CALLBACK (ext_yahoo_system_message) (yd->client_id, 1327 message->to, message->from, message->msg); 1248 1328 } else if (pkt->status <= 2 || pkt->status == 5) { 1249 1329 /* Confirm message receipt if we got the gunk */ 1250 if (message->gunk) {1330 if (message->gunk) { 1251 1331 struct yahoo_packet *outpkt; 1252 1332 1253 1333 outpkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE_CONFIRM, 1254 1334 YPACKET_STATUS_DEFAULT, 0); 1255 1335 yahoo_packet_hash(outpkt, 1, yd->user); 1256 1336 yahoo_packet_hash(outpkt, 5, message->from); … … 1260 1340 yahoo_packet_hash(outpkt, 450, "0"); 1261 1341 yahoo_send_packet(yid, outpkt, 0); 1262 1342 1263 1343 yahoo_packet_free(outpkt); 1264 1344 } 1265 1345 1266 if (!strcmp(message->msg, "<ding>")) 1267 YAHOO_CALLBACK(ext_yahoo_got_buzz) (yd->client_id, 1268 message->to, message->from, message->tm); 1269 else 1270 YAHOO_CALLBACK(ext_yahoo_got_im) (yd->client_id, 1271 message->to, message->from, message->msg, 1272 message->tm, pkt->status, message->utf8); 1346 if (!strcmp(message->msg, "<ding>")) { 1347 YAHOO_CALLBACK (ext_yahoo_got_buzz) (yd->client_id, 1348 message->to, message->from, message->tm); 1349 } else { 1350 YAHOO_CALLBACK (ext_yahoo_got_im) (yd->client_id, 1351 message->to, message->from, message->msg, 1352 message->tm, pkt->status, message->utf8); 1353 } 1273 1354 } else if (pkt->status == 0xffffffff) { 1274 YAHOO_CALLBACK (ext_yahoo_error) (yd->client_id,1275 1355 YAHOO_CALLBACK (ext_yahoo_error) (yd->client_id, 1356 message->msg, 0, E_SYSTEM); 1276 1357 } 1277 1358 FREE(message); … … 1286 1367 * 3 level: 1287 1368 * ======= 1288 * 1369 * 1289 1370 * 302 (318) - Beginning level 1 1290 * 1291 * 1292 * 1293 * 1294 * 1371 * 300 (318) - Begin level 2 1372 * 302 (319) - End level 2 header 1373 * 300 (319) - Begin level 3 1374 * 301 (319) - End level 3 1375 * 303 (319) - End level 2 1295 1376 * 303 (318) - End level 1 1296 1377 * … … 1299 1380 * 1300 1381 * 302 (315) - Beginning level 1 1301 * 1302 * 1382 * 300 (315) - Begin level 2 1383 * 301 (315) - End level 2 1303 1384 * 303 (315) - End level 1 1304 1385 * 1305 1386 */ 1306 1387 static void yahoo_process_status(struct yahoo_input_data *yid, 1307 1388 struct yahoo_packet *pkt) 1308 1389 { 1309 1390 YList *l; … … 1315 1396 1316 1397 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { 1317 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,1318 1319 return; 1320 } 1321 1322 /* 1323 * Status updates may be spread accross multiple packets and not 1324 * even on buddy boundaries, so keeping some state is important. 1325 * So, continue where we left off, and only add a user entry to 1398 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 1399 YAHOO_LOGIN_DUPL, NULL); 1400 return; 1401 } 1402 1403 /* 1404 * Status updates may be spread accross multiple packets and not 1405 * even on buddy boundaries, so keeping some state is important. 1406 * So, continue where we left off, and only add a user entry to 1326 1407 * the list once it's complete (301-315 End buddy). 1327 1408 */ … … 1332 1413 1333 1414 switch (pair->key) { 1334 case 300: 1415 case 300: /* Begin buddy */ 1335 1416 if (!strcmp(pair->value, "315") && !u) { 1336 1417 u = yd->half_user = y_new0(struct yahoo_process_status_entry, 1); 1337 1418 } 1338 1419 break; 1339 case 301: 1420 case 301: /* End buddy */ 1340 1421 if (!strcmp(pair->value, "315") && u) { 1341 1422 /* Sometimes user info comes in an odd format with no 1342 1423 "begin buddy" but *with* an "end buddy". Don't add 1343 1424 it twice. */ 1344 if (!y_list_find(users, u)) 1425 if (!y_list_find(users, u)) { 1345 1426 users = y_list_prepend(users, u); 1427 } 1346 1428 u = yd->half_user = NULL; 1347 1429 } 1348 1430 break; 1349 case 0: 1431 case 0: /* we won't actually do anything with this */ 1350 1432 NOTICE(("key %d:%s", pair->key, pair->value)); 1351 1433 break; 1352 case 1: 1434 case 1: /* we don't get the full buddy list here. */ 1353 1435 if (!yd->logged_in) { 1354 1436 yd->logged_in = 1; 1355 if (yd->current_status < 0) 1437 if (yd->current_status < 0) { 1356 1438 yd->current_status = yd->initial_status; 1357 YAHOO_CALLBACK(ext_yahoo_login_response) (yd-> 1358 client_id, YAHOO_LOGIN_OK, NULL); 1439 } 1440 YAHOO_CALLBACK (ext_yahoo_login_response) (yd-> 1441 client_id, YAHOO_LOGIN_OK, NULL); 1359 1442 } 1360 1443 break; 1361 case 8: 1444 case 8: /* how many online buddies we have */ 1362 1445 NOTICE(("key %d:%s", pair->key, pair->value)); 1363 1446 break; 1364 case 7: 1447 case 7: /* the current buddy */ 1365 1448 if (!u) { 1366 1449 /* This will only happen in case of a single level message */ … … 1370 1453 u->name = pair->value; 1371 1454 break; 1372 case 10: 1455 case 10: /* state */ 1373 1456 u->state = strtol(pair->value, NULL, 10); 1374 1457 break; 1375 case 19: 1458 case 19: /* custom status message */ 1376 1459 u->msg = pair->value; 1377 1460 break; 1378 case 47: 1461 case 47: /* is it an away message or not. Not applicable for YMSG16 anymore */ 1379 1462 u->away = atoi(pair->value); 1380 1463 break; 1381 case 137: 1464 case 137: /* seconds idle */ 1382 1465 u->idle = atoi(pair->value); 1383 1466 break; 1384 case 11: 1467 case 11: /* this is the buddy's session id */ 1385 1468 u->buddy_session = atoi(pair->value); 1386 1469 break; 1387 case 17: 1470 case 17: /* in chat? */ 1388 1471 u->f17 = atoi(pair->value); 1389 1472 break; 1390 case 13: 1473 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ 1391 1474 u->flags = atoi(pair->value); 1392 1475 break; 1393 case 60: 1476 case 60: /* SMS -> 1 MOBILE USER */ 1394 1477 /* sometimes going offline makes this 2, but invisible never sends it */ 1395 1478 u->mobile = atoi(pair->value); … … 1422 1505 u->f213 = atoi(pair->value); 1423 1506 break; 1424 case 16: 1425 YAHOO_CALLBACK (ext_yahoo_error) (yd->client_id,1426 1507 case 16: /* Custom error message */ 1508 YAHOO_CALLBACK (ext_yahoo_error) (yd->client_id, 1509 pair->value, 0, E_CUSTOM); 1427 1510 break; 1428 1511 default: 1429 1512 WARNING(("unknown status key %d:%s", pair->key, 1430 1513 pair->value)); 1431 1514 break; 1432 1515 } … … 1439 1522 if (u->name != NULL) { 1440 1523 if (pkt->service == 1441 1442 /*|| u->flags == 0 No flags for YMSG16 */) {1443 YAHOO_CALLBACK (ext_yahoo_status_changed) (yd->1444 1445 1524 YAHOO_SERVICE_LOGOFF 1525 /*|| u->flags == 0 No flags for YMSG16 */) { 1526 YAHOO_CALLBACK (ext_yahoo_status_changed) (yd-> 1527 client_id, u->name, 1528 YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0); 1446 1529 } else { 1447 1530 /* Key 47 always seems to be 1 for YMSG16 */ 1448 if (!u->state) 1531 if (!u->state) { 1449 1532 u->away = 0; 1450 else1533 } else { 1451 1534 u->away = 1; 1452 1453 YAHOO_CALLBACK(ext_yahoo_status_changed) (yd-> 1454 client_id, u->name, u->state, u->msg, 1455 u->away, u->idle, u->mobile); 1535 } 1536 1537 YAHOO_CALLBACK (ext_yahoo_status_changed) (yd-> 1538 client_id, u->name, u->state, u->msg, 1539 u->away, u->idle, u->mobile); 1456 1540 } 1457 1541 } … … 1464 1548 1465 1549 static void yahoo_process_buddy_list(struct yahoo_input_data *yid, 1466 1550 struct yahoo_packet *pkt) 1467 1551 { 1468 1552 struct yahoo_data *yd = yid->yd; … … 1480 1564 case 301: 1481 1565 case 302: 1482 break; 1566 break; /* Separators. Our logic does not need them */ 1483 1567 case 303: 1484 if (318 == atoi(pair->value)) 1568 if (318 == atoi(pair->value)) { 1485 1569 last_packet = 1; 1570 } 1486 1571 break; 1487 1572 case 65: … … 1491 1576 newbud = y_new0(struct yahoo_buddy, 1); 1492 1577 newbud->id = strdup(pair->value); 1493 if (cur_group) 1578 if (cur_group) { 1494 1579 newbud->group = strdup(cur_group); 1495 else if (yd->buddies) {1580 } else if (yd->buddies) { 1496 1581 struct yahoo_buddy *lastbud = 1497 (struct yahoo_buddy *)y_list_nth(yd->1498 1499 1582 (struct yahoo_buddy *) y_list_nth(yd-> 1583 buddies, 1584 y_list_length(yd->buddies) - 1)->data; 1500 1585 newbud->group = strdup(lastbud->group); 1501 } else 1586 } else { 1502 1587 newbud->group = strdup("Buddies"); 1588 } 1503 1589 1504 1590 yd->buddies = y_list_append(yd->buddies, newbud); … … 1509 1595 1510 1596 /* we could be getting multiple packets here */ 1511 if (pkt->hash && !last_packet) 1512 return; 1513 1514 YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, yd->buddies); 1597 if (pkt->hash && !last_packet) { 1598 return; 1599 } 1600 1601 YAHOO_CALLBACK (ext_yahoo_got_buddies) (yd->client_id, yd->buddies); 1515 1602 1516 1603 /* Logged in */ 1517 1604 if (!yd->logged_in) { 1518 1605 yd->logged_in = 1; 1519 if (yd->current_status < 0) 1606 if (yd->current_status < 0) { 1520 1607 yd->current_status = yd->initial_status; 1521 YAHOO_CALLBACK(ext_yahoo_login_response) (yd->client_id, 1522 YAHOO_LOGIN_OK, NULL); 1608 } 1609 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 1610 YAHOO_LOGIN_OK, NULL); 1523 1611 1524 1612 /* 1525 1613 yahoo_set_away(yd->client_id, yd->initial_status, NULL, 1526 1614 (yd->initial_status == YAHOO_STATUS_AVAILABLE) ? 0 : 1); 1527 1615 1528 1616 yahoo_get_yab(yd->client_id); … … 1533 1621 1534 1622 static void yahoo_process_list(struct yahoo_input_data *yid, 1535 1623 struct yahoo_packet *pkt) 1536 1624 { 1537 1625 struct yahoo_data *yd = yid->yd; … … 1543 1631 1544 1632 switch (pair->key) { 1545 case 89: /* identities */ 1546 { 1547 char **identities = 1548 y_strsplit(pair->value, ",", -1); 1549 int i; 1550 for (i = 0; identities[i]; i++) 1551 yd->identities = 1552 y_list_append(yd->identities, 1553 strdup(identities[i])); 1554 y_strfreev(identities); 1633 case 89: /* identities */ 1634 { 1635 char **identities = 1636 y_strsplit(pair->value, ",", -1); 1637 int i; 1638 for (i = 0; identities[i]; i++) { 1639 yd->identities = 1640 y_list_append(yd->identities, 1641 strdup(identities[i])); 1555 1642 } 1556 YAHOO_CALLBACK(ext_yahoo_got_identities) (yd->client_id, 1557 yd->identities); 1558 break; 1559 case 59: /* cookies */ 1643 y_strfreev(identities); 1644 } 1645 YAHOO_CALLBACK (ext_yahoo_got_identities) (yd->client_id, 1646 yd->identities); 1647 break; 1648 case 59: /* cookies */ 1560 1649 if (pair->value[0] == 'Y') { 1561 1650 FREE(yd->cookie_y); … … 1575 1664 1576 1665 break; 1577 case 3: /* my id */ 1578 case 90: /* 1 */ 1579 case 100: /* 0 */ 1580 case 101: /* NULL */ 1581 case 102: /* NULL */ 1582 case 93: /* 86400/1440 */ 1583 break; 1584 } 1585 } 1586 1587 if (yd->cookie_y && yd->cookie_t) /* We don't get cookie_c anymore */ 1588 YAHOO_CALLBACK(ext_yahoo_got_cookies) (yd->client_id); 1666 case 3: /* my id */ 1667 case 90: /* 1 */ 1668 case 100: /* 0 */ 1669 case 101: /* NULL */ 1670 case 102: /* NULL */ 1671 case 93: /* 86400/1440 */ 1672 break; 1673 } 1674 } 1675 1676 if (yd->cookie_y && yd->cookie_t) { /* We don't get cookie_c anymore */ 1677 YAHOO_CALLBACK (ext_yahoo_got_cookies) (yd->client_id); 1678 } 1589 1679 } 1590 1680 1591 1681 static void yahoo_process_verify(struct yahoo_input_data *yid, 1592 1682 struct yahoo_packet *pkt) 1593 1683 { 1594 1684 struct yahoo_data *yd = yid->yd; … … 1596 1686 if (pkt->status != 0x01) { 1597 1687 DEBUG_MSG(("expected status: 0x01, got: %d", pkt->status)); 1598 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,1599 1688 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 1689 YAHOO_LOGIN_LOCK, ""); 1600 1690 return; 1601 1691 } 1602 1692 1603 1693 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YPACKET_STATUS_DEFAULT, 1604 1694 yd->session_id); 1605 1695 1606 1696 yahoo_packet_hash(pkt, 1, yd->user); … … 1612 1702 1613 1703 static void yahoo_process_picture_checksum(struct yahoo_input_data *yid, 1614 1704 struct yahoo_packet *pkt) 1615 1705 { 1616 1706 struct yahoo_data *yd = yid->yd; … … 1638 1728 } 1639 1729 1640 YAHOO_CALLBACK (ext_yahoo_got_buddyicon_checksum) (yd->client_id, to,1641 1730 YAHOO_CALLBACK (ext_yahoo_got_buddyicon_checksum) (yd->client_id, to, 1731 from, checksum); 1642 1732 } 1643 1733 1644 1734 static void yahoo_process_picture(struct yahoo_input_data *yid, 1645 1735 struct yahoo_packet *pkt) 1646 1736 { 1647 1737 struct yahoo_data *yd = yid->yd; … … 1658 1748 switch (pair->key) { 1659 1749 case 1: 1660 case 4: 1750 case 4: /* sender */ 1661 1751 from = pair->value; 1662 1752 break; 1663 case 5: 1753 case 5: /* we */ 1664 1754 to = pair->value; 1665 1755 break; 1666 case 13: 1756 case 13: /* request / sending */ 1667 1757 status = atoi(pair->value); 1668 1758 break; 1669 case 20: 1759 case 20: /* url */ 1670 1760 url = pair->value; 1671 1761 break; 1672 case 192: 1762 case 192: /*checksum */ 1673 1763 checksum = atoi(pair->value); 1674 1764 break; … … 1677 1767 1678 1768 switch (status) { 1679 case 1: 1680 YAHOO_CALLBACK (ext_yahoo_got_buddyicon_request) (yd->client_id,1681 1769 case 1: /* this is a request, ignore for now */ 1770 YAHOO_CALLBACK (ext_yahoo_got_buddyicon_request) (yd->client_id, 1771 to, from); 1682 1772 break; 1683 case 2: 1684 YAHOO_CALLBACK (ext_yahoo_got_buddyicon) (yd->client_id, to,1685 1773 case 2: /* this is cool - we get a picture :) */ 1774 YAHOO_CALLBACK (ext_yahoo_got_buddyicon) (yd->client_id, to, 1775 from, url, checksum); 1686 1776 break; 1687 1777 } … … 1689 1779 1690 1780 static void yahoo_process_picture_upload(struct yahoo_input_data *yid, 1691 1781 struct yahoo_packet *pkt) 1692 1782 { 1693 1783 struct yahoo_data *yd = yid->yd; … … 1695 1785 char *url = NULL; 1696 1786 1697 if (pkt->status != 1) 1698 return; /* something went wrong */ 1699 1787 if (pkt->status != 1) { 1788 return; /* something went wrong */ 1789 1790 } 1700 1791 for (l = pkt->hash; l; l = l->next) { 1701 1792 struct yahoo_pair *pair = l->data; 1702 1793 1703 1794 switch (pair->key) { 1704 case 5: 1705 break; 1706 case 20: 1795 case 5: /* we */ 1796 break; 1797 case 20: /* url */ 1707 1798 url = pair->value; 1708 1799 break; 1709 case 27: 1710 break; 1711 case 38: 1712 break; 1713 } 1714 } 1715 1716 YAHOO_CALLBACK (ext_yahoo_buddyicon_uploaded) (yd->client_id, url);1800 case 27: /* local filename */ 1801 break; 1802 case 38: /* time */ 1803 break; 1804 } 1805 } 1806 1807 YAHOO_CALLBACK (ext_yahoo_buddyicon_uploaded) (yd->client_id, url); 1717 1808 } 1718 1809 … … 1727 1818 1728 1819 struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1); 1820 1729 1821 yid->yd = yd; 1730 1822 yid->type = YAHOO_CONNECTION_PAGER; … … 1739 1831 host = yss->pager_host; 1740 1832 1741 if (!host) 1833 if (!host) { 1742 1834 host = yss->pager_host_list[0]; 1743 1744 tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id, 1745 host, yss->pager_port, yahoo_connected, ccd, 0); 1835 } 1836 1837 tag = YAHOO_CALLBACK (ext_yahoo_connect_async) (yd->client_id, 1838 host, yss->pager_port, yahoo_connected, ccd, 0); 1746 1839 1747 1840 /* … … 1749 1842 * so ccd will have been freed 1750 1843 */ 1751 if (tag > 0) 1844 if (tag > 0) { 1752 1845 ccd->tag = tag; 1753 else if (tag < 0)1754 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,1755 1756 }1757 1758 struct yahoo_https_auth_data 1759 {1846 } else if (tag < 0) { 1847 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 1848 YAHOO_LOGIN_SOCK, NULL); 1849 } 1850 } 1851 1852 struct yahoo_https_auth_data { 1760 1853 struct yahoo_input_data *yid; 1761 1854 char *token; … … 1774 1867 char *s, *end; 1775 1868 int len = strlen(key); 1776 1869 1777 1870 s = response; 1778 1871 do { 1779 1872 if (strncmp(s, key, len) == 0 && s[len] == '=') { 1780 1873 s += len + 1; 1781 if ((end = strchr(s, '\r'))) 1874 if ((end = strchr(s, '\r'))) { 1782 1875 return g_strndup(s, end - s); 1783 else1876 } else { 1784 1877 return g_strdup(s); 1785 } 1786 1787 if ((s = strchr(s, '\n'))) 1788 s ++; 1878 } 1879 } 1880 1881 if ((s = strchr(s, '\n'))) { 1882 s++; 1883 } 1789 1884 } while (s && *s); 1790 1885 1791 1886 return NULL; 1792 1887 } … … 1794 1889 static enum yahoo_status yahoo_https_status_parse(int code) 1795 1890 { 1796 switch (code) 1797 { 1798 case 1212: return (enum yahoo_status) YAHOO_LOGIN_PASSWD; 1799 case 1213: return (enum yahoo_status) YAHOO_LOGIN_LOCK; 1800 case 1235: return (enum yahoo_status) YAHOO_LOGIN_UNAME; 1801 default: return (enum yahoo_status) code; 1891 switch (code) { 1892 case 1212: return (enum yahoo_status) YAHOO_LOGIN_PASSWD; 1893 case 1213: return (enum yahoo_status) YAHOO_LOGIN_LOCK; 1894 case 1235: return (enum yahoo_status) YAHOO_LOGIN_UNAME; 1895 default: return (enum yahoo_status) code; 1802 1896 } 1803 1897 } … … 1806 1900 { 1807 1901 struct yahoo_https_auth_data *had = g_new0(struct yahoo_https_auth_data, 1); 1808 1902 1809 1903 had->yid = yid; 1810 1904 had->chal = g_strdup(seed); 1811 1905 1812 1906 yahoo_https_auth_token_init(had); 1813 1907 } … … 1819 1913 char *login, *passwd, *chal; 1820 1914 char *url; 1821 1915 1822 1916 login = g_strndup(yd->user, 3 * strlen(yd->user)); 1823 1917 http_encode(login); … … 1826 1920 chal = g_strndup(had->chal, 3 * strlen(had->chal)); 1827 1921 http_encode(chal); 1828 1922 1829 1923 url = g_strdup_printf("https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=%d&login=%s&passwd=%s&chal=%s", 1830 1831 1924 (int) time(NULL), login, passwd, chal); 1925 1832 1926 http_dorequest_url(url, yahoo_https_auth_token_finish, had); 1833 1927 1834 1928 g_free(url); 1835 1929 g_free(chal); … … 1844 1938 struct yahoo_data *yd; 1845 1939 int st; 1846 1847 if (y_list_find(inputs, had->yid) == NULL) 1848 return; 1849 1940 1941 if (y_list_find(inputs, had->yid) == NULL) { 1942 return; 1943 } 1944 1850 1945 yid = had->yid; 1851 1946 yd = yid->yd; 1852 1947 1853 1948 if (req->status_code != 200) { 1854 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);1949 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL); 1855 1950 goto fail; 1856 1951 } 1857 1952 1858 1953 if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) { 1859 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL);1954 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL); 1860 1955 goto fail; 1861 1956 } 1862 1957 1863 1958 if ((had->token = yahoo_ha_find_key(req->reply_body, "ymsgr")) == NULL) { 1864 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 3001, NULL);1959 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 3001, NULL); 1865 1960 goto fail; 1866 1961 } 1867 1962 1868 1963 yahoo_https_auth_init(had); 1869 1964 return; 1870 1965 1871 1966 fail: 1872 1967 g_free(had->token); … … 1878 1973 { 1879 1974 char *url; 1880 1975 1881 1976 url = g_strdup_printf("https://login.yahoo.com/config/pwtoken_login?src=ymsgr&ts=%d&token=%s", 1882 1977 (int) time(NULL), had->token); 1883 1978 1884 1979 http_dorequest_url(url, yahoo_https_auth_finish, had); 1885 1980 1886 1981 g_free(url); 1887 1982 } … … 1895 1990 char *crumb = NULL; 1896 1991 int st; 1897 1898 if (y_list_find(inputs, had->yid) == NULL) 1899 return; 1900 1992 1993 if (y_list_find(inputs, had->yid) == NULL) { 1994 return; 1995 } 1996 1901 1997 yid = had->yid; 1902 1998 yd = yid->yd; 1903 1999 1904 2000 md5_byte_t result[16]; 1905 2001 md5_state_t ctx; 1906 2002 1907 2003 unsigned char yhash[32]; 1908 2004 1909 2005 if (req->status_code != 200) { 1910 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL);2006 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 2000 + req->status_code, NULL); 1911 2007 goto fail; 1912 2008 } 1913 2009 1914 2010 if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) { 1915 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL);2011 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, yahoo_https_status_parse(st), NULL); 1916 2012 goto fail; 1917 2013 } 1918 2014 1919 2015 if ((yd->cookie_y = yahoo_ha_find_key(req->reply_body, "Y")) == NULL || 1920 2016 (yd->cookie_t = yahoo_ha_find_key(req->reply_body, "T")) == NULL || 1921 2017 (crumb = yahoo_ha_find_key(req->reply_body, "crumb")) == NULL) { 1922 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 3002, NULL);2018 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 3002, NULL); 1923 2019 goto fail; 1924 2020 } 1925 1926 md5_init(&ctx); 1927 md5_append(&ctx, (unsigned char *) crumb, 11);1928 md5_append(&ctx, (unsigned char *) had->chal, strlen(had->chal));2021 2022 md5_init(&ctx); 2023 md5_append(&ctx, (unsigned char *) crumb, 11); 2024 md5_append(&ctx, (unsigned char *) had->chal, strlen(had->chal)); 1929 2025 md5_finish(&ctx, result); 1930 2026 to_y64(yhash, result, 16); … … 1935 2031 yahoo_packet_hash(pack, 277, yd->cookie_y); 1936 2032 yahoo_packet_hash(pack, 278, yd->cookie_t); 1937 yahoo_packet_hash(pack, 307, (char *) yhash);2033 yahoo_packet_hash(pack, 307, (char *) yhash); 1938 2034 yahoo_packet_hash(pack, 244, "524223"); 1939 2035 yahoo_packet_hash(pack, 2, yd->user); … … 1941 2037 yahoo_packet_hash(pack, 98, "us"); 1942 2038 yahoo_packet_hash(pack, 135, "7.5.0.647"); 1943 2039 1944 2040 yahoo_send_packet(yid, pack, 0); 1945 2041 1946 2042 yahoo_packet_free(pack); 1947 2043 1948 2044 fail: 1949 2045 g_free(crumb); … … 1954 2050 1955 2051 static void yahoo_process_auth(struct yahoo_input_data *yid, 1956 2052 struct yahoo_packet *pkt) 1957 2053 { 1958 2054 char *seed = NULL; … … 1979 2075 } 1980 2076 1981 if (!seed) 1982 return; 1983 1984 if (m==2) 2077 if (!seed) { 2078 return; 2079 } 2080 2081 if (m == 2) { 1985 2082 yahoo_https_auth(yid, seed, sn); 1986 else {2083 } else { 1987 2084 /* call error */ 1988 2085 WARNING(("unknown auth type %d", m)); 1989 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,1990 2086 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 2087 YAHOO_LOGIN_UNKNOWN, NULL); 1991 2088 } 1992 2089 } 1993 2090 1994 2091 static void yahoo_process_auth_resp(struct yahoo_input_data *yid, 1995 2092 struct yahoo_packet *pkt) 1996 2093 { 1997 2094 struct yahoo_data *yd = yid->yd; … … 2003 2100 for (l = pkt->hash; l; l = l->next) { 2004 2101 struct yahoo_pair *pair = l->data; 2005 if (pair->key == 0) 2102 if (pair->key == 0) { 2006 2103 ; /* login_id */ 2007 else if (pair->key == 1)2104 } else if (pair->key == 1) { 2008 2105 ; /* handle */ 2009 else if (pair->key == 20)2106 } else if (pair->key == 20) { 2010 2107 url = pair->value; 2011 else if (pair->key == 66)2108 } else if (pair->key == 66) { 2012 2109 login_status = atoi(pair->value); 2110 } 2013 2111 } 2014 2112 2015 2113 if (pkt->status == YPACKET_STATUS_DISCONNECTED) { 2016 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,2017 2114 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 2115 login_status, url); 2018 2116 /* yahoo_logoff(yd->client_id); */ 2019 2117 } … … 2021 2119 2022 2120 static void yahoo_process_mail(struct yahoo_input_data *yid, 2023 2121 struct yahoo_packet *pkt) 2024 2122 { 2025 2123 struct yahoo_data *yd = yid->yd; … … 2032 2130 for (l = pkt->hash; l; l = l->next) { 2033 2131 struct yahoo_pair *pair = l->data; 2034 if (pair->key == 9) 2132 if (pair->key == 9) { 2035 2133 count = strtol(pair->value, NULL, 10); 2036 else if (pair->key == 43)2134 } else if (pair->key == 43) { 2037 2135 who = pair->value; 2038 else if (pair->key == 42)2136 } else if (pair->key == 42) { 2039 2137 email = pair->value; 2040 else if (pair->key == 18)2138 } else if (pair->key == 18) { 2041 2139 subj = pair->value; 2042 else2140 } else { 2043 2141 LOG(("key: %d => value: %s", pair->key, pair->value)); 2142 } 2044 2143 } 2045 2144 … … 2047 2146 char from[1024]; 2048 2147 snprintf(from, sizeof(from), "%s (%s)", who, email); 2049 YAHOO_CALLBACK(ext_yahoo_mail_notify) (yd->client_id, from, 2050 subj, count); 2051 } else if (count > 0) 2052 YAHOO_CALLBACK(ext_yahoo_mail_notify) (yd->client_id, NULL, 2053 NULL, count); 2148 YAHOO_CALLBACK (ext_yahoo_mail_notify) (yd->client_id, from, 2149 subj, count); 2150 } else if (count > 0) { 2151 YAHOO_CALLBACK (ext_yahoo_mail_notify) (yd->client_id, NULL, 2152 NULL, count); 2153 } 2054 2154 } 2055 2155 2056 2156 static void yahoo_process_new_contact(struct yahoo_input_data *yid, 2057 2157 struct yahoo_packet *pkt) 2058 2158 { 2059 2159 struct yahoo_data *yd = yid->yd; … … 2067 2167 for (l = pkt->hash; l; l = l->next) { 2068 2168 struct yahoo_pair *pair = l->data; 2069 if (pair->key == 4) 2169 if (pair->key == 4) { 2070 2170 who = pair->value; 2071 else if (pair->key == 5)2171 } else if (pair->key == 5) { 2072 2172 me = pair->value; 2073 else if (pair->key == 14)2173 } else if (pair->key == 14) { 2074 2174 msg = pair->value; 2075 else if (pair->key == 13)2175 } else if (pair->key == 13) { 2076 2176 online = strtol(pair->value, NULL, 10); 2077 } 2078 2079 if (who && online < 0) 2080 YAHOO_CALLBACK(ext_yahoo_contact_added) (yd->client_id, me, who, 2081 msg); 2082 else if (online == 2) 2083 YAHOO_CALLBACK(ext_yahoo_rejected) (yd->client_id, who, msg); 2177 } 2178 } 2179 2180 if (who && online < 0) { 2181 YAHOO_CALLBACK (ext_yahoo_contact_added) (yd->client_id, me, who, 2182 msg); 2183 } else if (online == 2) { 2184 YAHOO_CALLBACK (ext_yahoo_rejected) (yd->client_id, who, msg); 2185 } 2084 2186 } 2085 2187 2086 2188 /* UNUSED? */ 2087 2189 static void yahoo_process_contact(struct yahoo_input_data *yid, 2088 2190 struct yahoo_packet *pkt) 2089 2191 { 2090 2192 struct yahoo_data *yd = yid->yd; … … 2102 2204 for (l = pkt->hash; l; l = l->next) { 2103 2205 struct yahoo_pair *pair = l->data; 2104 if (pair->key == 1) 2206 if (pair->key == 1) { 2105 2207 id = pair->value; 2106 else if (pair->key == 3)2208 } else if (pair->key == 3) { 2107 2209 who = pair->value; 2108 else if (pair->key == 14)2210 } else if (pair->key == 14) { 2109 2211 msg = pair->value; 2110 else if (pair->key == 7)2212 } else if (pair->key == 7) { 2111 2213 name = pair->value; 2112 else if (pair->key == 10)2214 } else if (pair->key == 10) { 2113 2215 state = strtol(pair->value, NULL, 10); 2114 else if (pair->key == 15)2216 } else if (pair->key == 15) { 2115 2217 ; /* tm */ 2116 else if (pair->key == 13)2218 } else if (pair->key == 13) { 2117 2219 ; /* online */ 2118 else if (pair->key == 47)2220 } else if (pair->key == 47) { 2119 2221 away = strtol(pair->value, NULL, 10); 2120 else if (pair->key == 137)2222 } else if (pair->key == 137) { 2121 2223 idle = strtol(pair->value, NULL, 10); 2122 else if (pair->key == 60)2224 } else if (pair->key == 60) { 2123 2225 mobile = strtol(pair->value, NULL, 10); 2124 2125 } 2126 2127 if (id) 2128 YAHOO_CALLBACK(ext_yahoo_contact_added) (yd->client_id, id, who, 2129 msg); 2130 else if (name) 2131 YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->client_id, name, 2132 state, msg, away, idle, mobile); 2133 else if (pkt->status == 0x07) 2134 YAHOO_CALLBACK(ext_yahoo_rejected) (yd->client_id, who, msg); 2226 } 2227 2228 } 2229 2230 if (id) { 2231 YAHOO_CALLBACK (ext_yahoo_contact_added) (yd->client_id, id, who, 2232 msg); 2233 } else if (name) { 2234 YAHOO_CALLBACK (ext_yahoo_status_changed) (yd->client_id, name, 2235 state, msg, away, idle, mobile); 2236 } else if (pkt->status == 0x07) { 2237 YAHOO_CALLBACK (ext_yahoo_rejected) (yd->client_id, who, msg); 2238 } 2135 2239 } 2136 2240 2137 2241 static void yahoo_process_buddyadd(struct yahoo_input_data *yid, 2138 2242 struct yahoo_packet *pkt) 2139 2243 { 2140 2244 struct yahoo_data *yd = yid->yd; … … 2146 2250 2147 2251 YList *l; 2252 2148 2253 for (l = pkt->hash; l; l = l->next) { 2149 2254 struct yahoo_pair *pair = l->data; 2150 if (pair->key == 1) 2255 if (pair->key == 1) { 2151 2256 ; /* Me... don't care */ 2152 if (pair->key == 7) 2257 } 2258 if (pair->key == 7) { 2153 2259 who = pair->value; 2154 if (pair->key == 65) 2260 } 2261 if (pair->key == 65) { 2155 2262 where = pair->value; 2156 if (pair->key == 66) 2263 } 2264 if (pair->key == 66) { 2157 2265 status = strtol(pair->value, NULL, 10); 2158 } 2159 2160 if (!who) 2161 return; 2162 if (!where) 2266 } 2267 } 2268 2269 if (!who) { 2270 return; 2271 } 2272 if (!where) { 2163 2273 where = "Unknown"; 2274 } 2164 2275 2165 2276 bud = y_new0(struct yahoo_buddy, 1); … … 2181 2292 accepted. Couldn't find any test account that doesn't require auth. 2182 2293 unfortunately (if there is even such a thing?) */ 2183 2184 /* A non-zero status (i've seen 2) seems to mean the buddy is already 2294 2295 /* A non-zero status (i've seen 2) seems to mean the buddy is already 2185 2296 * added and is online */ 2186 2297 if (status) { 2187 2298 LOG(("Setting online see packet for info")); 2188 2299 yahoo_dump_unhandled(pkt); 2189 YAHOO_CALLBACK (ext_yahoo_status_changed) (yd->client_id, who,2190 2300 YAHOO_CALLBACK (ext_yahoo_status_changed) (yd->client_id, who, 2301 YAHOO_STATUS_AVAILABLE, NULL, 0, 0, 0); 2191 2302 } 2192 2303 #endif … … 2194 2305 if (status == 0) { 2195 2306 YList *tmp = y_list_append(NULL, bud); 2196 YAHOO_CALLBACK (ext_yahoo_got_buddies) (yd->client_id, tmp);2307 YAHOO_CALLBACK (ext_yahoo_got_buddies) (yd->client_id, tmp); 2197 2308 y_list_free(tmp); 2198 2309 } … … 2200 2311 2201 2312 static void yahoo_process_buddydel(struct yahoo_input_data *yid, 2202 2313 struct yahoo_packet *pkt) 2203 2314 { 2204 2315 struct yahoo_data *yd = yid->yd; … … 2210 2321 2211 2322 YList *l; 2323 2212 2324 for (l = pkt->hash; l; l = l->next) { 2213 2325 struct yahoo_pair *pair = l->data; 2214 if (pair->key == 1) 2326 if (pair->key == 1) { 2215 2327 ; /* Me... don't care */ 2216 else if (pair->key == 7)2328 } else if (pair->key == 7) { 2217 2329 who = pair->value; 2218 else if (pair->key == 65)2330 } else if (pair->key == 65) { 2219 2331 where = pair->value; 2220 else if (pair->key == 66)2332 } else if (pair->key == 66) { 2221 2333 ; /* unk_66 */ 2222 else2334 } else { 2223 2335 DEBUG_MSG(("unknown key: %d = %s", pair->key, 2224 pair->value)); 2225 } 2226 2227 if (!who || !where) 2228 return; 2336 pair->value)); 2337 } 2338 } 2339 2340 if (!who || !where) { 2341 return; 2342 } 2229 2343 2230 2344 bud = y_new0(struct yahoo_buddy, 1); … … 2253 2367 2254 2368 static void yahoo_process_ignore(struct yahoo_input_data *yid, 2255 2369 struct yahoo_packet *pkt) 2256 2370 { 2257 2371 YList *l; 2372 2258 2373 for (l = pkt->hash; l; l = l->next) { 2259 2374 struct yahoo_pair *pair = l->data; 2260 if (pair->key == 0) 2375 if (pair->key == 0) { 2261 2376 ; /* who */ 2262 if (pair->key == 1) 2377 } 2378 if (pair->key == 1) { 2263 2379 ; /* Me... don't care */ 2264 if (pair->key == 13) /* 1 == ignore, 2 == unignore */ 2380 } 2381 if (pair->key == 13) { /* 1 == ignore, 2 == unignore */ 2265 2382 ; 2266 if (pair->key == 66) 2383 } 2384 if (pair->key == 66) { 2267 2385 ; /* status */ 2386 } 2268 2387 } 2269 2388 … … 2277 2396 2278 2397 /* if(status) 2279 2398 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, who, 0, status); 2280 2399 */ 2281 2400 } 2282 2401 2283 2402 static void yahoo_process_voicechat(struct yahoo_input_data *yid, 2284 2403 struct yahoo_packet *pkt) 2285 2404 { 2286 2405 char *who = NULL; … … 2289 2408 2290 2409 YList *l; 2410 2291 2411 for (l = pkt->hash; l; l = l->next) { 2292 2412 struct yahoo_pair *pair = l->data; 2293 if (pair->key == 4) 2413 if (pair->key == 4) { 2294 2414 who = pair->value; 2295 if (pair->key == 5) 2415 } 2416 if (pair->key == 5) { 2296 2417 me = pair->value; 2297 if (pair->key == 13) 2418 } 2419 if (pair->key == 13) { 2298 2420 ; /* voice room */ 2299 if (pair->key == 57) 2421 } 2422 if (pair->key == 57) { 2300 2423 room = pair->value; 2424 } 2301 2425 } 2302 2426 2303 2427 NOTICE(("got voice chat invite from %s in %s to identity %s", who, room, 2304 2305 /* 2428 me)); 2429 /* 2306 2430 * send: s:0 1:me 5:who 57:room 13:1 2307 2431 * ???? s:4 5:who 10:99 19:-1615114531 … … 2315 2439 2316 2440 static void yahoo_process_ping(struct yahoo_input_data *yid, 2317 2441 struct yahoo_packet *pkt) 2318 2442 { 2319 2443 char *errormsg = NULL; 2320 2444 2321 2445 YList *l; 2446 2322 2447 for (l = pkt->hash; l; l = l->next) { 2323 2448 struct yahoo_pair *pair = l->data; 2324 if (pair->key == 16) 2449 if (pair->key == 16) { 2325 2450 errormsg = pair->value; 2451 } 2326 2452 } 2327 2453 2328 2454 NOTICE(("got ping packet")); 2329 YAHOO_CALLBACK (ext_yahoo_got_ping) (yid->yd->client_id, errormsg);2455 YAHOO_CALLBACK (ext_yahoo_got_ping) (yid->yd->client_id, errormsg); 2330 2456 } 2331 2457 2332 2458 static void yahoo_process_buddy_change_group(struct yahoo_input_data *yid, 2333 2459 struct yahoo_packet *pkt) 2334 2460 { 2335 2461 YList *l; … … 2341 2467 for (l = pkt->hash; l; l = l->next) { 2342 2468 struct yahoo_pair *pair = l->data; 2343 if (pair->key == 1) 2469 if (pair->key == 1) { 2344 2470 me = pair->value; 2345 if (pair->key == 7) 2471 } 2472 if (pair->key == 7) { 2346 2473 who = pair->value; 2347 if (pair->key == 224) 2474 } 2475 if (pair->key == 224) { 2348 2476 old_group = pair->value; 2349 if (pair->key == 264) 2477 } 2478 if (pair->key == 264) { 2350 2479 new_group = pair->value; 2351 } 2352 2353 YAHOO_CALLBACK(ext_yahoo_got_buddy_change_group) (yid->yd->client_id, 2354 me, who, old_group, new_group); 2480 } 2481 } 2482 2483 YAHOO_CALLBACK (ext_yahoo_got_buddy_change_group) (yid->yd->client_id, 2484 me, who, old_group, new_group); 2355 2485 } 2356 2486 … … 2376 2506 2377 2507 /* send initial packet */ 2378 if (who) 2508 if (who) { 2379 2509 data = strdup("<RVWCFG>"); 2380 else2510 } else { 2381 2511 data = strdup("<RUPCFG>"); 2512 } 2382 2513 yahoo_add_to_send_queue(yid, data, strlen(data)); 2383 2514 FREE(data); … … 2404 2535 2405 2536 yid->read_tag = 2406 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,2407 2537 YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id, fd, 2538 YAHOO_INPUT_READ, yid); 2408 2539 } 2409 2540 2410 2541 static void yahoo_webcam_get_server(struct yahoo_input_data *y, char *who, 2411 2542 char *key) 2412 2543 { 2413 2544 struct yahoo_input_data *yid = y_new0(struct yahoo_input_data, 1); … … 2421 2552 yid->wcm->key = strdup(key); 2422 2553 2423 YAHOO_CALLBACK (ext_yahoo_connect_async) (yid->yd->client_id,2424 2425 2554 YAHOO_CALLBACK (ext_yahoo_connect_async) (yid->yd->client_id, 2555 yss->webcam_host, yss->webcam_port, 2556 _yahoo_webcam_get_server_connected, yid, 0); 2426 2557 2427 2558 } … … 2429 2560 static YList *webcam_queue = NULL; 2430 2561 static void yahoo_process_webcam_key(struct yahoo_input_data *yid, 2431 2562 struct yahoo_packet *pkt) 2432 2563 { 2433 2564 char *key = NULL; … … 2435 2566 2436 2567 YList *l; 2568 2437 2569 yahoo_dump_unhandled(pkt); 2438 2570 for (l = pkt->hash; l; l = l->next) { 2439 2571 struct yahoo_pair *pair = l->data; 2440 if (pair->key == 5) 2572 if (pair->key == 5) { 2441 2573 ; /* me */ 2442 if (pair->key == 61) 2574 } 2575 if (pair->key == 61) { 2443 2576 key = pair->value; 2577 } 2444 2578 } 2445 2579 2446 2580 l = webcam_queue; 2447 if (!l) 2448 return; 2581 if (!l) { 2582 return; 2583 } 2449 2584 who = l->data; 2450 2585 webcam_queue = y_list_remove_link(webcam_queue, webcam_queue); … … 2455 2590 2456 2591 static void yahoo_packet_process(struct yahoo_input_data *yid, 2457 2592 struct yahoo_packet *pkt) 2458 2593 { 2459 2594 DEBUG_MSG(("yahoo_packet_process: 0x%02x", pkt->service)); … … 2577 2712 yahoo_process_picture_upload(yid, pkt); 2578 2713 break; 2579 case YAHOO_SERVICE_Y8_LIST: 2714 case YAHOO_SERVICE_Y8_LIST: /* Buddy List */ 2580 2715 yahoo_process_buddy_list(yid, pkt); 2581 2716 break; … … 2594 2729 int pktlen; 2595 2730 2596 if (!yd) 2731 if (!yd) { 2597 2732 return NULL; 2733 } 2598 2734 2599 2735 DEBUG_MSG(("rxlen is %d", yid->rxlen)); … … 2603 2739 } 2604 2740 2605 pos += 4; 2741 pos += 4; /* YMSG */ 2606 2742 pos += 2; 2607 2743 pos += 2; … … 2626 2762 pos += 4; 2627 2763 DEBUG_MSG(("Yahoo Service: 0x%02x Status: %d", pkt->service, 2628 2764 pkt->status)); 2629 2765 pkt->id = yahoo_get32(yid->rxqueue + pos); 2630 2766 pos += 4; … … 2638 2774 if (yid->rxlen > 0) { 2639 2775 unsigned char *tmp = y_memdup(yid->rxqueue + YAHOO_PACKET_HDRLEN 2640 2776 + pktlen, yid->rxlen); 2641 2777 FREE(yid->rxqueue); 2642 2778 yid->rxqueue = tmp; 2643 2779 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, 2644 2780 yid->rxqueue)); 2645 2781 } else { 2646 2782 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue)); … … 2655 2791 { 2656 2792 char *st, *en; 2657 char *data = (char *) d;2793 char *data = (char *) d; 2658 2794 struct yab *yab = NULL; 2659 2795 … … 2671 2807 } 2672 2808 2673 if (!en) 2809 if (!en) { 2674 2810 return NULL; 2811 } 2675 2812 2676 2813 st = strstr(en, "id=\""); … … 2755 2892 struct yahoo_data *yd = yid->yd; 2756 2893 2757 if (!yd) 2894 if (!yd) { 2758 2895 return NULL; 2896 } 2759 2897 2760 2898 do { 2761 2899 DEBUG_MSG(("rxlen is %d", yid->rxlen)); 2762 2900 2763 if (yid->rxlen <= strlen("<ct")) 2901 if (yid->rxlen <= strlen("<ct")) { 2764 2902 return NULL; 2903 } 2765 2904 2766 2905 /* start with <ct */ 2767 2906 while (pos < yid->rxlen - strlen("<ct") + 1 2768 && memcmp(yid->rxqueue + pos, "<ct", strlen("<ct")))2907 && memcmp(yid->rxqueue + pos, "<ct", strlen("<ct"))) { 2769 2908 pos++; 2770 2771 if (pos >= yid->rxlen - 1) 2909 } 2910 2911 if (pos >= yid->rxlen - 1) { 2772 2912 return NULL; 2913 } 2773 2914 2774 2915 end = pos + 2; 2775 2916 /* end with > */ 2776 2917 while (end < yid->rxlen - strlen(">") 2777 && memcmp(yid->rxqueue + end, ">", strlen(">")))2918 && memcmp(yid->rxqueue + end, ">", strlen(">"))) { 2778 2919 end++; 2779 2780 if (end >= yid->rxlen - 1) 2920 } 2921 2922 if (end >= yid->rxlen - 1) { 2781 2923 return NULL; 2924 } 2782 2925 2783 2926 yab = yahoo_yab_read(yid->rxqueue + pos, end + 2 - pos); … … 2785 2928 yid->rxlen -= end + 1; 2786 2929 DEBUG_MSG(("rxlen == %d, rxqueue == %p", yid->rxlen, 2787 2930 yid->rxqueue)); 2788 2931 if (yid->rxlen > 0) { 2789 2932 unsigned char *tmp = 2790 2933 y_memdup(yid->rxqueue + end + 1, yid->rxlen); 2791 2934 FREE(yid->rxqueue); 2792 2935 yid->rxqueue = tmp; 2793 2936 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, 2794 2937 yid->rxqueue)); 2795 2938 } else { 2796 2939 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue)); … … 2812 2955 struct yahoo_data *yd = yid->yd; 2813 2956 2814 if (!yid || !yd) 2957 if (!yid || !yd) { 2815 2958 return NULL; 2959 } 2816 2960 2817 2961 DEBUG_MSG(("rxlen is %d", yid->rxlen)); 2818 2962 2819 2963 len = yid->rxqueue[pos++]; 2820 if (yid->rxlen < len) 2964 if (yid->rxlen < len) { 2821 2965 return NULL; 2966 } 2822 2967 2823 2968 /* extract status (0 = ok, 6 = webcam not online) */ … … 2825 2970 2826 2971 if (status == 0) { 2827 pos += 2; 2972 pos += 2; /* skip next 2 bytes */ 2828 2973 server = y_memdup(yid->rxqueue + pos, 16); 2829 2974 pos += 16; 2830 2975 } else if (status == 6) { 2831 YAHOO_CALLBACK (ext_yahoo_webcam_closed)2832 2976 YAHOO_CALLBACK (ext_yahoo_webcam_closed) 2977 (yd->client_id, yid->wcm->user, 4); 2833 2978 } 2834 2979 … … 2842 2987 yid->rxqueue = tmp; 2843 2988 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, 2844 2989 yid->rxqueue)); 2845 2990 } else { 2846 2991 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue)); … … 2863 3008 struct yahoo_data *yd = yid->yd; 2864 3009 2865 if (!yd) 3010 if (!yd) { 2866 3011 return -1; 2867 2868 if (!yid->wcm || !yid->wcd || !yid->rxlen) 3012 } 3013 3014 if (!yid->wcm || !yid->wcd || !yid->rxlen) { 2869 3015 return -1; 3016 } 2870 3017 2871 3018 DEBUG_MSG(("rxlen is %d", yid->rxlen)); … … 2876 3023 yid->wcd->packet_type = 0; 2877 3024 2878 if (yid->rxlen < header_len) 3025 if (yid->rxlen < header_len) { 2879 3026 return 0; 3027 } 2880 3028 2881 3029 if (header_len >= 8) { … … 2899 3047 begin = pos; 2900 3048 pos += yid->wcd->to_read; 2901 if (pos > yid->rxlen) 3049 if (pos > yid->rxlen) { 2902 3050 pos = yid->rxlen; 3051 } 2903 3052 2904 3053 /* if it is not an image then make sure we have the whole packet */ … … 2913 3062 2914 3063 DEBUG_MSG(("packet type %.2X, data length %d", yid->wcd->packet_type, 2915 3064 yid->wcd->data_size)); 2916 3065 2917 3066 /* find out what kind of packet we got */ … … 2920 3069 /* user requests to view webcam (uploading) */ 2921 3070 if (yid->wcd->data_size && 2922 3071 yid->wcm->direction == YAHOO_WEBCAM_UPLOAD) { 2923 3072 end = begin; 2924 while (end <= yid->rxlen && yid->rxqueue[end++] != 13) ; 3073 while (end <= yid->rxlen && yid->rxqueue[end++] != 13) { 3074 ; 3075 } 2925 3076 if (end > begin) { 2926 3077 who = y_memdup(yid->rxqueue + begin, 2927 3078 end - begin); 2928 3079 who[end - begin - 1] = 0; 2929 YAHOO_CALLBACK (ext_yahoo_webcam_viewer) (yd->2930 3080 YAHOO_CALLBACK (ext_yahoo_webcam_viewer) (yd-> 3081 client_id, who + 2, 2); 2931 3082 FREE(who); 2932 3083 } … … 2938 3089 /* 1 = accepted viewing permission */ 2939 3090 if (yid->wcd->timestamp == 0) { 2940 YAHOO_CALLBACK (ext_yahoo_webcam_closed) (yd->2941 3091 YAHOO_CALLBACK (ext_yahoo_webcam_closed) (yd-> 3092 client_id, yid->wcm->user, 3); 2942 3093 } 2943 3094 } 2944 3095 break; 2945 case 0x01: 3096 case 0x01: /* status packets?? */ 2946 3097 /* timestamp contains status info */ 2947 3098 /* 00 00 00 01 = we have data?? */ 2948 3099 break; 2949 case 0x02: 2950 YAHOO_CALLBACK (ext_yahoo_got_webcam_image) (yd->client_id,2951 2952 3100 case 0x02: /* image data */ 3101 YAHOO_CALLBACK (ext_yahoo_got_webcam_image) (yd->client_id, 3102 yid->wcm->user, yid->rxqueue + begin, 3103 yid->wcd->data_size, pos - begin, yid->wcd->timestamp); 2953 3104 break; 2954 case 0x05: 3105 case 0x05: /* response packets when uploading */ 2955 3106 if (!yid->wcd->data_size) { 2956 YAHOO_CALLBACK (ext_yahoo_webcam_data_request) (yd->2957 3107 YAHOO_CALLBACK (ext_yahoo_webcam_data_request) (yd-> 3108 client_id, yid->wcd->timestamp); 2958 3109 } 2959 3110 break; 2960 case 0x07: 3111 case 0x07: /* connection is closing */ 2961 3112 switch (reason) { 2962 case 0x01: 3113 case 0x01: /* user closed connection */ 2963 3114 closed = 1; 2964 3115 break; 2965 case 0x0F: 3116 case 0x0F: /* user cancelled permission */ 2966 3117 closed = 2; 2967 3118 break; 2968 3119 } 2969 YAHOO_CALLBACK (ext_yahoo_webcam_closed) (yd->client_id,2970 3120 YAHOO_CALLBACK (ext_yahoo_webcam_closed) (yd->client_id, 3121 yid->wcm->user, closed); 2971 3122 break; 2972 case 0x0C: 2973 case 0x0D: 3123 case 0x0C: /* user connected */ 3124 case 0x0D: /* user disconnected */ 2974 3125 if (yid->wcd->data_size) { 2975 3126 who = y_memdup(yid->rxqueue + begin, pos - begin + 1); 2976 3127 who[pos - begin] = 0; 2977 if (yid->wcd->packet_type == 0x0C) 3128 if (yid->wcd->packet_type == 0x0C) { 2978 3129 connect = 1; 2979 else3130 } else { 2980 3131 connect = 0; 2981 YAHOO_CALLBACK(ext_yahoo_webcam_viewer) (yd->client_id, 2982 who, connect); 3132 } 3133 YAHOO_CALLBACK (ext_yahoo_webcam_viewer) (yd->client_id, 3134 who, connect); 2983 3135 FREE(who); 2984 3136 } 2985 3137 break; 2986 case 0x13: 3138 case 0x13: /* user data */ 2987 3139 /* i=user_ip (ip of the user we are viewing) */ 2988 3140 /* j=user_ext_ip (external ip of the user we */ 2989 3141 /* are viewing) */ 2990 3142 break; 2991 case 0x17: 3143 case 0x17: /* ?? */ 2992 3144 break; 2993 3145 } … … 3001 3153 yid->rxqueue = tmp; 3002 3154 DEBUG_MSG(("new rxlen == %d, rxqueue == %p", yid->rxlen, 3003 3155 yid->rxqueue)); 3004 3156 } else { 3005 3157 DEBUG_MSG(("freed rxqueue == %p", yid->rxqueue)); … … 3008 3160 3009 3161 /* If we read a complete packet return success */ 3010 if (!yid->wcd->to_read) 3162 if (!yid->wcd->to_read) { 3011 3163 return 1; 3164 } 3012 3165 3013 3166 return 0; … … 3021 3174 3022 3175 LOG(("write callback: id=%d fd=%p data=%p", id, fd, data)); 3023 if (!yid || !yid->txqueues) 3176 if (!yid || !yid->txqueues) { 3024 3177 return -2; 3178 } 3025 3179 3026 3180 tx = yid->txqueues->data; … … 3028 3182 len = yahoo_send_data(fd, tx->queue, MIN(1024, tx->len)); 3029 3183 3030 if (len == -1 && errno == EAGAIN) 3184 if (len == -1 && errno == EAGAIN) { 3031 3185 return 1; 3186 } 3032 3187 3033 3188 if (len <= 0) { … … 3040 3195 free(tx); 3041 3196 yid->txqueues = 3042 3043 3197 y_list_remove_link(yid->txqueues, 3198 yid->txqueues); 3044 3199 y_list_free_1(l); 3045 3200 } 3046 3201 LOG(("yahoo_write_ready(%d, %p) len < 0", id, fd)); 3047 YAHOO_CALLBACK (ext_yahoo_remove_handler) (id, yid->write_tag);3202 YAHOO_CALLBACK (ext_yahoo_remove_handler) (id, yid->write_tag); 3048 3203 yid->write_tag = 0; 3049 3204 errno = e; … … 3062 3217 free(tx); 3063 3218 yid->txqueues = 3064 3219 y_list_remove_link(yid->txqueues, yid->txqueues); 3065 3220 y_list_free_1(l); 3066 3221 /* 3067 if(!yid->txqueues) 3222 if(!yid->txqueues) 3068 3223 LOG(("yahoo_write_ready(%d, %d) !yxqueues", id, fd)); 3069 3224 */ 3070 3225 if (!yid->txqueues) { 3071 3226 LOG(("yahoo_write_ready(%d, %p) !txqueues", id, fd)); 3072 YAHOO_CALLBACK (ext_yahoo_remove_handler) (id,3073 3227 YAHOO_CALLBACK (ext_yahoo_remove_handler) (id, 3228 yid->write_tag); 3074 3229 yid->write_tag = 0; 3075 3230 } … … 3080 3235 3081 3236 static void yahoo_process_pager_connection(struct yahoo_input_data *yid, 3082 3237 int over) 3083 3238 { 3084 3239 struct yahoo_packet *pkt; … … 3086 3241 int id = yd->client_id; 3087 3242 3088 if (over) 3089 return; 3243 if (over) { 3244 return; 3245 } 3090 3246 3091 3247 while (find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER) 3092 3248 && (pkt = yahoo_getdata(yid)) != NULL) { 3093 3249 3094 3250 yahoo_packet_process(yid, pkt); … … 3099 3255 3100 3256 static void yahoo_process_chatcat_connection(struct yahoo_input_data *yid, 3101 int over) 3102 { 3103 if (over) 3104 return; 3105 3106 if (strstr((char *)yid->rxqueue + (yid->rxlen - 20), "</content>")) { 3107 YAHOO_CALLBACK(ext_yahoo_chat_cat_xml) (yid->yd->client_id, 3108 (char *)yid->rxqueue); 3257 int over) 3258 { 3259 if (over) { 3260 return; 3261 } 3262 3263 if (strstr((char *) yid->rxqueue + (yid->rxlen - 20), "</content>")) { 3264 YAHOO_CALLBACK (ext_yahoo_chat_cat_xml) (yid->yd->client_id, 3265 (char *) yid->rxqueue); 3109 3266 } 3110 3267 } … … 3122 3279 LOG(("Got data for YAB")); 3123 3280 3124 if (over) 3125 return; 3281 if (over) { 3282 return; 3283 } 3126 3284 3127 3285 while (find_input_by_id_and_type(id, YAHOO_CONNECTION_YAB) 3128 3129 if (!yab->id) 3286 && (yab = yahoo_getyab(yid)) != NULL) { 3287 if (!yab->id) { 3130 3288 continue; 3289 } 3131 3290 3132 3291 changed = 1; … … 3141 3300 } else if (yab->fname && yab->lname) { 3142 3301 bud->real_name = y_new0(char, 3143 3144 3302 strlen(yab->fname) + 3303 strlen(yab->lname) + 2); 3145 3304 sprintf(bud->real_name, "%s %s", 3146 3305 yab->fname, yab->lname); 3147 3306 } else if (yab->fname) { 3148 3307 bud->real_name = strdup(yab->fname); 3149 3308 } 3150 break; 3309 break; /* for */ 3151 3310 } 3152 3311 } … … 3166 3325 } 3167 3326 3168 if (changed) 3169 YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, 3170 yd->buddies); 3327 if (changed) { 3328 YAHOO_CALLBACK (ext_yahoo_got_buddies) (yd->client_id, 3329 yd->buddies); 3330 } 3171 3331 } 3172 3332 #endif 3173 3333 3174 3334 static void yahoo_process_search_connection(struct yahoo_input_data *yid, 3175 3335 int over) 3176 3336 { 3177 3337 struct yahoo_found_contact *yct = NULL; 3178 char *p = (char *) yid->rxqueue, *np, *cp;3338 char *p = (char *) yid->rxqueue, *np, *cp; 3179 3339 int k, n; 3180 3340 int start = 0, found = 0, total = 0; 3181 3341 YList *contacts = NULL; 3182 3342 struct yahoo_input_data *pyid = 3183 find_input_by_id_and_type(yid->yd->client_id, 3184 YAHOO_CONNECTION_PAGER); 3185 3186 if (!over || !pyid) 3187 return; 3343 find_input_by_id_and_type(yid->yd->client_id, 3344 YAHOO_CONNECTION_PAGER); 3345 3346 if (!over || !pyid) { 3347 return; 3348 } 3188 3349 3189 3350 if (p && (p = strstr(p, "\r\n\r\n"))) { … … 3206 3367 } 3207 3368 3208 if (p) 3369 if (p) { 3209 3370 p++; 3371 } 3210 3372 3211 3373 k = 0; … … 3214 3376 np = strchr(p, 4); 3215 3377 3216 if (!np) 3378 if (!np) { 3217 3379 break; 3380 } 3218 3381 *np = 0; 3219 3382 p = np + 1; … … 3222 3385 case 1: 3223 3386 if (strlen(cp) > 2 3224 3387 && y_list_length(contacts) < total) { 3225 3388 yct = y_new0(struct yahoo_found_contact, 3226 3389 1); 3227 3390 contacts = y_list_append(contacts, yct); 3228 3391 yct->id = cp + 2; … … 3242 3405 case 5: 3243 3406 /* not worth the context switch for strcmp */ 3244 if (cp[0] != '\005' || cp[1] != '\000') 3407 if (cp[0] != '\005' || cp[1] != '\000') { 3245 3408 yct->location = cp; 3409 } 3246 3410 k = 0; 3247 3411 break; … … 3250 3414 } 3251 3415 3252 YAHOO_CALLBACK (ext_yahoo_got_search_result) (yid->yd->client_id, found,3253 3416 YAHOO_CALLBACK (ext_yahoo_got_search_result) (yid->yd->client_id, found, 3417 start, total, contacts); 3254 3418 3255 3419 while (contacts) { … … 3357 3521 3358 3522 yid->read_tag = 3359 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id,3360 3523 YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id, 3524 yid->fd, YAHOO_INPUT_READ, yid); 3361 3525 } 3362 3526 … … 3366 3530 struct yahoo_input_data *yid; 3367 3531 3368 if (!wcm || !wcm->server || !wcm->key) 3369 return; 3532 if (!wcm || !wcm->server || !wcm->key) { 3533 return; 3534 } 3370 3535 3371 3536 yid = y_new0(struct yahoo_input_data, 1); … … 3380 3545 3381 3546 LOG(("Connecting to: %s:%d", wcm->server, wcm->port)); 3382 YAHOO_CALLBACK (ext_yahoo_connect_async) (y->yd->client_id, wcm->server,3383 3547 YAHOO_CALLBACK (ext_yahoo_connect_async) (y->yd->client_id, wcm->server, 3548 wcm->port, _yahoo_webcam_connected, yid, 0); 3384 3549 3385 3550 } 3386 3551 3387 3552 static void yahoo_process_webcam_master_connection(struct yahoo_input_data *yid, 3388 3553 int over) 3389 3554 { 3390 3555 char *server; 3391 3556 struct yahoo_server_settings *yss; 3392 3557 3393 if (over) 3394 return; 3558 if (over) { 3559 return; 3560 } 3395 3561 3396 3562 server = yahoo_getwebcam_master(yid); … … 3402 3568 yid->wcm->conn_type = yss->conn_type; 3403 3569 yid->wcm->my_ip = strdup(yss->local_host); 3404 if (yid->wcm->direction == YAHOO_WEBCAM_UPLOAD) 3570 if (yid->wcm->direction == YAHOO_WEBCAM_UPLOAD) { 3405 3571 yid->wcm->description = strdup(yss->webcam_description); 3572 } 3406 3573 yahoo_webcam_connect(yid); 3407 3574 FREE(server); … … 3410 3577 3411 3578 static void yahoo_process_webcam_connection(struct yahoo_input_data *yid, 3412 3579 int over) 3413 3580 { 3414 3581 int id = yid->yd->client_id; 3415 3582 void *fd = yid->fd; 3416 3583 3417 if (over) 3418 return; 3584 if (over) { 3585 return; 3586 } 3419 3587 3420 3588 /* as long as we still have packets available keep processing them */ 3421 3589 while (find_input_by_id_and_fd(id, fd) 3422 && yahoo_get_webcam_data(yid) == 1) ; 3423 } 3424 3425 static void (*yahoo_process_connection[]) (struct yahoo_input_data *, 3426 int over) = { 3427 yahoo_process_pager_connection, yahoo_process_ft_connection, 3428 NULL, /*yahoo_process_yab_connection, */ 3429 yahoo_process_webcam_master_connection, 3430 yahoo_process_webcam_connection, 3431 yahoo_process_chatcat_connection, 3432 yahoo_process_search_connection}; 3590 && yahoo_get_webcam_data(yid) == 1) { 3591 ; 3592 } 3593 } 3594 3595 static void(*yahoo_process_connection[]) (struct yahoo_input_data *, 3596 int over) = { 3597 yahoo_process_pager_connection, yahoo_process_ft_connection, 3598 NULL, /*yahoo_process_yab_connection, */ 3599 yahoo_process_webcam_master_connection, 3600 yahoo_process_webcam_connection, 3601 yahoo_process_chatcat_connection, 3602 yahoo_process_search_connection 3603 }; 3433 3604 3434 3605 int yahoo_read_ready(int id, void *fd, void *data) … … 3439 3610 3440 3611 LOG(("read callback: id=%d fd=%p data=%p", id, fd, data)); 3441 if (!yid) 3612 if (!yid) { 3442 3613 return -2; 3614 } 3443 3615 3444 3616 do { 3445 len = YAHOO_CALLBACK (ext_yahoo_read) (fd, buf, sizeof(buf));3617 len = YAHOO_CALLBACK (ext_yahoo_read) (fd, buf, sizeof(buf)); 3446 3618 } while (len == -1 && errno == EINTR); 3447 3619 3448 if (len == -1 && (errno == EAGAIN || errno == EINTR)) 3620 if (len == -1 && (errno == EAGAIN || errno == EINTR)) { /* we'll try again later */ 3449 3621 return 1; 3622 } 3450 3623 3451 3624 if (len <= 0) { … … 3454 3627 3455 3628 if (yid->type == YAHOO_CONNECTION_PAGER) { 3456 YAHOO_CALLBACK (ext_yahoo_login_response) (yid->yd->3457 3629 YAHOO_CALLBACK (ext_yahoo_login_response) (yid->yd-> 3630 client_id, YAHOO_LOGIN_SOCK, NULL); 3458 3631 } 3459 3632 … … 3462 3635 3463 3636 /* no need to return an error, because we've already fixed it */ 3464 if (len == 0) 3637 if (len == 0) { 3465 3638 return 1; 3639 } 3466 3640 3467 3641 errno = e; … … 3471 3645 3472 3646 yid->rxqueue = 3473 3647 y_renew(unsigned char, yid->rxqueue, len + yid->rxlen + 1); 3474 3648 memcpy(yid->rxqueue + yid->rxlen, buf, len); 3475 3649 yid->rxlen += len; … … 3488 3662 yd = y_new0(struct yahoo_data, 1); 3489 3663 3490 if (!yd) 3664 if (!yd) { 3491 3665 return 0; 3666 } 3492 3667 3493 3668 yd->user = strdup(username); … … 3526 3701 char *host = yss->pager_host; 3527 3702 3528 if (!host) 3703 if (!host) { 3529 3704 host = yss->pager_host_list[ccd->server_i]; 3705 } 3530 3706 3531 3707 yss->pager_port = fallback_ports[ccd->i++]; 3532 tag = YAHOO_CALLBACK (ext_yahoo_connect_async) (yd->3533 3534 3535 3536 if (tag > 0) 3708 tag = YAHOO_CALLBACK (ext_yahoo_connect_async) (yd-> 3709 client_id, host, yss->pager_port, 3710 yahoo_connected, ccd, 0); 3711 3712 if (tag > 0) { 3537 3713 ccd->tag = tag; 3714 } 3538 3715 } else if (yss->pager_host_list 3539 3716 && yss->pager_host_list[ccd->server_i]) { 3540 3717 3541 3718 /* Get back to the default port */ … … 3545 3722 3546 3723 ccd->i = 0; 3547 tag = YAHOO_CALLBACK(ext_yahoo_connect_async) (yd->client_id, 3548 yss->pager_host_list[ccd->server_i], yss->pager_port, 3549 yahoo_connected, ccd, 0); 3724 tag = YAHOO_CALLBACK (ext_yahoo_connect_async) (yd->client_id, 3725 yss->pager_host_list[ccd->server_i], 3726 yss->pager_port, 3727 yahoo_connected, ccd, 0); 3550 3728 } else { 3551 3729 FREE(ccd); 3552 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id,3553 3730 YAHOO_CALLBACK (ext_yahoo_login_response) (yd->client_id, 3731 YAHOO_LOGIN_SOCK, NULL); 3554 3732 } 3555 3733 return; … … 3559 3737 3560 3738 /* fd == NULL && error == 0 means connect was cancelled */ 3561 if (!fd) 3562 return; 3739 if (!fd) { 3740 return; 3741 } 3563 3742 3564 3743 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YPACKET_STATUS_DEFAULT, 3565 3744 yd->session_id); 3566 3745 NOTICE(("Sending initial packet")); 3567 3746 … … 3576 3755 3577 3756 yid->read_tag = 3578 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id,3579 3757 YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id, 3758 yid->fd, YAHOO_INPUT_READ, yid); 3580 3759 } 3581 3760 … … 3583 3762 { 3584 3763 struct yahoo_input_data *yid = 3585 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3586 if (!yid) 3764 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3765 3766 if (!yid) { 3587 3767 return 0; 3588 else3768 } else { 3589 3769 return yid->fd; 3770 } 3590 3771 } 3591 3772 … … 3598 3779 3599 3780 void yahoo_send_im(int id, const char *from, const char *who, const char *what, 3600 3781 int utf8, int picture) 3601 3782 { 3602 3783 struct yahoo_input_data *yid = 3603 3784 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3604 3785 struct yahoo_packet *pkt = NULL; 3605 3786 struct yahoo_data *yd; 3606 3787 char pic_str[10]; 3607 3788 3608 if (!yid) 3609 return; 3789 if (!yid) { 3790 return; 3791 } 3610 3792 3611 3793 yd = yid->yd; 3612 3794 3613 3795 pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, (enum ypacket_status) YAHOO_STATUS_OFFLINE, 3614 3796 yd->session_id); 3615 3797 3616 3798 snprintf(pic_str, sizeof(pic_str), "%d", picture); 3617 3799 3618 if (from && strcmp(from, yd->user)) 3800 if (from && strcmp(from, yd->user)) { 3619 3801 yahoo_packet_hash(pkt, 0, yd->user); 3802 } 3620 3803 yahoo_packet_hash(pkt, 1, from ? from : yd->user); 3621 3804 yahoo_packet_hash(pkt, 5, who); 3622 3805 yahoo_packet_hash(pkt, 14, what); 3623 3806 3624 if (utf8) 3807 if (utf8) { 3625 3808 yahoo_packet_hash(pkt, 97, "1"); 3626 3627 yahoo_packet_hash(pkt, 63, ";0"); /* imvironment name; or ;0 */ 3809 } 3810 3811 yahoo_packet_hash(pkt, 63, ";0"); /* imvironment name; or ;0 */ 3628 3812 yahoo_packet_hash(pkt, 64, "0"); 3629 3813 yahoo_packet_hash(pkt, 206, pic_str); … … 3637 3821 { 3638 3822 struct yahoo_input_data *yid = 3639 3823 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3640 3824 struct yahoo_data *yd; 3641 3825 struct yahoo_packet *pkt = NULL; 3642 if (!yid) 3643 return; 3826 3827 if (!yid) { 3828 return; 3829 } 3644 3830 3645 3831 yd = yid->yd; 3646 3832 pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YPACKET_STATUS_NOTIFY, 3647 3833 yd->session_id); 3648 3834 3649 3835 yahoo_packet_hash(pkt, 5, who); … … 3661 3847 { 3662 3848 struct yahoo_input_data *yid = 3663 3849 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3664 3850 struct yahoo_data *yd; 3665 3851 struct yahoo_packet *pkt = NULL; … … 3667 3853 char s[4]; 3668 3854 3669 if (!yid) 3670 return; 3855 if (!yid) { 3856 return; 3857 } 3671 3858 3672 3859 yd = yid->yd; … … 3678 3865 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { 3679 3866 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, 3680 3867 (enum ypacket_status) YAHOO_STATUS_AVAILABLE, 0); 3681 3868 yahoo_packet_hash(pkt, 13, "2"); 3682 3869 yahoo_send_packet(yid, pkt, 0); … … 3687 3874 3688 3875 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, 3689 3876 yd->current_status, yd->session_id); 3690 3877 snprintf(s, sizeof(s), "%d", yd->current_status); 3691 3878 yahoo_packet_hash(pkt, 10, s); 3692 3879 yahoo_packet_hash(pkt, 19, msg && state == YAHOO_STATUS_CUSTOM ? msg : ""); 3693 yahoo_packet_hash(pkt, 47, (away == 2) ? "2": (away) ?"1":"0");3880 yahoo_packet_hash(pkt, 47, (away == 2) ? "2" : (away) ? "1" : "0"); 3694 3881 yahoo_send_packet(yid, pkt, 0); 3695 3882 yahoo_packet_free(pkt); … … 3697 3884 if (old_status == YAHOO_STATUS_INVISIBLE) { 3698 3885 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, 3699 3886 (enum ypacket_status) YAHOO_STATUS_AVAILABLE, 0); 3700 3887 yahoo_packet_hash(pkt, 13, "1"); 3701 3888 yahoo_send_packet(yid, pkt, 0); … … 3707 3894 { 3708 3895 struct yahoo_input_data *yid = 3709 3896 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3710 3897 struct yahoo_data *yd; 3711 3898 struct yahoo_packet *pkt = NULL; 3712 3899 3713 if (!yid) 3714 return; 3900 if (!yid) { 3901 return; 3902 } 3715 3903 yd = yid->yd; 3716 3904 … … 3722 3910 connection reset will hopefully be clear enough. */ 3723 3911 pkt = yahoo_packet_new(YAHOO_SERVICE_LOGOFF, 3724 3912 YPACKET_STATUS_DEFAULT, yd->session_id); 3725 3913 yd->current_status = -1; 3726 3914 … … 3732 3920 3733 3921 /* do { 3734 3735 3922 yahoo_input_close(yid); 3923 } while((yid = find_input_by_id(id)));*/ 3736 3924 3737 3925 } … … 3741 3929 { 3742 3930 struct yahoo_input_data *yid = 3743 3931 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3744 3932 struct yahoo_data *yd; 3745 3933 struct yahoo_packet *pkt = NULL; 3746 3934 3747 if (!yid) 3748 return; 3935 if (!yid) { 3936 return; 3937 } 3749 3938 yd = yid->yd; 3750 3939 3751 3940 pkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YPACKET_STATUS_DEFAULT, 3752 3941 yd->session_id); 3753 3942 yahoo_packet_hash(pkt, 1, yd->user); 3754 3943 if (pkt) { … … 3762 3951 { 3763 3952 struct yahoo_input_data *yid = data; 3953 3764 3954 if (fd == NULL || error) { 3765 3955 inputs = y_list_remove(inputs, yid); … … 3770 3960 yid->fd = fd; 3771 3961 yid->read_tag = 3772 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,3773 3962 YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id, fd, 3963 YAHOO_INPUT_READ, yid); 3774 3964 } 3775 3965 … … 3783 3973 char buff[2048]; 3784 3974 3785 if (!yd) 3786 return; 3975 if (!yd) { 3976 return; 3977 } 3787 3978 3788 3979 yid = y_new0(struct yahoo_input_data, 1); … … 3793 3984 3794 3985 snprintf(url, 1024, 3795 3796 3986 "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us" 3987 "&diffs=1&t=0&tags=short&rt=0&prog-ver=8.1.0.249&useutf8=1&legenc=codepage-1252"); 3797 3988 3798 3989 snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t); … … 3801 3992 3802 3993 yahoo_http_get(yid->yd->client_id, url, buff, 0, 0, 3803 3994 _yahoo_http_connected, yid); 3804 3995 } 3805 3996 … … 3821 4012 } 3822 4013 3823 YAHOO_CALLBACK (ext_yahoo_write) (fd, buff, strlen(buff));4014 YAHOO_CALLBACK (ext_yahoo_write) (fd, buff, strlen(buff)); 3824 4015 3825 4016 yid->fd = fd; 3826 4017 yid->read_tag = 3827 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,3828 4018 YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id, fd, 4019 YAHOO_INPUT_READ, yid); 3829 4020 3830 4021 FREE(buff); … … 3843 4034 int size = 0; 3844 4035 3845 if (!yd) 3846 return; 4036 if (!yd) { 4037 return; 4038 } 3847 4039 3848 4040 yid = y_new0(struct yahoo_input_data, 1); … … 3850 4042 yid->yd = yd; 3851 4043 3852 if (yab->yid)4044 if (yab->yid) { 3853 4045 size = snprintf(post, sizeof(post), "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 3854 3855 3856 "</ab>", yd->user, 9, yab->yid,/* Don't know why */3857 yab->id, yab->nname?yab->nname:"");3858 else4046 "<ab k=\"%s\" cc=\"%d\">" 4047 "<ct id=\"%d\" e=\"1\" yi=\"%s\" nn=\"%s\" />" 4048 "</ab>", yd->user, 9, yab->yid, /* Don't know why */ 4049 yab->id, yab->nname ? yab->nname : ""); 4050 } else { 3859 4051 size = snprintf(post, sizeof(post), "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 3860 "<ab k=\"%s\" cc=\"%d\">" 3861 "<ct a=\"1\" yi=\"%s\" nn=\"%s\" />" 3862 "</ab>", yd->user, 1, /* Don't know why */ 3863 yab->id, yab->nname?yab->nname:""); 4052 "<ab k=\"%s\" cc=\"%d\">" 4053 "<ct a=\"1\" yi=\"%s\" nn=\"%s\" />" 4054 "</ab>", yd->user, 1, /* Don't know why */ 4055 yab->id, yab->nname ? yab->nname : ""); 4056 } 3864 4057 3865 4058 yad->yid = yid; … … 3867 4060 3868 4061 strcpy(url, "http://address.yahoo.com/yab/us?v=XM&prog=ymsgr&.intl=us" 3869 4062 "&sync=1&tags=short&noclear=1&useutf8=1&legenc=codepage-1252"); 3870 4063 3871 4064 snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t); … … 3874 4067 3875 4068 yahoo_http_post(yid->yd->client_id, url, buff, size, 3876 4069 _yahoo_http_post_connected, yad); 3877 4070 } 3878 4071 … … 3880 4073 { 3881 4074 struct yahoo_input_data *yid = 3882 4075 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3883 4076 struct yahoo_data *yd; 3884 4077 struct yahoo_packet *pkt = NULL; 3885 4078 3886 if (!yid) 3887 return; 4079 if (!yid) { 4080 return; 4081 } 3888 4082 yd = yid->yd; 3889 4083 3890 4084 pkt = yahoo_packet_new(active ? YAHOO_SERVICE_IDACT : 3891 4085 YAHOO_SERVICE_IDDEACT, YPACKET_STATUS_DEFAULT, yd->session_id); 3892 4086 yahoo_packet_hash(pkt, 3, identity); 3893 4087 if (pkt) { … … 3900 4094 { 3901 4095 struct yahoo_input_data *yid = 3902 4096 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3903 4097 struct yahoo_data *yd; 3904 4098 struct yahoo_packet *pkt = NULL; 3905 4099 3906 if (!yid) 3907 return; 4100 if (!yid) { 4101 return; 4102 } 3908 4103 yd = yid->yd; 3909 4104 3910 4105 pkt = yahoo_packet_new(YAHOO_SERVICE_USERSTAT, YPACKET_STATUS_DEFAULT, 3911 4106 yd->session_id); 3912 4107 if (pkt) { 3913 4108 yahoo_send_packet(yid, pkt, 0); … … 3920 4115 { 3921 4116 struct yahoo_input_data *yid = 3922 4117 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3923 4118 struct yahoo_data *yd; 3924 4119 struct yahoo_packet *pkt = NULL; 3925 if (!yid) 3926 return; 4120 4121 if (!yid) { 4122 return; 4123 } 3927 4124 yd = yid->yd; 3928 4125 3929 4126 pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YPACKET_STATUS_DEFAULT, 3930 4127 yd->session_id); 3931 4128 yahoo_send_packet(yid, pkt, 0); 3932 4129 yahoo_packet_free(pkt); … … 3937 4134 { 3938 4135 struct yahoo_input_data *yid = 3939 4136 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3940 4137 struct yahoo_data *yd; 3941 4138 struct yahoo_packet *pkt = NULL; 3942 4139 3943 if (!yid) 3944 return; 4140 if (!yid) { 4141 return; 4142 } 3945 4143 3946 4144 yd = yid->yd; 3947 4145 3948 4146 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YPACKET_STATUS_DEFAULT, 3949 4147 yd->session_id); 3950 4148 yahoo_send_packet(yid, pkt, 0); 3951 4149 yahoo_packet_free(pkt); … … 3954 4152 3955 4153 void yahoo_add_buddy(int id, const char *who, const char *group, 3956 4154 const char *msg) 3957 4155 { 3958 4156 struct yahoo_input_data *yid = 3959 4157 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3960 4158 struct yahoo_data *yd; 3961 4159 struct yahoo_packet *pkt; 3962 4160 3963 if (!yid) 3964 return; 4161 if (!yid) { 4162 return; 4163 } 3965 4164 yd = yid->yd; 3966 4165 3967 if (!yd->logged_in) 3968 return; 4166 if (!yd->logged_in) { 4167 return; 4168 } 3969 4169 3970 4170 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YPACKET_STATUS_DEFAULT, 3971 3972 if (msg != NULL) 4171 yd->session_id); 4172 if (msg != NULL) { /* add message/request "it's me add me" */ 3973 4173 yahoo_packet_hash(pkt, 14, msg); 3974 else4174 } else { 3975 4175 yahoo_packet_hash(pkt, 14, ""); 4176 } 3976 4177 yahoo_packet_hash(pkt, 65, group); 3977 4178 yahoo_packet_hash(pkt, 97, "1"); … … 3990 4191 { 3991 4192 struct yahoo_input_data *yid = 3992 4193 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3993 4194 struct yahoo_data *yd; 3994 4195 struct yahoo_packet *pkt = NULL; 3995 4196 3996 if (!yid) 3997 return; 4197 if (!yid) { 4198 return; 4199 } 3998 4200 yd = yid->yd; 3999 4201 4000 4202 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YPACKET_STATUS_DEFAULT, 4001 4203 yd->session_id); 4002 4204 4003 4205 yahoo_packet_hash(pkt, 1, yd->user); … … 4011 4213 { 4012 4214 struct yahoo_input_data *yid = 4013 4215 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4014 4216 struct yahoo_data *yd; 4015 4217 struct yahoo_packet *pkt; 4016 4218 4017 if (!yid) 4018 return; 4219 if (!yid) { 4220 return; 4221 } 4019 4222 yd = yid->yd; 4020 4223 4021 if (!yd->logged_in) 4022 return; 4224 if (!yd->logged_in) { 4225 return; 4226 } 4023 4227 4024 4228 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_AUTHORIZATION, 4025 4229 YPACKET_STATUS_DEFAULT, yd->session_id); 4026 4230 yahoo_packet_hash(pkt, 1, yd->user); 4027 4231 yahoo_packet_hash(pkt, 5, who); 4028 if (reject) 4232 if (reject) { 4029 4233 yahoo_packet_hash(pkt, 13, "2"); 4030 else {4234 } else { 4031 4235 yahoo_packet_hash(pkt, 241, "0"); 4032 4236 yahoo_packet_hash(pkt, 13, "1"); … … 4048 4252 { 4049 4253 struct yahoo_input_data *yid = 4050 4254 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4051 4255 struct yahoo_data *yd; 4052 4256 struct yahoo_packet *pkt; 4053 4257 4054 if (!yid) 4055 return; 4258 if (!yid) { 4259 return; 4260 } 4056 4261 yd = yid->yd; 4057 4262 4058 if (!yd->logged_in) 4059 return; 4263 if (!yd->logged_in) { 4264 return; 4265 } 4060 4266 4061 4267 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, 4062 4268 YPACKET_STATUS_DEFAULT, yd->session_id); 4063 4269 yahoo_packet_hash(pkt, 1, yd->user); 4064 4270 yahoo_packet_hash(pkt, 7, who); … … 4071 4277 { 4072 4278 struct yahoo_input_data *yid = 4073 4279 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4074 4280 struct yahoo_data *yd; 4075 4281 struct yahoo_packet *pkt; 4076 4282 4077 if (!yid) 4078 return; 4283 if (!yid) { 4284 return; 4285 } 4079 4286 yd = yid->yd; 4080 4287 4081 if (!yd->logged_in) 4082 return; 4288 if (!yd->logged_in) { 4289 return; 4290 } 4083 4291 4084 4292 pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH_PERM, 4085 4293 YPACKET_STATUS_DEFAULT, yd->session_id); 4086 4294 yahoo_packet_hash(pkt, 1, yd->user); 4087 4295 yahoo_packet_hash(pkt, 7, who); … … 4094 4302 4095 4303 void yahoo_change_buddy_group(int id, const char *who, const char *old_group, 4096 4304 const char *new_group) 4097 4305 { 4098 4306 struct yahoo_input_data *yid = 4099 4307 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4100 4308 struct yahoo_data *yd; 4101 4309 struct yahoo_packet *pkt = NULL; 4102 4310 4103 if (!yid) 4104 return; 4311 if (!yid) { 4312 return; 4313 } 4105 4314 yd = yid->yd; 4106 4315 4107 4316 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_CHANGE_GROUP, 4108 4317 YPACKET_STATUS_DEFAULT, yd->session_id); 4109 4318 yahoo_packet_hash(pkt, 1, yd->user); 4110 4319 yahoo_packet_hash(pkt, 302, "240"); … … 4124 4333 { 4125 4334 struct yahoo_input_data *yid = 4126 4335 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4127 4336 struct yahoo_data *yd; 4128 4337 struct yahoo_packet *pkt = NULL; 4129 4338 4130 if (!yid) 4131 return; 4339 if (!yid) { 4340 return; 4341 } 4132 4342 yd = yid->yd; 4133 4343 4134 4344 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, 4135 4345 YPACKET_STATUS_DEFAULT, yd->session_id); 4136 4346 yahoo_packet_hash(pkt, 1, yd->user); 4137 4347 yahoo_packet_hash(pkt, 65, old_group); … … 4143 4353 4144 4354 void yahoo_conference_addinvite(int id, const char *from, const char *who, 4145 4355 const char *room, const YList *members, const char *msg) 4146 4356 { 4147 4357 struct yahoo_input_data *yid = 4148 4358 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4149 4359 struct yahoo_data *yd; 4150 4360 struct yahoo_packet *pkt; 4151 4361 4152 if (!yid) 4153 return; 4362 if (!yid) { 4363 return; 4364 } 4154 4365 yd = yid->yd; 4155 4366 4156 4367 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE, 4157 4368 YPACKET_STATUS_DEFAULT, yd->session_id); 4158 4369 4159 4370 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); … … 4163 4374 yahoo_packet_hash(pkt, 13, "0"); 4164 4375 for (; members; members = members->next) { 4165 yahoo_packet_hash(pkt, 52, (char *) members->data);4166 yahoo_packet_hash(pkt, 53, (char *) members->data);4376 yahoo_packet_hash(pkt, 52, (char *) members->data); 4377 yahoo_packet_hash(pkt, 53, (char *) members->data); 4167 4378 } 4168 4379 /* 52, 53 -> other members? */ … … 4175 4386 4176 4387 void yahoo_conference_invite(int id, const char *from, YList *who, 4177 4388 const char *room, const char *msg) 4178 4389 { 4179 4390 struct yahoo_input_data *yid = 4180 4391 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4181 4392 struct yahoo_data *yd; 4182 4393 struct yahoo_packet *pkt; 4183 4394 4184 if (!yid) 4185 return; 4395 if (!yid) { 4396 return; 4397 } 4186 4398 yd = yid->yd; 4187 4399 4188 4400 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFINVITE, YPACKET_STATUS_DEFAULT, 4189 4401 yd->session_id); 4190 4402 4191 4403 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4192 4404 yahoo_packet_hash(pkt, 50, yd->user); 4193 4405 for (; who; who = who->next) { 4194 yahoo_packet_hash(pkt, 52, (char *) who->data);4406 yahoo_packet_hash(pkt, 52, (char *) who->data); 4195 4407 } 4196 4408 yahoo_packet_hash(pkt, 57, room); … … 4204 4416 4205 4417 void yahoo_conference_logon(int id, const char *from, YList *who, 4206 4418 const char *room) 4207 4419 { 4208 4420 struct yahoo_input_data *yid = 4209 4421 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4210 4422 struct yahoo_data *yd; 4211 4423 struct yahoo_packet *pkt; 4212 4424 4213 if (!yid) 4214 return; 4425 if (!yid) { 4426 return; 4427 } 4215 4428 yd = yid->yd; 4216 4429 4217 4430 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGON, YPACKET_STATUS_DEFAULT, 4218 4431 yd->session_id); 4219 4432 4220 4433 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4221 4434 yahoo_packet_hash(pkt, 3, (from ? from : yd->user)); 4222 4435 yahoo_packet_hash(pkt, 57, room); 4223 for (; who; who = who->next) 4224 yahoo_packet_hash(pkt, 3, (char *)who->data); 4436 for (; who; who = who->next) { 4437 yahoo_packet_hash(pkt, 3, (char *) who->data); 4438 } 4225 4439 4226 4440 yahoo_send_packet(yid, pkt, 0); … … 4230 4444 4231 4445 void yahoo_conference_decline(int id, const char *from, YList *who, 4232 4446 const char *room, const char *msg) 4233 4447 { 4234 4448 struct yahoo_input_data *yid = 4235 4449 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4236 4450 struct yahoo_data *yd; 4237 4451 struct yahoo_packet *pkt; 4238 4452 4239 if (!yid) 4240 return; 4453 if (!yid) { 4454 return; 4455 } 4241 4456 yd = yid->yd; 4242 4457 4243 4458 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFDECLINE, 4244 4459 YPACKET_STATUS_DEFAULT, yd->session_id); 4245 4460 4246 4461 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4247 4462 yahoo_packet_hash(pkt, 3, (from ? from : yd->user)); 4248 for (; who; who = who->next) 4249 yahoo_packet_hash(pkt, 3, (char *)who->data); 4463 for (; who; who = who->next) { 4464 yahoo_packet_hash(pkt, 3, (char *) who->data); 4465 } 4250 4466 yahoo_packet_hash(pkt, 57, room); 4251 4467 yahoo_packet_hash(pkt, 14, msg); … … 4257 4473 4258 4474 void yahoo_conference_logoff(int id, const char *from, YList *who, 4259 4475 const char *room) 4260 4476 { 4261 4477 struct yahoo_input_data *yid = 4262 4478 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4263 4479 struct yahoo_data *yd; 4264 4480 struct yahoo_packet *pkt; 4265 4481 4266 if (!yid) 4267 return; 4482 if (!yid) { 4483 return; 4484 } 4268 4485 yd = yid->yd; 4269 4486 4270 4487 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YPACKET_STATUS_DEFAULT, 4271 4488 yd->session_id); 4272 4489 4273 4490 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4274 4491 yahoo_packet_hash(pkt, 3, (from ? from : yd->user)); 4275 for (; who; who = who->next) 4276 yahoo_packet_hash(pkt, 3, (char *)who->data); 4492 for (; who; who = who->next) { 4493 yahoo_packet_hash(pkt, 3, (char *) who->data); 4494 } 4277 4495 4278 4496 yahoo_packet_hash(pkt, 57, room); … … 4284 4502 4285 4503 void yahoo_conference_message(int id, const char *from, YList *who, 4286 4504 const char *room, const char *msg, int utf8) 4287 4505 { 4288 4506 struct yahoo_input_data *yid = 4289 4507 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4290 4508 struct yahoo_data *yd; 4291 4509 struct yahoo_packet *pkt; 4292 4510 4293 if (!yid) 4294 return; 4511 if (!yid) { 4512 return; 4513 } 4295 4514 yd = yid->yd; 4296 4515 4297 4516 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YPACKET_STATUS_DEFAULT, 4298 4517 yd->session_id); 4299 4518 4300 4519 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4301 4520 yahoo_packet_hash(pkt, 53, (from ? from : yd->user)); 4302 for (; who; who = who->next) 4303 yahoo_packet_hash(pkt, 53, (char *)who->data); 4521 for (; who; who = who->next) { 4522 yahoo_packet_hash(pkt, 53, (char *) who->data); 4523 } 4304 4524 4305 4525 yahoo_packet_hash(pkt, 57, room); 4306 4526 yahoo_packet_hash(pkt, 14, msg); 4307 4527 4308 if (utf8) 4528 if (utf8) { 4309 4529 yahoo_packet_hash(pkt, 97, "1"); 4530 } 4310 4531 4311 4532 yahoo_send_packet(yid, pkt, 0); … … 4322 4543 char buff[1024]; 4323 4544 4324 if (!yd) 4325 return; 4545 if (!yd) { 4546 return; 4547 } 4326 4548 4327 4549 yid = y_new0(struct yahoo_input_data, 1); … … 4331 4553 if (chatroomid == 0) { 4332 4554 snprintf(url, 1024, 4333 4555 "http://insider.msg.yahoo.com/ycontent/?chatcat=0"); 4334 4556 } else { 4335 4557 snprintf(url, 1024, 4336 4337 4558 "http://insider.msg.yahoo.com/ycontent/?chatroom_%d=0", 4559 chatroomid); 4338 4560 } 4339 4561 … … 4343 4565 4344 4566 yahoo_http_get(yid->yd->client_id, url, buff, 0, 0, 4345 4567 _yahoo_http_connected, yid); 4346 4568 } 4347 4569 4348 4570 void yahoo_chat_logon(int id, const char *from, const char *room, 4349 4571 const char *roomid) 4350 4572 { 4351 4573 struct yahoo_input_data *yid = 4352 4574 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4353 4575 struct yahoo_data *yd; 4354 4576 struct yahoo_packet *pkt; 4355 4577 4356 if (!yid) 4357 return; 4578 if (!yid) { 4579 return; 4580 } 4358 4581 4359 4582 yd = yid->yd; 4360 4583 4361 4584 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YPACKET_STATUS_DEFAULT, 4362 4585 yd->session_id); 4363 4586 4364 4587 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); … … 4371 4594 4372 4595 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YPACKET_STATUS_DEFAULT, 4373 4596 yd->session_id); 4374 4597 4375 4598 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); 4376 4599 yahoo_packet_hash(pkt, 104, room); 4377 4600 yahoo_packet_hash(pkt, 129, roomid); 4378 yahoo_packet_hash(pkt, 62, "2"); 4601 yahoo_packet_hash(pkt, 62, "2"); /* ??? */ 4379 4602 4380 4603 yahoo_send_packet(yid, pkt, 0); … … 4384 4607 4385 4608 void yahoo_chat_message(int id, const char *from, const char *room, 4386 4609 const char *msg, const int msgtype, const int utf8) 4387 4610 { 4388 4611 struct yahoo_input_data *yid = 4389 4612 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4390 4613 struct yahoo_data *yd; 4391 4614 struct yahoo_packet *pkt; 4392 4615 char buf[2]; 4393 4616 4394 if (!yid) 4395 return; 4617 if (!yid) { 4618 return; 4619 } 4396 4620 4397 4621 yd = yid->yd; 4398 4622 4399 4623 pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YPACKET_STATUS_DEFAULT, 4400 4624 yd->session_id); 4401 4625 4402 4626 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); … … 4407 4631 yahoo_packet_hash(pkt, 124, buf); 4408 4632 4409 if (utf8) 4633 if (utf8) { 4410 4634 yahoo_packet_hash(pkt, 97, "1"); 4635 } 4411 4636 4412 4637 yahoo_send_packet(yid, pkt, 0); … … 4418 4643 { 4419 4644 struct yahoo_input_data *yid = 4420 4645 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4421 4646 struct yahoo_data *yd; 4422 4647 struct yahoo_packet *pkt; 4423 4648 4424 if (!yid) 4425 return; 4649 if (!yid) { 4650 return; 4651 } 4426 4652 4427 4653 yd = yid->yd; 4428 4654 4429 4655 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT, YPACKET_STATUS_DEFAULT, 4430 4656 yd->session_id); 4431 4657 4432 4658 yahoo_packet_hash(pkt, 1, (from ? from : yd->user)); … … 4440 4666 { 4441 4667 struct yahoo_input_data *yid = 4442 4668 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4443 4669 struct yahoo_data *yd; 4444 4670 struct yahoo_packet *pkt; 4445 4671 4446 if (!yid) 4447 return; 4672 if (!yid) { 4673 return; 4674 } 4448 4675 4449 4676 yd = yid->yd; 4450 4677 4451 4678 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YPACKET_STATUS_DEFAULT, 4452 4679 0); 4453 4680 yahoo_packet_hash(pkt, 4, yd->user); 4454 4681 yahoo_packet_hash(pkt, 5, who); … … 4460 4687 4461 4688 void yahoo_send_picture_info(int id, const char *who, const char *url, 4462 4689 int checksum) 4463 4690 { 4464 4691 struct yahoo_input_data *yid = 4465 4692 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4466 4693 struct yahoo_data *yd; 4467 4694 struct yahoo_packet *pkt; 4468 4695 char checksum_str[10]; 4469 4696 4470 if (!yid) 4471 return; 4697 if (!yid) { 4698 return; 4699 } 4472 4700 4473 4701 yd = yid->yd; … … 4476 4704 4477 4705 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YPACKET_STATUS_DEFAULT, 4478 4706 0); 4479 4707 yahoo_packet_hash(pkt, 1, yd->user); 4480 4708 yahoo_packet_hash(pkt, 4, yd->user); … … 4491 4719 { 4492 4720 struct yahoo_input_data *yid = 4493 4721 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4494 4722 struct yahoo_data *yd; 4495 4723 struct yahoo_packet *pkt; 4496 4724 char type_str[10]; 4497 4725 4498 if (!yid) 4499 return; 4726 if (!yid) { 4727 return; 4728 } 4500 4729 4501 4730 yd = yid->yd; … … 4504 4733 4505 4734 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, 4506 4735 YPACKET_STATUS_DEFAULT, 0); 4507 4736 yahoo_packet_hash(pkt, 1, yd->user); 4508 4737 yahoo_packet_hash(pkt, 5, who); … … 4516 4745 { 4517 4746 struct yahoo_input_data *yid = 4518 4747 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4519 4748 struct yahoo_data *yd; 4520 4749 struct yahoo_packet *pkt; 4521 4750 char checksum_str[10]; 4522 4751 4523 if (!yid) 4524 return; 4752 if (!yid) { 4753 return; 4754 } 4525 4755 4526 4756 yd = yid->yd; … … 4529 4759 4530 4760 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, 4531 4761 YPACKET_STATUS_DEFAULT, 0); 4532 4762 yahoo_packet_hash(pkt, 1, yd->user); 4533 if (who != 0) 4763 if (who != 0) { 4534 4764 yahoo_packet_hash(pkt, 5, who); 4765 } 4535 4766 yahoo_packet_hash(pkt, 192, checksum_str); 4536 4767 yahoo_packet_hash(pkt, 212, "1"); … … 4543 4774 { 4544 4775 struct yahoo_input_data *yid = 4545 4546 4547 if (yid) 4776 find_input_by_id_and_webcam_user(id, who); 4777 4778 if (yid) { 4548 4779 yahoo_input_close(yid); 4780 } 4549 4781 } 4550 4782 … … 4552 4784 { 4553 4785 struct yahoo_input_data *yid = 4554 4786 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4555 4787 struct yahoo_data *yd; 4556 4788 struct yahoo_packet *pkt; 4557 4789 4558 if (!yid) 4559 return; 4560 4561 /* 4790 if (!yid) { 4791 return; 4792 } 4793 4794 /* 4562 4795 * add the user to the queue. this is a dirty hack, since 4563 4796 * the yahoo server doesn't tell us who's key it's returning, 4564 * we have to just hope that it sends back keys in the same 4797 * we have to just hope that it sends back keys in the same 4565 4798 * order that we request them. 4566 4799 * The queue is popped in yahoo_process_webcam_key … … 4571 4804 4572 4805 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBCAM, YPACKET_STATUS_DEFAULT, 4573 4806 yd->session_id); 4574 4807 4575 4808 yahoo_packet_hash(pkt, 1, yd->user); 4576 if (who != NULL) 4809 if (who != NULL) { 4577 4810 yahoo_packet_hash(pkt, 5, who); 4811 } 4578 4812 yahoo_send_packet(yid, pkt, 0); 4579 4813 … … 4582 4816 4583 4817 void yahoo_webcam_send_image(int id, unsigned char *image, unsigned int length, 4584 4818 unsigned int timestamp) 4585 4819 { 4586 4820 struct yahoo_input_data *yid = 4587 4821 find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM); 4588 4822 unsigned char *packet; 4589 4823 unsigned char header_len = 13; 4590 4824 unsigned int pos = 0; 4591 4825 4592 if (!yid) 4593 return; 4826 if (!yid) { 4827 return; 4828 } 4594 4829 4595 4830 packet = y_new0(unsigned char, header_len); … … 4597 4832 packet[pos++] = header_len; 4598 4833 packet[pos++] = 0; 4599 packet[pos++] = 5; 4834 packet[pos++] = 5; /* version byte?? */ 4600 4835 packet[pos++] = 0; 4601 4836 pos += yahoo_put32(packet + pos, length); 4602 packet[pos++] = 2; 4837 packet[pos++] = 2; /* packet type, image */ 4603 4838 pos += yahoo_put32(packet + pos, timestamp); 4604 4839 yahoo_add_to_send_queue(yid, packet, header_len); 4605 4840 FREE(packet); 4606 4841 4607 if (length) 4842 if (length) { 4608 4843 yahoo_add_to_send_queue(yid, image, length); 4844 } 4609 4845 } 4610 4846 … … 4612 4848 { 4613 4849 struct yahoo_input_data *yid = 4614 4850 find_input_by_id_and_type(id, YAHOO_CONNECTION_WEBCAM); 4615 4851 char *packet = NULL; 4616 4852 char *data = NULL; … … 4619 4855 unsigned int len = 0; 4620 4856 4621 if (!yid) 4622 return; 4857 if (!yid) { 4858 return; 4859 } 4623 4860 4624 4861 data = strdup("u="); 4625 data = y_string_append(data, (char *) who);4862 data = y_string_append(data, (char *) who); 4626 4863 data = y_string_append(data, "\r\n"); 4627 4864 len = strlen(data); … … 4630 4867 packet[pos++] = header_len; 4631 4868 packet[pos++] = 0; 4632 packet[pos++] = 5; 4869 packet[pos++] = 5; /* version byte?? */ 4633 4870 packet[pos++] = 0; 4634 4871 pos += yahoo_put32(packet + pos, len); 4635 packet[pos++] = 0; 4872 packet[pos++] = 0; /* packet type */ 4636 4873 pos += yahoo_put32(packet + pos, accept); 4637 4874 memcpy(packet + pos, data, len); … … 4644 4881 { 4645 4882 struct yahoo_input_data *yid = 4646 4883 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4647 4884 struct yahoo_packet *pkt; 4648 4885 4649 if (!yid) 4650 return; 4886 if (!yid) { 4887 return; 4888 } 4651 4889 4652 4890 pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YPACKET_STATUS_NOTIFY, 4653 4891 yid->yd->session_id); 4654 4892 4655 4893 yahoo_packet_hash(pkt, 49, "WEBCAMINVITE"); … … 4664 4902 4665 4903 static void yahoo_search_internal(int id, int t, const char *text, int g, 4666 4904 int ar, int photo, int yahoo_only, int startpos, int total) 4667 4905 { 4668 4906 struct yahoo_data *yd = find_conn_by_id(id); … … 4672 4910 char *ctext, *p; 4673 4911 4674 if (!yd) 4675 return; 4912 if (!yd) { 4913 return; 4914 } 4676 4915 4677 4916 yid = y_new0(struct yahoo_input_data, 1); … … 4685 4924 4686 4925 snprintf(buff, sizeof(buff), "&.sq=%%20&.tt=%d&.ss=%d", total, 4687 4926 startpos); 4688 4927 4689 4928 ctext = strdup(text); 4690 while ((p = strchr(ctext, ' '))) 4929 while ((p = strchr(ctext, ' '))) { 4691 4930 *p = '+'; 4931 } 4692 4932 4693 4933 snprintf(url, 1024, 4694 4695 4696 4934 "http://members.yahoo.com/interests?.oc=m&.kw=%s&.sb=%d&.g=%d&.ar=0%s%s%s", 4935 ctext, t, g, photo ? "&.p=y" : "", yahoo_only ? "&.pg=y" : "", 4936 startpos ? buff : ""); 4697 4937 4698 4938 FREE(ctext); … … 4702 4942 inputs = y_list_prepend(inputs, yid); 4703 4943 yahoo_http_get(yid->yd->client_id, url, buff, 0, 0, 4704 4944 _yahoo_http_connected, yid); 4705 4945 } 4706 4946 4707 4947 void yahoo_search(int id, enum yahoo_search_type t, const char *text, 4708 4709 4948 enum yahoo_search_gender g, enum yahoo_search_agerange ar, int photo, 4949 int yahoo_only) 4710 4950 { 4711 4951 struct yahoo_input_data *yid = 4712 4952 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4713 4953 struct yahoo_search_state *yss; 4714 4954 4715 if (!yid) 4716 return; 4717 4718 if (!yid->ys) 4955 if (!yid) { 4956 return; 4957 } 4958 4959 if (!yid->ys) { 4719 4960 yid->ys = y_new0(struct yahoo_search_state, 1); 4961 } 4720 4962 4721 4963 yss = yid->ys; … … 4735 4977 { 4736 4978 struct yahoo_input_data *yid = 4737 4979 find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4738 4980 struct yahoo_search_state *yss; 4739 4981 4740 if (!yid || !yid->ys) 4741 return; 4982 if (!yid || !yid->ys) { 4983 return; 4984 } 4742 4985 4743 4986 yss = yid->ys; 4744 4987 4745 if (start == -1) 4988 if (start == -1) { 4746 4989 start = yss->lsearch_nstart + yss->lsearch_nfound; 4990 } 4747 4991 4748 4992 yahoo_search_internal(id, yss->lsearch_type, yss->lsearch_text, 4749 4750 4751 4993 yss->lsearch_gender, yss->lsearch_agerange, 4994 yss->lsearch_photo, yss->lsearch_yahoo_only, 4995 start, yss->lsearch_ntotal); 4752 4996 } 4753 4997 4754 4998 void yahoo_send_picture(int id, const char *name, unsigned long size, 4755 4999 yahoo_get_fd_callback callback, void *data) 4756 5000 { 4757 5001 /* Not Implemented */ … … 4796 5040 out[23] = '$'; 4797 5041 out[22] = '$'; 4798 5042 4799 5043 for (i = 0; i < 22; i++) { 4800 if (r == 0)5044 if (r == 0) { 4801 5045 r = rand(); 4802 4803 c = r%61; 4804 4805 if(c<26) 5046 } 5047 5048 c = r % 61; 5049 5050 if (c < 26) { 4806 5051 out[i] = c + 'a'; 4807 else if (c<52)5052 } else if (c < 52) { 4808 5053 out[i] = c - 26 + 'A'; 4809 else5054 } else { 4810 5055 out[i] = c - 52 + '0'; 5056 } 4811 5057 4812 5058 r /= 61; … … 4819 5065 static int _are_same_id(const void *sfd1, const void *id) 4820 5066 { 4821 return strcmp(((struct send_file_data *) sfd1)->id, (char *)id);5067 return strcmp(((struct send_file_data *) sfd1)->id, (char *) id); 4822 5068 } 4823 5069 4824 5070 static int _are_same_yid(const void *sfd1, const void *yid) 4825 5071 { 4826 if (((struct send_file_data *)sfd1)->yid == yid)5072 if (((struct send_file_data *) sfd1)->yid == yid) { 4827 5073 return 0; 4828 else5074 } else { 4829 5075 return 1; 5076 } 4830 5077 } 4831 5078 … … 4833 5080 { 4834 5081 YList *l = y_list_find_custom(active_file_transfers, id, 4835 _are_same_id); 4836 4837 if(l) 4838 return (struct send_file_data *)l->data; 4839 5082 _are_same_id); 5083 5084 if (l) { 5085 return (struct send_file_data *) l->data; 5086 } 5087 4840 5088 return NULL; 4841 5089 } … … 4844 5092 { 4845 5093 YList *l = y_list_find_custom(active_file_transfers, yid, 4846 _are_same_yid); 4847 4848 if(l) 4849 return (struct send_file_data *)l->data; 4850 5094 _are_same_yid); 5095 5096 if (l) { 5097 return (struct send_file_data *) l->data; 5098 } 5099 4851 5100 return NULL; 4852 5101 } … … 4859 5108 static void yahoo_remove_active_transfer(struct send_file_data *sfd) 4860 5109 { 4861 if (sfd == NULL) 4862 return; 4863 5110 if (sfd == NULL) { 5111 return; 5112 } 5113 4864 5114 active_file_transfers = y_list_remove(active_file_transfers, sfd); 4865 5115 free(sfd->id); … … 4885 5135 yid->fd = fd; 4886 5136 yid->read_tag = 4887 YAHOO_CALLBACK(ext_yahoo_add_handler) (yid->yd->client_id, fd,4888 5137 YAHOO_CALLBACK (ext_yahoo_add_handler) (yid->yd->client_id, fd, 5138 YAHOO_INPUT_READ, yid); 4889 5139 } 4890 5140 4891 5141 static void yahoo_file_transfer_upload(struct yahoo_data *yd, 4892 5142 struct send_file_data *sfd) 4893 5143 { 4894 5144 char url[256]; … … 4909 5159 recv_enc = yahoo_urlencode(sfd->who); 4910 5160 4911 snprintf(url, sizeof(url), 4912 4913 5161 snprintf(url, sizeof(url), 5162 "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr, 5163 token_enc, sender_enc, recv_enc); 4914 5164 4915 5165 snprintf(buff, sizeof(buff), "T=%s; Y=%s", yd->cookie_t, yd->cookie_y); 4916 5166 4917 5167 yahoo_http_post(yd->client_id, url, buff, sfd->size, 4918 5168 _yahoo_ft_upload_connected, sfd); 4919 5169 4920 5170 FREE(token_enc); … … 4924 5174 4925 5175 static void yahoo_init_ft_recv(struct yahoo_data *yd, 4926 5176 struct send_file_data *sfd) 4927 5177 { 4928 5178 char url[256]; … … 4943 5193 recv_enc = yahoo_urlencode(yd->user); 4944 5194 4945 snprintf(url, sizeof(url), 4946 4947 5195 snprintf(url, sizeof(url), 5196 "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr, 5197 token_enc, sender_enc, recv_enc); 4948 5198 4949 5199 snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, yd->cookie_t); 4950 5200 4951 5201 yahoo_http_head(yid->yd->client_id, url, buff, 0, NULL, 4952 5202 _yahoo_http_connected, yid); 4953 5203 4954 5204 FREE(token_enc); … … 4958 5208 4959 5209 static void yahoo_file_transfer_accept(struct yahoo_input_data *yid, 4960 5210 struct send_file_data *sfd) 4961 5211 { 4962 5212 struct yahoo_packet *pkt; 4963 5213 4964 5214 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFERACCEPT, 4965 5215 YPACKET_STATUS_DEFAULT, yid->yd->session_id); 4966 5216 4967 5217 yahoo_packet_hash(pkt, 1, yid->yd->user); … … 4980 5230 4981 5231 static void yahoo_process_filetransferaccept(struct yahoo_input_data *yid, 4982 5232 struct yahoo_packet *pkt) 4983 5233 { 4984 5234 YList *l; … … 5016 5266 5017 5267 yahoo_file_transfer_upload(yid->yd, sfd); 5018 } 5019 else { 5020 YAHOO_CALLBACK(ext_yahoo_file_transfer_done) 5021 (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN, 5022 sfd ? sfd->data : NULL); 5268 } else { 5269 YAHOO_CALLBACK (ext_yahoo_file_transfer_done) 5270 (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN, 5271 sfd ? sfd->data : NULL); 5023 5272 5024 5273 yahoo_remove_active_transfer(sfd); … … 5027 5276 5028 5277 static void yahoo_process_filetransferinfo(struct yahoo_input_data *yid, 5029 5278 struct yahoo_packet *pkt) 5030 5279 { 5031 5280 YList *l; … … 5070 5319 5071 5320 yahoo_file_transfer_accept(yid, sfd); 5072 } 5073 else { 5074 YAHOO_CALLBACK(ext_yahoo_file_transfer_done) 5075 (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN, 5076 sfd ? sfd->data : NULL); 5321 } else { 5322 YAHOO_CALLBACK (ext_yahoo_file_transfer_done) 5323 (yid->yd->client_id, YAHOO_FILE_TRANSFER_UNKNOWN, 5324 sfd ? sfd->data : NULL); 5077 5325 5078 5326 yahoo_remove_active_transfer(sfd); … … 5081 5329 5082 5330 static void yahoo_send_filetransferinfo(struct yahoo_data *yd, 5083 5331 struct send_file_data *sfd) 5084 5332 { 5085 5333 struct yahoo_input_data *yid; … … 5087 5335 5088 5336 yid = find_input_by_id_and_type(yd->client_id, YAHOO_CONNECTION_PAGER); 5089 sfd->ip_addr = YAHOO_CALLBACK (ext_yahoo_get_ip_addr)("relay.yahoo.com");5337 sfd->ip_addr = YAHOO_CALLBACK (ext_yahoo_get_ip_addr)("relay.yahoo.com"); 5090 5338 5091 5339 if (!sfd->ip_addr) { 5092 YAHOO_CALLBACK (ext_yahoo_file_transfer_done)5093 5340 YAHOO_CALLBACK (ext_yahoo_file_transfer_done) 5341 (yd->client_id, YAHOO_FILE_TRANSFER_RELAY, sfd->data); 5094 5342 5095 5343 yahoo_remove_active_transfer(sfd); … … 5099 5347 5100 5348 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFERINFO, 5101 5349 YPACKET_STATUS_DEFAULT, yd->session_id); 5102 5350 5103 5351 yahoo_packet_hash(pkt, 1, yd->user); … … 5114 5362 5115 5363 static void yahoo_process_filetransfer(struct yahoo_input_data *yid, 5116 5364 struct yahoo_packet *pkt) 5117 5365 { 5118 5366 YList *l; … … 5167 5415 /* Received a FT request from buddy */ 5168 5416 sfd = y_new0(struct send_file_data, 1); 5169 5417 5170 5418 sfd->client_id = yd->client_id; 5171 5419 sfd->id = strdup(id); … … 5173 5421 sfd->filename = strdup(filename); 5174 5422 sfd->size = size; 5175 5423 5176 5424 yahoo_add_active_transfer(sfd); 5177 5425 5178 YAHOO_CALLBACK(ext_yahoo_got_file) (yd->client_id, yd->user, 5179 who, msg, filename, size, sfd->id); 5180 } 5181 else { 5426 YAHOO_CALLBACK (ext_yahoo_got_file) (yd->client_id, yd->user, 5427 who, msg, filename, size, sfd->id); 5428 } else { 5182 5429 /* Response to our request */ 5183 5430 sfd = yahoo_get_active_transfer(id); … … 5185 5432 if (sfd && action == YAHOO_FILE_TRANSFER_ACCEPT) { 5186 5433 yahoo_send_filetransferinfo(yd, sfd); 5187 } 5188 else if (!sfd || action == YAHOO_FILE_TRANSFER_REJECT) { 5189 YAHOO_CALLBACK(ext_yahoo_file_transfer_done) 5190 (yd->client_id, YAHOO_FILE_TRANSFER_REJECT, 5191 sfd ? sfd->data : NULL); 5434 } else if (!sfd || action == YAHOO_FILE_TRANSFER_REJECT) { 5435 YAHOO_CALLBACK (ext_yahoo_file_transfer_done) 5436 (yd->client_id, YAHOO_FILE_TRANSFER_REJECT, 5437 sfd ? sfd->data : NULL); 5192 5438 5193 5439 yahoo_remove_active_transfer(sfd); … … 5198 5444 #if 0 5199 5445 void yahoo_send_file(int id, const char *who, const char *msg, 5200 5201 5446 const char *name, unsigned long size, 5447 yahoo_get_fd_callback callback, void *data) 5202 5448 { 5203 5449 struct yahoo_packet *pkt = NULL; … … 5206 5452 struct yahoo_data *yd; 5207 5453 struct send_file_data *sfd; 5208 5454 5209 5455 yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 5210 5456 yd = find_conn_by_id(id); … … 5221 5467 yahoo_add_active_transfer(sfd); 5222 5468 5223 if (!yd) 5224 return; 5469 if (!yd) { 5470 return; 5471 } 5225 5472 5226 5473 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFER, 5227 5474 YPACKET_STATUS_DEFAULT, yd->session_id); 5228 5475 5229 5476 snprintf(size_str, sizeof(size_str), "%ld", size); … … 5251 5498 char resp[2]; 5252 5499 struct yahoo_input_data *yid; 5253 5500 5254 5501 struct send_file_data *sfd = yahoo_get_active_transfer(id); 5255 5502 … … 5259 5506 5260 5507 pkt = yahoo_packet_new(YAHOO_SERVICE_Y7_FILETRANSFER, 5261 5508 YPACKET_STATUS_DEFAULT, yid->yd->session_id); 5262 5509 5263 5510 snprintf(resp, sizeof(resp), "%d", response); … … 5272 5519 yahoo_packet_free(pkt); 5273 5520 5274 if (response == YAHOO_FILE_TRANSFER_REJECT)5521 if (response == YAHOO_FILE_TRANSFER_REJECT) { 5275 5522 yahoo_remove_active_transfer(sfd); 5523 } 5276 5524 } 5277 5525 #endif … … 5281 5529 struct send_file_data *sfd; 5282 5530 struct yahoo_data *yd = yid->yd; 5283 5531 5284 5532 sfd = yahoo_get_active_transfer_with_yid(yid); 5285 5533 … … 5289 5537 } 5290 5538 5291 /* 5539 /* 5292 5540 * We want to handle only the complete data with HEAD since we don't 5293 5541 * want a situation where both the GET and HEAD are active. 5294 5542 * With SEND, we really can't do much with partial response 5295 5543 */ 5296 if ((sfd->state == FT_STATE_HEAD || sfd->state == FT_STATE_SEND) 5297 && !over) 5298 return; 5544 if ((sfd->state == FT_STATE_HEAD || sfd->state == FT_STATE_SEND) 5545 && !over) { 5546 return; 5547 } 5299 5548 5300 5549 if (sfd->state == FT_STATE_HEAD) { … … 5304 5553 char *sender_enc = NULL, *recv_enc = NULL, *token_enc = NULL; 5305 5554 5306 struct yahoo_input_data *yid_ft = 5307 5308 5555 struct yahoo_input_data *yid_ft = 5556 y_new0(struct yahoo_input_data, 1); 5557 5309 5558 yid_ft->yd = yid->yd; 5310 5559 yid_ft->type = YAHOO_CONNECTION_FT; 5311 5560 5312 5561 inputs = y_list_prepend(inputs, yid_ft); 5313 5562 sfd->yid = yid_ft; … … 5317 5566 sender_enc = yahoo_urlencode(sfd->who); 5318 5567 recv_enc = yahoo_urlencode(yd->user); 5319 5320 snprintf(url, sizeof(url), 5321 5322 5568 5569 snprintf(url, sizeof(url), 5570 "http://%s/relay?token=%s&sender=%s&recver=%s", sfd->ip_addr, 5571 token_enc, sender_enc, recv_enc); 5323 5572 5324 5573 snprintf(buff, sizeof(buff), "Y=%s; T=%s", yd->cookie_y, 5325 5574 yd->cookie_t); 5326 5575 5327 5576 5328 5577 yahoo_http_get(yd->client_id, url, buff, 1, 1, 5329 5578 _yahoo_http_connected, yid_ft); 5330 5579 5331 5580 FREE(token_enc); 5332 5581 FREE(sender_enc); 5333 5582 FREE(recv_enc); 5334 } 5335 else if (sfd->state == FT_STATE_RECV || 5336 sfd->state == FT_STATE_RECV_START) { 5583 } else if (sfd->state == FT_STATE_RECV || 5584 sfd->state == FT_STATE_RECV_START) { 5337 5585 5338 5586 unsigned char *data_begin = NULL; 5339 5587 5340 if (yid->rxlen == 0) 5588 if (yid->rxlen == 0) { 5341 5589 yahoo_remove_active_transfer(sfd); 5590 } 5342 5591 5343 5592 if (sfd->state != FT_STATE_RECV_START && 5344 (data_begin =5345 (unsigned char *)strstr((char *)yid->rxqueue,5346 5593 (data_begin = 5594 (unsigned char *) strstr((char *) yid->rxqueue, 5595 "\r\n\r\n"))) { 5347 5596 5348 5597 sfd->state = FT_STATE_RECV_START; 5349 5598 5350 yid->rxlen -= 4 +(data_begin-yid->rxqueue)/sizeof(char);5599 yid->rxlen -= 4 + (data_begin - yid->rxqueue) / sizeof(char); 5351 5600 data_begin += 4; 5352 5601 5353 if (yid->rxlen > 0) 5354 YAHOO_CALLBACK(ext_yahoo_got_ft_data) 5355 (yd->client_id, data_begin, 5356 yid->rxlen, sfd->data); 5357 } 5358 else if (sfd->state == FT_STATE_RECV_START) 5359 YAHOO_CALLBACK(ext_yahoo_got_ft_data) (yd->client_id, 5360 yid->rxqueue, yid->rxlen, sfd->data); 5602 if (yid->rxlen > 0) { 5603 YAHOO_CALLBACK (ext_yahoo_got_ft_data) 5604 (yd->client_id, data_begin, 5605 yid->rxlen, sfd->data); 5606 } 5607 } else if (sfd->state == FT_STATE_RECV_START) { 5608 YAHOO_CALLBACK (ext_yahoo_got_ft_data) (yd->client_id, 5609 yid->rxqueue, yid->rxlen, sfd->data); 5610 } 5361 5611 5362 5612 FREE(yid->rxqueue); 5363 5613 yid->rxqueue = NULL; 5364 5614 yid->rxlen = 0; 5365 } 5366 else if (sfd->state == FT_STATE_SEND) { 5615 } else if (sfd->state == FT_STATE_SEND) { 5367 5616 /* Sent file completed */ 5368 5617 int len = 0; 5369 char *off = strstr((char *) yid->rxqueue, "Content-Length: ");5618 char *off = strstr((char *) yid->rxqueue, "Content-Length: "); 5370 5619 5371 5620 if (off) { … … 5374 5623 } 5375 5624 5376 if (len < sfd->size) 5377 YAHOO_CALLBACK(ext_yahoo_file_transfer_done) 5378 (yd->client_id, 5379 YAHOO_FILE_TRANSFER_FAILED, sfd->data); 5380 else 5381 YAHOO_CALLBACK(ext_yahoo_file_transfer_done) 5382 (yd->client_id, 5383 YAHOO_FILE_TRANSFER_DONE, sfd->data); 5625 if (len < sfd->size) { 5626 YAHOO_CALLBACK (ext_yahoo_file_transfer_done) 5627 (yd->client_id, 5628 YAHOO_FILE_TRANSFER_FAILED, sfd->data); 5629 } else { 5630 YAHOO_CALLBACK (ext_yahoo_file_transfer_done) 5631 (yd->client_id, 5632 YAHOO_FILE_TRANSFER_DONE, sfd->data); 5633 } 5384 5634 5385 5635 yahoo_remove_active_transfer(sfd); … … 5393 5643 { 5394 5644 struct yahoo_data *yd = find_conn_by_id(id); 5395 if (!yd) 5645 5646 if (!yd) { 5396 5647 return YAHOO_STATUS_OFFLINE; 5648 } 5397 5649 return yd->current_status; 5398 5650 } … … 5401 5653 { 5402 5654 struct yahoo_data *yd = find_conn_by_id(id); 5403 if (!yd) 5655 5656 if (!yd) { 5404 5657 return NULL; 5658 } 5405 5659 return yd->buddies; 5406 5660 } … … 5409 5663 { 5410 5664 struct yahoo_data *yd = find_conn_by_id(id); 5411 if (!yd) 5665 5666 if (!yd) { 5412 5667 return NULL; 5668 } 5413 5669 return yd->ignore; 5414 5670 } … … 5417 5673 { 5418 5674 struct yahoo_data *yd = find_conn_by_id(id); 5419 if (!yd) 5675 5676 if (!yd) { 5420 5677 return NULL; 5678 } 5421 5679 return yd->identities; 5422 5680 } … … 5425 5683 { 5426 5684 struct yahoo_data *yd = find_conn_by_id(id); 5427 if (!yd) 5685 5686 if (!yd) { 5428 5687 return NULL; 5429 if (!strncasecmp(which, "y", 1)) 5688 } 5689 if (!strncasecmp(which, "y", 1)) { 5430 5690 return yd->cookie_y; 5431 if (!strncasecmp(which, "b", 1)) 5691 } 5692 if (!strncasecmp(which, "b", 1)) { 5432 5693 return yd->cookie_b; 5433 if (!strncasecmp(which, "t", 1)) 5694 } 5695 if (!strncasecmp(which, "t", 1)) { 5434 5696 return yd->cookie_t; 5435 if (!strncasecmp(which, "c", 1)) 5697 } 5698 if (!strncasecmp(which, "c", 1)) { 5436 5699 return yd->cookie_c; 5437 if (!strncasecmp(which, "login", 5)) 5700 } 5701 if (!strncasecmp(which, "login", 5)) { 5438 5702 return yd->login_cookie; 5703 } 5439 5704 return NULL; 5440 5705 } -
protocols/yahoo/yahoo.c
raf359b4 r5ebff60 35 35 36 36 /* A hack to handle removal of buddies not in the group "Buddies" correctly */ 37 struct byahoo_buddygroups 38 { 37 struct byahoo_buddygroups { 39 38 char *buddy; 40 39 char *group; 41 40 }; 42 41 43 struct byahoo_data 44 { 42 struct byahoo_data { 45 43 int y2_id; 46 44 int current_status; … … 49 47 }; 50 48 51 struct byahoo_input_data 52 { 49 struct byahoo_input_data { 53 50 int h; 54 51 void *d; 55 52 }; 56 53 57 struct byahoo_conf_invitation 58 { 54 struct byahoo_conf_invitation { 59 55 char *name; 60 56 struct groupchat *c; … … 67 63 static int byahoo_chat_id = 0; 68 64 69 static char *byahoo_strip( const char *in)65 static char *byahoo_strip(const char *in) 70 66 { 71 67 int len; 72 68 73 69 /* This should get rid of the markup noise at the beginning of the string. */ 74 while( *in ) 75 { 76 if( g_strncasecmp( in, "<font", 5 ) == 0 || 77 g_strncasecmp( in, "<fade", 5 ) == 0 || 78 g_strncasecmp( in, "<alt", 4 ) == 0 ) 79 { 80 char *s = strchr( in, '>' ); 81 if( !s ) 70 while (*in) { 71 if (g_strncasecmp(in, "<font", 5) == 0 || 72 g_strncasecmp(in, "<fade", 5) == 0 || 73 g_strncasecmp(in, "<alt", 4) == 0) { 74 char *s = strchr(in, '>'); 75 if (!s) { 82 76 break; 83 77 } 78 84 79 in = s + 1; 85 } 86 else if( strncmp( in, "\e[", 2 ) == 0 ) 87 { 80 } else if (strncmp(in, "\e[", 2) == 0) { 88 81 const char *s; 89 90 for( s = in + 2; *s && *s != 'm'; s ++ ); 91 92 if( *s != 'm' ) 82 83 for (s = in + 2; *s && *s != 'm'; s++) { 84 ; 85 } 86 87 if (*s != 'm') { 93 88 break; 94 89 } 90 95 91 in = s + 1; 96 } 97 else 98 { 92 } else { 99 93 break; 100 94 } 101 95 } 102 96 103 97 /* This is supposed to get rid of the noise at the end of the line. */ 104 len = strlen( in ); 105 while( len > 0 && ( in[len-1] == '>' || in[len-1] == 'm' ) ) 106 { 98 len = strlen(in); 99 while (len > 0 && (in[len - 1] == '>' || in[len - 1] == 'm')) { 107 100 int blen = len; 108 101 const char *search; 109 110 if ( in[len-1] == '>' )102 103 if (in[len - 1] == '>') { 111 104 search = "</"; 112 else105 } else { 113 106 search = "\e["; 114 107 } 108 115 109 len -= 3; 116 while ( len > 0 && strncmp( in + len, search, 2 ) != 0 )117 len 118 119 if( len <= 0 && strncmp( in, search, 2 ) != 0 ) 120 {110 while (len > 0 && strncmp(in + len, search, 2) != 0) { 111 len--; 112 } 113 114 if (len <= 0 && strncmp(in, search, 2) != 0) { 121 115 len = blen; 122 116 break; 123 117 } 124 118 } 125 126 return( g_strndup( in, len ));127 } 128 129 static void byahoo_init( account_t *acc)130 { 131 set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc);132 119 120 return(g_strndup(in, len)); 121 } 122 123 static void byahoo_init(account_t *acc) 124 { 125 set_add(&acc->set, "mail_notifications", "false", set_eval_bool, acc); 126 133 127 acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE; 134 128 } 135 129 136 static void byahoo_login( account_t *acc)137 { 138 struct im_connection *ic = imcb_new( acc);139 struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1);130 static void byahoo_login(account_t *acc) 131 { 132 struct im_connection *ic = imcb_new(acc); 133 struct byahoo_data *yd = ic->proto_data = g_new0(struct byahoo_data, 1); 140 134 char *s; 141 135 142 136 yd->logged_in = FALSE; 143 137 yd->current_status = YAHOO_STATUS_AVAILABLE; 144 145 if( ( s = strchr( acc->user, '@' ) ) && g_strcasecmp( s, "@yahoo.com" ) == 0 ) 146 imcb_error( ic, "Your Yahoo! username should just be a username. " 147 "Do not include any @domain part." ); 148 149 imcb_log( ic, "Connecting" ); 150 yd->y2_id = yahoo_init( acc->user, acc->pass ); 151 yahoo_login( yd->y2_id, yd->current_status ); 152 } 153 154 static void byahoo_logout( struct im_connection *ic ) 138 139 if ((s = strchr(acc->user, '@')) && g_strcasecmp(s, "@yahoo.com") == 0) { 140 imcb_error(ic, "Your Yahoo! username should just be a username. " 141 "Do not include any @domain part."); 142 } 143 144 imcb_log(ic, "Connecting"); 145 yd->y2_id = yahoo_init(acc->user, acc->pass); 146 yahoo_login(yd->y2_id, yd->current_status); 147 } 148 149 static void byahoo_logout(struct im_connection *ic) 155 150 { 156 151 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 157 152 GSList *l; 158 159 while ( ic->groupchats )160 imcb_chat_free( ic->groupchats->data);161 162 for( l = yd->buddygroups; l; l = l->next ) 163 {153 154 while (ic->groupchats) { 155 imcb_chat_free(ic->groupchats->data); 156 } 157 158 for (l = yd->buddygroups; l; l = l->next) { 164 159 struct byahoo_buddygroups *bg = l->data; 165 166 g_free( bg->buddy);167 g_free( bg->group);168 g_free( bg);169 } 170 g_slist_free( yd->buddygroups);171 172 yahoo_logoff( yd->y2_id);173 174 g_free( yd);175 } 176 177 static void byahoo_get_info(struct im_connection *ic, char *who) 160 161 g_free(bg->buddy); 162 g_free(bg->group); 163 g_free(bg); 164 } 165 g_slist_free(yd->buddygroups); 166 167 yahoo_logoff(yd->y2_id); 168 169 g_free(yd); 170 } 171 172 static void byahoo_get_info(struct im_connection *ic, char *who) 178 173 { 179 174 /* Just make an URL and let the user fetch the info */ 180 imcb_log(ic, "%s\n%s: %s%s", _("User Info"), 181 182 183 } 184 185 static int byahoo_buddy_msg( struct im_connection *ic, char *who, char *what, int flags)175 imcb_log(ic, "%s\n%s: %s%s", _("User Info"), 176 _("For now, fetch yourself"), yahoo_get_profile_url(), 177 who); 178 } 179 180 static int byahoo_buddy_msg(struct im_connection *ic, char *who, char *what, int flags) 186 181 { 187 182 struct byahoo_data *yd = ic->proto_data; 188 189 yahoo_send_im( yd->y2_id, NULL, who, what, 1, 0);190 183 184 yahoo_send_im(yd->y2_id, NULL, who, what, 1, 0); 185 191 186 return 1; 192 187 } 193 188 194 static int byahoo_send_typing( struct im_connection *ic, char *who, int typing)189 static int byahoo_send_typing(struct im_connection *ic, char *who, int typing) 195 190 { 196 191 struct byahoo_data *yd = ic->proto_data; 197 198 yahoo_send_typing( yd->y2_id, NULL, who, ( typing & OPT_TYPING ) != 0);199 192 193 yahoo_send_typing(yd->y2_id, NULL, who, (typing & OPT_TYPING) != 0); 194 200 195 return 1; 201 196 } 202 197 203 static void byahoo_set_away( struct im_connection *ic, char *state, char *msg)198 static void byahoo_set_away(struct im_connection *ic, char *state, char *msg) 204 199 { 205 200 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 206 207 if( state && msg == NULL ) 208 { 201 202 if (state && msg == NULL) { 209 203 /* Use these states only if msg doesn't contain additional 210 204 info since away messages are only supported with CUSTOM. */ 211 if ( g_strcasecmp( state, "Be Right Back" ) == 0 )205 if (g_strcasecmp(state, "Be Right Back") == 0) { 212 206 yd->current_status = YAHOO_STATUS_BRB; 213 else if( g_strcasecmp( state, "Busy" ) == 0 )207 } else if (g_strcasecmp(state, "Busy") == 0) { 214 208 yd->current_status = YAHOO_STATUS_BUSY; 215 else if( g_strcasecmp( state, "Not At Home" ) == 0 )209 } else if (g_strcasecmp(state, "Not At Home") == 0) { 216 210 yd->current_status = YAHOO_STATUS_NOTATHOME; 217 else if( g_strcasecmp( state, "Not At Desk" ) == 0 )211 } else if (g_strcasecmp(state, "Not At Desk") == 0) { 218 212 yd->current_status = YAHOO_STATUS_NOTATDESK; 219 else if( g_strcasecmp( state, "Not In Office" ) == 0 )213 } else if (g_strcasecmp(state, "Not In Office") == 0) { 220 214 yd->current_status = YAHOO_STATUS_NOTINOFFICE; 221 else if( g_strcasecmp( state, "On Phone" ) == 0 )215 } else if (g_strcasecmp(state, "On Phone") == 0) { 222 216 yd->current_status = YAHOO_STATUS_ONPHONE; 223 else if( g_strcasecmp( state, "On Vacation" ) == 0 )217 } else if (g_strcasecmp(state, "On Vacation") == 0) { 224 218 yd->current_status = YAHOO_STATUS_ONVACATION; 225 else if( g_strcasecmp( state, "Out To Lunch" ) == 0 )219 } else if (g_strcasecmp(state, "Out To Lunch") == 0) { 226 220 yd->current_status = YAHOO_STATUS_OUTTOLUNCH; 227 else if( g_strcasecmp( state, "Stepped Out" ) == 0 )221 } else if (g_strcasecmp(state, "Stepped Out") == 0) { 228 222 yd->current_status = YAHOO_STATUS_STEPPEDOUT; 229 else if( g_strcasecmp( state, "Invisible" ) == 0 )223 } else if (g_strcasecmp(state, "Invisible") == 0) { 230 224 yd->current_status = YAHOO_STATUS_INVISIBLE; 231 else225 } else { 232 226 yd->current_status = YAHOO_STATUS_CUSTOM; 233 }234 else if( msg )227 } 228 } else if (msg) { 235 229 yd->current_status = YAHOO_STATUS_CUSTOM; 236 else230 } else { 237 231 yd->current_status = YAHOO_STATUS_AVAILABLE; 238 239 yahoo_set_away( yd->y2_id, yd->current_status, msg, state ? 2 : 0 ); 240 } 241 242 static GList *byahoo_away_states( struct im_connection *ic ) 232 } 233 234 yahoo_set_away(yd->y2_id, yd->current_status, msg, state ? 2 : 0); 235 } 236 237 static GList *byahoo_away_states(struct im_connection *ic) 243 238 { 244 239 static GList *m = NULL; 245 240 246 if( m == NULL ) 247 { 248 m = g_list_append( m, "Be Right Back" ); 249 m = g_list_append( m, "Busy" ); 250 m = g_list_append( m, "Not At Home" ); 251 m = g_list_append( m, "Not At Desk" ); 252 m = g_list_append( m, "Not In Office" ); 253 m = g_list_append( m, "On Phone" ); 254 m = g_list_append( m, "On Vacation" ); 255 m = g_list_append( m, "Out To Lunch" ); 256 m = g_list_append( m, "Stepped Out" ); 257 m = g_list_append( m, "Invisible" ); 258 } 259 241 if (m == NULL) { 242 m = g_list_append(m, "Be Right Back"); 243 m = g_list_append(m, "Busy"); 244 m = g_list_append(m, "Not At Home"); 245 m = g_list_append(m, "Not At Desk"); 246 m = g_list_append(m, "Not In Office"); 247 m = g_list_append(m, "On Phone"); 248 m = g_list_append(m, "On Vacation"); 249 m = g_list_append(m, "Out To Lunch"); 250 m = g_list_append(m, "Stepped Out"); 251 m = g_list_append(m, "Invisible"); 252 } 253 260 254 return m; 261 255 } 262 256 263 static void byahoo_keepalive( struct im_connection *ic)257 static void byahoo_keepalive(struct im_connection *ic) 264 258 { 265 259 struct byahoo_data *yd = ic->proto_data; 266 267 yahoo_keepalive( yd->y2_id);268 } 269 270 static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group)260 261 yahoo_keepalive(yd->y2_id); 262 } 263 264 static void byahoo_add_buddy(struct im_connection *ic, char *who, char *group) 271 265 { 272 266 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 273 267 bee_user_t *bu; 274 275 if( group && ( bu = bee_user_by_handle( ic->bee, ic, who ) ) && bu->group ) 276 { 268 269 if (group && (bu = bee_user_by_handle(ic->bee, ic, who)) && bu->group) { 277 270 GSList *bgl; 278 271 279 272 /* If the person is in our list already, this is a group change. */ 280 yahoo_change_buddy_group( yd->y2_id, who, bu->group->name, group);281 273 yahoo_change_buddy_group(yd->y2_id, who, bu->group->name, group); 274 282 275 /* No idea how often people have people in multiple groups and 283 276 BitlBee doesn't currently support this anyway .. but keep 284 277 this struct up-to-date for now. */ 285 for( bgl = yd->buddygroups; bgl; bgl = bgl->next ) 286 { 278 for (bgl = yd->buddygroups; bgl; bgl = bgl->next) { 287 279 struct byahoo_buddygroups *bg = bgl->data; 288 289 if( g_strcasecmp( bg->buddy, who ) == 0 && 290 g_strcasecmp( bg->group, bu->group->name ) == 0 ) 291 { 292 g_free( bg->group ); 293 bg->group = g_strdup( group ); 280 281 if (g_strcasecmp(bg->buddy, who) == 0 && 282 g_strcasecmp(bg->group, bu->group->name) == 0) { 283 g_free(bg->group); 284 bg->group = g_strdup(group); 294 285 } 295 286 } 296 } 297 else298 yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL );299 } 300 301 static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *group)287 } else { 288 yahoo_add_buddy(yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL); 289 } 290 } 291 292 static void byahoo_remove_buddy(struct im_connection *ic, char *who, char *group) 302 293 { 303 294 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 304 295 GSList *bgl; 305 306 yahoo_remove_buddy( yd->y2_id, who, BYAHOO_DEFAULT_GROUP ); 307 308 for( bgl = yd->buddygroups; bgl; bgl = bgl->next ) 309 { 296 297 yahoo_remove_buddy(yd->y2_id, who, BYAHOO_DEFAULT_GROUP); 298 299 for (bgl = yd->buddygroups; bgl; bgl = bgl->next) { 310 300 struct byahoo_buddygroups *bg = bgl->data; 311 312 if( g_strcasecmp( bg->buddy, who ) == 0 ) 313 yahoo_remove_buddy( yd->y2_id, who, bg->group ); 314 } 315 } 316 317 static void byahoo_chat_msg( struct groupchat *c, char *message, int flags ) 301 302 if (g_strcasecmp(bg->buddy, who) == 0) { 303 yahoo_remove_buddy(yd->y2_id, who, bg->group); 304 } 305 } 306 } 307 308 static void byahoo_chat_msg(struct groupchat *c, char *message, int flags) 318 309 { 319 310 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 320 321 yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1);322 } 323 324 static void byahoo_chat_invite( struct groupchat *c, char *who, char *msg)311 312 yahoo_conference_message(yd->y2_id, NULL, c->data, c->title, message, 1); 313 } 314 315 static void byahoo_chat_invite(struct groupchat *c, char *who, char *msg) 325 316 { 326 317 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 327 328 yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ? msg : "");329 } 330 331 static void byahoo_chat_leave( struct groupchat *c)318 319 yahoo_conference_invite(yd->y2_id, NULL, c->data, c->title, msg ? msg : ""); 320 } 321 322 static void byahoo_chat_leave(struct groupchat *c) 332 323 { 333 324 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 334 335 yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title);336 imcb_chat_free( c);337 } 338 339 static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who)325 326 yahoo_conference_logoff(yd->y2_id, NULL, c->data, c->title); 327 imcb_chat_free(c); 328 } 329 330 static struct groupchat *byahoo_chat_with(struct im_connection *ic, char *who) 340 331 { 341 332 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; … … 343 334 char *roomname; 344 335 YList *members; 345 346 roomname = g_strdup_printf( "%s-Bee-%d", ic->acc->user, byahoo_chat_id);347 348 c = imcb_chat_new( ic, roomname);349 imcb_chat_add_buddy( c, ic->acc->user);350 336 337 roomname = g_strdup_printf("%s-Bee-%d", ic->acc->user, byahoo_chat_id); 338 339 c = imcb_chat_new(ic, roomname); 340 imcb_chat_add_buddy(c, ic->acc->user); 341 351 342 /* FIXME: Free this thing when the chat's destroyed. We can't *always* 352 343 do this because it's not always created here. */ 353 c->data = members = g_new0( YList, 1);354 members->data = g_strdup( who);355 356 yahoo_conference_invite( yd->y2_id, NULL, members, roomname, "Please join my groupchat...");357 358 g_free( roomname);359 344 c->data = members = g_new0(YList, 1); 345 members->data = g_strdup(who); 346 347 yahoo_conference_invite(yd->y2_id, NULL, members, roomname, "Please join my groupchat..."); 348 349 g_free(roomname); 350 360 351 return c; 361 352 } 362 353 363 static void byahoo_auth_allow( struct im_connection *ic, const char *who)354 static void byahoo_auth_allow(struct im_connection *ic, const char *who) 364 355 { 365 356 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 366 367 yahoo_confirm_buddy( yd->y2_id, who, 0, "");368 } 369 370 static void byahoo_auth_deny( struct im_connection *ic, const char *who)357 358 yahoo_confirm_buddy(yd->y2_id, who, 0, ""); 359 } 360 361 static void byahoo_auth_deny(struct im_connection *ic, const char *who) 371 362 { 372 363 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 373 374 yahoo_confirm_buddy( yd->y2_id, who, 1, "");375 } 376 377 void byahoo_initmodule( 364 365 yahoo_confirm_buddy(yd->y2_id, who, 1, ""); 366 } 367 368 void byahoo_initmodule() 378 369 { 379 370 struct prpl *ret = g_new0(struct prpl, 1); 371 380 372 ret->name = "yahoo"; 381 ret->mms = 832;/* this guess taken from libotr UPGRADING file */373 ret->mms = 832; /* this guess taken from libotr UPGRADING file */ 382 374 ret->init = byahoo_init; 383 375 384 376 ret->login = byahoo_login; 385 377 ret->keepalive = byahoo_keepalive; 386 378 ret->logout = byahoo_logout; 387 379 388 380 ret->buddy_msg = byahoo_buddy_msg; 389 381 ret->get_info = byahoo_get_info; … … 393 385 ret->remove_buddy = byahoo_remove_buddy; 394 386 ret->send_typing = byahoo_send_typing; 395 387 396 388 ret->chat_msg = byahoo_chat_msg; 397 389 ret->chat_invite = byahoo_chat_invite; … … 400 392 401 393 ret->handle_cmp = g_strcasecmp; 402 394 403 395 ret->auth_allow = byahoo_auth_allow; 404 396 ret->auth_deny = byahoo_auth_deny; 405 397 406 398 register_protocol(ret); 407 399 } 408 400 409 static struct im_connection *byahoo_get_ic_by_id( int id)401 static struct im_connection *byahoo_get_ic_by_id(int id) 410 402 { 411 403 GSList *l; 412 404 struct im_connection *ic; 413 405 struct byahoo_data *yd; 414 415 for( l = get_connections(); l; l = l->next ) 416 { 406 407 for (l = get_connections(); l; l = l->next) { 417 408 ic = l->data; 418 409 yd = ic->proto_data; 419 420 if( strcmp( ic->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id ) 421 return( ic ); 422 } 423 424 return( NULL ); 410 411 if (strcmp(ic->acc->prpl->name, "yahoo") == 0 && yd->y2_id == id) { 412 return(ic); 413 } 414 } 415 416 return(NULL); 425 417 } 426 418 … … 428 420 /* Now it's callback time! */ 429 421 430 struct byahoo_connect_callback_data 431 { 422 struct byahoo_connect_callback_data { 432 423 int fd; 433 424 yahoo_connect_callback callback; … … 436 427 }; 437 428 438 void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond)429 void byahoo_connect_callback(gpointer data, gint source, b_input_condition cond) 439 430 { 440 431 struct byahoo_connect_callback_data *d = data; 441 442 if( !byahoo_get_ic_by_id( d->id ) ) 443 { 444 g_free( d ); 432 433 if (!byahoo_get_ic_by_id(d->id)) { 434 g_free(d); 445 435 return; 446 436 } 447 448 d->callback( NULL + d->fd, 0, d->data ); 449 g_free( d ); 450 } 451 452 struct byahoo_read_ready_data 453 { 437 438 d->callback(NULL + d->fd, 0, d->data); 439 g_free(d); 440 } 441 442 struct byahoo_read_ready_data { 454 443 int id; 455 444 int fd; … … 458 447 }; 459 448 460 gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_condition cond)449 gboolean byahoo_read_ready_callback(gpointer data, gint source, b_input_condition cond) 461 450 { 462 451 struct byahoo_read_ready_data *d = data; 463 464 if ( !byahoo_get_ic_by_id( d->id ) )452 453 if (!byahoo_get_ic_by_id(d->id)) { 465 454 /* WTF doesn't libyahoo clean this up? */ 466 455 return FALSE; 467 468 yahoo_read_ready( d->id, NULL + d->fd, d->data ); 469 456 } 457 458 yahoo_read_ready(d->id, NULL + d->fd, d->data); 459 470 460 return TRUE; 471 461 } 472 462 473 struct byahoo_write_ready_data 474 { 463 struct byahoo_write_ready_data { 475 464 int id; 476 465 int fd; … … 479 468 }; 480 469 481 gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condition cond)470 gboolean byahoo_write_ready_callback(gpointer data, gint source, b_input_condition cond) 482 471 { 483 472 struct byahoo_write_ready_data *d = data; 484 485 return yahoo_write_ready( d->id, NULL + d->fd, d->data);486 } 487 488 void ext_yahoo_login_response( int id, int succ, const char *url)489 { 490 struct im_connection *ic = byahoo_get_ic_by_id( id);473 474 return yahoo_write_ready(d->id, NULL + d->fd, d->data); 475 } 476 477 void ext_yahoo_login_response(int id, int succ, const char *url) 478 { 479 struct im_connection *ic = byahoo_get_ic_by_id(id); 491 480 struct byahoo_data *yd = NULL; 492 493 if( ic == NULL ) 494 { 481 482 if (ic == NULL) { 495 483 /* libyahoo2 seems to call this one twice when something 496 484 went wrong sometimes. Don't know why. Because we clean 497 485 up the connection on the first failure, the second 498 486 should be ignored. */ 499 487 500 488 return; 501 489 } 502 490 503 491 yd = (struct byahoo_data *) ic->proto_data; 504 505 if( succ == YAHOO_LOGIN_OK ) 506 { 507 imcb_connected( ic ); 508 492 493 if (succ == YAHOO_LOGIN_OK) { 494 imcb_connected(ic); 495 509 496 yd->logged_in = TRUE; 510 } 511 else 512 { 497 } else { 513 498 char *errstr; 514 499 int allow_reconnect = FALSE; 515 500 516 501 yd->logged_in = FALSE; 517 518 if ( succ == YAHOO_LOGIN_UNAME )502 503 if (succ == YAHOO_LOGIN_UNAME) { 519 504 errstr = "Incorrect Yahoo! username"; 520 else if( succ == YAHOO_LOGIN_PASSWD )505 } else if (succ == YAHOO_LOGIN_PASSWD) { 521 506 errstr = "Incorrect Yahoo! password"; 522 else if( succ == YAHOO_LOGIN_LOCK )507 } else if (succ == YAHOO_LOGIN_LOCK) { 523 508 errstr = "Yahoo! account locked"; 524 else if( succ == 1236 )509 } else if (succ == 1236) { 525 510 errstr = "Yahoo! account locked or machine temporarily banned"; 526 else if( succ == YAHOO_LOGIN_DUPL )511 } else if (succ == YAHOO_LOGIN_DUPL) { 527 512 errstr = "Logged in on a different machine or device"; 528 else if( succ == YAHOO_LOGIN_SOCK ) 529 { 513 } else if (succ == YAHOO_LOGIN_SOCK) { 530 514 errstr = "Socket problem"; 531 515 allow_reconnect = TRUE; 532 } 533 else 516 } else { 534 517 errstr = "Unknown error"; 535 536 if( url && *url ) 537 imcb_error( ic, "Error %d (%s). See %s for more information.", succ, errstr, url ); 538 else 539 imcb_error( ic, "Error %d (%s)", succ, errstr ); 540 541 imc_logout( ic, allow_reconnect ); 542 } 543 } 544 545 void ext_yahoo_got_buddies( int id, YList *buds ) 546 { 547 struct im_connection *ic = byahoo_get_ic_by_id( id ); 518 } 519 520 if (url && *url) { 521 imcb_error(ic, "Error %d (%s). See %s for more information.", succ, errstr, url); 522 } else { 523 imcb_error(ic, "Error %d (%s)", succ, errstr); 524 } 525 526 imc_logout(ic, allow_reconnect); 527 } 528 } 529 530 void ext_yahoo_got_buddies(int id, YList *buds) 531 { 532 struct im_connection *ic = byahoo_get_ic_by_id(id); 548 533 struct byahoo_data *yd = ic->proto_data; 549 534 YList *bl = buds; 550 551 while( bl ) 552 { 535 536 while (bl) { 553 537 struct yahoo_buddy *b = bl->data; 554 538 struct byahoo_buddygroups *bg; 555 556 if( strcmp( b->group, BYAHOO_DEFAULT_GROUP ) != 0 ) 557 { 558 bg = g_new0( struct byahoo_buddygroups, 1 ); 559 560 bg->buddy = g_strdup( b->id ); 561 bg->group = g_strdup( b->group ); 562 yd->buddygroups = g_slist_append( yd->buddygroups, bg ); 563 } 564 565 imcb_add_buddy( ic, b->id, b->group ); 566 imcb_rename_buddy( ic, b->id, b->real_name ); 567 539 540 if (strcmp(b->group, BYAHOO_DEFAULT_GROUP) != 0) { 541 bg = g_new0(struct byahoo_buddygroups, 1); 542 543 bg->buddy = g_strdup(b->id); 544 bg->group = g_strdup(b->group); 545 yd->buddygroups = g_slist_append(yd->buddygroups, bg); 546 } 547 548 imcb_add_buddy(ic, b->id, b->group); 549 imcb_rename_buddy(ic, b->id, b->real_name); 550 568 551 bl = bl->next; 569 552 } 570 553 } 571 554 572 void ext_yahoo_got_identities( int id, YList *ids)573 { 574 } 575 576 void ext_yahoo_got_cookies( int id)577 { 578 } 579 580 void ext_yahoo_status_changed( int id, const char *who, int stat, const char *msg, int away, int idle, int mobile)581 { 582 struct im_connection *ic = byahoo_get_ic_by_id( id);555 void ext_yahoo_got_identities(int id, YList *ids) 556 { 557 } 558 559 void ext_yahoo_got_cookies(int id) 560 { 561 } 562 563 void ext_yahoo_status_changed(int id, const char *who, int stat, const char *msg, int away, int idle, int mobile) 564 { 565 struct im_connection *ic = byahoo_get_ic_by_id(id); 583 566 char *state_string = NULL; 584 567 int flags = OPT_LOGGED_IN; 585 586 if ( away )568 569 if (away) { 587 570 flags |= OPT_AWAY; 588 if( mobile ) 571 } 572 if (mobile) { 589 573 flags |= OPT_MOBILE; 590 591 switch (stat) 592 {574 } 575 576 switch (stat) { 593 577 case YAHOO_STATUS_BRB: 594 578 state_string = "Be Right Back"; … … 632 616 break; 633 617 } 634 635 imcb_buddy_status( ic, who, flags, state_string, msg ); 636 637 if( stat == YAHOO_STATUS_IDLE ) 638 imcb_buddy_times( ic, who, 0, idle ); 639 } 640 641 void ext_yahoo_got_buzz( int id, const char *me, const char *who, long tm ) 642 { 643 } 644 645 void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8 ) 646 { 647 struct im_connection *ic = byahoo_get_ic_by_id( id ); 618 619 imcb_buddy_status(ic, who, flags, state_string, msg); 620 621 if (stat == YAHOO_STATUS_IDLE) { 622 imcb_buddy_times(ic, who, 0, idle); 623 } 624 } 625 626 void ext_yahoo_got_buzz(int id, const char *me, const char *who, long tm) 627 { 628 } 629 630 void ext_yahoo_got_im(int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8) 631 { 632 struct im_connection *ic = byahoo_get_ic_by_id(id); 648 633 char *m; 649 650 if ( msg )651 {652 m = byahoo_strip( msg);653 imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0);654 g_free( m );655 656 } 657 658 void ext_yahoo_got_file( int id, const char *ignored, const char *who, const char *msg, 659 const char *fname, unsigned long fesize, char *trid ) 660 { 661 struct im_connection *ic = byahoo_get_ic_by_id( id ); 662 663 imcb_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); 664 } 665 666 void ext_yahoo_got_ft_data( int id, const unsigned char *in, int len, void *data ) 667 { 668 } 669 670 void ext_yahoo_file_transfer_done( int id, int result, void *data ) 671 { 672 } 673 674 void ext_yahoo_typing_notify( int id, const char *ignored, const char *who, int stat ) 675 { 676 struct im_connection *ic = byahoo_get_ic_by_id( id ); 677 678 if( stat == 1 )679 imcb_buddy_typing( ic, (char*) who, OPT_TYPING );680 else681 imcb_buddy_typing( ic, (char*) who, 0 );682 } 683 684 void ext_yahoo_system_message( int id, const char *me, const char *who, const char *msg)685 { 686 struct im_connection *ic = byahoo_get_ic_by_id( id);687 688 imcb_log( ic, "Yahoo! system message: %s", msg);689 } 690 691 void ext_yahoo_webcam_invite( int id, const char *ignored, const char *from)692 { 693 struct im_connection *ic = byahoo_get_ic_by_id( id);694 695 imcb_log( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from);696 } 697 698 void ext_yahoo_error( int id, const char *err, int fatal, int num)699 { 700 struct im_connection *ic = byahoo_get_ic_by_id( id);701 702 imcb_error( ic, "%s", err);634 635 if (msg) { 636 m = byahoo_strip(msg); 637 imcb_buddy_msg(ic, (char *) who, (char *) m, 0, 0); 638 g_free(m); 639 } 640 } 641 642 void ext_yahoo_got_file(int id, const char *ignored, const char *who, const char *msg, 643 const char *fname, unsigned long fesize, char *trid) 644 { 645 struct im_connection *ic = byahoo_get_ic_by_id(id); 646 647 imcb_log(ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who); 648 } 649 650 void ext_yahoo_got_ft_data(int id, const unsigned char *in, int len, void *data) 651 { 652 } 653 654 void ext_yahoo_file_transfer_done(int id, int result, void *data) 655 { 656 } 657 658 void ext_yahoo_typing_notify(int id, const char *ignored, const char *who, int stat) 659 { 660 struct im_connection *ic = byahoo_get_ic_by_id(id); 661 662 if (stat == 1) { 663 imcb_buddy_typing(ic, (char *) who, OPT_TYPING); 664 } else { 665 imcb_buddy_typing(ic, (char *) who, 0); 666 } 667 } 668 669 void ext_yahoo_system_message(int id, const char *me, const char *who, const char *msg) 670 { 671 struct im_connection *ic = byahoo_get_ic_by_id(id); 672 673 imcb_log(ic, "Yahoo! system message: %s", msg); 674 } 675 676 void ext_yahoo_webcam_invite(int id, const char *ignored, const char *from) 677 { 678 struct im_connection *ic = byahoo_get_ic_by_id(id); 679 680 imcb_log(ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from); 681 } 682 683 void ext_yahoo_error(int id, const char *err, int fatal, int num) 684 { 685 struct im_connection *ic = byahoo_get_ic_by_id(id); 686 687 imcb_error(ic, "%s", err); 703 688 } 704 689 705 690 /* TODO: Clear up the mess of inp and d structures */ 706 int ext_yahoo_add_handler( int id, void *fd_, yahoo_input_condition cond, void *data)707 { 708 struct byahoo_input_data *inp = g_new0( struct byahoo_input_data, 1);691 int ext_yahoo_add_handler(int id, void *fd_, yahoo_input_condition cond, void *data) 692 { 693 struct byahoo_input_data *inp = g_new0(struct byahoo_input_data, 1); 709 694 int fd = (long) fd_; 710 711 if( cond == YAHOO_INPUT_READ ) 712 { 713 struct byahoo_read_ready_data *d = g_new0( struct byahoo_read_ready_data, 1 ); 714 695 696 if (cond == YAHOO_INPUT_READ) { 697 struct byahoo_read_ready_data *d = g_new0(struct byahoo_read_ready_data, 1); 698 715 699 d->id = id; 716 700 d->fd = fd; 717 701 d->data = data; 718 702 719 703 inp->d = d; 720 d->tag = inp->h = b_input_add( fd, B_EV_IO_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d ); 721 } 722 else if( cond == YAHOO_INPUT_WRITE ) 723 { 724 struct byahoo_write_ready_data *d = g_new0( struct byahoo_write_ready_data, 1 ); 725 704 d->tag = inp->h = b_input_add(fd, B_EV_IO_READ, (b_event_handler) byahoo_read_ready_callback, 705 (gpointer) d); 706 } else if (cond == YAHOO_INPUT_WRITE) { 707 struct byahoo_write_ready_data *d = g_new0(struct byahoo_write_ready_data, 1); 708 726 709 d->id = id; 727 710 d->fd = fd; 728 711 d->data = data; 729 712 730 713 inp->d = d; 731 d->tag = inp->h = b_input_add( fd, B_EV_IO_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d );732 }733 else734 {735 g_free( inp);714 d->tag = inp->h = 715 b_input_add(fd, B_EV_IO_WRITE, (b_event_handler) byahoo_write_ready_callback, 716 (gpointer) d); 717 } else { 718 g_free(inp); 736 719 return -1; 737 720 /* Panic... */ 738 721 } 739 740 byahoo_inputs = g_slist_append( byahoo_inputs, inp);722 723 byahoo_inputs = g_slist_append(byahoo_inputs, inp); 741 724 return inp->h; 742 725 } 743 726 744 void ext_yahoo_remove_handler( int id, int tag)727 void ext_yahoo_remove_handler(int id, int tag) 745 728 { 746 729 struct byahoo_input_data *inp; 747 730 GSList *l = byahoo_inputs; 748 749 while( l ) 750 { 731 732 while (l) { 751 733 inp = l->data; 752 if( inp->h == tag ) 753 { 754 g_free( inp->d ); 755 g_free( inp ); 756 byahoo_inputs = g_slist_remove( byahoo_inputs, inp ); 734 if (inp->h == tag) { 735 g_free(inp->d); 736 g_free(inp); 737 byahoo_inputs = g_slist_remove(byahoo_inputs, inp); 757 738 break; 758 739 } 759 740 l = l->next; 760 741 } 761 762 b_event_remove( tag ); 763 } 764 765 int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data, int use_ssl ) 742 743 b_event_remove(tag); 744 } 745 746 int ext_yahoo_connect_async(int id, const char *host, int port, yahoo_connect_callback callback, void *data, 747 int use_ssl) 766 748 { 767 749 struct byahoo_connect_callback_data *d; 768 750 int fd; 769 770 d = g_new0( struct byahoo_connect_callback_data, 1 ); 771 if( ( fd = proxy_connect( host, port, (b_event_handler) byahoo_connect_callback, (gpointer) d ) ) < 0 ) 772 { 773 g_free( d ); 774 return( fd ); 751 752 d = g_new0(struct byahoo_connect_callback_data, 1); 753 if ((fd = proxy_connect(host, port, (b_event_handler) byahoo_connect_callback, (gpointer) d)) < 0) { 754 g_free(d); 755 return(fd); 775 756 } 776 757 d->fd = fd; … … 778 759 d->data = data; 779 760 d->id = id; 780 761 781 762 return fd; 782 763 } 783 764 784 char *ext_yahoo_get_ip_addr( const char *domain)765 char *ext_yahoo_get_ip_addr(const char *domain) 785 766 { 786 767 return NULL; 787 768 } 788 769 789 int ext_yahoo_write( void *fd, char *buf, int len)790 { 791 return write( (long) fd, buf, len);792 } 793 794 int ext_yahoo_read( void *fd, char *buf, int len)795 { 796 return read( (long) fd, buf, len);797 } 798 799 void ext_yahoo_close( void *fd)800 { 801 close( (long) fd);802 } 803 804 void ext_yahoo_got_buddy_change_group( 805 const char *old_group, const char *new_group)806 { 807 struct im_connection *ic = byahoo_get_ic_by_id( id);808 809 imcb_add_buddy( ic, who, new_group);810 } 811 812 static void byahoo_accept_conf( void *data)770 int ext_yahoo_write(void *fd, char *buf, int len) 771 { 772 return write((long) fd, buf, len); 773 } 774 775 int ext_yahoo_read(void *fd, char *buf, int len) 776 { 777 return read((long) fd, buf, len); 778 } 779 780 void ext_yahoo_close(void *fd) 781 { 782 close((long) fd); 783 } 784 785 void ext_yahoo_got_buddy_change_group(int id, const char *me, const char *who, 786 const char *old_group, const char *new_group) 787 { 788 struct im_connection *ic = byahoo_get_ic_by_id(id); 789 790 imcb_add_buddy(ic, who, new_group); 791 } 792 793 static void byahoo_accept_conf(void *data) 813 794 { 814 795 struct byahoo_conf_invitation *inv = data; 815 796 struct groupchat *b = NULL; 816 797 GSList *l; 817 818 for( l = inv->ic->groupchats; l; l = l->next ) 819 { 798 799 for (l = inv->ic->groupchats; l; l = l->next) { 820 800 b = l->data; 821 if ( b == inv->c )801 if (b == inv->c) { 822 802 break; 823 } 824 825 if( b != NULL ) 826 { 827 yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name ); 828 imcb_chat_add_buddy( inv->c, inv->ic->acc->user ); 829 } 830 else 831 { 832 imcb_log( inv->ic, "Duplicate/corrupted invitation to `%s'.", inv->name ); 833 } 834 835 g_free( inv->name ); 836 g_free( inv ); 837 } 838 839 static void byahoo_reject_conf( void *data ) 803 } 804 } 805 806 if (b != NULL) { 807 yahoo_conference_logon(inv->yid, NULL, inv->members, inv->name); 808 imcb_chat_add_buddy(inv->c, inv->ic->acc->user); 809 } else { 810 imcb_log(inv->ic, "Duplicate/corrupted invitation to `%s'.", inv->name); 811 } 812 813 g_free(inv->name); 814 g_free(inv); 815 } 816 817 static void byahoo_reject_conf(void *data) 840 818 { 841 819 struct byahoo_conf_invitation *inv = data; 842 843 yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat");844 imcb_chat_free( inv->c);845 g_free( inv->name);846 g_free( inv);847 } 848 849 void ext_yahoo_got_conf_invite( 850 const char *who, const char *room, const char *msg, YList *members)851 { 852 struct im_connection *ic = byahoo_get_ic_by_id( id);820 821 yahoo_conference_decline(inv->yid, NULL, inv->members, inv->name, "User rejected groupchat"); 822 imcb_chat_free(inv->c); 823 g_free(inv->name); 824 g_free(inv); 825 } 826 827 void ext_yahoo_got_conf_invite(int id, const char *ignored, 828 const char *who, const char *room, const char *msg, YList *members) 829 { 830 struct im_connection *ic = byahoo_get_ic_by_id(id); 853 831 struct byahoo_conf_invitation *inv; 854 832 char txt[1024]; 855 833 YList *m; 856 857 if ( g_strcasecmp( who, ic->acc->user ) == 0 )834 835 if (g_strcasecmp(who, ic->acc->user) == 0) { 858 836 /* WTF, Yahoo! seems to echo these now? */ 859 837 return; 860 861 inv = g_malloc( sizeof( struct byahoo_conf_invitation ) ); 862 memset( inv, 0, sizeof( struct byahoo_conf_invitation ) ); 863 inv->name = g_strdup( room ); 864 inv->c = imcb_chat_new( ic, (char*) room ); 838 } 839 840 inv = g_malloc(sizeof(struct byahoo_conf_invitation)); 841 memset(inv, 0, sizeof(struct byahoo_conf_invitation)); 842 inv->name = g_strdup(room); 843 inv->c = imcb_chat_new(ic, (char *) room); 865 844 inv->c->data = members; 866 845 inv->yid = id; 867 846 inv->members = members; 868 847 inv->ic = ic; 869 870 for( m = members; m; m = m->next ) 871 if( g_strcasecmp( m->data, ic->acc->user ) != 0 ) 872 imcb_chat_add_buddy( inv->c, m->data ); 873 874 g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg ); 875 876 imcb_ask( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf ); 877 } 878 879 void ext_yahoo_conf_userdecline( int id, const char *ignored, const char *who, const char *room, const char *msg ) 880 { 881 struct im_connection *ic = byahoo_get_ic_by_id( id ); 882 883 imcb_log( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); 884 } 885 886 void ext_yahoo_conf_userjoin( int id, const char *ignored, const char *who, const char *room ) 887 { 888 struct im_connection *ic = byahoo_get_ic_by_id( id ); 889 struct groupchat *c = bee_chat_by_title( ic->bee, ic, room ); 890 891 if( c ) 892 imcb_chat_add_buddy( c, (char*) who ); 893 } 894 895 void ext_yahoo_conf_userleave( int id, const char *ignored, const char *who, const char *room ) 896 897 { 898 struct im_connection *ic = byahoo_get_ic_by_id( id ); 899 struct groupchat *c = bee_chat_by_title( ic->bee, ic, room ); 900 901 if( c ) 902 imcb_chat_remove_buddy( c, (char*) who, "" ); 903 } 904 905 void ext_yahoo_conf_message( int id, const char *ignored, const char *who, const char *room, const char *msg, int utf8 ) 906 { 907 struct im_connection *ic = byahoo_get_ic_by_id( id ); 908 char *m = byahoo_strip( msg ); 909 struct groupchat *c = bee_chat_by_title( ic->bee, ic, room ); 910 911 if( c ) 912 imcb_chat_msg( c, (char*) who, (char*) m, 0, 0 ); 913 g_free( m ); 914 } 915 916 void ext_yahoo_chat_cat_xml( int id, const char *xml ) 917 { 918 } 919 920 void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, void *fd ) 921 { 922 } 923 924 void ext_yahoo_chat_userjoin( int id, const char *me, const char *room, struct yahoo_chat_member *who ) 848 849 for (m = members; m; m = m->next) { 850 if (g_strcasecmp(m->data, ic->acc->user) != 0) { 851 imcb_chat_add_buddy(inv->c, m->data); 852 } 853 } 854 855 g_snprintf(txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg); 856 857 imcb_ask(ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf); 858 } 859 860 void ext_yahoo_conf_userdecline(int id, const char *ignored, const char *who, const char *room, const char *msg) 861 { 862 struct im_connection *ic = byahoo_get_ic_by_id(id); 863 864 imcb_log(ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg); 865 } 866 867 void ext_yahoo_conf_userjoin(int id, const char *ignored, const char *who, const char *room) 868 { 869 struct im_connection *ic = byahoo_get_ic_by_id(id); 870 struct groupchat *c = bee_chat_by_title(ic->bee, ic, room); 871 872 if (c) { 873 imcb_chat_add_buddy(c, (char *) who); 874 } 875 } 876 877 void ext_yahoo_conf_userleave(int id, const char *ignored, const char *who, const char *room) 878 879 { 880 struct im_connection *ic = byahoo_get_ic_by_id(id); 881 struct groupchat *c = bee_chat_by_title(ic->bee, ic, room); 882 883 if (c) { 884 imcb_chat_remove_buddy(c, (char *) who, ""); 885 } 886 } 887 888 void ext_yahoo_conf_message(int id, const char *ignored, const char *who, const char *room, const char *msg, int utf8) 889 { 890 struct im_connection *ic = byahoo_get_ic_by_id(id); 891 char *m = byahoo_strip(msg); 892 struct groupchat *c = bee_chat_by_title(ic->bee, ic, room); 893 894 if (c) { 895 imcb_chat_msg(c, (char *) who, (char *) m, 0, 0); 896 } 897 g_free(m); 898 } 899 900 void ext_yahoo_chat_cat_xml(int id, const char *xml) 901 { 902 } 903 904 void ext_yahoo_chat_join(int id, const char *who, const char *room, const char *topic, YList *members, void *fd) 905 { 906 } 907 908 void ext_yahoo_chat_userjoin(int id, const char *me, const char *room, struct yahoo_chat_member *who) 925 909 { 926 910 free(who->id); 927 911 free(who->alias); 928 912 free(who->location); 929 free(who); 930 } 931 932 void ext_yahoo_chat_userleave( int id, const char *me, const char *room, const char *who ) 933 { 934 } 935 936 void ext_yahoo_chat_message( int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8 ) 937 { 938 } 939 940 void ext_yahoo_chat_yahoologout( int id, const char *me ) 941 { 942 } 943 944 void ext_yahoo_chat_yahooerror( int id, const char *me ) 945 { 946 } 947 948 void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg ) 949 { 950 struct im_connection *ic = byahoo_get_ic_by_id( id ); 951 952 imcb_ask_auth( ic, who, msg ); 953 } 954 955 void ext_yahoo_rejected( int id, const char *who, const char *msg ) 956 { 957 } 958 959 void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat, const char *msg ) 960 { 961 } 962 963 void ext_yahoo_mail_notify( int id, const char *from, const char *subj, int cnt ) 964 { 965 struct im_connection *ic = byahoo_get_ic_by_id( id ); 966 967 if( !set_getbool( &ic->acc->set, "mail_notifications" ) ) 913 free(who); 914 } 915 916 void ext_yahoo_chat_userleave(int id, const char *me, const char *room, const char *who) 917 { 918 } 919 920 void ext_yahoo_chat_message(int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, 921 int utf8) 922 { 923 } 924 925 void ext_yahoo_chat_yahoologout(int id, const char *me) 926 { 927 } 928 929 void ext_yahoo_chat_yahooerror(int id, const char *me) 930 { 931 } 932 933 void ext_yahoo_contact_added(int id, const char *myid, const char *who, const char *msg) 934 { 935 struct im_connection *ic = byahoo_get_ic_by_id(id); 936 937 imcb_ask_auth(ic, who, msg); 938 } 939 940 void ext_yahoo_rejected(int id, const char *who, const char *msg) 941 { 942 } 943 944 void ext_yahoo_game_notify(int id, const char *me, const char *who, int stat, const char *msg) 945 { 946 } 947 948 void ext_yahoo_mail_notify(int id, const char *from, const char *subj, int cnt) 949 { 950 struct im_connection *ic = byahoo_get_ic_by_id(id); 951 952 if (!set_getbool(&ic->acc->set, "mail_notifications")) { 968 953 ; /* The user doesn't care. */ 969 else if( from && subj ) 970 imcb_log( ic, "Received e-mail message from %s with subject `%s'", from, subj ); 971 else if( cnt > 0 ) 972 imcb_log( ic, "Received %d new e-mails", cnt ); 973 } 974 975 void ext_yahoo_webcam_invite_reply( int id, const char *me, const char *from, int accept ) 976 { 977 } 978 979 void ext_yahoo_webcam_closed( int id, const char *who, int reason ) 980 { 981 } 982 983 void ext_yahoo_got_search_result( int id, int found, int start, int total, YList *contacts ) 984 { 985 } 986 987 void ext_yahoo_webcam_viewer( int id, const char *who, int connect ) 988 { 989 } 990 991 void ext_yahoo_webcam_data_request( int id, int send ) 992 { 993 } 994 995 int ext_yahoo_log( const char *fmt, ... ) 996 { 997 return( 0 ); 998 } 999 1000 void ext_yahoo_got_webcam_image( int id, const char * who, const unsigned char *image, unsigned int image_size, unsigned int real_size, unsigned int timestamp ) 1001 { 1002 } 1003 1004 void ext_yahoo_got_ping( int id, const char *msg ) 1005 { 1006 } 1007 1008 void ext_yahoo_got_buddyicon (int id, const char *me, const char *who, const char *url, int checksum) {} 1009 void ext_yahoo_got_buddyicon_checksum (int id, const char *me,const char *who, int checksum) {} 1010 1011 void ext_yahoo_got_buddyicon_request(int id, const char *me, const char *who){} 1012 void ext_yahoo_buddyicon_uploaded(int id, const char *url){} 954 } else if (from && subj) { 955 imcb_log(ic, "Received e-mail message from %s with subject `%s'", from, subj); 956 } else if (cnt > 0) { 957 imcb_log(ic, "Received %d new e-mails", cnt); 958 } 959 } 960 961 void ext_yahoo_webcam_invite_reply(int id, const char *me, const char *from, int accept) 962 { 963 } 964 965 void ext_yahoo_webcam_closed(int id, const char *who, int reason) 966 { 967 } 968 969 void ext_yahoo_got_search_result(int id, int found, int start, int total, YList *contacts) 970 { 971 } 972 973 void ext_yahoo_webcam_viewer(int id, const char *who, int connect) 974 { 975 } 976 977 void ext_yahoo_webcam_data_request(int id, int send) 978 { 979 } 980 981 int ext_yahoo_log(const char *fmt, ...) 982 { 983 return(0); 984 } 985 986 void ext_yahoo_got_webcam_image(int id, const char * who, const unsigned char *image, unsigned int image_size, 987 unsigned int real_size, unsigned int timestamp) 988 { 989 } 990 991 void ext_yahoo_got_ping(int id, const char *msg) 992 { 993 } 994 995 void ext_yahoo_got_buddyicon(int id, const char *me, const char *who, const char *url, int checksum) 996 { 997 } 998 void ext_yahoo_got_buddyicon_checksum(int id, const char *me, const char *who, int checksum) 999 { 1000 } 1001 1002 void ext_yahoo_got_buddyicon_request(int id, const char *me, const char *who) 1003 { 1004 } 1005 void ext_yahoo_buddyicon_uploaded(int id, const char *url) 1006 { 1007 } -
protocols/yahoo/yahoo2.h
raf359b4 r5ebff60 30 30 #include "bitlbee.h" 31 31 #undef free 32 #define free( x ) g_free( x)32 #define free(x) g_free(x) 33 33 #undef malloc 34 #define malloc( x ) g_malloc( x)34 #define malloc(x) g_malloc(x) 35 35 #undef calloc 36 #define calloc( x, y ) g_calloc( x, y)36 #define calloc(x, y) g_calloc(x, y) 37 37 #undef realloc 38 #define realloc( x, y ) g_realloc( x, y)38 #define realloc(x, y) g_realloc(x, y) 39 39 #undef strdup 40 #define strdup( x ) g_strdup( x)40 #define strdup(x) g_strdup(x) 41 41 #undef strndup 42 #define strndup( x,y ) g_strndup( x,y)42 #define strndup(x, y) g_strndup(x, y) 43 43 #undef snprintf 44 44 // #define snprintf( x... ) g_snprintf( x ) 45 45 #undef strcasecmp 46 #define strcasecmp( x,y ) g_strcasecmp( x,y)46 #define strcasecmp(x, y) g_strcasecmp(x, y) 47 47 #undef strncasecmp 48 #define strncasecmp( x,y,z ) g_strncasecmp( x,y,z)48 #define strncasecmp(x, y, z) g_strncasecmp(x, y, z) 49 49 50 50 … … 52 52 53 53 /* returns the socket descriptor object for a given pager connection. shouldn't be needed */ 54 54 void *yahoo_get_fd(int id); 55 55 56 56 /* says how much logging to do */ 57 57 /* see yahoo2_types.h for the different values */ 58 59 58 int yahoo_set_log_level(enum yahoo_log_level level); 59 enum yahoo_log_level yahoo_get_log_level(void); 60 60 61 61 /* these functions should be self explanatory */ … … 67 67 /* you must call init before calling any other function */ 68 68 /* 69 * The optional parameters to init are key/value pairs that specify 69 * The optional parameters to init are key/value pairs that specify 70 70 * server settings to use. This list must be NULL terminated - even 71 71 * if the list is empty. If a parameter isn't set, a default value … … 74 74 * are copied, so you can use const/auto/static/pointers/whatever 75 75 * you want. Parameters are: 76 * 76 * NAME TYPE DEFAULT 77 77 * pager_host char * scs.msg.yahoo.com 78 78 * pager_port int 5050 … … 87 87 * You should set at least local_host if you intend to use webcams 88 88 */ 89 90 89 int yahoo_init_with_attributes(const char *username, 90 const char *password, ...); 91 91 92 92 /* yahoo_init does the same as yahoo_init_with_attributes, assuming defaults 93 93 * for all attributes */ 94 94 int yahoo_init(const char *username, const char *password); 95 95 96 96 /* release all resources held by this session */ 97 97 /* you need to call yahoo_close for a session only if 98 98 * yahoo_logoff is never called for it (ie, it was never logged in) */ 99 99 void yahoo_close(int id); 100 100 /* login logs in to the server */ 101 101 /* initial is of type enum yahoo_status. see yahoo2_types.h */ 102 103 102 void yahoo_login(int id, int initial); 103 void yahoo_logoff(int id); 104 104 /* reloads status of all buddies */ 105 105 void yahoo_refresh(int id); 106 106 /* activates/deactivates an identity */ 107 108 107 void yahoo_set_identity_status(int id, const char *identity, 108 int active); 109 109 /* regets the entire buddy list from the server */ 110 110 void yahoo_get_list(int id); 111 111 /* download buddy contact information from your yahoo addressbook */ 112 112 void yahoo_get_yab(int id); 113 113 /* add/modify an address book entry. if yab->dbid is set, it will */ 114 114 /* modify that entry else it creates a new entry */ 115 116 117 115 void yahoo_set_yab(int id, struct yab *yab); 116 void yahoo_keepalive(int id); 117 void yahoo_chat_keepalive(int id); 118 118 119 119 /* from is the identity you're sending from. if NULL, the default is used */ 120 120 /* utf8 is whether msg is a utf8 string or not. */ 121 122 121 void yahoo_send_im(int id, const char *from, const char *who, 122 const char *msg, int utf8, int picture); 123 123 // void yahoo_send_buzz(int id, const char *from, const char *who); 124 124 /* if type is true, send typing notice, else send stopped typing notice */ 125 126 125 void yahoo_send_typing(int id, const char *from, const char *who, 126 int typ); 127 127 128 128 /* used to set away/back status. */ 129 129 /* away says whether the custom message is an away message or a sig */ 130 131 132 133 134 135 136 137 138 130 void yahoo_set_away(int id, enum yahoo_status state, const char *msg, 131 int away); 132 133 void yahoo_add_buddy(int id, const char *who, const char *group, 134 const char *msg); 135 void yahoo_remove_buddy(int id, const char *who, const char *group); 136 void yahoo_confirm_buddy(int id, const char *who, int reject, 137 const char *msg); 138 void yahoo_stealth_buddy(int id, const char *who, int unstealth); 139 139 /* if unignore is true, unignore, else ignore */ 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 140 void yahoo_ignore_buddy(int id, const char *who, int unignore); 141 void yahoo_change_buddy_group(int id, const char *who, 142 const char *old_group, const char *new_group); 143 void yahoo_group_rename(int id, const char *old_group, 144 const char *new_group); 145 146 void yahoo_conference_invite(int id, const char *from, YList *who, 147 const char *room, const char *msg); 148 void yahoo_conference_addinvite(int id, const char *from, 149 const char *who, const char *room, const YList *members, 150 const char *msg); 151 void yahoo_conference_decline(int id, const char *from, YList *who, 152 const char *room, const char *msg); 153 void yahoo_conference_message(int id, const char *from, YList *who, 154 const char *room, const char *msg, int utf8); 155 void yahoo_conference_logon(int id, const char *from, YList *who, 156 const char *room); 157 void yahoo_conference_logoff(int id, const char *from, YList *who, 158 const char *room); 159 159 160 160 /* Get a list of chatrooms */ 161 161 void yahoo_get_chatrooms(int id, int chatroomid); 162 162 /* join room with specified roomname and roomid */ 163 164 163 void yahoo_chat_logon(int id, const char *from, const char *room, 164 const char *roomid); 165 165 /* Send message "msg" to room with specified roomname, msgtype is 1-normal message or 2-/me mesage */ 166 167 166 void yahoo_chat_message(int id, const char *from, const char *room, 167 const char *msg, const int msgtype, const int utf8); 168 168 /* Log off chat */ 169 169 void yahoo_chat_logoff(int id, const char *from); 170 170 171 171 /* requests a webcam feed */ 172 172 /* who is the person who's webcam you would like to view */ 173 173 /* if who is null, then you're the broadcaster */ 174 175 174 void yahoo_webcam_get_feed(int id, const char *who); 175 void yahoo_webcam_close_feed(int id, const char *who); 176 176 177 177 /* sends an image when uploading */ … … 179 179 /* in bytes. The timestamp is the time in milliseconds since we started the */ 180 180 /* webcam. */ 181 182 181 void yahoo_webcam_send_image(int id, unsigned char *image, 182 unsigned int length, unsigned int timestamp); 183 183 184 184 /* this function should be called if we want to allow a user to watch the */ 185 185 /* webcam. Who is the user we want to accept. */ 186 186 /* Accept user (accept = 1), decline user (accept = 0) */ 187 187 void yahoo_webcam_accept_viewer(int id, const char *who, int accept); 188 188 189 189 /* send an invitation to a user to view your webcam */ 190 190 void yahoo_webcam_invite(int id, const char *who); 191 191 192 192 /* will set up a connection and initiate file transfer. … … 194 194 * the file data to 195 195 */ 196 197 198 196 void yahoo_send_file(int id, const char *who, const char *msg, 197 const char *name, unsigned long size, 198 yahoo_get_fd_callback callback, void *data); 199 199 200 200 /* … … 202 202 * since that is your only chance to recognize future callbacks 203 203 */ 204 205 204 void yahoo_send_file_transfer_response(int client_id, int response, 205 char *id, void *data); 206 206 207 207 208 208 /* send a search request 209 209 */ 210 211 212 210 void yahoo_search(int id, enum yahoo_search_type t, const char *text, 211 enum yahoo_search_gender g, enum yahoo_search_agerange ar, 212 int photo, int yahoo_only); 213 213 214 214 /* continue last search … … 217 217 * where the above three are passed to ext_yahoo_got_search_result 218 218 */ 219 219 void yahoo_search_again(int id, int start); 220 220 221 221 /* these should be called when input is available on a fd */ 222 222 /* registered by ext_yahoo_add_handler */ 223 223 /* if these return negative values, errno may be set */ 224 225 224 int yahoo_read_ready(int id, void *fd, void *data); 225 int yahoo_write_ready(int id, void *fd, void *data); 226 226 227 227 /* utility functions. these do not hit the server */ 228 229 230 231 228 enum yahoo_status yahoo_current_status(int id); 229 const YList *yahoo_get_buddylist(int id); 230 const YList *yahoo_get_ignorelist(int id); 231 const YList *yahoo_get_identities(int id); 232 232 /* 'which' could be y, t, c or login. This may change in later versions. */ 233 233 const char *yahoo_get_cookie(int id, const char *which); 234 234 235 235 /* returns the url used to get user profiles - you must append the user id */ 236 236 /* as of now this is http://profiles.yahoo.com/ */ 237 237 /* You'll have to do urlencoding yourself, but see yahoo_httplib.h first */ 238 239 240 238 const char *yahoo_get_profile_url(void); 239 240 void yahoo_buddyicon_request(int id, const char *who); 241 241 242 242 #include "yahoo_httplib.h" -
protocols/yahoo/yahoo2_callbacks.h
raf359b4 r5ebff60 45 45 */ 46 46 47 48 49 50 51 47 typedef enum { 48 YAHOO_INPUT_READ = 1 << 0, 49 YAHOO_INPUT_WRITE = 1 << 1, 50 YAHOO_INPUT_EXCEPTION = 1 << 2 51 } yahoo_input_condition; 52 52 53 53 /* 54 54 * A callback function called when an asynchronous connect completes. 55 * 56 * Params: 57 * fd - The file descriptor object that has been connected, or NULL on 55 * 56 * Params: 57 * fd - The file descriptor object that has been connected, or NULL on 58 58 * error 59 59 * error - The value of errno set by the call to connect or 0 if no error … … 63 63 * function 64 64 */ 65 66 65 typedef void (*yahoo_connect_callback) (void *fd, int error, 66 void *callback_data); 67 67 68 68 /* … … 72 72 */ 73 73 74 /* 74 /* 75 75 * should we use a callback structure or directly call functions 76 76 * if you want the structure, you *must* define USE_STRUCT_CALLBACKS … … 80 80 81 81 #ifdef USE_STRUCT_CALLBACKS 82 #define YAHOO_CALLBACK_TYPE(x) 82 #define YAHOO_CALLBACK_TYPE(x) (*x) 83 83 struct yahoo_callbacks { 84 84 #else 85 #define YAHOO_CALLBACK_TYPE(x) 85 #define YAHOO_CALLBACK_TYPE(x) x 86 86 #endif 87 87 88 88 /* 89 89 * Name: ext_yahoo_login_response 90 * 91 * Params: 92 * 93 * 94 * 90 * Called when the login process is complete 91 * Params: 92 * id - the id that identifies the server connection 93 * succ - enum yahoo_login_status 94 * url - url to reactivate account if locked 95 95 */ 96 96 void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response) (int id, int succ, 97 97 const char *url); 98 98 99 99 /* 100 100 * Name: ext_yahoo_got_buddies 101 * 102 * Params: 103 * 104 * 101 * Called when the contact list is got from the server 102 * Params: 103 * id - the id that identifies the server connection 104 * buds - the buddy list 105 105 */ 106 106 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies) (int id, YList *buds); … … 108 108 /* 109 109 * Name: ext_yahoo_got_ignore 110 * 111 * Params: 112 * 113 * 110 * Called when the ignore list is got from the server 111 * Params: 112 * id - the id that identifies the server connection 113 * igns - the ignore list 114 114 */ 115 115 // void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore) (int id, YList *igns); … … 117 117 /* 118 118 * Name: ext_yahoo_got_identities 119 * 120 * Params: 121 * 122 * 119 * Called when the contact list is got from the server 120 * Params: 121 * id - the id that identifies the server connection 122 * ids - the identity list 123 123 */ 124 124 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities) (int id, YList *ids); … … 126 126 /* 127 127 * Name: ext_yahoo_got_cookies 128 * 129 * Params: 130 * 128 * Called when the cookie list is got from the server 129 * Params: 130 * id - the id that identifies the server connection 131 131 */ 132 132 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies) (int id); … … 134 134 /* 135 135 * Name: ext_yahoo_got_ping 136 * 137 * Params: 138 * 136 * Called when the ping packet is received from the server 137 * Params: 138 * id - the id that identifies the server connection 139 139 * errormsg - optional error message 140 140 */ 141 141 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping) (int id, 142 142 const char *errormsg); 143 143 144 144 /* 145 145 * Name: ext_yahoo_status_changed 146 * 147 * Params: 148 * 149 * 150 * 151 * 152 * 153 * 146 * Called when remote user's status changes. 147 * Params: 148 * id - the id that identifies the server connection 149 * who - the handle of the remote user 150 * stat - status code (enum yahoo_status) 151 * msg - the message if stat == YAHOO_STATUS_CUSTOM 152 * away - whether the contact is away or not (YAHOO_STATUS_CUSTOM) 153 * idle - this is the number of seconds he is idle [if he is idle] 154 154 * mobile - this is set for mobile users/buddies 155 155 * TODO: add support for pager, chat, and game states 156 156 */ 157 157 void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed) (int id, 158 const char *who, int stat, const char *msg, int away, int idle, 159 int mobile); 158 const char *who, int stat, const char *msg, int away, 159 int idle, 160 int mobile); 160 161 161 162 /* 162 163 * Name: ext_yahoo_got_buzz 163 * 164 * Params: 165 * 166 * 167 * 168 * 164 * Called when remote user sends you a buzz. 165 * Params: 166 * id - the id that identifies the server connection 167 * me - the identity the message was sent to 168 * who - the handle of the remote user 169 * tm - timestamp of message if offline 169 170 */ 170 171 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buzz) (int id, const char *me, 171 172 const char *who, long tm); 172 173 173 174 /* 174 175 * Name: ext_yahoo_got_im 175 * 176 * Params: 177 * 178 * 179 * 180 * 181 * 182 * 183 * 184 * 185 * 186 * 176 * Called when remote user sends you a message. 177 * Params: 178 * id - the id that identifies the server connection 179 * me - the identity the message was sent to 180 * who - the handle of the remote user 181 * msg - the message - NULL if stat == 2 182 * tm - timestamp of message if offline 183 * stat - message status - 0 184 * 1 185 * 2 == error sending message 186 * 5 187 * utf8 - whether the message is encoded as utf8 or not 187 188 */ 188 189 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im) (int id, const char *me, 189 190 const char *who, const char *msg, long tm, int stat, int utf8); 190 191 191 192 /* 192 193 * Name: ext_yahoo_got_conf_invite 193 * 194 * Params: 195 * 196 * 197 * 198 * 199 * 194 * Called when remote user sends you a conference invitation. 195 * Params: 196 * id - the id that identifies the server connection 197 * me - the identity the invitation was sent to 198 * who - the user inviting you 199 * room - the room to join 200 * msg - the message 200 201 * members - the initial members of the conference (null terminated list) 201 202 */ 202 203 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite) (int id, 203 204 204 const char *me, const char *who, const char *room, 205 const char *msg, YList *members); 205 206 206 207 /* 207 208 * Name: ext_yahoo_conf_userdecline 208 * 209 * Params: 210 * 211 * 212 * 213 * 214 * 209 * Called when someone declines to join the conference. 210 * Params: 211 * id - the id that identifies the server connection 212 * me - the identity in the conference 213 * who - the user who has declined 214 * room - the room 215 * msg - the declining message 215 216 */ 216 217 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline) (int id, 217 218 218 const char *me, const char *who, const char *room, 219 const char *msg); 219 220 220 221 /* 221 222 * Name: ext_yahoo_conf_userjoin 222 * 223 * Params: 224 * 225 * 226 * 227 * 223 * Called when someone joins the conference. 224 * Params: 225 * id - the id that identifies the server connection 226 * me - the identity in the conference 227 * who - the user who has joined 228 * room - the room joined 228 229 */ 229 230 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin) (int id, 230 231 const char *me, const char *who, const char *room); 231 232 232 233 /* 233 234 * Name: ext_yahoo_conf_userleave 234 * 235 * Params: 236 * 237 * 238 * 239 * 235 * Called when someone leaves the conference. 236 * Params: 237 * id - the id that identifies the server connection 238 * me - the identity in the conference 239 * who - the user who has left 240 * room - the room left 240 241 */ 241 242 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave) (int id, 242 243 const char *me, const char *who, const char *room); 243 244 244 245 /* 245 246 * Name: ext_yahoo_chat_cat_xml 246 * 247 * Params: 248 * 249 * 247 * Called when ? 248 * Params: 249 * id - the id that identifies the server connection 250 * xml - ? 250 251 */ 251 252 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml) (int id, 252 253 const char *xml); 253 254 254 255 /* 255 256 * Name: ext_yahoo_chat_join 256 * 257 * Params: 258 * 259 * 260 * room - the room joined, used in all other chat calls, freed by261 * 262 * 263 * members - the initial members of the chatroom (null terminated YList 257 * Called when joining the chatroom. 258 * Params: 259 * id - the id that identifies the server connection 260 * me - the identity in the chatroom 261 * room - the room joined, used in all other chat calls, freed by 262 * library after call 263 * topic - the topic of the room, freed by library after call 264 * members - the initial members of the chatroom (null terminated YList 264 265 * of yahoo_chat_member's) Must be freed by the client 265 266 * fd - the object where the connection is coming from (for tracking) 266 267 */ 267 268 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join) (int id, const char *me, 268 269 const char *room, const char *topic, YList *members, void *fd); 269 270 270 271 /* 271 272 * Name: ext_yahoo_chat_userjoin 272 * 273 * Params: 274 * 275 * 276 * 277 * 273 * Called when someone joins the chatroom. 274 * Params: 275 * id - the id that identifies the server connection 276 * me - the identity in the chatroom 277 * room - the room joined 278 * who - the user who has joined, Must be freed by the client 278 279 */ 279 280 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin) (int id, 280 281 281 const char *me, const char *room, 282 struct yahoo_chat_member *who); 282 283 283 284 /* 284 285 * Name: ext_yahoo_chat_userleave 285 * 286 * Params: 287 * 288 * 289 * 290 * 286 * Called when someone leaves the chatroom. 287 * Params: 288 * id - the id that identifies the server connection 289 * me - the identity in the chatroom 290 * room - the room left 291 * who - the user who has left (Just the User ID) 291 292 */ 292 293 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave) (int id, 293 294 const char *me, const char *room, const char *who); 294 295 295 296 /* 296 297 * Name: ext_yahoo_chat_message 297 * 298 * Params: 299 * 300 * 301 * 302 * 303 * 304 * 305 * 306 * 298 * Called when someone messages in the chatroom. 299 * Params: 300 * id - the id that identifies the server connection 301 * me - the identity in the chatroom 302 * room - the room 303 * who - the user who messaged (Just the user id) 304 * msg - the message 305 * msgtype - 1 = Normal message 306 * 2 = /me type message 307 * utf8 - whether the message is utf8 encoded or not 307 308 */ 308 309 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message) (int id, 309 310 310 const char *me, const char *who, const char *room, 311 const char *msg, int msgtype, int utf8); 311 312 312 313 /* … … 315 316 * called when yahoo disconnects your chat session 316 317 * Note this is called whenver a disconnect happens, client or server 317 * requested. Care should be taken to make sure you know the origin 318 * requested. Care should be taken to make sure you know the origin 318 319 * of the disconnect request before doing anything here (auto-join's etc) 319 320 * Params: 320 321 * id - the id that identifies this connection 321 * 322 * me - the identity in the chatroom 322 323 * Returns: 323 324 * nothing. 324 325 */ 325 326 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout) (int id, 326 327 const char *me); 327 328 328 329 /* … … 332 333 * Note this is called whenver chat message is sent into a room 333 334 * in error (fd not connected, room doesn't exists etc) 334 * Care should be taken to make sure you know the origin 335 * Care should be taken to make sure you know the origin 335 336 * of the error before doing anything about it. 336 337 * Params: 337 338 * id - the id that identifies this connection 338 * 339 * me - the identity in the chatroom 339 340 * Returns: 340 341 * nothing. 341 342 */ 342 343 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror) (int id, 343 344 const char *me); 344 345 345 346 /* 346 347 * Name: ext_yahoo_conf_message 347 * 348 * Params: 349 * 350 * 351 * 352 * 353 * 354 * 348 * Called when someone messages in the conference. 349 * Params: 350 * id - the id that identifies the server connection 351 * me - the identity the conf message was sent to 352 * who - the user who messaged 353 * room - the room 354 * msg - the message 355 * utf8 - whether the message is utf8 encoded or not 355 356 */ 356 357 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message) (int id, 357 358 358 const char *me, const char *who, const char *room, 359 const char *msg, int utf8); 359 360 360 361 /* 361 362 * Name: ext_yahoo_got_file 362 * 363 * Params: 364 * 365 * 366 * 367 * 368 * 369 * 370 * 363 * Called when someone sends you a file 364 * Params: 365 * id - the id that identifies the server connection 366 * me - the identity the file was sent to 367 * who - the user who sent the file 368 * msg - the message 369 * fname- the file name if direct transfer 370 * fsize- the file size if direct transfer 371 * trid - transfer id. Unique for this transfer 371 372 * 372 373 * NOTE: Subsequent callbacks for file transfer do not send all of this … … 376 377 */ 377 378 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file) (int id, const char *me, 378 379 379 const char *who, const char *msg, const char *fname, 380 unsigned long fesize, char *trid); 380 381 381 382 /* 382 383 * Name: ext_yahoo_got_ft_data 383 * 384 * Params: 385 * 386 * 387 * 388 * 384 * Called multiple times when parts of the file are received 385 * Params: 386 * id - the id that identifies the server connection 387 * in - The data 388 * len - Length of the data 389 * data - callback data 389 390 */ 390 391 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ft_data) (int id, 391 392 const unsigned char *in, int len, void *data); 392 393 393 394 /* 394 395 * Name: ext_yahoo_file_transfer_done 395 * 396 * Params: 397 * 398 * 399 * 396 * File transfer is done 397 * Params: 398 * id - the id that identifies the server connection 399 * result - To notify if it finished successfully or with a failure 400 * data - callback data 400 401 */ 401 402 void YAHOO_CALLBACK_TYPE(ext_yahoo_file_transfer_done) (int id, 402 403 int result, void *data); 403 404 404 405 /* 405 406 * Name: ext_yahoo_contact_added 406 * 407 * Params: 408 * 409 * 410 * 411 * 407 * Called when a contact is added to your list 408 * Params: 409 * id - the id that identifies the server connection 410 * myid - the identity he was added to 411 * who - who was added 412 * msg - any message sent 412 413 */ 413 414 void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added) (int id, 414 415 const char *myid, const char *who, const char *msg); 415 416 416 417 /* 417 418 * Name: ext_yahoo_rejected 418 * 419 * Params: 420 * 421 * 422 * 419 * Called when a contact rejects your add 420 * Params: 421 * id - the id that identifies the server connection 422 * who - who rejected you 423 * msg - any message sent 423 424 */ 424 425 void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected) (int id, const char *who, 425 426 const char *msg); 426 427 427 428 /* 428 429 * Name: ext_yahoo_typing_notify 429 * 430 * Params: 431 * 432 * 433 * 434 * 430 * Called when remote user starts or stops typing. 431 * Params: 432 * id - the id that identifies the server connection 433 * me - the handle of the identity the notification is sent to 434 * who - the handle of the remote user 435 * stat - 1 if typing, 0 if stopped typing 435 436 */ 436 437 void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify) (int id, 437 438 const char *me, const char *who, int stat); 438 439 439 440 /* 440 441 * Name: ext_yahoo_game_notify 441 * 442 * Params: 443 * 444 * 445 * 446 * 447 * 442 * Called when remote user starts or stops a game. 443 * Params: 444 * id - the id that identifies the server connection 445 * me - the handle of the identity the notification is sent to 446 * who - the handle of the remote user 447 * stat - 1 if game, 0 if stopped gaming 448 * msg - game description and/or other text 448 449 */ 449 450 void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify) (int id, const char *me, 450 451 const char *who, int stat, const char *msg); 451 452 452 453 /* 453 454 * Name: ext_yahoo_mail_notify 454 * 455 * Params: 456 * 457 * 458 * 459 * 455 * Called when you receive mail, or with number of messages 456 * Params: 457 * id - the id that identifies the server connection 458 * from - who the mail is from - NULL if only mail count 459 * subj - the subject of the mail - NULL if only mail count 460 * cnt - mail count - 0 if new mail notification 460 461 */ 461 462 void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify) (int id, 462 463 const char *from, const char *subj, int cnt); 463 464 464 465 /* 465 466 * Name: ext_yahoo_system_message 466 * 467 * Params: 468 * 469 * 470 * 471 * 467 * System message 468 * Params: 469 * id - the id that identifies the server connection 470 * me - the handle of the identity the notification is sent to 471 * who - the source of the system message (there are different types) 472 * msg - the message 472 473 */ 473 474 void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message) (int id, 474 475 const char *me, const char *who, const char *msg); 475 476 476 477 /* 477 478 * Name: ext_yahoo_got_buddyicon 478 * 479 * Params: 480 * 481 * 482 * 483 * 484 * 479 * Buddy icon received 480 * Params: 481 * id - the id that identifies the server connection 482 * me - the handle of the identity the notification is sent to 483 * who - the person the buddy icon is for 484 * url - the url to use to load the icon 485 * checksum - the checksum of the icon content 485 486 */ 486 487 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon) (int id, 487 const char *me, const char *who, const char *url, int checksum); 488 const char *me, const char *who, const char *url, 489 int checksum); 488 490 489 491 /* 490 492 * Name: ext_yahoo_got_buddyicon_checksum 491 * 492 * Params: 493 * 494 * 495 * 496 * 493 * Buddy icon checksum received 494 * Params: 495 * id - the id that identifies the server connection 496 * me - the handle of the identity the notification is sent to 497 * who - the yahoo id of the buddy icon checksum is for 498 * checksum - the checksum of the icon content 497 499 */ 498 500 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum) (int id, 499 501 const char *me, const char *who, int checksum); 500 502 501 503 /* 502 504 * Name: ext_yahoo_got_buddyicon_request 503 * 504 * Params: 505 * 506 * 507 * 505 * Buddy icon request received 506 * Params: 507 * id - the id that identifies the server connection 508 * me - the handle of the identity the notification is sent to 509 * who - the yahoo id of the buddy that requested the buddy icon 508 510 */ 509 511 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request) (int id, 510 512 const char *me, const char *who); 511 513 512 514 /* 513 515 * Name: ext_yahoo_got_buddyicon_request 514 * 515 * Params: 516 * 517 * 516 * Buddy icon request received 517 * Params: 518 * id - the id that identifies the server connection 519 * url - remote url, the uploaded buddy icon can be fetched from 518 520 */ 519 521 void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded) (int id, 520 522 const char *url); 521 523 522 524 /* 523 525 * Name: ext_yahoo_got_webcam_image 524 * 526 * Called when you get a webcam update 525 527 * An update can either be receiving an image, a part of an image or 526 528 * just an update with a timestamp 527 529 * Params: 528 * 529 * 530 * id - the id that identifies the server connection 531 * who - the user who's webcam we're viewing 530 532 * image - image data 531 533 * image_size - length of the image in bytes … … 544 546 */ 545 547 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_webcam_image) (int id, 546 547 548 548 const char *who, const unsigned char *image, 549 unsigned int image_size, unsigned int real_size, 550 unsigned int timestamp); 549 551 550 552 /* 551 553 * Name: ext_yahoo_webcam_invite 552 * 553 * Params: 554 * 555 * 556 * 554 * Called when you get a webcam invitation 555 * Params: 556 * id - the id that identifies the server connection 557 * me - identity the invitation is to 558 * from - who the invitation is from 557 559 */ 558 560 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite) (int id, 559 561 const char *me, const char *from); 560 562 561 563 /* 562 564 * Name: ext_yahoo_webcam_invite_reply 563 * 564 * Params: 565 * 566 * 567 * 565 * Called when you get a response to a webcam invitation 566 * Params: 567 * id - the id that identifies the server connection 568 * me - identity the invitation response is to 569 * from - who the invitation response is from 568 570 * accept - 0 (decline), 1 (accept) 569 571 */ 570 572 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply) (int id, 571 573 const char *me, const char *from, int accept); 572 574 573 575 /* 574 576 * Name: ext_yahoo_webcam_closed 575 * 576 * Params: 577 * 578 * 577 * Called when the webcam connection closed 578 * Params: 579 * id - the id that identifies the server connection 580 * who - the user who we where connected to 579 581 * reason - reason why the connection closed 580 582 * 1 = user stopped broadcasting … … 584 586 */ 585 587 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed) (int id, 586 588 const char *who, int reason); 587 589 588 590 /* … … 590 592 * Called when the search result received from server 591 593 * Params: 592 * id 593 * 594 * 595 * 596 * 597 * 598 * 594 * id - the id that identifies the server connection 595 * found - total number of results returned in the current result set 596 * start - offset from where the current result set starts 597 * total - total number of results available (start + found <= total) 598 * contacts - the list of results as a YList of yahoo_found_contact 599 * these will be freed after this function returns, so 600 * if you need to use the information, make a copy 599 601 */ 600 602 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result) (int id, 601 603 int found, int start, int total, YList *contacts); 602 604 603 605 /* 604 606 * Name: ext_yahoo_error 605 * 606 * Params: 607 * 608 * 609 * 610 * 607 * Called on error. 608 * Params: 609 * id - the id that identifies the server connection 610 * err - the error message 611 * fatal- whether this error is fatal to the connection or not 612 * num - Which error is this 611 613 */ 612 614 void YAHOO_CALLBACK_TYPE(ext_yahoo_error) (int id, const char *err, 613 615 int fatal, int num); 614 616 615 617 /* … … 622 624 */ 623 625 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer) (int id, 624 626 const char *who, int connect); 625 627 626 628 /* … … 632 634 */ 633 635 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request) (int id, 634 636 int send); 635 637 636 638 /* 637 639 * Name: ext_yahoo_log 638 * 639 * Params: 640 * 641 * Returns: 642 * 640 * Called to log a message. 641 * Params: 642 * fmt - the printf formatted message 643 * Returns: 644 * 0 643 645 */ 644 646 int YAHOO_CALLBACK_TYPE(ext_yahoo_log) (const char *fmt, ...); … … 646 648 /* 647 649 * Name: ext_yahoo_add_handler 648 * 649 * 650 * 651 * Params: 652 * 653 * 654 * 655 * 656 * 650 * Add a listener for the fd. Must call yahoo_read_ready 651 * when a YAHOO_INPUT_READ fd is ready and yahoo_write_ready 652 * when a YAHOO_INPUT_WRITE fd is ready. 653 * Params: 654 * id - the id that identifies the server connection 655 * fd - the fd object on which to listen 656 * cond - the condition on which to call the callback 657 * data - callback data to pass to yahoo_*_ready 658 * 657 659 * Returns: a tag to be used when removing the handler 658 660 */ 659 661 int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler) (int id, void *fd, 660 662 yahoo_input_condition cond, void *data); 661 663 662 664 /* 663 665 * Name: ext_yahoo_remove_handler 664 * 665 * Params: 666 * 667 * 666 * Remove the listener for the fd. 667 * Params: 668 * id - the id that identifies the connection 669 * tag - the handler tag to remove 668 670 */ 669 671 void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler) (int id, int tag); … … 671 673 /* 672 674 * Name: ext_yahoo_connect 673 * 674 * Params: 675 * 676 * 677 * Returns: 678 * 675 * Connect to a host:port 676 * Params: 677 * host - the host to connect to 678 * port - the port to connect on 679 * Returns: 680 * a unix file descriptor to the socket 679 681 */ 680 682 // int YAHOO_CALLBACK_TYPE(ext_yahoo_connect) (const char *host, int port); … … 682 684 /* 683 685 * Name: ext_yahoo_connect_async 684 * 685 * 686 * 687 * 688 * 689 * 690 * 691 * Params: 692 * 693 * 694 * 695 * 696 * 697 * 698 * Returns: 699 * 686 * Connect to a host:port asynchronously. This function should return 687 * immediately returing a tag used to identify the connection handler, 688 * or a pre-connect error (eg: host name lookup failure). 689 * Once the connect completes (successfully or unsuccessfully), callback 690 * should be called (see the signature for yahoo_connect_callback). 691 * The callback may safely be called before this function returns, but 692 * it should not be called twice. 693 * Params: 694 * id - the id that identifies this connection 695 * host - the host to connect to 696 * port - the port to connect on 697 * callback - function to call when connect completes 698 * callback_data - data to pass to the callback function 699 * use_ssl - Whether we need an SSL connection 700 * Returns: 701 * a tag signifying the connection attempt 700 702 */ 701 703 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async) (int id, 702 703 704 const char *host, int port, yahoo_connect_callback callback, 705 void *callback_data, int use_ssl); 704 706 705 707 /* 706 708 * Name: ext_yahoo_get_ip_addr 707 * 708 * Params: 709 * 710 * Returns: 711 * 709 * get IP Address for a domain name 710 * Params: 711 * domain - Domain name 712 * Returns: 713 * Newly allocated string containing the IP Address in IPv4 notation 712 714 */ 713 715 char *YAHOO_CALLBACK_TYPE(ext_yahoo_get_ip_addr) (const char *domain); … … 715 717 /* 716 718 * Name: ext_yahoo_write 717 * 718 * Params: 719 * 720 * 721 * 722 * Returns: 723 * 719 * Write data from the buffer into the socket for the specified connection 720 * Params: 721 * fd - the file descriptor object that identifies this connection 722 * buf - Buffer to write the data from 723 * len - Length of the data 724 * Returns: 725 * Number of bytes written or -1 for error 724 726 */ 725 727 int YAHOO_CALLBACK_TYPE(ext_yahoo_write) (void *fd, char *buf, int len); … … 727 729 /* 728 730 * Name: ext_yahoo_read 729 * 730 * Params: 731 * 732 * 733 * 734 * Returns: 735 * 731 * Read data into a buffer from socket for the specified connection 732 * Params: 733 * fd - the file descriptor object that identifies this connection 734 * buf - Buffer to read the data into 735 * len - Max length to read 736 * Returns: 737 * Number of bytes read or -1 for error 736 738 */ 737 739 int YAHOO_CALLBACK_TYPE(ext_yahoo_read) (void *fd, char *buf, int len); … … 739 741 /* 740 742 * Name: ext_yahoo_close 741 * 742 * 743 * Params: 744 * 745 * Returns: 746 * 743 * Close the file descriptor object and free its resources. Libyahoo2 will not 744 * use this object again. 745 * Params: 746 * fd - the file descriptor object that identifies this connection 747 * Returns: 748 * Nothing 747 749 */ 748 750 void YAHOO_CALLBACK_TYPE(ext_yahoo_close) (void *fd); … … 750 752 /* 751 753 * Name: ext_yahoo_got_buddy_change_group 752 * 753 * Params: 754 * 755 * 756 * 757 * 758 * 759 * Returns: 760 * 754 * Acknowledgement of buddy changing group 755 * Params: 756 * id: client id 757 * me: The user 758 * who: Buddy name 759 * old_group: Old group name 760 * new_group: New group name 761 * Returns: 762 * Nothing 761 763 */ 762 764 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddy_change_group) (int id, 763 const char *me, const char *who, const char *old_group, 764 const char *new_group); 765 const char *me, const char *who, 766 const char *old_group, 767 const char *new_group); 765 768 766 769 #ifdef USE_STRUCT_CALLBACKS -
protocols/yahoo/yahoo2_types.h
raf359b4 r5ebff60 29 29 #endif 30 30 31 enum yahoo_service {/* these are easier to see in hex */32 33 34 35 36 YAHOO_SERVICE_IDLE,/* 5 (placemarker) */37 38 39 40 41 YAHOO_SERVICE_USERSTAT,/* 0xa */42 43 44 45 46 47 YAHOO_SERVICE_ADDIDENT,/* 0x10 */48 49 50 YAHOO_SERVICE_GOTGROUPRENAME,/* < 1, 36(old), 37(new) */51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 YAHOO_SERVICE_PEERTOPEER = 0x4F,/* Checks if P2P possible */72 73 74 75 76 77 78 79 YAHOO_SERVICE_IGNORECONTACT,/* > 1, 7, 13 < 1, 66, 13, 0 */80 81 YAHOO_SERVICE_GROUPRENAME = 0x89,/* > 1, 65(new), 66(0), 67(old) */82 83 YAHOO_SERVICE_CHATONLINE = 0x96,/* > 109(id), 1, 6(abcde) < 0,1 */84 85 YAHOO_SERVICE_CHATJOIN,/* > 1 104-room 129-1600326591 62-2 */86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 YAHOO_SERVICE_Y6_VISIBLE_TOGGLE = 0xc5,/* YMSG13, key 13: 2 = invisible, 1 = visible */102 YAHOO_SERVICE_Y6_STATUS_UPDATE = 0xc6,/* YMSG13 */103 YAHOO_SERVICE_PICTURE_STATUS = 0xc7,/* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */104 105 106 107 YAHOO_SERVICE_Y7_CONTACT_DETAILS = 0xd3,/* YMSG13 */108 109 YAHOO_SERVICE_Y7_AUTHORIZATION = 0xd6,/* YMSG13 */110 YAHOO_SERVICE_Y7_FILETRANSFER = 0xdc,/* YMSG13 */111 YAHOO_SERVICE_Y7_FILETRANSFERINFO,/* YMSG13 */112 YAHOO_SERVICE_Y7_FILETRANSFERACCEPT,/* YMSG13 */113 YAHOO_SERVICE_Y7_MINGLE = 0xe1,/* YMSG13 */114 YAHOO_SERVICE_Y7_CHANGE_GROUP = 0xe7,/* YMSG13 */115 YAHOO_SERVICE_MYSTERY = 0xef,/* Don't know what this is for */116 YAHOO_SERVICE_Y8_STATUS = 0xf0,/* YMSG15 */117 YAHOO_SERVICE_Y8_LIST = 0Xf1,/* YMSG15 */118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 YAHOO_STATUS_OFFLINE = 0x5a55aa56/* don't ask */138 139 140 141 142 143 144 145 146 147 148 YPACKET_STATUS_NOTIFY = 0x16,/* TYPING */149 150 151 152 153 #define YAHOO_STATUS_GAME 0x2/* Games don't fit into the regular status model */154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 31 enum yahoo_service { /* these are easier to see in hex */ 32 YAHOO_SERVICE_LOGON = 1, 33 YAHOO_SERVICE_LOGOFF, 34 YAHOO_SERVICE_ISAWAY, 35 YAHOO_SERVICE_ISBACK, 36 YAHOO_SERVICE_IDLE, /* 5 (placemarker) */ 37 YAHOO_SERVICE_MESSAGE, 38 YAHOO_SERVICE_IDACT, 39 YAHOO_SERVICE_IDDEACT, 40 YAHOO_SERVICE_MAILSTAT, 41 YAHOO_SERVICE_USERSTAT, /* 0xa */ 42 YAHOO_SERVICE_NEWMAIL, 43 YAHOO_SERVICE_CHATINVITE, 44 YAHOO_SERVICE_CALENDAR, 45 YAHOO_SERVICE_NEWPERSONALMAIL, 46 YAHOO_SERVICE_NEWCONTACT, 47 YAHOO_SERVICE_ADDIDENT, /* 0x10 */ 48 YAHOO_SERVICE_ADDIGNORE, 49 YAHOO_SERVICE_PING, 50 YAHOO_SERVICE_GOTGROUPRENAME, /* < 1, 36(old), 37(new) */ 51 YAHOO_SERVICE_SYSMESSAGE = 0x14, 52 YAHOO_SERVICE_SKINNAME = 0x15, 53 YAHOO_SERVICE_PASSTHROUGH2 = 0x16, 54 YAHOO_SERVICE_CONFINVITE = 0x18, 55 YAHOO_SERVICE_CONFLOGON, 56 YAHOO_SERVICE_CONFDECLINE, 57 YAHOO_SERVICE_CONFLOGOFF, 58 YAHOO_SERVICE_CONFADDINVITE, 59 YAHOO_SERVICE_CONFMSG, 60 YAHOO_SERVICE_CHATLOGON, 61 YAHOO_SERVICE_CHATLOGOFF, 62 YAHOO_SERVICE_CHATMSG = 0x20, 63 YAHOO_SERVICE_GAMELOGON = 0x28, 64 YAHOO_SERVICE_GAMELOGOFF, 65 YAHOO_SERVICE_GAMEMSG = 0x2a, 66 YAHOO_SERVICE_FILETRANSFER = 0x46, 67 YAHOO_SERVICE_VOICECHAT = 0x4A, 68 YAHOO_SERVICE_NOTIFY, 69 YAHOO_SERVICE_VERIFY, 70 YAHOO_SERVICE_P2PFILEXFER, 71 YAHOO_SERVICE_PEERTOPEER = 0x4F, /* Checks if P2P possible */ 72 YAHOO_SERVICE_WEBCAM, 73 YAHOO_SERVICE_AUTHRESP = 0x54, 74 YAHOO_SERVICE_LIST, 75 YAHOO_SERVICE_AUTH = 0x57, 76 YAHOO_SERVICE_AUTHBUDDY = 0x6d, 77 YAHOO_SERVICE_ADDBUDDY = 0x83, 78 YAHOO_SERVICE_REMBUDDY, 79 YAHOO_SERVICE_IGNORECONTACT, /* > 1, 7, 13 < 1, 66, 13, 0 */ 80 YAHOO_SERVICE_REJECTCONTACT, 81 YAHOO_SERVICE_GROUPRENAME = 0x89, /* > 1, 65(new), 66(0), 67(old) */ 82 YAHOO_SERVICE_Y7_PING = 0x8A, 83 YAHOO_SERVICE_CHATONLINE = 0x96, /* > 109(id), 1, 6(abcde) < 0,1 */ 84 YAHOO_SERVICE_CHATGOTO, 85 YAHOO_SERVICE_CHATJOIN, /* > 1 104-room 129-1600326591 62-2 */ 86 YAHOO_SERVICE_CHATLEAVE, 87 YAHOO_SERVICE_CHATEXIT = 0x9b, 88 YAHOO_SERVICE_CHATADDINVITE = 0x9d, 89 YAHOO_SERVICE_CHATLOGOUT = 0xa0, 90 YAHOO_SERVICE_CHATPING, 91 YAHOO_SERVICE_COMMENT = 0xa8, 92 YAHOO_SERVICE_GAME_INVITE = 0xb7, 93 YAHOO_SERVICE_STEALTH_PERM = 0xb9, 94 YAHOO_SERVICE_STEALTH_SESSION = 0xba, 95 YAHOO_SERVICE_AVATAR = 0xbc, 96 YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd, 97 YAHOO_SERVICE_PICTURE = 0xbe, 98 YAHOO_SERVICE_PICTURE_UPDATE = 0xc1, 99 YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2, 100 YAHOO_SERVICE_YAB_UPDATE = 0xc4, 101 YAHOO_SERVICE_Y6_VISIBLE_TOGGLE = 0xc5, /* YMSG13, key 13: 2 = invisible, 1 = visible */ 102 YAHOO_SERVICE_Y6_STATUS_UPDATE = 0xc6, /* YMSG13 */ 103 YAHOO_SERVICE_PICTURE_STATUS = 0xc7, /* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */ 104 YAHOO_SERVICE_VERIFY_ID_EXISTS = 0xc8, 105 YAHOO_SERVICE_AUDIBLE = 0xd0, 106 YAHOO_SERVICE_Y7_PHOTO_SHARING = 0xd2, 107 YAHOO_SERVICE_Y7_CONTACT_DETAILS = 0xd3, /* YMSG13 */ 108 YAHOO_SERVICE_Y7_CHAT_SESSION = 0xd4, 109 YAHOO_SERVICE_Y7_AUTHORIZATION = 0xd6, /* YMSG13 */ 110 YAHOO_SERVICE_Y7_FILETRANSFER = 0xdc, /* YMSG13 */ 111 YAHOO_SERVICE_Y7_FILETRANSFERINFO, /* YMSG13 */ 112 YAHOO_SERVICE_Y7_FILETRANSFERACCEPT, /* YMSG13 */ 113 YAHOO_SERVICE_Y7_MINGLE = 0xe1, /* YMSG13 */ 114 YAHOO_SERVICE_Y7_CHANGE_GROUP = 0xe7, /* YMSG13 */ 115 YAHOO_SERVICE_MYSTERY = 0xef, /* Don't know what this is for */ 116 YAHOO_SERVICE_Y8_STATUS = 0xf0, /* YMSG15 */ 117 YAHOO_SERVICE_Y8_LIST = 0Xf1, /* YMSG15 */ 118 YAHOO_SERVICE_MESSAGE_CONFIRM = 0xfb, 119 YAHOO_SERVICE_WEBLOGIN = 0x0226, 120 YAHOO_SERVICE_SMS_MSG = 0x02ea 121 }; 122 123 enum yahoo_status { 124 YAHOO_STATUS_AVAILABLE = 0, 125 YAHOO_STATUS_BRB, 126 YAHOO_STATUS_BUSY, 127 YAHOO_STATUS_NOTATHOME, 128 YAHOO_STATUS_NOTATDESK, 129 YAHOO_STATUS_NOTINOFFICE, 130 YAHOO_STATUS_ONPHONE, 131 YAHOO_STATUS_ONVACATION, 132 YAHOO_STATUS_OUTTOLUNCH, 133 YAHOO_STATUS_STEPPEDOUT, 134 YAHOO_STATUS_INVISIBLE = 12, 135 YAHOO_STATUS_CUSTOM = 99, 136 YAHOO_STATUS_IDLE = 999, 137 YAHOO_STATUS_OFFLINE = 0x5a55aa56 /* don't ask */ 138 }; 139 140 enum ypacket_status { 141 YPACKET_STATUS_DISCONNECTED = -1, 142 YPACKET_STATUS_DEFAULT = 0, 143 YPACKET_STATUS_SERVERACK = 1, 144 YPACKET_STATUS_GAME = 0x2, 145 YPACKET_STATUS_AWAY = 0x4, 146 YPACKET_STATUS_CONTINUED = 0x5, 147 YPACKET_STATUS_INVISIBLE = 12, 148 YPACKET_STATUS_NOTIFY = 0x16, /* TYPING */ 149 YPACKET_STATUS_WEBLOGIN = 0x5a55aa55, 150 YPACKET_STATUS_OFFLINE = 0x5a55aa56 151 }; 152 153 #define YAHOO_STATUS_GAME 0x2 /* Games don't fit into the regular status model */ 154 155 enum yahoo_login_status { 156 YAHOO_LOGIN_OK = 0, 157 YAHOO_LOGIN_LOGOFF = 1, 158 YAHOO_LOGIN_UNAME = 3, 159 YAHOO_LOGIN_PASSWD = 13, 160 YAHOO_LOGIN_LOCK = 14, 161 YAHOO_LOGIN_DUPL = 99, 162 YAHOO_LOGIN_SOCK = -1, 163 YAHOO_LOGIN_UNKNOWN = 999 164 }; 165 166 enum yahoo_error { 167 E_UNKNOWN = -1, 168 E_CONNECTION = -2, 169 E_SYSTEM = -3, 170 E_CUSTOM = 0, 171 172 /* responses from ignore buddy */ 173 E_IGNOREDUP = 2, 174 E_IGNORENONE = 3, 175 E_IGNORECONF = 12, 176 177 /* conference */ 178 E_CONFNOTAVAIL = 20 179 }; 180 181 enum yahoo_log_level { 182 YAHOO_LOG_NONE = 0, 183 YAHOO_LOG_FATAL, 184 YAHOO_LOG_ERR, 185 YAHOO_LOG_WARNING, 186 YAHOO_LOG_NOTICE, 187 YAHOO_LOG_INFO, 188 YAHOO_LOG_DEBUG 189 }; 190 191 enum yahoo_file_transfer { 192 YAHOO_FILE_TRANSFER_INIT = 1, 193 YAHOO_FILE_TRANSFER_ACCEPT = 3, 194 YAHOO_FILE_TRANSFER_REJECT = 4, 195 YAHOO_FILE_TRANSFER_DONE = 5, 196 YAHOO_FILE_TRANSFER_RELAY, 197 YAHOO_FILE_TRANSFER_FAILED, 198 YAHOO_FILE_TRANSFER_UNKNOWN 199 }; 200 200 201 201 #define YAHOO_PROTO_VER 0x0010 … … 222 222 #define YAHOO_STYLE_URLOFF "\033[xlm" 223 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 224 enum yahoo_connection_type { 225 YAHOO_CONNECTION_PAGER = 0, 226 YAHOO_CONNECTION_FT, 227 YAHOO_CONNECTION_YAB, 228 YAHOO_CONNECTION_WEBCAM_MASTER, 229 YAHOO_CONNECTION_WEBCAM, 230 YAHOO_CONNECTION_CHATCAT, 231 YAHOO_CONNECTION_SEARCH, 232 YAHOO_CONNECTION_AUTH 233 }; 234 235 enum yahoo_webcam_direction_type { 236 YAHOO_WEBCAM_DOWNLOAD = 0, 237 YAHOO_WEBCAM_UPLOAD 238 }; 239 240 enum yahoo_stealth_visibility_type { 241 YAHOO_STEALTH_DEFAULT = 0, 242 YAHOO_STEALTH_ONLINE, 243 YAHOO_STEALTH_PERM_OFFLINE 244 }; 245 245 246 246 /* chat member attribs */ … … 251 251 #define YAHOO_CHAT_WEBCAM 0x10 252 252 253 254 255 256 int direction;/* Uploading or downloading */257 int conn_type;/* 0=Dialup, 1=DSL/Cable, 2=T1/Lan */258 259 char *user;/* user we are viewing */260 char *server;/* webcam server to connect to */261 int port;/* webcam port to connect on */262 char *key;/* key to connect to the server with */263 char *description;/* webcam description */264 char *my_ip;/* own ip number */265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 253 enum yahoo_webcam_conn_type { Y_WCM_DIALUP, Y_WCM_DSL, Y_WCM_T1 }; 254 255 struct yahoo_webcam { 256 int direction; /* Uploading or downloading */ 257 int conn_type; /* 0=Dialup, 1=DSL/Cable, 2=T1/Lan */ 258 259 char *user; /* user we are viewing */ 260 char *server; /* webcam server to connect to */ 261 int port; /* webcam port to connect on */ 262 char *key; /* key to connect to the server with */ 263 char *description; /* webcam description */ 264 char *my_ip; /* own ip number */ 265 }; 266 267 struct yahoo_webcam_data { 268 unsigned int data_size; 269 unsigned int to_read; 270 unsigned int timestamp; 271 unsigned char packet_type; 272 }; 273 274 struct yahoo_data { 275 char *user; 276 char *password; 277 278 char *cookie_y; 279 char *cookie_t; 280 char *cookie_c; 281 char *cookie_b; 282 char *login_cookie; 283 char *crumb; 284 char *seed; 285 286 YList *buddies; 287 YList *ignore; 288 YList *identities; 289 char *login_id; 290 291 int current_status; 292 int initial_status; 293 int logged_in; 294 295 int session_id; 296 297 int client_id; 298 299 char *rawbuddylist; 300 char *ignorelist; 301 302 void *server_settings; 303 304 struct yahoo_process_status_entry *half_user; 305 }; 306 307 struct yab { 308 int yid; 309 char *id; 310 char *fname; 311 char *lname; 312 char *nname; 313 char *email; 314 char *hphone; 315 char *wphone; 316 char *mphone; 317 int dbid; 318 }; 319 320 struct yahoo_buddy { 321 char *group; 322 char *id; 323 char *real_name; 324 struct yab *yab_entry; 325 }; 326 327 enum yahoo_search_type { 328 YAHOO_SEARCH_KEYWORD = 0, 329 YAHOO_SEARCH_YID, 330 YAHOO_SEARCH_NAME 331 }; 332 333 enum yahoo_search_gender { 334 YAHOO_GENDER_NONE = 0, 335 YAHOO_GENDER_MALE, 336 YAHOO_GENDER_FEMALE 337 }; 338 339 enum yahoo_search_agerange { 340 YAHOO_AGERANGE_NONE = 0 341 }; 342 343 struct yahoo_found_contact { 344 char *id; 345 char *gender; 346 char *location; 347 int age; 348 int online; 349 }; 350 350 351 351 /* 352 352 * Function pointer to be passed to http get/post and send file 353 353 */ 354 355 354 typedef void (*yahoo_get_fd_callback) (int id, void *fd, int error, 355 void *data); 356 356 357 357 /* 358 358 * Function pointer to be passed to yahoo_get_url_handle 359 359 */ 360 361 362 363 364 365 366 367 368 369 370 371 372 struct yahoo_process_status_entry { 373 char *name; /* 7 name */374 int state; /* 10 state */375 int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */376 int mobile; /* 60 mobile */377 char *msg; /* 19 custom status message */378 int away; /* 47 away (or invisible) */379 int buddy_session; /* 11 state */380 int f17; /* 17 in chat? then what about flags? */381 int idle; /* 137 seconds idle */382 int f138; /* 138 state */383 char *f184; /* 184 state */384 int f192; /* 192 state */385 int f10001; /* 10001 state */386 int f10002; /* 10002 state */387 int f198; /* 198 state */388 char *f197; /* 197 state */389 char *f205; /* 205 state */390 int f213; /* 213 state */391 360 typedef void (*yahoo_get_url_handle_callback) (int id, void *fd, 361 int error, const char *filename, unsigned long size, 362 void *data); 363 364 struct yahoo_chat_member { 365 char *id; 366 int age; 367 int attribs; 368 char *alias; 369 char *location; 370 }; 371 372 struct yahoo_process_status_entry { 373 char *name; /* 7 name */ 374 int state; /* 10 state */ 375 int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */ 376 int mobile; /* 60 mobile */ 377 char *msg; /* 19 custom status message */ 378 int away; /* 47 away (or invisible) */ 379 int buddy_session; /* 11 state */ 380 int f17; /* 17 in chat? then what about flags? */ 381 int idle; /* 137 seconds idle */ 382 int f138; /* 138 state */ 383 char *f184; /* 184 state */ 384 int f192; /* 192 state */ 385 int f10001; /* 10001 state */ 386 int f10002; /* 10002 state */ 387 int f198; /* 198 state */ 388 char *f197; /* 197 state */ 389 char *f205; /* 205 state */ 390 int f213; /* 213 state */ 391 }; 392 392 393 393 #ifdef __cplusplus -
protocols/yahoo/yahoo_debug.h
raf359b4 r5ebff60 22 22 extern int yahoo_log_message(char *fmt, ...); 23 23 24 #define NOTICE(x) if (yahoo_get_log_level() >= YAHOO_LOG_NOTICE) { yahoo_log_message x; yahoo_log_message("\n"); }24 #define NOTICE(x) if (yahoo_get_log_level() >= YAHOO_LOG_NOTICE) { yahoo_log_message x; yahoo_log_message("\n"); } 25 25 26 #define LOG(x) if (yahoo_get_log_level() >= YAHOO_LOG_INFO) { yahoo_log_message("%s:%d: ", __FILE__, __LINE__); \27 yahoo_log_message x; \28 yahoo_log_message("\n"); }26 #define LOG(x) if (yahoo_get_log_level() >= YAHOO_LOG_INFO) { yahoo_log_message("%s:%d: ", __FILE__, __LINE__); \ 27 yahoo_log_message x; \ 28 yahoo_log_message("\n"); } 29 29 30 #define WARNING(x) if(yahoo_get_log_level() >= YAHOO_LOG_WARNING) { yahoo_log_message("%s:%d: warning: ", __FILE__, __LINE__); \ 31 yahoo_log_message x; \ 32 yahoo_log_message("\n"); } 30 #define WARNING(x) if (yahoo_get_log_level() >= YAHOO_LOG_WARNING) { yahoo_log_message("%s:%d: warning: ", __FILE__, \ 31 __LINE__); \ 32 yahoo_log_message x; \ 33 yahoo_log_message("\n"); } 33 34 34 #define DEBUG_MSG(x) if(yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { yahoo_log_message("%s:%d: debug: ", __FILE__, __LINE__); \ 35 yahoo_log_message x; \ 36 yahoo_log_message("\n"); } 35 #define DEBUG_MSG(x) if (yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { yahoo_log_message("%s:%d: debug: ", __FILE__, \ 36 __LINE__); \ 37 yahoo_log_message x; \ 38 yahoo_log_message("\n"); } 37 39 38 40 -
protocols/yahoo/yahoo_httplib.c
raf359b4 r5ebff60 32 32 char *strchr(), *strrchr(); 33 33 # if !HAVE_MEMCPY 34 # define memcpy(d, s, n) bcopy 35 # define memmove(d, s, n) bcopy 34 # define memcpy(d, s, n) bcopy((s), (d), (n)) 35 # define memmove(d, s, n) bcopy((s), (d), (n)) 36 36 # endif 37 37 #endif … … 53 53 #ifdef USE_STRUCT_CALLBACKS 54 54 extern struct yahoo_callbacks *yc; 55 #define YAHOO_CALLBACK(x) 55 #define YAHOO_CALLBACK(x) yc->x 56 56 #else 57 #define YAHOO_CALLBACK(x) 57 #define YAHOO_CALLBACK(x) x 58 58 #endif 59 59 … … 69 69 70 70 do { 71 rc = YAHOO_CALLBACK (ext_yahoo_read) (fd, &c, 1);72 } while (rc == -1 && (errno == EINTR || errno == EAGAIN)); 71 rc = YAHOO_CALLBACK (ext_yahoo_read) (fd, &c, 1); 72 } while (rc == -1 && (errno == EINTR || errno == EAGAIN)); /* this is bad - it should be done asynchronously */ 73 73 74 74 if (rc == 1) { 75 if (c == '\r') 75 if (c == '\r') { /* get rid of \r */ 76 76 continue; 77 } 77 78 *ptr = c; 78 if (c == '\n') 79 if (c == '\n') { 79 80 break; 81 } 80 82 ptr++; 81 83 } else if (rc == 0) { 82 if (n == 1) 83 return (0); /* EOF, no data */ 84 else 85 break; /* EOF, w/ data */ 84 if (n == 1) { 85 return (0); /* EOF, no data */ 86 } else { 87 break; /* EOF, w/ data */ 88 } 86 89 } else { 87 90 return -1; … … 95 98 96 99 static int url_to_host_port_path(const char *url, 97 100 char *host, int *port, char *path, int *ssl) 98 101 { 99 102 char *urlcopy = NULL; … … 127 130 128 131 if (!colon || (slash && slash < colon)) { 129 if (*ssl) 132 if (*ssl) { 130 133 *port = 443; 131 else134 } else { 132 135 *port = 80; 136 } 133 137 } else { 134 138 *colon = 0; … … 161 165 int len = strlen(instr); 162 166 163 if (!(str = y_new(char, 3 *len + 1))) 164 return ""; 167 if (!(str = y_new(char, 3 * len + 1))) { 168 return ""; 169 } 165 170 166 171 while (instr[ipos]) { 167 while (isurlchar(instr[ipos])) 172 while (isurlchar(instr[ipos])) { 168 173 str[bpos++] = instr[ipos++]; 169 if (!instr[ipos]) 174 } 175 if (!instr[ipos]) { 170 176 break; 177 } 171 178 172 179 snprintf(&str[bpos], 4, "%%%02x", instr[ipos] & 0xff); … … 192 199 int len = strlen(instr); 193 200 194 if (!(str = y_new(char, len + 1))) 195 return ""; 201 if (!(str = y_new(char, len + 1))) { 202 return ""; 203 } 196 204 197 205 while (instr[ipos]) { 198 while (instr[ipos] && instr[ipos] != '%') 206 while (instr[ipos] && instr[ipos] != '%') { 199 207 if (instr[ipos] == '+') { 200 208 str[bpos++] = ' '; 201 209 ipos++; 202 } else 210 } else { 203 211 str[bpos++] = instr[ipos++]; 204 if (!instr[ipos]) 212 } 213 } 214 if (!instr[ipos]) { 205 215 break; 216 } 206 217 207 218 if (instr[ipos + 1] && instr[ipos + 2]) { … … 210 221 entity[1] = instr[ipos++]; 211 222 sscanf(entity, "%2x", &dec); 212 str[bpos++] = (char) dec;223 str[bpos++] = (char) dec; 213 224 } else { 214 225 str[bpos++] = instr[ipos++]; … … 230 241 char entity[4] = { 0, 0, 0, 0 }; 231 242 char *entitymap[5][2] = { 232 { "amp;", "&"},233 { "quot;", "\""},234 { "lt;", "<"},235 { "gt;", "<"},236 { "nbsp;", " "}243 { "amp;", "&" }, 244 { "quot;", "\"" }, 245 { "lt;", "<" }, 246 { "gt;", "<" }, 247 { "nbsp;", " " } 237 248 }; 238 249 unsigned dec; 239 250 int len = strlen(instr); 240 251 241 if (!(str = y_new(char, len + 1))) 242 return ""; 252 if (!(str = y_new(char, len + 1))) { 253 return ""; 254 } 243 255 244 256 while (instr[ipos]) { 245 while (instr[ipos] && instr[ipos] != '&') 257 while (instr[ipos] && instr[ipos] != '&') { 246 258 if (instr[ipos] == '+') { 247 259 str[bpos++] = ' '; 248 260 ipos++; 249 } else 261 } else { 250 262 str[bpos++] = instr[ipos++]; 251 if (!instr[ipos] || !instr[ipos + 1]) 263 } 264 } 265 if (!instr[ipos] || !instr[ipos + 1]) { 252 266 break; 267 } 253 268 ipos++; 254 269 … … 256 271 ipos++; 257 272 epos = 0; 258 while (instr[ipos] != ';') 273 while (instr[ipos] != ';') { 259 274 entity[epos++] = instr[ipos++]; 275 } 260 276 sscanf(entity, "%u", &dec); 261 str[bpos++] = (char) dec;277 str[bpos++] = (char) dec; 262 278 ipos++; 263 279 } else { 264 280 int i; 265 for (i = 0; i < 5; i++) 281 for (i = 0; i < 5; i++) { 266 282 if (!strncmp(instr + ipos, entitymap[i][0], 267 283 strlen(entitymap[i][0]))) { 268 284 str[bpos++] = entitymap[i][1][0]; 269 285 ipos += strlen(entitymap[i][0]); 270 286 break; 271 287 } 288 } 272 289 } 273 290 } … … 294 311 { 295 312 struct callback_data *ccd = data; 296 if (error == 0) 297 YAHOO_CALLBACK(ext_yahoo_write) (fd, ccd->request, 298 strlen(ccd->request)); 313 314 if (error == 0) { 315 YAHOO_CALLBACK (ext_yahoo_write) (fd, ccd->request, 316 strlen(ccd->request)); 317 } 299 318 free(ccd->request); 300 319 ccd->callback(ccd->id, fd, error, ccd->user_data); … … 303 322 304 323 static void yahoo_send_http_request(int id, char *host, int port, char *request, 305 324 yahoo_get_fd_callback callback, void *data, int use_ssl) 306 325 { 307 326 struct callback_data *ccd = y_new0(struct callback_data, 1); 327 308 328 ccd->callback = callback; 309 329 ccd->id = id; … … 311 331 ccd->user_data = data; 312 332 313 YAHOO_CALLBACK (ext_yahoo_connect_async) (id, host, port,314 333 YAHOO_CALLBACK (ext_yahoo_connect_async) (id, host, port, 334 connect_complete, ccd, use_ssl); 315 335 } 316 336 317 337 void yahoo_http_post(int id, const char *url, const char *cookies, 318 338 long content_length, yahoo_get_fd_callback callback, void *data) 319 339 { 320 340 char host[255]; … … 324 344 int ssl = 0; 325 345 326 if (!url_to_host_port_path(url, host, &port, path, &ssl)) 346 if (!url_to_host_port_path(url, host, &port, path, &ssl)) { 327 347 return; 348 } 328 349 329 350 /* thanks to kopete dumpcap */ 330 351 snprintf(buff, sizeof(buff), 331 332 333 334 335 336 337 352 "POST %s HTTP/1.1\r\n" 353 "Cookie: %s\r\n" 354 "User-Agent: Mozilla/5.0\r\n" 355 "Host: %s\r\n" 356 "Content-Length: %ld\r\n" 357 "Cache-Control: no-cache\r\n" 358 "\r\n", path, cookies, host, content_length); 338 359 339 360 yahoo_send_http_request(id, host, port, buff, callback, data, ssl); … … 341 362 342 363 void yahoo_http_get(int id, const char *url, const char *cookies, int http11, 343 364 int keepalive, yahoo_get_fd_callback callback, void *data) 344 365 { 345 366 char host[255]; … … 350 371 int ssl = 0; 351 372 352 if (!url_to_host_port_path(url, host, &port, path, &ssl)) 373 if (!url_to_host_port_path(url, host, &port, path, &ssl)) { 353 374 return; 375 } 354 376 355 377 /* Allow cases when we don't need to send a cookie */ 356 if (cookies) 378 if (cookies) { 357 379 snprintf(cookiebuff, sizeof(cookiebuff), "Cookie: %s\r\n", 358 359 else380 cookies); 381 } else { 360 382 cookiebuff[0] = '\0'; 383 } 361 384 362 385 snprintf(buff, sizeof(buff), 363 364 365 366 367 "%s" "\r\n", path, http11?"1":"0", cookiebuff, host,368 keepalive? "Connection: Keep-Alive\r\n":"Connection: close\r\n");386 "GET %s HTTP/1.%s\r\n" 387 "%sHost: %s\r\n" 388 "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n" 389 "Accept: */*\r\n" 390 "%s" "\r\n", path, http11 ? "1" : "0", cookiebuff, host, 391 keepalive ? "Connection: Keep-Alive\r\n" : "Connection: close\r\n"); 369 392 370 393 yahoo_send_http_request(id, host, port, buff, callback, data, ssl); … … 372 395 373 396 void yahoo_http_head(int id, const char *url, const char *cookies, int len, 374 397 char *payload, yahoo_get_fd_callback callback, void *data) 375 398 { 376 399 char host[255]; … … 381 404 int ssl = 0; 382 405 383 if (!url_to_host_port_path(url, host, &port, path, &ssl)) 406 if (!url_to_host_port_path(url, host, &port, path, &ssl)) { 384 407 return; 408 } 385 409 386 410 /* Allow cases when we don't need to send a cookie */ 387 if (cookies) 411 if (cookies) { 388 412 snprintf(cookiebuff, sizeof(cookiebuff), "Cookie: %s\r\n", 389 390 else413 cookies); 414 } else { 391 415 cookiebuff[0] = '\0'; 416 } 392 417 393 418 snprintf(buff, sizeof(buff), 394 395 396 397 398 399 400 401 402 payload?payload:"");419 "HEAD %s HTTP/1.0\r\n" 420 "Accept: */*\r\n" 421 "Host: %s:%d\r\n" 422 "User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n" 423 "%s" 424 "Content-Length: %d\r\n" 425 "Cache-Control: no-cache\r\n" 426 "\r\n%s", path, host, port, cookiebuff, len, 427 payload ? payload : ""); 403 428 404 429 yahoo_send_http_request(id, host, port, buff, callback, data, ssl); -
protocols/yahoo/yahoo_httplib.h
raf359b4 r5ebff60 29 29 #include "yahoo2_types.h" 30 30 31 32 33 31 char *yahoo_urlencode(const char *instr); 32 char *yahoo_urldecode(const char *instr); 33 char *yahoo_xmldecode(const char *instr); 34 34 35 36 37 38 39 40 41 42 43 35 int yahoo_tcp_readline(char *ptr, int maxlen, void *fd); 36 void yahoo_http_post(int id, const char *url, const char *cookies, 37 long size, yahoo_get_fd_callback callback, void *data); 38 void yahoo_http_get(int id, const char *url, const char *cookies, 39 int http11, int keepalive, yahoo_get_fd_callback callback, 40 void *data); 41 void yahoo_http_head(int id, const char *url, const char *cookies, 42 int size, char *payload, yahoo_get_fd_callback callback, 43 void *data); 44 44 45 45 #ifdef __cplusplus -
protocols/yahoo/yahoo_util.c
raf359b4 r5ebff60 27 27 # define strrchr rindex 28 28 # endif 29 char *strchr (), *strrchr();29 char *strchr(), *strrchr(); 30 30 # if !HAVE_MEMCPY 31 # define memcpy(d, s, n) bcopy 32 # define memmove(d, s, n) bcopy 31 # define memcpy(d, s, n) bcopy((s), (d), (n)) 32 # define memmove(d, s, n) bcopy((s), (d), (n)) 33 33 # endif 34 34 #endif … … 57 57 { 58 58 char **v; 59 for(v = vector; *v; v++) { 59 60 for (v = vector; *v; v++) { 60 61 FREE(*v); 61 62 } … … 67 68 char ** vector; 68 69 char *s, *p; 69 int i =0;70 int i = 0; 70 71 int l = strlen(sep); 71 if(nelem <= 0) { 72 73 if (nelem <= 0) { 72 74 char * s; 73 nelem =0;75 nelem = 0; 74 76 if (*str) { 75 for (s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++)77 for (s = strstr(str, sep); s; s = strstr(s + l, sep), nelem++) { 76 78 ; 77 if(strcmp(str+strlen(str)-l, sep)) 79 } 80 if (strcmp(str + strlen(str) - l, sep)) { 78 81 nelem++; 82 } 79 83 } 80 84 } … … 82 86 vector = y_new(char *, nelem + 1); 83 87 84 for (p=str, s=strstr(p,sep); i<nelem && s; p=s+l, s=strstr(p,sep), i++) {85 int len = s -p;86 vector[i] = y_new(char, len +1);88 for (p = str, s = strstr(p, sep); i < nelem && s; p = s + l, s = strstr(p, sep), i++) { 89 int len = s - p; 90 vector[i] = y_new(char, len + 1); 87 91 strncpy(vector[i], p, len); 88 92 vector[i][len] = '\0'; 89 93 } 90 94 91 if (i<nelem && *str)/* str didn't end with sep, and str isn't empty */95 if (i < nelem && *str) { /* str didn't end with sep, and str isn't empty */ 92 96 vector[i++] = strdup(p); 93 97 } 98 94 99 vector[i] = NULL; 95 100 … … 100 105 { 101 106 void * new_chunk = malloc(n); 102 if(new_chunk) 107 108 if (new_chunk) { 103 109 memcpy(new_chunk, addr, n); 110 } 104 111 return new_chunk; 105 112 } -
protocols/yahoo/yahoo_util.h
raf359b4 r5ebff60 30 30 # include <glib.h> 31 31 32 # define FREE(x) if(x) {g_free(x); x=NULL;}32 # define FREE(x) if (x) { g_free(x); x = NULL; } 33 33 34 # define y_new 35 # define y_new0 36 # define y_renew 34 # define y_new g_new 35 # define y_new0 g_new0 36 # define y_renew g_renew 37 37 38 # define y_memdup 39 # define y_strsplit 40 # define y_strfreev 38 # define y_memdup g_memdup 39 # define y_strsplit g_strsplit 40 # define y_strfreev g_strfreev 41 41 # ifndef strdup 42 # define strdup 42 # define strdup g_strdup 43 43 # endif 44 44 # ifndef strncasecmp 45 # define strncasecmp 46 # define strcasecmp 45 # define strncasecmp g_strncasecmp 46 # define strcasecmp g_strcasecmp 47 47 # endif 48 48 49 # define snprintf 49 # define snprintf g_snprintf 50 50 #ifdef vsnprintf 51 51 #undef vsnprintf 52 52 #endif 53 # define vsnprintf 53 # define vsnprintf g_vsnprintf 54 54 55 55 #else … … 58 58 # include <stdarg.h> 59 59 60 # define FREE(x) if(x) {free(x); x=NULL;}60 # define FREE(x) if (x) { free(x); x = NULL; } 61 61 62 # define y_new(type, n) (type *)malloc(sizeof(type) * (n))63 # define y_new0(type, n) (type *)calloc((n), sizeof(type))64 # define y_renew(type, mem, n) (type *)realloc(mem, n)62 # define y_new(type, n) (type *) malloc(sizeof(type) * (n)) 63 # define y_new0(type, n) (type *) calloc((n), sizeof(type)) 64 # define y_renew(type, mem, n) (type *) realloc(mem, n) 65 65 66 66 void *y_memdup(const void *addr, int n); … … 87 87 88 88 #ifndef MIN 89 #define MIN(x, y) ((x)<(y)?(x):(y))89 #define MIN(x, y) ((x) < (y) ? (x) : (y)) 90 90 #endif 91 91 92 92 #ifndef MAX 93 #define MAX(x, y) ((x)>(y)?(x):(y))93 #define MAX(x, y) ((x) > (y) ? (x) : (y)) 94 94 #endif 95 95 96 /* 96 /* 97 97 * The following three functions return newly allocated memory. 98 98 * You must free it yourself
Note: See TracChangeset
for help on using the changeset viewer.