soc.2009.vulture: 42b2bf4c: Proxy page of account options now comple...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Tue Sep 15 15:40:37 EDT 2009


-----------------------------------------------------------------
Revision: 42b2bf4ce0b52f2a1dd6de7d254ba63072bb309e
Ancestor: cd038dddf49514dd4bbca86e842cd326645a1c88
Author: gdick at soc.pidgin.im
Date: 2009-09-15T18:57:09
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/42b2bf4ce0b52f2a1dd6de7d254ba63072bb309e

Modified files:
        vulture/acctmanager.c vulture/acctmanager.h
        vulture/purpleacct.c vulture/resource.h
        vulture/vulture-res.rc

ChangeLog: 

Proxy page of account options now complete.

-------------- next part --------------
============================================================
--- vulture/acctmanager.c	26252ebbc4a4f5ca398441f5b3b1ce1cbf9346bf
+++ vulture/acctmanager.c	5f224d6224915bf6c8b1a069954fa580bbf58ede
@@ -44,6 +44,8 @@ static void UpdateBIconPreview(HWND hwnd
 static INT_PTR CALLBACK AccountAccountPropPageProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
 static void EnableDisableBIconSelectControls(HWND hwndPropPage);
 static void UpdateBIconPreview(HWND hwndPropPage);
+static INT_PTR CALLBACK ProxyAccountPropPageProc(HWND hwndPropPage, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+static void EnableDisableProxyControls(HWND hwndPropPage);
 
 
 #define CCH_ACCMGR_HEADER	64
@@ -55,8 +57,8 @@ enum ENUM_ACCOUNT_PROP_PAGES
 	APP_ACCOUNT,
 #if 0
 	APP_PROTO,
+#endif
 	APP_PROXY,
-#endif
 	APP_COUNT
 };
 
@@ -281,6 +283,13 @@ static void EditAccount(HWND hwndParent,
 	rgpsp[APP_ACCOUNT].lParam = (LPARAM)lpvac;
 	rgpsp[APP_ACCOUNT].pszTemplate = MAKEINTRESOURCE(IDD_ACCOUNTPROP_ACCOUNT);
 
+	rgpsp[APP_PROXY].dwSize = sizeof(PROPSHEETPAGE);
+	rgpsp[APP_PROXY].dwFlags = PSP_DEFAULT;
+	rgpsp[APP_PROXY].hInstance = g_hInstance;
+	rgpsp[APP_PROXY].pfnDlgProc = ProxyAccountPropPageProc;
+	rgpsp[APP_PROXY].lParam = (LPARAM)lpvac;
+	rgpsp[APP_PROXY].pszTemplate = MAKEINTRESOURCE(IDD_ACCOUNTPROP_PROXY);
+
 	PropertySheet(&psh);
 }
 
@@ -569,3 +578,155 @@ static void UpdateBIconPreview(HWND hwnd
 	if(hbitmap)
 		DeleteObject(hbitmap);
 }
+
+
+/**
+ * Property-page procedure for 'proxy' page of accounts property sheet.
+ *
+ * @param	hwndPropPage	Property-page 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 ProxyAccountPropPageProc(HWND hwndPropPage, UINT uiMsg, WPARAM wParam, LPARAM lParam)
+{
+	VULTURE_ACCOUNT *lpvac;
+
+	switch(uiMsg)
+	{
+	case WM_INITDIALOG:
+		{
+			int iUseProxyID = IDC_RADIO_USEPROXY_OVERRIDE, iProxyTypeID = IDC_RADIO_PROXYTYPE_HTTP;
+
+			lpvac = (VULTURE_ACCOUNT*)((PROPSHEETPAGE*)lParam)->lParam;
+			SetWindowLongPtr(hwndPropPage, GWLP_USERDATA, (LONG_PTR)lpvac);
+
+			switch(lpvac->proxy.proxytype)
+			{
+			case PURPLE_PROXY_USE_GLOBAL:
+				iUseProxyID = IDC_RADIO_USEPROXY_GLOBAL;
+				break;
+
+			case PURPLE_PROXY_NONE:
+				iUseProxyID = IDC_RADIO_USEPROXY_NONE;
+				break;
+
+			case PURPLE_PROXY_USE_ENVVAR:
+				iUseProxyID = IDC_RADIO_USEPROXY_SYSTEM;
+				break;
+
+			case PURPLE_PROXY_SOCKS4:
+				iProxyTypeID = IDC_RADIO_PROXYTYPE_SOCKS4;
+				break;
+
+			case PURPLE_PROXY_SOCKS5:
+				iProxyTypeID = IDC_RADIO_PROXYTYPE_SOCKS5;
+				break;
+
+			default:
+				break;
+			}
+
+			CheckRadioButton(hwndPropPage, IDC_RADIO_USEPROXY_GLOBAL, IDC_RADIO_USEPROXY_OVERRIDE, iUseProxyID);
+			CheckRadioButton(hwndPropPage, IDC_RADIO_PROXYTYPE_HTTP, IDC_RADIO_PROXYTYPE_SOCKS5, iProxyTypeID);
+
+			if(lpvac->proxy.szHost) SetDlgItemText(hwndPropPage, IDC_EDIT_HOST, lpvac->proxy.szHost);
+			if(lpvac->proxy.szUsername) SetDlgItemText(hwndPropPage, IDC_EDIT_USERNAME, lpvac->proxy.szUsername);
+			if(lpvac->proxy.szPassword) SetDlgItemText(hwndPropPage, IDC_EDIT_PASSWORD, lpvac->proxy.szPassword);
+			SetDlgItemInt(hwndPropPage, IDC_EDIT_PORT, lpvac->proxy.iPort, FALSE);
+
+			EnableDisableProxyControls(hwndPropPage);
+		}
+
+		/* Let the system set the focus. */
+		return TRUE;
+
+	case WM_COMMAND:
+		switch(LOWORD(wParam))
+		{
+		case IDC_RADIO_USEPROXY_GLOBAL:
+		case IDC_RADIO_USEPROXY_NONE:
+		case IDC_RADIO_USEPROXY_SYSTEM:
+		case IDC_RADIO_USEPROXY_OVERRIDE:
+			EnableDisableProxyControls(hwndPropPage);
+			return TRUE;
+		}
+
+		break;
+
+	case WM_NOTIFY:
+		if(((LPNMHDR)lParam)->code == PSN_APPLY)
+		{
+			VULTURE_ACCOUNT *lpvac = (VULTURE_ACCOUNT*)GetWindowLongPtr(hwndPropPage, GWLP_USERDATA);
+			int cch;
+			HWND hwndEdit;
+
+			if(IsDlgButtonChecked(hwndPropPage, IDC_RADIO_USEPROXY_GLOBAL))
+				lpvac->proxy.proxytype = PURPLE_PROXY_USE_GLOBAL;
+			else if(IsDlgButtonChecked(hwndPropPage, IDC_RADIO_USEPROXY_NONE))
+				lpvac->proxy.proxytype = PURPLE_PROXY_NONE;
+			else if(IsDlgButtonChecked(hwndPropPage, IDC_RADIO_USEPROXY_SYSTEM))
+				lpvac->proxy.proxytype = PURPLE_PROXY_USE_ENVVAR;
+			else if(IsDlgButtonChecked(hwndPropPage, IDC_RADIO_PROXYTYPE_HTTP))
+				lpvac->proxy.proxytype = PURPLE_PROXY_HTTP;
+			else if(IsDlgButtonChecked(hwndPropPage, IDC_RADIO_PROXYTYPE_SOCKS4))
+				lpvac->proxy.proxytype = PURPLE_PROXY_SOCKS4;
+			else
+				lpvac->proxy.proxytype = PURPLE_PROXY_SOCKS5;
+
+			/* Username. */
+			g_free(lpvac->proxy.szUsername);
+			hwndEdit = GetDlgItem(hwndPropPage, IDC_EDIT_USERNAME);
+			cch = GetWindowTextLength(hwndEdit) + 1;
+			lpvac->proxy.szUsername = g_new(TCHAR, cch);
+			GetWindowText(hwndEdit, lpvac->proxy.szUsername, cch);
+
+			/* Password. */
+			g_free(lpvac->proxy.szPassword);
+			hwndEdit = GetDlgItem(hwndPropPage, IDC_EDIT_PASSWORD);
+			cch = GetWindowTextLength(hwndEdit) + 1;
+			lpvac->proxy.szPassword = g_new(TCHAR, cch);
+			GetWindowText(hwndEdit, lpvac->proxy.szPassword, cch);
+
+			/* Host. */
+			g_free(lpvac->proxy.szHost);
+			hwndEdit = GetDlgItem(hwndPropPage, IDC_EDIT_USERNAME);
+			cch = GetWindowTextLength(hwndEdit) + 1;
+			lpvac->proxy.szHost = g_new(TCHAR, cch);
+			GetWindowText(hwndEdit, lpvac->proxy.szHost, cch);
+
+			/* Port. */
+			lpvac->proxy.iPort = GetDlgItemInt(hwndPropPage, IDC_EDIT_PORT, NULL, FALSE);
+
+			SetWindowLongPtr(hwndPropPage, DWLP_MSGRESULT, PSNRET_NOERROR);
+			return TRUE;
+		}
+
+		break;
+	}
+
+	return FALSE;
+}
+
+
+/**
+ * Enables or disables the proxy configuration controls, according to the
+ * selected radio button.
+ *
+ * @param	hwndPropPage	Window handle for proxy property page.
+ */
+static void EnableDisableProxyControls(HWND hwndPropPage)
+{
+	BOOL bEnable = IsDlgButtonChecked(hwndPropPage, IDC_RADIO_USEPROXY_OVERRIDE);
+
+	EnableWindow(GetDlgItem(hwndPropPage, IDC_RADIO_PROXYTYPE_HTTP), bEnable);
+	EnableWindow(GetDlgItem(hwndPropPage, IDC_RADIO_PROXYTYPE_SOCKS4), bEnable);
+	EnableWindow(GetDlgItem(hwndPropPage, IDC_RADIO_PROXYTYPE_SOCKS5), bEnable);
+	EnableWindow(GetDlgItem(hwndPropPage, IDC_EDIT_HOST), bEnable);
+	EnableWindow(GetDlgItem(hwndPropPage, IDC_EDIT_PORT), bEnable);
+	EnableWindow(GetDlgItem(hwndPropPage, IDC_EDIT_USERNAME), bEnable);
+	EnableWindow(GetDlgItem(hwndPropPage, IDC_EDIT_PASSWORD), bEnable);
+}
============================================================
--- vulture/acctmanager.h	31eeb2594b2c63a3161f11030e19e76111e40564
+++ vulture/acctmanager.h	4f86840517791314000c40a9d5bfbf3d3ce053ce
@@ -47,6 +47,15 @@ typedef struct _VULTURE_ACCOUNT
 	LPCVOID			lpvOrigBIcon;
 	DWORD			cbOrigBIcon;
 
