From ba1083b4da33ca44a5ae7d90eabbe3d6d340a81e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 17 May 2018 16:47:04 +0300 Subject: XSoundNotify, YAPP, YaRelay, ZeroSwitch, ZeroNotify -> CMPlugin --- plugins/YARelay/src/main.cpp | 48 ++++++++++++++++++++--------------------- plugins/YARelay/src/options.cpp | 21 +++++++++--------- plugins/YARelay/src/stdafx.h | 28 ++++++++++++++---------- 3 files changed, 52 insertions(+), 45 deletions(-) (limited to 'plugins/YARelay/src') diff --git a/plugins/YARelay/src/main.cpp b/plugins/YARelay/src/main.cpp index d0feea1c5f..4aba06bdb5 100644 --- a/plugins/YARelay/src/main.cpp +++ b/plugins/YARelay/src/main.cpp @@ -21,7 +21,7 @@ Features: #include "../../utils/mir_buffer.h" -HINSTANCE hInst; +CMPlugin g_plugin; int hLangpack; MCONTACT hForwardFrom, hForwardTo; @@ -30,6 +30,8 @@ int iSplit, iSplitMaxSize, iSendParts, iMarkRead, iSendAndHistory, iForwardOnSta LIST arMessageProcs(10, HandleKeySortT); +///////////////////////////////////////////////////////////////////////////////////////// + PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -43,15 +45,14 @@ PLUGININFOEX pluginInfoEx = { {0x1202e6a, 0xc1b3, 0x42e5, {0x83, 0x8a, 0x3e, 0x49, 0x7b, 0x31, 0xf3, 0x8e}} }; -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { - hInst=hinstDLL; - return TRUE; + return &pluginInfoEx; } -/** -* Protocols acknowledgement -*/ +///////////////////////////////////////////////////////////////////////////////////////// +// Protocols acknowledgement + int ProtoAck(WPARAM,LPARAM lparam) { ACKDATA *pAck = (ACKDATA *)lparam; @@ -67,7 +68,7 @@ int ProtoAck(WPARAM,LPARAM lparam) time(<ime); DBEVENTINFO dbei = {}; - dbei.szModule = "yaRelay"; + dbei.szModule = MODULENAME; dbei.timestamp = ltime; dbei.flags = DBEF_SENT | DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; @@ -82,9 +83,9 @@ int ProtoAck(WPARAM,LPARAM lparam) return 0; } -/** -* New event was added into DB. -*/ +///////////////////////////////////////////////////////////////////////////////////////// +// New event was added into DB. + static int MessageEventAdded(WPARAM hContact, LPARAM hDBEvent) { // is the message sender accepted for forwarding @@ -212,33 +213,30 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDBEvent) return 0; } -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) -{ - return &pluginInfoEx; -} +///////////////////////////////////////////////////////////////////////////////////////// extern "C" int __declspec(dllexport) Load() { mir_getLP(&pluginInfoEx); // Load plugin options from DB - hForwardFrom = (MCONTACT)db_get_dw(NULL, "yaRelay", "ForwardFrom", 0); - hForwardTo = (MCONTACT)db_get_dw(NULL, "yaRelay", "ForwardTo", 0); + hForwardFrom = (MCONTACT)db_get_dw(NULL, MODULENAME, "ForwardFrom", 0); + hForwardTo = (MCONTACT)db_get_dw(NULL, MODULENAME, "ForwardTo", 0); - iForwardOnStatus = db_get_dw(NULL, "yaRelay", "ForwardOnStatus", STATUS_OFFLINE | STATUS_AWAY | STATUS_NA); + iForwardOnStatus = db_get_dw(NULL, MODULENAME, "ForwardOnStatus", STATUS_OFFLINE | STATUS_AWAY | STATUS_NA); - wchar_t *szForwardTemplate = db_get_wsa(NULL, "yaRelay", "ForwardTemplate"); + wchar_t *szForwardTemplate = db_get_wsa(NULL, MODULENAME, "ForwardTemplate"); if (szForwardTemplate){ wcsncpy(tszForwardTemplate, szForwardTemplate, _countof(tszForwardTemplate)); mir_free(szForwardTemplate); } else wcsncpy(tszForwardTemplate, L"%u: %m", MAXTEMPLATESIZE-1); - iSplit = db_get_dw(NULL, "yaRelay", "Split", 0); - iSplitMaxSize = db_get_dw(NULL, "yaRelay", "SplitMaxSize", 100); - iSendParts = db_get_dw(NULL, "yaRelay", "SendParts", 0); - iMarkRead = db_get_dw(NULL, "yaRelay", "MarkRead", 0); - iSendAndHistory = db_get_dw(NULL, "yaRelay", "SendAndHistory", 1); + iSplit = db_get_dw(NULL, MODULENAME, "Split", 0); + iSplitMaxSize = db_get_dw(NULL, MODULENAME, "SplitMaxSize", 100); + iSendParts = db_get_dw(NULL, MODULENAME, "SendParts", 0); + iMarkRead = db_get_dw(NULL, MODULENAME, "MarkRead", 0); + iSendAndHistory = db_get_dw(NULL, MODULENAME, "SendAndHistory", 1); // hook events HookEvent(ME_DB_EVENT_ADDED, MessageEventAdded); @@ -247,6 +245,8 @@ extern "C" int __declspec(dllexport) Load() return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" int __declspec(dllexport) Unload(void) { return 0; diff --git a/plugins/YARelay/src/options.cpp b/plugins/YARelay/src/options.cpp index 86d9ad6028..2ce13a9d78 100644 --- a/plugins/YARelay/src/options.cpp +++ b/plugins/YARelay/src/options.cpp @@ -168,15 +168,15 @@ static INT_PTR CALLBACK OptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, iSplitMaxSize = 1; // write to database - db_set_dw(NULL, "yaRelay", "ForwardFrom", (DWORD)hForwardFrom); - db_set_dw(NULL, "yaRelay", "ForwardTo", (DWORD)hForwardTo); - db_set_dw(NULL, "yaRelay", "ForwardOnStatus", iForwardOnStatus); - db_set_ws(NULL, "yaRelay", "ForwardTemplate", tszForwardTemplate); - db_set_dw(NULL, "yaRelay", "Split", iSplit); - db_set_dw(NULL, "yaRelay", "SplitMaxSize", iSplitMaxSize); - db_set_dw(NULL, "yaRelay", "SendParts", iSendParts); - db_set_dw(NULL, "yaRelay", "MarkRead", iMarkRead); - db_set_dw(NULL, "yaRelay", "SendAndHistory", iSendAndHistory); + db_set_dw(NULL, MODULENAME, "ForwardFrom", (DWORD)hForwardFrom); + db_set_dw(NULL, MODULENAME, "ForwardTo", (DWORD)hForwardTo); + db_set_dw(NULL, MODULENAME, "ForwardOnStatus", iForwardOnStatus); + db_set_ws(NULL, MODULENAME, "ForwardTemplate", tszForwardTemplate); + db_set_dw(NULL, MODULENAME, "Split", iSplit); + db_set_dw(NULL, MODULENAME, "SplitMaxSize", iSplitMaxSize); + db_set_dw(NULL, MODULENAME, "SendParts", iSendParts); + db_set_dw(NULL, MODULENAME, "MarkRead", iMarkRead); + db_set_dw(NULL, MODULENAME, "SendAndHistory", iSendAndHistory); return TRUE; } break; @@ -188,10 +188,11 @@ static INT_PTR CALLBACK OptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, /** * Init options panel */ + int OptionsInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.hInstance = hInst; + odp.hInstance = g_plugin.getInst(); odp.position = -1; odp.szGroup.a = LPGEN("Message sessions"); odp.pszTemplate = MAKEINTRESOURCEA(IDD_SETTINGS); diff --git a/plugins/YARelay/src/stdafx.h b/plugins/YARelay/src/stdafx.h index a185b39742..2d76fcbfaa 100644 --- a/plugins/YARelay/src/stdafx.h +++ b/plugins/YARelay/src/stdafx.h @@ -23,7 +23,6 @@ Features: #include #include -#define __NO_CMPLUGIN_NEEDED #include #include #include @@ -36,18 +35,25 @@ Features: #include "resource.h" #include "version.h" -#define STATUS_OFFLINE 0x1 -#define STATUS_ONLINE 0x2 -#define STATUS_AWAY 0x4 -#define STATUS_NA 0x8 -#define STATUS_OCCUPIED 0x10 -#define STATUS_DND 0x20 -#define STATUS_FREECHAT 0x40 -#define STATUS_INVISIBLE 0x80 +#define STATUS_OFFLINE 0x1 +#define STATUS_ONLINE 0x2 +#define STATUS_AWAY 0x4 +#define STATUS_NA 0x8 +#define STATUS_OCCUPIED 0x10 +#define STATUS_DND 0x20 +#define STATUS_FREECHAT 0x40 +#define STATUS_INVISIBLE 0x80 -#define MAXTEMPLATESIZE 1024 +#define MAXTEMPLATESIZE 1024 -extern HINSTANCE hInst; +#define MODULENAME "yaRelay" + +struct CMPlugin : public PLUGIN +{ + CMPlugin() : + PLUGIN(MODULENAME) + {} +}; extern MCONTACT hForwardFrom, hForwardTo; extern wchar_t tszForwardTemplate[MAXTEMPLATESIZE]; -- cgit v1.2.3