comparison libpurple/conversation.c @ 18305:ffd706ec0220

Set and use convchatbuddy->buddy. This change also makes sure we don't leak everytime any user in a chatroom changes nick. Thanks to stingray for noticing this. Fixes #1818.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 27 Jun 2007 09:15:57 +0000
parents 9b9e202eb449
children f4d05584369e 636679fb98ad
comparison
equal deleted inserted replaced
18304:38ecbc8a70bd 18305:ffd706ec0220
1561 quiet = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_conversations_get_handle(), 1561 quiet = GPOINTER_TO_INT(purple_signal_emit_return_1(purple_conversations_get_handle(),
1562 "chat-buddy-joining", conv, user, flag)) | 1562 "chat-buddy-joining", conv, user, flag)) |
1563 purple_conv_chat_is_user_ignored(chat, user); 1563 purple_conv_chat_is_user_ignored(chat, user);
1564 1564
1565 cbuddy = purple_conv_chat_cb_new(user, alias, flag); 1565 cbuddy = purple_conv_chat_cb_new(user, alias, flag);
1566 cbuddy->buddy = purple_find_buddy(conv->account, user) != NULL;
1566 /* This seems dumb. Why should we set users thousands of times? */ 1567 /* This seems dumb. Why should we set users thousands of times? */
1567 purple_conv_chat_set_users(chat, 1568 purple_conv_chat_set_users(chat,
1568 g_list_prepend(chat->in_room, cbuddy)); 1569 g_list_prepend(chat->in_room, cbuddy));
1569 1570
1570 cbuddies = g_list_prepend(cbuddies, cbuddy); 1571 cbuddies = g_list_prepend(cbuddies, cbuddy);
1628 1629
1629 gc = purple_conversation_get_gc(conv); 1630 gc = purple_conversation_get_gc(conv);
1630 g_return_if_fail(gc != NULL); 1631 g_return_if_fail(gc != NULL);
1631 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); 1632 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
1632 g_return_if_fail(prpl_info != NULL); 1633 g_return_if_fail(prpl_info != NULL);
1633
1634 flags = purple_conv_chat_user_get_flags(chat, old_user);
1635 cb = purple_conv_chat_cb_new(new_user, NULL, flags);
1636 purple_conv_chat_set_users(chat,
1637 g_list_prepend(chat->in_room, cb));
1638 1634
1639 if (!strcmp(chat->nick, purple_normalize(conv->account, old_user))) { 1635 if (!strcmp(chat->nick, purple_normalize(conv->account, old_user))) {
1640 const char *alias; 1636 const char *alias;
1641 1637
1642 /* Note this for later. */ 1638 /* Note this for later. */
1657 PurpleBuddy *buddy; 1653 PurpleBuddy *buddy;
1658 if ((buddy = purple_find_buddy(gc->account, new_user)) != NULL) 1654 if ((buddy = purple_find_buddy(gc->account, new_user)) != NULL)
1659 new_alias = purple_buddy_get_contact_alias(buddy); 1655 new_alias = purple_buddy_get_contact_alias(buddy);
1660 } 1656 }
1661 1657
1658 flags = purple_conv_chat_user_get_flags(chat, old_user);
1659 cb = purple_conv_chat_cb_new(new_user, new_alias, flags);
1660 cb->buddy = purple_find_buddy(conv->account, new_user) != NULL;
1661 purple_conv_chat_set_users(chat,
1662 g_list_prepend(chat->in_room, cb));
1663
1662 if (ops != NULL && ops->chat_rename_user != NULL) 1664 if (ops != NULL && ops->chat_rename_user != NULL)
1663 ops->chat_rename_user(conv, old_user, new_user, new_alias); 1665 ops->chat_rename_user(conv, old_user, new_user, new_alias);
1664 1666
1665 cb = purple_conv_chat_cb_find(chat, old_user); 1667 cb = purple_conv_chat_cb_find(chat, old_user);
1666 1668
1947 { 1949 {
1948 g_return_val_if_fail(chat != NULL, TRUE); 1950 g_return_val_if_fail(chat != NULL, TRUE);
1949 1951
1950 return chat->left; 1952 return chat->left;
1951 } 1953 }
1954
1952 PurpleConvChatBuddy * 1955 PurpleConvChatBuddy *
1953 purple_conv_chat_cb_new(const char *name, const char *alias, PurpleConvChatBuddyFlags flags) 1956 purple_conv_chat_cb_new(const char *name, const char *alias, PurpleConvChatBuddyFlags flags)
1954 { 1957 {
1955 PurpleConvChatBuddy *cb; 1958 PurpleConvChatBuddy *cb;
1956 1959