+	struct
+	{
+		PurpleProxyType	proxytype;
+		LPTSTR		szHost;
+		int		iPort;
+		LPTSTR		szUsername;
+		LPTSTR		szPassword;
+	} proxy;
+
 	/* Indicates that previous buddy icon should be preserved if szBIcon is
 	 * NULL.
 	 */
============================================================
--- vulture/purpleacct.c	d66e760cb29c00a8cf79e712e29290025b5986c6
+++ vulture/purpleacct.c	da204d0379d90653cddf9a824139fa9c35d9dba5
@@ -54,6 +54,7 @@ void PurpleGetAccounts(BOOL bOnlineOnly,
 			const gchar *szAlias;
 			PurplePlugin *lppluginPrpl;
 			PurplePluginProtocolInfo *lpprplinfo;
+			PurpleProxyInfo *lpproxyinfo;
 
 			lpvac->lppac = (PurpleAccount*)lpglistPurpleAcc->data;
 			lpvac->bEnabled = purple_account_get_enabled(lpvac->lppac, VULTURE_ID);
@@ -112,6 +113,23 @@ void PurpleGetAccounts(BOOL bOnlineOnly,
 				}
 			}
 
+			if((lpproxyinfo = purple_account_get_proxy_info(lpvac->lppac)))
+			{
+				lpvac->proxy.proxytype = purple_proxy_info_get_type(lpproxyinfo);
+				lpvac->proxy.szHost = VultureUTF8ToTCHAR(purple_proxy_info_get_host(lpproxyinfo));
+				lpvac->proxy.szUsername = VultureUTF8ToTCHAR(purple_proxy_info_get_username(lpproxyinfo));
+				lpvac->proxy.szPassword = VultureUTF8ToTCHAR(purple_proxy_info_get_password(lpproxyinfo));
+				lpvac->proxy.iPort = purple_proxy_info_get_port(lpproxyinfo);
+			}
+			else
+			{
+				lpvac->proxy.proxytype = PURPLE_PROXY_USE_GLOBAL;
+				lpvac->proxy.szHost = NULL;
+				lpvac->proxy.szUsername = NULL;
+				lpvac->proxy.szPassword = NULL;
+				lpvac->proxy.iPort = 0;
+			}			
+
 			lpvac->bConnected = purple_account_is_connected(lpvac->lppac);
 
 			*lplpglistAccounts = g_list_prepend(*lplpglistAccounts, lpvac);
