Mercurial > pidgin
comparison libpurple/blist.c @ 19114:6de2e9ba0930
merge of '2970edca111b3535ae0703e3c866ad1c3b87df94'
and 'a2b508e8680ac3f20965226a5dd83f7e2a3b15bb'
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Sun, 24 Jun 2007 02:56:09 +0000 |
parents | eec2b191ef71 |
children | 5ed02bbcf1ff |
comparison
equal
deleted
inserted
replaced
19102:7f26e5b98b15 | 19114:6de2e9ba0930 |
---|---|
33 #include "signals.h" | 33 #include "signals.h" |
34 #include "util.h" | 34 #include "util.h" |
35 #include "value.h" | 35 #include "value.h" |
36 #include "xmlnode.h" | 36 #include "xmlnode.h" |
37 | 37 |
38 #define PATHSIZE 1024 | |
39 | |
40 static PurpleBlistUiOps *blist_ui_ops = NULL; | 38 static PurpleBlistUiOps *blist_ui_ops = NULL; |
41 | 39 |
42 static PurpleBuddyList *purplebuddylist = NULL; | 40 static PurpleBuddyList *purplebuddylist = NULL; |
43 static guint save_timer = 0; | 41 static guint save_timer = 0; |
44 static gboolean blist_loaded = FALSE; | 42 static gboolean blist_loaded = FALSE; |
302 static xmlnode * | 300 static xmlnode * |
303 blist_to_xmlnode() | 301 blist_to_xmlnode() |
304 { | 302 { |
305 xmlnode *node, *child, *grandchild; | 303 xmlnode *node, *child, *grandchild; |
306 PurpleBlistNode *gnode; | 304 PurpleBlistNode *gnode; |
307 const GList *cur; | 305 GList *cur; |
308 | 306 |
309 node = xmlnode_new("purple"); | 307 node = xmlnode_new("purple"); |
310 xmlnode_set_attrib(node, "version", "1.0"); | 308 xmlnode_set_attrib(node, "version", "1.0"); |
311 | 309 |
312 /* Write groups */ | 310 /* Write groups */ |
1772 | 1770 |
1773 g_return_if_fail(buddy != NULL); | 1771 g_return_if_fail(buddy != NULL); |
1774 | 1772 |
1775 node = (PurpleBlistNode *)buddy; | 1773 node = (PurpleBlistNode *)buddy; |
1776 cnode = node->parent; | 1774 cnode = node->parent; |
1777 gnode = cnode->parent; | 1775 gnode = (cnode != NULL) ? cnode->parent : NULL; |
1778 contact = (PurpleContact *)cnode; | 1776 contact = (PurpleContact *)cnode; |
1779 group = (PurpleGroup *)gnode; | 1777 group = (PurpleGroup *)gnode; |
1780 | 1778 |
1781 /* Remove the node from its parent */ | 1779 /* Remove the node from its parent */ |
1782 if (node->prev) | 1780 if (node->prev) |
1783 node->prev->next = node->next; | 1781 node->prev->next = node->next; |
1784 if (node->next) | 1782 if (node->next) |
1785 node->next->prev = node->prev; | 1783 node->next->prev = node->prev; |
1786 if (cnode->child == node) | 1784 if ((cnode != NULL) && (cnode->child == node)) |
1787 cnode->child = node->next; | 1785 cnode->child = node->next; |
1788 | 1786 |
1789 /* Adjust size counts */ | 1787 /* Adjust size counts */ |
1790 if (PURPLE_BUDDY_IS_ONLINE(buddy)) { | 1788 if (contact != NULL) { |
1791 contact->online--; | 1789 if (PURPLE_BUDDY_IS_ONLINE(buddy)) { |
1792 if (contact->online == 0) | 1790 contact->online--; |
1793 group->online--; | 1791 if (contact->online == 0) |
1794 } | 1792 group->online--; |
1795 if (purple_account_is_connected(buddy->account)) { | 1793 } |
1796 contact->currentsize--; | 1794 if (purple_account_is_connected(buddy->account)) { |
1797 if (contact->currentsize == 0) | 1795 contact->currentsize--; |
1798 group->currentsize--; | 1796 if (contact->currentsize == 0) |
1799 } | 1797 group->currentsize--; |
1800 contact->totalsize--; | 1798 } |
1799 contact->totalsize--; | |
1800 | |
1801 /* Re-sort the contact */ | |
1802 if (cnode->child && contact->priority == buddy) { | |
1803 purple_contact_invalidate_priority_buddy(contact); | |
1804 if (ops && ops->update) | |
1805 ops->update(purplebuddylist, cnode); | |
1806 } | |
1807 } | |
1801 | 1808 |
1802 purple_blist_schedule_save(); | 1809 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 | 1810 |
1811 /* Remove this buddy from the buddies hash table */ | 1811 /* Remove this buddy from the buddies hash table */ |
1812 hb.name = g_strdup(purple_normalize(buddy->account, buddy->name)); | 1812 hb.name = g_strdup(purple_normalize(buddy->account, buddy->name)); |
1813 hb.account = buddy->account; | 1813 hb.account = buddy->account; |
1814 hb.group = ((PurpleBlistNode*)buddy)->parent->parent; | 1814 hb.group = gnode; |
1815 g_hash_table_remove(purplebuddylist->buddies, &hb); | 1815 g_hash_table_remove(purplebuddylist->buddies, &hb); |
1816 g_free(hb.name); | 1816 g_free(hb.name); |
1817 | 1817 |
1818 /* Update the UI */ | 1818 /* Update the UI */ |
1819 if (ops && ops->remove) | 1819 if (ops && ops->remove) |
1839 * get freed while the timeout is pending and this line can | 1839 * get freed while the timeout is pending and this line can |
1840 * be removed. */ | 1840 * be removed. */ |
1841 while (g_source_remove_by_user_data((gpointer *)buddy)); | 1841 while (g_source_remove_by_user_data((gpointer *)buddy)); |
1842 | 1842 |
1843 /* If the contact is empty then remove it */ | 1843 /* If the contact is empty then remove it */ |
1844 if (!cnode->child) | 1844 if ((contact != NULL) && !cnode->child) |
1845 purple_blist_remove_contact(contact); | 1845 purple_blist_remove_contact(contact); |
1846 } | 1846 } |
1847 | 1847 |
1848 void purple_blist_remove_chat(PurpleChat *chat) | 1848 void purple_blist_remove_chat(PurpleChat *chat) |
1849 { | 1849 { |
1891 | 1891 |
1892 void purple_blist_remove_group(PurpleGroup *group) | 1892 void purple_blist_remove_group(PurpleGroup *group) |
1893 { | 1893 { |
1894 PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); | 1894 PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); |
1895 PurpleBlistNode *node; | 1895 PurpleBlistNode *node; |
1896 const GList *l; | 1896 GList *l; |
1897 | 1897 |
1898 g_return_if_fail(group != NULL); | 1898 g_return_if_fail(group != NULL); |
1899 | 1899 |
1900 node = (PurpleBlistNode *)group; | 1900 node = (PurpleBlistNode *)group; |
1901 | 1901 |