Mercurial > pidgin
comparison src/protocols/irc/irc.c @ 2829:e3f98544eae0
[gaim-migrate @ 2842]
i really wanted this just now
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Sun, 02 Dec 2001 04:24:54 +0000 |
| parents | b917845dad3c |
| children | c229b7405178 |
comparison
equal
deleted
inserted
replaced
| 2828:06539a384d6b | 2829:e3f98544eae0 |
|---|---|
| 62 char *chanmodes; | 62 char *chanmodes; |
| 63 char *nickmodes; | 63 char *nickmodes; |
| 64 gboolean six_modes; | 64 gboolean six_modes; |
| 65 | 65 |
| 66 gboolean in_whois; | 66 gboolean in_whois; |
| 67 GString *whois_str; | 67 gboolean in_list; |
| 68 GString *liststr; | |
| 68 }; | 69 }; |
| 69 | 70 |
| 70 static char *irc_name() | 71 static char *irc_name() |
| 71 { | 72 { |
| 72 return "IRC"; | 73 return "IRC"; |
| 556 struct irc_data *id = gc->proto_data; | 557 struct irc_data *id = gc->proto_data; |
| 557 char tmp[1024]; | 558 char tmp[1024]; |
| 558 | 559 |
| 559 if (!id->in_whois) { | 560 if (!id->in_whois) { |
| 560 id->in_whois = TRUE; | 561 id->in_whois = TRUE; |
| 561 id->whois_str = g_string_new(""); | 562 id->liststr = g_string_new(""); |
| 562 } else { | 563 } else { |
| 563 /* I can't decide if we should have one break or two */ | 564 /* I can't decide if we should have one break or two */ |
| 564 id->whois_str = g_string_append(id->whois_str, "<BR>"); | 565 id->liststr = g_string_append(id->liststr, "<BR>"); |
| 565 id->in_whois = TRUE; | 566 id->in_whois = TRUE; |
| 566 } | 567 } |
| 567 | 568 |
| 568 switch (num) { | 569 switch (num) { |
| 569 case 311: | 570 case 311: |
| 570 id->whois_str = g_string_append(id->whois_str, "<b>User: </b>"); | 571 id->liststr = g_string_append(id->liststr, "<b>User: </b>"); |
| 571 break; | 572 break; |
| 572 case 312: | 573 case 312: |
| 573 id->whois_str = g_string_append(id->whois_str, "<b>Server: </b>"); | 574 id->liststr = g_string_append(id->liststr, "<b>Server: </b>"); |
| 574 break; | 575 break; |
| 575 case 313: | 576 case 313: |
| 576 g_snprintf(tmp, sizeof(tmp), "<b>IRC Operator:</b> %s ", word[4]); | 577 g_snprintf(tmp, sizeof(tmp), "<b>IRC Operator:</b> %s ", word[4]); |
| 577 id->whois_str = g_string_append(id->whois_str, tmp); | 578 id->liststr = g_string_append(id->liststr, tmp); |
| 578 break; | 579 break; |
| 579 | 580 |
| 580 case 317: | 581 case 317: |
| 581 id->whois_str = g_string_append(id->whois_str, "<b>Idle Time: </b>"); | 582 id->liststr = g_string_append(id->liststr, "<b>Idle Time: </b>"); |
| 582 break; | 583 break; |
| 583 case 319: | 584 case 319: |
| 584 id->whois_str = g_string_append(id->whois_str, "<b>Channels: </b>"); | 585 id->liststr = g_string_append(id->liststr, "<b>Channels: </b>"); |
| 585 break; | 586 break; |
| 586 default: | 587 default: |
| 587 break; | 588 break; |
| 588 } | 589 } |
| 589 | 590 |
| 590 if (word_eol[5][0] == ':') | 591 if (word_eol[5][0] == ':') |
| 591 id->whois_str = g_string_append(id->whois_str, word_eol[5] + 1); | 592 id->liststr = g_string_append(id->liststr, word_eol[5] + 1); |
| 592 else | 593 else |
| 593 id->whois_str = g_string_append(id->whois_str, word_eol[5]); | 594 id->liststr = g_string_append(id->liststr, word_eol[5]); |
| 594 | 595 } |
| 596 | |
| 597 static void handle_roomlist(struct gaim_connection *gc, char *word[], char *word_eol[]) | |
| 598 { | |
| 599 struct irc_data *id = gc->proto_data; | |
| 600 | |
| 601 if (!id->in_list) { | |
| 602 id->in_list = TRUE; | |
| 603 id->liststr = g_string_new(""); | |
| 604 } else { | |
| 605 id->liststr = g_string_append(id->liststr, "<BR>"); | |
| 606 id->in_list = TRUE; | |
| 607 } | |
| 608 | |
| 609 id->liststr = g_string_append(id->liststr, word_eol[4]); | |
| 595 } | 610 } |
| 596 | 611 |
| 597 static void process_numeric(struct gaim_connection *gc, char *word[], char *word_eol[]) | 612 static void process_numeric(struct gaim_connection *gc, char *word[], char *word_eol[]) |
| 598 { | 613 { |
| 599 struct irc_data *id = gc->proto_data; | 614 struct irc_data *id = gc->proto_data; |
| 615 case 5: | 630 case 5: |
| 616 handle_005(gc, word, word_eol); | 631 handle_005(gc, word, word_eol); |
| 617 break; | 632 break; |
| 618 case 301: | 633 case 301: |
| 619 if (id->in_whois) { | 634 if (id->in_whois) { |
| 620 id->whois_str = g_string_append(id->whois_str, "<BR><b>Away: </b>"); | 635 id->liststr = g_string_append(id->liststr, "<BR><b>Away: </b>"); |
| 621 | 636 |
| 622 if (word_eol[5][0] == ':') | 637 if (word_eol[5][0] == ':') |
| 623 id->whois_str = g_string_append(id->whois_str, word_eol[5] + 1); | 638 id->liststr = g_string_append(id->liststr, word_eol[5] + 1); |
| 624 else | 639 else |
| 625 id->whois_str = g_string_append(id->whois_str, word_eol[5]); | 640 id->liststr = g_string_append(id->liststr, word_eol[5]); |
| 626 } else | 641 } else |
| 627 irc_got_im(gc, word[4], word_eol[5], IM_FLAG_AWAY, time(NULL)); | 642 irc_got_im(gc, word[4], word_eol[5], IM_FLAG_AWAY, time(NULL)); |
| 628 break; | 643 break; |
| 629 case 303: | 644 case 303: |
| 630 handle_list(gc, &word_eol[4][1]); | 645 handle_list(gc, &word_eol[4][1]); |
| 634 case 313: | 649 case 313: |
| 635 case 317: | 650 case 317: |
| 636 case 319: | 651 case 319: |
| 637 handle_whois(gc, word, word_eol, n); | 652 handle_whois(gc, word, word_eol, n); |
| 638 break; | 653 break; |
| 654 case 322: | |
| 655 handle_roomlist(gc, word, word_eol); | |
| 656 break; | |
| 657 case 323: | |
| 639 case 318: | 658 case 318: |
| 640 if (id->in_whois && id->whois_str) { | 659 if ((id->in_whois || id->in_list) && id->liststr) { |
| 641 GString *str = decode_html(id->whois_str->str); | 660 GString *str = decode_html(id->liststr->str); |
| 642 g_show_info_text(gc, NULL, 2, str->str, NULL); | 661 g_show_info_text(gc, NULL, 2, str->str, NULL); |
| 643 g_string_free(str, TRUE); | 662 g_string_free(str, TRUE); |
| 644 g_string_free(id->whois_str, TRUE); | 663 g_string_free(id->liststr, TRUE); |
| 645 id->whois_str = NULL; | 664 id->liststr = NULL; |
| 646 id->in_whois = FALSE; | 665 id->in_whois = FALSE; |
| 666 id->in_list = FALSE; | |
| 647 } | 667 } |
| 648 break; | 668 break; |
| 649 case 324: | 669 case 324: |
| 650 handle_mode(gc, word, word_eol, TRUE); | 670 handle_mode(gc, word, word_eol, TRUE); |
| 651 break; | 671 break; |
| 1087 g_free(idata->chantypes); | 1107 g_free(idata->chantypes); |
| 1088 g_free(idata->chanmodes); | 1108 g_free(idata->chanmodes); |
| 1089 g_free(idata->nickmodes); | 1109 g_free(idata->nickmodes); |
| 1090 | 1110 |
| 1091 g_string_free(idata->str, TRUE); | 1111 g_string_free(idata->str, TRUE); |
| 1092 if (idata->whois_str) | 1112 if (idata->liststr) |
| 1093 g_string_free(idata->whois_str, TRUE); | 1113 g_string_free(idata->liststr, TRUE); |
| 1094 | 1114 |
| 1095 if (idata->timer) | 1115 if (idata->timer) |
| 1096 g_source_remove(idata->timer); | 1116 g_source_remove(idata->timer); |
| 1097 | 1117 |
| 1098 if (gc->inpa) | 1118 if (gc->inpa) |
| 1332 do_error_dialog(buf, _("IRC Part")); | 1352 do_error_dialog(buf, _("IRC Part")); |
| 1333 } | 1353 } |
| 1334 } else if (!g_strcasecmp(pdibuf, "WHOIS")) { | 1354 } else if (!g_strcasecmp(pdibuf, "WHOIS")) { |
| 1335 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", word_eol[2]); | 1355 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", word_eol[2]); |
| 1336 irc_write(id->fd, buf, strlen(buf)); | 1356 irc_write(id->fd, buf, strlen(buf)); |
| 1357 } else if (!g_strcasecmp(pdibuf, "LIST")) { | |
| 1358 g_snprintf(buf, sizeof(buf), "LIST\r\n"); | |
| 1359 irc_write(id->fd, buf, strlen(buf)); | |
| 1337 } else if (!g_strcasecmp(pdibuf, "HELP")) { | 1360 } else if (!g_strcasecmp(pdibuf, "HELP")) { |
| 1338 struct conversation *c = NULL; | 1361 struct conversation *c = NULL; |
| 1339 if (is_channel(gc, who)) { | 1362 if (is_channel(gc, who)) { |
| 1340 c = irc_find_chat(gc, who); | 1363 c = irc_find_chat(gc, who); |
| 1341 } else { | 1364 } else { |
| 1342 c = find_conversation(who); | 1365 c = find_conversation(who); |
| 1343 } | 1366 } |
| 1344 if (!c) | 1367 if (!c) |
| 1345 return -EINVAL; | 1368 return -EINVAL; |
| 1346 write_to_conv(c, "<B>Currently supported commands:<BR>" | 1369 write_to_conv(c, "<B>Currently supported commands:<BR>" |
| 1347 "JOIN PART TOPIC WHOIS<BR>" | 1370 "JOIN PART LIST TOPIC WHOIS<BR>" |
| 1348 "OP DEOP VOICE DEVOICE KICK<BR>" | 1371 "OP DEOP VOICE DEVOICE KICK<BR>" |
| 1349 "NICK ME MSG QUOTE SAY</B>", | 1372 "NICK ME MSG QUOTE SAY</B>", |
| 1350 WFLAG_NOLOG, NULL, time(NULL)); | 1373 WFLAG_NOLOG, NULL, time(NULL)); |
| 1351 } else { | 1374 } else { |
| 1352 struct conversation *c = NULL; | 1375 struct conversation *c = NULL; |
