diff options
author | George Hazan <ghazan@miranda.im> | 2019-09-19 15:37:14 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-09-19 15:37:14 +0300 |
commit | f10190b71550e7129e6b3ac163fc39f8c1349ffa (patch) | |
tree | bbb6806bddfb891230ee9a6b33aa3ce106b084f5 /plugins/PluginUpdater/src/Options.cpp | |
parent | 835555b9555f43be50582c4be774d65fe69fbe4d (diff) |
fixes #2069 (Plugin Updater: add "enable HTTPS" option)
Diffstat (limited to 'plugins/PluginUpdater/src/Options.cpp')
-rw-r--r-- | plugins/PluginUpdater/src/Options.cpp | 87 |
1 files changed, 49 insertions, 38 deletions
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index cbcc8f5890..acee0c5a49 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -19,11 +19,37 @@ Boston, MA 02111-1307, USA. #include "stdafx.h"
+static const wchar_t* GetHttps(HWND hwndDlg)
+{
+ return IsDlgButtonChecked(hwndDlg, IDC_USE_HTTPS) ? L"https" : L"http";
+}
+
static int GetBits(HWND hwndDlg)
{
return IsDlgButtonChecked(hwndDlg, IDC_CHANGE_PLATFORM) ? DEFAULT_OPP_BITS : DEFAULT_BITS;
}
+static void UpdateUrl(HWND hwndDlg)
+{
+ wchar_t defurl[MAX_PATH];
+ if (IsDlgButtonChecked(hwndDlg, IDC_STABLE)) {
+ mir_snwprintf(defurl, DEFAULT_UPDATE_URL, GetHttps(hwndDlg), GetBits(hwndDlg));
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
+ }
+ else if (IsDlgButtonChecked(hwndDlg, IDC_STABLE_SYMBOLS)) {
+ mir_snwprintf(defurl, DEFAULT_UPDATE_URL_STABLE_SYMBOLS, GetHttps(hwndDlg), GetBits(hwndDlg));
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
+ }
+ else if (IsDlgButtonChecked(hwndDlg, IDC_TRUNK)) {
+ mir_snwprintf(defurl, DEFAULT_UPDATE_URL_TRUNK, GetHttps(hwndDlg), GetBits(hwndDlg));
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
+ }
+ else if (IsDlgButtonChecked(hwndDlg, IDC_TRUNK_SYMBOLS)) {
+ mir_snwprintf(defurl, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS, GetHttps(hwndDlg), GetBits(hwndDlg));
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
+ }
+}
+
static int GetUpdateMode()
{
int UpdateMode = g_plugin.getByte(DB_SETTING_UPDATE_MODE, -1);
@@ -50,19 +76,22 @@ static int GetUpdateMode() wchar_t* GetDefaultUrl()
{
+ int bits = g_plugin.bChangePlatform ? DEFAULT_OPP_BITS : DEFAULT_BITS;
+ const wchar_t *pwszProto = g_plugin.bUseHttps ? L"https" : L"http";
+
wchar_t url[MAX_PATH];
switch (GetUpdateMode()) {
case UPDATE_MODE_STABLE:
- mir_snwprintf(url, DEFAULT_UPDATE_URL, g_plugin.bChangePlatform ? DEFAULT_OPP_BITS : DEFAULT_BITS);
+ mir_snwprintf(url, DEFAULT_UPDATE_URL, pwszProto, bits);
return mir_wstrdup(url);
case UPDATE_MODE_STABLE_SYMBOLS:
- mir_snwprintf(url, DEFAULT_UPDATE_URL_STABLE_SYMBOLS, g_plugin.bChangePlatform ? DEFAULT_OPP_BITS : DEFAULT_BITS);
+ mir_snwprintf(url, DEFAULT_UPDATE_URL_STABLE_SYMBOLS, pwszProto, bits);
return mir_wstrdup(url);
case UPDATE_MODE_TRUNK:
- mir_snwprintf(url, DEFAULT_UPDATE_URL_TRUNK, g_plugin.bChangePlatform ? DEFAULT_OPP_BITS : DEFAULT_BITS);
+ mir_snwprintf(url, DEFAULT_UPDATE_URL_TRUNK, pwszProto, bits);
return mir_wstrdup(url);
case UPDATE_MODE_TRUNK_SYMBOLS:
- mir_snwprintf(url, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS, g_plugin.bChangePlatform ? DEFAULT_OPP_BITS : DEFAULT_BITS);
+ mir_snwprintf(url, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS, pwszProto, bits);
return mir_wstrdup(url);
default:
return g_plugin.getWStringA(DB_SETTING_UPDATE_URL);
@@ -73,8 +102,6 @@ wchar_t* GetDefaultUrl() static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- wchar_t defurl[MAX_PATH];
-
switch (msg) {
case WM_INITDIALOG:
if (g_plugin.bUpdateOnStartup) {
@@ -82,6 +109,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), TRUE);
}
+ CheckDlgButton(hwndDlg, IDC_USE_HTTPS, g_plugin.bUseHttps ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ONLYONCEADAY, g_plugin.bOnlyOnceADay ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHANGE_PLATFORM, g_plugin.bChangePlatform ? BST_CHECKED : BST_UNCHECKED);
@@ -123,24 +151,20 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar switch (GetUpdateMode()) {
case UPDATE_MODE_STABLE:
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
CheckDlgButton(hwndDlg, IDC_STABLE, BST_CHECKED);
+ UpdateUrl(hwndDlg);
break;
case UPDATE_MODE_STABLE_SYMBOLS:
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL_STABLE_SYMBOLS, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
CheckDlgButton(hwndDlg, IDC_STABLE_SYMBOLS, BST_CHECKED);
+ UpdateUrl(hwndDlg);
break;
case UPDATE_MODE_TRUNK:
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL_TRUNK, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
CheckDlgButton(hwndDlg, IDC_TRUNK, BST_CHECKED);
+ UpdateUrl(hwndDlg);
break;
case UPDATE_MODE_TRUNK_SYMBOLS:
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
CheckDlgButton(hwndDlg, IDC_TRUNK_SYMBOLS, BST_CHECKED);
+ UpdateUrl(hwndDlg);
break;
default:
CheckDlgButton(hwndDlg, IDC_CUSTOM, BST_CHECKED);
@@ -189,32 +213,28 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar case IDC_TRUNK_SYMBOLS:
EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE);
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
+ UpdateUrl(hwndDlg);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_TRUNK:
EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE);
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL_TRUNK, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
+ UpdateUrl(hwndDlg);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_STABLE:
EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE);
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
+ UpdateUrl(hwndDlg);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case IDC_STABLE_SYMBOLS:
EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), FALSE);
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL_STABLE_SYMBOLS, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
+ UpdateUrl(hwndDlg);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -230,6 +250,11 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
+ case IDC_USE_HTTPS:
+ UpdateUrl(hwndDlg);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
case IDC_PERIOD:
case IDC_CUSTOMURL:
if ((HWND)lParam == GetFocus() && (HIWORD(wParam) == EN_CHANGE))
@@ -242,22 +267,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar break;
case IDC_CHANGE_PLATFORM:
- if (IsDlgButtonChecked(hwndDlg, IDC_STABLE)) {
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
- }
- else if (IsDlgButtonChecked(hwndDlg, IDC_STABLE_SYMBOLS)) {
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL_STABLE_SYMBOLS, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
- }
- else if (IsDlgButtonChecked(hwndDlg, IDC_TRUNK)) {
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL_TRUNK, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
- }
- else if (IsDlgButtonChecked(hwndDlg, IDC_TRUNK_SYMBOLS)) {
- mir_snwprintf(defurl, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS, GetBits(hwndDlg));
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, defurl);
- }
+ UpdateUrl(hwndDlg);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -279,6 +289,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar g_plugin.setByte("UpdateOnPeriod", g_plugin.bUpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD));
g_plugin.setByte("PeriodMeasure", g_plugin.iPeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE)));
g_plugin.setByte("SilentMode", g_plugin.bSilentMode = IsDlgButtonChecked(hwndDlg, IDC_SILENTMODE));
+ g_plugin.setByte("UseHttps", g_plugin.bUseHttps = IsDlgButtonChecked(hwndDlg, IDC_USE_HTTPS));
g_plugin.setByte("Backup", g_plugin.bBackup = IsDlgButtonChecked(hwndDlg, IDC_BACKUP));
wchar_t buffer[3] = { 0 };
Edit_GetText(GetDlgItem(hwndDlg, IDC_PERIOD), buffer, _countof(buffer));
|