Mercurial > pidgin
comparison src/protocols/irc/irc.c @ 5436:ad445074d239
[gaim-migrate @ 5818]
Another big commit. Ugh. I need a very smart regexp.
Core/UI split do_error_dialog(), and soon the mail dialogs! Yay! This
should work without problems at all, but standard disclaimer..
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 18 May 2003 19:59:02 +0000 |
parents | f3cf3bff72f0 |
children | 3e8487580024 |
comparison
equal
deleted
inserted
replaced
5435:a2f26666de42 | 5436:ad445074d239 |
---|---|
1091 break; | 1091 break; |
1092 case 376: /* RPL_ENDOFMOTD */ | 1092 case 376: /* RPL_ENDOFMOTD */ |
1093 irc_request_buddy_update(gc); | 1093 irc_request_buddy_update(gc); |
1094 break; | 1094 break; |
1095 case 382: /* RPL_REHASHING */ | 1095 case 382: /* RPL_REHASHING */ |
1096 do_error_dialog(_("Rehashing server"), _("IRC Operator"), GAIM_ERROR); | 1096 gaim_notify_error(gc, NULL, _("Rehashing server"), _("IRC Operator")); |
1097 break; | 1097 break; |
1098 case 401: /* ERR_NOSUCHNICK */ | 1098 case 401: /* ERR_NOSUCHNICK */ |
1099 do_error_dialog(_("No such nick/channel"), _("IRC Error"), GAIM_ERROR); | 1099 gaim_notify_error(gc, NULL, _("No such nick/channel"), _("IRC Error")); |
1100 break; | 1100 break; |
1101 case 402: /* ERR_NOSUCHSERVER */ | 1101 case 402: /* ERR_NOSUCHSERVER */ |
1102 do_error_dialog(_("No such server"), _("IRC Error"), GAIM_ERROR); | 1102 gaim_notify_error(gc, NULL, _("No such server"), _("IRC Error")); |
1103 break; | 1103 break; |
1104 case 422: /* ERR_NOMOTD */ | 1104 case 422: /* ERR_NOMOTD */ |
1105 break; /* drop it - bringing up dialog for NOMOTD is annoying */ | 1105 break; /* drop it - bringing up dialog for NOMOTD is annoying */ |
1106 case 431: /* ERR_NONICKNAMEGIVEN */ | 1106 case 431: /* ERR_NONICKNAMEGIVEN */ |
1107 do_error_dialog(_("No nickname given"), _("IRC Error"), GAIM_ERROR); | 1107 gaim_notify_error(gc, NULL, _("No nickname given"), _("IRC Error")); |
1108 break; | 1108 break; |
1109 case 481: /* ERR_NOPRIVILEGES */ | 1109 case 481: /* ERR_NOPRIVILEGES */ |
1110 do_error_dialog(_("You're not an IRC operator!"), _("IRC Error"), GAIM_ERROR); | 1110 gaim_notify_error(gc, NULL, _("You're not an IRC operator!"), |
1111 _("IRC Error")); | |
1111 break; | 1112 break; |
1112 case 433: | 1113 case 433: |
1113 do_prompt_dialog(_("That nick is already in use. Please enter a new nick"), gc->displayname, gc, irc_change_nick, NULL); | 1114 do_prompt_dialog(_("That nick is already in use. Please enter a new nick"), gc->displayname, gc, irc_change_nick, NULL); |
1114 break; | 1115 break; |
1115 default: | 1116 default: |
1116 /* Other error messages */ | 1117 /* Other error messages */ |
1117 if (n > 400 && n < 502) { | 1118 if (n > 400 && n < 502) { |
1118 char errmsg[IRC_BUF_LEN]; | 1119 char errmsg[IRC_BUF_LEN]; |
1119 char *errmsg1 = strrchr(text, ':'); | 1120 char *errmsg1 = strrchr(text, ':'); |
1121 | |
1120 g_snprintf(errmsg, sizeof(errmsg), "IRC Error %d", n); | 1122 g_snprintf(errmsg, sizeof(errmsg), "IRC Error %d", n); |
1121 if (errmsg) | 1123 |
1122 do_error_dialog(errmsg, errmsg1 ? errmsg1+1 : NULL, GAIM_ERROR); | 1124 if (errmsg) { |
1123 } | 1125 gaim_notify_error(gc, NULL, errmsg, |
1126 (errmsg1 ? errmsg1 + 1 : NULL)); | |
1127 } | |
1128 } | |
1129 | |
1124 break; | 1130 break; |
1125 } | 1131 } |
1126 } | 1132 } |
1127 | 1133 |
1128 static gboolean | 1134 static gboolean |
1388 if (!g_ascii_strncasecmp(msg, "VERSION", 7)) { | 1394 if (!g_ascii_strncasecmp(msg, "VERSION", 7)) { |
1389 g_snprintf(buf, sizeof(buf), "\001VERSION Gaim " VERSION ": The Penguin Pimpin' " | 1395 g_snprintf(buf, sizeof(buf), "\001VERSION Gaim " VERSION ": The Penguin Pimpin' " |
1390 "Multi-protocol Messaging Client: " WEBSITE "\001"); | 1396 "Multi-protocol Messaging Client: " WEBSITE "\001"); |
1391 irc_send_notice (gc, nick, buf); | 1397 irc_send_notice (gc, nick, buf); |
1392 g_snprintf(out, sizeof(out), ">> CTCP VERSION requested from %s", nick); | 1398 g_snprintf(out, sizeof(out), ">> CTCP VERSION requested from %s", nick); |
1393 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); | 1399 gaim_notify_info(gc, NULL, out, _("IRC CTCP info")); |
1394 } | 1400 } |
1395 else if (!g_ascii_strncasecmp(msg, "CLIENTINFO", 10)) { | 1401 else if (!g_ascii_strncasecmp(msg, "CLIENTINFO", 10)) { |
1396 g_snprintf(buf, sizeof(buf), "\001CLIENTINFO USERINFO CLIENTINFO VERSION\001"); | 1402 g_snprintf(buf, sizeof(buf), "\001CLIENTINFO USERINFO CLIENTINFO VERSION\001"); |
1397 irc_send_notice (gc, nick, buf); | 1403 irc_send_notice (gc, nick, buf); |
1398 g_snprintf(out, sizeof(out), ">> CTCP CLIENTINFO requested from %s", nick); | 1404 g_snprintf(out, sizeof(out), ">> CTCP CLIENTINFO requested from %s", nick); |
1399 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); | 1405 gaim_notify_info(gc, NULL, out, _("IRC CTCP info")); |
1400 } | 1406 } |
1401 else if (!g_ascii_strncasecmp(msg, "USERINFO", 8)) { | 1407 else if (!g_ascii_strncasecmp(msg, "USERINFO", 8)) { |
1402 g_snprintf(buf, sizeof(buf), "\001USERINFO Alias: %s\001", gc->account->alias); | 1408 g_snprintf(buf, sizeof(buf), "\001USERINFO Alias: %s\001", gc->account->alias); |
1403 irc_send_notice (gc, nick, buf); | 1409 irc_send_notice (gc, nick, buf); |
1404 g_snprintf(out, sizeof(out), ">> CTCP USERINFO requested from %s", nick); | 1410 g_snprintf(out, sizeof(out), ">> CTCP USERINFO requested from %s", nick); |
1405 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); | 1411 gaim_notify_info(gc, NULL, out, _("IRC CTCP info")); |
1406 } | 1412 } |
1407 else if (!g_ascii_strncasecmp(msg, "ACTION", 6)) { | 1413 else if (!g_ascii_strncasecmp(msg, "ACTION", 6)) { |
1408 char *po = strchr(msg + 6, 1); | 1414 char *po = strchr(msg + 6, 1); |
1409 char *tmp; | 1415 char *tmp; |
1410 if (po) *po = 0; | 1416 if (po) *po = 0; |
1414 } | 1420 } |
1415 else if (!g_ascii_strncasecmp(msg, "PING", 4)) { | 1421 else if (!g_ascii_strncasecmp(msg, "PING", 4)) { |
1416 g_snprintf(buf, sizeof(buf), "\001%s\001", msg); | 1422 g_snprintf(buf, sizeof(buf), "\001%s\001", msg); |
1417 irc_send_notice (gc, nick, buf); | 1423 irc_send_notice (gc, nick, buf); |
1418 g_snprintf(out, sizeof(out), ">> CTCP PING requested from %s", nick); | 1424 g_snprintf(out, sizeof(out), ">> CTCP PING requested from %s", nick); |
1419 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); | 1425 gaim_notify_info(gc, NULL, out, _("IRC CTCP info")); |
1420 } | 1426 } |
1421 else if (!g_ascii_strncasecmp(msg, "DCC CHAT", 8)) { | 1427 else if (!g_ascii_strncasecmp(msg, "DCC CHAT", 8)) { |
1422 char **chat_args = g_strsplit(msg, " ", 5); | 1428 char **chat_args = g_strsplit(msg, " ", 5); |
1423 char ask[1024]; | 1429 char ask[1024]; |
1424 struct dcc_chat *dccchat = g_new0(struct dcc_chat, 1); | 1430 struct dcc_chat *dccchat = g_new0(struct dcc_chat, 1); |
1454 | 1460 |
1455 g_snprintf(buf, sizeof(buf), | 1461 g_snprintf(buf, sizeof(buf), |
1456 _("Received an invalid file send request from %s."), | 1462 _("Received an invalid file send request from %s."), |
1457 nick); | 1463 nick); |
1458 | 1464 |
1459 do_error_dialog(buf, _("IRC Error"), GAIM_ERROR); | 1465 gaim_notify_error(gc, NULL, buf, _("IRC Error")); |
1460 | 1466 |
1461 return; | 1467 return; |
1462 } | 1468 } |
1463 | 1469 |
1464 file_params = get_file_params_count(send_args, param_count); | 1470 file_params = get_file_params_count(send_args, param_count); |
1597 return FALSE; | 1603 return FALSE; |
1598 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); | 1604 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); |
1599 gaim_conversation_set_account(c, NULL); | 1605 gaim_conversation_set_account(c, NULL); |
1600 g_snprintf(outbuf, sizeof(outbuf), _("You have been kicked from %s: %s"), | 1606 g_snprintf(outbuf, sizeof(outbuf), _("You have been kicked from %s: %s"), |
1601 word[3], *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5]); | 1607 word[3], *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5]); |
1602 do_error_dialog(outbuf, _("IRC Error"), GAIM_ERROR); | 1608 gaim_notify_error(gc, NULL, outbuf, _("IRC Error")); |
1603 } else { | 1609 } else { |
1604 char *reason = *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5]; | 1610 char *reason = *word_eol[5] == ':' ? word_eol[5] + 1 : word_eol[5]; |
1605 char *msg = g_strdup_printf(_("Kicked by %s: %s"), nick, reason); | 1611 char *msg = g_strdup_printf(_("Kicked by %s: %s"), nick, reason); |
1606 struct gaim_conversation *c = irc_find_chat(gc, word[3]); | 1612 struct gaim_conversation *c = irc_find_chat(gc, word[3]); |
1607 irc_rem_chat_bud(gc, word[4], c, msg); | 1613 irc_rem_chat_bud(gc, word[4], c, msg); |
1639 } else if (!strcmp(cmd, "TOPIC")) { | 1645 } else if (!strcmp(cmd, "TOPIC")) { |
1640 irc_parse_topic(gc, nick, word, word_eol); | 1646 irc_parse_topic(gc, nick, word, word_eol); |
1641 } else if (!strcmp(cmd, "WALLOPS")) { /* Don't know if a dialog box is the right way? */ | 1647 } else if (!strcmp(cmd, "WALLOPS")) { /* Don't know if a dialog box is the right way? */ |
1642 char *msg = strrchr(word_eol[0], ':'); | 1648 char *msg = strrchr(word_eol[0], ':'); |
1643 if (msg) | 1649 if (msg) |
1644 do_error_dialog(msg+1, _("IRC Operator"), GAIM_ERROR); | 1650 gaim_notify_error(gc, NULL, msg+1, _("IRC Operator")); |
1645 } | 1651 } |
1646 | 1652 |
1647 return FALSE; | 1653 return FALSE; |
1648 } | 1654 } |
1649 | 1655 |
1656 | 1662 |
1657 if (!g_ascii_strcasecmp(word[4], ":\001CLIENTINFO")) { | 1663 if (!g_ascii_strcasecmp(word[4], ":\001CLIENTINFO")) { |
1658 char *p = g_strrstr(word_eol[5], "\001"); | 1664 char *p = g_strrstr(word_eol[5], "\001"); |
1659 *p = 0; | 1665 *p = 0; |
1660 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); | 1666 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); |
1661 do_error_dialog(buf, _("CTCP ClientInfo"), GAIM_INFO); | 1667 gaim_notify_info(gc, NULL, buf, _("CTCP ClientInfo")); |
1662 | 1668 |
1663 } else if (!g_ascii_strcasecmp(word[4], ":\001USERINFO")) { | 1669 } else if (!g_ascii_strcasecmp(word[4], ":\001USERINFO")) { |
1664 char *p = g_strrstr(word_eol[5], "\001"); | 1670 char *p = g_strrstr(word_eol[5], "\001"); |
1665 *p = 0; | 1671 *p = 0; |
1666 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); | 1672 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); |
1667 do_error_dialog(buf, _("CTCP UserInfo"), GAIM_INFO); | 1673 gaim_notify_info(gc, NULL, buf, _("CTCP UserInfo")); |
1668 | 1674 |
1669 } else if (!g_ascii_strcasecmp(word[4], ":\001VERSION")) { | 1675 } else if (!g_ascii_strcasecmp(word[4], ":\001VERSION")) { |
1670 char *p = g_strrstr(word_eol[5], "\001"); | 1676 char *p = g_strrstr(word_eol[5], "\001"); |
1671 *p = 0; | 1677 *p = 0; |
1672 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); | 1678 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); |
1673 do_error_dialog(buf, _("CTCP Version"), GAIM_INFO); | 1679 gaim_notify_info(gc, NULL, buf, _("CTCP Version")); |
1674 | 1680 |
1675 } else if (!g_ascii_strcasecmp(word[4], ":\001PING")) { | 1681 } else if (!g_ascii_strcasecmp(word[4], ":\001PING")) { |
1676 char *p = g_strrstr(word_eol[5], "\001"); | 1682 char *p = g_strrstr(word_eol[5], "\001"); |
1677 struct timeval ping_time; | 1683 struct timeval ping_time; |
1678 struct timeval now; | 1684 struct timeval now; |
1696 | 1702 |
1697 g_snprintf(buf, sizeof(buf), | 1703 g_snprintf(buf, sizeof(buf), |
1698 "CTCP Ping reply from %s: %lu.%.03lu seconds", | 1704 "CTCP Ping reply from %s: %lu.%.03lu seconds", |
1699 nick, ping_time.tv_sec, (ping_time.tv_usec/1000)); | 1705 nick, ping_time.tv_sec, (ping_time.tv_usec/1000)); |
1700 | 1706 |
1701 do_error_dialog(buf, _("CTCP Ping"), GAIM_INFO); | 1707 gaim_notify_info(gc, NULL, buf, _("CTCP Ping")); |
1702 g_strfreev(vector); | 1708 g_strfreev(vector); |
1703 } | 1709 } |
1704 } else { | 1710 } else { |
1705 if (*word_eol[4] == ':') word_eol[4]++; | 1711 if (*word_eol[4] == ':') word_eol[4]++; |
1706 if (ex) | 1712 if (ex) |
2302 irc_write(id->fd, buf, strlen(buf)); | 2308 irc_write(id->fd, buf, strlen(buf)); |
2303 if (c) { | 2309 if (c) { |
2304 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); | 2310 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); |
2305 gaim_conversation_set_account(c, NULL); | 2311 gaim_conversation_set_account(c, NULL); |
2306 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan); | 2312 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan); |
2307 do_error_dialog(buf, _("IRC Part"), GAIM_INFO); | 2313 gaim_notify_info(gc, NULL, buf, _("IRC Part")); |
2308 } | 2314 } |
2309 } else if (!g_ascii_strcasecmp(pdibuf, "WHOIS")) { | 2315 } else if (!g_ascii_strcasecmp(pdibuf, "WHOIS")) { |
2310 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", word_eol[2]); | 2316 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", word_eol[2]); |
2311 irc_write(id->fd, buf, strlen(buf)); | 2317 irc_write(id->fd, buf, strlen(buf)); |
2312 } else if (!g_ascii_strcasecmp(pdibuf, "WHOWAS")) { | 2318 } else if (!g_ascii_strcasecmp(pdibuf, "WHOWAS")) { |