soc.2009.vulture: 0ebd75de: Don't show blist nodes for offline accou...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Wed Jun 17 15:00:28 EDT 2009


-----------------------------------------------------------------
Revision: 0ebd75deb70fb05bacb5ac165bfb489bbda1f4b7
Ancestor: 6269afb54f719e39a43bc4ec64ab99a1e58467ea
Author: gdick at soc.pidgin.im
Date: 2009-06-17T14:30:32
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/0ebd75deb70fb05bacb5ac165bfb489bbda1f4b7

Modified files:
        vulture/purpleblist.c

ChangeLog: 

Don't show blist nodes for offline accounts.

-------------- next part --------------
============================================================
--- vulture/purpleblist.c	2a8f59d9f5e953acfdf5b6f9dec0fd1521687c64
+++ vulture/purpleblist.c	6334927d73097fbbd9f112746e4e535ae1ad7322
@@ -30,6 +30,11 @@
 #include "purplemain.h"
 
 
+
+static BOOL ShouldShowNode(PurpleBlistNode *lpblistnode);
+
+
+
 /**
  * Callback for when a new buddy-list node is created.
  *
@@ -66,6 +71,9 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
 
 	if(!lpblistnode)
 		return;
+
+	if(!ShouldShowNode(lpblistnode))
+		return;
 		
 	lpvbn = (VULTURE_BLIST_NODE*)lpblistnode->ui_data;
 
@@ -107,3 +115,48 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
 	if(lpvbn->szNodeText)
 		VulturePostUIMessage(g_hwndMain, VUIMSG_UPDATEBLISTNODE, lpvbn);
 }
+
+
+
+/**
+ * Determines whether a buddy-list node should be shown.
+ *
+ * @param	lpblistnode	Buddy-list node.
+ */
+static BOOL ShouldShowNode(PurpleBlistNode *lpblistnode)
+{
+	switch(lpblistnode->type)
+	{
+	case PURPLE_BLIST_GROUP_NODE:
+	case PURPLE_BLIST_CONTACT_NODE:
+		{
+			PurpleBlistNode *lpblistnodeRover;
+
+			/* Show iff any of our children should be shown. */
+			for(lpblistnodeRover = purple_blist_node_get_first_child(lpblistnode);
+				lpblistnodeRover;
+				lpblistnodeRover = purple_blist_node_get_sibling_next(lpblistnodeRover))
+			{
+				if(ShouldShowNode(lpblistnodeRover))
+					return TRUE;
+			}
+		}
+
+		break;
+
+	case PURPLE_BLIST_CHAT_NODE:
+		if(purple_account_is_connected(purple_chat_get_account((PurpleChat*)lpblistnode)))
+			return TRUE;
+		break;
+
+	case PURPLE_BLIST_BUDDY_NODE:
+		if(purple_account_is_connected(purple_buddy_get_account((PurpleBuddy*)lpblistnode)))
+			return TRUE;
+		break;
+
+	default:
+		break;
+	}
+
+	return FALSE;
+}


More information about the Commits mailing list