@@ -140,6 +158,9 @@ void VultureFreeAccountList(GList *lpgli
 		g_free(lpvac->szPassword);
 		g_free(lpvac->szAlias);
 		g_free(lpvac->szBIcon);
+		g_free(lpvac->proxy.szHost);
+		g_free(lpvac->proxy.szUsername);
+		g_free(lpvac->proxy.szPassword);
 		if(lpvac->lpstoredimgOrigBIcon) purple_imgstore_unref(lpvac->lpstoredimgOrigBIcon);
 		g_free(lpvac);
 	}
@@ -208,6 +229,23 @@ void PurpleApplyVultureAccount(VULTURE_A
 		}
 	}
 
+	/* Set proxy, using specifics if anything set, or to NULL otherwise. */
+	if(lpvac->proxy.proxytype != PURPLE_PROXY_USE_GLOBAL ||
+		lpvac->proxy.szHost || lpvac->proxy.szUsername || lpvac->proxy.szPassword ||
+		lpvac->proxy.iPort != 0)
+	{
+		PurpleProxyInfo *lpproxyinfo = purple_proxy_info_new();
+		purple_account_set_proxy_info(lpvac->lppac, lpproxyinfo);
+
+		purple_proxy_info_set_type(lpproxyinfo, lpvac->proxy.proxytype);
+		purple_proxy_info_set_host(lpproxyinfo, VultureTCHARToUTF8(lpvac->proxy.szHost));
+		purple_proxy_info_set_username(lpproxyinfo, VultureTCHARToUTF8(lpvac->proxy.szUsername));
+		purple_proxy_info_set_password(lpproxyinfo, VultureTCHARToUTF8(lpvac->proxy.szPassword));
+		purple_proxy_info_set_port(lpproxyinfo, lpvac->proxy.iPort);
+	}
+	else
+		purple_account_set_proxy_info(lpvac->lppac, NULL);
+
 	purple_account_set_enabled(lpvac->lppac, VULTURE_ID, lpvac->bEnabled);
 }
 
