comparison src/protocols/irc/irc.c @ 4793:677d3cb193a1

[gaim-migrate @ 5113] this removes all the remaining deprecated glib, gdk, gdk-pixbuf, and gtk function calls. Hopefully I didn't break anything. Most of this is due to the deprecation of g_strcasecmp and g_strncasecmp. Two functions I never thought would be deprecated, but apparently they're no good at comparing utf8 text. g_ascii_str{,n}casecmp is OK when you're sure that it's ASCII. Otherwise, we're supposed to use g_utf8_collate(), except that it is case sensitive. Since glib doesn't currently have a case-insensitive one, I wrote one. If you need to compare utf8 text, you can use gaim_utf8_strcasecmp(). I have to go do dishes now. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 16 Mar 2003 00:01:49 +0000
parents 1e28e7d802a1
children 0ed37c803503
comparison
equal deleted inserted replaced
4792:9212d1c5b7dc 4793:677d3cb193a1
204 { 204 {
205 GSList *bcs = gc->buddy_chats; 205 GSList *bcs = gc->buddy_chats;
206 206
207 while (bcs) { 207 while (bcs) {
208 struct gaim_conversation *b = bcs->data; 208 struct gaim_conversation *b = bcs->data;
209 if (!g_strcasecmp(b->name, name)) 209 if (!gaim_utf8_strcasecmp(b->name, name))
210 return b; 210 return b;
211 bcs = bcs->next; 211 bcs = bcs->next;
212 } 212 }
213 return NULL; 213 return NULL;
214 } 214 }
307 encode_html(char *msg) 307 encode_html(char *msg)
308 { 308 {
309 GString *str = g_string_new(""); 309 GString *str = g_string_new("");
310 char *cur = msg, *end = msg; 310 char *cur = msg, *end = msg;
311 gboolean bold = FALSE, underline = FALSE, italics = FALSE; 311 gboolean bold = FALSE, underline = FALSE, italics = FALSE;
312 312
313 while ((end = strchr(cur, '<'))) { 313 while ((end = strchr(cur, '<'))) {
314 *end = 0; 314 *end = 0;
315 str = g_string_append(str, cur); 315 str = g_string_append(str, cur);
316 cur = ++end; 316 cur = ++end;
317 if (!g_strncasecmp(cur, "B>", 2)) { 317 if (!g_ascii_strncasecmp(cur, "B>", 2)) {
318 if (!bold) { 318 if (!bold) {
319 bold = TRUE; 319 bold = TRUE;
320 str = g_string_append_c(str, '\2'); 320 str = g_string_append_c(str, '\2');
321 } 321 }
322 cur = cur + 2; 322 cur = cur + 2;
323 } else if (!g_strncasecmp(cur, "I>", 2)) { /* use bold for italics too */ 323 } else if (!g_ascii_strncasecmp(cur, "I>", 2)) { /* use bold for italics too */
324 if (!italics) { 324 if (!italics) {
325 italics = TRUE; 325 italics = TRUE;
326 str = g_string_append_c(str, '\2'); 326 str = g_string_append_c(str, '\2');
327 } 327 }
328 cur = cur + 2; 328 cur = cur + 2;
329 } else if (!g_strncasecmp(cur, "U>", 2)) { 329 } else if (!g_ascii_strncasecmp(cur, "U>", 2)) {
330 if (!underline) { 330 if (!underline) {
331 underline = TRUE; 331 underline = TRUE;
332 str = g_string_append_c(str, '\37'); 332 str = g_string_append_c(str, '\37');
333 } 333 }
334 cur = cur + 2; 334 cur = cur + 2;
335 } else if (!g_strncasecmp(cur, "/B>", 3)) { 335 } else if (!g_ascii_strncasecmp(cur, "/B>", 3)) {
336 if (bold) { 336 if (bold) {
337 bold = FALSE; 337 bold = FALSE;
338 str = g_string_append_c(str, '\2'); 338 str = g_string_append_c(str, '\2');
339 } 339 }
340 cur = cur + 3; 340 cur = cur + 3;
341 } else if (!g_strncasecmp(cur, "/I>", 3)) { 341 } else if (!g_ascii_strncasecmp(cur, "/I>", 3)) {
342 if (italics) { 342 if (italics) {
343 italics = FALSE; 343 italics = FALSE;
344 str = g_string_append_c(str, '\2'); 344 str = g_string_append_c(str, '\2');
345 } 345 }
346 cur = cur + 3; 346 cur = cur + 3;
347 } else if (!g_strncasecmp(cur, "/U>", 3)) { 347 } else if (!g_ascii_strncasecmp(cur, "/U>", 3)) {
348 if (underline) { 348 if (underline) {
349 underline = FALSE; 349 underline = FALSE;
350 str = g_string_append_c(str, '\37'); 350 str = g_string_append_c(str, '\37');
351 } 351 }
352 cur = cur + 3; 352 cur = cur + 3;
353 } else { 353 } else {
354 str = g_string_append_c(str, '<'); 354 str = g_string_append_c(str, '<');
355 } 355 }
356 356
357 } 357 }
358 str = g_string_append(str, cur); 358 str = g_string_append(str, cur);
359 return str; 359 return str;
360 } 360 }
361 361
567 567
568 static void 568 static void
569 handle_list(struct gaim_connection *gc, char *list) 569 handle_list(struct gaim_connection *gc, char *list)
570 { 570 {
571 struct irc_data *id = gc->proto_data; 571 struct irc_data *id = gc->proto_data;
572 char *tmp;
572 GaimBlistNode *gnode, *bnode; 573 GaimBlistNode *gnode, *bnode;
573 574
575 tmp = g_utf8_strdown(list, -1);
576
574 id->str = g_string_append_c(id->str, ' '); 577 id->str = g_string_append_c(id->str, ' ');
575 id->str = g_string_append(id->str, list); 578 id->str = g_string_append(id->str, tmp);
576 id->bc--; 579 id->bc--;
580 g_free(tmp);
577 if (id->bc) 581 if (id->bc)
578 return; 582 return;
579 583
580 g_strdown(id->str->str);
581 584
582 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { 585 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
583 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) 586 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
584 continue; 587 continue;
585 for(bnode = gnode->child; bnode; bnode = bnode->next) { 588 for(bnode = gnode->child; bnode; bnode = bnode->next) {
586 struct buddy *b = (struct buddy *)bnode; 589 struct buddy *b = (struct buddy *)bnode;
587 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) 590 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
588 continue; 591 continue;
589 if(b->account->gc == gc) { 592 if(b->account->gc == gc) {
590 char *tmp = g_strdup(b->name); 593 char *tmp = g_utf8_strdown(b->name, -1);
591 char *x, *l; 594 char *x, *l;
592 g_strdown(tmp);
593 x = strstr(id->str->str, tmp); 595 x = strstr(id->str->str, tmp);
594 l = x + strlen(b->name); 596 l = x + strlen(b->name);
595 if (x && (*l != ' ' && *l != 0)) 597 if (x && (*l != ' ' && *l != 0))
596 x = 0; 598 x = 0;
597 if (!b->present && x) 599 if (!b->present && x)
997 { 999 {
998 struct irc_data *id = gc->proto_data; 1000 struct irc_data *id = gc->proto_data;
999 char *text = word_eol[3]; 1001 char *text = word_eol[3];
1000 int n = atoi(word[2]); 1002 int n = atoi(word[2]);
1001 1003
1002 if (!g_strncasecmp(gc->displayname, text, strlen(gc->displayname))) 1004 if (!g_ascii_strncasecmp(gc->displayname, text, strlen(gc->displayname)))
1003 text += strlen(gc->displayname) + 1; 1005 text += strlen(gc->displayname) + 1;
1004 if (*text == ':') 1006 if (*text == ':')
1005 text++; 1007 text++;
1006 1008
1007 /* RPL_ and ERR_ */ 1009 /* RPL_ and ERR_ */
1134 who++; 1136 who++;
1135 if (*who == '%') 1137 if (*who == '%')
1136 who++; 1138 who++;
1137 if (*who == '+') 1139 if (*who == '+')
1138 who++; 1140 who++;
1139 if (!g_strcasecmp(who, nick)) { 1141 if (!gaim_utf8_strcasecmp(who, nick)) {
1140 char *tmp = g_strdup(r->data); 1142 char *tmp = g_strdup(r->data);
1141 gaim_chat_remove_user(chat, tmp, reason); 1143 gaim_chat_remove_user(chat, tmp, reason);
1142 g_free(tmp); 1144 g_free(tmp);
1143 break; 1145 break;
1144 } 1146 }
1306 { 1308 {
1307 struct irc_data *id = gc->proto_data; 1309 struct irc_data *id = gc->proto_data;
1308 char buf[IRC_BUF_LEN]; 1310 char buf[IRC_BUF_LEN];
1309 char out[IRC_BUF_LEN]; 1311 char out[IRC_BUF_LEN];
1310 1312
1311 if (!g_strncasecmp(msg, "VERSION", 7)) { 1313 if (!g_ascii_strncasecmp(msg, "VERSION", 7)) {
1312 g_snprintf(buf, sizeof(buf), "\001VERSION Gaim " VERSION ": The Penguin Pimpin' " 1314 g_snprintf(buf, sizeof(buf), "\001VERSION Gaim " VERSION ": The Penguin Pimpin' "
1313 "Multi-protocol Messaging Client: " WEBSITE "\001"); 1315 "Multi-protocol Messaging Client: " WEBSITE "\001");
1314 irc_send_notice (gc, nick, buf); 1316 irc_send_notice (gc, nick, buf);
1315 g_snprintf(out, sizeof(out), ">> CTCP VERSION requested from %s", nick); 1317 g_snprintf(out, sizeof(out), ">> CTCP VERSION requested from %s", nick);
1316 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); 1318 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO);
1317 } 1319 }
1318 if (!g_strncasecmp(msg, "CLIENTINFO", 10)) { 1320 if (!g_ascii_strncasecmp(msg, "CLIENTINFO", 10)) {
1319 g_snprintf(buf, sizeof(buf), "\001CLIENTINFO USERINFO CLIENTINFO VERSION\001"); 1321 g_snprintf(buf, sizeof(buf), "\001CLIENTINFO USERINFO CLIENTINFO VERSION\001");
1320 irc_send_notice (gc, nick, buf); 1322 irc_send_notice (gc, nick, buf);
1321 g_snprintf(out, sizeof(out), ">> CTCP CLIENTINFO requested from %s", nick); 1323 g_snprintf(out, sizeof(out), ">> CTCP CLIENTINFO requested from %s", nick);
1322 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); 1324 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO);
1323 } 1325 }
1324 if (!g_strncasecmp(msg, "USERINFO", 8)) { 1326 if (!g_ascii_strncasecmp(msg, "USERINFO", 8)) {
1325 g_snprintf(buf, sizeof(buf), "\001USERINFO Alias: %s\001", gc->account->alias); 1327 g_snprintf(buf, sizeof(buf), "\001USERINFO Alias: %s\001", gc->account->alias);
1326 irc_send_notice (gc, nick, buf); 1328 irc_send_notice (gc, nick, buf);
1327 g_snprintf(out, sizeof(out), ">> CTCP USERINFO requested from %s", nick); 1329 g_snprintf(out, sizeof(out), ">> CTCP USERINFO requested from %s", nick);
1328 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); 1330 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO);
1329 } 1331 }
1330 if (!g_strncasecmp(msg, "ACTION", 6)) { 1332 if (!g_ascii_strncasecmp(msg, "ACTION", 6)) {
1331 char *po = strchr(msg + 6, 1); 1333 char *po = strchr(msg + 6, 1);
1332 char *tmp; 1334 char *tmp;
1333 if (po) *po = 0; 1335 if (po) *po = 0;
1334 tmp = g_strconcat("/me", msg + 6, NULL); 1336 tmp = g_strconcat("/me", msg + 6, NULL);
1335 handle_privmsg(gc, to, nick, tmp); 1337 handle_privmsg(gc, to, nick, tmp);
1336 g_free(tmp); 1338 g_free(tmp);
1337 } 1339 }
1338 if (!g_strncasecmp(msg, "PING", 4)) { 1340 if (!g_ascii_strncasecmp(msg, "PING", 4)) {
1339 g_snprintf(buf, sizeof(buf), "\001%s\001", msg); 1341 g_snprintf(buf, sizeof(buf), "\001%s\001", msg);
1340 irc_send_notice (gc, nick, buf); 1342 irc_send_notice (gc, nick, buf);
1341 g_snprintf(out, sizeof(out), ">> CTCP PING requested from %s", nick); 1343 g_snprintf(out, sizeof(out), ">> CTCP PING requested from %s", nick);
1342 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO); 1344 do_error_dialog(out, _("IRC CTCP info"), GAIM_INFO);
1343 } 1345 }
1344 if (!g_strncasecmp(msg, "DCC CHAT", 8)) { 1346 if (!g_ascii_strncasecmp(msg, "DCC CHAT", 8)) {
1345 char **chat_args = g_strsplit(msg, " ", 5); 1347 char **chat_args = g_strsplit(msg, " ", 5);
1346 char ask[1024]; 1348 char ask[1024];
1347 struct dcc_chat *dccchat = g_new0(struct dcc_chat, 1); 1349 struct dcc_chat *dccchat = g_new0(struct dcc_chat, 1);
1348 dccchat->gc = gc; 1350 dccchat->gc = gc;
1349 g_snprintf(dccchat->ip_address, sizeof(dccchat->ip_address), chat_args[3]); 1351 g_snprintf(dccchat->ip_address, sizeof(dccchat->ip_address), chat_args[3]);
1352 g_snprintf(ask, sizeof(ask), _("%s would like to establish a DCC chat"), nick); 1354 g_snprintf(ask, sizeof(ask), _("%s would like to establish a DCC chat"), nick);
1353 do_ask_dialog(ask, _("This requires a direct connection to be established between the two computers. Messages sent will not pass through the IRC server"), dccchat, _("Connect"), dcc_chat_init, _("Cancel"), dcc_chat_cancel, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); 1355 do_ask_dialog(ask, _("This requires a direct connection to be established between the two computers. Messages sent will not pass through the IRC server"), dccchat, _("Connect"), dcc_chat_init, _("Cancel"), dcc_chat_cancel, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE);
1354 } 1356 }
1355 1357
1356 1358
1357 if (!g_strncasecmp(msg, "DCC SEND", 8)) { 1359 if (!g_ascii_strncasecmp(msg, "DCC SEND", 8)) {
1358 struct gaim_xfer *xfer; 1360 struct gaim_xfer *xfer;
1359 char **send_args; 1361 char **send_args;
1360 char *ip, *filename; 1362 char *ip, *filename;
1361 struct irc_xfer_data *xfer_data; 1363 struct irc_xfer_data *xfer_data;
1362 size_t size; 1364 size_t size;
1510 if (!*word[3]) 1512 if (!*word[3])
1511 return FALSE; 1513 return FALSE;
1512 to = word[3]; 1514 to = word[3];
1513 msg = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4]; 1515 msg = *word_eol[4] == ':' ? word_eol[4] + 1 : word_eol[4];
1514 if (msg[0] == 1 && msg[strlen (msg) - 1] == 1) { /* ctcp */ 1516 if (msg[0] == 1 && msg[strlen (msg) - 1] == 1) { /* ctcp */
1515 if (!g_strncasecmp(msg + 1, "DCC ", 4)) 1517 if (!g_ascii_strncasecmp(msg + 1, "DCC ", 4))
1516 process_data_init(pdibuf, buf, word, word_eol, TRUE); 1518 process_data_init(pdibuf, buf, word, word_eol, TRUE);
1517 handle_ctcp(gc, to, nick, msg + 1, word, word_eol); 1519 handle_ctcp(gc, to, nick, msg + 1, word, word_eol);
1518 } else { 1520 } else {
1519 handle_privmsg(gc, to, nick, msg); 1521 handle_privmsg(gc, to, nick, msg);
1520 } 1522 }
1537 irc_parse_notice(struct gaim_connection *gc, char *nick, char *ex, 1539 irc_parse_notice(struct gaim_connection *gc, char *nick, char *ex,
1538 char *word[], char *word_eol[]) 1540 char *word[], char *word_eol[])
1539 { 1541 {
1540 char buf[IRC_BUF_LEN]; 1542 char buf[IRC_BUF_LEN];
1541 1543
1542 if (!g_strcasecmp(word[4], ":\001CLIENTINFO")) { 1544 if (!g_ascii_strcasecmp(word[4], ":\001CLIENTINFO")) {
1543 char *p = g_strrstr(word_eol[5], "\001"); 1545 char *p = g_strrstr(word_eol[5], "\001");
1544 *p = 0; 1546 *p = 0;
1545 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); 1547 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]);
1546 do_error_dialog(buf, _("CTCP ClientInfo"), GAIM_INFO); 1548 do_error_dialog(buf, _("CTCP ClientInfo"), GAIM_INFO);
1547 1549
1548 } else if (!g_strcasecmp(word[4], ":\001USERINFO")) { 1550 } else if (!g_ascii_strcasecmp(word[4], ":\001USERINFO")) {
1549 char *p = g_strrstr(word_eol[5], "\001"); 1551 char *p = g_strrstr(word_eol[5], "\001");
1550 *p = 0; 1552 *p = 0;
1551 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); 1553 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]);
1552 do_error_dialog(buf, _("CTCP UserInfo"), GAIM_INFO); 1554 do_error_dialog(buf, _("CTCP UserInfo"), GAIM_INFO);
1553 1555
1554 } else if (!g_strcasecmp(word[4], ":\001VERSION")) { 1556 } else if (!g_ascii_strcasecmp(word[4], ":\001VERSION")) {
1555 char *p = g_strrstr(word_eol[5], "\001"); 1557 char *p = g_strrstr(word_eol[5], "\001");
1556 *p = 0; 1558 *p = 0;
1557 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]); 1559 g_snprintf(buf, sizeof(buf), "CTCP Answer: %s", word_eol[5]);
1558 do_error_dialog(buf, _("CTCP Version"), GAIM_INFO); 1560 do_error_dialog(buf, _("CTCP Version"), GAIM_INFO);
1559 1561
1560 } else if (!g_strcasecmp(word[4], ":\001PING")) { 1562 } else if (!g_ascii_strcasecmp(word[4], ":\001PING")) {
1561 char *p = g_strrstr(word_eol[5], "\001"); 1563 char *p = g_strrstr(word_eol[5], "\001");
1562 struct timeval ping_time; 1564 struct timeval ping_time;
1563 struct timeval now; 1565 struct timeval now;
1564 gchar **vector; 1566 gchar **vector;
1565 1567
1599 char *chan = *word[3] == ':' ? word[3] + 1 : word[3]; 1601 char *chan = *word[3] == ':' ? word[3] + 1 : word[3];
1600 static int id = 1; 1602 static int id = 1;
1601 struct gaim_conversation *c; 1603 struct gaim_conversation *c;
1602 char *hostmask, *p; 1604 char *hostmask, *p;
1603 1605
1604 if (!g_strcasecmp(gc->displayname, nick)) { 1606 if (!gaim_utf8_strcasecmp(gc->displayname, nick)) {
1605 serv_got_joined_chat(gc, id++, chan); 1607 serv_got_joined_chat(gc, id++, chan);
1606 } else { 1608 } else {
1607 c = irc_find_chat(gc, chan); 1609 c = irc_find_chat(gc, chan);
1608 if (c) { 1610 if (c) {
1609 hostmask = g_strdup(word[1]); 1611 hostmask = g_strdup(word[1]);
1670 who++; 1672 who++;
1671 if (*who == '%') 1673 if (*who == '%')
1672 who++; 1674 who++;
1673 if (*who == '+') 1675 if (*who == '+')
1674 who++; 1676 who++;
1675 if (!g_strcasecmp(who, nick)) { 1677 if (!gaim_utf8_strcasecmp(who, nick)) {
1676 char *tmp = g_strdup(r->data); 1678 char *tmp = g_strdup(r->data);
1677 gaim_chat_remove_user(chat, tmp, reason); 1679 gaim_chat_remove_user(chat, tmp, reason);
1678 g_free(tmp); 1680 g_free(tmp);
1679 break; 1681 break;
1680 } 1682 }
2048 return 1; 2050 return 1;
2049 } 2051 }
2050 2052
2051 process_data_init(pdibuf, what + 1, word, word_eol, TRUE); 2053 process_data_init(pdibuf, what + 1, word, word_eol, TRUE);
2052 g_string_free(str, FALSE); 2054 g_string_free(str, FALSE);
2053 if (!g_strcasecmp(pdibuf, "ME")) { 2055 if (!g_ascii_strcasecmp(pdibuf, "ME")) {
2054 if (dccchat) { 2056 if (dccchat) {
2055 intl = irc_send_convert(gc, word_eol[2], sizeof(buf), &len); 2057 intl = irc_send_convert(gc, word_eol[2], sizeof(buf), &len);
2056 g_snprintf(buf, sizeof(buf), "\001ACTION %s\001\r\n", intl); 2058 g_snprintf(buf, sizeof(buf), "\001ACTION %s\001\r\n", intl);
2057 g_free(intl); 2059 g_free(intl);
2058 irc_write(dccchat->fd, buf, strlen(buf)); 2060 irc_write(dccchat->fd, buf, strlen(buf));
2061 } 2063 }
2062 g_snprintf(buf, sizeof(buf), "\001ACTION %s\001", word_eol[2]); 2064 g_snprintf(buf, sizeof(buf), "\001ACTION %s\001", word_eol[2]);
2063 irc_send_privmsg (gc, who, buf, FALSE); 2065 irc_send_privmsg (gc, who, buf, FALSE);
2064 g_free(what); 2066 g_free(what);
2065 return 1; 2067 return 1;
2066 } else if (!g_strcasecmp(pdibuf, "INVITE")) { 2068 } else if (!g_ascii_strcasecmp(pdibuf, "INVITE")) {
2067 char buf[IRC_BUF_LEN]; 2069 char buf[IRC_BUF_LEN];
2068 g_snprintf(buf, sizeof(buf), "INVITE %s\r\n", word_eol[2]); 2070 g_snprintf(buf, sizeof(buf), "INVITE %s\r\n", word_eol[2]);
2069 irc_write(id->fd, buf, strlen(buf)); 2071 irc_write(id->fd, buf, strlen(buf));
2070 } else if (!g_strcasecmp(pdibuf, "TOPIC")) { 2072 } else if (!g_ascii_strcasecmp(pdibuf, "TOPIC")) {
2071 if (!*word_eol[2]) { 2073 if (!*word_eol[2]) {
2072 struct gaim_conversation *c; 2074 struct gaim_conversation *c;
2073 struct gaim_chat *chat; 2075 struct gaim_chat *chat;
2074 2076
2075 c = irc_find_chat(gc, who); 2077 c = irc_find_chat(gc, who);
2087 intl = irc_send_convert(gc, word_eol[2], sizeof(buf), &len); 2089 intl = irc_send_convert(gc, word_eol[2], sizeof(buf), &len);
2088 g_snprintf(buf, sizeof(buf), "TOPIC %s :%s\r\n", who, intl); 2090 g_snprintf(buf, sizeof(buf), "TOPIC %s :%s\r\n", who, intl);
2089 g_free(intl); 2091 g_free(intl);
2090 irc_write(id->fd, buf, strlen(buf)); 2092 irc_write(id->fd, buf, strlen(buf));
2091 } 2093 }
2092 } else if (!g_strcasecmp(pdibuf, "NICK")) { 2094 } else if (!g_ascii_strcasecmp(pdibuf, "NICK")) {
2093 if (!*word_eol[2]) { 2095 if (!*word_eol[2]) {
2094 g_free(what); 2096 g_free(what);
2095 return -EINVAL; 2097 return -EINVAL;
2096 } 2098 }
2097 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", word_eol[2]); 2099 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", word_eol[2]);
2098 irc_write(id->fd, buf, strlen(buf)); 2100 irc_write(id->fd, buf, strlen(buf));
2099 } else if (!g_strcasecmp(pdibuf, "OP")) { 2101 } else if (!g_ascii_strcasecmp(pdibuf, "OP")) {
2100 set_mode(gc, who, '+', 'o', word); 2102 set_mode(gc, who, '+', 'o', word);
2101 } else if (!g_strcasecmp(pdibuf, "DEOP")) { 2103 } else if (!g_ascii_strcasecmp(pdibuf, "DEOP")) {
2102 set_mode(gc, who, '-', 'o', word); 2104 set_mode(gc, who, '-', 'o', word);
2103 } else if (!g_strcasecmp(pdibuf, "VOICE")) { 2105 } else if (!g_ascii_strcasecmp(pdibuf, "VOICE")) {
2104 set_mode(gc, who, '+', 'v', word); 2106 set_mode(gc, who, '+', 'v', word);
2105 } else if (!g_strcasecmp(pdibuf, "DEVOICE")) { 2107 } else if (!g_ascii_strcasecmp(pdibuf, "DEVOICE")) {
2106 set_mode(gc, who, '-', 'v', word); 2108 set_mode(gc, who, '-', 'v', word);
2107 } else if (!g_strcasecmp(pdibuf, "MODE")) { 2109 } else if (!g_ascii_strcasecmp(pdibuf, "MODE")) {
2108 char *chan = who; 2110 char *chan = who;
2109 set_chan_mode(gc, chan, word_eol[2]); 2111 set_chan_mode(gc, chan, word_eol[2]);
2110 } else if (!g_strcasecmp(pdibuf, "QUOTE")) { 2112 } else if (!g_ascii_strcasecmp(pdibuf, "QUOTE")) {
2111 if (!*word_eol[2]) { 2113 if (!*word_eol[2]) {
2112 g_free(what); 2114 g_free(what);
2113 return -EINVAL; 2115 return -EINVAL;
2114 } 2116 }
2115 g_snprintf(buf, sizeof(buf), "%s\r\n", word_eol[2]); 2117 g_snprintf(buf, sizeof(buf), "%s\r\n", word_eol[2]);
2116 irc_write(id->fd, buf, strlen(buf)); 2118 irc_write(id->fd, buf, strlen(buf));
2117 } else if (!g_strcasecmp(pdibuf, "SAY")) { 2119 } else if (!g_ascii_strcasecmp(pdibuf, "SAY")) {
2118 if (!*word_eol[2]) { 2120 if (!*word_eol[2]) {
2119 g_free(what); 2121 g_free(what);
2120 return -EINVAL; 2122 return -EINVAL;
2121 } 2123 }
2122 irc_send_privmsg (gc, who, word_eol[2], TRUE); 2124 irc_send_privmsg (gc, who, word_eol[2], TRUE);
2123 return 1; 2125 return 1;
2124 } else if (!g_strcasecmp(pdibuf, "MSG")) { 2126 } else if (!g_ascii_strcasecmp(pdibuf, "MSG")) {
2125 if (!*word[2]) { 2127 if (!*word[2]) {
2126 g_free(what); 2128 g_free(what);
2127 return -EINVAL; 2129 return -EINVAL;
2128 } 2130 }
2129 if (!*word_eol[3]) { 2131 if (!*word_eol[3]) {
2130 g_free(what); 2132 g_free(what);
2131 return -EINVAL; 2133 return -EINVAL;
2132 } 2134 }
2133 irc_send_privmsg (gc, word[2], word_eol[3], TRUE); 2135 irc_send_privmsg (gc, word[2], word_eol[3], TRUE);
2134 } else if (!g_strcasecmp(pdibuf, "KICK")) { 2136 } else if (!g_ascii_strcasecmp(pdibuf, "KICK")) {
2135 if (!*word[2]) { 2137 if (!*word[2]) {
2136 g_free(what); 2138 g_free(what);
2137 return -EINVAL; 2139 return -EINVAL;
2138 } 2140 }
2139 if (*word_eol[3]) { 2141 if (*word_eol[3]) {
2141 g_snprintf(buf, sizeof(buf), "KICK %s %s :%s\r\n", who, word[2], intl); 2143 g_snprintf(buf, sizeof(buf), "KICK %s %s :%s\r\n", who, word[2], intl);
2142 g_free(intl); 2144 g_free(intl);
2143 } else 2145 } else
2144 g_snprintf(buf, sizeof(buf), "KICK %s %s\r\n", who, word[2]); 2146 g_snprintf(buf, sizeof(buf), "KICK %s %s\r\n", who, word[2]);
2145 irc_write(id->fd, buf, strlen(buf)); 2147 irc_write(id->fd, buf, strlen(buf));
2146 } else if (!g_strcasecmp(pdibuf, "JOIN") || !g_strcasecmp(pdibuf, "J")) { 2148 } else if (!g_ascii_strcasecmp(pdibuf, "JOIN") || !g_ascii_strcasecmp(pdibuf, "J")) {
2147 if (!*word[2]) { 2149 if (!*word[2]) {
2148 g_free(what); 2150 g_free(what);
2149 return -EINVAL; 2151 return -EINVAL;
2150 } 2152 }
2151 if (*word[3]) 2153 if (*word[3])
2152 g_snprintf(buf, sizeof(buf), "JOIN %s %s\r\n", word[2], word[3]); 2154 g_snprintf(buf, sizeof(buf), "JOIN %s %s\r\n", word[2], word[3]);
2153 else 2155 else
2154 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", word[2]); 2156 g_snprintf(buf, sizeof(buf), "JOIN %s\r\n", word[2]);
2155 irc_write(id->fd, buf, strlen(buf)); 2157 irc_write(id->fd, buf, strlen(buf));
2156 } else if (!g_strcasecmp(pdibuf, "PART")) { 2158 } else if (!g_ascii_strcasecmp(pdibuf, "PART")) {
2157 char *chan = *word[2] ? word[2] : who; 2159 char *chan = *word[2] ? word[2] : who;
2158 char *reason = word_eol[3]; 2160 char *reason = word_eol[3];
2159 struct gaim_conversation *c; 2161 struct gaim_conversation *c;
2160 if (!is_channel(gc, chan)) { 2162 if (!is_channel(gc, chan)) {
2161 g_free(what); 2163 g_free(what);
2173 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); 2175 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c);
2174 gaim_conversation_set_account(c, NULL); 2176 gaim_conversation_set_account(c, NULL);
2175 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan); 2177 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan);
2176 do_error_dialog(buf, _("IRC Part"), GAIM_INFO); 2178 do_error_dialog(buf, _("IRC Part"), GAIM_INFO);
2177 } 2179 }
2178 } else if (!g_strcasecmp(pdibuf, "WHOIS")) { 2180 } else if (!g_ascii_strcasecmp(pdibuf, "WHOIS")) {
2179 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", word_eol[2]); 2181 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", word_eol[2]);
2180 irc_write(id->fd, buf, strlen(buf)); 2182 irc_write(id->fd, buf, strlen(buf));
2181 } else if (!g_strcasecmp(pdibuf, "WHOWAS")) { 2183 } else if (!g_ascii_strcasecmp(pdibuf, "WHOWAS")) {
2182 g_snprintf(buf, sizeof(buf), "WHOWAS %s\r\n", word_eol[2]); 2184 g_snprintf(buf, sizeof(buf), "WHOWAS %s\r\n", word_eol[2]);
2183 irc_write(id->fd, buf, strlen(buf)); 2185 irc_write(id->fd, buf, strlen(buf));
2184 } else if (!g_strcasecmp(pdibuf, "LIST")) { 2186 } else if (!g_ascii_strcasecmp(pdibuf, "LIST")) {
2185 g_snprintf(buf, sizeof(buf), "LIST\r\n"); 2187 g_snprintf(buf, sizeof(buf), "LIST\r\n");
2186 irc_write(id->fd, buf, strlen(buf)); 2188 irc_write(id->fd, buf, strlen(buf));
2187 } else if (!g_strcasecmp(pdibuf, "QUIT")) { 2189 } else if (!g_ascii_strcasecmp(pdibuf, "QUIT")) {
2188 char *reason = word_eol[2]; 2190 char *reason = word_eol[2];
2189 id->str = g_string_insert(id->str, 0, reason); 2191 id->str = g_string_insert(id->str, 0, reason);
2190 do_quit(); 2192 do_quit();
2191 } else if (!g_strcasecmp(pdibuf, "VERSION")) { 2193 } else if (!g_ascii_strcasecmp(pdibuf, "VERSION")) {
2192 g_snprintf(buf, sizeof(buf), "VERSION\r\n"); 2194 g_snprintf(buf, sizeof(buf), "VERSION\r\n");
2193 irc_write(id->fd, buf, strlen(buf)); 2195 irc_write(id->fd, buf, strlen(buf));
2194 } else if (!g_strcasecmp(pdibuf, "W")) { 2196 } else if (!g_ascii_strcasecmp(pdibuf, "W")) {
2195 g_snprintf(buf, sizeof(buf), "WHO *\r\n"); 2197 g_snprintf(buf, sizeof(buf), "WHO *\r\n");
2196 irc_write(id->fd, buf, strlen(buf)); 2198 irc_write(id->fd, buf, strlen(buf));
2197 } else if (!g_strcasecmp(pdibuf, "REHASH")) { 2199 } else if (!g_ascii_strcasecmp(pdibuf, "REHASH")) {
2198 g_snprintf(buf, sizeof(buf), "REHASH\r\n"); 2200 g_snprintf(buf, sizeof(buf), "REHASH\r\n");
2199 irc_write(id->fd, buf, strlen(buf)); 2201 irc_write(id->fd, buf, strlen(buf));
2200 } else if (!g_strcasecmp(pdibuf, "RESTART")) { 2202 } else if (!g_ascii_strcasecmp(pdibuf, "RESTART")) {
2201 g_snprintf(buf, sizeof(buf), "RESTART\r\n"); 2203 g_snprintf(buf, sizeof(buf), "RESTART\r\n");
2202 irc_write(id->fd, buf, strlen(buf)); 2204 irc_write(id->fd, buf, strlen(buf));
2203 } else if (!g_strcasecmp(pdibuf, "CTCP")) { 2205 } else if (!g_ascii_strcasecmp(pdibuf, "CTCP")) {
2204 if (!g_strcasecmp(word[2], "CLIENTINFO")) { 2206 if (!g_ascii_strcasecmp(word[2], "CLIENTINFO")) {
2205 if (word[3]) 2207 if (word[3])
2206 irc_ctcp_clientinfo(gc, word[3]); 2208 irc_ctcp_clientinfo(gc, word[3]);
2207 } else if (!g_strcasecmp(word[2], "USERINFO")) { 2209 } else if (!g_ascii_strcasecmp(word[2], "USERINFO")) {
2208 if (word[3]) 2210 if (word[3])
2209 irc_ctcp_userinfo(gc, word[3]); 2211 irc_ctcp_userinfo(gc, word[3]);
2210 } else if (!g_strcasecmp(word[2], "VERSION")) { 2212 } else if (!g_ascii_strcasecmp(word[2], "VERSION")) {
2211 if (word[3]) 2213 if (word[3])
2212 irc_ctcp_version(gc, word[3]); 2214 irc_ctcp_version(gc, word[3]);
2213 2215
2214 } else if (!g_strcasecmp(word[2], "PING")) { 2216 } else if (!g_ascii_strcasecmp(word[2], "PING")) {
2215 if (word[3]) 2217 if (word[3])
2216 irc_ctcp_ping(gc, word[3]); 2218 irc_ctcp_ping(gc, word[3]);
2217 } 2219 }
2218 } else if (!g_strcasecmp(pdibuf, "DCC")) { 2220 } else if (!g_ascii_strcasecmp(pdibuf, "DCC")) {
2219 struct gaim_conversation *c = NULL; 2221 struct gaim_conversation *c = NULL;
2220 if (!g_strcasecmp(word[2], "CHAT")) { 2222 if (!g_ascii_strcasecmp(word[2], "CHAT")) {
2221 if (word[3]) 2223 if (word[3])
2222 irc_start_chat(gc, word[3]); 2224 irc_start_chat(gc, word[3]);
2223 2225
2224 if (is_channel(gc, who)) { 2226 if (is_channel(gc, who)) {
2225 c = irc_find_chat(gc, who); 2227 c = irc_find_chat(gc, who);
2230 gaim_conversation_write(c, NULL, 2232 gaim_conversation_write(c, NULL,
2231 _("<I>Requesting DCC CHAT</I>"), 2233 _("<I>Requesting DCC CHAT</I>"),
2232 -1, WFLAG_SYSTEM, time(NULL)); 2234 -1, WFLAG_SYSTEM, time(NULL));
2233 } 2235 }
2234 } 2236 }
2235 } else if (!g_strcasecmp(pdibuf, "HELP")) { 2237 } else if (!g_ascii_strcasecmp(pdibuf, "HELP")) {
2236 struct gaim_conversation *c = NULL; 2238 struct gaim_conversation *c = NULL;
2237 if (is_channel(gc, who)) { 2239 if (is_channel(gc, who)) {
2238 c = irc_find_chat(gc, who); 2240 c = irc_find_chat(gc, who);
2239 } else { 2241 } else {
2240 c = gaim_find_conversation(who); 2242 c = gaim_find_conversation(who);
2241 } 2243 }
2242 if (!c) { 2244 if (!c) {
2243 g_free(what); 2245 g_free(what);
2244 return -EINVAL; 2246 return -EINVAL;
2245 } 2247 }
2246 if (!g_strcasecmp(word[2], "OPER")) { 2248 if (!g_ascii_strcasecmp(word[2], "OPER")) {
2247 gaim_conversation_write(c, NULL, 2249 gaim_conversation_write(c, NULL,
2248 _("<B>Operator commands:<BR>" 2250 _("<B>Operator commands:<BR>"
2249 "REHASH RESTART</B>"), 2251 "REHASH RESTART</B>"),
2250 -1, WFLAG_NOLOG, time(NULL)); 2252 -1, WFLAG_NOLOG, time(NULL));
2251 } else if (!g_strcasecmp(word[2], "CTCP")) { 2253 } else if (!g_ascii_strcasecmp(word[2], "CTCP")) {
2252 gaim_conversation_write(c, NULL, 2254 gaim_conversation_write(c, NULL,
2253 _("<B>CTCP commands:<BR>" 2255 _("<B>CTCP commands:<BR>"
2254 "CLIENTINFO <nick><BR>" 2256 "CLIENTINFO <nick><BR>"
2255 "USERINFO <nick><BR>" 2257 "USERINFO <nick><BR>"
2256 "VERSION <nick><BR>" 2258 "VERSION <nick><BR>"
2257 "PING <nick></B><BR>"), 2259 "PING <nick></B><BR>"),
2258 -1, WFLAG_NOLOG, time(NULL)); 2260 -1, WFLAG_NOLOG, time(NULL));
2259 } else if (!g_strcasecmp(word[2], "DCC")) { 2261 } else if (!g_ascii_strcasecmp(word[2], "DCC")) {
2260 gaim_conversation_write(c, NULL, 2262 gaim_conversation_write(c, NULL,
2261 _("<B>DCC commands:<BR>" 2263 _("<B>DCC commands:<BR>"
2262 "CHAT <nick></B>"), 2264 "CHAT <nick></B>"),
2263 -1, WFLAG_NOLOG, time(NULL)); 2265 -1, WFLAG_NOLOG, time(NULL));
2264 } else { 2266 } else {