summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-09-19 15:37:14 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-09-19 15:37:14 +0300
commitf10190b71550e7129e6b3ac163fc39f8c1349ffa (patch)
treebbb6806bddfb891230ee9a6b33aa3ce106b084f5
parent835555b9555f43be50582c4be774d65fe69fbe4d (diff)
fixes #2069 (Plugin Updater: add "enable HTTPS" option)
-rw-r--r--plugins/PluginUpdater/res/Resource.rc21
-rw-r--r--plugins/PluginUpdater/src/Options.cpp87
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp1
-rw-r--r--plugins/PluginUpdater/src/resource.h1
-rw-r--r--plugins/PluginUpdater/src/stdafx.h10
-rw-r--r--plugins/PluginUpdater/src/version.h2
6 files changed, 68 insertions, 54 deletions
diff --git a/plugins/PluginUpdater/res/Resource.rc b/plugins/PluginUpdater/res/Resource.rc
index 7ceb047664..03c99f4c0b 100644
--- a/plugins/PluginUpdater/res/Resource.rc
+++ b/plugins/PluginUpdater/res/Resource.rc
@@ -56,7 +56,7 @@ BEGIN
PUSHBUTTON "Select &none",IDC_SELNONE,175,218,60,14,NOT WS_TABSTOP
END
-IDD_OPT_UPDATENOTIFY DIALOGEX 0, 0, 301, 251
+IDD_OPT_UPDATENOTIFY DIALOGEX 0, 0, 301, 260
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
@@ -74,17 +74,18 @@ BEGIN
CONTROL "Silent mode",IDC_SILENTMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,72,267,10
CONTROL "Backup database before update (requires Db_autobackups plugin)",IDC_BACKUP,
"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,11,86,272,10
- GROUPBOX "Files source",IDC_STATIC,2,104,285,121
+ GROUPBOX "Files source",IDC_STATIC,2,104,285,132
CONTROL "Stable version",IDC_STABLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,117,267,10
CONTROL "Stable version with debug symbols",IDC_STABLE_SYMBOLS,
- "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,132,267,10
- CONTROL "Development version (less stable)",IDC_TRUNK,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,147,267,10
+ "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,131,267,10
+ CONTROL "Development version (less stable)",IDC_TRUNK,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,145,267,10
CONTROL "Development version with debug symbols",IDC_TRUNK_SYMBOLS,
- "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,162,267,10
- CONTROL "Custom version",IDC_CUSTOM,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,177,267,10
- EDITTEXT IDC_CUSTOMURL,12,190,267,16,ES_AUTOHSCROLL | WS_DISABLED
- CONTROL "Change platform to 32-bit",IDC_CHANGE_PLATFORM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,211,212,10
- CTEXT "Some component(s) was updated.\nYou need to restart your Miranda to apply installed updates.",IDC_NEEDRESTARTLABEL,11,228,267,15,NOT WS_VISIBLE
+ "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,159,267,10
+ CONTROL "Custom version",IDC_CUSTOM,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,173,267,10
+ EDITTEXT IDC_CUSTOMURL,12,185,267,16,ES_AUTOHSCROLL | WS_DISABLED
+ CONTROL "Change platform to 32-bit",IDC_CHANGE_PLATFORM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,206,267,10
+ CTEXT "Some component(s) was updated.\nYou need to restart your Miranda to apply installed updates.",IDC_NEEDRESTARTLABEL,11,239,267,15,NOT WS_VISIBLE
+ CONTROL "Use HTTPS",IDC_USE_HTTPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,219,267,10
END
IDD_POPUP DIALOGEX 0, 0, 316, 174
@@ -185,7 +186,7 @@ BEGIN
VERTGUIDE, 11
VERTGUIDE, 278
VERTGUIDE, 286
- BOTTOMMARGIN, 243
+ BOTTOMMARGIN, 254
END
IDD_POPUP, DIALOG
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>