src/protocols/irc/msgs.c

changeset 10246
aa5bff72f94c
parent 10242
3d70dbd01f4c
child 10504
eae130eefbfe
equal deleted inserted replaced
10245:81654bee87e8 10246:aa5bff72f94c
116 char *buf; 116 char *buf;
117 117
118 if (!args || !args[1] || !args[2]) 118 if (!args || !args[1] || !args[2])
119 return; 119 return;
120 120
121 convo = gaim_find_conversation_with_account(args[1], irc->account); 121 convo = gaim_find_conversation_with_account(GAIM_CONV_CHAT, args[1], irc->account);
122 if (!convo) /* XXX punt on channels we are not in for now */ 122 if (!convo) /* XXX punt on channels we are not in for now */
123 return; 123 return;
124 124
125 buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], args[3] ? args[3] : ""); 125 buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], args[3] ? args[3] : "");
126 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 126 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
269 } else { 269 } else {
270 chan = args[1]; 270 chan = args[1];
271 topic = irc_mirc2txt (args[2]); 271 topic = irc_mirc2txt (args[2]);
272 } 272 }
273 273
274 convo = gaim_find_conversation_with_account(chan, irc->account); 274 convo = gaim_find_conversation_with_account(GAIM_CONV_CHAT, chan, irc->account);
275 if (!convo) { 275 if (!convo) {
276 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan); 276 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan);
277 } 277 }
278 278
279 /* If this is an interactive update, print it out */ 279 /* If this is an interactive update, print it out */
314 { 314 {
315 char *names, *cur, *end, *tmp, *msg; 315 char *names, *cur, *end, *tmp, *msg;
316 GaimConversation *convo; 316 GaimConversation *convo;
317 317
318 if (!strcmp(name, "366")) { 318 if (!strcmp(name, "366")) {
319 convo = gaim_find_conversation_with_account(irc->nameconv ? irc->nameconv : args[1], irc->account); 319 convo = gaim_find_conversation_with_account(GAIM_CONV_ANY, irc->nameconv ? irc->nameconv : args[1], irc->account);
320 if (!convo) { 320 if (!convo) {
321 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[2]); 321 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[2]);
322 g_string_free(irc->names, TRUE); 322 g_string_free(irc->names, TRUE);
323 irc->names = NULL; 323 irc->names = NULL;
324 g_free(irc->nameconv); 324 g_free(irc->nameconv);
429 void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args) 429 void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args)
430 { 430 {
431 GaimConnection *gc; 431 GaimConnection *gc;
432 GaimConversation *convo; 432 GaimConversation *convo;
433 433
434 convo = gaim_find_conversation_with_account(args[1], irc->account); 434 convo = gaim_find_conversation_with_account(GAIM_CONV_ANY, args[1], irc->account);
435 if (convo) { 435 if (convo) {
436 if (gaim_conversation_get_type(convo) == GAIM_CONV_CHAT) /* does this happen? */ 436 if (gaim_conversation_get_type(convo) == GAIM_CONV_CHAT) /* does this happen? */
437 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], _("no such channel"), 437 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], _("no such channel"),
438 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 438 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
439 else 439 else
454 void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args) 454 void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args)
455 { 455 {
456 GaimConnection *gc; 456 GaimConnection *gc;
457 GaimConversation *convo; 457 GaimConversation *convo;
458 458
459 convo = gaim_find_conversation_with_account(args[1], irc->account); 459 convo = gaim_find_conversation_with_account(GAIM_CONV_CHAT, args[1], irc->account);
460 if (convo) { 460 if (convo) {
461 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], args[2], GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 461 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], args[2], GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
462 } else { 462 } else {
463 if ((gc = gaim_account_get_connection(irc->account)) == NULL) 463 if ((gc = gaim_account_get_connection(irc->account)) == NULL)
464 return; 464 return;
466 } 466 }
467 } 467 }
468 468
469 void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args) 469 void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args)
470 { 470 {
471 GaimConversation *convo = gaim_find_conversation_with_account(args[1], irc->account); 471 GaimConversation *convo = gaim_find_conversation_with_account(GAIM_CONV_CHAT, args[1], irc->account);
472 472
473 gaim_debug(GAIM_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]); 473 gaim_debug(GAIM_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]);
474 if (convo) { 474 if (convo) {
475 /*g_slist_remove(irc->gc->buddy_chats, convo); 475 /*g_slist_remove(irc->gc->buddy_chats, convo);
476 gaim_conversation_set_account(convo, NULL);*/ 476 gaim_conversation_set_account(convo, NULL);*/
483 GaimConversation *convo; 483 GaimConversation *convo;
484 484
485 if (!args || !args[1] || !args[2]) 485 if (!args || !args[1] || !args[2])
486 return; 486 return;
487 487
488 convo = gaim_find_conversation_with_account(args[1], irc->account); 488 convo = gaim_find_conversation_with_account(GAIM_CONV_CHAT, args[1], irc->account);
489 if (!convo) 489 if (!convo)
490 return; 490 return;
491 491
492 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", args[2], GAIM_MESSAGE_SYSTEM, time(NULL)); 492 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", args[2], GAIM_MESSAGE_SYSTEM, time(NULL));
493 } 493 }
581 serv_got_joined_chat(gc, id++, args[0]); 581 serv_got_joined_chat(gc, id++, args[0]);
582 g_free(nick); 582 g_free(nick);
583 return; 583 return;
584 } 584 }
585 585
586 convo = gaim_find_conversation_with_account(args[0], irc->account); 586 convo = gaim_find_conversation_with_account(GAIM_CONV_CHAT, args[0], irc->account);
587 if (convo == NULL) { 587 if (convo == NULL) {
588 gaim_debug(GAIM_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]); 588 gaim_debug(GAIM_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]);
589 g_free(nick); 589 g_free(nick);
590 return; 590 return;
591 } 591 }
603 } 603 }
604 604
605 void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args) 605 void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args)
606 { 606 {
607 GaimConnection *gc = gaim_account_get_connection(irc->account); 607 GaimConnection *gc = gaim_account_get_connection(irc->account);
608 GaimConversation *convo = gaim_find_conversation_with_account(args[0], irc->account); 608 GaimConversation *convo = gaim_find_conversation_with_account(GAIM_CONV_CHAT, args[0], irc->account);
609 char *nick = irc_mask_nick(from), *buf; 609 char *nick = irc_mask_nick(from), *buf;
610 610
611 if (!gc) { 611 if (!gc) {
612 g_free(nick); 612 g_free(nick);
613 return; 613 return;
638 { 638 {
639 GaimConversation *convo; 639 GaimConversation *convo;
640 char *nick = irc_mask_nick(from), *buf; 640 char *nick = irc_mask_nick(from), *buf;
641 641
642 if (*args[0] == '#' || *args[0] == '&') { /* Channel */ 642 if (*args[0] == '#' || *args[0] == '&') { /* Channel */
643 convo = gaim_find_conversation_with_account(args[0], irc->account); 643 convo = gaim_find_conversation_with_account(GAIM_CONV_CHAT, args[0], irc->account);
644 if (!convo) { 644 if (!convo) {
645 gaim_debug(GAIM_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]); 645 gaim_debug(GAIM_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]);
646 g_free(nick); 646 g_free(nick);
647 return; 647 return;
648 } 648 }
767 char *nick, *msg; 767 char *nick, *msg;
768 768
769 if (!args || !args[0] || !gc) 769 if (!args || !args[0] || !gc)
770 return; 770 return;
771 771
772 convo = gaim_find_conversation_with_account(args[0], irc->account); 772 convo = gaim_find_conversation_with_account(GAIM_CONV_CHAT, args[0], irc->account);
773 if (!convo) { 773 if (!convo) {
774 gaim_debug(GAIM_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", args[0]); 774 gaim_debug(GAIM_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", args[0]);
775 return; 775 return;
776 } 776 }
777 777
820 msg = g_strdup(_("Error: invalid PONG from server")); 820 msg = g_strdup(_("Error: invalid PONG from server"));
821 } else { 821 } else {
822 msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp); 822 msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp);
823 } 823 }
824 824
825 convo = gaim_find_conversation_with_account(parts[0], irc->account); 825 convo = gaim_find_conversation_with_account(GAIM_CONV_ANY, parts[0], irc->account);
826 g_strfreev(parts); 826 g_strfreev(parts);
827 if (convo) { 827 if (convo) {
828 if (gaim_conversation_get_type (convo) == GAIM_CONV_CHAT) 828 if (gaim_conversation_get_type (convo) == GAIM_CONV_CHAT)
829 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "PONG", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 829 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "PONG", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
830 else 830 else
874 if (!gaim_utf8_strcasecmp(args[0], gaim_connection_get_display_name(gc))) { 874 if (!gaim_utf8_strcasecmp(args[0], gaim_connection_get_display_name(gc))) {
875 serv_got_im(gc, nick, msg, 0, time(NULL)); 875 serv_got_im(gc, nick, msg, 0, time(NULL));
876 } else if (notice) { 876 } else if (notice) {
877 serv_got_im(gc, nick, msg, 0, time(NULL)); 877 serv_got_im(gc, nick, msg, 0, time(NULL));
878 } else { 878 } else {
879 convo = gaim_find_conversation_with_account(args[0], irc->account); 879 convo = gaim_find_conversation_with_account(GAIM_CONV_CHAT, args[0], irc->account);
880 if (convo) 880 if (convo)
881 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), nick, 0, msg, time(NULL)); 881 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), nick, 0, msg, time(NULL));
882 else 882 else
883 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a PRIVMSG on %s, which does not exist\n", args[0]); 883 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a PRIVMSG on %s, which does not exist\n", args[0]);
884 } 884 }

mercurial