diff options
Diffstat (limited to 'plugins/PluginUpdater')
-rw-r--r-- | plugins/PluginUpdater/res/Resource.rc | 65 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgUpdate.cpp | 35 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Notifications.cpp | 50 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Notifications.h | 2 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Options.cpp | 148 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/PluginUpdater.cpp | 26 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 19 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/resource.h | 24 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/stdafx.h | 14 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/version.h | 2 |
10 files changed, 168 insertions, 217 deletions
diff --git a/plugins/PluginUpdater/res/Resource.rc b/plugins/PluginUpdater/res/Resource.rc index 03c99f4c0b..7f58df1125 100644 --- a/plugins/PluginUpdater/res/Resource.rc +++ b/plugins/PluginUpdater/res/Resource.rc @@ -61,31 +61,29 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Hotkey",IDC_STATIC,2,0,284,26
- CONTROL "Go to Options -> Customize -> Hotkeys to change the hotkey",IDC_LINK_HOTKEY,
- "Hyperlink",WS_TABSTOP,29,11,249,10
- GROUPBOX "Update options",IDC_STATIC,1,29,285,73
- CONTROL "On startup",IDC_UPDATEONSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,44,73,10
- CONTROL "(but only once a day)",IDC_ONLYONCEADAY,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,92,44,186,10
- CONTROL "Every",IDC_UPDATEONPERIOD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,58,52,10
- EDITTEXT IDC_PERIOD,65,56,28,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
- CONTROL "",IDC_PERIODSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,92,56,10,15
- COMBOBOX IDC_PERIODMEASURE,114,56,58,30,CBS_DROPDOWNLIST | CBS_SORT | WS_DISABLED | WS_VSCROLL | WS_TABSTOP
- CONTROL "Silent mode",IDC_SILENTMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,72,267,10
+ GROUPBOX "Update options",IDC_STATIC,1,3,285,89
+ CONTROL "On startup",IDC_UPDATEONSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,18,73,10
+ CONTROL "(but only once a day)",IDC_ONLYONCEADAY,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,92,18,186,10
+ CONTROL "Every",IDC_UPDATEONPERIOD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,32,52,10
+ EDITTEXT IDC_PERIOD,65,30,28,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
+ CONTROL "",IDC_PERIODSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,92,30,10,14
+ COMBOBOX IDC_PERIODMEASURE,114,30,58,30,CBS_DROPDOWNLIST | CBS_SORT | WS_DISABLED | WS_VSCROLL | WS_TABSTOP
+ CONTROL "Silent mode",IDC_SILENTMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,46,267,10
+ CONTROL "Restart Miranda automatically",IDC_AUTORESTART,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,60,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,132
- CONTROL "Stable version",IDC_STABLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,117,267,10
+ "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,11,74,272,10
+ GROUPBOX "Files source",IDC_STATIC,2,94,285,132
+ CONTROL "Stable version",IDC_STABLE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,107,267,10
CONTROL "Stable version with debug symbols",IDC_STABLE_SYMBOLS,
- "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
+ "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,121,267,10
+ CONTROL "Development version (less stable)",IDC_TRUNK,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,135,267,10
CONTROL "Development version with debug symbols",IDC_TRUNK_SYMBOLS,
- "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
+ "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,149,267,10
+ CONTROL "Custom version",IDC_CUSTOM,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,163,267,10
+ EDITTEXT IDC_CUSTOMURL,12,175,267,16,ES_AUTOHSCROLL | WS_DISABLED
+ CONTROL "Change platform to 32-bit",IDC_CHANGE_PLATFORM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,196,267,10
+ CONTROL "Use HTTPS",IDC_USE_HTTPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,209,267,10
+ CTEXT "Some component(s) was updated.\nYou need to restart your Miranda to apply installed updates.",IDC_NEEDRESTARTLABEL,11,229,267,15,NOT WS_VISIBLE
END
IDD_POPUP DIALOGEX 0, 0, 316, 174
@@ -182,34 +180,11 @@ BEGIN BEGIN
LEFTMARGIN, 1
RIGHTMARGIN, 294
- VERTGUIDE, 2
- VERTGUIDE, 11
- VERTGUIDE, 278
- VERTGUIDE, 286
BOTTOMMARGIN, 254
END
- IDD_POPUP, DIALOG
- BEGIN
- VERTGUIDE, 1
- VERTGUIDE, 7
- VERTGUIDE, 86
- VERTGUIDE, 90
- VERTGUIDE, 114
- VERTGUIDE, 116
- VERTGUIDE, 140
- VERTGUIDE, 153
- VERTGUIDE, 169
- VERTGUIDE, 173
- VERTGUIDE, 178
- VERTGUIDE, 186
- VERTGUIDE, 311
- END
-
IDD_MISSINGPLUGINS, DIALOG
BEGIN
- VERTGUIDE, 6
- VERTGUIDE, 235
BOTTOMMARGIN, 245
END
END
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index be7728d691..3d558cfc54 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -146,22 +146,24 @@ static void ApplyUpdates(void *param) }
// 5) Prepare Restart
- int rc = MessageBox(hDlg, TranslateT("Update complete. Press Yes to restart Miranda now or No to postpone a restart until the exit."), TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION);
- PostMessage(hDlg, WM_CLOSE, 0, 0);
- if (rc == IDYES) {
- BOOL bRestartCurrentProfile = g_plugin.getByte("RestartCurrentProfile", 1) ? 1 : 0;
- if (g_plugin.bChangePlatform) {
- wchar_t mirstartpath[MAX_PATH];
+ if (!g_plugin.bAutoRestart)
+ if (IDYES != MessageBox(hDlg, TranslateT("Update complete. Press Yes to restart Miranda now or No to postpone a restart until the exit."), TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION)) {
+ PostMessage(hDlg, WM_CLOSE, 0, 0);
+ return;
+ }
+ PostMessage(hDlg, WM_CLOSE, 0, 0);
+ BOOL bRestartCurrentProfile = g_plugin.getBool("RestartCurrentProfile", true);
+ if (g_plugin.bChangePlatform) {
+ wchar_t mirstartpath[MAX_PATH];
#ifdef _WIN64
- mir_snwprintf(mirstartpath, L"%s\\miranda32.exe", tszMirandaPath.get());
+ mir_snwprintf(mirstartpath, L"%s\\miranda32.exe", tszMirandaPath.get());
#else
- mir_snwprintf(mirstartpath, L"%s\\miranda64.exe", tszMirandaPath.get());
+ mir_snwprintf(mirstartpath, L"%s\\miranda64.exe", tszMirandaPath.get());
#endif
- CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile, (LPARAM)mirstartpath);
- }
- else CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile);
+ CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile, (LPARAM)mirstartpath);
}
+ else CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile);
}
static void ResizeVert(HWND hDlg, int yy)
@@ -466,14 +468,9 @@ static void DlgUpdateSilent(void *param) if (Popup_Enabled())
ShowPopup(tszTitle, TranslateT("You need to restart your Miranda to apply installed updates."), POPUP_TYPE_MSG);
else {
- if (Clist_TrayNotifyW(MODULEA, tszTitle, TranslateT("You need to restart your Miranda to apply installed updates."), NIIF_INFO, 30000)) {
+ if (Clist_TrayNotifyW(MODULEA, tszTitle, TranslateT("You need to restart your Miranda to apply installed updates."), NIIF_INFO, 30000))
// Error, let's try to show MessageBox as last way to inform user about successful update
- wchar_t tszText[200];
- mir_snwprintf(tszText, L"%s\n\n%s", TranslateT("You need to restart your Miranda to apply installed updates."), TranslateT("Would you like to restart it now?"));
-
- if (MessageBox(nullptr, tszText, tszTitle, MB_ICONINFORMATION | MB_YESNO) == IDYES)
- CallServiceSync(MS_SYSTEM_RESTART, g_plugin.getByte("RestartCurrentProfile", 1) ? 1 : 0, 0);
- }
+ RestartPrompt(0);
}
}
@@ -867,7 +864,7 @@ static void CALLBACK TimerAPCProc(void *, DWORD, DWORD) DoCheck();
}
-static LONGLONG PeriodToMilliseconds(const int period, int &periodMeasure)
+static LONGLONG PeriodToMilliseconds(const int period, CMOption<int> &periodMeasure)
{
LONGLONG result = period * 1000LL;
switch (periodMeasure) {
diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp index 72285052fd..1c6cbe293c 100644 --- a/plugins/PluginUpdater/src/Notifications.cpp +++ b/plugins/PluginUpdater/src/Notifications.cpp @@ -19,35 +19,32 @@ Boston, MA 02111-1307, USA. #include "stdafx.h"
-aPopups PopupsList[POPUPS];
+aPopups PopupsList[POPUPS] =
+{
+ { IDC_MSG_BOXES, IDC_MSG_BOXES_TX, IDC_MSG_BOXES_BG, 0, 0 },
+ { IDC_ERRORS, IDC_ERR_TX, IDC_ERR_BG, 0, 0 },
+ { IDC_INFO_MESSAGES, IDC_INFO_MESSAGES_TX, IDC_INFO_MESSAGES_BG, 0, 0 }
+};
void InitPopupList()
{
- int index = 0;
- PopupsList[index].ID = index;
- PopupsList[index].colorBack = g_plugin.getDword("Popups0Bg", COLOR_BG_FIRSTDEFAULT);
- PopupsList[index].colorText = g_plugin.getDword("Popups0Tx", COLOR_TX_DEFAULT);
-
- index = 1;
- PopupsList[index].ID = index;
- PopupsList[index].colorBack = g_plugin.getDword("Popups1Bg", COLOR_BG_SECONDDEFAULT);
- PopupsList[index].colorText = g_plugin.getDword("Popups1Tx", COLOR_TX_DEFAULT);
-
- index = 2;
- PopupsList[index].ID = index;
- PopupsList[index].colorBack = g_plugin.getDword("Popups2Bg", COLOR_BG_FIRSTDEFAULT);
- PopupsList[index].colorText = g_plugin.getDword("Popups2Tx", COLOR_TX_DEFAULT);
+ PopupsList[0].colorBack = g_plugin.getDword("Popups0Bg", COLOR_BG_FIRSTDEFAULT);
+ PopupsList[0].colorText = g_plugin.getDword("Popups0Tx", COLOR_TX_DEFAULT);
+
+ PopupsList[1].colorBack = g_plugin.getDword("Popups1Bg", COLOR_BG_SECONDDEFAULT);
+ PopupsList[1].colorText = g_plugin.getDword("Popups1Tx", COLOR_TX_DEFAULT);
+
+ PopupsList[2].colorBack = g_plugin.getDword("Popups2Bg", COLOR_BG_FIRSTDEFAULT);
+ PopupsList[2].colorText = g_plugin.getDword("Popups2Tx", COLOR_TX_DEFAULT);
}
-void PopupAction(HWND hPopup, BYTE action)
+static void PopupAction(HWND hPopup, BYTE action)
{
switch (action) {
case PCA_CLOSEPOPUP:
+ PUDeletePopup(hPopup);
break;
- case PCA_DONOTHING:
- return;
}
- PUDeletePopup(hPopup);
}
static LRESULT CALLBACK PopupDlgProc(HWND hPopup, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -68,13 +65,16 @@ static LRESULT CALLBACK PopupDlgProc(HWND hPopup, UINT uMsg, WPARAM wParam, LPAR return DefWindowProc(hPopup, uMsg, wParam, lParam);
}
-static void _stdcall RestartPrompt(void *)
+void CALLBACK RestartPrompt(void *)
{
- wchar_t tszText[200];
- mir_snwprintf(tszText, L"%s\n\n%s", TranslateT("You need to restart your Miranda to apply installed updates."), TranslateT("Would you like to restart it now?"));
+ if (!g_plugin.bAutoRestart) {
+ wchar_t tszText[200];
+ mir_snwprintf(tszText, L"%s\n\n%s", TranslateT("You need to restart your Miranda to apply installed updates."), TranslateT("Would you like to restart it now?"));
+ if (MessageBox(nullptr, tszText, TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION | MB_TOPMOST) != IDYES)
+ return;
+ }
- if (MessageBox(nullptr, tszText, TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION | MB_TOPMOST) == IDYES)
- CallService(MS_SYSTEM_RESTART, g_plugin.getByte("RestartCurrentProfile", 1) ? 1 : 0, 0);
+ CallService(MS_SYSTEM_RESTART, g_plugin.getBool("RestartCurrentProfile", true), 0);
}
static LRESULT CALLBACK PopupDlgProcRestart(HWND hPopup, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -83,6 +83,7 @@ static LRESULT CALLBACK PopupDlgProcRestart(HWND hPopup, UINT uMsg, WPARAM wPara case WM_CONTEXTMENU:
PUDeletePopup(hPopup);
break;
+
case WM_COMMAND:
PUDeletePopup(hPopup);
CallFunctionAsync(RestartPrompt, nullptr);
@@ -137,3 +138,4 @@ void ShowPopup(LPCTSTR ptszTitle, LPCTSTR ptszText, int Number) if (Number == POPUP_TYPE_ERROR)
MessageBox(nullptr, ptszText, ptszTitle, MB_ICONINFORMATION);
}
+
diff --git a/plugins/PluginUpdater/src/Notifications.h b/plugins/PluginUpdater/src/Notifications.h index 3c3026f42e..26c9141925 100644 --- a/plugins/PluginUpdater/src/Notifications.h +++ b/plugins/PluginUpdater/src/Notifications.h @@ -23,7 +23,7 @@ Boston, MA 02111-1307, USA. struct aPopups
{
- int ID;
+ int ctrl1, ctrl2, ctrl3;
COLORREF colorBack;
COLORREF colorText;
};
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index 40177e91f7..8cc5bf781b 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -110,6 +110,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar }
CheckDlgButton(hwndDlg, IDC_USE_HTTPS, g_plugin.bUseHttps ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_AUTORESTART, g_plugin.bAutoRestart ? 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);
@@ -194,6 +195,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar EnableWindow(GetDlgItem(hwndDlg, IDC_ONLYONCEADAY), IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP));
__fallthrough;
+ case IDC_AUTORESTART:
case IDC_SILENTMODE:
case IDC_ONLYONCEADAY:
case IDC_BACKUP:
@@ -270,10 +272,6 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar UpdateUrl(hwndDlg);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
-
- case IDC_LINK_HOTKEY:
- g_plugin.openOptions(L"Customize", L"Hotkeys");
- return true;
}
break;
@@ -284,16 +282,18 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
if (hdr && hdr->code == PSN_APPLY) {
- g_plugin.setByte("UpdateOnStartup", g_plugin.bUpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP));
- g_plugin.setByte("OnlyOnceADay", g_plugin.bOnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY));
- 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));
+ g_plugin.bBackup = IsDlgButtonChecked(hwndDlg, IDC_BACKUP);
+ g_plugin.bUseHttps = IsDlgButtonChecked(hwndDlg, IDC_USE_HTTPS);
+ g_plugin.bSilentMode = IsDlgButtonChecked(hwndDlg, IDC_SILENTMODE);
+ g_plugin.bAutoRestart = IsDlgButtonChecked(hwndDlg, IDC_AUTORESTART);
+ g_plugin.bOnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY);
+ g_plugin.bUpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD);
+ g_plugin.bUpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP);
+ g_plugin.iPeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE));
+
wchar_t buffer[3] = { 0 };
Edit_GetText(GetDlgItem(hwndDlg, IDC_PERIOD), buffer, _countof(buffer));
- g_plugin.setDword("Period", g_plugin.iPeriod = _wtoi(buffer));
+ g_plugin.iPeriod = _wtoi(buffer);
InitTimer((void*)1);
@@ -379,21 +379,20 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM TranslateDialogDefault(hdlg);
//Colors
- if (g_plugin.PopupDefColors == byCOLOR_OWN) {
+ if (g_plugin.PopupDefColors == byCOLOR_OWN)
CheckDlgButton(hdlg, IDC_USEOWNCOLORS, BST_CHECKED);
- }
- else if (g_plugin.PopupDefColors == byCOLOR_WINDOWS) {
+ else if (g_plugin.PopupDefColors == byCOLOR_WINDOWS)
CheckDlgButton(hdlg, IDC_USEWINCOLORS, BST_CHECKED);
- }
- else if (g_plugin.PopupDefColors == byCOLOR_POPUP) {
+ else if (g_plugin.PopupDefColors == byCOLOR_POPUP)
CheckDlgButton(hdlg, IDC_USEPOPUPCOLORS, BST_CHECKED);
+
+ for (auto &it : PopupsList) {
+ SendDlgItemMessage(hdlg, it.ctrl2, CPM_SETCOLOUR, 0, it.colorText);
+ SendDlgItemMessage(hdlg, it.ctrl3, CPM_SETCOLOUR, 0, it.colorBack);
+ EnableWindow(GetDlgItem(hdlg, it.ctrl2), g_plugin.PopupDefColors == byCOLOR_OWN);
+ EnableWindow(GetDlgItem(hdlg, it.ctrl3), g_plugin.PopupDefColors == byCOLOR_OWN);
}
- for (int i = 0; i < POPUPS; i++) {
- SendDlgItemMessage(hdlg, (i + 42071), CPM_SETCOLOUR, 0, PopupsList[i].colorBack);
- SendDlgItemMessage(hdlg, (i + 41071), CPM_SETCOLOUR, 0, PopupsList[i].colorText);
- EnableWindow(GetDlgItem(hdlg, (i + 42071)), (g_plugin.PopupDefColors == byCOLOR_OWN));
- EnableWindow(GetDlgItem(hdlg, (i + 41071)), (g_plugin.PopupDefColors == byCOLOR_OWN));
- }
+
// Timeout
SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE, EM_LIMITTEXT, 4, 0);
SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, -1, 9999);
@@ -408,10 +407,10 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM SendDlgItemMessage(hdlg, IDC_RC, CB_SETCURSEL, g_plugin.PopupRightClickAction, 0);
//Popups notified
- for (int i = 0; i < POPUPS; i++) {
+ for (auto &it : PopupsList) {
char str[20] = { 0 };
- mir_snprintf(str, "Popups%d", i);
- CheckDlgButton(hdlg, (i + 40071), (g_plugin.getByte(str, DEFAULT_POPUP_ENABLED)) ? BST_CHECKED : BST_UNCHECKED);
+ mir_snprintf(str, "Popups%d", int(&it - PopupsList));
+ CheckDlgButton(hdlg, it.ctrl1, (g_plugin.getByte(str, DEFAULT_POPUP_ENABLED)) ? BST_CHECKED : BST_UNCHECKED);
}
return TRUE;
@@ -430,10 +429,6 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
return TRUE;
}
- if (idCtrl == IDC_LC)
- g_plugin.PopupLeftClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_LC, CB_GETCURSEL, 0, 0);
- else if (idCtrl == IDC_RC)
- g_plugin.PopupRightClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_RC, CB_GETCURSEL, 0, 0);
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
return TRUE;
@@ -443,11 +438,9 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM if (wNotifyCode != BN_CLICKED)
break;
- g_plugin.PopupDefColors = byCOLOR_OWN;
-
- for (int i = 0; i < POPUPS; i++) {
- EnableWindow(GetDlgItem(hdlg, (i + 42071)), TRUE); //Background
- EnableWindow(GetDlgItem(hdlg, (i + 41071)), TRUE); //Text
+ for (auto &it : PopupsList) {
+ EnableWindow(GetDlgItem(hdlg, it.ctrl2), TRUE); //Text
+ EnableWindow(GetDlgItem(hdlg, it.ctrl3), TRUE); //Background
}
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
break;
@@ -457,10 +450,9 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM break;
//Use Windows colors
- g_plugin.PopupDefColors = byCOLOR_WINDOWS;
- for (int i = 0; i < POPUPS; i++) {
- EnableWindow(GetDlgItem(hdlg, (i + 42071)), FALSE); //Background
- EnableWindow(GetDlgItem(hdlg, (i + 41071)), FALSE); //Text
+ for (auto &it : PopupsList) {
+ EnableWindow(GetDlgItem(hdlg, it.ctrl2), FALSE); //Text
+ EnableWindow(GetDlgItem(hdlg, it.ctrl3), FALSE); //Background
}
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
break;
@@ -470,10 +462,9 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM break;
//Use Popup colors
- g_plugin.PopupDefColors = byCOLOR_POPUP;
- for (int i = 0; i < POPUPS; i++) {
- EnableWindow(GetDlgItem(hdlg, (i + 42071)), FALSE); //Background
- EnableWindow(GetDlgItem(hdlg, (i + 41071)), FALSE); //Text
+ for (auto &it : PopupsList) {
+ EnableWindow(GetDlgItem(hdlg, it.ctrl2), FALSE); //Text
+ EnableWindow(GetDlgItem(hdlg, it.ctrl3), FALSE); //Background
}
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
break;
@@ -482,10 +473,9 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM {//Declarations and initializations
LPCTSTR Title = TranslateT("Plugin Updater");
LPCTSTR Text = TranslateT("Test");
- for (int i = 0; i < POPUPS; i++) {
- if (IsDlgButtonChecked(hdlg, i + 40071))
- ShowPopup(Title, Text, i);
- }
+ for (auto &it : PopupsList)
+ if (IsDlgButtonChecked(hdlg, it.ctrl1))
+ ShowPopup(Title, Text, int(&it - PopupsList));
}
break;
@@ -503,12 +493,6 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
break;
- case IDC_PROGR_DLG:
- EnableWindow(GetDlgItem(hdlg, IDC_PROGR_DLG_MSG), BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_PROGR_DLG));
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
- break;
-
case IDC_MSG_BOXES_MSG:
case IDC_ERRORS_MSG:
case IDC_INFO_MESSAGES_MSG:
@@ -524,45 +508,37 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM switch (((LPNMHDR)lParam)->code) {
case PSN_RESET:
//Restore the options stored in memory.
- LoadOptions();
InitPopupList();
return TRUE;
case PSN_APPLY:
- {
- //Text color
+ for (auto &it : PopupsList) {
+ int i = int(&it - PopupsList);
char szSetting[20] = { 0 };
- DWORD ctlColor = 0;
- for (int i = 0; i < POPUPS; i++) {
- ctlColor = SendDlgItemMessage(hdlg, (i + 42071), CPM_GETCOLOUR, 0, 0);
- PopupsList[i].colorBack = ctlColor;
- mir_snprintf(szSetting, "Popups%iBg", i);
- g_plugin.setDword(szSetting, ctlColor);
- ctlColor = SendDlgItemMessage(hdlg, (i + 41071), CPM_GETCOLOUR, 0, 0);
- PopupsList[i].colorText = ctlColor;
- mir_snprintf(szSetting, "Popups%iTx", i);
- g_plugin.setDword(szSetting, ctlColor);
- }
- //Colors
- g_plugin.setByte("DefColors", g_plugin.PopupDefColors);
- //Timeout
- g_plugin.PopupTimeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, nullptr, TRUE);
- g_plugin.setDword("Timeout", g_plugin.PopupTimeout);
- //Left mouse click
- g_plugin.setByte("LeftClickAction", g_plugin.PopupLeftClickAction);
- //Right mouse click
- g_plugin.setByte("RightClickAction", g_plugin.PopupRightClickAction);
- //Notified popups
- for (int i = 0; i < POPUPS; i++) {
- char str[20] = { 0 };
- mir_snprintf(str, "Popups%d", i);
- g_plugin.setByte(str, (BYTE)(IsDlgButtonChecked(hdlg, (i + 40071))));
- }
- return TRUE;
- } //case PSN_APPLY
- } // switch code
+ mir_snprintf(szSetting, "Popups%d", i);
+ g_plugin.setByte(szSetting, (BYTE)(IsDlgButtonChecked(hdlg, it.ctrl1)));
+
+ mir_snprintf(szSetting, "Popups%iTx", i);
+ g_plugin.setDword(szSetting, it.colorText = SendDlgItemMessage(hdlg, it.ctrl2, CPM_GETCOLOUR, 0, 0));
+
+ mir_snprintf(szSetting, "Popups%iBg", i);
+ g_plugin.setDword(szSetting, it.colorBack = SendDlgItemMessage(hdlg, it.ctrl3, CPM_GETCOLOUR, 0, 0));
+ }
+
+ g_plugin.PopupTimeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, nullptr, TRUE);
+ g_plugin.PopupLeftClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_LC, CB_GETCURSEL, 0, 0);
+ g_plugin.PopupRightClickAction = (BYTE)SendDlgItemMessage(hdlg, IDC_RC, CB_GETCURSEL, 0, 0);
+
+ if (IsDlgButtonChecked(hdlg, IDC_USEOWNCOLORS))
+ g_plugin.PopupDefColors = byCOLOR_OWN;
+ else if (IsDlgButtonChecked(hdlg, IDC_USEWINCOLORS))
+ g_plugin.PopupDefColors = byCOLOR_WINDOWS;
+ else
+ g_plugin.PopupDefColors = byCOLOR_POPUP;
+ return TRUE;
+ }
break; //End WM_NOTIFY
- } //switch message
+ }
return FALSE;
}
diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp index 5a4f6c3d8f..d9b136a83b 100644 --- a/plugins/PluginUpdater/src/PluginUpdater.cpp +++ b/plugins/PluginUpdater/src/PluginUpdater.cpp @@ -39,8 +39,29 @@ PLUGININFOEX pluginInfoEx = { };
CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
-{}
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
+
+ // popup options
+ PopupTimeout(MODULENAME, "Timeout", DEFAULT_TIMEOUT_VALUE),
+ PopupDefColors(MODULENAME, "DefColors", DEFAULT_COLORS),
+ PopupLeftClickAction(MODULENAME, "LeftClickAction", DEFAULT_POPUP_LCLICK),
+ PopupRightClickAction(MODULENAME, "RightClickAction", DEFAULT_POPUP_RCLICK),
+
+ // common settings
+ bBackup(MODULENAME, "Backup", false),
+ bUseHttps(MODULENAME, "UseHttps", IsWinVerVistaPlus()),
+ bSilentMode(MODULENAME, "SilentMode", false),
+ bAutoRestart(MODULENAME, "AutoRestart", false),
+ bOnlyOnceADay(MODULENAME, "OnlyOnceADay", true),
+ bUpdateOnPeriod(MODULENAME, "UpdateOnPeriod", false),
+ bChangePlatform(MODULENAME, DB_SETTING_CHANGEPLATFORM, false),
+ bUpdateOnStartup(MODULENAME, "UpdateOnStartup", true),
+
+ // other settings
+ iPeriod(MODULENAME, "Period", 1),
+ iPeriodMeasure(MODULENAME, "PeriodMeasure", 1)
+{
+}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -54,7 +75,6 @@ int CMPlugin::Load() if (g_tszTempPath[dwLen-1] == '\\')
g_tszTempPath[dwLen-1] = 0;
- LoadOptions();
InitPopupList();
InitNetlib();
InitIcoLib();
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 383d3f4168..82e5e5e380 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -24,25 +24,6 @@ HANDLE hPipe = nullptr; /////////////////////////////////////////////////////////////////////////////////////
-void LoadOptions()
-{
- g_plugin.PopupDefColors = g_plugin.getByte("DefColors", DEFAULT_COLORS);
- g_plugin.PopupLeftClickAction= g_plugin.getByte("LeftClickAction", DEFAULT_POPUP_LCLICK);
- g_plugin.PopupRightClickAction = g_plugin.getByte("RightClickAction", DEFAULT_POPUP_RCLICK);
- g_plugin.PopupTimeout = g_plugin.getDword("Timeout", DEFAULT_TIMEOUT_VALUE);
-
- g_plugin.bUpdateOnStartup = g_plugin.getBool("UpdateOnStartup", true);
- g_plugin.bOnlyOnceADay = g_plugin.getBool("OnlyOnceADay", true);
- g_plugin.bUpdateOnPeriod = g_plugin.getBool("UpdateOnPeriod", false);
- g_plugin.bSilentMode = g_plugin.getBool("SilentMode", false);
- g_plugin.bUseHttps = g_plugin.getBool("UseHttps", IsWinVerVistaPlus());
- g_plugin.bBackup = g_plugin.getBool("Backup", false);
- g_plugin.bChangePlatform = g_plugin.getBool(DB_SETTING_CHANGEPLATFORM, false);
-
- g_plugin.iPeriod = g_plugin.getDword("Period", 1);
- g_plugin.iPeriodMeasure = g_plugin.getByte("PeriodMeasure", 1);
-}
-
IconItem iconList[] =
{
{ LPGEN("Check for updates"),"check_update", IDI_MENU },
diff --git a/plugins/PluginUpdater/src/resource.h b/plugins/PluginUpdater/src/resource.h index 44449ad4bb..9105bba95a 100644 --- a/plugins/PluginUpdater/src/resource.h +++ b/plugins/PluginUpdater/src/resource.h @@ -54,18 +54,16 @@ #define IDC_USE_HTTPS 1051
#define IDC_CHANGE_PLATFORM 1052
#define IDC_SEARCH 1053
-#define IDC_MSG_BOXES 40071
-#define IDC_ERRORS 40072
-#define IDC_INFO_MESSAGES 40073
-#define IDC_PROGR_DLG 40074
-#define IDC_MSG_BOXES_TX 41071
-#define IDC_ERR_TX 41072
-#define IDC_INFO_MESSAGES_TX 41073
-#define IDC_PROGR_DLG_TX 41074
-#define IDC_MSG_BOXES_BG 42071
-#define IDC_ERR_BG 42072
-#define IDC_INFO_MESSAGES_BG 42073
-#define IDC_PROGR_DLG_BG 42074
+#define IDC_MSG_BOXES 1054
+#define IDC_ERRORS 1055
+#define IDC_INFO_MESSAGES 1056
+#define IDC_MSG_BOXES_TX 1057
+#define IDC_ERR_TX 1058
+#define IDC_INFO_MESSAGES_TX 1059
+#define IDC_MSG_BOXES_BG 1060
+#define IDC_ERR_BG 1061
+#define IDC_INFO_MESSAGES_BG 1062
+#define IDC_AUTORESTART 1063
// Next default values for new objects
//
@@ -73,7 +71,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 119
#define _APS_NEXT_COMMAND_VALUE 40075
-#define _APS_NEXT_CONTROL_VALUE 1054
+#define _APS_NEXT_CONTROL_VALUE 1064
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/plugins/PluginUpdater/src/stdafx.h b/plugins/PluginUpdater/src/stdafx.h index 7ef23fc695..9c0ecbff67 100644 --- a/plugins/PluginUpdater/src/stdafx.h +++ b/plugins/PluginUpdater/src/stdafx.h @@ -162,14 +162,15 @@ struct CMPlugin : public PLUGIN<CMPlugin> int Load() override;
int Unload() override;
+ bool bForceRedownload = false, bSilent; // not a db options
+
// common options
- bool bUpdateOnStartup, bUpdateOnPeriod, bOnlyOnceADay, bSilentMode, bBackup, bChangePlatform, bSilent, bUseHttps;
- bool bForceRedownload = false; // not a db option
- int iPeriod, iPeriodMeasure;
+ CMOption<bool> bUpdateOnStartup, bUpdateOnPeriod, bOnlyOnceADay, bSilentMode, bBackup, bChangePlatform, bUseHttps, bAutoRestart;
+ CMOption<int> iPeriod, iPeriodMeasure;
// popup options
- BYTE PopupDefColors, PopupLeftClickAction, PopupRightClickAction;
- int PopupTimeout;
+ CMOption<BYTE> PopupDefColors, PopupLeftClickAction, PopupRightClickAction;
+ CMOption<DWORD> PopupTimeout;
};
void UninitCheck(void);
@@ -218,7 +219,6 @@ typedef OBJLIST<ServListEntry> SERVLIST; ///////////////////////////////////////////////////////////////////////////////
void InitPopupList();
-void LoadOptions();
void InitNetlib();
void InitIcoLib();
void InitServices();
@@ -231,6 +231,8 @@ void UnloadCheck(); void UnloadListNew();
void UnloadNetlib();
+void CALLBACK RestartPrompt(void *);
+
void BackupFile(wchar_t *ptszSrcFileName, wchar_t *ptszBackFileName);
bool ParseHashes(const wchar_t *ptszUrl, ptrW &baseUrl, SERVLIST &arHashes);
diff --git a/plugins/PluginUpdater/src/version.h b/plugins/PluginUpdater/src/version.h index 3bafaed049..e289793974 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 6 +#define __BUILD_NUM 7 #include <stdver.h> |