soc.2009.vulture: 6fb975b9: Some improvements to buddy-list-populati...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Wed Jun 10 17:05:37 EDT 2009


-----------------------------------------------------------------
Revision: 6fb975b923d6e2e210e6795129813a65e4dd698d
Ancestor: 0399aa4c47aacb853572cc6a48e094f78e0ee524
Author: gdick at soc.pidgin.im
Date: 2009-06-10T21:02:41
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/6fb975b923d6e2e210e6795129813a65e4dd698d

Modified files:
        vulture/purpleblist.c vulture/vulture-res.rc
        vulture/vultureblist.c

ChangeLog: 

Some improvements to buddy-list-population logic.

-------------- next part --------------
============================================================
--- vulture/purpleblist.c	2a1ac2ae2cf87aa64db985177ed0cdd137a044ca
+++ vulture/purpleblist.c	2a8f59d9f5e953acfdf5b6f9dec0fd1521687c64
@@ -47,6 +47,8 @@ void PurpleBlistNewNode(PurpleBlistNode 
 	lpvbn->szNodeText = NULL;
 	lpvbn->hti = NULL;
 	InitializeCriticalSection(&lpvbn->cs);
+
+	PurpleBlistUpdateNode(NULL, lpblistnode);
 }
 
 
@@ -62,7 +64,9 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
 
 	UNREFERENCED_PARAMETER(lpbuddylist);
 
-	
+	if(!lpblistnode)
+		return;
+		
 	lpvbn = (VULTURE_BLIST_NODE*)lpblistnode->ui_data;
 
 	EnterCriticalSection(&lpvbn->cs);
@@ -79,6 +83,13 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
 
 		case PURPLE_BLIST_CONTACT_NODE:
 			szNodeText = purple_contact_get_alias((PurpleContact*)lpblistnode);
+
+			if(!szNodeText || !(*szNodeText))
+			{
+				PurpleBuddy *lpbuddy = purple_contact_get_priority_buddy((PurpleContact*)lpblistnode);
+				szNodeText = purple_buddy_get_name(lpbuddy);
+			}
+
 			break;
 
 		default:
@@ -91,5 +102,8 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
 	}
 	LeaveCriticalSection(&lpvbn->cs);
 
-	VulturePostUIMessage(g_hwndMain, VUIMSG_UPDATEBLISTNODE, lpvbn);
+
+	/* TODO: We should probably be less willing to give up. */
+	if(lpvbn->szNodeText)
+		VulturePostUIMessage(g_hwndMain, VUIMSG_UPDATEBLISTNODE, lpvbn);
 }
============================================================
--- vulture/vulture-res.rc	5b95763a4a7c77a1d7cd03adcf0339dae13b5df6
+++ vulture/vulture-res.rc	099f8b8646ca4235743f0fe537a0e466c0768d60
@@ -30,16 +30,6 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_U
 // Dialog resources
 //
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
-IDD_BLIST DIALOG 0, 0, 186, 95
-STYLE DS_3DLOOK | DS_CENTER | DS_CONTROL | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
-FONT 8, "Ms Shell Dlg"
-{
-    CONTROL         "", IDC_TREE_BLIST, WC_TREEVIEW, WS_TABSTOP | WS_BORDER | TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_INFOTIP | TVS_FULLROWSELECT, 5, 5, 175, 85
-}
-
-
-
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
 IDD_ACCOUNTS DIALOG 0, 0, 315, 260
 STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
 EXSTYLE WS_EX_WINDOWEDGE
@@ -59,6 +49,16 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_U
 
 
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+IDD_BLIST DIALOG 0, 0, 186, 95
+STYLE DS_3DLOOK | DS_CENTER | DS_CONTROL | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
+FONT 8, "Ms Shell Dlg"
+{
+    CONTROL         "", IDC_TREE_BLIST, WC_TREEVIEW, WS_TABSTOP | WS_BORDER | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_SHOWSELALWAYS | TVS_INFOTIP | TVS_FULLROWSELECT, 5, 5, 175, 85
+}
+
+
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
 IDD_STATUS DIALOG 0, 0, 161, 41
 STYLE DS_3DLOOK | DS_CENTER | DS_CONTROL | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
 FONT 8, "Ms Shell Dlg"
