summaryrefslogtreecommitdiff
path: root/plugins/YARelay/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-17 16:47:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-17 16:47:04 +0300
commitba1083b4da33ca44a5ae7d90eabbe3d6d340a81e (patch)
treeff215cbcb7d606f9898dbb0f038e850540f52e75 /plugins/YARelay/src
parent3c641c02b973483e86b9562088719396bbdbe412 (diff)
XSoundNotify, YAPP, YaRelay, ZeroSwitch, ZeroNotify -> CMPlugin
Diffstat (limited to 'plugins/YARelay/src')
-rw-r--r--plugins/YARelay/src/main.cpp48
-rw-r--r--plugins/YARelay/src/options.cpp21
-rw-r--r--plugins/YARelay/src/stdafx.h28
3 files changed, 52 insertions, 45 deletions
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<MESSAGE_PROC> 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(&ltime);
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 <time.h>
#include <malloc.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_database.h>
@@ -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>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
extern MCONTACT hForwardFrom, hForwardTo;
extern wchar_t tszForwardTemplate[MAXTEMPLATESIZE];