============================================================
--- vulture/resource.h	8c8681b15cb43ff007e37603950af127abef55ad
+++ vulture/resource.h	052a2c994fd8d762eaa82549259d124335e5912b
@@ -59,6 +59,15 @@
 #define IDC_EDIT_PASSWORD		1031
 #define IDC_STATIC_BICON		1032
 #define IDC_STATIC_PROTOCOL		1033
+#define IDC_RADIO_USEPROXY_GLOBAL	1034
+#define IDC_RADIO_USEPROXY_NONE		1035
+#define IDC_RADIO_USEPROXY_SYSTEM	1036
+#define IDC_RADIO_USEPROXY_OVERRIDE	1037
+#define IDC_RADIO_PROXYTYPE_HTTP	1038
+#define IDC_RADIO_PROXYTYPE_SOCKS4	1039
+#define IDC_RADIO_PROXYTYPE_SOCKS5	1040
+#define IDC_EDIT_HOST			1041
+#define IDC_EDIT_PORT			1042
 
 
 
@@ -75,6 +84,7 @@
 #define IDD_ADDGROUP			111
 #define IDD_CHATPROPERTIES		112
 #define IDD_ACCOUNTPROP_ACCOUNT		113
+#define IDD_ACCOUNTPROP_PROXY		114
 
 
 #define IDM_BLIST			1001
