/soc/2013/ankitkv/gobjectification: fde4eb63fab0: Refactored pro...

Ankit Vani a at nevitus.org
Wed Jul 3 12:30:40 EDT 2013


Changeset: fde4eb63fab0888e039a1d864addc19059f62932
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-03 22:00 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/fde4eb63fab0

Description:

Refactored protocols with initial GObject blist API

diffstat:

 libpurple/protocols/bonjour/bonjour.c   |  12 +++++-------
 libpurple/protocols/bonjour/buddy.c     |  10 +++++-----
 libpurple/protocols/gg/purplew.c        |  14 ++++++++++----
 libpurple/protocols/sametime/sametime.c |   2 +-
 4 files changed, 21 insertions(+), 17 deletions(-)

diffs (111 lines):

diff --git a/libpurple/protocols/bonjour/bonjour.c b/libpurple/protocols/bonjour/bonjour.c
--- a/libpurple/protocols/bonjour/bonjour.c
+++ b/libpurple/protocols/bonjour/bonjour.c
@@ -421,19 +421,17 @@ bonjour_tooltip_text(PurpleBuddy *buddy,
 }
 
 static void
-bonjour_do_group_change(PurpleBuddy *buddy, const char *new_group) {
-	PurpleBlistNodeFlags oldflags;
-
+bonjour_do_group_change(PurpleBuddy *buddy, const char *new_group)
+{
 	if (buddy == NULL)
 		return;
 
-	oldflags = purple_blist_node_get_flags((PurpleBlistNode *)buddy);
-
 	/* If we're moving them out of the bonjour group, make them persistent */
 	if (purple_strequal(new_group, BONJOUR_GROUP_NAME))
-		purple_blist_node_set_flags((PurpleBlistNode *)buddy, oldflags | PURPLE_BLIST_NODE_FLAG_NO_SAVE);
+		purple_blist_node_set_dont_save(PURPLE_BLIST_NODE(buddy), TRUE);
 	else
-		purple_blist_node_set_flags((PurpleBlistNode *)buddy, oldflags ^ PURPLE_BLIST_NODE_FLAG_NO_SAVE);
+		purple_blist_node_set_dont_save(PURPLE_BLIST_NODE(buddy),
+				!purple_blist_node_get_dont_save(PURPLE_BLIST_NODE(buddy)));
 
 }
 
diff --git a/libpurple/protocols/bonjour/buddy.c b/libpurple/protocols/bonjour/buddy.c
--- a/libpurple/protocols/bonjour/buddy.c
+++ b/libpurple/protocols/bonjour/buddy.c
@@ -153,7 +153,7 @@ bonjour_buddy_add_to_purple(BonjourBuddy
 
 	if (buddy == NULL) {
 		buddy = purple_buddy_new(account, bonjour_buddy->name, NULL);
-		purple_blist_node_set_flags((PurpleBlistNode *)buddy, PURPLE_BLIST_NODE_FLAG_NO_SAVE);
+		purple_blist_node_set_dont_save(PURPLE_BLIST_NODE(buddy), TRUE);
 		purple_blist_add_buddy(buddy, NULL, group, NULL);
 	}
 
@@ -207,14 +207,14 @@ bonjour_buddy_add_to_purple(BonjourBuddy
  * If the buddy is being saved, mark as offline, otherwise delete
  */
 void bonjour_buddy_signed_off(PurpleBuddy *pb) {
-	if (PURPLE_BLIST_NODE_SHOULD_SAVE(pb)) {
+	if (purple_blist_node_get_dont_save(PURPLE_BLIST_NODE(pb))) {
+		purple_account_remove_buddy(purple_buddy_get_account(pb), pb, NULL);
+		purple_blist_remove_buddy(pb);
+	} else {
 		purple_prpl_got_user_status(purple_buddy_get_account(pb),
 					    purple_buddy_get_name(pb), "offline", NULL);
 		bonjour_buddy_delete(purple_buddy_get_protocol_data(pb));
 		purple_buddy_set_protocol_data(pb, NULL);
-	} else {
-		purple_account_remove_buddy(purple_buddy_get_account(pb), pb, NULL);
-		purple_blist_remove_buddy(pb);
 	}
 }
 
diff --git a/libpurple/protocols/gg/purplew.c b/libpurple/protocols/gg/purplew.c
--- a/libpurple/protocols/gg/purplew.c
+++ b/libpurple/protocols/gg/purplew.c
@@ -101,18 +101,22 @@ GList * ggp_purplew_group_get_buddies(Pu
 	g_return_val_if_fail(group != NULL, NULL);
 	
 	gnode = PURPLE_BLIST_NODE(group);
-	for (cnode = gnode->child; cnode; cnode = cnode->next)
+	for (cnode = purple_blist_node_get_first_child(gnode);
+		cnode != NULL;
+		cnode = purple_blist_node_get_sibling_next(cnode))
 	{
 		if (!PURPLE_IS_CONTACT(cnode))
 			continue;
-		for (bnode = cnode->child; bnode; bnode = bnode->next)
+		for (bnode = purple_blist_node_get_first_child(cnode);
+			bnode != NULL;
+			bnode = purple_blist_node_get_sibling_next(bnode))
 		{
 			PurpleBuddy *buddy;
 			if (!PURPLE_IS_BUDDY(bnode))
 				continue;
 			
 			buddy = PURPLE_BUDDY(bnode);
-			if (account == NULL || buddy->account == account)
+			if (account == NULL || purple_buddy_get_account(buddy) == account)
 				buddies = g_list_append(buddies, buddy);
 		}
 	}
@@ -124,7 +128,9 @@ GList * ggp_purplew_account_get_groups(P
 {
 	PurpleBlistNode *bnode;
 	GList *groups = NULL;
-	for (bnode = purple_blist_get_root(); bnode; bnode = bnode->next)
+	for (bnode = purple_blist_get_root();
+		bnode != NULL;
+		bnode = purple_blist_node_get_sibling_next(bnode))
 	{
 		PurpleGroup *group;
 		GSList *accounts;
diff --git a/libpurple/protocols/sametime/sametime.c b/libpurple/protocols/sametime/sametime.c
--- a/libpurple/protocols/sametime/sametime.c
+++ b/libpurple/protocols/sametime/sametime.c
@@ -718,7 +718,7 @@ static void blist_export(PurpleConnectio
 			  bn;
 			  bn = purple_blist_node_get_sibling_next(bn)) {
 	if(! PURPLE_IS_BUDDY(bn)) continue;
-	if(! PURPLE_BLIST_NODE_SHOULD_SAVE(bn)) continue;
+	if(purple_blist_node_get_dont_save(bn)) continue;
 
 	bdy = (PurpleBuddy *) bn;
 



More information about the Commits mailing list