From 8a74e7495ce5ad39de4f5c25121a84d35df90c36 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 20 May 2018 15:08:48 +0300 Subject: CMPlugin to receive a reference to PLUGININFOEX --- plugins/MirLua/src/m_hotkeys.cpp | 2 +- plugins/MirLua/src/m_icolib.cpp | 4 ++-- plugins/MirLua/src/m_message.cpp | 2 +- plugins/MirLua/src/m_sounds.cpp | 2 +- plugins/MirLua/src/main.cpp | 24 ++++++++++++++---------- plugins/MirLua/src/mlua.cpp | 4 +++- plugins/MirLua/src/mlua_icons.cpp | 2 +- plugins/MirLua/src/mlua_options.cpp | 2 +- plugins/MirLua/src/mlua_script.cpp | 6 +++--- plugins/MirLua/src/mlua_utils.cpp | 8 ++++---- plugins/MirLua/src/stdafx.h | 6 ++---- 11 files changed, 33 insertions(+), 29 deletions(-) (limited to 'plugins/MirLua') diff --git a/plugins/MirLua/src/m_hotkeys.cpp b/plugins/MirLua/src/m_hotkeys.cpp index f6041b504e..8e38f16bf8 100644 --- a/plugins/MirLua/src/m_hotkeys.cpp +++ b/plugins/MirLua/src/m_hotkeys.cpp @@ -18,7 +18,7 @@ void MakeHotkey(lua_State *L, HOTKEYDESC &hk) lua_pop(L, 1); lua_getfield(L, -1, "Section"); - hk.szSection.w = mir_utf8decodeW(luaL_optstring(L, -1, MODULE)); + hk.szSection.w = mir_utf8decodeW(luaL_optstring(L, -1, MODULENAME)); lua_pop(L, 1); lua_getfield(L, -1, "Hotkey"); diff --git a/plugins/MirLua/src/m_icolib.cpp b/plugins/MirLua/src/m_icolib.cpp index 332d5273c5..a83c9877d7 100644 --- a/plugins/MirLua/src/m_icolib.cpp +++ b/plugins/MirLua/src/m_icolib.cpp @@ -18,7 +18,7 @@ static void MakeSKINICONDESC(lua_State *L, SKINICONDESC &sid) lua_pop(L, 1); lua_getfield(L, -1, "Section"); - sid.section.w = mir_utf8decodeW(luaL_optstring(L, 3, MODULE)); + sid.section.w = mir_utf8decodeW(luaL_optstring(L, 3, MODULENAME)); lua_pop(L, 1); lua_getfield(L, -1, "DefaultFile"); @@ -57,7 +57,7 @@ static int lua_AddIcon(lua_State *L) sid.flags = SIDF_ALL_UNICODE; sid.pszName = mir_utf8decodeA(luaL_checkstring(L, 1)); sid.description.w = mir_utf8decodeW(luaL_checkstring(L, 2)); - sid.section.w = mir_utf8decodeW(luaL_optstring(L, 3, MODULE)); + sid.section.w = mir_utf8decodeW(luaL_optstring(L, 3, MODULENAME)); sid.defaultFile.w = mir_utf8decodeW(lua_tostring(L, 4)); sid.hDefaultIcon = GetIcon(IDI_SCRIPT); diff --git a/plugins/MirLua/src/m_message.cpp b/plugins/MirLua/src/m_message.cpp index b35b4dd67d..4ac1f991e9 100644 --- a/plugins/MirLua/src/m_message.cpp +++ b/plugins/MirLua/src/m_message.cpp @@ -35,7 +35,7 @@ static int message_Send(lua_State *L) } else if ((res = ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)message)) != ACKRESULT_FAILED) { DBEVENTINFO dbei = {}; - dbei.szModule = MODULE; + dbei.szModule = MODULENAME; dbei.timestamp = time(0); dbei.eventType = EVENTTYPE_MESSAGE; dbei.cbBlob = (DWORD)mir_strlen(message); diff --git a/plugins/MirLua/src/m_sounds.cpp b/plugins/MirLua/src/m_sounds.cpp index e6737ed705..177148320a 100644 --- a/plugins/MirLua/src/m_sounds.cpp +++ b/plugins/MirLua/src/m_sounds.cpp @@ -4,7 +4,7 @@ static int lua_AddSound(lua_State *L) { ptrA name(mir_utf8decodeA(luaL_checkstring(L, 1))); ptrW description(mir_utf8decodeW(luaL_checkstring(L, 2))); - ptrW section(mir_utf8decodeW(luaL_optstring(L, 3, MODULE))); + ptrW section(mir_utf8decodeW(luaL_optstring(L, 3, MODULENAME))); ptrW filePath(mir_utf8decodeW(lua_tostring(L, 4))); int res; diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp index 6388952bae..73c3d91aa1 100644 --- a/plugins/MirLua/src/main.cpp +++ b/plugins/MirLua/src/main.cpp @@ -12,7 +12,7 @@ HNETLIBUSER hNetlib = nullptr; ///////////////////////////////////////////////////////////////////////////////////////// -PLUGININFOEX pluginInfo = +PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -27,9 +27,13 @@ PLUGININFOEX pluginInfo = }; +CMPlugin::CMPlugin() : + PLUGIN(MODULENAME, pluginInfoEx) +{} + extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { - return &pluginInfo; + return &pluginInfoEx; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -49,8 +53,8 @@ int OnOptionsInit(WPARAM wParam, LPARAM) int OnModulesLoaded(WPARAM, LPARAM) { - g_hCLibsFolder = FoldersRegisterCustomPathT(MODULE, "CLibsFolder", MIRLUA_PATHT, TranslateT("C libs folder")); - g_hScriptsFolder = FoldersRegisterCustomPathT(MODULE, "ScriptsFolder", MIRLUA_PATHT, TranslateT("Scripts folder")); + g_hCLibsFolder = FoldersRegisterCustomPathT(MODULENAME, "CLibsFolder", MIRLUA_PATHT, TranslateT("C libs folder")); + g_hScriptsFolder = FoldersRegisterCustomPathT(MODULENAME, "ScriptsFolder", MIRLUA_PATHT, TranslateT("Scripts folder")); HookEvent(ME_OPT_INITIALISE, OnOptionsInit); return 0; @@ -58,20 +62,20 @@ int OnModulesLoaded(WPARAM, LPARAM) extern "C" int __declspec(dllexport) Load(void) { - mir_getLP(&pluginInfo); + mir_getLP(&pluginInfoEx); InitIcons(); NETLIBUSER nlu = {}; nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS; - nlu.szDescriptiveName.a = MODULE; - nlu.szSettingsModule = MODULE; + nlu.szDescriptiveName.a = MODULENAME; + nlu.szSettingsModule = MODULENAME; hNetlib = Netlib_RegisterUser(&nlu); - Proto_RegisterModule(PROTOTYPE_FILTER, MODULE); + Proto_RegisterModule(PROTOTYPE_FILTER, MODULENAME); - hRecvMessage = CreateHookableEvent(MODULE PSR_MESSAGE); - CreateProtoServiceFunction(MODULE, PSR_MESSAGE, FilterRecvMessage); + hRecvMessage = CreateHookableEvent(MODULENAME PSR_MESSAGE); + CreateProtoServiceFunction(MODULENAME, PSR_MESSAGE, FilterRecvMessage); g_mLua = new CMLua(); g_mLua->Load(); diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index b0a12289c6..169dcb6a91 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -1,9 +1,11 @@ #include "stdafx.h" +extern PLUGININFOEX pluginInfoEx; + int hMLuaLangpack; CMLua::CMLua() - : PLUGIN(MODULE), + : PLUGIN(MODULENAME, pluginInfoEx), L(nullptr), Scripts(1) { diff --git a/plugins/MirLua/src/mlua_icons.cpp b/plugins/MirLua/src/mlua_icons.cpp index 835f45d243..3b2466bc27 100644 --- a/plugins/MirLua/src/mlua_icons.cpp +++ b/plugins/MirLua/src/mlua_icons.cpp @@ -11,7 +11,7 @@ IconItem Icons[] = void InitIcons() { - g_plugin.registerIcon(MODULE, Icons, MODULE); + g_plugin.registerIcon(MODULENAME, Icons, MODULENAME); } HICON GetIcon(int iconId) diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp index d518cae533..226a925fd9 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_plugin, IDD_OPTIONS, MODULE), + : CPluginDlgBase(g_plugin, IDD_OPTIONS, MODULENAME), m_mLua(mLua), isScriptListInit(false), m_popupOnError(this, IDC_POPUPONERROR), m_popupOnObsolete(this, IDC_POPUPONOBSOLETE), diff --git a/plugins/MirLua/src/mlua_script.cpp b/plugins/MirLua/src/mlua_script.cpp index 83b5008e15..9e4cc4ffbe 100644 --- a/plugins/MirLua/src/mlua_script.cpp +++ b/plugins/MirLua/src/mlua_script.cpp @@ -44,17 +44,17 @@ const wchar_t* CMLuaScript::GetFileName() const bool CMLuaScript::IsEnabled() { - return db_get_b(NULL, MODULE, _T2A(fileName), 1); + return db_get_b(NULL, MODULENAME, _T2A(fileName), 1); } void CMLuaScript::Enable() { - db_unset(NULL, MODULE, _T2A(fileName)); + db_unset(NULL, MODULENAME, _T2A(fileName)); } void CMLuaScript::Disable() { - db_set_b(NULL, MODULE, _T2A(fileName), 0); + db_set_b(NULL, MODULENAME, _T2A(fileName), 0); } CMLuaScript::Status CMLuaScript::GetStatus() const diff --git a/plugins/MirLua/src/mlua_utils.cpp b/plugins/MirLua/src/mlua_utils.cpp index 9275b74a7f..5ecdbc677d 100644 --- a/plugins/MirLua/src/mlua_utils.cpp +++ b/plugins/MirLua/src/mlua_utils.cpp @@ -44,16 +44,16 @@ void ObsoleteMethod(lua_State *L, const char *message) char text[512]; mir_snprintf(text, "%s is obsolete. %s", ar.name, message); Log(text); - if (db_get_b(NULL, MODULE, "PopupOnObsolete", 0)) - ShowNotification(MODULE, text, MB_OK | MB_ICONWARNING, NULL); + if (db_get_b(NULL, MODULENAME, "PopupOnObsolete", 0)) + ShowNotification(MODULENAME, text, MB_OK | MB_ICONWARNING, NULL); } void ReportError(lua_State *L) { const char *message = lua_tostring(L, -1); Log(message); - if (db_get_b(NULL, MODULE, "PopupOnError", 0)) - ShowNotification(MODULE, message, MB_OK | MB_ICONERROR); + if (db_get_b(NULL, MODULENAME, "PopupOnError", 0)) + ShowNotification(MODULENAME, message, MB_OK | MB_ICONERROR); } int luaM_atpanic(lua_State *L) diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 54c6f64a4e..f97ecd09de 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -44,13 +44,11 @@ class CMLuaScript; #include "mlua_options.h" #include "mlua_metatable.h" -#define MODULE "MirLua" +#define MODULENAME "MirLua" struct CMPlugin : public PLUGIN { - CMPlugin() : - PLUGIN(MODULE) - {} + CMPlugin(); }; extern CMLua *g_mLua; -- cgit v1.2.3