============================================================
--- vulture/vulture-res.rc	06715c1aa6b83e175e70aff6d95b0e4e7c3a7ed6
+++ vulture/vulture-res.rc	fbc97e36a8625ed888ae0735c54b1d7fb7c164c1
@@ -206,6 +206,34 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_U
 
 
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+IDD_ACCOUNTPROP_PROXY DIALOG 0, 0, 248, 233
+STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
+CAPTION "Proxy"
+FONT 8, "Ms Shell Dlg"
+{
+	LTEXT		"Specific proxy options can be configured for each account.", IDC_STATIC, 5, 4, 241, 10, SS_LEFT
+	AUTORADIOBUTTON	"Use &global proxy settings", IDC_RADIO_USEPROXY_GLOBAL, 15, 20, 230, 10, WS_GROUP
+	AUTORADIOBUTTON	"&Don't use a proxy", IDC_RADIO_USEPROXY_NONE, 15, 35, 230, 10
+	AUTORADIOBUTTON	"Use &system proxy settings", IDC_RADIO_USEPROXY_SYSTEM, 15, 50, 230, 10
+	AUTORADIOBUTTON	"Use the pro&xy settings below", IDC_RADIO_USEPROXY_OVERRIDE, 15, 65, 230, 10
+	GROUPBOX	"Proxy configuration", IDC_STATIC, 5, 85, 240, 145
+	LTEXT		"Proxy type:", IDC_STATIC, 15, 100, 225, 10, SS_LEFT
+	AUTORADIOBUTTON  "&HTTP", IDC_RADIO_PROXYTYPE_HTTP, 25, 115, 215, 10, WS_GROUP
+	AUTORADIOBUTTON	"SOCKS&4", IDC_RADIO_PROXYTYPE_SOCKS4, 25, 130, 215, 10
+	AUTORADIOBUTTON	"SOCKS&5", IDC_RADIO_PROXYTYPE_SOCKS5, 25, 145, 215, 10
+	LTEXT		"Hos&t:", IDC_STATIC, 15, 167, 60, 8, SS_LEFT
+	EDITTEXT	IDC_EDIT_HOST, 85, 165, 150, 12, ES_AUTOHSCROLL
+	LTEXT		"&Port:", IDC_STATIC, 15, 182, 60, 8, SS_LEFT
+	EDITTEXT	IDC_EDIT_PORT, 85, 180, 150, 12, ES_AUTOHSCROLL | ES_NUMBER
+	LTEXT		"&Username:", IDC_STATIC, 15, 197, 60, 8, SS_LEFT
+	EDITTEXT	IDC_EDIT_USERNAME, 85, 195, 150, 12, ES_AUTOHSCROLL
+	LTEXT		"Pass&word:", IDC_STATIC, 15, 212, 60, 8, SS_LEFT
+	EDITTEXT	IDC_EDIT_PASSWORD, 85, 210, 150, 12, ES_AUTOHSCROLL | ES_PASSWORD
+}
+
+
+
+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


More information about the Commits mailing list