libpurple/protocols/irc/msgs.c

changeset 40765
a5381c20e802
parent 40717
beb4c413afe8
child 40885
87f6241da196
equal deleted inserted replaced
40763:502c78a7f11f 40765:a5381c20e802
192 return; 192 return;
193 193
194 undirected: 194 undirected:
195 /* This, too, should be escaped somehow (smarter) */ 195 /* This, too, should be escaped somehow (smarter) */
196 clean = g_utf8_make_valid(args[0], -1); 196 clean = g_utf8_make_valid(args[0], -1);
197 purple_debug(PURPLE_DEBUG_INFO, "irc", "Unrecognized message: %s\n", clean); 197 purple_debug_info("irc", "Unrecognized message: %s", clean);
198 g_free(clean); 198 g_free(clean);
199 } 199 }
200 200
201 void irc_msg_features(struct irc_conn *irc, const char *name, const char *from, char **args) 201 void irc_msg_features(struct irc_conn *irc, const char *name, const char *from, char **args)
202 { 202 {
339 } 339 }
340 340
341 void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args) 341 void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args)
342 { 342 {
343 if (!irc->whois.nick) { 343 if (!irc->whois.nick) {
344 purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected %s reply for %s\n", purple_strequal(name, "314") ? "WHOWAS" : "WHOIS" 344 purple_debug_warning("irc", "Unexpected %s reply for %s",
345 , args[1]); 345 purple_strequal(name, "314") ? "WHOWAS" : "WHOIS", args[1]);
346 return; 346 return;
347 } 347 }
348 348
349 if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) { 349 if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) {
350 purple_debug(PURPLE_DEBUG_WARNING, "irc", "Got %s reply for %s while waiting for %s\n", purple_strequal(name, "314") ? "WHOWAS" : "WHOIS" 350 purple_debug_warning("irc", "Got %s reply for %s while waiting for %s",
351 , args[1], irc->whois.nick); 351 purple_strequal(name, "314") ? "WHOWAS" : "WHOIS", args[1], irc->whois.nick);
352 return; 352 return;
353 } 353 }
354 354
355 if (purple_strequal(name, "301")) { 355 if (purple_strequal(name, "301")) {
356 irc->whois.away = g_strdup(args[2]); 356 irc->whois.away = g_strdup(args[2]);
374 irc->whois.channels = g_string_append(irc->whois.channels, args[2]); 374 irc->whois.channels = g_string_append(irc->whois.channels, args[2]);
375 } 375 }
376 } else if (purple_strequal(name, "320")) { 376 } else if (purple_strequal(name, "320")) {
377 irc->whois.identified = 1; 377 irc->whois.identified = 1;
378 } else if (purple_strequal(name, "330")) { 378 } else if (purple_strequal(name, "330")) {
379 purple_debug(PURPLE_DEBUG_INFO, "irc", "330 %s: 1=[%s] 2=[%s] 3=[%s]", 379 purple_debug_info("irc", "330 %s: 1=[%s] 2=[%s] 3=[%s]",
380 name, args[1], args[2], args[3]); 380 name, args[1], args[2], args[3]);
381 if (purple_strequal(args[3], "is logged in as")) 381 if (purple_strequal(args[3], "is logged in as"))
382 irc->whois.login = g_strdup(args[2]); 382 irc->whois.login = g_strdup(args[2]);
383 } 383 }
384 } 384 }
385 385
388 PurpleConnection *gc; 388 PurpleConnection *gc;
389 char *tmp, *tmp2; 389 char *tmp, *tmp2;
390 PurpleNotifyUserInfo *user_info; 390 PurpleNotifyUserInfo *user_info;
391 391
392 if (!irc->whois.nick) { 392 if (!irc->whois.nick) {
393 purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected End of %s for %s\n", purple_strequal(name, "369") ? "WHOWAS" : "WHOIS" 393 purple_debug_warning("irc", "Unexpected End of %s for %s",
394 , args[1]); 394 purple_strequal(name, "369") ? "WHOWAS" : "WHOIS", args[1]);
395 return; 395 return;
396 } 396 }
397 if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) { 397 if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) {
398 purple_debug(PURPLE_DEBUG_WARNING, "irc", "Received end of %s for %s, expecting %s\n", purple_strequal(name, "369") ? "WHOWAS" : "WHOIS" 398 purple_debug_warning("irc", "Received end of %s for %s, expecting %s",
399 , args[1], irc->whois.nick); 399 purple_strequal(name, "369") ? "WHOWAS" : "WHOIS", args[1], irc->whois.nick);
400 return; 400 return;
401 } 401 }
402 402
403 user_info = purple_notify_user_info_new(); 403 user_info = purple_notify_user_info_new();
404 404
472 472
473 PurpleChatUserFlags flags; 473 PurpleChatUserFlags flags;
474 474
475 chat = purple_conversations_find_chat_with_account(args[1], irc->account); 475 chat = purple_conversations_find_chat_with_account(args[1], irc->account);
476 if (!chat) { 476 if (!chat) {
477 purple_debug(PURPLE_DEBUG_ERROR, "irc","Got a WHO response for %s, which doesn't exist\n", args[1]); 477 purple_debug_error("irc", "Got a WHO response for %s, which doesn't exist", args[1]);
478 return; 478 return;
479 } 479 }
480 480
481 cb = purple_chat_conversation_find_user(chat, args[5]); 481 cb = purple_chat_conversation_find_user(chat, args[5]);
482 if (!cb) { 482 if (!cb) {
483 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a WHO response for %s who isn't a buddy.\n", args[5]); 483 purple_debug_error("irc", "Got a WHO response for %s who isn't a buddy.", args[5]);
484 return; 484 return;
485 } 485 }
486 486
487 userhost = g_strdup_printf("%s@%s", args[2], args[3]); 487 userhost = g_strdup_printf("%s@%s", args[2], args[3]);
488 488
562 topic = irc_mirc2txt (args[2]); 562 topic = irc_mirc2txt (args[2]);
563 } 563 }
564 564
565 chat = purple_conversations_find_chat_with_account(chan, irc->account); 565 chat = purple_conversations_find_chat_with_account(chan, irc->account);
566 if (!chat) { 566 if (!chat) {
567 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan); 567 purple_debug_error("irc", "Got a topic for %s, which doesn't exist", chan);
568 g_free(topic); 568 g_free(topic);
569 return; 569 return;
570 } 570 }
571 571
572 /* If this is an interactive update, print it out */ 572 /* If this is an interactive update, print it out */
610 gint64 mtime; 610 gint64 mtime;
611 char *msg, *timestamp, *datestamp; 611 char *msg, *timestamp, *datestamp;
612 612
613 chat = purple_conversations_find_chat_with_account(args[1], irc->account); 613 chat = purple_conversations_find_chat_with_account(args[1], irc->account);
614 if (!chat) { 614 if (!chat) {
615 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got topic info for %s, which doesn't exist\n", args[1]); 615 purple_debug_error("irc", "Got topic info for %s, which doesn't exist", args[1]);
616 return; 616 return;
617 } 617 }
618 618
619 mtime = g_ascii_strtoll(args[3], NULL, 10); 619 mtime = g_ascii_strtoll(args[3], NULL, 10);
620 if(mtime == 0 || mtime == G_MININT64 || mtime == G_MAXINT64) { 620 if(mtime == 0 || mtime == G_MININT64 || mtime == G_MAXINT64) {
621 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got apparently nonsensical topic timestamp %s\n", args[3]); 621 purple_debug_error("irc", "Got apparently nonsensical topic timestamp %s", args[3]);
622 return; 622 return;
623 } 623 }
624 624
625 dt = g_date_time_new_from_unix_utc(mtime); 625 dt = g_date_time_new_from_unix_utc(mtime);
626 if(dt == NULL) { 626 if(dt == NULL) {
627 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Failed to turn %" G_GINT64_FORMAT " into a GDateTime\n", mtime); 627 purple_debug_error("irc", "Failed to turn %" G_GINT64_FORMAT " into a GDateTime", mtime);
628 return; 628 return;
629 } 629 }
630 630
631 local = g_date_time_to_local(dt); 631 local = g_date_time_to_local(dt);
632 g_date_time_unref(dt); 632 g_date_time_unref(dt);
662 PurpleConversation *convo; 662 PurpleConversation *convo;
663 663
664 if (purple_strequal(name, "366")) { 664 if (purple_strequal(name, "366")) {
665 convo = purple_conversations_find_with_account(args[1], irc->account); 665 convo = purple_conversations_find_with_account(args[1], irc->account);
666 if (!convo) { 666 if (!convo) {
667 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]); 667 purple_debug_error("irc", "Got a NAMES list for %s, which doesn't exist", args[1]);
668 g_string_free(irc->names, TRUE); 668 g_string_free(irc->names, TRUE);
669 irc->names = NULL; 669 irc->names = NULL;
670 return; 670 return;
671 } 671 }
672 672
837 837
838 void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args) 838 void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args)
839 { 839 {
840 PurpleChatConversation *chat = purple_conversations_find_chat_with_account(args[1], irc->account); 840 PurpleChatConversation *chat = purple_conversations_find_chat_with_account(args[1], irc->account);
841 841
842 purple_debug(PURPLE_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]); 842 purple_debug_info("irc", "We're apparently not in %s, but tried to use it", args[1]);
843 if (chat) { 843 if (chat) {
844 /*g_slist_remove(irc->gc->buddy_chats, chat); 844 /*g_slist_remove(irc->gc->buddy_chats, chat);
845 purple_conversation_set_account(chat, NULL);*/ 845 purple_conversation_set_account(chat, NULL);*/
846 purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), 846 purple_conversation_write_system_message(PURPLE_CONVERSATION(chat),
847 args[2], PURPLE_MESSAGE_NO_LOG); 847 args[2], PURPLE_MESSAGE_NO_LOG);
967 return; 967 return;
968 } 968 }
969 969
970 chat = purple_conversations_find_chat_with_account(args[0], irc->account); 970 chat = purple_conversations_find_chat_with_account(args[0], irc->account);
971 if (chat == NULL) { 971 if (chat == NULL) {
972 purple_debug(PURPLE_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]); 972 purple_debug_error("irc", "JOIN for %s failed", args[0]);
973 g_free(nick); 973 g_free(nick);
974 return; 974 return;
975 } 975 }
976 976
977 userhost = irc_mask_userhost(from); 977 userhost = irc_mask_userhost(from);
1001 g_return_if_fail(gc); 1001 g_return_if_fail(gc);
1002 1002
1003 nick = irc_mask_nick(from); 1003 nick = irc_mask_nick(from);
1004 1004
1005 if (!chat) { 1005 if (!chat) {
1006 purple_debug(PURPLE_DEBUG_ERROR, "irc", "Received a KICK for unknown channel %s\n", args[0]); 1006 purple_debug_error("irc", "Received a KICK for unknown channel %s", args[0]);
1007 g_free(nick); 1007 g_free(nick);
1008 return; 1008 return;
1009 } 1009 }
1010 1010
1011 if (!purple_utf8_strcasecmp(purple_connection_get_display_name(gc), args[1])) { 1011 if (!purple_utf8_strcasecmp(purple_connection_get_display_name(gc), args[1])) {
1029 1029
1030 if (*args[0] == '#' || *args[0] == '&') { /* Channel */ 1030 if (*args[0] == '#' || *args[0] == '&') { /* Channel */
1031 char *escaped; 1031 char *escaped;
1032 chat = purple_conversations_find_chat_with_account(args[0], irc->account); 1032 chat = purple_conversations_find_chat_with_account(args[0], irc->account);
1033 if (!chat) { 1033 if (!chat) {
1034 purple_debug(PURPLE_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]); 1034 purple_debug_error("irc", "MODE received for %s, which we are not in", args[0]);
1035 g_free(nick); 1035 g_free(nick);
1036 return; 1036 return;
1037 } 1037 }
1038 escaped = (args[2] != NULL) ? g_markup_escape_text(args[2], -1) : NULL; 1038 escaped = (args[2] != NULL) ? g_markup_escape_text(args[2], -1) : NULL;
1039 buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick); 1039 buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick);
1210 * that I can see. This catches that. */ 1210 * that I can see. This catches that. */
1211 channel = (args[0][0] == ':') ? &args[0][1] : args[0]; 1211 channel = (args[0][0] == ':') ? &args[0][1] : args[0];
1212 1212
1213 chat = purple_conversations_find_chat_with_account(channel, irc->account); 1213 chat = purple_conversations_find_chat_with_account(channel, irc->account);
1214 if (!chat) { 1214 if (!chat) {
1215 purple_debug(PURPLE_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", channel); 1215 purple_debug_info("irc", "Got a PART on %s, which doesn't exist -- probably closed", channel);
1216 return; 1216 return;
1217 } 1217 }
1218 1218
1219 nick = irc_mask_nick(from); 1219 nick = irc_mask_nick(from);
1220 if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { 1220 if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) {

mercurial