From d9fddc0cfa9066eb1b5ad3f4807b37426ae6ca88 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 5 Mar 2019 21:10:22 +0300 Subject: Popup: - wiping out checks for service presence; - code cleaning --- plugins/PackUpdater/Src/Notifications.cpp | 10 ++++---- plugins/PackUpdater/Src/Options.cpp | 39 +++++++++---------------------- plugins/PackUpdater/Src/Utils.cpp | 10 ++++---- 3 files changed, 21 insertions(+), 38 deletions(-) (limited to 'plugins/PackUpdater') diff --git a/plugins/PackUpdater/Src/Notifications.cpp b/plugins/PackUpdater/Src/Notifications.cpp index 9512a700c7..83ce348095 100644 --- a/plugins/PackUpdater/Src/Notifications.cpp +++ b/plugins/PackUpdater/Src/Notifications.cpp @@ -148,7 +148,7 @@ void show_popup(HWND hDlg, LPCTSTR pszTitle, LPCTSTR pszText, int iNumber, int A MakePopupAction(pmpd->pa[pd.actionCount++], IDNO); } - CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&pd, APF_NEWDATA); + PUAddPopupW(&pd, APF_NEWDATA); } INT_PTR CALLBACK DlgDownload(HWND hDlg, UINT message, WPARAM, LPARAM) @@ -176,7 +176,7 @@ INT_PTR CALLBACK DlgDownloadPop(HWND hDlg, UINT uMsg, WPARAM, LPARAM) static void __stdcall CreateDownloadDialog(void*) { - if (ServiceExists(MS_POPUP_ADDPOPUPW) && db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups3", DEFAULT_POPUP_ENABLED)) + if (db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups3", DEFAULT_POPUP_ENABLED)) hDlgDld = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_POPUPDUMMI), nullptr, DlgDownloadPop); else if (g_plugin.getByte("Popups3M", DEFAULT_MESSAGE_ENABLED)) { mir_wstrncpy(tszDialogMsg, Text, _countof(tszDialogMsg)); @@ -195,7 +195,7 @@ void DlgDownloadProc() if (!DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath)) { Title = TranslateT("Pack Updater"); Text = TranslateT("An error occurred while downloading the update."); - if (ServiceExists(MS_POPUP_ADDPOPUPW) && db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups1", DEFAULT_POPUP_ENABLED)) { + if (db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups1", DEFAULT_POPUP_ENABLED)) { Number = 1; show_popup(nullptr, Title, Text, Number, 0); } @@ -420,7 +420,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam INT rc = -1; Title = TranslateT("Pack Updater"); Text = tszBuff; - if (ServiceExists(MS_POPUP_ADDPOPUPW) && ServiceExists(MS_POPUP_REGISTERACTIONS) && db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups0", DEFAULT_POPUP_ENABLED) && (db_get_dw(0, "Popup", "Actions", 0) & 1)) + if (ServiceExists(MS_POPUP_REGISTERACTIONS) && db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups0", DEFAULT_POPUP_ENABLED) && (db_get_dw(0, "Popup", "Actions", 0) & 1)) rc = DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_POPUPDUMMI), nullptr, DlgMsgPop); else rc = MessageBox(nullptr, tszBuff, Title, MB_YESNO | MB_ICONQUESTION); @@ -508,7 +508,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam mir_snwprintf(tszBuff, TranslateT("You have chosen not to install the pack update immediately.\nYou can install it manually from this location:\n\n%s"), arFilePath[0].c_str()); Title = TranslateT("Pack Updater"); Text = tszBuff; - if (ServiceExists(MS_POPUP_ADDPOPUPW) && db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups2", DEFAULT_POPUP_ENABLED)) { + if (db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups2", DEFAULT_POPUP_ENABLED)) { Number = 2; show_popup(nullptr, Title, Text, Number, 0); } diff --git a/plugins/PackUpdater/Src/Options.cpp b/plugins/PackUpdater/Src/Options.cpp index b662b16a54..628bad6ee5 100644 --- a/plugins/PackUpdater/Src/Options.cpp +++ b/plugins/PackUpdater/Src/Options.cpp @@ -31,8 +31,6 @@ LRESULT CALLBACK MyEditProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - char str[20]; - switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); @@ -55,19 +53,12 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), PeriodMeasure); CheckDlgButton(hwndDlg, IDC_REMINDER, Reminder ? BST_CHECKED : BST_UNCHECKED); - if (ServiceExists(MS_POPUP_ADDPOPUPW)) { - ShowWindow(GetDlgItem(hwndDlg, IDC_NOTIFY2), SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg, IDC_MSG_BOXES2), SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg, IDC_ERRORS2), SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg, IDC_INFO_MESSAGES2), SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg, IDC_PROGR_DLG2), SW_HIDE); - } - else { - for (int i = 1; i < POPUPS; i++) { - mir_snprintf(str, "Popups%dM", i); - CheckDlgButton(hwndDlg, (i + 1029), (g_plugin.getByte(str, DEFAULT_MESSAGE_ENABLED)) ? BST_CHECKED : BST_UNCHECKED); - } - } + + ShowWindow(GetDlgItem(hwndDlg, IDC_NOTIFY2), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_MSG_BOXES2), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_ERRORS2), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_INFO_MESSAGES2), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_PROGR_DLG2), SW_HIDE); return TRUE; case WM_COMMAND: @@ -141,12 +132,6 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA g_plugin.setByte("PeriodMeasure", PeriodMeasure); Reminder = IsDlgButtonChecked(hwndDlg, IDC_REMINDER); g_plugin.setByte("Reminder", Reminder); - if (!ServiceExists(MS_POPUP_ADDPOPUPW)) { - for (int i = 1; i < POPUPS; i++) { - mir_snprintf(str, "Popups%dM", i); - g_plugin.setByte(str, (BYTE)(IsDlgButtonChecked(hwndDlg, (i + 1029)))); - } - } } break; } @@ -389,12 +374,10 @@ int OptInit(WPARAM wParam, LPARAM) odp.pfnDlgProc = UpdateNotifyOptsProc; g_plugin.addOptions(wParam, &odp); - if (ServiceExists(MS_POPUP_ADDPOPUPW)) { - odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP); - odp.szGroup.w = LPGENW("Popups"); - odp.szTitle.w = LPGENW("Pack Updater"); - odp.pfnDlgProc = DlgPopupOpts; - g_plugin.addOptions(wParam, &odp); - } + odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP); + odp.szGroup.w = LPGENW("Popups"); + odp.szTitle.w = LPGENW("Pack Updater"); + odp.pfnDlgProc = DlgPopupOpts; + g_plugin.addOptions(wParam, &odp); return 0; } diff --git a/plugins/PackUpdater/Src/Utils.cpp b/plugins/PackUpdater/Src/Utils.cpp index 2ff8415ef9..29e1974917 100644 --- a/plugins/PackUpdater/Src/Utils.cpp +++ b/plugins/PackUpdater/Src/Utils.cpp @@ -193,7 +193,7 @@ static void CheckUpdates(void *) if (!tszDownloadURL) { // URL is not set Title = TranslateT("Pack Updater"); Text = TranslateT("URL for checking updates not found."); - if (ServiceExists(MS_POPUP_ADDPOPUPW) && db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups1", DEFAULT_POPUP_ENABLED)) { + if (db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups1", DEFAULT_POPUP_ENABLED)) { Number = 1; show_popup(nullptr, Title, Text, Number, 0); } @@ -248,7 +248,7 @@ static void CheckUpdates(void *) if (wcsstr(tszBuff, L"\\")) { //check update name Title = TranslateT("Pack Updater"); Text = TranslateT("Name of Update's file is not supported."); - if (ServiceExists(MS_POPUP_ADDPOPUPW) && db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups1", DEFAULT_POPUP_ENABLED)) { + if (db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups1", DEFAULT_POPUP_ENABLED)) { Number = 1; show_popup(nullptr, Title, Text, Number, 0); } @@ -339,7 +339,7 @@ static void CheckUpdates(void *) if (!UpdatesCount && !Silent) { Title = TranslateT("Pack Updater"); Text = TranslateT("No updates found."); - if (ServiceExists(MS_POPUP_ADDPOPUPW) && db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups2", DEFAULT_POPUP_ENABLED)) { + if (db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups2", DEFAULT_POPUP_ENABLED)) { Number = 2; show_popup(nullptr, Title, Text, Number, 0); } @@ -350,7 +350,7 @@ static void CheckUpdates(void *) if (!FileCount) { Title = TranslateT("Pack Updater"); Text = TranslateT("No files for update."); - if (ServiceExists(MS_POPUP_ADDPOPUPW) && db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups2", DEFAULT_POPUP_ENABLED)) { + if (db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups2", DEFAULT_POPUP_ENABLED)) { Number = 2; show_popup(nullptr, Title, Text, Number, 0); } @@ -365,7 +365,7 @@ void DoCheck(int iFlag) if (hCheckThread != nullptr) { Title = TranslateT("Pack Updater"); Text = TranslateT("Update checking already started!"); - if (ServiceExists(MS_POPUP_ADDPOPUPW) && db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups2", DEFAULT_POPUP_ENABLED)) { + if (db_get_b(0, "Popup", "ModuleIsEnabled", 1) && g_plugin.getByte("Popups2", DEFAULT_POPUP_ENABLED)) { Number = 2; show_popup(nullptr, Title, Text, Number, 0); } -- cgit v1.2.3