comparison src/protocols/yahoo/yahoochat.c @ 10392:a8f9e5ce4f92

[gaim-migrate @ 11620] a little bit of clean up and reorganization of the yahoo prpl. I moved the packet functions to their own file, renamed a couple of them, added a convience function and used it a lot. I plan on adding several more convience functions. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Thu, 16 Dec 2004 21:47:54 +0000
parents e74eb0d11f86
children 45a0a07e8b25
comparison
equal deleted inserted replaced
10391:38256d3e8324 10392:a8f9e5ce4f92
37 #include "notify.h" 37 #include "notify.h"
38 #include "util.h" 38 #include "util.h"
39 #include "internal.h" 39 #include "internal.h"
40 40
41 #include "yahoo.h" 41 #include "yahoo.h"
42 #include "yahoo_packet.h"
42 #include "yahoochat.h" 43 #include "yahoochat.h"
43 #include "ycht.h" 44 #include "ycht.h"
44 45
45 #define YAHOO_CHAT_ID (1) 46 #define YAHOO_CHAT_ID (1)
46 47
60 61
61 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YAHOO_STATUS_AVAILABLE,0); 62 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATONLINE, YAHOO_STATUS_AVAILABLE,0);
62 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); 63 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
63 yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); 64 yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc));
64 yahoo_packet_hash(pkt, 6, "abcde"); 65 yahoo_packet_hash(pkt, 6, "abcde");
65 66 yahoo_packet_send_and_free(pkt, yd);
66 yahoo_send_packet(yd, pkt);
67
68 yahoo_packet_free(pkt);
69 } 67 }
70 68
71 /* this is slow, and different from the gaim_* version in that it (hopefully) won't add a user twice */ 69 /* this is slow, and different from the gaim_* version in that it (hopefully) won't add a user twice */
72 void yahoo_chat_add_users(GaimConvChat *chat, GList *newusers) 70 void yahoo_chat_add_users(GaimConvChat *chat, GList *newusers)
73 { 71 {
601 yahoo_packet_hash(pkt, 3, name); 599 yahoo_packet_hash(pkt, 3, name);
602 } 600 }
603 601
604 yahoo_packet_hash(pkt, 57, room); 602 yahoo_packet_hash(pkt, 57, room);
605 603
606 yahoo_send_packet(yd, pkt); 604 yahoo_packet_send_and_free(pkt, yd);
607
608 yahoo_packet_free(pkt);
609 } 605 }
610 606
611 static int yahoo_conf_send(GaimConnection *gc, const char *dn, const char *room, 607 static int yahoo_conf_send(GaimConnection *gc, const char *dn, const char *room,
612 GList *members, const char *what) 608 GList *members, const char *what)
613 { 609 {
631 yahoo_packet_hash(pkt, 57, room); 627 yahoo_packet_hash(pkt, 57, room);
632 yahoo_packet_hash(pkt, 14, msg2); 628 yahoo_packet_hash(pkt, 14, msg2);
633 if (utf8) 629 if (utf8)
634 yahoo_packet_hash(pkt, 97, "1"); /* utf-8 */ 630 yahoo_packet_hash(pkt, 97, "1"); /* utf-8 */
635 631
636 yahoo_send_packet(yd, pkt); 632 yahoo_packet_send_and_free(pkt, yd);
637
638 yahoo_packet_free(pkt);
639 g_free(msg); 633 g_free(msg);
640 g_free(msg2); 634 g_free(msg2);
641 635
642 return 0; 636 return 0;
643 } 637 }
664 continue; 658 continue;
665 yahoo_packet_hash(pkt, 3, memarr[i]); 659 yahoo_packet_hash(pkt, 3, memarr[i]);
666 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c), memarr[i], NULL, GAIM_CBFLAGS_NONE, TRUE); 660 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c), memarr[i], NULL, GAIM_CBFLAGS_NONE, TRUE);
667 } 661 }
668 } 662 }
669 yahoo_send_packet(yd, pkt); 663 yahoo_packet_send_and_free(pkt, yd);
670
671 yahoo_packet_free(pkt);
672 664
673 if (memarr) 665 if (memarr)
674 g_strfreev(memarr); 666 g_strfreev(memarr);
675 } 667 }
676 668
699 if (!strcmp(name, dn)) 691 if (!strcmp(name, dn))
700 continue; 692 continue;
701 yahoo_packet_hash(pkt, 52, name); 693 yahoo_packet_hash(pkt, 52, name);
702 yahoo_packet_hash(pkt, 53, name); 694 yahoo_packet_hash(pkt, 53, name);
703 } 695 }
704 yahoo_send_packet(yd, pkt); 696
705 697 yahoo_packet_send_and_free(pkt, yd);
706 yahoo_packet_free(pkt); 698 g_free(msg2);
707 if (msg)
708 g_free(msg2);
709 } 699 }
710 700
711 /* 701 /*
712 * Functions dealing with chats 702 * Functions dealing with chats
713 */ 703 */
734 yahoo_packet_hash(pkt, 104, eroom); 724 yahoo_packet_hash(pkt, 104, eroom);
735 yahoo_packet_hash(pkt, 109, dn); 725 yahoo_packet_hash(pkt, 109, dn);
736 yahoo_packet_hash(pkt, 108, "1"); 726 yahoo_packet_hash(pkt, 108, "1");
737 yahoo_packet_hash(pkt, 112, "0"); /* what does this one mean? */ 727 yahoo_packet_hash(pkt, 112, "0"); /* what does this one mean? */
738 728
739 yahoo_send_packet(yd, pkt); 729 yahoo_packet_send_and_free(pkt, yd);
740
741 yahoo_packet_free(pkt);
742 730
743 yd->in_chat = 0; 731 yd->in_chat = 0;
744 if (yd->chat_name) { 732 if (yd->chat_name) {
745 g_free(yd->chat_name); 733 g_free(yd->chat_name);
746 yd->chat_name = NULL; 734 yd->chat_name = NULL;
753 return; 741 return;
754 742
755 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT, 743 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATLOGOUT,
756 YAHOO_STATUS_AVAILABLE, 0); 744 YAHOO_STATUS_AVAILABLE, 0);
757 yahoo_packet_hash(pkt, 1, dn); 745 yahoo_packet_hash(pkt, 1, dn);
758 yahoo_send_packet(yd, pkt); 746 yahoo_packet_send_and_free(pkt, yd);
759 yahoo_packet_free(pkt);
760 747
761 yd->chat_online = 0; 748 yd->chat_online = 0;
762 g_free(eroom); 749 g_free(eroom);
763 } 750 }
764 751
837 yahoo_packet_hash(pkt, 124, "1"); 824 yahoo_packet_hash(pkt, 124, "1");
838 /* fixme: what about /think? (124=3) */ 825 /* fixme: what about /think? (124=3) */
839 if (utf8) 826 if (utf8)
840 yahoo_packet_hash(pkt, 97, "1"); 827 yahoo_packet_hash(pkt, 97, "1");
841 828
842 yahoo_send_packet(yd, pkt); 829 yahoo_packet_send_and_free(pkt, yd);
843 yahoo_packet_free(pkt);
844 g_free(msg1); 830 g_free(msg1);
845 g_free(room2); 831 g_free(room2);
846 832
847 return 0; 833 return 0;
848 } 834 }
870 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); 856 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
871 yahoo_packet_hash(pkt, 62, "2"); 857 yahoo_packet_hash(pkt, 62, "2");
872 yahoo_packet_hash(pkt, 104, room2); 858 yahoo_packet_hash(pkt, 104, room2);
873 yahoo_packet_hash(pkt, 129, "0"); 859 yahoo_packet_hash(pkt, 129, "0");
874 860
875 yahoo_send_packet(yd, pkt); 861 yahoo_packet_send_and_free(pkt, yd);
876
877 yahoo_packet_free(pkt);
878 g_free(room2); 862 g_free(room2);
879 } 863 }
880 864
881 static void yahoo_chat_invite(GaimConnection *gc, const char *dn, const char *buddy, 865 static void yahoo_chat_invite(GaimConnection *gc, const char *dn, const char *buddy,
882 const char *room, const char *msg) 866 const char *room, const char *msg)
902 yahoo_packet_hash(pkt, 118, buddy); 886 yahoo_packet_hash(pkt, 118, buddy);
903 yahoo_packet_hash(pkt, 104, room2); 887 yahoo_packet_hash(pkt, 104, room2);
904 yahoo_packet_hash(pkt, 117, (msg2?msg2:"")); 888 yahoo_packet_hash(pkt, 117, (msg2?msg2:""));
905 yahoo_packet_hash(pkt, 129, "0"); 889 yahoo_packet_hash(pkt, 129, "0");
906 890
907 yahoo_send_packet(yd, pkt); 891 yahoo_packet_send_and_free(pkt, yd);
908 yahoo_packet_free(pkt);
909 892
910 g_free(room2); 893 g_free(room2);
911 if (msg2) 894 g_free(msg2);
912 g_free(msg2);
913 } 895 }
914 896
915 void yahoo_chat_goto(GaimConnection *gc, const char *name) 897 void yahoo_chat_goto(GaimConnection *gc, const char *name)
916 { 898 {
917 struct yahoo_data *yd; 899 struct yahoo_data *yd;
933 915
934 yahoo_packet_hash(pkt, 109, name); 916 yahoo_packet_hash(pkt, 109, name);
935 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); 917 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
936 yahoo_packet_hash(pkt, 62, "2"); 918 yahoo_packet_hash(pkt, 62, "2");
937 919
938 yahoo_send_packet(yd, pkt); 920 yahoo_packet_send_and_free(pkt, yd);
939 yahoo_packet_free(pkt);
940 } 921 }
941 /* 922 /*
942 * These are the functions registered with the core 923 * These are the functions registered with the core
943 * which get called for both chats and conferences. 924 * which get called for both chats and conferences.
944 */ 925 */