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 | |
parent | 835555b9555f43be50582c4be774d65fe69fbe4d (diff) |
fixes #2069 (Plugin Updater: add "enable HTTPS" option)
Diffstat (limited to 'plugins/PluginUpdater/src')
-rw-r--r-- | plugins/PluginUpdater/src/Options.cpp | 87 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 1 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/resource.h | 1 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/stdafx.h | 10 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/version.h | 2 |
5 files changed, 57 insertions, 44 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));
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 1f0a35f304..f45ca7db3e 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -36,6 +36,7 @@ void LoadOptions() g_plugin.bUpdateOnPeriod = g_plugin.getBool("UpdateOnPeriod", false);
g_plugin.bForceRedownload = g_plugin.getBool(DB_SETTING_REDOWNLOAD, false);
g_plugin.bSilentMode = g_plugin.getBool("SilentMode", false);
+ g_plugin.bUseHttps = g_plugin.getBool("UseHttps", true);
g_plugin.bBackup = g_plugin.getBool("Backup", false);
g_plugin.bChangePlatform = g_plugin.getBool(DB_SETTING_CHANGEPLATFORM, false);
diff --git a/plugins/PluginUpdater/src/resource.h b/plugins/PluginUpdater/src/resource.h index b8c9fc1f07..44449ad4bb 100644 --- a/plugins/PluginUpdater/src/resource.h +++ b/plugins/PluginUpdater/src/resource.h @@ -51,6 +51,7 @@ #define IDC_NEEDRESTARTLABEL 1048
#define IDC_BACKUP 1049
#define IDC_STABLE_SYMBOLS 1050
+#define IDC_USE_HTTPS 1051
#define IDC_CHANGE_PLATFORM 1052
#define IDC_SEARCH 1053
#define IDC_MSG_BOXES 40071
diff --git a/plugins/PluginUpdater/src/stdafx.h b/plugins/PluginUpdater/src/stdafx.h index be48a02b44..f7a03e8ce2 100644 --- a/plugins/PluginUpdater/src/stdafx.h +++ b/plugins/PluginUpdater/src/stdafx.h @@ -91,10 +91,10 @@ struct FILEINFO typedef OBJLIST<FILEINFO> FILELIST;
-#define DEFAULT_UPDATE_URL L"https://miranda-ng.org/distr/stable/x%d"
-#define DEFAULT_UPDATE_URL_TRUNK L"https://miranda-ng.org/distr/x%d"
-#define DEFAULT_UPDATE_URL_TRUNK_SYMBOLS L"https://miranda-ng.org/distr/pdb_x%d"
-#define DEFAULT_UPDATE_URL_STABLE_SYMBOLS L"https://miranda-ng.org/distr/stable/pdb_x%d"
+#define DEFAULT_UPDATE_URL L"%s://miranda-ng.org/distr/stable/x%d"
+#define DEFAULT_UPDATE_URL_TRUNK L"%s://miranda-ng.org/distr/x%d"
+#define DEFAULT_UPDATE_URL_TRUNK_SYMBOLS L"%s://miranda-ng.org/distr/pdb_x%d"
+#define DEFAULT_UPDATE_URL_STABLE_SYMBOLS L"%s://miranda-ng.org/distr/stable/pdb_x%d"
#define FILENAME_X64 L"miranda64.exe"
#define FILENAME_X32 L"miranda32.exe"
@@ -162,7 +162,7 @@ struct CMPlugin : public PLUGIN<CMPlugin> int Unload() override;
// common options
- bool bUpdateOnStartup, bUpdateOnPeriod, bOnlyOnceADay, bForceRedownload, bSilentMode, bBackup, bChangePlatform, bSilent;
+ bool bUpdateOnStartup, bUpdateOnPeriod, bOnlyOnceADay, bForceRedownload, bSilentMode, bBackup, bChangePlatform, bSilent, bUseHttps;
int iPeriod, iPeriodMeasure;
// popup options
diff --git a/plugins/PluginUpdater/src/version.h b/plugins/PluginUpdater/src/version.h index 2361e95ca1..cb66144643 100644 --- a/plugins/PluginUpdater/src/version.h +++ b/plugins/PluginUpdater/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 2 #define __RELEASE_NUM 0 -#define __BUILD_NUM 4 +#define __BUILD_NUM 5 #include <stdver.h> |