============================================================
--- vulture/vultureblist.c	a61778b6a0117d8fbc0d4d3f136fd6f503fa152a
+++ vulture/vultureblist.c	767d4092c8e24dea114ee319765908f07381ddf2
@@ -47,8 +47,10 @@ HWND g_hwndMain = NULL;
 
 HWND g_hwndMain = NULL;
 
+static GList *g_lpglistStatuses = NULL;
 
 
+
 /**
  * Creates the main window, incorporating the buddy list.
  *
@@ -220,16 +222,20 @@ static LRESULT CALLBACK MainWndProc(HWND
 				EnterCriticalSection(&lpvbn->cs);
 				{
 					TVITEM tvitem;
-					HTREEITEM htiParent = TreeView_GetParent(hwndBlistTree, lpvbn->hti);
 
-					/* If the parent doesn't match, we need
-					 * to recreate.
-					 */
-					if((lpvbn->lpvbnParent && lpvbn->lpvbnParent->hti != htiParent) ||
-						(!lpvbn->lpvbnParent && htiParent))
+					if(lpvbn->hti)
 					{
-						TreeView_DeleteItem(hwndBlistTree, lpvbn->hti);
-						lpvbn->hti = NULL;
+						HTREEITEM htiParent = TreeView_GetParent(hwndBlistTree, lpvbn->hti);
+
+						/* If the parent doesn't match, we need
+						 * to recreate.
+						 */
+						if((lpvbn->lpvbnParent && lpvbn->lpvbnParent->hti != htiParent) ||
+							(!lpvbn->lpvbnParent && htiParent))
+						{
+							TreeView_DeleteItem(hwndBlistTree, lpvbn->hti);
+							lpvbn->hti = NULL;
+						}
 					}
 
 
@@ -365,6 +371,14 @@ static INT_PTR CALLBACK StatusDlgProc(HW
 		}
 
 		break;
+
+
+	case WM_DESTROY:
+
+		if(g_lpglistStatuses)
+			VulturePurpleFreeStatusList(g_lpglistStatuses);
+
+		return TRUE;
 	}
 
 	return FALSE;
@@ -441,16 +455,19 @@ static void PopulateStatusList(HWND hwnd
 {
 	GList *lpglistStatusRover;
 	GArray *lpgarrayWaitContext;
-	GList *lpglistStatuses = NULL;
-	
 
+	if(g_lpglistStatuses)
+		VulturePurpleFreeStatusList(g_lpglistStatuses);
+
+	SendMessage(hwndComboStatus, CB_RESETCONTENT, 0, 0);
+
 	/* Get all statuses. */
 	lpgarrayWaitContext = VultureAllocPurpleWaitContext();
-	VultureEnqueueMultiSyncPurpleCall(PC_GETALLSAVEDSTATUSES, (void*)&lpglistStatuses, lpgarrayWaitContext);
+	VultureEnqueueMultiSyncPurpleCall(PC_GETALLSAVEDSTATUSES, (void*)&g_lpglistStatuses, lpgarrayWaitContext);
 	VulturePurpleWait(lpgarrayWaitContext);
 
 	/* Populate control. */
-	for(lpglistStatusRover = lpglistStatuses; lpglistStatusRover; lpglistStatusRover = lpglistStatusRover->next)
+	for(lpglistStatusRover = g_lpglistStatuses; lpglistStatusRover; lpglistStatusRover = lpglistStatusRover->next)
 	{
 		VULTURE_SAVED_STATUS *lpvss = lpglistStatusRover->data;
 		COMBOBOXEXITEM cbexitem;
@@ -464,6 +481,4 @@ static void PopulateStatusList(HWND hwnd
 
 		SendMessage(hwndComboStatus, CBEM_INSERTITEM, 0, (LPARAM)&cbexitem);
 	}
-
-	VulturePurpleFreeStatusList(lpglistStatuses);
 }


More information about the Commits mailing list