comparison src/protocols/yahoo/yahoochat.c @ 10394:45a0a07e8b25

[gaim-migrate @ 11623] Renamed yahoo_packet_hash to yahoo_packet_hash_str, added yahoo_packet_hash_int, and a new variable arg yahoo_packet_hash that calls either of them. I was going to add some more format chars to yahoo_packet_hash, and may yet. Stuff like automaticly converting strings' character sets or html to yahoo codes, etc. But first I want to look at how yahoo 6 handles character sets and see if it's any different. Feel free to give opinions on if these changes are actually better, assuming you actually look at them, as opposed to running away like a girly man when you see yahoo protocol code. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Fri, 17 Dec 2004 00:05:32 +0000
parents a8f9e5ce4f92
children 1a97d5e88d12
comparison
equal deleted inserted replaced
10393:a7a2c27248af 10394:45a0a07e8b25
58 ycht_connection_open(gc); 58 ycht_connection_open(gc);
59 return; 59 return;
60 } 60 }
61 61
62 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YAHOO_STATUS_AVAILABLE,0); 62 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YAHOO_STATUS_AVAILABLE,0);
63 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); 63 yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc),
64 yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); 64 109, gaim_connection_get_display_name(gc), 6, "abcde");
65 yahoo_packet_hash(pkt, 6, "abcde");
66 yahoo_packet_send_and_free(pkt, yd); 65 yahoo_packet_send_and_free(pkt, yd);
67 } 66 }
68 67
69 /* this is slow, and different from the gaim_* version in that it (hopefully) won't add a user twice */ 68 /* this is slow, and different from the gaim_* version in that it (hopefully) won't add a user twice */
70 void yahoo_chat_add_users(GaimConvChat *chat, GList *newusers) 69 void yahoo_chat_add_users(GaimConvChat *chat, GList *newusers)
591 590
592 gaim_debug_misc("yahoo", "leaving conference %s\n", room); 591 gaim_debug_misc("yahoo", "leaving conference %s\n", room);
593 592
594 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YAHOO_STATUS_AVAILABLE, 0); 593 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGOFF, YAHOO_STATUS_AVAILABLE, 0);
595 594
596 yahoo_packet_hash(pkt, 1, dn); 595 yahoo_packet_hash_str(pkt, 1, dn);
597 for (w = who; w; w = w->next) { 596 for (w = who; w; w = w->next) {
598 const char *name = gaim_conv_chat_cb_get_name(w->data); 597 const char *name = gaim_conv_chat_cb_get_name(w->data);
599 yahoo_packet_hash(pkt, 3, name); 598 yahoo_packet_hash_str(pkt, 3, name);
600 } 599 }
601 600
602 yahoo_packet_hash(pkt, 57, room); 601 yahoo_packet_hash_str(pkt, 57, room);
603 602
604 yahoo_packet_send_and_free(pkt, yd); 603 yahoo_packet_send_and_free(pkt, yd);
605 } 604 }
606 605
607 static int yahoo_conf_send(GaimConnection *gc, const char *dn, const char *room, 606 static int yahoo_conf_send(GaimConnection *gc, const char *dn, const char *room,
617 msg2 = yahoo_string_encode(gc, msg, &utf8); 616 msg2 = yahoo_string_encode(gc, msg, &utf8);
618 617
619 618
620 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YAHOO_STATUS_AVAILABLE, 0); 619 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFMSG, YAHOO_STATUS_AVAILABLE, 0);
621 620
622 yahoo_packet_hash(pkt, 1, dn); 621 yahoo_packet_hash_str(pkt, 1, dn);
623 for (who = members; who; who = who->next) { 622 for (who = members; who; who = who->next) {
624 const char *name = gaim_conv_chat_cb_get_name(who->data); 623 const char *name = gaim_conv_chat_cb_get_name(who->data);
625 yahoo_packet_hash(pkt, 53, name); 624 yahoo_packet_hash_str(pkt, 53, name);
626 } 625 }
627 yahoo_packet_hash(pkt, 57, room); 626 yahoo_packet_hash(pkt, "ss", 57, room, 14, msg2);
628 yahoo_packet_hash(pkt, 14, msg2);
629 if (utf8) 627 if (utf8)
630 yahoo_packet_hash(pkt, 97, "1"); /* utf-8 */ 628 yahoo_packet_hash_str(pkt, 97, "1"); /* utf-8 */
631 629
632 yahoo_packet_send_and_free(pkt, yd); 630 yahoo_packet_send_and_free(pkt, yd);
633 g_free(msg); 631 g_free(msg);
634 g_free(msg2); 632 g_free(msg2);
635 633
647 memarr = g_strsplit(members, "\n", 0); 645 memarr = g_strsplit(members, "\n", 0);
648 646
649 647
650 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGON, YAHOO_STATUS_AVAILABLE, 0); 648 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFLOGON, YAHOO_STATUS_AVAILABLE, 0);
651 649
652 yahoo_packet_hash(pkt, 1, dn); 650 yahoo_packet_hash(pkt, "sss", 1, dn, 3, dn, 57, room);
653 yahoo_packet_hash(pkt, 3, dn);
654 yahoo_packet_hash(pkt, 57, room);
655 if (memarr) { 651 if (memarr) {
656 for(i = 0 ; memarr[i]; i++) { 652 for(i = 0 ; memarr[i]; i++) {
657 if (!strcmp(memarr[i], "") || !strcmp(memarr[i], dn)) 653 if (!strcmp(memarr[i], "") || !strcmp(memarr[i], dn))
658 continue; 654 continue;
659 yahoo_packet_hash(pkt, 3, memarr[i]); 655 yahoo_packet_hash_str(pkt, 3, memarr[i]);
660 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c), memarr[i], NULL, GAIM_CBFLAGS_NONE, TRUE); 656 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c), memarr[i], NULL, GAIM_CBFLAGS_NONE, TRUE);
661 } 657 }
662 } 658 }
663 yahoo_packet_send_and_free(pkt, yd); 659 yahoo_packet_send_and_free(pkt, yd);
664 660
679 675
680 members = gaim_conv_chat_get_users(GAIM_CONV_CHAT(c)); 676 members = gaim_conv_chat_get_users(GAIM_CONV_CHAT(c));
681 677
682 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE, YAHOO_STATUS_AVAILABLE, 0); 678 pkt = yahoo_packet_new(YAHOO_SERVICE_CONFADDINVITE, YAHOO_STATUS_AVAILABLE, 0);
683 679
684 yahoo_packet_hash(pkt, 1, dn); 680 yahoo_packet_hash(pkt, "sssss", 1, dn, 51, buddy, 57, room, 58, msg?msg2:"", 13, "0");
685 yahoo_packet_hash(pkt, 51, buddy);
686 yahoo_packet_hash(pkt, 57, room);
687 yahoo_packet_hash(pkt, 58, msg?msg2:"");
688 yahoo_packet_hash(pkt, 13, "0");
689 for(; members; members = members->next) { 681 for(; members; members = members->next) {
690 const char *name = gaim_conv_chat_cb_get_name(members->data); 682 const char *name = gaim_conv_chat_cb_get_name(members->data);
691 if (!strcmp(name, dn)) 683 if (!strcmp(name, dn))
692 continue; 684 continue;
693 yahoo_packet_hash(pkt, 52, name); 685 yahoo_packet_hash(pkt, "ss", 52, name, 53, name);
694 yahoo_packet_hash(pkt, 53, name);
695 } 686 }
696 687
697 yahoo_packet_send_and_free(pkt, yd); 688 yahoo_packet_send_and_free(pkt, yd);
698 g_free(msg2); 689 g_free(msg2);
699 } 690 }
719 710
720 eroom = yahoo_string_encode(gc, room, &utf8); 711 eroom = yahoo_string_encode(gc, room, &utf8);
721 712
722 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATEXIT, YAHOO_STATUS_AVAILABLE, 0); 713 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATEXIT, YAHOO_STATUS_AVAILABLE, 0);
723 714
724 yahoo_packet_hash(pkt, 104, eroom); 715 yahoo_packet_hash(pkt, "sss", 104, eroom, 109, dn, 108, "1");
725 yahoo_packet_hash(pkt, 109, dn); 716 yahoo_packet_hash_str(pkt, 112, "0"); /* what does this one mean? */
726 yahoo_packet_hash(pkt, 108, "1");
727 yahoo_packet_hash(pkt, 112, "0"); /* what does this one mean? */
728 717
729 yahoo_packet_send_and_free(pkt, yd); 718 yahoo_packet_send_and_free(pkt, yd);
730 719
731 yd->in_chat = 0; 720 yd->in_chat = 0;
732 if (yd->chat_name) { 721 if (yd->chat_name) {
740 if (!logout) 729 if (!logout)
741 return; 730 return;
742 731
743 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT, 732 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT,
744 YAHOO_STATUS_AVAILABLE, 0); 733 YAHOO_STATUS_AVAILABLE, 0);
745 yahoo_packet_hash(pkt, 1, dn); 734 yahoo_packet_hash_str(pkt, 1, dn);
746 yahoo_packet_send_and_free(pkt, yd); 735 yahoo_packet_send_and_free(pkt, yd);
747 736
748 yd->chat_online = 0; 737 yd->chat_online = 0;
749 g_free(eroom); 738 g_free(eroom);
750 } 739 }
813 g_free(msg2); 802 g_free(msg2);
814 room2 = yahoo_string_encode(gc, room, NULL); 803 room2 = yahoo_string_encode(gc, room, NULL);
815 804
816 pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YAHOO_STATUS_AVAILABLE, 0); 805 pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YAHOO_STATUS_AVAILABLE, 0);
817 806
818 yahoo_packet_hash(pkt, 1, dn); 807 yahoo_packet_hash(pkt, "sss", 1, dn, 104, room2, 117, msg1);
819 yahoo_packet_hash(pkt, 104, room2);
820 yahoo_packet_hash(pkt, 117, msg1);
821 if (me) 808 if (me)
822 yahoo_packet_hash(pkt, 124, "2"); 809 yahoo_packet_hash_str(pkt, 124, "2");
823 else 810 else
824 yahoo_packet_hash(pkt, 124, "1"); 811 yahoo_packet_hash_str(pkt, 124, "1");
825 /* fixme: what about /think? (124=3) */ 812 /* fixme: what about /think? (124=3) */
826 if (utf8) 813 if (utf8)
827 yahoo_packet_hash(pkt, 97, "1"); 814 yahoo_packet_hash_str(pkt, 97, "1");
828 815
829 yahoo_packet_send_and_free(pkt, yd); 816 yahoo_packet_send_and_free(pkt, yd);
830 g_free(msg1); 817 g_free(msg1);
831 g_free(room2); 818 g_free(room2);
832 819
850 /* apparently room names are always utf8, or else always not utf8, 837 /* apparently room names are always utf8, or else always not utf8,
851 * so we don't have to actually pass the flag in the packet. Or something. */ 838 * so we don't have to actually pass the flag in the packet. Or something. */
852 room2 = yahoo_string_encode(gc, room, &utf8); 839 room2 = yahoo_string_encode(gc, room, &utf8);
853 840
854 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YAHOO_STATUS_AVAILABLE, 0); 841 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATJOIN, YAHOO_STATUS_AVAILABLE, 0);
855 842 yahoo_packet_hash(pkt, "ssss", 1, gaim_connection_get_display_name(gc),
856 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); 843 62, "2", 104, room2, 129, "0");
857 yahoo_packet_hash(pkt, 62, "2");
858 yahoo_packet_hash(pkt, 104, room2);
859 yahoo_packet_hash(pkt, 129, "0");
860
861 yahoo_packet_send_and_free(pkt, yd); 844 yahoo_packet_send_and_free(pkt, yd);
862 g_free(room2); 845 g_free(room2);
863 } 846 }
864 847
865 static void yahoo_chat_invite(GaimConnection *gc, const char *dn, const char *buddy, 848 static void yahoo_chat_invite(GaimConnection *gc, const char *dn, const char *buddy,
878 } 861 }
879 862
880 room2 = yahoo_string_encode(gc, room, &utf8); 863 room2 = yahoo_string_encode(gc, room, &utf8);
881 if (msg) 864 if (msg)
882 msg2 = yahoo_string_encode(gc, msg, NULL); 865 msg2 = yahoo_string_encode(gc, msg, NULL);
866
883 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATADDINVITE, YAHOO_STATUS_AVAILABLE, 0); 867 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATADDINVITE, YAHOO_STATUS_AVAILABLE, 0);
884 868 yahoo_packet_hash(pkt, "sssss", 1, dn, 118, buddy, 104, room2, 117, (msg2?msg2:""), 129, "0");
885 yahoo_packet_hash(pkt, 1, dn);
886 yahoo_packet_hash(pkt, 118, buddy);
887 yahoo_packet_hash(pkt, 104, room2);
888 yahoo_packet_hash(pkt, 117, (msg2?msg2:""));
889 yahoo_packet_hash(pkt, 129, "0");
890
891 yahoo_packet_send_and_free(pkt, yd); 869 yahoo_packet_send_and_free(pkt, yd);
892 870
893 g_free(room2); 871 g_free(room2);
894 g_free(msg2); 872 g_free(msg2);
895 } 873 }
910 888
911 if (!yd->chat_online) 889 if (!yd->chat_online)
912 yahoo_chat_online(gc); 890 yahoo_chat_online(gc);
913 891
914 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATGOTO, YAHOO_STATUS_AVAILABLE, 0); 892 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATGOTO, YAHOO_STATUS_AVAILABLE, 0);
915 893 yahoo_packet_hash(pkt, "sss", 109, name, 1, gaim_connection_get_display_name(gc), 62, "2");
916 yahoo_packet_hash(pkt, 109, name);
917 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
918 yahoo_packet_hash(pkt, 62, "2");
919
920 yahoo_packet_send_and_free(pkt, yd); 894 yahoo_packet_send_and_free(pkt, yd);
921 } 895 }
922 /* 896 /*
923 * These are the functions registered with the core 897 * These are the functions registered with the core
924 * which get called for both chats and conferences. 898 * which get called for both chats and conferences.