soc.2009.vulture: 694f93d7: Show online accounts in join-chat dialog...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Sat Jul 4 16:05:58 EDT 2009


-----------------------------------------------------------------
Revision: 694f93d71ba6c93f3df22db6cd643ee2be43eb3a
Ancestor: ea8a918807216b8b4dd03584245dd650d7368634
Author: gdick at soc.pidgin.im
Date: 2009-07-04T11:54:50
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/694f93d71ba6c93f3df22db6cd643ee2be43eb3a

Modified files:
        vulture/acctmanager.h vulture/purpleacct.c
        vulture/purpleacct.h vulture/purplequeue.c
        vulture/purplequeue.h vulture/vultureblist.c
        vulture/vulturedlg.c

ChangeLog: 

Show online accounts in join-chat dialogue.

-------------- next part --------------
============================================================
--- vulture/acctmanager.h	c6e3c44c599f106244c5db8a4b8a3db7fe94f80d
+++ vulture/acctmanager.h	dd7aeaa4c06dcaf84ec094c14bbd94b779a93699
@@ -37,6 +37,13 @@ typedef struct _VULTURE_ACCOUNT
 } VULTURE_ACCOUNT;
 
 
+typedef struct _VULTURE_GET_ACCOUNTS
+{
+	GList	*lpglistAccounts;
+	BOOL	bOnlineOnly;
+} VULTURE_GET_ACCOUNTS;
+
+
 BOOL VultureAccountManagerDlg(HWND hwndParent, GList *lpglistAccounts);
 
 
============================================================
--- vulture/purpleacct.c	eba0bc3cfa1bbda818dd56082363b479d56e53d2
+++ vulture/purpleacct.c	b970f746fbbcefee6558602478c9fe10abbb7f0a
@@ -30,12 +30,14 @@
 
 
 /**
- * Get a list of VULTURE_ACCOUNTS representing all PurpleAccounts. Free the
- * list with VultureFreeAccountList.
+ * Get a list of VULTURE_ACCOUNTs representing either all PurpleAccounts or
+ * only those online, as required. Free the list with VultureFreeAccountList.
  *
+ * @param	bOnlineOnly		Whether to retrieve online accounts
+ *					only.
  * @param[out]	lplpglistAccounts	List to populate.
  */
