im.pidgin.pidgin: a6e5b9db3ef85c7185709be9f5d3ce132813d995
sadrul at pidgin.im
sadrul at pidgin.im
Tue Jan 22 09:11:19 EST 2008
-----------------------------------------------------------------
Revision: a6e5b9db3ef85c7185709be9f5d3ce132813d995
Ancestor: cfe7d41cc3f84809ec35f2962b485dbaac4fd285
Author: sadrul at pidgin.im
Date: 2008-01-21T19:43:55
Branch: im.pidgin.pidgin
Modified files:
ChangeLog.API finch/gntblist.c libpurple/blist.c
libpurple/blist.h
ChangeLog:
Add some accessor functions for PurpleBlistNode.
-------------- next part --------------
============================================================
--- ChangeLog.API a5a3c86dbafbd51b09a61561a351b55dcb6b0614
+++ ChangeLog.API 3979790a0e6fc294dde883814733c5f1b733af7f
@@ -30,6 +30,10 @@ version 2.4.0 (??/??/????):
* purple_attention_type_get_outgoing_desc
* purple_attention_type_get_icon_name
* purple_attention_type_get_unlocalized_name
+ * Add some PurpleBuddyListNode accessor functions:
+ * purple_blist_node_get_parent
+ * purple_blist_node_get_first_child
+ * purple_blist_node_get_sibling_next
Pidgin:
Added:
============================================================
--- finch/gntblist.c 2e76b660a03c856b059db27915a0c39241c0e1aa
+++ finch/gntblist.c 5e23323a36973094dd88b6bfad4a26f1ea16d136
@@ -220,7 +220,8 @@ is_contact_online(PurpleContact *contact
is_contact_online(PurpleContact *contact)
{
PurpleBlistNode *node;
- for (node = ((PurpleBlistNode*)contact)->child; node; node = node->next) {
+ for (node = purple_blist_node_get_first_child(((PurpleBlistNode*)contact)); node;
+ node = purple_blist_node_get_sibling_next(node)) {
if (PURPLE_BUDDY_IS_ONLINE((PurpleBuddy*)node))
return TRUE;
}
@@ -231,7 +232,8 @@ is_group_online(PurpleGroup *group)
is_group_online(PurpleGroup *group)
{
PurpleBlistNode *node;
- for (node = ((PurpleBlistNode*)group)->child; node; node = node->next) {
+ for (node = purple_blist_node_get_first_child(((PurpleBlistNode*)group)); node;
+ node = purple_blist_node_get_sibling_next(node)) {
if (PURPLE_BLIST_NODE_IS_CHAT(node) &&
purple_account_is_connected(((PurpleChat *)node)->account))
return TRUE;
@@ -281,21 +283,21 @@ node_remove(PurpleBuddyList *list, Purpl
ggblist->tagged = g_list_remove(ggblist->tagged, node);
if (PURPLE_BLIST_NODE_IS_BUDDY(node)) {
- PurpleContact *contact = (PurpleContact*)node->parent;
+ PurpleContact *contact = (PurpleContact*)purple_blist_node_get_parent(node);
if ((!purple_prefs_get_bool(PREF_ROOT "/showoffline") && !is_contact_online(contact)) ||
contact->currentsize < 1)
node_remove(list, (PurpleBlistNode*)contact);
else
node_update(list, (PurpleBlistNode*)contact);
} else if (!PURPLE_BLIST_NODE_IS_GROUP(node)) {
- PurpleGroup *group = (PurpleGroup*)node->parent;
+ PurpleGroup *group = (PurpleGroup*)purple_blist_node_get_parent(node);
if ((group->currentsize < 1 && !purple_prefs_get_bool(PREF_ROOT "/emptygroups")) ||
(!purple_prefs_get_bool(PREF_ROOT "/showoffline") && !is_group_online(group)))
- node_remove(list, node->parent);
- for (node = node->child; node; node = node->next)
+ node_remove(list, purple_blist_node_get_parent(node));
+ for (node = purple_blist_node_get_first_child(node); node; node = purple_blist_node_get_sibling_next(node))
reset_blist_node_ui_data(node);
} else {
- for (node = node->child; node; node = node->next)
+ for (node = purple_blist_node_get_first_child(node); node; node = purple_blist_node_get_sibling_next(node))
node_remove(list, node);
}
@@ -325,11 +327,9 @@ node_update(PurpleBuddyList *list, Purpl
if (PURPLE_BLIST_NODE_IS_BUDDY(node)) {
PurpleBuddy *buddy = (PurpleBuddy*)node;
- if (purple_account_is_connected(buddy->account) &&
- (PURPLE_BUDDY_IS_ONLINE(buddy) || purple_prefs_get_bool(PREF_ROOT "/showoffline")))
- add_node((PurpleBlistNode*)buddy, list->ui_data);
+ add_node((PurpleBlistNode*)buddy, list->ui_data);
- node_update(list, node->parent);
+ node_update(list, purple_blist_node_get_parent(node));
} else if (PURPLE_BLIST_NODE_IS_CHAT(node)) {
add_chat((PurpleChat *)node, list->ui_data);
} else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) {
@@ -340,7 +340,7 @@ node_update(PurpleBuddyList *list, Purpl
else {
if (node->ui_data == NULL) {
/* The core seems to expect the UI to add the buddies. */
- for (node = node->child; node; node = node->next)
+ for (node = purple_blist_node_get_first_child(node); node; node = purple_blist_node_get_sibling_next(node))
add_node(node, list->ui_data);
}
}
@@ -399,6 +399,8 @@ add_buddy_cb(void *data, PurpleRequestFi
purple_blist_add_group(grp, NULL);
}
+ /* XXX: Ask if there's already the same buddy in the same group (#4553) */
+
buddy = purple_buddy_new(account, username, alias);
purple_blist_add_buddy(buddy, NULL, grp, NULL);
purple_account_add_buddy(account, buddy);
@@ -677,7 +679,7 @@ add_contact(PurpleContact *contact, Finc
if (name == NULL)
return;
- group = (PurpleGroup*)node->parent;
+ group = (PurpleGroup*)purple_blist_node_get_parent(node);
add_node((PurpleBlistNode*)group, ggblist);
create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), contact,
@@ -699,7 +701,10 @@ add_buddy(PurpleBuddy *buddy, FinchBlist
if (!purple_account_is_connected(buddy->account))
return;
- contact = (PurpleContact*)node->parent;
+ if (!PURPLE_BUDDY_IS_ONLINE(buddy) && !purple_prefs_get_bool(PREF_ROOT "/showoffline"))
+ return;
+
+ contact = (PurpleContact*)purple_blist_node_get_parent(node);
if (!contact) /* When a new buddy is added and show-offline is set */
return;
add_node((PurpleBlistNode*)contact, ggblist);
@@ -1035,8 +1040,8 @@ remove_contact(PurpleContact *contact)
PurpleGroup *group;
cnode = (PurpleBlistNode *)contact;
- group = (PurpleGroup*)cnode->parent;
- for (bnode = cnode->child; bnode; bnode = bnode->next) {
+ group = (PurpleGroup*)purple_blist_node_get_parent(cnode);
+ for (bnode = purple_blist_node_get_first_child(cnode); bnode; bnode = purple_blist_node_get_sibling_next(bnode)) {
PurpleBuddy *buddy = (PurpleBuddy*)bnode;
if (purple_account_is_connected(buddy->account))
purple_account_remove_buddy(buddy->account, buddy, group);
@@ -1104,32 +1109,32 @@ remove_group(PurpleGroup *group)
{
PurpleBlistNode *cnode, *bnode;
- cnode = ((PurpleBlistNode*)group)->child;
+ cnode = purple_blist_node_get_first_child(((PurpleBlistNode*)group));
while (cnode) {
if (PURPLE_BLIST_NODE_IS_CONTACT(cnode)) {
- bnode = cnode->child;
- cnode = cnode->next;
+ bnode = purple_blist_node_get_first_child(cnode);
+ cnode = purple_blist_node_get_sibling_next(cnode);
while (bnode) {
PurpleBuddy *buddy;
if (PURPLE_BLIST_NODE_IS_BUDDY(bnode)) {
buddy = (PurpleBuddy*)bnode;
- bnode = bnode->next;
+ bnode = purple_blist_node_get_sibling_next(bnode);
if (purple_account_is_connected(buddy->account)) {
purple_account_remove_buddy(buddy->account, buddy, group);
purple_blist_remove_buddy(buddy);
}
} else {
- bnode = bnode->next;
+ bnode = purple_blist_node_get_sibling_next(bnode);
}
}
} else if (PURPLE_BLIST_NODE_IS_CHAT(cnode)) {
PurpleChat *chat = (PurpleChat *)cnode;
- cnode = cnode->next;
+ cnode = purple_blist_node_get_sibling_next(cnode);
if (purple_account_is_connected(chat->account))
purple_blist_remove_chat(chat);
} else {
- cnode = cnode->next;
+ cnode = purple_blist_node_get_sibling_next(cnode);
}
}
@@ -1222,12 +1227,12 @@ finch_blist_place_tagged(PurpleBlistNode
if (PURPLE_BLIST_NODE_IS_GROUP(target))
tg = (PurpleGroup*)target;
else if (PURPLE_BLIST_NODE_IS_BUDDY(target)) {
- tc = (PurpleContact*)target->parent;
- tg = (PurpleGroup*)target->parent->parent;
+ tc = (PurpleContact*)purple_blist_node_get_parent(target);
+ tg = (PurpleGroup*)purple_blist_node_get_parent((PurpleBlistNode*)tc);
} else {
if (PURPLE_BLIST_NODE_IS_CONTACT(target))
tc = (PurpleContact*)target;
- tg = (PurpleGroup*)target->parent;
+ tg = (PurpleGroup*)purple_blist_node_get_parent(target);
}
if (ggblist->tagged) {
@@ -1476,7 +1481,7 @@ draw_tooltip_real(FinchBlist *ggblist)
title = g_strdup(name);
tooltip_for_buddy(pr, str, TRUE);
- for (node = node->child; node; node = node->next) {
+ for (node = purple_blist_node_get_first_child(node); node; node = purple_blist_node_get_sibling_next(node)) {
PurpleBuddy *buddy = (PurpleBuddy*)node;
if (offline) {
int value = purple_blist_node_get_int(node, "last_seen");
@@ -2082,7 +2087,7 @@ get_contact_log_size(PurpleBlistNode *c)
int log = 0;
PurpleBlistNode *node;
- for (node = c->child; node; node = node->next) {
+ for (node = purple_blist_node_get_first_child(c); node; node = purple_blist_node_get_sibling_next(node)) {
PurpleBuddy *b = (PurpleBuddy*)node;
log += purple_log_get_total_size(PURPLE_LOG_IM, b->name, b->account);
}
@@ -2176,8 +2181,8 @@ buddy_recent_signed_on_off(gpointer data
node_remove(purple_get_blist(), node);
} else {
update_node_display(node, ggblist);
- if (node->parent && PURPLE_BLIST_NODE_IS_CONTACT(node->parent))
- update_node_display(node->parent, ggblist);
+ if (purple_blist_node_get_parent(node) && PURPLE_BLIST_NODE_IS_CONTACT(purple_blist_node_get_parent(node)))
+ update_node_display(purple_blist_node_get_parent(node), ggblist);
}
return FALSE;
@@ -2195,8 +2200,8 @@ buddy_signed_on_off_cb(gpointer data)
purple_timeout_remove(fnode->signed_timer);
fnode->signed_timer = purple_timeout_add_seconds(6, (GSourceFunc)buddy_recent_signed_on_off, data);
update_node_display(node, ggblist);
- if (node->parent && PURPLE_BLIST_NODE_IS_CONTACT(node->parent))
- update_node_display(node->parent, ggblist);
+ if (purple_blist_node_get_parent(node) && PURPLE_BLIST_NODE_IS_CONTACT(purple_blist_node_get_parent(node)))
+ update_node_display(purple_blist_node_get_parent(node), ggblist);
return FALSE;
}
============================================================
--- libpurple/blist.c 9e2030e9e75e5b512a593fd3d0dd4e902a4ccb98
+++ libpurple/blist.c 6f36dcb06dcd094699d6f32ea65f99e8f08e6b82
@@ -753,6 +753,21 @@ PurpleBlistNode *purple_blist_node_next(
return ret;
}
+PurpleBlistNode *purple_blist_node_get_parent(PurpleBlistNode *node)
+{
+ return node ? node->parent : NULL;
+}
+
+PurpleBlistNode *purple_blist_node_get_first_child(PurpleBlistNode *node)
+{
+ return node ? node->child : NULL;
+}
+
+PurpleBlistNode *purple_blist_node_get_sibling_next(PurpleBlistNode *node)
+{
+ return node? node->next : NULL;
+}
+
void
purple_blist_update_buddy_status(PurpleBuddy *buddy, PurpleStatus *old_status)
{
============================================================
--- libpurple/blist.h 5b78b66b7c456adf4af0cbf8bbca764cc8787f14
+++ libpurple/blist.h 385f2656641904f67f314c713238a0b3a1a578f4
@@ -231,10 +231,49 @@ PurpleBlistNode *purple_blist_get_root(v
* @param node A node.
* @param offline Whether to include nodes for offline accounts
* @return The next node
+ * @see purple_blist_node_get_parent
+ * @see purple_blist_node_get_first_child
+ * @see purple_blist_node_get_sibling_next
*/
PurpleBlistNode *purple_blist_node_next(PurpleBlistNode *node, gboolean offline);
/**
+ * Returns the parent node of a given node.
+ *
+ * @param node A node.
+ * @return The parent node.
+ * @since 2.4.0
+ * @see purple_blist_node_get_first_child
+ * @see purple_blist_node_get_sibling_next
+ * @see purple_blist_node_next
+ */
+PurpleBlistNode *purple_blist_node_get_parent(PurpleBlistNode *node);
+
+/**
+ * Returns the the first child node of a given node.
+ *
+ * @param node A node.
+ * @return The child node.
+ * @since 2.4.0
+ * @see purple_blist_node_get_parent
+ * @see purple_blist_node_get_sibling_next
+ * @see purple_blist_node_next
+ */
+PurpleBlistNode *purple_blist_node_get_first_child(PurpleBlistNode *node);
+
+/**
+ * Returns the sibling node of a given node.
+ *
+ * @param node A node.
+ * @return The sibling node.
+ * @since 2.4.0
+ * @see purple_blist_node_get_parent
+ * @see purple_blist_node_get_first_child
+ * @see purple_blist_node_next
+ */
+PurpleBlistNode *purple_blist_node_get_sibling_next(PurpleBlistNode *node);
+
+/**
* Shows the buddy list, creating a new one if necessary.
*/
void purple_blist_show(void);
More information about the Commits
mailing list