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 /plugins/Toaster/src | |
| 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 'plugins/Toaster/src')
| -rw-r--r-- | plugins/Toaster/src/options.cpp | 7 | ||||
| -rw-r--r-- | plugins/Toaster/src/services.cpp | 47 | ||||
| -rw-r--r-- | plugins/Toaster/src/stdafx.h | 2 |
3 files changed, 11 insertions, 45 deletions
diff --git a/plugins/Toaster/src/options.cpp b/plugins/Toaster/src/options.cpp index 7c1e446042..be08b5cf16 100644 --- a/plugins/Toaster/src/options.cpp +++ b/plugins/Toaster/src/options.cpp @@ -13,7 +13,7 @@ COptions::COptions() bool COptions::OnInitDialog()
{
- m_enabled.SetState(CallService(MS_POPUP_QUERY, PUQS_GETSTATUS));
+ m_enabled.SetState(Popup_Enabled());
return true;
}
@@ -34,10 +34,7 @@ void COptions::Preview_OnClick(CCtrlBase*) void COptions::Enabled_OnChange(CCtrlCheck* chk)
{
- if (chk->GetState())
- CallService(MS_POPUP_QUERY, PUQS_ENABLEPOPUPS);
- else
- CallService(MS_POPUP_QUERY, PUQS_DISABLEPOPUPS);
+ Popup_Enable(chk->GetState());
}
/////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Toaster/src/services.cpp b/plugins/Toaster/src/services.cpp index 6bc3e1b8e4..fe5bd912fd 100644 --- a/plugins/Toaster/src/services.cpp +++ b/plugins/Toaster/src/services.cpp @@ -9,7 +9,7 @@ void __stdcall ShowToastNotification(void* p) {
std::unique_ptr<ToastData> td((ToastData*)p);
- if (!db_get_b(0, "Popup", "ModuleIsEnabled", 1))
+ if (!Popup_Enabled())
return;
ptrW imagePath;
@@ -80,13 +80,13 @@ static INT_PTR CreatePopup2(WPARAM wParam, LPARAM) ptrW text, title;
if (ppd->flags & PU2_UNICODE)
{
- text = mir_wstrdup(ppd->lpwzText);
- title = mir_wstrdup(ppd->lpwzTitle);
+ text = mir_wstrdup(ppd->szText.w);
+ title = mir_wstrdup(ppd->szTitle.w);
}
else
{
- text = mir_a2u(ppd->lpzText);
- title = mir_a2u(ppd->lpzTitle);
+ text = mir_a2u(ppd->szText.a);
+ title = mir_a2u(ppd->szTitle.a);
}
ToastData *td = nullptr;
@@ -122,16 +122,11 @@ static INT_PTR CreateClassPopup(WPARAM, LPARAM lParam) auto it = mp_Classes.find(ppc->pszClassName);
if (it != mp_Classes.end())
{
- ToastData *td = nullptr;
-
+ ToastData *td;
if (it->second->iFlags & PCF_UNICODE)
- {
- td = new ToastData(ppc->hContact, ppc->pwszTitle, ppc->pwszText, it->second->hIcon);
- }
+ td = new ToastData(ppc->hContact, ppc->szTitle.w, ppc->szText.w, it->second->hIcon);
else
- {
- td = new ToastData(ppc->hContact, ptrW(mir_utf8decodeW(ppc->pszTitle)), ptrW(mir_utf8decodeW(ppc->pszText)), it->second->hIcon);
- }
+ td = new ToastData(ppc->hContact, ptrW(mir_utf8decodeW(ppc->szTitle.a)), ptrW(mir_utf8decodeW(ppc->szText.a)), it->second->hIcon);
td->vPopupData = ppc->PluginData;
td->pPopupProc = it->second->pPopupProc;
@@ -163,30 +158,6 @@ void CleanupClasses() mp_Classes.clear();
}
-static 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);
- return !enabled;
- }
- case PUQS_DISABLEPOPUPS:
- {
- bool enabled = db_get_b(0, "Popup", "ModuleIsEnabled", 1) != 0;
- if (enabled) db_set_b(0, "Popup", "ModuleIsEnabled", 0);
- CallFunctionAsync(HideAllToasts, nullptr);
- return enabled;
- }
- case PUQS_GETSTATUS:
- return db_get_b(0, "Popup", "ModuleIsEnabled", 1);
- default:
- return 1;
- }
-}
-
static INT_PTR ShowMessageW(WPARAM wParam, LPARAM lParam)
{
HICON hIcon = nullptr;
@@ -239,8 +210,6 @@ void InitServices() CreateServiceFunction(MS_POPUP_ADDPOPUPW, CreatePopupW);
CreateServiceFunction(MS_POPUP_ADDPOPUP2, CreatePopup2);
- CreateServiceFunction(MS_POPUP_QUERY, PopupQuery);
-
CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, CreateClassPopup);
CreateServiceFunction(MS_POPUP_REGISTERCLASS, RegisterPopupClass);
CreateServiceFunction(MS_POPUP_UNREGISTERCLASS, UnRegisterPopupClass);
diff --git a/plugins/Toaster/src/stdafx.h b/plugins/Toaster/src/stdafx.h index aecd986516..c5204df533 100644 --- a/plugins/Toaster/src/stdafx.h +++ b/plugins/Toaster/src/stdafx.h @@ -16,7 +16,7 @@ #include <m_langpack.h>
#include <m_avatars.h>
#include <m_protocols.h>
-#include <m_popup.h>
+#include <m_popup_int.h>
#include <m_message.h>
#include <m_chat.h>
#include <m_skin.h>
|
