comparison src/protocols/irc/irc.c @ 2619:536198196dc6

[gaim-migrate @ 2632] i hate you mid. i have that IM Me song stuck in my head. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 26 Oct 2001 10:11:33 +0000
parents 251ecc5cd9b3
children a1b708ee93af
comparison
equal deleted inserted replaced
2618:047256035ec6 2619:536198196dc6
57 57
58 char *chantypes; 58 char *chantypes;
59 char *chanmodes; 59 char *chanmodes;
60 char *nickmodes; 60 char *nickmodes;
61 gboolean six_modes; 61 gboolean six_modes;
62
63 gboolean in_whois;
64 GString *whois_str;
62 }; 65 };
63 66
64 static char *irc_name() 67 static char *irc_name()
65 { 68 {
66 return "IRC"; 69 return "IRC";
561 break; 564 break;
562 case 5: 565 case 5:
563 handle_005(gc, word, word_eol); 566 handle_005(gc, word, word_eol);
564 break; 567 break;
565 case 301: 568 case 301:
566 irc_got_im(gc, word[4], word_eol[5], IM_FLAG_AWAY, time(NULL)); 569 if (id->in_whois) {
570 id->whois_str = g_string_append(id->whois_str, "<BR><BR>");
571 id->whois_str = g_string_append(id->whois_str, word_eol[4]);
572 } else
573 irc_got_im(gc, word[4], word_eol[5], IM_FLAG_AWAY, time(NULL));
567 break; 574 break;
568 case 303: 575 case 303:
569 handle_list(gc, &word_eol[4][1]); 576 handle_list(gc, &word_eol[4][1]);
577 break;
578 case 311:
579 case 312:
580 case 313:
581 case 317:
582 case 319:
583 if (!id->in_whois) {
584 id->in_whois = TRUE;
585 id->whois_str = g_string_new("");
586 } else {
587 id->whois_str = g_string_append(id->whois_str, "<BR><BR>");
588 id->in_whois = TRUE;
589 }
590 id->whois_str = g_string_append(id->whois_str, word_eol[4]);
591 break;
592 case 318:
593 id->whois_str = g_string_append(id->whois_str, "<BR><BR>");
594 id->whois_str = g_string_append(id->whois_str, word_eol[4]);
595 {
596 GString *str = decode_html(id->whois_str->str);
597 g_show_info_text(str->str);
598 g_string_free(str, TRUE);
599 }
600 g_string_free(id->whois_str, TRUE);
601 id->whois_str = NULL;
602 id->in_whois = FALSE;
570 break; 603 break;
571 case 324: 604 case 324:
572 handle_mode(gc, word, word_eol, TRUE); 605 handle_mode(gc, word, word_eol, TRUE);
573 break; 606 break;
574 case 332: 607 case 332:
577 case 353: 610 case 353:
578 handle_names(gc, word[5], word_eol[6]); 611 handle_names(gc, word[5], word_eol[6]);
579 break; 612 break;
580 case 376: 613 case 376:
581 irc_request_buddy_update(gc); 614 irc_request_buddy_update(gc);
615 break;
616 case 401:
617 case 402:
618 case 431:
619 if (!id->in_whois) {
620 id->in_whois = TRUE;
621 id->whois_str = g_string_new("");
622 } else {
623 id->whois_str = g_string_append(id->whois_str, "<BR><BR>");
624 id->in_whois = TRUE;
625 }
626 id->whois_str = g_string_append(id->whois_str, word_eol[4]);
582 break; 627 break;
583 } 628 }
584 } 629 }
585 630
586 static gboolean is_channel(struct gaim_connection *gc, char *name) 631 static gboolean is_channel(struct gaim_connection *gc, char *name)
949 g_free(idata->chantypes); 994 g_free(idata->chantypes);
950 g_free(idata->chanmodes); 995 g_free(idata->chanmodes);
951 g_free(idata->nickmodes); 996 g_free(idata->nickmodes);
952 997
953 g_string_free(idata->str, TRUE); 998 g_string_free(idata->str, TRUE);
999 if (idata->whois_str)
1000 g_string_free(idata->whois_str, TRUE);
954 1001
955 if (idata->timer) 1002 if (idata->timer)
956 g_source_remove(idata->timer); 1003 g_source_remove(idata->timer);
957 1004
958 if (gc->inpa) 1005 if (gc->inpa)
1164 if (*word_eol[3]) 1211 if (*word_eol[3])
1165 g_snprintf(buf, sizeof(buf), "KICK %s %s :%s\r\n", who, word[2], word_eol[3]); 1212 g_snprintf(buf, sizeof(buf), "KICK %s %s :%s\r\n", who, word[2], word_eol[3]);
1166 else 1213 else
1167 g_snprintf(buf, sizeof(buf), "KICK %s %s\r\n", who, word[2]); 1214 g_snprintf(buf, sizeof(buf), "KICK %s %s\r\n", who, word[2]);
1168 irc_write(id->fd, buf, strlen(buf)); 1215 irc_write(id->fd, buf, strlen(buf));
1169 } else if (!g_strcasecmp(pdibuf, "BAN")) {
1170 } else if (!g_strcasecmp(pdibuf, "KICKBAN")) {
1171 } else if (!g_strcasecmp(pdibuf, "JOIN")) { 1216 } else if (!g_strcasecmp(pdibuf, "JOIN")) {
1172 if (!*word[2]) 1217 if (!*word[2])
1173 return -EINVAL; 1218 return -EINVAL;
1174 if (*word[3]) 1219 if (*word[3])
1175 g_snprintf(buf, sizeof(buf), "JOIN %s %s\r\n", word[2], word[3]); 1220 g_snprintf(buf, sizeof(buf), "JOIN %s %s\r\n", word[2], word[3]);
1191 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c); 1236 gc->buddy_chats = g_slist_remove(gc->buddy_chats, c);
1192 c->gc = NULL; 1237 c->gc = NULL;
1193 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan); 1238 g_snprintf(buf, sizeof(buf), _("You have left %s"), chan);
1194 do_error_dialog(buf, _("IRC Part")); 1239 do_error_dialog(buf, _("IRC Part"));
1195 } 1240 }
1241 } else if (!g_strcasecmp(pdibuf, "WHOIS")) {
1242 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", word_eol[2]);
1243 irc_write(id->fd, buf, strlen(buf));
1196 } else if (!g_strcasecmp(pdibuf, "HELP")) { 1244 } else if (!g_strcasecmp(pdibuf, "HELP")) {
1197 struct conversation *c = NULL; 1245 struct conversation *c = NULL;
1198 if (is_channel(gc, who)) { 1246 if (is_channel(gc, who)) {
1199 c = irc_find_chat(gc, who); 1247 c = irc_find_chat(gc, who);
1200 } else { 1248 } else {
1201 c = find_conversation(who); 1249 c = find_conversation(who);
1202 } 1250 }
1203 if (!c) 1251 if (!c)
1204 return -EINVAL; 1252 return -EINVAL;
1205 write_to_conv(c, "<B>Currently supported commands:<BR>" 1253 write_to_conv(c, "<B>Currently supported commands:<BR>"
1206 "JOIN PART TOPIC<BR>" 1254 "JOIN PART TOPIC WHOIS<BR>"
1207 "OP DEOP VOICE DEVOICE KICK<BR>" 1255 "OP DEOP VOICE DEVOICE KICK<BR>"
1208 "NICK ME MSG QUOTE SAY</B>", 1256 "NICK ME MSG QUOTE SAY</B>",
1209 WFLAG_NOLOG, NULL, time(NULL)); 1257 WFLAG_NOLOG, NULL, time(NULL));
1210 } else { 1258 } else {
1211 struct conversation *c = NULL; 1259 struct conversation *c = NULL;
1331 } 1379 }
1332 1380
1333 static char **irc_list_icon(int uc) 1381 static char **irc_list_icon(int uc)
1334 { 1382 {
1335 return irc_icon_xpm; 1383 return irc_icon_xpm;
1384 }
1385
1386 static void irc_get_info(struct gaim_connection *gc, char *who)
1387 {
1388 struct irc_data *idata = gc->proto_data;
1389 char buf[IRC_BUF_LEN];
1390
1391 g_snprintf(buf, sizeof(buf), "WHOIS %s\r\n", who);
1392 irc_write(idata->fd, buf, strlen(buf));
1393 }
1394
1395 static GList *irc_buddy_menu(struct gaim_connection *gc, char *who)
1396 {
1397 GList *m = NULL;
1398 struct proto_buddy_menu *pbm;
1399
1400 pbm = g_new0(struct proto_buddy_menu, 1);
1401 pbm->label = _("Get Info");
1402 pbm->callback = irc_get_info;
1403 pbm->gc = gc;
1404 m = g_list_append(m, pbm);
1405
1406 return m;
1336 } 1407 }
1337 1408
1338 static struct prpl *my_protocol = NULL; 1409 static struct prpl *my_protocol = NULL;
1339 1410
1340 void irc_init(struct prpl *ret) 1411 void irc_init(struct prpl *ret)
1353 ret->join_chat = irc_join_chat; 1424 ret->join_chat = irc_join_chat;
1354 ret->chat_leave = irc_chat_leave; 1425 ret->chat_leave = irc_chat_leave;
1355 ret->chat_send = irc_chat_send; 1426 ret->chat_send = irc_chat_send;
1356 ret->away_states = irc_away_states; 1427 ret->away_states = irc_away_states;
1357 ret->set_away = irc_set_away; 1428 ret->set_away = irc_set_away;
1429 ret->get_info = irc_get_info;
1430 ret->buddy_menu = irc_buddy_menu;
1358 my_protocol = ret; 1431 my_protocol = ret;
1359 } 1432 }
1360 1433
1361 #ifndef STATIC 1434 #ifndef STATIC
1362 1435