soc.2009.vulture: d86ddf2f: Show/hide buddies as they are on/offline.
gdick at soc.pidgin.im
gdick at soc.pidgin.im
Wed Jun 24 15:15:32 EDT 2009
-----------------------------------------------------------------
Revision: d86ddf2f000915a9966391e75fa5809b25de2eda
Ancestor: 9c35d774ce4998581f96e80a2b451dc1b20d34af
Author: gdick at soc.pidgin.im
Date: 2009-06-24T12:01:49
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/d86ddf2f000915a9966391e75fa5809b25de2eda
Modified files:
vulture/purpleblist.c vulture/purplemain.h
vulture/vultureblist.c
ChangeLog:
Show/hide buddies as they are on/offline.
-------------- next part --------------
============================================================
--- vulture/purpleblist.c c6d8e121f93f1b43f86539d7b192ec924f7e84c3
+++ vulture/purpleblist.c 52f22504086c2db722d41854f2d5c28ed2385455
@@ -70,56 +70,64 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
if(!lpblistnode)
return;
-
- if(!ShouldShowNode(lpblistnode))
- return;
lpvbn = (VULTURE_BLIST_NODE*)lpblistnode->ui_data;
EnterCriticalSection(&lpvbn->cs);
- {
- const char *szNodeText;
- if(lpvbn->lpvbnParent) VultureBListNodeRelease(lpvbn->lpvbnParent);
- lpvbn->lpvbnParent = lpblistnode->parent ? (VULTURE_BLIST_NODE*)lpblistnode->parent->ui_data : NULL;
- if(lpvbn->lpvbnParent) VultureBListNodeAddRef(lpvbn->lpvbnParent);
-
- switch(lpblistnode->type)
+ if(ShouldShowNode(lpblistnode))
{
- case PURPLE_BLIST_GROUP_NODE:
- szNodeText = ((PurpleGroup*)lpblistnode)->name;
- break;
+ const char *szNodeText;
- case PURPLE_BLIST_CONTACT_NODE:
- szNodeText = purple_contact_get_alias((PurpleContact*)lpblistnode);
+ if(lpvbn->lpvbnParent) VultureBListNodeRelease(lpvbn->lpvbnParent);
+ lpvbn->lpvbnParent = lpblistnode->parent ? (VULTURE_BLIST_NODE*)lpblistnode->parent->ui_data : NULL;
+ if(lpvbn->lpvbnParent) VultureBListNodeAddRef(lpvbn->lpvbnParent);
- if(!szNodeText || !(*szNodeText))
+ switch(lpblistnode->type)
{
- PurpleBuddy *lpbuddy = purple_contact_get_priority_buddy((PurpleContact*)lpblistnode);
- szNodeText = purple_buddy_get_name(lpbuddy);
- }
+ case PURPLE_BLIST_GROUP_NODE:
+ szNodeText = ((PurpleGroup*)lpblistnode)->name;
+ break;
- break;
+ case PURPLE_BLIST_CONTACT_NODE:
+ szNodeText = purple_contact_get_alias((PurpleContact*)lpblistnode);
- default:
- szNodeText = PURPLE_BLIST_NODE_NAME(lpblistnode);
- break;
- }
+ if(!szNodeText || !(*szNodeText))
+ {
+ PurpleBuddy *lpbuddy = purple_contact_get_priority_buddy((PurpleContact*)lpblistnode);
+ szNodeText = purple_buddy_get_name(lpbuddy);
+ }
- if(lpvbn->szNodeText) g_free(lpvbn->szNodeText);
- lpvbn->szNodeText = szNodeText ? VultureUTF8ToTCHAR(szNodeText) : NULL;
+ break;
- /* TODO: We should probably be less willing to give up. */
- if(lpvbn->szNodeText)
+ default:
+ szNodeText = PURPLE_BLIST_NODE_NAME(lpblistnode);
+ break;
+ }
+
+ if(lpvbn->szNodeText) g_free(lpvbn->szNodeText);
+ lpvbn->szNodeText = szNodeText ? VultureUTF8ToTCHAR(szNodeText) : NULL;
+
+ /* TODO: We should probably be less willing to give up. */
+ if(lpvbn->szNodeText)
+ {
+ /* If our parent isn't showing, show it first. */
+ if(lpvbn->lpvbnParent && !lpvbn->lpvbnParent->hti)
+ PurpleBlistUpdateNode(lpbuddylist, lpvbn->lpvbnParent->lpblistnode);
+
+ VultureBListNodeAddRef(lpvbn);
+ VulturePostUIMessage(g_hwndMain, VUIMSG_UPDATEBLISTNODE, lpvbn);
+ }
+ }
+ else if(lpvbn->hti)
{
- /* If out parent isn't showing, show it first. */
- if(lpvbn->lpvbnParent && !lpvbn->lpvbnParent->hti)
- PurpleBlistUpdateNode(lpbuddylist, lpvbn->lpvbnParent->lpblistnode);
+ VulturePostUIMessage(g_hwndMain, VUIMSG_REMOVEBLISTNODE, lpvbn);
- VultureBListNodeAddRef(lpvbn);
- VulturePostUIMessage(g_hwndMain, VUIMSG_UPDATEBLISTNODE, lpvbn);
+ /* The parent may need to go, too. */
+ if(lpvbn->lpvbnParent && lpvbn->lpvbnParent->hti)
+ PurpleBlistUpdateNode(lpbuddylist, lpvbn->lpvbnParent->lpblistnode);
}
- }
+
LeaveCriticalSection(&lpvbn->cs);
}
@@ -157,8 +165,15 @@ static BOOL ShouldShowNode(PurpleBlistNo
break;
case PURPLE_BLIST_BUDDY_NODE:
- if(purple_account_is_connected(purple_buddy_get_account((PurpleBuddy*)lpblistnode)))
- return TRUE;
+ {
+ PurpleBuddy *lpbuddy = (PurpleBuddy*)lpblistnode;
+
+ if(purple_account_is_connected(purple_buddy_get_account(lpbuddy)) &&
+ (purple_presence_is_online(lpbuddy->presence) ||
+ purple_blist_node_get_bool(lpblistnode, "show_offline")))
+ return TRUE;
+ }
+
break;
default:
============================================================
--- vulture/purplemain.h 396e29f02b1379f64d04cad01a11faa52467db89
+++ vulture/purplemain.h 1df62eb9305114399b2bca8f12ea682c8dc9acb9
@@ -53,6 +53,9 @@ enum ENUM_VULTURE_UI_MESSAGES
/* (VULTURE_SAVED_STATUS*) New status. */
VUIMSG_STATUSCHANGED,
+
+ /* (VULTURE_BLIST_NODE*) Node to remove. */
+ VUIMSG_REMOVEBLISTNODE,
};
/* HandlEs for reigistering signal handlERs. */
============================================================
--- vulture/vultureblist.c daa7c0c24f7d2dc6107db8641d1bf954a8b5097e
+++ vulture/vultureblist.c 20c6fa07494e76cc71a60f752110e9eccbc9b646
@@ -54,6 +54,7 @@ static void SetStatusMsg(HWND hwndStatus
static void UpdateStatusUI(VULTURE_SAVED_STATUS *lpvss, HWND hwndStatusDlg);
static LRESULT CALLBACK StatusMsgBoxSubclassProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
static void SetStatusMsg(HWND hwndStatusDlg);
+static void RemoveBListNode(HWND hwndBlistTree, VULTURE_BLIST_NODE *lpvbn);
#define BLIST_MARGIN 6
@@ -251,13 +252,7 @@ static LRESULT CALLBACK MainWndProc(HWND
if((lpvbn->lpvbnParent && lpvbn->lpvbnParent->hti != htiParent) ||
(!lpvbn->lpvbnParent && htiParent))
{
- TreeView_DeleteItem(hwndBlistTree, lpvbn->hti);
- lpvbn->hti = NULL;
-
- /* Release the reference belonging to the pointer
- * cached in the tree-item.
- */
- VultureBListNodeRelease(lpvbn);
+ RemoveBListNode(hwndBlistTree, lpvbn);
}
}
@@ -292,6 +287,10 @@ static LRESULT CALLBACK MainWndProc(HWND
break;
+ case VUIMSG_REMOVEBLISTNODE:
+ RemoveBListNode(GetDlgItem(g_hwndBListDlg, IDC_TREE_BLIST), (VULTURE_BLIST_NODE*)lParam);
+ break;
+
case VUIMSG_NEWCONVERSATION:
if(!g_lpglistConvContainers)
g_lpglistConvContainers = g_list_prepend(g_lpglistConvContainers, VultureCreateConvContainer());
@@ -708,3 +707,21 @@ static void SetStatusMsg(HWND hwndStatus
if(szOldMessage) g_free(szOldMessage);
if(vss.szMessage) ProcHeapFree(vss.szMessage);
}
+
+
+/**
+ * Removes a buddy-list node, doing the requisite housekeeping.
+ *
+ * @param hwndStatusDlg Buddy-list tree-view handle.
+ * @param lpvbn Node to delete.
+ */
+static void RemoveBListNode(HWND hwndBlistTree, VULTURE_BLIST_NODE *lpvbn)
+{
+ TreeView_DeleteItem(hwndBlistTree, lpvbn->hti);
+ lpvbn->hti = NULL;
+
+ /* Release the reference belonging to the pointer
+ * cached in the tree-item.
+ */
+ VultureBListNodeRelease(lpvbn);
+}
More information about the Commits
mailing list