soc.2009.vulture: ee69b69e: Beginnings of account manager. Enough to...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Sat Jun 6 12:50:55 EDT 2009


-----------------------------------------------------------------
Revision: ee69b69e46801c3dd21e2e42aa84a99dccfa177e
Ancestor: 95fd9abdf38b00bca8b99acbdf0bb6e0bfe5b67b
Author: gdick at soc.pidgin.im
Date: 2009-06-06T15:43:19
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/ee69b69e46801c3dd21e2e42aa84a99dccfa177e

Added files:
        vulture/acctmanager.c vulture/acctmanager.h
        vulture/purpleacct.c vulture/purpleacct.h
Modified files:
        vulture/Makefile.mingw vulture/blist.c vulture/blist.h
        vulture/purplemain.c vulture/purplequeue.c
        vulture/purplequeue.h vulture/resource.h
        vulture/vulture-res.rc vulture/vulture.c

ChangeLog: 

Beginnings of account manager. Enough to enable/disable accounts.

-------------- next part --------------
============================================================
--- vulture/acctmanager.c	d11304ca79c4c522547ef79387065a277a05fab9
+++ vulture/acctmanager.c	d11304ca79c4c522547ef79387065a277a05fab9
@@ -0,0 +1,169 @@
+/*
+ * Vulture - Win32 libpurple client
+ *
+ * acctmanager.c: Account management, including UI.
+ *
+ * Copyright (C) 2009, Gregor Dick <gdick at soc.pidgin.im>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+
+#include <windows.h>
+#include <commctrl.h>
+#include <glib.h>
+
+#include "vulture.h"
+#include "resource.h"
+#include "acctmanager.h"
+
+
+
+typedef struct _ACCMGRDATA
+{
+	GList	*lpglistAccounts;
+} ACCMGRDATA;
+
+
+static INT_PTR CALLBACK AccountManagerDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+
+
+#define CCH_ACCMGR_HEADER	64
+
+
+/**
+ * Show the account manager dialogue. The list of accounts is updated to
+ * reflect the user's changes, but the caller needs to inform libpurple.
+ *
+ * @param		hwndParent		Parent window handle.
+ * @param[in/out]	lpglistAccounts		List of VULTURE_ACCOUNTs.
+ *
+ * @return TRUE iff the dialogue was OK-ed. The list may have been modified
+ * even if FALSE is returned.
+ */
+BOOL VultureAccountManagerDlg(HWND hwndParent, GList *lpglistAccounts)
+{
+	ACCMGRDATA amd = {lpglistAccounts};
+	return DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_ACCOUNTS), hwndParent, AccountManagerDlgProc, (LPARAM)&amd);
+}
+
+
+/**
+ * Dialogue procedure for account manager.
+ *
+ * @param	hwndDlg		Dialogue window handle.
+ * @param	uiMsg		Message ID.
+ * @param	wParam		Message-specific.
+ * @param	lParam		Message-specific.
+ *
+ * @return Usually TRUE if message processed and FALSE otherwise. There are
+ * some exceptions for particular messages.
+ */
+static INT_PTR CALLBACK AccountManagerDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
+{	
+	switch(uiMsg)
+	{
+	case WM_INITDIALOG:
+		{
+			ACCMGRDATA *lpamd = (ACCMGRDATA*)lParam;
+			GList *lpglistAccounts;
+			HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST_ACCOUNTS);
+			LVITEM lvitem;
+			LVCOLUMN lvcol;
+			TCHAR szHeader[CCH_ACCMGR_HEADER];
+
+			/* Remember the parameters. */
+			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)lpamd);
+
+			/* Prepare the columns, taking titles from the string
+			 * table.
+			 */
+
+			lvcol.mask = LVCF_TEXT | LVCF_SUBITEM;
+			lvcol.iSubItem = 0;
+			lvcol.pszText = szHeader;
+
+			LoadString(g_hInstance, IDS_ACCMGR_ACCOUNT, szHeader, NUM_ELEMENTS(szHeader));
+			ListView_InsertColumn(hwndList, lvcol.iSubItem, &lvcol);
+
+			lvcol.iSubItem++;
+			LoadString(g_hInstance, IDS_ACCMGR_PROTOCOL, szHeader, NUM_ELEMENTS(szHeader));
+			ListView_InsertColumn(hwndList, lvcol.iSubItem, &lvcol);
+
+
+			/* List-view extended styles have to be set explicitly,
+			 * not just read from the template.
+			 */
+			ListView_SetExtendedListViewStyle(hwndList, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);
+
+
+			/* Populate the list. */
+			for(lvitem.iItem = 0, lpglistAccounts = lpamd->lpglistAccounts;
+				lpglistAccounts;
+				lvitem.iItem++, lpglistAccounts = lpglistAccounts->next)
+			{
+				lvitem.mask = LVIF_TEXT | LVIF_PARAM;
+				lvitem.iSubItem = 0;
+				lvitem.pszText = ((VULTURE_ACCOUNT*)lpglistAccounts->data)->szUsername;
+				lvitem.lParam = (LPARAM)lpglistAccounts->data;
+				ListView_InsertItem(hwndList, &lvitem);
+
+				lvitem.mask = LVIF_TEXT;
+				lvitem.iSubItem = 1;
+				lvitem.pszText = ((VULTURE_ACCOUNT*)lpglistAccounts->data)->szProtocolID;
+				ListView_SetItem(hwndList, &lvitem);
+
+				ListView_SetCheckState(hwndList, lvitem.iImage, ((VULTURE_ACCOUNT*)lpglistAccounts->data)->bEnabled);
+			}
+
+			ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);
+			ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE_USEHEADER);
+		}
+
+		/* Let the system set the focus. */
+		return TRUE;
+
+	case WM_COMMAND:
+		switch(LOWORD(wParam))
+		{
+		case IDOK:
+			{
+				/* Store the checkbox states for each account. */
+				HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST_ACCOUNTS);
+				LVITEM lvitem;
+				int iCount = ListView_GetItemCount(hwndList);
+
+				lvitem.mask = LVIF_PARAM;
+
+				for(lvitem.iItem = 0; lvitem.iItem < iCount; lvitem.iItem++)
+				{
+					ListView_GetItem(hwndList, &lvitem);
+					((VULTURE_ACCOUNT*)lvitem.lParam)->bEnabled = ListView_GetCheckState(hwndList, lvitem.iItem);
+				}
+
+				EndDialog(hwndDlg, TRUE);
+			}
+
+			return TRUE;
+
+		case IDCANCEL:
+			EndDialog(hwndDlg, FALSE);
+			return TRUE;
+		}
+
+		break;
+	}
+
+	return FALSE;
+}
============================================================
--- vulture/acctmanager.h	c6e3c44c599f106244c5db8a4b8a3db7fe94f80d
+++ vulture/acctmanager.h	c6e3c44c599f106244c5db8a4b8a3db7fe94f80d
@@ -0,0 +1,43 @@
+/*
+ * Vulture - Win32 libpurple client
+ *
+ * acctmanager.h: Account management, including UI.
+ *
+ * Copyright (C) 2009, Gregor Dick <gdick at soc.pidgin.im>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+
+#ifndef _VULTURE_ACCTMANAGER_H_
+#define _VULTURE_ACCTMANAGER_H_
+
+#include <windows.h>
+
+#include "purple.h"
+
+
+typedef struct _VULTURE_ACCOUNT
+{
+	PurpleAccount	*lppac;
+	BOOL		bEnabled;
+	LPTSTR		szUsername;
+	LPTSTR		szProtocolID;
+} VULTURE_ACCOUNT;
+
+
+BOOL VultureAccountManagerDlg(HWND hwndParent, GList *lpglistAccounts);
+
+
+#endif
============================================================
--- vulture/purpleacct.c	eba0bc3cfa1bbda818dd56082363b479d56e53d2
+++ vulture/purpleacct.c	eba0bc3cfa1bbda818dd56082363b479d56e53d2
@@ -0,0 +1,100 @@
+/*
+ * Vulture - Win32 libpurple client
+ *
+ * purpleacct.c: libpurple side of account-handling.
+ *
+ * Copyright (C) 2009, Gregor Dick <gdick at soc.pidgin.im>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+
+#include <windows.h>
+#include <glib.h>
+
+#include "vulture.h"
+#include "purple.h"
+#include "purpleacct.h"
+#include "acctmanager.h"
+
+
+/**
+ * Get a list of VULTURE_ACCOUNTS representing all PurpleAccounts. Free the
+ * list with VultureFreeAccountList.
+ *
+ * @param[out]	lplpglistAccounts	List to populate.
+ */
+void PurpleGetAllAccounts(GList **lplpglistAccounts)
+{
+	GList *lpglistPurpleAcc;
+
+	*lplpglistAccounts = NULL;
+
+	for(lpglistPurpleAcc = purple_accounts_get_all(); lpglistPurpleAcc; lpglistPurpleAcc = lpglistPurpleAcc->next)
+	{
+		VULTURE_ACCOUNT *lpvac = g_new(VULTURE_ACCOUNT, 1);
+
+		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));
+
+		*lplpglistAccounts = g_list_prepend(*lplpglistAccounts, lpvac);
+	}
+
+	*lplpglistAccounts = g_list_reverse(*lplpglistAccounts);
+}
+
+
+/**
+ * Frees a list of VULTURE_ACCOUNTS.
+ *
+ * @param	lpglistAccounts		List to free.
+ */
+void VultureFreeAccountList(GList *lpglistAccounts)
+{
+	GList *lpglistRover;
+
+	for(lpglistRover = lpglistAccounts; lpglistRover; lpglistRover = lpglistRover->next)
+	{
+		VULTURE_ACCOUNT *lpvac = (VULTURE_ACCOUNT*)lpglistRover->data;
+
+		g_free(lpvac->szUsername);
+		g_free(lpvac->szProtocolID);
+		g_free(lpvac);
+	}
+}
+
+
+/**
+ * Updates the PurpleAccount underlying a VULTURE_ACCOUNT with properties from
+ * the latter.
+ *
+ * @param	lpvac	Account.
+ */
+void PurpleApplyVultureAccount(VULTURE_ACCOUNT *lpvac)
+{
+	char *szUsername, *szProtocolID;
+
+	szUsername = VultureTCHARToUTF8(lpvac->szUsername);
+	szProtocolID = VultureTCHARToUTF8(lpvac->szProtocolID);
+
+	purple_account_set_username(lpvac->lppac, szUsername);
+	purple_account_set_protocol_id(lpvac->lppac, szProtocolID);
+	purple_account_set_enabled(lpvac->lppac, VULTURE_ID, lpvac->bEnabled);
+
+	g_free(szProtocolID);
+	g_free(szUsername);
+}
============================================================
--- vulture/purpleacct.h	259f7ddb9aad54f5a4578b765212c7084c402f9a
+++ vulture/purpleacct.h	259f7ddb9aad54f5a4578b765212c7084c402f9a
@@ -0,0 +1,38 @@
+/*
+ * Vulture - Win32 libpurple client
+ *
+ * purpleacct.h: libpurple side of account-handling.
+ *
+ * Copyright (C) 2009, Gregor Dick <gdick at soc.pidgin.im>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+
+#ifndef _VULTURE_PURPLEACCT_H_
+#define _VULTURE_PURPLEACCT_H_
+
+
+#include <glib.h>
+
+#include "vulture.h"
+#include "acctmanager.h"
+
+
+void PurpleGetAllAccounts(GList **lplpglistAccounts);
+void VultureFreeAccountList(GList *lpglistAccounts);
+void PurpleApplyVultureAccount(VULTURE_ACCOUNT *lpvac);
+
+
+#endif
============================================================
--- vulture/Makefile.mingw	30e56f06dbb946d6e447e8509887825218f6cfc1
+++ vulture/Makefile.mingw	d2d38d1b6d3c00e3f8db7ef69cc80155998ed599
@@ -57,7 +57,9 @@ VULTURE_C_SRC =	\
 			purplequeue.c \
 			purpleevloop.c \
 			cmdline.c \
-			purplestatus.c
+			purplestatus.c \
+			acctmanager.c \
+			purpleacct.c
 
 VULTURE_RC_SRC = vulture-res.rc
 VULTURE_OBJECTS = $(VULTURE_C_SRC:%.c=%.o) $(VULTURE_RC_SRC:%.rc=%.o)
============================================================
--- vulture/blist.c	59966eb0912f6596beb61f53efec7fb7fa185496
+++ vulture/blist.c	bc8666bf7d1a94221dc617e40aea18b09f35bf53
@@ -29,19 +29,23 @@
 #include "blist.h"
 #include "purplequeue.h"
 #include "purplestatus.h"
+#include "acctmanager.h"
+#include "purpleacct.h"
 
 
 static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
 static INT_PTR CALLBACK StatusDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
 static INT_PTR CALLBACK BuddyListDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+static void ManageAccounts(HWND hwndParent);
 
 
 #define BLIST_MARGIN 6
 
 
-static HWND g_hwndMain = NULL;
+HWND g_hwndMain = NULL;
 
 
+
 /**
  * Creates the main window, incorporating the buddy list.
  *
@@ -127,6 +131,10 @@ static LRESULT CALLBACK MainWndProc(HWND
 		case IDM_BLIST_BUDDIES_CLOSE:
 			SendMessage(hwnd, WM_CLOSE, 0, 0);
 			return 0;
+
+		case IDM_BLIST_ACCOUNTS_MANAGE:
+			ManageAccounts(hwnd);
+			return 0;
 		}
 
 		break;
@@ -295,3 +303,30 @@ static INT_PTR CALLBACK BuddyListDlgProc
 
 	return FALSE;
 }
+
+
+/**
+ * Shows the account manager dialogue, and updates accounts if user OKs.
+ *
+ * @param	hwndParent	Parent window handle.
+ */
+static void ManageAccounts(HWND hwndParent)
+{
+	GList *lpglistAccounts;
+
+	VultureSingleSyncPurpleCall(PC_GETALLACCOUNTS, &lpglistAccounts);
+
+	/* Show the dialogue and check whether the user OKs. */
+	if(VultureAccountManagerDlg(hwndParent, lpglistAccounts))
+	{
+		GList *lpglistRover;
+		GArray *lpgarrayWaitContext = VultureAllocPurpleWaitContext();
+
+		for(lpglistRover = lpglistAccounts; lpglistRover; lpglistRover = lpglistRover->next)
+			VultureEnqueueMultiSyncPurpleCall(PC_UPDATEPURPLEACCOUNT, lpglistRover->data, lpgarrayWaitContext);
+
+		VulturePurpleWait(lpgarrayWaitContext);		
+	}
+
+	VultureFreeAccountList(lpglistAccounts);
+}
============================================================
--- vulture/blist.h	76aebfd775faba9602b1fce5b54e90dbd9cb3e74
+++ vulture/blist.h	866f3cdb00421b86035a6abb8a2aee8cb6f11d92
@@ -23,6 +23,8 @@
 #ifndef _VULTURE_BLIST_H_
 #define _VULTURE_BLIST_H_
 
