diff options
-rw-r--r-- | plugins/MirLua/src/m_database.cpp | 24 | ||||
-rw-r--r-- | plugins/MirLua/src/m_genmenu.cpp | 12 | ||||
-rw-r--r-- | plugins/MirLua/src/m_msg_buttonsbar.cpp | 26 | ||||
-rw-r--r-- | plugins/MirLua/src/m_popup.cpp | 30 | ||||
-rw-r--r-- | plugins/MirLua/src/m_protocols.cpp | 142 | ||||
-rw-r--r-- | plugins/MirLua/src/m_toptoolbar.cpp | 22 | ||||
-rw-r--r-- | plugins/MirLua/src/main.cpp | 4 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua.cpp | 4 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_module_loader.cpp | 1 | ||||
-rw-r--r-- | plugins/MirLua/src/mlua_script_loader.cpp | 17 | ||||
-rw-r--r-- | plugins/MirLua/src/stdafx.h | 4 | ||||
-rw-r--r-- | plugins/MirLua/src/version.h | 2 |
12 files changed, 225 insertions, 63 deletions
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index 8d05a605f3..a1cf6f1dc6 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -89,22 +89,22 @@ static int lua_GetEvent(lua_State *L) }
lua_newtable(L);
- lua_pushstring(L, "Module");
+ lua_pushliteral(L, "Module");
lua_pushstring(L, ptrA(mir_utf8encode(dbei.szModule)));
lua_settable(L, -3);
- lua_pushstring(L, "Timestamp");
+ lua_pushliteral(L, "Timestamp");
lua_pushnumber(L, dbei.timestamp);
lua_settable(L, -3);
- lua_pushstring(L, "Type");
+ lua_pushliteral(L, "Type");
lua_pushinteger(L, dbei.eventType);
lua_settable(L, -3);
- lua_pushstring(L, "Flags");
+ lua_pushliteral(L, "Flags");
lua_pushinteger(L, dbei.flags);
lua_settable(L, -3);
- lua_pushstring(L, "Length");
+ lua_pushliteral(L, "Length");
lua_pushnumber(L, dbei.cbBlob);
lua_settable(L, -3);
- lua_pushstring(L, "Blob");
+ lua_pushliteral(L, "Blob");
lua_newtable(L);
for (DWORD i = 0; i < dbei.cbBlob; i++)
{
@@ -292,13 +292,13 @@ static int SettingsChangedHookEventObjParam(void *obj, WPARAM wParam, LPARAM lPa DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam;
lua_newtable(L);
- lua_pushstring(L, "Module");
+ lua_pushliteral(L, "Module");
lua_pushstring(L, dbcws->szModule);
lua_settable(L, -3);
- lua_pushstring(L, "Setting");
+ lua_pushliteral(L, "Setting");
lua_pushstring(L, dbcws->szSetting);
lua_settable(L, -3);
- lua_pushstring(L, "Value");
+ lua_pushliteral(L, "Value");
switch (dbcws->value.type)
{
case DBVT_BYTE:
@@ -358,13 +358,13 @@ static int lua_DecodeDBCONTACTWRITESETTING(lua_State *L) DBCONTACTWRITESETTING *pDBCWS = (DBCONTACTWRITESETTING*)lua_tointeger(L, 1);
lua_newtable(L);
- lua_pushstring(L, "Module");
+ lua_pushliteral(L, "Module");
lua_pushstring(L, pDBCWS->szModule);
lua_settable(L, -3);
- lua_pushstring(L, "Setting");
+ lua_pushliteral(L, "Setting");
lua_pushstring(L, pDBCWS->szSetting);
lua_settable(L, -3);
- lua_pushstring(L, "Value");
+ lua_pushliteral(L, "Value");
switch (pDBCWS->value.type)
{
case DBVT_BYTE:
diff --git a/plugins/MirLua/src/m_genmenu.cpp b/plugins/MirLua/src/m_genmenu.cpp index 57c6938f60..75be453dd4 100644 --- a/plugins/MirLua/src/m_genmenu.cpp +++ b/plugins/MirLua/src/m_genmenu.cpp @@ -4,7 +4,7 @@ void MakeMenuItem(lua_State *L, CMenuItem &mi) {
mi.hLangpack = hScriptsLangpack;
- lua_pushstring(L, "Flags");
+ lua_pushliteral(L, "Flags");
lua_gettable(L, -2);
mi.flags = lua_tointeger(L, -1);
lua_pop(L, 1);
@@ -12,27 +12,27 @@ void MakeMenuItem(lua_State *L, CMenuItem &mi) if (!(mi.flags & CMIF_TCHAR))
mi.flags |= CMIF_TCHAR;
- lua_pushstring(L, "Name");
+ lua_pushliteral(L, "Name");
lua_gettable(L, -2);
mi.name.t = mir_utf8decodeT((char*)luaL_checkstring(L, -1));
lua_pop(L, 1);
- lua_pushstring(L, "Position");
+ lua_pushliteral(L, "Position");
lua_gettable(L, -2);
mi.position = lua_tointeger(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "Icon");
+ lua_pushliteral(L, "Icon");
lua_gettable(L, -2);
mi.hIcolibItem = (HANDLE)lua_touserdata(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "Service");
+ lua_pushliteral(L, "Service");
lua_gettable(L, -2);
mi.pszService = (char*)lua_tostring(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "Parent");
+ lua_pushliteral(L, "Parent");
lua_gettable(L, -2);
mi.root = (HGENMENU)lua_touserdata(L, -1);
lua_pop(L, 1);
diff --git a/plugins/MirLua/src/m_msg_buttonsbar.cpp b/plugins/MirLua/src/m_msg_buttonsbar.cpp index 9b3fc3b8e7..40cf42ae95 100644 --- a/plugins/MirLua/src/m_msg_buttonsbar.cpp +++ b/plugins/MirLua/src/m_msg_buttonsbar.cpp @@ -6,17 +6,17 @@ static BBButton* MakeBBButton(lua_State *L) tbb->cbSize = sizeof(BBButton);
tbb->dwDefPos = 100;
- lua_pushstring(L, "Module");
+ lua_pushliteral(L, "Module");
lua_gettable(L, -2);
tbb->pszModuleName = mir_utf8decode((char*)luaL_checkstring(L, -1), NULL);
lua_pop(L, 1);
- lua_pushstring(L, "ButtonID");
+ lua_pushliteral(L, "ButtonID");
lua_gettable(L, -2);
tbb->dwButtonID = luaL_checkinteger(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "Flags");
+ lua_pushliteral(L, "Flags");
lua_gettable(L, -2);
tbb->bbbFlags = lua_tointeger(L, -1);
lua_pop(L, 1);
@@ -24,12 +24,12 @@ static BBButton* MakeBBButton(lua_State *L) if ((tbb->bbbFlags & BBBF_ANSITOOLTIP))
tbb->bbbFlags &= ~BBBF_ANSITOOLTIP;
- lua_pushstring(L, "Tooltip");
+ lua_pushliteral(L, "Tooltip");
lua_gettable(L, -2);
tbb->ptszTooltip = mir_utf8decodeT((char*)lua_tostring(L, -1));
lua_pop(L, 1);
- lua_pushstring(L, "Icon");
+ lua_pushliteral(L, "Icon");
lua_gettable(L, -2);
tbb->hIcon = (HANDLE)lua_touserdata(L, -1);
lua_pop(L, 1);
@@ -96,16 +96,16 @@ int ButtonPressedHookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPAR CustomButtonClickData *bcd = (CustomButtonClickData*)lParam;
lua_newtable(L);
- lua_pushstring(L, "Module");
+ lua_pushliteral(L, "Module");
lua_pushstring(L, ptrA(mir_utf8encode(bcd->pszModule)));
lua_settable(L, -3);
- lua_pushstring(L, "ButtonID");
+ lua_pushliteral(L, "ButtonID");
lua_pushinteger(L, bcd->dwButtonId);
lua_settable(L, -3);
- lua_pushstring(L, "hContact");
+ lua_pushliteral(L, "hContact");
lua_pushinteger(L, bcd->hContact);
lua_settable(L, -3);
- lua_pushstring(L, "Flags");
+ lua_pushliteral(L, "Flags");
lua_pushinteger(L, bcd->flags);
lua_settable(L, -3);
@@ -142,16 +142,16 @@ static int lua_DecodeCustomButtonClickData(lua_State *L) CustomButtonClickData *bcd = (CustomButtonClickData*)lua_tointeger(L, 1);
lua_newtable(L);
- lua_pushstring(L, "Module");
+ lua_pushliteral(L, "Module");
lua_pushstring(L, ptrA(mir_utf8encode(bcd->pszModule)));
lua_settable(L, -3);
- lua_pushstring(L, "ButtonID");
+ lua_pushliteral(L, "ButtonID");
lua_pushinteger(L, bcd->dwButtonId);
lua_settable(L, -3);
- lua_pushstring(L, "hContact");
+ lua_pushliteral(L, "hContact");
lua_pushinteger(L, bcd->hContact);
lua_settable(L, -3);
- lua_pushstring(L, "Flags");
+ lua_pushliteral(L, "Flags");
lua_pushinteger(L, bcd->flags);
lua_settable(L, -3);
diff --git a/plugins/MirLua/src/m_popup.cpp b/plugins/MirLua/src/m_popup.cpp index 961d34492d..2127f70f5f 100644 --- a/plugins/MirLua/src/m_popup.cpp +++ b/plugins/MirLua/src/m_popup.cpp @@ -4,32 +4,32 @@ static POPUPDATAT* MakePopupData(lua_State *L) {
POPUPDATAT *ppd = (POPUPDATAT*)mir_calloc(sizeof(POPUPDATAT));
- lua_pushstring(L, "ContactName");
+ lua_pushliteral(L, "ContactName");
lua_gettable(L, -2);
mir_tstrcpy(ppd->lptzContactName, ptrT(mir_utf8decodeT(lua_tostring(L, -1))));
lua_pop(L, 1);
- lua_pushstring(L, "Text");
+ lua_pushliteral(L, "Text");
lua_gettable(L, -2);
mir_tstrcpy(ppd->lptzText, ptrT(mir_utf8decodeT(luaL_checkstring(L, -1))));
lua_pop(L, 1);
- lua_pushstring(L, "hContact");
+ lua_pushliteral(L, "hContact");
lua_gettable(L, -2);
ppd->lchContact = lua_tointeger(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "ColorBack");
+ lua_pushliteral(L, "ColorBack");
lua_gettable(L, -2);
ppd->colorBack = lua_tonumber(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "ColorText");
+ lua_pushliteral(L, "ColorText");
lua_gettable(L, -2);
ppd->colorText = lua_tonumber(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "Seconds");
+ lua_pushliteral(L, "Seconds");
lua_gettable(L, -2);
ppd->iSeconds = lua_tointeger(L, -1);
lua_pop(L, 1);
@@ -58,7 +58,7 @@ static POPUPDATA2* MakePopupData2(lua_State *L) POPUPDATA2 *ppd = (POPUPDATA2*)mir_calloc(sizeof(POPUPDATA2));
ppd->cbSize = sizeof(POPUPDATA2);
- lua_pushstring(L, "Flags");
+ lua_pushliteral(L, "Flags");
lua_gettable(L, -2);
ppd->flags = lua_tointeger(L, -1);
lua_pop(L, 1);
@@ -66,42 +66,42 @@ static POPUPDATA2* MakePopupData2(lua_State *L) if (!(ppd->flags & PU2_TCHAR))
ppd->flags |= PU2_TCHAR;
- lua_pushstring(L, "Title");
+ lua_pushliteral(L, "Title");
lua_gettable(L, -2);
ppd->lptzTitle = mir_utf8decodeT(lua_tostring(L, -1));
lua_pop(L, 1);
- lua_pushstring(L, "Text");
+ lua_pushliteral(L, "Text");
lua_gettable(L, -2);
ppd->lptzText = mir_utf8decodeT(luaL_checkstring(L, -1));
lua_pop(L, 1);
- lua_pushstring(L, "hContact");
+ lua_pushliteral(L, "hContact");
lua_gettable(L, -2);
ppd->lchContact = lua_tointeger(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "ColorBack");
+ lua_pushliteral(L, "ColorBack");
lua_gettable(L, -2);
ppd->colorBack = lua_tonumber(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "ColorText");
+ lua_pushliteral(L, "ColorText");
lua_gettable(L, -2);
ppd->colorText = lua_tonumber(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "hEvent");
+ lua_pushliteral(L, "hEvent");
lua_gettable(L, -2);
ppd->lchEvent = lua_touserdata(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "Timestamp");
+ lua_pushliteral(L, "Timestamp");
lua_gettable(L, -2);
ppd->dwTimestamp = lua_tonumber(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "Timeout");
+ lua_pushliteral(L, "Timeout");
lua_gettable(L, -2);
ppd->iSeconds = lua_tointeger(L, -1);
lua_pop(L, 1);
diff --git a/plugins/MirLua/src/m_protocols.cpp b/plugins/MirLua/src/m_protocols.cpp new file mode 100644 index 0000000000..9e121b8a66 --- /dev/null +++ b/plugins/MirLua/src/m_protocols.cpp @@ -0,0 +1,142 @@ +#include "stdafx.h"
+
+static void MapToTable(lua_State *L, const PROTOCOLDESCRIPTOR* pd)
+{
+ lua_newtable(L);
+ lua_pushliteral(L, "Name");
+ lua_pushstring(L, ptrA(mir_utf8encode(pd->szName)));
+ lua_settable(L, -3);
+ lua_pushliteral(L, "Type");
+ lua_pushinteger(L, pd->type);
+ lua_settable(L, -3);
+}
+
+static int lua_GetProto(lua_State *L)
+{
+ ptrA name(mir_utf8decodeA(luaL_checkstring(L, 1)));
+
+ PROTOCOLDESCRIPTOR* pd = ::Proto_IsProtocolLoaded(name);
+
+ if (pd)
+ MapToTable(L, pd);
+ else
+ lua_pushnil(L);
+
+ return 1;
+}
+
+static int lua_EnumProtos(lua_State *L)
+{
+ if (!lua_isfunction(L, 1))
+ {
+ lua_pushlightuserdata(L, NULL);
+ return 1;
+ }
+
+ lua_pushvalue(L, 1);
+ int ref = luaL_ref(L, LUA_REGISTRYINDEX);
+
+ int count;
+ PROTOCOLDESCRIPTOR** protos;
+ Proto_EnumProtocols(&count, &protos);
+
+ for (int i = 0; i < count; i++)
+ {
+ lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
+ MapToTable(L, protos[i]);
+ if (lua_pcall(L, 1, 0, 0))
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ }
+
+ luaL_unref(L, LUA_REGISTRYINDEX, ref);
+ lua_pushinteger(L, count);
+
+ return 1;
+}
+
+static void MapToTable(lua_State *L, const PROTOACCOUNT* pa)
+{
+ lua_newtable(L);
+ lua_pushliteral(L, "InternalName");
+ lua_pushstring(L, ptrA(mir_utf8encode(pa->szModuleName)));
+ lua_settable(L, -3);
+ lua_pushliteral(L, "AccountName");
+ lua_pushstring(L, ptrA(mir_utf8encodeT(pa->tszAccountName)));
+ lua_settable(L, -3);
+ lua_pushliteral(L, "ProtoName");
+ lua_pushstring(L, ptrA(mir_utf8encode(pa->szProtoName)));
+ lua_settable(L, -3);
+ lua_pushliteral(L, "IsEnabled");
+ lua_pushboolean(L, pa->bIsEnabled);
+ lua_settable(L, -3);
+ lua_pushliteral(L, "IsVisible");
+ lua_pushboolean(L, pa->bIsVisible);
+ lua_settable(L, -3);
+ lua_pushliteral(L, "IsVirtual");
+ lua_pushboolean(L, pa->bIsVirtual);
+ lua_settable(L, -3);
+ lua_pushliteral(L, "OldProto");
+ lua_pushboolean(L, pa->bOldProto);
+ lua_settable(L, -3);
+}
+
+static int lua_GetAccount(lua_State *L)
+{
+ ptrA moduleName(mir_utf8decodeA(luaL_checkstring(L, 1)));
+
+ PROTOACCOUNT* pa = ::Proto_GetAccount(moduleName);
+
+ if (pa)
+ MapToTable(L, pa);
+ else
+ lua_pushnil(L);
+
+ return 1;
+}
+
+static int lua_EnumAccounts(lua_State *L)
+{
+ if (!lua_isfunction(L, 1))
+ {
+ lua_pushlightuserdata(L, NULL);
+ return 1;
+ }
+
+ lua_pushvalue(L, 1);
+ int ref = luaL_ref(L, LUA_REGISTRYINDEX);
+
+ int count;
+ PROTOACCOUNT** accounts;
+ Proto_EnumAccounts(&count, &accounts);
+
+ for (int i = 0; i < count; i++)
+ {
+ lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
+ MapToTable(L, accounts[i]);
+ if (lua_pcall(L, 1, 0, 0))
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ }
+
+ luaL_unref(L, LUA_REGISTRYINDEX, ref);
+ lua_pushinteger(L, count);
+
+ return 1;
+}
+
+static luaL_Reg protocolsApi[] =
+{
+ { "GetProto", lua_GetProto },
+ { "EnumProtos", lua_EnumProtos },
+
+ { "GetAccount", lua_GetAccount },
+ { "EnumAccounts", lua_EnumAccounts },
+
+ { NULL, NULL }
+};
+
+LUAMOD_API int luaopen_m_protocols(lua_State *L)
+{
+ luaL_newlib(L, protocolsApi);
+
+ return 1;
+}
diff --git a/plugins/MirLua/src/m_toptoolbar.cpp b/plugins/MirLua/src/m_toptoolbar.cpp index 71ecbb2b0b..0a17afa9cd 100644 --- a/plugins/MirLua/src/m_toptoolbar.cpp +++ b/plugins/MirLua/src/m_toptoolbar.cpp @@ -4,59 +4,59 @@ static TTBButton* MakeTBButton(lua_State *L) {
TTBButton *tbb = (TTBButton*)mir_calloc(sizeof(TTBButton));
- lua_pushstring(L, "Name");
+ lua_pushliteral(L, "Name");
lua_gettable(L, -2);
tbb->name = mir_utf8decode((char*)luaL_checkstring(L, -1), NULL);
lua_pop(L, 1);
- lua_pushstring(L, "Service");
+ lua_pushliteral(L, "Service");
lua_gettable(L, -2);
tbb->pszService = (char*)lua_tostring(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "Flags");
+ lua_pushliteral(L, "Flags");
lua_gettable(L, -2);
tbb->dwFlags = lua_tointeger(L, -1);
lua_pop(L, 1);
// up state
- lua_pushstring(L, "IconUp");
+ lua_pushliteral(L, "IconUp");
lua_gettable(L, -2);
tbb->hIconHandleUp = (HANDLE)lua_touserdata(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "TooltipUp");
+ lua_pushliteral(L, "TooltipUp");
lua_gettable(L, -2);
tbb->pszTooltipUp = mir_utf8decode((char*)lua_tostring(L, -1), NULL);
lua_pop(L, 1);
- lua_pushstring(L, "wParamUp");
+ lua_pushliteral(L, "wParamUp");
lua_gettable(L, -2);
tbb->wParamUp = luaM_towparam(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "lParamUp");
+ lua_pushliteral(L, "lParamUp");
lua_gettable(L, -2);
tbb->lParamUp = luaM_tolparam(L, -1);
lua_pop(L, 1);
// dn state
- lua_pushstring(L, "IconDown");
+ lua_pushliteral(L, "IconDown");
lua_gettable(L, -2);
tbb->hIconHandleDn = (HANDLE)lua_touserdata(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "TooltipDown");
+ lua_pushliteral(L, "TooltipDown");
lua_gettable(L, -2);
tbb->pszTooltipDn = mir_utf8decode((char*)lua_tostring(L, -1), NULL);
lua_pop(L, 1);
- lua_pushstring(L, "wParamDown");
+ lua_pushliteral(L, "wParamDown");
lua_gettable(L, -2);
tbb->wParamDown = luaM_towparam(L, -1);
lua_pop(L, 1);
- lua_pushstring(L, "lParamDown");
+ lua_pushliteral(L, "lParamDown");
lua_gettable(L, -2);
tbb->lParamDown = luaM_tolparam(L, -1);
lua_pop(L, 1);
diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp index 9ac95a6579..b90eeb97b2 100644 --- a/plugins/MirLua/src/main.cpp +++ b/plugins/MirLua/src/main.cpp @@ -42,8 +42,8 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) int OnModulesLoaded(WPARAM, LPARAM)
{
- g_hCommonFolderPath = FoldersRegisterCustomPathT("MirLua", Translate("Common scripts folder"), COMMON_SCRIPTS_PATHT);
- g_hCustomFolderPath = FoldersRegisterCustomPathT("MirLua", Translate("Custom scripts folder"), CUSTOM_SCRIPTS_PATHT);
+ g_hCommonFolderPath = FoldersRegisterCustomPathT(MODULE, Translate("Common scripts folder"), COMMON_SCRIPTS_PATHT);
+ g_hCustomFolderPath = FoldersRegisterCustomPathT(MODULE, Translate("Custom scripts folder"), CUSTOM_SCRIPTS_PATHT);
g_mLua = new CMLua();
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index 61405de928..c1dd847be4 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -27,9 +27,9 @@ void CMLua::Load() luaL_openlibs(L);
lua_getglobal(L, "package");
- lua_pushstring(L, "");
+ lua_pushliteral(L, "");
lua_setfield(L, -2, "path");
- lua_pushstring(L, "");
+ lua_pushliteral(L, "");
lua_setfield(L, -2, "cpath");
lua_pop(L, 1);
diff --git a/plugins/MirLua/src/mlua_module_loader.cpp b/plugins/MirLua/src/mlua_module_loader.cpp index 391daadfa6..b27424d5ff 100644 --- a/plugins/MirLua/src/mlua_module_loader.cpp +++ b/plugins/MirLua/src/mlua_module_loader.cpp @@ -24,6 +24,7 @@ void CLuaModuleLoader::LoadModules() PreloadModule(MLUA_MESSAGE, luaopen_m_message);
PreloadModule(MLUA_MSGBUTTONSBAR, luaopen_m_msg_buttonsbar);
PreloadModule(MLUA_POPUP, luaopen_m_popup);
+ PreloadModule(MLUA_PROTOCOLS, luaopen_m_protocols);
PreloadModule(MLUA_TOPTOOLBAR, luaopen_m_toptoolbar);
PreloadModule(MLUA_VARIABLES, luaopen_m_variables);
PreloadModule(MLUA_WINDOWS, luaopen_m_windows);
diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp index 7150ebdc48..3a25345c93 100644 --- a/plugins/MirLua/src/mlua_script_loader.cpp +++ b/plugins/MirLua/src/mlua_script_loader.cpp @@ -21,7 +21,13 @@ void CLuaScriptLoader::RegisterScriptsFolder(const char *path) void CLuaScriptLoader::LoadScript(const TCHAR *path)
{
- if (luaL_dofile(L, T2Utf(path)))
+ if (luaL_loadfile(L, T2Utf(path)))
+ {
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ return;
+ }
+
+ if (lua_pcall(L, 0, 1, 0))
{
CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
return;
@@ -30,6 +36,14 @@ void CLuaScriptLoader::LoadScript(const TCHAR *path) TCHAR buf[4096];
mir_sntprintf(buf, _T("%s:OK"), path);
CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib, (LPARAM)buf);
+
+ if (lua_istable(L, -1))
+ {
+ lua_pushliteral(L, "Load");
+ lua_gettable(L, -2);
+ if (lua_isfunction(L, -1) && lua_pcall(L, 0, 0, 0))
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ }
}
void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir)
@@ -77,6 +91,7 @@ void CLuaScriptLoader::UnloadScript(const TCHAR *path) lua_pushnil(L);
lua_setfield(L, -2, moduleName);
lua_pop(L, 1);
+
lua_pushnil(L);
lua_setglobal(L, moduleName);
}
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 867d07f7e8..d43437e64c 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -17,6 +17,7 @@ #include <m_clist.h>
#include <m_icolib.h>
#include <m_message.h>
+#include <m_protocols.h>
#include <m_folders.h>
#include <m_msg_buttonsbar.h>
@@ -83,6 +84,9 @@ LUAMOD_API int (luaopen_m_msg_buttonsbar)(lua_State *L); #define MLUA_POPUP "m_popup"
LUAMOD_API int (luaopen_m_popup)(lua_State *L);
+#define MLUA_PROTOCOLS "m_protocols"
+LUAMOD_API int (luaopen_m_protocols)(lua_State *L);
+
#define MLUA_TOPTOOLBAR "m_toptoolbar"
LUAMOD_API int (luaopen_m_toptoolbar)(lua_State *L);
diff --git a/plugins/MirLua/src/version.h b/plugins/MirLua/src/version.h index 7be6f65f4a..6dd15f8c9f 100644 --- a/plugins/MirLua/src/version.h +++ b/plugins/MirLua/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 3
-#define __BUILD_NUM 5
+#define __BUILD_NUM 6
#include <stdver.h>
|