comparison src/protocols/toc/toc.c @ 4349:0c68d402f59f

[gaim-migrate @ 4614] XML Blist Gaim stores all the buddy lists in one big happy file now. You can order the buddies however you want, and they'll stay ordered that way. We can also store some per-buddy information now, which will be cool. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 19 Jan 2003 22:16:52 +0000
parents cc2f780c0505
children 5fb47ec9bfe4
comparison
equal deleted inserted replaced
4348:922b66840a51 4349:0c68d402f59f
511 g_snprintf(buf, sizeof(buf), _("Your warning level is currently too high to log in.")); 511 g_snprintf(buf, sizeof(buf), _("Your warning level is currently too high to log in."));
512 break; 512 break;
513 case 983: 513 case 983:
514 g_snprintf(buf, sizeof(buf), _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); 514 g_snprintf(buf, sizeof(buf), _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));
515 break; 515 break;
516 case 989:
517 g_snprintf(buf, sizeof(buf), _("An unknown signon error has occurred: %s."), w); 516 g_snprintf(buf, sizeof(buf), _("An unknown signon error has occurred: %s."), w);
518 break; 517 break;
519 default: 518 default:
520 g_snprintf(buf, sizeof(buf), _("An unknown error, %d, has occurred. Info: %s"), no, w); 519 g_snprintf(buf, sizeof(buf), _("An unknown error, %d, has occurred. Info: %s"), no, w);
521 } 520 }
599 tdt->state = STATE_ONLINE; 598 tdt->state = STATE_ONLINE;
600 599
601 account_online(gc); 600 account_online(gc);
602 serv_finish_login(gc); 601 serv_finish_login(gc);
603 602
604 if (bud_list_cache_exists(gc))
605 do_import(gc, NULL);
606
607 /* Client sends TOC toc_init_done message */ 603 /* Client sends TOC toc_init_done message */
608 debug_printf("* Client sends TOC toc_init_done message\n"); 604 debug_printf("* Client sends TOC toc_init_done message\n");
609 g_snprintf(snd, sizeof snd, "toc_init_done"); 605 g_snprintf(snd, sizeof snd, "toc_init_done");
610 sflap_send(gc, snd, -1, TYPE_DATA); 606 sflap_send(gc, snd, -1, TYPE_DATA);
611 607
635 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { 631 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) {
636 hide_login_progress(gc, _("Disconnected.")); 632 hide_login_progress(gc, _("Disconnected."));
637 signoff(gc); 633 signoff(gc);
638 return; 634 return;
639 } 635 }
640 if (bud_list_cache_exists(gc))
641 do_import(gc, NULL);
642 g_snprintf(snd, sizeof snd, "toc_init_done"); 636 g_snprintf(snd, sizeof snd, "toc_init_done");
643 sflap_send(gc, snd, -1, TYPE_DATA); 637 sflap_send(gc, snd, -1, TYPE_DATA);
644 do_error_dialog(_("TOC has come back from its pause. You may now send" 638 do_error_dialog(_("TOC has come back from its pause. You may now send"
645 " messages again."), NULL, GAIM_INFO); 639 " messages again."), NULL, GAIM_INFO);
646 } 640 }
647 } else if (!strcasecmp(c, "CONFIG")) { 641 } else if (!strcasecmp(c, "CONFIG")) {
648 c = strtok(NULL, ":"); 642 c = strtok(NULL, ":");
649 parse_toc_buddy_list(gc, c); 643 parse_toc_buddy_list(gc->user, c);
650 } else if (!strcasecmp(c, "NICK")) { 644 } else if (!strcasecmp(c, "NICK")) {
651 /* ignore NICK so that things get imported/exported properly 645 /* ignore NICK so that things get imported/exported properly
652 c = strtok(NULL, ":"); 646 c = strtok(NULL, ":");
653 g_snprintf(gc->username, sizeof(gc->username), "%s", c); 647 g_snprintf(gc->username, sizeof(gc->username), "%s", c);
654 */ 648 */
993 } 987 }
994 988
995 static void toc_set_config(struct gaim_connection *gc) 989 static void toc_set_config(struct gaim_connection *gc)
996 { 990 {
997 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2]; 991 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2];
998 toc_build_config(gc, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE); 992 toc_build_config(gc->user, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE);
999 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); 993 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf);
1000 sflap_send(gc, snd, -1, TYPE_DATA); 994 sflap_send(gc, snd, -1, TYPE_DATA);
1001 g_free(buf); 995 g_free(buf);
1002 } 996 }
1003 997
1270 m = g_list_append(m, pbm); 1264 m = g_list_append(m, pbm);
1271 1265
1272 return m; 1266 return m;
1273 } 1267 }
1274 1268
1275 static void toc_add_permit(struct gaim_connection *gc, char *who) 1269 static void toc_add_permit(struct gaim_connection *gc, const char *who)
1276 { 1270 {
1277 char buf2[BUF_LEN * 2]; 1271 char buf2[BUF_LEN * 2];
1278 if (gc->permdeny != 3) 1272 if (gc->user->permdeny != 3)
1279 return; 1273 return;
1280 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", normalize(who)); 1274 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", normalize(who));
1281 sflap_send(gc, buf2, -1, TYPE_DATA); 1275 sflap_send(gc, buf2, -1, TYPE_DATA);
1282 toc_set_config(gc); 1276 toc_set_config(gc);
1283 signoff_blocked(gc); 1277 signoff_blocked(gc);
1284 } 1278 }
1285 1279
1286 static void toc_add_deny(struct gaim_connection *gc, char *who) 1280 static void toc_add_deny(struct gaim_connection *gc, const char *who)
1287 { 1281 {
1288 char buf2[BUF_LEN * 2]; 1282 char buf2[BUF_LEN * 2];
1289 if (gc->permdeny != 4) 1283 if (gc->user->permdeny != 4)
1290 return; 1284 return;
1291 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", normalize(who)); 1285 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", normalize(who));
1292 sflap_send(gc, buf2, -1, TYPE_DATA); 1286 sflap_send(gc, buf2, -1, TYPE_DATA);
1293 toc_set_config(gc); 1287 toc_set_config(gc);
1294 signoff_blocked(gc); 1288 signoff_blocked(gc);
1298 { 1292 {
1299 char buf2[BUF_LEN * 2]; 1293 char buf2[BUF_LEN * 2];
1300 GSList *list; 1294 GSList *list;
1301 int at; 1295 int at;
1302 1296
1303 switch (gc->permdeny) { 1297 switch (gc->user->permdeny) {
1304 case 1: 1298 case 1:
1305 /* permit all, deny none. to get here reliably we need to have been in permit 1299 /* permit all, deny none. to get here reliably we need to have been in permit
1306 * mode, and send an empty toc_add_deny message, which will switch us to deny none */ 1300 * mode, and send an empty toc_add_deny message, which will switch us to deny none */
1307 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); 1301 g_snprintf(buf2, sizeof(buf2), "toc_add_permit ");
1308 sflap_send(gc, buf2, -1, TYPE_DATA); 1302 sflap_send(gc, buf2, -1, TYPE_DATA);
1322 * message, which will clear and set our permit list. toc sucks. */ 1316 * message, which will clear and set our permit list. toc sucks. */
1323 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); 1317 g_snprintf(buf2, sizeof(buf2), "toc_add_deny ");
1324 sflap_send(gc, buf2, -1, TYPE_DATA); 1318 sflap_send(gc, buf2, -1, TYPE_DATA);
1325 1319
1326 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); 1320 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit ");
1327 list = gc->permit; 1321 list = gc->user->permit;
1328 while (list) { 1322 while (list) {
1329 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", normalize(list->data)); 1323 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", normalize(list->data));
1330 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ 1324 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */
1331 sflap_send(gc, buf2, -1, TYPE_DATA); 1325 sflap_send(gc, buf2, -1, TYPE_DATA);
1332 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); 1326 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit ");
1340 * message, which will clear and set our deny list. toc sucks. */ 1334 * message, which will clear and set our deny list. toc sucks. */
1341 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); 1335 g_snprintf(buf2, sizeof(buf2), "toc_add_permit ");
1342 sflap_send(gc, buf2, -1, TYPE_DATA); 1336 sflap_send(gc, buf2, -1, TYPE_DATA);
1343 1337
1344 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); 1338 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny ");
1345 list = gc->deny; 1339 list = gc->user->deny;
1346 while (list) { 1340 while (list) {
1347 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", normalize(list->data)); 1341 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", normalize(list->data));
1348 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ 1342 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */
1349 sflap_send(gc, buf2, -1, TYPE_DATA); 1343 sflap_send(gc, buf2, -1, TYPE_DATA);
1350 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); 1344 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny ");
1358 } 1352 }
1359 toc_set_config(gc); 1353 toc_set_config(gc);
1360 signoff_blocked(gc); 1354 signoff_blocked(gc);
1361 } 1355 }
1362 1356
1363 static void toc_rem_permit(struct gaim_connection *gc, char *who) 1357 static void toc_rem_permit(struct gaim_connection *gc, const char *who)
1364 { 1358 {
1365 if (gc->permdeny != 3) 1359 if (gc->user->permdeny != 3)
1366 return; 1360 return;
1367 toc_set_permit_deny(gc); 1361 toc_set_permit_deny(gc);
1368 } 1362 }
1369 1363
1370 static void toc_rem_deny(struct gaim_connection *gc, char *who) 1364 static void toc_rem_deny(struct gaim_connection *gc, const char *who)
1371 { 1365 {
1372 if (gc->permdeny != 4) 1366 if (gc->user->permdeny != 4)
1373 return; 1367 return;
1374 toc_set_permit_deny(gc); 1368 toc_set_permit_deny(gc);
1375 } 1369 }
1376 1370
1377 static GList *toc_away_states(struct gaim_connection *gc) 1371 static GList *toc_away_states(struct gaim_connection *gc)