Mercurial > pidgin
comparison src/protocols/toc/toc.c @ 2334:b53cd5b63a99
[gaim-migrate @ 2347]
i feel like everyone's watching me
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Fri, 21 Sep 2001 00:14:12 +0000 |
| parents | a87ca0aa1840 |
| children | 29449a6b79e6 |
comparison
equal
deleted
inserted
replaced
| 2333:de907b3cf529 | 2334:b53cd5b63a99 |
|---|---|
| 234 debug_printf("message too long, truncating\n"); | 234 debug_printf("message too long, truncating\n"); |
| 235 buf[MSG_LEN - 1] = '\0'; | 235 buf[MSG_LEN - 1] = '\0'; |
| 236 len = MSG_LEN; | 236 len = MSG_LEN; |
| 237 } | 237 } |
| 238 | 238 |
| 239 if (olen < 0) | |
| 240 debug_printf("TOC C: %s\n", buf); | |
| 241 | |
| 239 hdr.ast = '*'; | 242 hdr.ast = '*'; |
| 240 hdr.type = type; | 243 hdr.type = type; |
| 241 hdr.seqno = htons(tdt->seqno++ & 0xffff); | 244 hdr.seqno = htons(tdt->seqno++ & 0xffff); |
| 242 hdr.len = htons(len + (type == TYPE_SIGNON ? 0 : 1)); | 245 hdr.len = htons(len + (type == TYPE_SIGNON ? 0 : 1)); |
| 243 | 246 |
| 306 return; | 309 return; |
| 307 | 310 |
| 308 g_show_info_text(url_text, NULL); | 311 g_show_info_text(url_text, NULL); |
| 309 } | 312 } |
| 310 | 313 |
| 314 static char *show_error_message(char *d) | |
| 315 { | |
| 316 int no = atoi(strtok(NULL, ":")); | |
| 317 char *w = strtok(NULL, ":"); | |
| 318 static char buf[256]; | |
| 319 | |
| 320 plugin_event(event_error, (void *)no, 0, 0, 0); | |
| 321 | |
| 322 switch(no) { | |
| 323 case 69: | |
| 324 g_snprintf(buf, sizeof(buf), _("Unable to write file %s."), w); | |
| 325 break; | |
| 326 case 169: | |
| 327 g_snprintf(buf, sizeof(buf), _("Unable to read file %s."), w); | |
| 328 break; | |
| 329 case 269: | |
| 330 g_snprintf(buf, sizeof(buf), _("Message too long, last %s bytes truncated."), w); | |
| 331 break; | |
| 332 case 901: | |
| 333 g_snprintf(buf, sizeof(buf), _("%s not currently logged in."), w); | |
| 334 break; | |
| 335 case 902: | |
| 336 g_snprintf(buf, sizeof(buf), _("Warning of %s not allowed."), w); | |
| 337 break; | |
| 338 case 903: | |
| 339 g_snprintf(buf, sizeof(buf), _("A message has been dropped, you are exceeding the server speed limit.")); | |
| 340 break; | |
| 341 case 950: | |
| 342 g_snprintf(buf, sizeof(buf), _("Chat in %s is not available."), w); | |
| 343 break; | |
| 344 case 960: | |
| 345 g_snprintf(buf, sizeof(buf), _("You are sending messages too fast to %s."), w); | |
| 346 break; | |
| 347 case 961: | |
| 348 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was too big."), w); | |
| 349 break; | |
| 350 case 962: | |
| 351 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was sent too fast."), w); | |
| 352 break; | |
| 353 case 970: | |
| 354 g_snprintf(buf, sizeof(buf), _("Failure.")); | |
| 355 break; | |
| 356 case 971: | |
| 357 g_snprintf(buf, sizeof(buf), _("Too many matches.")); | |
| 358 break; | |
| 359 case 972: | |
| 360 g_snprintf(buf, sizeof(buf), _("Need more qualifiers.")); | |
| 361 break; | |
| 362 case 973: | |
| 363 g_snprintf(buf, sizeof(buf), _("Dir service temporarily unavailable.")); | |
| 364 break; | |
| 365 case 974: | |
| 366 g_snprintf(buf, sizeof(buf), _("Email lookup restricted.")); | |
| 367 break; | |
| 368 case 975: | |
| 369 g_snprintf(buf, sizeof(buf), _("Keyword ignored.")); | |
| 370 break; | |
| 371 case 976: | |
| 372 g_snprintf(buf, sizeof(buf), _("No keywords.")); | |
| 373 break; | |
| 374 case 977: | |
| 375 g_snprintf(buf, sizeof(buf), _("User has no directory information.")); | |
| 376 /* g_snprintf(buf, sizeof(buf), "Language not supported."); */ | |
| 377 break; | |
| 378 case 978: | |
| 379 g_snprintf(buf, sizeof(buf), _("Country not supported.")); | |
| 380 break; | |
| 381 case 979: | |
| 382 g_snprintf(buf, sizeof(buf), _("Failure unknown: %s."), w); | |
| 383 break; | |
| 384 case 980: | |
| 385 g_snprintf(buf, sizeof(buf), _("Incorrect nickname or password.")); | |
| 386 break; | |
| 387 case 981: | |
| 388 g_snprintf(buf, sizeof(buf), _("The service is temporarily unavailable.")); | |
| 389 break; | |
| 390 case 982: | |
| 391 g_snprintf(buf, sizeof(buf), _("Your warning level is currently too high to log in.")); | |
| 392 break; | |
| 393 case 983: | |
| 394 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.")); | |
| 395 break; | |
| 396 case 989: | |
| 397 g_snprintf(buf, sizeof(buf), _("An unknown signon error has occurred: %s."), w); | |
| 398 break; | |
| 399 default: | |
| 400 g_snprintf(buf, sizeof(buf), _("An unknown error, %d, has occured. Info: %s"), no, w); | |
| 401 } | |
| 402 | |
| 403 return buf; | |
| 404 } | |
| 405 | |
| 311 static void toc_callback(gpointer data, gint source, GaimInputCondition condition) | 406 static void toc_callback(gpointer data, gint source, GaimInputCondition condition) |
| 312 { | 407 { |
| 313 struct gaim_connection *gc = (struct gaim_connection *)data; | 408 struct gaim_connection *gc = (struct gaim_connection *)data; |
| 314 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | 409 struct toc_data *tdt = (struct toc_data *)gc->proto_data; |
| 315 struct sflap_hdr *hdr; | 410 struct sflap_hdr *hdr; |
| 361 if (tdt->state == STATE_SIGNON_REQUEST) { | 456 if (tdt->state == STATE_SIGNON_REQUEST) { |
| 362 debug_printf("* TOC sends client SIGN_ON reply\n"); | 457 debug_printf("* TOC sends client SIGN_ON reply\n"); |
| 363 if (g_strncasecmp(buf + sizeof(struct sflap_hdr), "SIGN_ON", strlen("SIGN_ON"))) { | 458 if (g_strncasecmp(buf + sizeof(struct sflap_hdr), "SIGN_ON", strlen("SIGN_ON"))) { |
| 364 debug_printf("Didn't get SIGN_ON! buf was: %s\n", | 459 debug_printf("Didn't get SIGN_ON! buf was: %s\n", |
| 365 buf + sizeof(struct sflap_hdr)); | 460 buf + sizeof(struct sflap_hdr)); |
| 366 hide_login_progress(gc, _("Authentication Failed")); | 461 if (!g_strncasecmp(buf + sizeof(struct sflap_hdr), "ERROR", 5)) { |
| 462 strtok(buf + sizeof(struct sflap_hdr), ":"); | |
| 463 hide_login_progress(gc, show_error_message(buf + | |
| 464 sizeof(struct sflap_hdr))); | |
| 465 } else | |
| 466 hide_login_progress(gc, _("Authentication Failed")); | |
| 367 signoff(gc); | 467 signoff(gc); |
| 368 return; | 468 return; |
| 369 } | 469 } |
| 370 /* we're supposed to check that it's really TOC v1 here but we know it is ;) */ | 470 /* we're supposed to check that it's really TOC v1 here but we know it is ;) */ |
| 371 debug_printf("TOC version: %s\n", buf + sizeof(struct sflap_hdr) + 8); | 471 debug_printf("TOC version: %s\n", buf + sizeof(struct sflap_hdr) + 8); |
| 394 sflap_send(gc, snd, -1, TYPE_DATA); | 494 sflap_send(gc, snd, -1, TYPE_DATA); |
| 395 | 495 |
| 396 return; | 496 return; |
| 397 } | 497 } |
| 398 | 498 |
| 399 debug_printf("From TOC server: %s\n", buf + sizeof(struct sflap_hdr)); | 499 debug_printf("TOC S: %s\n", buf + sizeof(struct sflap_hdr)); |
| 400 | 500 |
| 401 c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ | 501 c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ |
| 402 | 502 |
| 403 if (!g_strcasecmp(c, "SIGN_ON")) { | 503 if (!g_strcasecmp(c, "SIGN_ON")) { |
| 404 /* we should only get here after a PAUSE */ | 504 /* we should only get here after a PAUSE */ |
| 487 g_free(tmp); | 587 g_free(tmp); |
| 488 | 588 |
| 489 serv_got_update(gc, c, logged, evil, signon, time_idle, type, 0); | 589 serv_got_update(gc, c, logged, evil, signon, time_idle, type, 0); |
| 490 } else if (!strcasecmp(c, "ERROR")) { | 590 } else if (!strcasecmp(c, "ERROR")) { |
| 491 c = strtok(NULL, ":"); | 591 c = strtok(NULL, ":"); |
| 492 show_error_dialog(c); | 592 show_error_message(c); |
| 493 } else if (!strcasecmp(c, "EVILED")) { | 593 } else if (!strcasecmp(c, "EVILED")) { |
| 494 int lev; | 594 int lev; |
| 495 char *name; | 595 char *name; |
| 496 | 596 |
| 497 sscanf(strtok(NULL, ":"), "%d", &lev); | 597 sscanf(strtok(NULL, ":"), "%d", &lev); |
| 845 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); | 945 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); |
| 846 sflap_send(g, buf, -1, TYPE_DATA); | 946 sflap_send(g, buf, -1, TYPE_DATA); |
| 847 toc_set_config(g); | 947 toc_set_config(g); |
| 848 } | 948 } |
| 849 | 949 |
| 850 static void toc_add_buddies(struct gaim_connection *g, GList * buddies) | 950 static void toc_add_buddies(struct gaim_connection *g, GList *buddies) |
| 851 { | 951 { |
| 852 char buf[BUF_LEN * 2]; | 952 char buf[BUF_LEN * 2]; |
| 853 int n; | 953 int n; |
| 854 | 954 |
| 855 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | 955 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
| 866 | 966 |
| 867 static void toc_remove_buddy(struct gaim_connection *g, char *name) | 967 static void toc_remove_buddy(struct gaim_connection *g, char *name) |
| 868 { | 968 { |
| 869 char buf[BUF_LEN * 2]; | 969 char buf[BUF_LEN * 2]; |
| 870 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); | 970 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); |
| 971 sflap_send(g, buf, -1, TYPE_DATA); | |
| 972 toc_set_config(g); | |
| 973 } | |
| 974 | |
| 975 static void toc_remove_buddies(struct gaim_connection *g, GList *buddies) | |
| 976 { | |
| 977 char buf[BUF_LEN * 2]; | |
| 978 int n; | |
| 979 | |
| 980 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); | |
| 981 while (buddies) { | |
| 982 if (strlen(normalize(buddies->data)) + n + 32 > MSG_LEN) { | |
| 983 sflap_send(g, buf, -1, TYPE_DATA); | |
| 984 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); | |
| 985 } | |
| 986 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); | |
| 987 buddies = buddies->next; | |
| 988 } | |
| 871 sflap_send(g, buf, -1, TYPE_DATA); | 989 sflap_send(g, buf, -1, TYPE_DATA); |
| 872 toc_set_config(g); | 990 toc_set_config(g); |
| 873 } | 991 } |
| 874 | 992 |
| 875 static void toc_set_idle(struct gaim_connection *g, int time) | 993 static void toc_set_idle(struct gaim_connection *g, int time) |
| 1188 ret->set_idle = toc_set_idle; | 1306 ret->set_idle = toc_set_idle; |
| 1189 ret->change_passwd = toc_change_passwd; | 1307 ret->change_passwd = toc_change_passwd; |
| 1190 ret->add_buddy = toc_add_buddy; | 1308 ret->add_buddy = toc_add_buddy; |
| 1191 ret->add_buddies = toc_add_buddies; | 1309 ret->add_buddies = toc_add_buddies; |
| 1192 ret->remove_buddy = toc_remove_buddy; | 1310 ret->remove_buddy = toc_remove_buddy; |
| 1311 ret->remove_buddies = toc_remove_buddies; | |
| 1193 ret->add_permit = toc_add_permit; | 1312 ret->add_permit = toc_add_permit; |
| 1194 ret->add_deny = toc_add_deny; | 1313 ret->add_deny = toc_add_deny; |
| 1195 ret->rem_permit = toc_rem_permit; | 1314 ret->rem_permit = toc_rem_permit; |
| 1196 ret->rem_deny = toc_rem_deny; | 1315 ret->rem_deny = toc_rem_deny; |
| 1197 ret->set_permit_deny = toc_set_permit_deny; | 1316 ret->set_permit_deny = toc_set_permit_deny; |