-void PurpleGetAllAccounts(GList **lplpglistAccounts)
+void PurpleGetAccounts(BOOL bOnlineOnly, GList **lplpglistAccounts)
 {
 	GList *lpglistPurpleAcc;
 
@@ -43,15 +45,18 @@ void PurpleGetAllAccounts(GList **lplpgl
 
 	for(lpglistPurpleAcc = purple_accounts_get_all(); lpglistPurpleAcc; lpglistPurpleAcc = lpglistPurpleAcc->next)
 	{
-		VULTURE_ACCOUNT *lpvac = g_new(VULTURE_ACCOUNT, 1);
+		if(!bOnlineOnly || purple_account_is_connected((PurpleAccount*)lpglistPurpleAcc->data))
+		{
+			VULTURE_ACCOUNT *lpvac = g_new(VULTURE_ACCOUNT, 1);
 
-		lpvac->lppac = (PurpleAccount*)lpglistPurpleAcc->data;
-		lpvac->bEnabled = purple_account_get_enabled(lpvac->lppac, VULTURE_ID);
+			lpvac->lppac = (PurpleAccount*)lpglistPurpleAcc->data;
+			lpvac->bEnabled = purple_account_get_enabled(lpvac->lppac, VULTURE_ID);
 
-		lpvac->szUsername = VultureUTF8ToTCHAR(purple_account_get_username(lpvac->lppac));
-		lpvac->szProtocolID = VultureUTF8ToTCHAR(purple_account_get_protocol_id(lpvac->lppac));
+			lpvac->szUsername = VultureUTF8ToTCHAR(purple_account_get_username(lpvac->lppac));
+			lpvac->szProtocolID = VultureUTF8ToTCHAR(purple_account_get_protocol_id(lpvac->lppac));
 
-		*lplpglistAccounts = g_list_prepend(*lplpglistAccounts, lpvac);
+			*lplpglistAccounts = g_list_prepend(*lplpglistAccounts, lpvac);
+		}
 	}
 
 	*lplpglistAccounts = g_list_reverse(*lplpglistAccounts);
============================================================
--- vulture/purpleacct.h	259f7ddb9aad54f5a4578b765212c7084c402f9a
+++ vulture/purpleacct.h	290134562e787747c50d09c3f6bae2d94b43d961
@@ -24,13 +24,14 @@
 #define _VULTURE_PURPLEACCT_H_
 
 
+#include <windows.h>
 #include <glib.h>
 
 #include "vulture.h"
 #include "acctmanager.h"
 
 
-void PurpleGetAllAccounts(GList **lplpglistAccounts);
+void PurpleGetAccounts(BOOL bOnlineOnly, GList **lplpglistAccounts);
 void VultureFreeAccountList(GList *lpglistAccounts);
 void PurpleApplyVultureAccount(VULTURE_ACCOUNT *lpvac);
 
============================================================
--- vulture/purplequeue.c	da8c62004b726dbb3028ec5dcc4e9b0cc7b3d440
+++ vulture/purplequeue.c	be933e1dd436c643c5ae2292931aa176c21af73a
@@ -178,8 +178,12 @@ static void DispatchPurpleCall(PURPLE_CA
 		PurpleGetBoxSavedStatuses((GList**)lppurplecall->lpvParam);
 		break;
 
-	case PC_GETALLACCOUNTS:
-		PurpleGetAllAccounts((GList**)lppurplecall->lpvParam);
+	case PC_GETACCOUNTS:
+		{
+			VULTURE_GET_ACCOUNTS *lpvgetaccounts = (VULTURE_GET_ACCOUNTS*)lppurplecall->lpvParam;
+			PurpleGetAccounts(lpvgetaccounts->bOnlineOnly, &lpvgetaccounts->lpglistAccounts);
+		}
+
 		break;
 
 	case PC_UPDATEPURPLEACCOUNT:
============================================================
--- vulture/purplequeue.h	08bd96f669fc6b7148f30e61ea0dcb0ae74b83fd
+++ vulture/purplequeue.h	988265e45873a784dee1804a3110174d2664e120
@@ -42,8 +42,10 @@ enum PURPLE_CALL_ID
 	/* (GLlist**) Used to return list of statuses. */
 	PC_GETALLSAVEDSTATUSES,
 
-	/* (GLlist**) Used to return list of accounts. */
-	PC_GETALLACCOUNTS,
+	/* (VULTURE_GET_ACCOUNTS*) Specifies which accounts to get, and returns
+	 * them.
+	 */
+	PC_GETACCOUNTS,
 
 	/* (VULTURE_ACCOUNT*) Account to update. */
 	PC_UPDATEPURPLEACCOUNT,
============================================================
--- vulture/vultureblist.c	ee41f1b4173a1fb445f8182fc92010342dcd6d85
+++ vulture/vultureblist.c	8289535165a647135867e6daa5158cf8a6cfa73a
@@ -580,23 +580,24 @@ static void ManageAccounts(HWND hwndPare
  */
 static void ManageAccounts(HWND hwndParent)
 {
-	GList *lpglistAccounts;
+	VULTURE_GET_ACCOUNTS vgetaccounts;
 
-	VultureSingleSyncPurpleCall(PC_GETALLACCOUNTS, &lpglistAccounts);
+	vgetaccounts.bOnlineOnly = FALSE;
+	VultureSingleSyncPurpleCall(PC_GETACCOUNTS, &vgetaccounts);
 
 	/* Show the dialogue and check whether the user OKs. */
-	if(VultureAccountManagerDlg(hwndParent, lpglistAccounts))
+	if(VultureAccountManagerDlg(hwndParent, vgetaccounts.lpglistAccounts))
 	{
 		GList *lpglistRover;
 		GArray *lpgarrayWaitContext = VultureAllocPurpleWaitContext();
 
-		for(lpglistRover = lpglistAccounts; lpglistRover; lpglistRover = lpglistRover->next)
+		for(lpglistRover = vgetaccounts.lpglistAccounts; lpglistRover; lpglistRover = lpglistRover->next)
 			VultureEnqueueMultiSyncPurpleCall(PC_UPDATEPURPLEACCOUNT, lpglistRover->data, lpgarrayWaitContext);
 
 		VulturePurpleWait(lpgarrayWaitContext);		
 	}
 
-	VultureFreeAccountList(lpglistAccounts);
+	VultureFreeAccountList(vgetaccounts.lpglistAccounts);
 }
 
 
============================================================
--- vulture/vulturedlg.c	6b7bd27db19a0ca52c93abbf12d7c8ecdd527206
+++ vulture/vulturedlg.c	97c26ad3083fd5aad7252a31fc5358e0f8253d7b
@@ -22,14 +22,19 @@
 
 
 #include <windows.h>
+#include <commctrl.h>
 #include <glib.h>
 
 #include "vulture.h"
 #include "vulturedlg.h"
 #include "resource.h"
+#include "acctmanager.h"
+#include "purplequeue.h"
+#include "purpleacct.h"
 
 
 static INT_PTR CALLBACK JoinChatDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+static void PopulateAccountsCombo(HWND hwndCBEx, GList *lpglistAccounts);
 
 
 /**
@@ -60,13 +65,26 @@ static INT_PTR CALLBACK JoinChatDlgProc(
 static INT_PTR CALLBACK JoinChatDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
 {
 	static int s_cyNonGroup = 0, s_cyButtonMargin = 0;
+	static GList *s_lpglistAccounts = NULL;
 
 	switch(uiMsg)
 	{
 	case WM_INITDIALOG:
 		{
+			VULTURE_GET_ACCOUNTS vgetaccounts;
 			RECT rcGroup, rcDlg, rcButton;
 
+			/* Get online accounts. */
+			vgetaccounts.bOnlineOnly = TRUE;
+			VultureSingleSyncPurpleCall(PC_GETACCOUNTS, &vgetaccounts);
+			s_lpglistAccounts = vgetaccounts.lpglistAccounts;
+
+			/* Populate combo and select first item. */
+			PopulateAccountsCombo(GetDlgItem(hwndDlg, IDC_CBEX_ACCOUNTS), s_lpglistAccounts);
+			if(SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CB_GETCOUNT, 0, 0) > 0)
+				SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CB_SETCURSEL, 0, 0);
+
+			/* Remember metrics. */
 			GetClientRect(hwndDlg, &rcDlg);
 			GetClientRect(GetDlgItem(hwndDlg, IDC_STATIC_DETAILS), &rcGroup);
 			GetClientRect(GetDlgItem(hwndDlg, IDOK), &rcButton);
@@ -116,7 +134,38 @@ static INT_PTR CALLBACK JoinChatDlgProc(
 		}
 
 		return TRUE;
+
+	case WM_DESTROY:
+		VultureFreeAccountList(s_lpglistAccounts);
+		return TRUE;
 	}
 
 	return FALSE;
 }
+
+
+/**
+ * Populates a ComboBoxEx control with accounts.
+ *
+ * @param	hwndCBEx		ComboBoxEx control window handle.
+ * @param	lpglistAccounts		Accounts to add.
+ */
+static void PopulateAccountsCombo(HWND hwndCBEx, GList *lpglistAccounts)
+{
+	GList *lpglistRover;
+	COMBOBOXEXITEM cbexitem;
+
+	SendMessage(hwndCBEx, CB_RESETCONTENT, 0, 0);
+
+	cbexitem.mask = CBEIF_TEXT | CBEIF_LPARAM;
+
+	/* Add each account. */
+	for(lpglistRover = lpglistAccounts; lpglistRover; lpglistRover = lpglistRover->next)
+	{
+		VULTURE_ACCOUNT *lpvac = (VULTURE_ACCOUNT*)lpglistRover->data;
+
+		cbexitem.pszText = lpvac->szUsername;
+		cbexitem.lParam = (LPARAM)lpvac;
+		SendMessage(hwndCBEx, CBEM_INSERTITEM, 0, (LPARAM)&cbexitem);
+	}
+}


More information about the Commits mailing list