+extern HWND g_hwndMain;
+
 int VultureCreateMainWindow(int iCmdShow);
 
 #endif
============================================================
--- vulture/purplemain.c	cbe1ff5c4df90877595b7ee34619108197776f64
+++ vulture/purplemain.c	2ca898002e2a581b40d8abbfd917748f5a0da336
@@ -53,9 +53,7 @@ static void InitUI(void);
 static void InitUI(void);
 
 
-#define VULTURE_ID	"vulture"
 
-
 GMainLoop *g_lpgmainloop = NULL;
 
 
============================================================
--- vulture/purplequeue.c	62f199fc87002fc07d07398ab83bf08551ed306f
+++ vulture/purplequeue.c	e0e2ce7e2f0d0a3ea64061238de56981b98ec323
@@ -27,6 +27,7 @@
 #include "purplemain.h"
 #include "purplequeue.h"
 #include "purplestatus.h"
+#include "purpleacct.h"
 
 
 /** Queue node representing a libpurple call. */
@@ -173,6 +174,14 @@ static void DispatchPurpleCall(PURPLE_CA
 		PurpleGetAllSavedStatuses((GList**)lppurplecall->lpvParam);
 		break;
 
+	case PC_GETALLACCOUNTS:
+		PurpleGetAllAccounts((GList**)lppurplecall->lpvParam);
+		break;
+
+	case PC_UPDATEPURPLEACCOUNT:
+		PurpleApplyVultureAccount((VULTURE_ACCOUNT*)lppurplecall->lpvParam);
+		break;
+
 	case PC_QUIT:
 		g_main_loop_quit(g_lpgmainloop);
 		break;
@@ -340,7 +349,8 @@ void VulturePurpleWait(GArray *lpgarrayW
 {
 	int i;
 
-	WaitForMultipleObjects(lpgarrayWaitContext->len, (HANDLE*)lpgarrayWaitContext->data, TRUE, INFINITE);
+	if(lpgarrayWaitContext->len > 0)
+		WaitForMultipleObjects(lpgarrayWaitContext->len, (HANDLE*)lpgarrayWaitContext->data, TRUE, INFINITE);
 	
 	for(i = 0; i < lpgarrayWaitContext->len; i++)
 		CloseHandle(g_array_index(lpgarrayWaitContext, HANDLE, i));
@@ -363,3 +373,18 @@ void VultureEnqueueMultiSyncPurpleCall(i
 	g_array_append_val(lpgarrayWaitContext, hevent);
 	VultureEnqueueSyncPurpleCall(iCallID, lpvParam, hevent);
 }
+
+
+/**
+ * Makes and waits for a single synchronous call to libpurple.
+ *
+ * @param	iCallID			ID of the operation to perform.
+ * @param	lpvParam		Function-specific data.
+ */
+void VultureSingleSyncPurpleCall(int iCallID, void *lpvParam)
+{
+	HANDLE hevent = CreateEvent(NULL, TRUE, FALSE, NULL);
+	VultureEnqueueSyncPurpleCall(iCallID, lpvParam, hevent);
+	WaitForSingleObject(hevent, INFINITE);
+	CloseHandle(hevent);
+}
============================================================
--- vulture/purplequeue.h	d6e427a834b0b61d3ae25d700d8920f58b60404a
+++ vulture/purplequeue.h	ab4d3e302bb7422d5a5941d38b1b89dd92551776
@@ -41,6 +41,12 @@ enum PURPLE_CALL_ID
 
 	/* (GLlist**) Used to return list of statuses. */
 	PC_GETALLSAVEDSTATUSES,
+
+	/* (GLlist**) Used to return list of accounts. */
+	PC_GETALLACCOUNTS,
+
+	/* (VULTURE_ACCOUNT*) Account to update. */
+	PC_UPDATEPURPLEACCOUNT,
 };
 
 
@@ -52,6 +58,7 @@ void VultureEnqueueMultiSyncPurpleCall(i
 GSource* VultureCreateSyncQueueSource(void);
 void VulturePurpleWait(GArray *lpgarrayWaitContext);
 void VultureEnqueueMultiSyncPurpleCall(int iCallID, void *lpvParam, GArray *lpgarrayWaitContext);
+void VultureSingleSyncPurpleCall(int iCallID, void *lpvParam);
 
 
 
============================================================
--- vulture/resource.h	e65c6ee61ea44d34d795c8b771a85002d69337c3
+++ vulture/resource.h	f22c088302e92b5f805a9d52393f300ad6c52761
@@ -5,10 +5,19 @@
 #define IDD_STATUS                              101
 #define IDM_BLIST                               103
 #define IDD_BLIST                               105
+#define IDD_ACCOUNTS                            107
+#define IDR_ACCEL_MAIN                          109
 #define IDC_BUDDY_ICON                          1002
+#define IDC_LIST_ACCOUNTS                       1003
 #define IDC_CBEX_STATUS                         1004
 #define IDM_BLIST_BUDDIES_CLOSE                 40000
 #define IDS_ERROR_BLIST                         40000
+#define IDM_BLIST_ACCOUNTS_MANAGE               40001
 #define IDS_ERROR_PURPLEINIT                    40001
+#define IDS_ACCMGR_ACCOUNT                      40002
 #define IDC_EDIT_STATUSMSG                      40003
+#define IDS_ACCMGR_PROTOCOL                     40003
 #define IDC_TREE_BLIST                          40004
+#define IDC_BTN_ACCOUNT_ADD                     40005
+#define IDC_BTN_ACCOUNT_PROPERTIES              40006
+#define IDC_BTN_ACCOUNT_DELETE                  40007
============================================================
--- vulture/vulture-res.rc	c1a27394163593e53bc674ad4a3ed7c5c924f922
+++ vulture/vulture-res.rc	5b95763a4a7c77a1d7cd03adcf0339dae13b5df6
@@ -18,6 +18,10 @@ IDM_BLIST MENU
     {
         MENUITEM "&Close", IDM_BLIST_BUDDIES_CLOSE
     }
+    POPUP "&Accounts"
+    {
+        MENUITEM "&Manage Accounts\tCtrl+A", IDM_BLIST_ACCOUNTS_MANAGE
+    }
 }
 
 
@@ -36,12 +40,31 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_U
 
 
 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
+CAPTION "Accounts"
+FONT 8, "Ms Shell Dlg"
+{
+    DEFPUSHBUTTON   "OK", IDOK, 205, 240, 50, 14, BS_DEFPUSHBUTTON
+    PUSHBUTTON      "Cancel", IDCANCEL, 260, 240, 50, 14, BS_PUSHBUTTON
+    GROUPBOX        "Accounts", IDC_STATIC, 7, 5, 300, 230
+    LTEXT           "The accounts currently configured are listed below. Use the checkboxes to enable or disable the accounts.", IDC_STATIC, 15, 15, 285, 20, SS_LEFT
+    CONTROL         "", IDC_LIST_ACCOUNTS, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_REPORT, 15, 35, 285, 175
+    PUSHBUTTON      "&Add...", IDC_BTN_ACCOUNT_ADD, 140, 215, 50, 14, WS_DISABLED | BS_PUSHBUTTON
+    PUSHBUTTON      "&Properties", IDC_BTN_ACCOUNT_PROPERTIES, 195, 215, 50, 14, WS_DISABLED | BS_PUSHBUTTON
+    PUSHBUTTON      "&Delete", IDC_BTN_ACCOUNT_DELETE, 250, 215, 50, 14, WS_DISABLED | BS_PUSHBUTTON
+}
+
+
+
+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"
 {
     CONTROL         "", IDC_BUDDY_ICON, WC_STATIC, WS_TABSTOP | SS_BLACKFRAME | SS_NOTIFY | SS_SUNKEN, 5, 5, 30, 30
-    CONTROL         "1", IDC_CBEX_STATUS, "ComboBoxEx32", CBS_DROPDOWNLIST, 40, 5, 115, 90
+    CONTROL         "1", IDC_CBEX_STATUS, "ComboBoxEx32", 0x50000003, 40, 5, 115, 90
     EDITTEXT        IDC_EDIT_STATUSMSG, 40, 20, 115, 15, ES_AUTOHSCROLL | ES_WANTRETURN
 }
 
@@ -56,11 +79,24 @@ STRINGTABLE
 {
     IDS_ERROR_BLIST               "Couldn't initialise buddy list."
     IDS_ERROR_PURPLEINIT          "Couldn't initialise libpurple."
+    IDS_ACCMGR_ACCOUNT            "Account"
+    IDS_ACCMGR_PROTOCOL           "Protocol"
 }
 
 
 
 //
+// Accelerator resources
+//
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+IDR_ACCEL_MAIN ACCELERATORS
+{
+    "A",            IDM_BLIST_ACCOUNTS_MANAGE, VIRTKEY, CONTROL
+}
+
+
+
+//
 // Manifest resources
 //
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
============================================================
--- vulture/vulture.c	5dcdfa6be03b02495fa5a3fd692b00bedbbe8e1b
+++ vulture/vulture.c	6eaf80abbba4e0068791a3316a75a76ef62ad1b0
@@ -54,6 +54,7 @@ int WINAPI WinMain(HINSTANCE hinst, HINS
 	MSG msg;
 	HANDLE hthreadPurple;
 	INITCOMMONCONTROLSEX iccx;
+	HACCEL haccel;
 
 	g_hInstance = hinst;
 	g_hProcHeap = GetProcessHeap();
@@ -79,10 +80,16 @@ int WINAPI WinMain(HINSTANCE hinst, HINS
 		return VEC_ERROR_BLIST;
 	}
 
+	/* For keyboard shortcuts. */
+	haccel = LoadAccelerators(hinst, MAKEINTRESOURCE(IDR_ACCEL_MAIN));
+
 	while(GetMessage(&msg, NULL, 0, 0))
 	{
-		TranslateMessage(&msg);
-		DispatchMessage(&msg);
+		if(!TranslateAccelerator(g_hwndMain, haccel, &msg))
+		{
+			TranslateMessage(&msg);
+			DispatchMessage(&msg);
+		}
 	}
 
 	/* UI has shut down; do the same to libpurple, waiting until it's


More information about the Commits mailing list