diff options
author | George Hazan <ghazan@miranda.im> | 2019-03-06 16:15:45 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-03-06 16:15:55 +0300 |
commit | f580be3d9dcccb14831d6bed9e7dfca600f5b6f8 (patch) | |
tree | 468913d477b9d2a9fb430df9a886d24a8cf41887 /src/core/stdpopup | |
parent | 827dbce0a554ccc313fd0b14b45bd57dffeead95 (diff) |
popups:
- internal implementation details & all service declarations moved to m_popup_int.h;
- all service calls removed and replaced with function calls;
- direct access to popup serttings replaced with Popup_Enable / Popup_Enabled;
Diffstat (limited to 'src/core/stdpopup')
-rw-r--r-- | src/core/stdpopup/src/options.cpp | 8 | ||||
-rw-r--r-- | src/core/stdpopup/src/services.cpp | 49 | ||||
-rw-r--r-- | src/core/stdpopup/src/stdafx.h | 2 | ||||
-rw-r--r-- | src/core/stdpopup/src/yapp.cpp | 4 |
4 files changed, 17 insertions, 46 deletions
diff --git a/src/core/stdpopup/src/options.cpp b/src/core/stdpopup/src/options.cpp index c30ed0635e..1bb5d199f1 100644 --- a/src/core/stdpopup/src/options.cpp +++ b/src/core/stdpopup/src/options.cpp @@ -429,16 +429,16 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam POPUPCLASS pc = *arNewClasses[i]; pc.PluginWindowProc = nullptr; POPUPDATACLASS d = {sizeof(d), pc.pszName}; - d.pwszTitle = L"Preview"; - d.pwszText = L"The quick brown fox jumps over the lazy dog."; + d.szTitle.w = L"Preview"; + d.szText.w = L"The quick brown fox jumps over the lazy dog."; CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d); } else { POPUPCLASS pc = *arNewClasses[i]; pc.PluginWindowProc = nullptr; POPUPDATACLASS d = {sizeof(d), pc.pszName}; - d.pszTitle = "Preview"; - d.pszText = "The quick brown fox jumps over the lazy dog."; + d.szTitle.a = "Preview"; + d.szText.a = "The quick brown fox jumps over the lazy dog."; CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d); } break; diff --git a/src/core/stdpopup/src/services.cpp b/src/core/stdpopup/src/services.cpp index f01f16e83a..ce8650f2ce 100644 --- a/src/core/stdpopup/src/services.cpp +++ b/src/core/stdpopup/src/services.cpp @@ -70,7 +70,7 @@ static INT_PTR CreatePopup(WPARAM wParam, LPARAM) pd_out->timeout = pd_in->iSeconds; lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0)); - if (!db_get_b(0, "Popup", "ModuleIsEnabled", 1)) { + if (!Popup_Enabled()) { mir_free(pd_out->pwzTitle); mir_free(pd_out->pwzText); mir_free(pd_out); @@ -111,7 +111,7 @@ static INT_PTR CreatePopupW(WPARAM wParam, LPARAM) pd_out->timeout = pd_in->iSeconds; lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0)); - if (!db_get_b(0, "Popup", "ModuleIsEnabled", 1)) { + if (!Popup_Enabled()) { mir_free(pd_out->pwzTitle); mir_free(pd_out->pwzText); mir_free(pd_out); @@ -151,7 +151,7 @@ void ShowPopup(PopupData &pd_in) lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0)); - if (!db_get_b(0, "Popup", "ModuleIsEnabled", 1)) { + if (!Popup_Enabled()) { mir_free(pd_out->pwzTitle); mir_free(pd_out->pwzText); mir_free(pd_out); @@ -193,7 +193,7 @@ static INT_PTR GetOpaque(WPARAM wParam, LPARAM) void UpdateMenu() { - bool isEnabled = db_get_b(0, "Popup", "ModuleIsEnabled", 1) == 1; + bool isEnabled = Popup_Enabled() == 1; if (isEnabled) { Menu_ModifyItem(hMenuItem, LPGENW("Disable Popups"), IcoLib_GetIcon(ICO_POPUP_ON)); Menu_ModifyItem(hMenuRoot, nullptr, IcoLib_GetIcon(ICO_POPUP_ON)); @@ -207,38 +207,10 @@ void UpdateMenu() CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTTButton, isEnabled ? TTBST_PUSHED : 0); } -INT_PTR PopupQuery(WPARAM wParam, LPARAM) -{ - switch(wParam) { - case PUQS_ENABLEPOPUPS: - { - bool enabled = db_get_b(0, "Popup", "ModuleIsEnabled", 1) != 0; - if (!enabled) db_set_b(0, "Popup", "ModuleIsEnabled", 1); - UpdateMenu(); - return !enabled; - } - break; - case PUQS_DISABLEPOPUPS: - { - bool enabled = db_get_b(0, "Popup", "ModuleIsEnabled", 1) != 0; - if (enabled) db_set_b(0, "Popup", "ModuleIsEnabled", 0); - UpdateMenu(); - return enabled; - } - break; - - case PUQS_GETSTATUS: - return db_get_b(0, "Popup", "ModuleIsEnabled", 1); - default: - UpdateMenu(); - return 1; - } -} - static INT_PTR TogglePopups(WPARAM, LPARAM) { - BYTE val = db_get_b(0, "Popup", "ModuleIsEnabled", 1); - db_set_b(0, "Popup", "ModuleIsEnabled", !val); + BYTE val = Popup_Enabled(); + Popup_Enable(!val); UpdateMenu(); return 0; } @@ -287,7 +259,7 @@ static INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam) if (bShutdown) return -1; - if (db_get_b(0, "Popup", "ModuleIsEnabled", 1)) { + if (Popup_Enabled()) { POPUPDATAW pd = {0}; mir_wstrcpy(pd.lpwzContactName, lParam == SM_WARNING ? L"Warning" : L"Notification"); pd.lchIcon = LoadIcon(nullptr, lParam == SM_WARNING ? IDI_WARNING : IDI_INFORMATION); @@ -302,7 +274,7 @@ static INT_PTR ShowMessageW(WPARAM wParam, LPARAM lParam) if (bShutdown) return -1; - if (db_get_b(0, "Popup", "ModuleIsEnabled", 1)) { + if (Popup_Enabled()) { POPUPDATAW pd = {0}; mir_wstrcpy(pd.lpwzContactName, lParam == SM_WARNING ? L"Warning" : L"Notification"); pd.lchIcon = LoadIcon(nullptr, lParam == SM_WARNING ? IDI_WARNING : IDI_INFORMATION); @@ -399,8 +371,8 @@ static INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam) pd.hContact = pdc->hContact; pd.opaque = pdc->PluginData; - pd.pszTitle = (char *)pdc->pszTitle; - pd.pszText = (char *)pdc->pszText; + pd.pszTitle = (char *)pdc->szTitle.a; + pd.pszText = (char *)pdc->szText.a; ShowPopup(pd); } @@ -428,7 +400,6 @@ void InitServices() CreateServiceFunction(MS_POPUP_CHANGEW, PopupChangeW); CreateServiceFunction(MS_POPUP_GETCONTACT, GetContact); CreateServiceFunction(MS_POPUP_GETPLUGINDATA, GetOpaque); - CreateServiceFunction(MS_POPUP_QUERY, PopupQuery); CreateServiceFunction(MS_POPUP_SHOWMESSAGE, ShowMessage); CreateServiceFunction(MS_POPUP_SHOWMESSAGEW, ShowMessageW); diff --git a/src/core/stdpopup/src/stdafx.h b/src/core/stdpopup/src/stdafx.h index 0255cba2d7..6cb4378305 100644 --- a/src/core/stdpopup/src/stdafx.h +++ b/src/core/stdpopup/src/stdafx.h @@ -21,7 +21,7 @@ #include <m_clistint.h> #include <m_fontservice.h> #include <m_avatars.h> -#include <m_popup.h> +#include <m_popup_int.h> #include <m_icolib.h> #include <m_toptoolbar.h> #include <win2k.h> diff --git a/src/core/stdpopup/src/yapp.cpp b/src/core/stdpopup/src/yapp.cpp index 047c33502f..b440675cf6 100644 --- a/src/core/stdpopup/src/yapp.cpp +++ b/src/core/stdpopup/src/yapp.cpp @@ -77,7 +77,7 @@ static int TTBLoaded(WPARAM, LPARAM) ttb.pszService = "Popup/EnableDisableMenuCommand"; ttb.lParamUp = 1; ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP | TTBBF_ASPUSHBUTTON; - if (db_get_b(0, "Popup", "ModuleIsEnabled", 1)) + if (Popup_Enabled()) ttb.dwFlags |= TTBBF_PUSHED; ttb.name = LPGEN("Toggle Popups"); ttb.hIconHandleUp = IcoLib_GetIconHandle(ICO_TB_POPUP_OFF); @@ -157,7 +157,7 @@ static void InitFonts() static void InitMenuItems(void) { - bool isEnabled = db_get_b(0, "Popup", "ModuleIsEnabled", 1) == 1; + bool isEnabled = Popup_Enabled() == 1; hMenuRoot = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 500010000, IcoLib_GetIcon(isEnabled ? ICO_POPUP_ON : ICO_POPUP_OFF, 0)); Menu_ConfigureItem(hMenuRoot, MCI_OPT_UID, "043A641A-2767-4C57-AA57-9233D6F9DC54"); |