comparison src/protocols/toc/toc.c @ 9285:7a8aa87164ae

[gaim-migrate @ 10088] Ok I'm done. This started out as shx's patch to make add/remove buddy/buddies take GaimBuddy and GaimGroup's in various places. I think his diff was like 2000 lines and mine is like 5000. I tried to clean up blist.c a bit and make it more uniform. There are some more g_return_if_fail() checks. Removed some code that was deprecated--it's probably been long enough. Removed some #include <multi.h>'s. Make blist.xml saving happen on a timer, like prefs.xml and accounts.xml. Sorry if this doesn't merge cleanly with whatever you're doing. People should really test this a lot. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 15 Jun 2004 02:37:27 +0000
parents 8b1af7cadeb8
children b3bda982996b
comparison
equal deleted inserted replaced
9284:fe0291162312 9285:7a8aa87164ae
565 struct toc_data *tdt = (struct toc_data *)gc->proto_data; 565 struct toc_data *tdt = (struct toc_data *)gc->proto_data;
566 struct sflap_hdr *hdr; 566 struct sflap_hdr *hdr;
567 struct signon so; 567 struct signon so;
568 char buf[8 * 1024], *c; 568 char buf[8 * 1024], *c;
569 char snd[BUF_LEN * 2]; 569 char snd[BUF_LEN * 2];
570
571 const char *username = gaim_account_get_username(account); 570 const char *username = gaim_account_get_username(account);
572 char *password; 571 char *password;
572 GaimBuddy *buddy;
573 573
574 /* there's data waiting to be read, so read it. */ 574 /* there's data waiting to be read, so read it. */
575 if (wait_reply(gc, buf, 8 * 1024) <= 0) { 575 if (wait_reply(gc, buf, 8 * 1024) <= 0) {
576 gaim_connection_error(gc, _("Connection Closed")); 576 gaim_connection_error(gc, _("Connection Closed"));
577 return; 577 return;
645 645
646 /* 646 /*
647 * Add me to my buddy list so that we know the time when 647 * Add me to my buddy list so that we know the time when
648 * the server thinks I signed on. 648 * the server thinks I signed on.
649 */ 649 */
650 serv_add_buddy(gc, username, NULL); 650 buddy = gaim_buddy_new(account, username, NULL);
651 /* XXX - Pick a group to add to */
652 /* gaim_blist_add(buddy, NULL, g, NULL); */
653 serv_add_buddy(gc, buddy);
651 654
652 /* Client sends TOC toc_init_done message */ 655 /* Client sends TOC toc_init_done message */
653 gaim_debug(GAIM_DEBUG_INFO, "toc", 656 gaim_debug(GAIM_DEBUG_INFO, "toc",
654 "Client sends TOC toc_init_done message\n"); 657 "Client sends TOC toc_init_done message\n");
655 g_snprintf(snd, sizeof snd, "toc_init_done"); 658 g_snprintf(snd, sizeof snd, "toc_init_done");
1183 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); 1186 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new);
1184 sflap_send(g, buf, -1, TYPE_DATA); 1187 sflap_send(g, buf, -1, TYPE_DATA);
1185 } 1188 }
1186 1189
1187 static void 1190 static void
1188 toc_add_buddy(GaimConnection *gc, const char *name, GaimGroup *group) 1191 toc_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group)
1189 { 1192 {
1190 char buf[BUF_LEN * 2]; 1193 char buf[BUF_LEN * 2];
1191 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", gaim_normalize(gc->account, name)); 1194 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", gaim_normalize(gc->account, buddy->name));
1192 sflap_send(gc, buf, -1, TYPE_DATA); 1195 sflap_send(gc, buf, -1, TYPE_DATA);
1193 toc_set_config(gc); 1196 toc_set_config(gc);
1194 } 1197 }
1195 1198
1196 static void toc_add_buddies(GaimConnection *gc, GList *buddies) 1199 static void toc_add_buddies(GaimConnection *gc, GList *buddies, GList *groups)
1197 { 1200 {
1198 char buf[BUF_LEN * 2]; 1201 char buf[BUF_LEN * 2];
1199 int n; 1202 int n;
1203 GList *cur;
1200 1204
1201 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); 1205 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy");
1202 while (buddies) { 1206 for (cur = buddies; cur != NULL; cur = cur->next) {
1203 if (strlen(gaim_normalize(gc->account, buddies->data)) + n + 32 > MSG_LEN) { 1207 GaimBuddy *buddy = cur->data;
1208
1209 if (strlen(gaim_normalize(gc->account, buddy->name)) + n + 32 > MSG_LEN) {
1204 sflap_send(gc, buf, -1, TYPE_DATA); 1210 sflap_send(gc, buf, -1, TYPE_DATA);
1205 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); 1211 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy");
1206 } 1212 }
1207 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddies->data)); 1213 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddy->name));
1208 buddies = buddies->next;
1209 } 1214 }
1210 sflap_send(gc, buf, -1, TYPE_DATA); 1215 sflap_send(gc, buf, -1, TYPE_DATA);
1211 } 1216 }
1212 1217
1213 static void toc_remove_buddy(GaimConnection *gc, const char *name, const char *group) 1218 static void toc_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group)
1214 { 1219 {
1215 char buf[BUF_LEN * 2]; 1220 char buf[BUF_LEN * 2];
1216 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", gaim_normalize(gc->account, name)); 1221 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", gaim_normalize(gc->account, buddy->name));
1217 sflap_send(gc, buf, -1, TYPE_DATA); 1222 sflap_send(gc, buf, -1, TYPE_DATA);
1218 toc_set_config(gc); 1223 toc_set_config(gc);
1219 } 1224 }
1220 1225
1221 static void toc_remove_buddies(GaimConnection *gc, GList *buddies, const char *group) 1226 static void toc_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups)
1222 { 1227 {
1223 char buf[BUF_LEN * 2]; 1228 char buf[BUF_LEN * 2];
1224 int n; 1229 int n;
1230 GList *cur;
1225 1231
1226 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); 1232 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy");
1227 while (buddies) { 1233 for (cur = buddies; cur != NULL; cur = cur->next) {
1228 if (strlen(gaim_normalize(gc->account, buddies->data)) + n + 32 > MSG_LEN) { 1234 GaimBuddy *buddy = cur->data;
1235
1236 if (strlen(gaim_normalize(gc->account, buddy->name)) + n + 32 > MSG_LEN) {
1229 sflap_send(gc, buf, -1, TYPE_DATA); 1237 sflap_send(gc, buf, -1, TYPE_DATA);
1230 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); 1238 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy");
1231 } 1239 }
1232 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddies->data)); 1240 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddy->name));
1233 buddies = buddies->next;
1234 } 1241 }
1235 sflap_send(gc, buf, -1, TYPE_DATA); 1242 sflap_send(gc, buf, -1, TYPE_DATA);
1236 toc_set_config(gc); 1243 toc_set_config(gc);
1237 } 1244 }
1238 1245