libpurple/blist.c

changeset 17690
32b7b02dd752
parent 16856
3e42fed1dd43
child 17879
3e3f85138f1a
child 18178
d461ccafa1fb
equal deleted inserted replaced
17689:a93d038c9521 17690:32b7b02dd752
1772 1772
1773 g_return_if_fail(buddy != NULL); 1773 g_return_if_fail(buddy != NULL);
1774 1774
1775 node = (PurpleBlistNode *)buddy; 1775 node = (PurpleBlistNode *)buddy;
1776 cnode = node->parent; 1776 cnode = node->parent;
1777 gnode = cnode->parent; 1777 gnode = (cnode != NULL) ? cnode->parent : NULL;
1778 contact = (PurpleContact *)cnode; 1778 contact = (PurpleContact *)cnode;
1779 group = (PurpleGroup *)gnode; 1779 group = (PurpleGroup *)gnode;
1780 1780
1781 /* Remove the node from its parent */ 1781 /* Remove the node from its parent */
1782 if (node->prev) 1782 if (node->prev)
1783 node->prev->next = node->next; 1783 node->prev->next = node->next;
1784 if (node->next) 1784 if (node->next)
1785 node->next->prev = node->prev; 1785 node->next->prev = node->prev;
1786 if (cnode->child == node) 1786 if ((cnode != NULL) && (cnode->child == node))
1787 cnode->child = node->next; 1787 cnode->child = node->next;
1788 1788
1789 /* Adjust size counts */ 1789 /* Adjust size counts */
1790 if (PURPLE_BUDDY_IS_ONLINE(buddy)) { 1790 if (contact != NULL) {
1791 contact->online--; 1791 if (PURPLE_BUDDY_IS_ONLINE(buddy)) {
1792 if (contact->online == 0) 1792 contact->online--;
1793 group->online--; 1793 if (contact->online == 0)
1794 } 1794 group->online--;
1795 if (purple_account_is_connected(buddy->account)) { 1795 }
1796 contact->currentsize--; 1796 if (purple_account_is_connected(buddy->account)) {
1797 if (contact->currentsize == 0) 1797 contact->currentsize--;
1798 group->currentsize--; 1798 if (contact->currentsize == 0)
1799 } 1799 group->currentsize--;
1800 contact->totalsize--; 1800 }
1801 contact->totalsize--;
1802
1803 /* Re-sort the contact */
1804 if (cnode->child && contact->priority == buddy) {
1805 purple_contact_invalidate_priority_buddy(contact);
1806 if (ops && ops->update)
1807 ops->update(purplebuddylist, cnode);
1808 }
1809 }
1801 1810
1802 purple_blist_schedule_save(); 1811 purple_blist_schedule_save();
1803
1804 /* Re-sort the contact */
1805 if (cnode->child && contact->priority == buddy) {
1806 purple_contact_invalidate_priority_buddy(contact);
1807 if (ops && ops->update)
1808 ops->update(purplebuddylist, cnode);
1809 }
1810 1812
1811 /* Remove this buddy from the buddies hash table */ 1813 /* Remove this buddy from the buddies hash table */
1812 hb.name = g_strdup(purple_normalize(buddy->account, buddy->name)); 1814 hb.name = g_strdup(purple_normalize(buddy->account, buddy->name));
1813 hb.account = buddy->account; 1815 hb.account = buddy->account;
1814 hb.group = ((PurpleBlistNode*)buddy)->parent->parent; 1816 hb.group = gnode;
1815 g_hash_table_remove(purplebuddylist->buddies, &hb); 1817 g_hash_table_remove(purplebuddylist->buddies, &hb);
1816 g_free(hb.name); 1818 g_free(hb.name);
1817 1819
1818 /* Update the UI */ 1820 /* Update the UI */
1819 if (ops && ops->remove) 1821 if (ops && ops->remove)
1839 * get freed while the timeout is pending and this line can 1841 * get freed while the timeout is pending and this line can
1840 * be removed. */ 1842 * be removed. */
1841 while (g_source_remove_by_user_data((gpointer *)buddy)); 1843 while (g_source_remove_by_user_data((gpointer *)buddy));
1842 1844
1843 /* If the contact is empty then remove it */ 1845 /* If the contact is empty then remove it */
1844 if (!cnode->child) 1846 if ((contact != NULL) && !cnode->child)
1845 purple_blist_remove_contact(contact); 1847 purple_blist_remove_contact(contact);
1846 } 1848 }
1847 1849
1848 void purple_blist_remove_chat(PurpleChat *chat) 1850 void purple_blist_remove_chat(PurpleChat *chat)
1849 { 1851 {

mercurial