summaryrefslogtreecommitdiff
path: root/protocols/Discord
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-04-18 18:14:33 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-04-18 18:14:33 +0300
commitb172c4bbc75cdad0e8ccd22292aa671ba43cac45 (patch)
tree4677a04a47f3987c88f3fb44c6b70d2642b1f8a3 /protocols/Discord
parent524d1c7186eca3f0a4da08548eeb919785227101 (diff)
PLUGIN<> to half-automatically calculate the dll's g_hInstance and pass it inside
Diffstat (limited to 'protocols/Discord')
-rw-r--r--protocols/Discord/src/main.cpp24
-rw-r--r--protocols/Discord/src/proto.h11
-rw-r--r--protocols/Discord/src/stdafx.h6
3 files changed, 18 insertions, 23 deletions
diff --git a/protocols/Discord/src/main.cpp b/protocols/Discord/src/main.cpp
index 4437ee1864..3b50bc946b 100644
--- a/protocols/Discord/src/main.cpp
+++ b/protocols/Discord/src/main.cpp
@@ -17,11 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
+CMPlugin g_plugin;
CHAT_MANAGER *pci;
HINSTANCE g_hInstance;
int hLangpack = 0;
HWND g_hwndHeartbeat;
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
IconItem g_iconList[] =
{
{ LPGEN("Main icon"), "main", IDI_MAIN },
@@ -41,13 +44,7 @@ PLUGININFOEX pluginInfo = {
{ 0x88928401, 0x2ce8, 0x4568, { 0xaa, 0xa7, 0x22, 0x61, 0x41, 0x87, 0x0c, 0xbf } }
};
-DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
-{
- g_hInstance = hInstance;
- return TRUE;
-}
-
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
@@ -79,16 +76,3 @@ extern "C" int __declspec(dllexport) Unload(void)
DestroyWindow(g_hwndHeartbeat);
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-struct CMPlugin : public ACCPROTOPLUGIN<CDiscordProto>
-{
- CMPlugin() :
- ACCPROTOPLUGIN<CDiscordProto>("Discord")
- {
- SetUniqueId(DB_KEY_ID);
- }
-}
- g_plugin;
-
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h
index 99fb50ecf6..a33511d3bd 100644
--- a/protocols/Discord/src/proto.h
+++ b/protocols/Discord/src/proto.h
@@ -350,3 +350,14 @@ public:
static void CALLBACK HeartbeatTimerProc(HWND hwnd, UINT msg, UINT_PTR id, DWORD);
static void CALLBACK MarkReadTimerProc(HWND hwnd, UINT msg, UINT_PTR id, DWORD);
};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct CMPlugin : public ACCPROTOPLUGIN<CDiscordProto>
+{
+ CMPlugin() :
+ ACCPROTOPLUGIN<CDiscordProto>("Discord")
+ {
+ SetUniqueId(DB_KEY_ID);
+ }
+};
diff --git a/protocols/Discord/src/stdafx.h b/protocols/Discord/src/stdafx.h
index d09c1a7499..5c83a50ef0 100644
--- a/protocols/Discord/src/stdafx.h
+++ b/protocols/Discord/src/stdafx.h
@@ -47,9 +47,6 @@ extern IconItem g_iconList[];
extern HINSTANCE g_hInstance;
extern HWND g_hwndHeartbeat;
-#include "version.h"
-#include "proto.h"
-
#define DB_KEY_ID "id"
#define DB_KEY_EMAIL "Email"
#define DB_KEY_PASSWORD "Password"
@@ -65,6 +62,9 @@ extern HWND g_hwndHeartbeat;
#define DB_KEY_GROUP "GroupName"
#define DB_KEYVAL_GROUP L"Discord"
+#include "version.h"
+#include "proto.h"
+
SnowFlake getId(const JSONNode &pNode);
CMStringW PrepareMessageText(const JSONNode &pRoot);
int StrToStatus(const CMStringW &str);