comparison src/toc.c @ 1030:38452403563b

[gaim-migrate @ 1040] updating the buddy list to work better with multiple connections. there are still a bunch of things fucked up with this but i wanted more people to start working on it than just me, especially since i won't be here this weekend. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 27 Oct 2000 07:53:32 +0000
parents e1e36f95af9a
children 643a4d81c18a
comparison
equal deleted inserted replaced
1029:740c6f933fe0 1030:38452403563b
38 #include "prpl.h" 38 #include "prpl.h"
39 #include "multi.h" 39 #include "multi.h"
40 #include "gaim.h" 40 #include "gaim.h"
41 #include "gnome_applet_mgr.h" 41 #include "gnome_applet_mgr.h"
42 42
43 #define REVISION "gaim:$Revision: 1030 $" 43 #include "pixmaps/admin_icon.xpm"
44 #include "pixmaps/aol_icon.xpm"
45 #include "pixmaps/away_icon.xpm"
46 #include "pixmaps/dt_icon.xpm"
47 #include "pixmaps/free_icon.xpm"
48
49 #define REVISION "gaim:$Revision: 1040 $"
44 50
45 struct toc_data { 51 struct toc_data {
46 int toc_fd; 52 int toc_fd;
47 int seqno; 53 int seqno;
48 int state; 54 int state;
134 g_snprintf(buf, sizeof(buf), "Retrieving config..."); 140 g_snprintf(buf, sizeof(buf), "Retrieving config...");
135 set_login_progress(gc, 5, buf); 141 set_login_progress(gc, 5, buf);
136 while (gtk_events_pending()) 142 while (gtk_events_pending())
137 gtk_main_iteration(); 143 gtk_main_iteration();
138 144
139 account_online(gc); 145 account_online(user, gc);
140 serv_finish_login(gc); 146 serv_finish_login(gc);
141 147
142 config = toc_wait_config(gc); 148 config = toc_wait_config(gc);
143 tdt->state = STATE_ONLINE; 149 tdt->state = STATE_ONLINE;
144 150
412 time(&time_idle); 418 time(&time_idle);
413 time_idle -= idle*60; 419 time_idle -= idle*60;
414 } else 420 } else
415 time_idle = 0; 421 time_idle = 0;
416 422
417 serv_got_update(c, logged, evil, signon, time_idle, type, 0); 423 serv_got_update(gc, c, logged, evil, signon, time_idle, type, 0);
418 424
419 } else if (!strcasecmp(c, "CONFIG")) { 425 } else if (!strcasecmp(c, "CONFIG")) {
420 /* do we want to load the buddy list again here? */ 426 /* do we want to load the buddy list again here? */
421 c = strtok(NULL,":"); 427 c = strtok(NULL,":");
422 parse_toc_buddy_list(gc, c, 0); 428 parse_toc_buddy_list(gc, c, 0);
802 return buf; 808 return buf;
803 else 809 else
804 return NULL; 810 return NULL;
805 } 811 }
806 812
807 void toc_build_config(char *s, int len, gboolean show) 813 void toc_build_config(struct gaim_connection *gc, char *s, int len, gboolean show)
808 { 814 {
809 GSList *grp = groups; 815 GSList *grp = gc->groups;
810 GList *mem; 816 GSList *mem;
811 struct group *g; 817 struct group *g;
812 struct buddy *b; 818 struct buddy *b;
813 GList *plist = permit; 819 GSList *plist = gc->permit;
814 GList *dlist = deny; 820 GSList *dlist = gc->deny;
815 821
816 int pos=0; 822 int pos=0;
817 823
818 if (!permdeny) 824 if (!gc->permdeny)
819 permdeny = 1; 825 gc->permdeny = 1;
820 826
821 pos += g_snprintf(&s[pos], len - pos, "m %d\n", permdeny); 827 pos += g_snprintf(&s[pos], len - pos, "m %d\n", gc->permdeny);
822 while(grp) { 828 while(grp) {
823 g = (struct group *)grp->data; 829 g = (struct group *)grp->data;
824 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name); 830 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name);
825 mem = g->members; 831 mem = g->members;
826 while(mem) { 832 while(mem) {
862 do { 868 do {
863 if (c == NULL) 869 if (c == NULL)
864 break; 870 break;
865 if (*c == 'g') { 871 if (*c == 'g') {
866 strncpy(current,c+2, sizeof(current)); 872 strncpy(current,c+2, sizeof(current));
867 add_group(current); 873 add_group(gc, current);
868 how_many++; 874 how_many++;
869 } else if (*c == 'b' && !find_buddy(c+2)) { 875 } else if (*c == 'b' && !find_buddy(gc, c+2)) {
870 char nm[80], sw[80], *tmp = c+2; 876 char nm[80], sw[80], *tmp = c+2;
871 int i = 0; 877 int i = 0;
872 while (*tmp != ':' && *tmp) 878 while (*tmp != ':' && *tmp)
873 nm[i++] = *tmp++; 879 nm[i++] = *tmp++;
874 if (*tmp == ':') *tmp++ = '\0'; 880 if (*tmp == ':') *tmp++ = '\0';
875 nm[i] = '\0'; 881 nm[i] = '\0';
876 i = 0; 882 i = 0;
877 while (*tmp) sw[i++] = *tmp++; 883 while (*tmp) sw[i++] = *tmp++;
878 sw[i] = '\0'; 884 sw[i] = '\0';
879 if (!find_buddy(nm)) 885 if (!find_buddy(gc, nm))
880 add_buddy(current, nm, sw); 886 add_buddy(gc, current, nm, sw);
881 how_many++; 887 how_many++;
882 888
883 bud = g_list_append(bud, c+2); 889 bud = g_list_append(bud, c+2);
884 } else if (*c == 'p') { 890 } else if (*c == 'p') {
885 GList *d = permit; 891 GSList *d = gc->permit;
886 char *n; 892 char *n;
887 name = g_malloc(strlen(c+2) + 2); 893 name = g_malloc(strlen(c+2) + 2);
888 g_snprintf(name, strlen(c+2) + 1, "%s", c+2); 894 g_snprintf(name, strlen(c+2) + 1, "%s", c+2);
889 n = g_strdup(normalize(name)); 895 n = g_strdup(normalize(name));
890 while (d) { 896 while (d) {
892 break; 898 break;
893 d = d->next; 899 d = d->next;
894 } 900 }
895 g_free(n); 901 g_free(n);
896 if (!d) 902 if (!d)
897 permit = g_list_append(permit, name); 903 gc->permit = g_slist_append(gc->permit, name);
898 } else if (*c == 'd') { 904 } else if (*c == 'd') {
899 GList *d = deny; 905 GSList *d = gc->deny;
900 char *n; 906 char *n;
901 name = g_malloc(strlen(c+2) + 2); 907 name = g_malloc(strlen(c+2) + 2);
902 g_snprintf(name, strlen(c+2) + 1, "%s", c+2); 908 g_snprintf(name, strlen(c+2) + 1, "%s", c+2);
903 n = g_strdup(normalize(name)); 909 n = g_strdup(normalize(name));
904 while (d) { 910 while (d) {
906 break; 912 break;
907 d = d->next; 913 d = d->next;
908 } 914 }
909 g_free(n); 915 g_free(n);
910 if (!d) 916 if (!d)
911 deny = g_list_append(deny, name); 917 gc->deny = g_slist_append(gc->deny, name);
912 } else if (!strncmp("toc", c, 3)) { 918 } else if (!strncmp("toc", c, 3)) {
913 sscanf(c + strlen(c) - 1, "%d", &permdeny); 919 sscanf(c + strlen(c) - 1, "%d", &gc->permdeny);
914 sprintf(debug_buff, "permdeny: %d\n", permdeny); 920 sprintf(debug_buff, "permdeny: %d\n", gc->permdeny);
915 debug_print(debug_buff); 921 debug_print(debug_buff);
916 if (permdeny == 0) 922 if (gc->permdeny == 0)
917 permdeny = 1; 923 gc->permdeny = 1;
918 } else if (*c == 'm') { 924 } else if (*c == 'm') {
919 sscanf(c + 2, "%d", &permdeny); 925 sscanf(c + 2, "%d", &gc->permdeny);
920 sprintf(debug_buff, "permdeny: %d\n", permdeny); 926 sprintf(debug_buff, "permdeny: %d\n", gc->permdeny);
921 debug_print(debug_buff); 927 debug_print(debug_buff);
922 if (permdeny == 0) 928 if (gc->permdeny == 0)
923 permdeny = 1; 929 gc->permdeny = 1;
924 } 930 }
925 } while((c=strtok(NULL,"\n"))); 931 } while((c=strtok(NULL,"\n")));
926 #if 0 932 #if 0
927 fprintf(stdout, "Sending message '%s'\n",buf); 933 fprintf(stdout, "Sending message '%s'\n",buf);
928 #endif 934 #endif
929 935
930 if (bud != NULL) serv_add_buddies(bud); 936 if (bud != NULL) serv_add_buddies(gc, bud);
931 serv_set_permit_deny(); 937 serv_set_permit_deny(gc);
932 if (blist) { 938 if (blist) {
933 build_edit_tree(); 939 build_edit_tree();
934 build_permit_tree();
935 } 940 }
936 } 941 }
937 942
938 /* perhaps the server dropped the buddy list, try importing from 943 /* perhaps the server dropped the buddy list, try importing from
939 cache */ 944 cache */
1094 1099
1095 static void toc_keepalive(struct gaim_connection *gc) { 1100 static void toc_keepalive(struct gaim_connection *gc) {
1096 sflap_send(gc, "", 0, TYPE_KEEPALIVE); 1101 sflap_send(gc, "", 0, TYPE_KEEPALIVE);
1097 } 1102 }
1098 1103
1104 static char **toc_list_icon(int uc) {
1105 if (uc & UC_UNAVAILABLE)
1106 return (char **)away_icon_xpm;
1107 if (uc & UC_AOL)
1108 return (char **)aol_icon_xpm;
1109 if (uc & UC_NORMAL)
1110 return (char **)free_icon_xpm;
1111 if (uc & UC_ADMIN)
1112 return (char **)admin_icon_xpm;
1113 if (uc & UC_UNCONFIRMED)
1114 return (char **)dt_icon_xpm;
1115 return NULL;
1116 }
1117
1099 void toc_init(struct prpl *ret) { 1118 void toc_init(struct prpl *ret) {
1100 ret->protocol = PROTO_TOC; 1119 ret->protocol = PROTO_TOC;
1101 ret->name = toc_name; 1120 ret->name = toc_name;
1121 ret->list_icon = toc_list_icon;
1102 ret->login = toc_login; 1122 ret->login = toc_login;
1103 ret->close = toc_close; 1123 ret->close = toc_close;
1104 ret->send_im = toc_send_im; 1124 ret->send_im = toc_send_im;
1105 ret->set_info = toc_set_info; 1125 ret->set_info = toc_set_info;
1106 ret->get_info = toc_get_info; 1126 ret->get_info = toc_get_info;