src/protocols/irc/msgs.c

changeset 7118
280b3b85a28a
parent 7108
82655fa54acb
child 7877
e523a7081aaf
equal deleted inserted replaced
7117:4d6a9973c7a9 7118:280b3b85a28a
54 return g_strdup(strchr(mask, '!') + 1); 54 return g_strdup(strchr(mask, '!') + 1);
55 } 55 }
56 56
57 static void irc_chat_remove_buddy(GaimConversation *convo, char *data[2]) 57 static void irc_chat_remove_buddy(GaimConversation *convo, char *data[2])
58 { 58 {
59 GList *users = gaim_chat_get_users(GAIM_CHAT(convo)); 59 GList *users = gaim_conv_chat_get_users(GAIM_CONV_CHAT(convo));
60 char *message = g_strdup_printf("quit: %s", data[1]); 60 char *message = g_strdup_printf("quit: %s", data[1]);
61 61
62 if (g_list_find_custom(users, data[0], (GCompareFunc)(strcmp))) 62 if (g_list_find_custom(users, data[0], (GCompareFunc)(strcmp)))
63 gaim_chat_remove_user(GAIM_CHAT(convo), data[0], message); 63 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), data[0], message);
64 64
65 g_free(message); 65 g_free(message);
66 } 66 }
67 67
68 void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args) 68 void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args)
83 return; 83 return;
84 } 84 }
85 85
86 gc = gaim_account_get_connection(irc->account); 86 gc = gaim_account_get_connection(irc->account);
87 if (gc) 87 if (gc)
88 serv_got_im(gc, args[1], args[2], GAIM_IM_AUTO_RESP, time(NULL)); 88 serv_got_im(gc, args[1], args[2], GAIM_CONV_IM_AUTO_RESP, time(NULL));
89 } 89 }
90 90
91 void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args) 91 void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args)
92 { 92 {
93 GaimConnection *gc = gaim_account_get_connection(irc->account); 93 GaimConnection *gc = gaim_account_get_connection(irc->account);
122 convo = gaim_find_conversation_with_account(args[1], irc->account); 122 convo = gaim_find_conversation_with_account(args[1], irc->account);
123 if (!convo) /* XXX punt on channels we are not in for now */ 123 if (!convo) /* XXX punt on channels we are not in for now */
124 return; 124 return;
125 125
126 buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], args[3] ? args[3] : ""); 126 buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], args[3] ? args[3] : "");
127 gaim_chat_write(GAIM_CHAT(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 127 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
128 g_free(buf); 128 g_free(buf);
129 129
130 return; 130 return;
131 } 131 }
132 132
238 238
239 convo = gaim_find_conversation_with_account(chan, irc->account); 239 convo = gaim_find_conversation_with_account(chan, irc->account);
240 if (!convo) { 240 if (!convo) {
241 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan); 241 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan);
242 } 242 }
243 gaim_chat_set_topic(GAIM_CHAT(convo), NULL, topic); 243 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), NULL, topic);
244 /* If this is an interactive update, print it out */ 244 /* If this is an interactive update, print it out */
245 if (!strcmp(name, "topic")) { 245 if (!strcmp(name, "topic")) {
246 nick = irc_mask_nick(from); 246 nick = irc_mask_nick(from);
247 msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick, topic); 247 msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick, topic);
248 g_free(nick); 248 g_free(nick);
249 gaim_chat_write(GAIM_CHAT(convo), from, msg, GAIM_MESSAGE_SYSTEM, time(NULL)); 249 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), from, msg, GAIM_MESSAGE_SYSTEM, time(NULL));
250 g_free(msg); 250 g_free(msg);
251 } else { 251 } else {
252 msg = g_strdup_printf(_("The topic for %s is: %s"), chan, topic); 252 msg = g_strdup_printf(_("The topic for %s is: %s"), chan, topic);
253 gaim_chat_write(GAIM_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM, time(NULL)); 253 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM, time(NULL));
254 g_free(msg); 254 g_free(msg);
255 } 255 }
256 } 256 }
257 257
258 void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args) 258 void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args)
287 names = cur = g_string_free(irc->names, FALSE); 287 names = cur = g_string_free(irc->names, FALSE);
288 irc->names = NULL; 288 irc->names = NULL;
289 if (irc->nameconv) { 289 if (irc->nameconv) {
290 msg = g_strdup_printf("Users on %s: %s", args[1], names); 290 msg = g_strdup_printf("Users on %s: %s", args[1], names);
291 if (gaim_conversation_get_type(convo) == GAIM_CONV_CHAT) 291 if (gaim_conversation_get_type(convo) == GAIM_CONV_CHAT)
292 gaim_chat_write(GAIM_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 292 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
293 else 293 else
294 gaim_im_write(GAIM_IM(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 294 gaim_conv_im_write(GAIM_CONV_IM(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
295 g_free(msg); 295 g_free(msg);
296 g_free(irc->nameconv); 296 g_free(irc->nameconv);
297 irc->nameconv = NULL; 297 irc->nameconv = NULL;
298 } else { 298 } else {
299 GList *users = NULL; 299 GList *users = NULL;
312 } 312 }
313 313
314 if (users != NULL) { 314 if (users != NULL) {
315 GList *l; 315 GList *l;
316 316
317 gaim_chat_add_users(GAIM_CHAT(convo), users); 317 gaim_conv_chat_add_users(GAIM_CONV_CHAT(convo), users);
318 318
319 for (l = users; l != NULL; l = l->next) 319 for (l = users; l != NULL; l = l->next)
320 g_free(l->data); 320 g_free(l->data);
321 321
322 g_list_free(users); 322 g_list_free(users);
366 GaimConversation *convo; 366 GaimConversation *convo;
367 367
368 convo = gaim_find_conversation_with_account(args[1], irc->account); 368 convo = gaim_find_conversation_with_account(args[1], irc->account);
369 if (convo) { 369 if (convo) {
370 if (gaim_conversation_get_type(convo) == GAIM_CONV_CHAT) /* does this happen? */ 370 if (gaim_conversation_get_type(convo) == GAIM_CONV_CHAT) /* does this happen? */
371 gaim_chat_write(GAIM_CHAT(convo), args[1], _("no such channel"), 371 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], _("no such channel"),
372 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 372 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
373 else 373 else
374 gaim_im_write(GAIM_IM(convo), args[1], _("User is not logged in"), 374 gaim_conv_im_write(GAIM_CONV_IM(convo), args[1], _("User is not logged in"),
375 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 375 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
376 } else { 376 } else {
377 if ((gc = gaim_account_get_connection(irc->account)) == NULL) 377 if ((gc = gaim_account_get_connection(irc->account)) == NULL)
378 return; 378 return;
379 gaim_notify_error(gc, NULL, _("No such nick or channel"), args[1]); 379 gaim_notify_error(gc, NULL, _("No such nick or channel"), args[1]);
390 GaimConnection *gc; 390 GaimConnection *gc;
391 GaimConversation *convo; 391 GaimConversation *convo;
392 392
393 convo = gaim_find_conversation_with_account(args[1], irc->account); 393 convo = gaim_find_conversation_with_account(args[1], irc->account);
394 if (convo) { 394 if (convo) {
395 gaim_chat_write(GAIM_CHAT(convo), args[1], args[2], GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 395 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], args[2], GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
396 } else { 396 } else {
397 if ((gc = gaim_account_get_connection(irc->account)) == NULL) 397 if ((gc = gaim_account_get_connection(irc->account)) == NULL)
398 return; 398 return;
399 gaim_notify_error(gc, NULL, _("Could not send"), args[2]); 399 gaim_notify_error(gc, NULL, _("Could not send"), args[2]);
400 } 400 }
406 406
407 gaim_debug(GAIM_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]); 407 gaim_debug(GAIM_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]);
408 if (convo) { 408 if (convo) {
409 /*g_slist_remove(irc->gc->buddy_chats, convo); 409 /*g_slist_remove(irc->gc->buddy_chats, convo);
410 gaim_conversation_set_account(convo, NULL);*/ 410 gaim_conversation_set_account(convo, NULL);*/
411 gaim_chat_write(GAIM_CHAT(convo), args[1], args[2], GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 411 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], args[2], GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
412 } 412 }
413 } 413 }
414 414
415 void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args) 415 void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args)
416 { 416 {
421 421
422 convo = gaim_find_conversation_with_account(args[1], irc->account); 422 convo = gaim_find_conversation_with_account(args[1], irc->account);
423 if (!convo) 423 if (!convo)
424 return; 424 return;
425 425
426 gaim_chat_write(GAIM_CHAT(convo), "", args[2], GAIM_MESSAGE_SYSTEM, time(NULL)); 426 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", args[2], GAIM_MESSAGE_SYSTEM, time(NULL));
427 } 427 }
428 428
429 void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args) 429 void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args)
430 { 430 {
431 GaimConnection *gc = gaim_account_get_connection(irc->account); 431 GaimConnection *gc = gaim_account_get_connection(irc->account);
524 g_free(nick); 524 g_free(nick);
525 return; 525 return;
526 } 526 }
527 527
528 userhost = irc_mask_userhost(from); 528 userhost = irc_mask_userhost(from);
529 gaim_chat_add_user(GAIM_CHAT(convo), nick, userhost); 529 gaim_conv_chat_add_user(GAIM_CONV_CHAT(convo), nick, userhost);
530 g_free(userhost); 530 g_free(userhost);
531 g_free(nick); 531 g_free(nick);
532 } 532 }
533 533
534 void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args) 534 void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args)
548 return; 548 return;
549 } 549 }
550 550
551 if (!gaim_utf8_strcasecmp(gaim_connection_get_display_name(gc), args[1])) { 551 if (!gaim_utf8_strcasecmp(gaim_connection_get_display_name(gc), args[1])) {
552 buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]); 552 buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]);
553 gaim_chat_write(GAIM_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM, time(NULL)); 553 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM, time(NULL));
554 g_free(buf); 554 g_free(buf);
555 /*g_slist_remove(irc->gc->buddy_chats, convo); 555 /*g_slist_remove(irc->gc->buddy_chats, convo);
556 gaim_conversation_set_account(convo, NULL);*/ 556 gaim_conversation_set_account(convo, NULL);*/
557 /*g_list_free(gaim_chat_get_users(GAIM_CHAT(convo))); 557 /*g_list_free(gaim_conv_chat_get_users(GAIM_CONV_CHAT(convo)));
558 gaim_chat_set_users(GAIM_CHAT(convo), NULL);*/ 558 gaim_conv_chat_set_users(GAIM_CONV_CHAT(convo), NULL);*/
559 } else { 559 } else {
560 buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]); 560 buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]);
561 gaim_chat_remove_user(GAIM_CHAT(convo), args[1], buf); 561 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), args[1], buf);
562 g_free(buf); 562 g_free(buf);
563 } 563 }
564 564
565 g_free(nick); 565 g_free(nick);
566 return; 566 return;
577 gaim_debug(GAIM_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]); 577 gaim_debug(GAIM_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]);
578 g_free(nick); 578 g_free(nick);
579 return; 579 return;
580 } 580 }
581 buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], args[2] ? args[2] : "", nick); 581 buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], args[2] ? args[2] : "", nick);
582 gaim_chat_write(GAIM_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 582 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
583 g_free(buf); 583 g_free(buf);
584 } else { /* User */ 584 } else { /* User */
585 } 585 }
586 g_free(nick); 586 g_free(nick);
587 } 587 }
601 if (!gaim_utf8_strcasecmp(nick, gaim_connection_get_display_name(gc))) { 601 if (!gaim_utf8_strcasecmp(nick, gaim_connection_get_display_name(gc))) {
602 gaim_connection_set_display_name(gc, args[0]); 602 gaim_connection_set_display_name(gc, args[0]);
603 } 603 }
604 604
605 while (chats) { 605 while (chats) {
606 GaimChat *chat = GAIM_CHAT(chats->data); 606 GaimConvChat *chat = GAIM_CONV_CHAT(chats->data);
607 GList *users = gaim_chat_get_users(chat); 607 GList *users = gaim_conv_chat_get_users(chat);
608 608
609 while (users) { 609 while (users) {
610 char *user = users->data; 610 char *user = users->data;
611 611
612 if (!strcmp(nick, user)) { 612 if (!strcmp(nick, user)) {
613 gaim_chat_rename_user(chat, user, args[0]); 613 gaim_conv_chat_rename_user(chat, user, args[0]);
614 users = gaim_chat_get_users(chat); 614 users = gaim_conv_chat_get_users(chat);
615 break; 615 break;
616 } 616 }
617 users = users->next; 617 users = users->next;
618 } 618 }
619 chats = chats->next; 619 chats = chats->next;
678 } 678 }
679 679
680 nick = irc_mask_nick(from); 680 nick = irc_mask_nick(from);
681 if (!gaim_utf8_strcasecmp(nick, gaim_connection_get_display_name(gc))) { 681 if (!gaim_utf8_strcasecmp(nick, gaim_connection_get_display_name(gc))) {
682 msg = g_strdup_printf(_("You have parted the channel%s%s"), *args[1] ? ": " : "", args[1]); 682 msg = g_strdup_printf(_("You have parted the channel%s%s"), *args[1] ? ": " : "", args[1]);
683 gaim_chat_write(GAIM_CHAT(convo), args[0], msg, GAIM_MESSAGE_SYSTEM, time(NULL)); 683 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], msg, GAIM_MESSAGE_SYSTEM, time(NULL));
684 g_free(msg); 684 g_free(msg);
685 } else { 685 } else {
686 gaim_chat_remove_user(GAIM_CHAT(convo), nick, args[1]); 686 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), nick, args[1]);
687 } 687 }
688 g_free(nick); 688 g_free(nick);
689 } 689 }
690 690
691 void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args) 691 void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args)
724 724
725 convo = gaim_find_conversation_with_account(parts[0], irc->account); 725 convo = gaim_find_conversation_with_account(parts[0], irc->account);
726 g_strfreev(parts); 726 g_strfreev(parts);
727 if (convo) { 727 if (convo) {
728 if (gaim_conversation_get_type (convo) == GAIM_CONV_CHAT) 728 if (gaim_conversation_get_type (convo) == GAIM_CONV_CHAT)
729 gaim_chat_write(GAIM_CHAT(convo), "PONG", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 729 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "PONG", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
730 else 730 else
731 gaim_im_write(GAIM_IM(convo), "PONG", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 731 gaim_conv_im_write(GAIM_CONV_IM(convo), "PONG", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
732 } else { 732 } else {
733 gc = gaim_account_get_connection(irc->account); 733 gc = gaim_account_get_connection(irc->account);
734 if (!gc) { 734 if (!gc) {
735 g_free(msg); 735 g_free(msg);
736 return; 736 return;
771 } else if (notice) { 771 } else if (notice) {
772 serv_got_im(gc, nick, msg, 0, time(NULL)); 772 serv_got_im(gc, nick, msg, 0, time(NULL));
773 } else { 773 } else {
774 convo = gaim_find_conversation_with_account(args[0], irc->account); 774 convo = gaim_find_conversation_with_account(args[0], irc->account);
775 if (convo) 775 if (convo)
776 serv_got_chat_in(gc, gaim_chat_get_id(GAIM_CHAT(convo)), nick, 0, msg, time(NULL)); 776 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), nick, 0, msg, time(NULL));
777 else 777 else
778 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a PRIVMSG on %s, which does not exist\n", args[0]); 778 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a PRIVMSG on %s, which does not exist\n", args[0]);
779 } 779 }
780 g_free(msg); 780 g_free(msg);
781 g_free(nick); 781 g_free(nick);

mercurial