comparison libpurple/protocols/irc/msgs.c @ 15456:79f25bbe69bf

This makes IRC /names handling generally more robust, as well as properly dealing with the case where the user runs /quote names #chan and we don't know about it. I thought things were already handled in this fashion, but obviously they were not.
author Ethan Blanton <elb@pidgin.im>
date Sun, 28 Jan 2007 21:48:58 +0000
parents 8c81db398f56
children 32c366eeeb99
comparison
equal deleted inserted replaced
15454:c68f2808f703 15456:79f25bbe69bf
440 { 440 {
441 char *names, *cur, *end, *tmp, *msg; 441 char *names, *cur, *end, *tmp, *msg;
442 GaimConversation *convo; 442 GaimConversation *convo;
443 443
444 if (!strcmp(name, "366")) { 444 if (!strcmp(name, "366")) {
445 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, irc->nameconv ? irc->nameconv : args[1], irc->account); 445 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, args[1], irc->account);
446 if (!convo) { 446 if (!convo) {
447 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]); 447 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]);
448 g_string_free(irc->names, TRUE); 448 g_string_free(irc->names, TRUE);
449 irc->names = NULL; 449 irc->names = NULL;
450 g_free(irc->nameconv);
451 irc->nameconv = NULL;
452 return; 450 return;
453 } 451 }
454 452
455 names = cur = g_string_free(irc->names, FALSE); 453 names = cur = g_string_free(irc->names, FALSE);
456 irc->names = NULL; 454 irc->names = NULL;
457 if (irc->nameconv) { 455 if (gaim_conversation_get_data(convo, IRC_NAMES_FLAG)) {
458 msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : ""); 456 msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : "");
459 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT) 457 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT)
460 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 458 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
461 else 459 else
462 gaim_conv_im_write(GAIM_CONV_IM(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); 460 gaim_conv_im_write(GAIM_CONV_IM(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
463 g_free(msg); 461 g_free(msg);
464 g_free(irc->nameconv);
465 irc->nameconv = NULL;
466 } else { 462 } else {
467 GList *users = NULL; 463 GList *users = NULL;
468 GList *flags = NULL; 464 GList *flags = NULL;
469 465
470 while (*cur) { 466 while (*cur) {
502 g_free(l->data); 498 g_free(l->data);
503 499
504 g_list_free(users); 500 g_list_free(users);
505 g_list_free(flags); 501 g_list_free(flags);
506 } 502 }
503
504 gaim_conversation_set_data(convo, IRC_NAMES_FLAG,
505 GINT_TO_POINTER(TRUE));
507 } 506 }
508 g_free(names); 507 g_free(names);
509 } else { 508 } else {
510 if (!irc->names) 509 if (!irc->names)
511 irc->names = g_string_new(""); 510 irc->names = g_string_new("");
721 serv_got_joined_chat(gc, id++, args[0]); 720 serv_got_joined_chat(gc, id++, args[0]);
722 g_free(nick); 721 g_free(nick);
723 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, 722 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
724 args[0], 723 args[0],
725 irc->account); 724 irc->account);
725
726 if (convo == NULL) { 726 if (convo == NULL) {
727 gaim_debug_error("irc", "tried to join %s but couldn't\n", args[0]); 727 gaim_debug_error("irc", "tried to join %s but couldn't\n", args[0]);
728 return; 728 return;
729 } 729 }
730 gaim_conversation_set_data(convo, IRC_NAMES_FLAG,
731 GINT_TO_POINTER(FALSE));
730 gaim_conversation_present(convo); 732 gaim_conversation_present(convo);
731 return; 733 return;
732 } 734 }
733 735
734 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0], irc->account); 736 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0], irc->account);