summaryrefslogtreecommitdiff
path: root/plugins/AsSingleWindow
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-20 15:08:48 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-05-20 15:08:48 +0300
commit8a74e7495ce5ad39de4f5c25121a84d35df90c36 (patch)
tree03e5b4870f09a3163306740c2eebee47bc15b042 /plugins/AsSingleWindow
parentc5bf7d6123dd1c3b82ccb8fdb1b068077e9d56d4 (diff)
CMPlugin to receive a reference to PLUGININFOEX
Diffstat (limited to 'plugins/AsSingleWindow')
-rw-r--r--plugins/AsSingleWindow/src/AsSingleWindow.cpp76
-rw-r--r--plugins/AsSingleWindow/src/AsSingleWindow.h4
-rw-r--r--plugins/AsSingleWindow/src/Options.cpp8
-rw-r--r--plugins/AsSingleWindow/src/Options.h2
-rw-r--r--plugins/AsSingleWindow/src/stdafx.h4
5 files changed, 49 insertions, 45 deletions
diff --git a/plugins/AsSingleWindow/src/AsSingleWindow.cpp b/plugins/AsSingleWindow/src/AsSingleWindow.cpp
index 8ab98c8d1a..87496f8e83 100644
--- a/plugins/AsSingleWindow/src/AsSingleWindow.cpp
+++ b/plugins/AsSingleWindow/src/AsSingleWindow.cpp
@@ -4,11 +4,15 @@
#include "WindowsManager.h"
#include "version.h"
-CLIST_INTERFACE *pcli;
+sPluginVars pluginVars;
+
CMPlugin g_plugin;
+CLIST_INTERFACE *pcli;
int &hLangpack(g_plugin.m_hLang);
-PLUGININFOEX pluginInfo = {
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -20,11 +24,43 @@ PLUGININFOEX pluginInfo = {
{0xF6C73B4, 0x2B2B, 0x711D, {0xFB, 0xB6, 0xBB, 0x26, 0x7D, 0xFD, 0x72, 0x08}}, // 0xF6C73B42B2B711DFBB6BB267DFD7208
};
-sPluginVars pluginVars;
+CMPlugin::CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
+{}
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
- return &pluginInfo;
+ return &pluginInfoEx;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int MsgWindowEvent(WPARAM, LPARAM lParam)
+{
+ MessageWindowEventData* data = (MessageWindowEventData*)lParam;
+
+ if (data == nullptr)
+ return 0;
+
+ switch (data->uType) {
+ case MSG_WINDOW_EVT_OPEN:
+ // Здесь можно отлавливать только открытие окна,
+ // т.к. закрытие может быть закрытием вкладки
+ windowAdd(data->hwndWindow, false);
+ break;
+ }
+
+ return 0;
+}
+
+static int OnModulesLoaded(WPARAM, LPARAM)
+{
+ windowAdd(pcli->hwndContactList, true);
+
+ HookEvent(ME_MSG_WINDOWEVENT, MsgWindowEvent);
+
+ optionsLoad();
+ return 0;
}
static int OnShutdown(WPARAM, LPARAM)
@@ -36,7 +72,7 @@ static int OnShutdown(WPARAM, LPARAM)
extern "C" __declspec(dllexport) int Load(void)
{
- mir_getLP(&pluginInfo);
+ mir_getLP(&pluginInfoEx);
pcli = Clist_GetInterface();
::InitializeCriticalSection(&pluginVars.m_CS);
@@ -47,36 +83,10 @@ extern "C" __declspec(dllexport) int Load(void)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" __declspec(dllexport) int Unload(void)
{
::DeleteCriticalSection(&pluginVars.m_CS);
return 0;
}
-
-int OnModulesLoaded(WPARAM, LPARAM)
-{
- windowAdd(pcli->hwndContactList, true);
-
- HookEvent(ME_MSG_WINDOWEVENT, MsgWindowEvent);
-
- optionsLoad();
- return 0;
-}
-
-int MsgWindowEvent(WPARAM, LPARAM lParam)
-{
- MessageWindowEventData* data = (MessageWindowEventData*)lParam;
-
- if (data == nullptr)
- return 0;
-
- switch (data->uType) {
- case MSG_WINDOW_EVT_OPEN:
- // Здесь можно отлавливать только открытие окна,
- // т.к. закрытие может быть закрытием вкладки
- windowAdd(data->hwndWindow, false);
- break;
- }
-
- return 0;
-}
diff --git a/plugins/AsSingleWindow/src/AsSingleWindow.h b/plugins/AsSingleWindow/src/AsSingleWindow.h
index 035a7697b2..eb00523ec3 100644
--- a/plugins/AsSingleWindow/src/AsSingleWindow.h
+++ b/plugins/AsSingleWindow/src/AsSingleWindow.h
@@ -29,7 +29,3 @@ struct sPluginVars {
};
extern sPluginVars pluginVars;
-extern PLUGININFOEX pluginInfo;
-
-int OnModulesLoaded(WPARAM, LPARAM);
-int MsgWindowEvent(WPARAM, LPARAM);
diff --git a/plugins/AsSingleWindow/src/Options.cpp b/plugins/AsSingleWindow/src/Options.cpp
index 54da7362e4..383e0422d2 100644
--- a/plugins/AsSingleWindow/src/Options.cpp
+++ b/plugins/AsSingleWindow/src/Options.cpp
@@ -103,8 +103,8 @@ void dlgUpdateControls(HWND hWnd)
void optionsLoad()
{
- pluginVars.Options.DrivenWindowPos = db_get_b(0, SETTINGSNAME, "DrivenWindowPosition", ASW_CLWINDOWPOS_RIGHT);
- pluginVars.Options.WindowsMerging = db_get_b(0, SETTINGSNAME, "WindowsMerging", ASW_WINDOWS_MERGEONE);
+ pluginVars.Options.DrivenWindowPos = db_get_b(0, MODULENAME, "DrivenWindowPosition", ASW_CLWINDOWPOS_RIGHT);
+ pluginVars.Options.WindowsMerging = db_get_b(0, MODULENAME, "WindowsMerging", ASW_WINDOWS_MERGEONE);
}
void optionsUpdate(HWND hWnd)
@@ -122,6 +122,6 @@ void optionsUpdate(HWND hWnd)
void optionsSave()
{
- db_set_b(0, SETTINGSNAME, "DrivenWindowPosition", pluginVars.Options.DrivenWindowPos);
- db_set_b(0, SETTINGSNAME, "WindowsMerging", pluginVars.Options.WindowsMerging);
+ db_set_b(0, MODULENAME, "DrivenWindowPosition", pluginVars.Options.DrivenWindowPos);
+ db_set_b(0, MODULENAME, "WindowsMerging", pluginVars.Options.WindowsMerging);
}
diff --git a/plugins/AsSingleWindow/src/Options.h b/plugins/AsSingleWindow/src/Options.h
index 4c0a265793..5a2829dc72 100644
--- a/plugins/AsSingleWindow/src/Options.h
+++ b/plugins/AsSingleWindow/src/Options.h
@@ -1,6 +1,6 @@
#pragma once
-#define SETTINGSNAME "AsSingleWindow"
+#define MODULENAME "AsSingleWindow"
int InitOptions(WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK cbOptionsDialog(HWND, UINT, WPARAM, LPARAM);
diff --git a/plugins/AsSingleWindow/src/stdafx.h b/plugins/AsSingleWindow/src/stdafx.h
index 8b7fa46405..206955b5f7 100644
--- a/plugins/AsSingleWindow/src/stdafx.h
+++ b/plugins/AsSingleWindow/src/stdafx.h
@@ -25,7 +25,5 @@
struct CMPlugin : public PLUGIN<CMPlugin>
{
- CMPlugin() :
- PLUGIN<CMPlugin>(SETTINGSNAME)
- {}
+ CMPlugin();
};