diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-17 21:05:17 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-17 21:05:23 +0300 |
commit | 5ebe9c34375bce857ad3160abba67d6ed2beadaf (patch) | |
tree | 6ec4260f751125db66852d70aed8e106a2527012 /plugins/MirLua/src | |
parent | 754665d1ae053678088144bb833bda76a0d95794 (diff) |
MirLua, MirOTR, New_GPG, OpenSSL, SecureIM -> CMplugin
Diffstat (limited to 'plugins/MirLua/src')
-rw-r--r-- | plugins/MirLua/src/m_icolib.cpp | 4 | ||||
-rw-r--r-- | plugins/MirLua/src/m_options.cpp | 4 | ||||
-rw-r--r-- | plugins/MirLua/src/main.cpp | 21 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_icons.cpp | 2 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_options.cpp | 2 | ||||
-rw-r--r-- | plugins/MirLua/src/stdafx.h | 9 |
6 files changed, 20 insertions, 22 deletions
diff --git a/plugins/MirLua/src/m_icolib.cpp b/plugins/MirLua/src/m_icolib.cpp index f89e7a6dee..332d5273c5 100644 --- a/plugins/MirLua/src/m_icolib.cpp +++ b/plugins/MirLua/src/m_icolib.cpp @@ -28,7 +28,7 @@ static void MakeSKINICONDESC(lua_State *L, SKINICONDESC &sid) if (sid.defaultFile.w == nullptr)
{
sid.defaultFile.w = (wchar_t*)mir_calloc(MAX_PATH + 1);
- GetModuleFileName(g_hInstance, sid.defaultFile.w, MAX_PATH);
+ GetModuleFileName(g_plugin.getInst(), sid.defaultFile.w, MAX_PATH);
}
lua_getfield(L, -1, "DefaultIndex");
@@ -64,7 +64,7 @@ static int lua_AddIcon(lua_State *L) if (sid.defaultFile.w == nullptr)
{
sid.defaultFile.w = (wchar_t*)mir_calloc(MAX_PATH + 1);
- GetModuleFileName(g_hInstance, sid.defaultFile.w, MAX_PATH);
+ GetModuleFileName(g_plugin.getInst(), sid.defaultFile.w, MAX_PATH);
}
}
else if (lua_type(L, 1) == LUA_TTABLE)
diff --git a/plugins/MirLua/src/m_options.cpp b/plugins/MirLua/src/m_options.cpp index 5e548aeeb6..56a41f4f98 100644 --- a/plugins/MirLua/src/m_options.cpp +++ b/plugins/MirLua/src/m_options.cpp @@ -9,7 +9,7 @@ private: public:
CMLuaScriptOptionPage(lua_State *_L, int onInitDialogRef, int onApplyRef)
- : CDlgBase(g_hInstance, IDD_SCRIPTOPTIONSPAGE), L(_L),
+ : CDlgBase(g_plugin.getInst(), IDD_SCRIPTOPTIONSPAGE), L(_L),
m_onInitDialogRef(onInitDialogRef), m_onApplyRef(onApplyRef)
{
}
@@ -43,7 +43,7 @@ public: void MakeOptionDialogPage(lua_State *L, OPTIONSDIALOGPAGE &odp)
{
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.hLangpack = CMLuaEnvironment::GetEnvironmentId(L);
lua_getfield(L, -1, "Flags");
diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp index cee700e68b..31c5d93912 100644 --- a/plugins/MirLua/src/main.cpp +++ b/plugins/MirLua/src/main.cpp @@ -1,8 +1,7 @@ #include "stdafx.h"
int hLangpack;
-
-HINSTANCE g_hInstance;
+CMPlugin g_plugin;
CMLua *g_mLua;
@@ -11,6 +10,8 @@ HANDLE g_hScriptsFolder; HNETLIBUSER hNetlib = nullptr;
+/////////////////////////////////////////////////////////////////////////////////////////
+
PLUGININFOEX pluginInfo =
{
sizeof(PLUGININFOEX),
@@ -26,29 +27,23 @@ PLUGININFOEX pluginInfo = };
-DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
-{
- g_hInstance = hInstance;
-
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
int OnOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = {};
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE;
odp.szGroup.w = LPGENW("Services");
odp.szTitle.w = L"Lua";
odp.szTab.w = LPGENW("Scripts");
odp.pDialog = new CMLuaOptions(g_mLua);
Options_AddPage(wParam, &odp);
-
return 0;
}
@@ -58,7 +53,6 @@ int OnModulesLoaded(WPARAM, LPARAM) g_hScriptsFolder = FoldersRegisterCustomPathT(MODULE, "ScriptsFolder", MIRLUA_PATHT, TranslateT("Scripts folder"));
HookEvent(ME_OPT_INITIALISE, OnOptionsInit);
-
return 0;
}
@@ -83,10 +77,11 @@ extern "C" int __declspec(dllexport) Load(void) g_mLua->Load();
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
-
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload(void)
{
delete g_mLua;
diff --git a/plugins/MirLua/src/mlua_icons.cpp b/plugins/MirLua/src/mlua_icons.cpp index 64648484ed..5feb9bc833 100644 --- a/plugins/MirLua/src/mlua_icons.cpp +++ b/plugins/MirLua/src/mlua_icons.cpp @@ -11,7 +11,7 @@ IconItem Icons[] = void InitIcons()
{
- Icon_Register(g_hInstance, MODULE, Icons, _countof(Icons), MODULE);
+ Icon_Register(g_plugin.getInst(), MODULE, Icons, _countof(Icons), MODULE);
}
HICON GetIcon(int iconId)
diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp index 9aff70ba3f..43451746d4 100644 --- a/plugins/MirLua/src/mlua_options.cpp +++ b/plugins/MirLua/src/mlua_options.cpp @@ -1,7 +1,7 @@ #include "stdafx.h"
CMLuaOptions::CMLuaOptions(CMLua *mLua)
- : CPluginDlgBase(g_hInstance, IDD_OPTIONS, MODULE),
+ : CPluginDlgBase(g_plugin.getInst(), IDD_OPTIONS, MODULE),
m_mLua(mLua), isScriptListInit(false),
m_popupOnError(this, IDC_POPUPONERROR),
m_popupOnObsolete(this, IDC_POPUPONOBSOLETE),
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index b61f7dfedc..54c6f64a4e 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -6,8 +6,6 @@ #include <map>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_core.h>
#include <m_utils.h>
@@ -48,7 +46,12 @@ class CMLuaScript; #define MODULE "MirLua"
-extern HINSTANCE g_hInstance;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE)
+ {}
+};
extern CMLua *g_mLua;
|