comparison libpurple/conversation.c @ 18115:871d9aa8e51c

Re-apply a good change from 1411afd7660760db59966c3a9f18e2adab8eb27e: Clarify some code so it doesn't look like people should modify the lists returned by purple_conv_chat_get_ignored() or purple_conv_chat_get_users().
author Richard Laager <rlaager@wiktel.com>
date Sat, 16 Jun 2007 19:08:51 +0000
parents 926ccb104da0
children 9b9e202eb449
comparison
equal deleted inserted replaced
18114:873ee0038752 18115:871d9aa8e51c
1267 /* Make sure the user isn't already ignored. */ 1267 /* Make sure the user isn't already ignored. */
1268 if (purple_conv_chat_is_user_ignored(chat, name)) 1268 if (purple_conv_chat_is_user_ignored(chat, name))
1269 return; 1269 return;
1270 1270
1271 purple_conv_chat_set_ignored(chat, 1271 purple_conv_chat_set_ignored(chat,
1272 g_list_append(purple_conv_chat_get_ignored(chat), g_strdup(name))); 1272 g_list_append(chat->ignored, g_strdup(name)));
1273 } 1273 }
1274 1274
1275 void 1275 void
1276 purple_conv_chat_unignore(PurpleConvChat *chat, const char *name) 1276 purple_conv_chat_unignore(PurpleConvChat *chat, const char *name)
1277 { 1277 {
1286 1286
1287 item = g_list_find(purple_conv_chat_get_ignored(chat), 1287 item = g_list_find(purple_conv_chat_get_ignored(chat),
1288 purple_conv_chat_get_ignored_user(chat, name)); 1288 purple_conv_chat_get_ignored_user(chat, name));
1289 1289
1290 purple_conv_chat_set_ignored(chat, 1290 purple_conv_chat_set_ignored(chat,
1291 g_list_remove_link(purple_conv_chat_get_ignored(chat), item)); 1291 g_list_remove_link(chat->ignored, item));
1292 1292
1293 g_free(item->data); 1293 g_free(item->data);
1294 g_list_free_1(item); 1294 g_list_free_1(item);
1295 } 1295 }
1296 1296
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 /* This seems dumb. Why should we set users thousands of times? */ 1566 /* This seems dumb. Why should we set users thousands of times? */
1567 purple_conv_chat_set_users(chat, 1567 purple_conv_chat_set_users(chat,
1568 g_list_prepend(purple_conv_chat_get_users(chat), cbuddy)); 1568 g_list_prepend(chat->in_room, cbuddy));
1569 1569
1570 cbuddies = g_list_prepend(cbuddies, cbuddy); 1570 cbuddies = g_list_prepend(cbuddies, cbuddy);
1571 1571
1572 if (!quiet && new_arrivals) { 1572 if (!quiet && new_arrivals) {
1573 char *escaped = g_markup_escape_text(alias, -1); 1573 char *escaped = g_markup_escape_text(alias, -1);
1632 g_return_if_fail(prpl_info != NULL); 1632 g_return_if_fail(prpl_info != NULL);
1633 1633
1634 flags = purple_conv_chat_user_get_flags(chat, old_user); 1634 flags = purple_conv_chat_user_get_flags(chat, old_user);
1635 cb = purple_conv_chat_cb_new(new_user, NULL, flags); 1635 cb = purple_conv_chat_cb_new(new_user, NULL, flags);
1636 purple_conv_chat_set_users(chat, 1636 purple_conv_chat_set_users(chat,
1637 g_list_prepend(purple_conv_chat_get_users(chat), cb)); 1637 g_list_prepend(chat->in_room, cb));
1638 1638
1639 if (!strcmp(chat->nick, purple_normalize(conv->account, old_user))) { 1639 if (!strcmp(chat->nick, purple_normalize(conv->account, old_user))) {
1640 const char *alias; 1640 const char *alias;
1641 1641
1642 /* Note this for later. */ 1642 /* Note this for later. */
1664 1664
1665 cb = purple_conv_chat_cb_find(chat, old_user); 1665 cb = purple_conv_chat_cb_find(chat, old_user);
1666 1666
1667 if (cb) { 1667 if (cb) {
1668 purple_conv_chat_set_users(chat, 1668 purple_conv_chat_set_users(chat,
1669 g_list_remove(purple_conv_chat_get_users(chat), cb)); 1669 g_list_remove(chat->in_room, cb));
1670 purple_conv_chat_cb_destroy(cb); 1670 purple_conv_chat_cb_destroy(cb);
1671 } 1671 }
1672 1672
1673 if (purple_conv_chat_is_user_ignored(chat, old_user)) { 1673 if (purple_conv_chat_is_user_ignored(chat, old_user)) {
1674 purple_conv_chat_unignore(chat, old_user); 1674 purple_conv_chat_unignore(chat, old_user);
1758 1758
1759 cb = purple_conv_chat_cb_find(chat, user); 1759 cb = purple_conv_chat_cb_find(chat, user);
1760 1760
1761 if (cb) { 1761 if (cb) {
1762 purple_conv_chat_set_users(chat, 1762 purple_conv_chat_set_users(chat,
1763 g_list_remove(purple_conv_chat_get_users(chat), cb)); 1763 g_list_remove(chat->in_room, cb));
1764 purple_conv_chat_cb_destroy(cb); 1764 purple_conv_chat_cb_destroy(cb);
1765 } 1765 }
1766 1766
1767 /* NOTE: Don't remove them from ignored in case they re-enter. */ 1767 /* NOTE: Don't remove them from ignored in case they re-enter. */
1768 1768
1807 void 1807 void
1808 purple_conv_chat_clear_users(PurpleConvChat *chat) 1808 purple_conv_chat_clear_users(PurpleConvChat *chat)
1809 { 1809 {
1810 PurpleConversation *conv; 1810 PurpleConversation *conv;
1811 PurpleConversationUiOps *ops; 1811 PurpleConversationUiOps *ops;
1812 GList *users, *names = NULL; 1812 GList *users;
1813 GList *l; 1813 GList *l;
1814 GList *names = NULL;
1814 1815
1815 g_return_if_fail(chat != NULL); 1816 g_return_if_fail(chat != NULL);
1816 1817
1817 conv = purple_conv_chat_get_conversation(chat); 1818 conv = purple_conv_chat_get_conversation(chat);
1818 ops = purple_conversation_get_ui_ops(conv); 1819 ops = purple_conversation_get_ui_ops(conv);
1819 users = purple_conv_chat_get_users(chat); 1820 users = chat->in_room;
1820 1821
1821 if (ops != NULL && ops->chat_remove_users != NULL) { 1822 if (ops != NULL && ops->chat_remove_users != NULL) {
1822 for (l = users; l; l = l->next) { 1823 for (l = users; l; l = l->next) {
1823 PurpleConvChatBuddy *cb = l->data; 1824 PurpleConvChatBuddy *cb = l->data;
1824 names = g_list_prepend(names, cb->name); 1825 names = g_list_prepend(names, cb->name);