summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-10-26 20:06:26 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-10-26 20:06:26 +0000
commit2990dd9600121101a2149b4fcb35a614693c8328 (patch)
tree3b93ad624bae56895857ac9ab54776609600ea10 /plugins/MirLua/src
parent222cd09a54fa24a87614addbc6f68781f5344299 (diff)
git-svn-id: http://svn.miranda-ng.org/main/trunk@15620 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src')
-rw-r--r--plugins/MirLua/src/m_core.cpp19
-rw-r--r--plugins/MirLua/src/m_database.cpp2
-rw-r--r--plugins/MirLua/src/m_protocols.cpp16
3 files changed, 27 insertions, 10 deletions
diff --git a/plugins/MirLua/src/m_core.cpp b/plugins/MirLua/src/m_core.cpp
index b3c5afc73f..698eacffa3 100644
--- a/plugins/MirLua/src/m_core.cpp
+++ b/plugins/MirLua/src/m_core.cpp
@@ -177,6 +177,23 @@ static int lua_CallService(lua_State *L)
return 1;
}
+static int lua_IsPluginLoaded(lua_State *L)
+{
+ const char *value = luaL_checkstring(L, 1);
+
+ MUUID uuid = { 0 };
+ int res = sscanf_s(value, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
+ &uuid.a, &uuid.b, &uuid.c, &uuid.d[0], &uuid.d[1], &uuid.d[2], &uuid.d[3], &uuid.d[4], &uuid.d[5], &uuid.d[6], &uuid.d[7]);
+ if (res == 11)
+ {
+ res = ::IsPluginLoaded(uuid);
+ }
+ lua_pushboolean(L, res);
+
+ return 1;
+}
+
+
static int lua_Utf8DecodeA(lua_State *L)
{
return luaM_toansi(L);
@@ -244,6 +261,8 @@ luaL_Reg coreApi[] =
{ "ServiceExists", lua_ServiceExists },
{ "CallService", lua_CallService },
+ { "IsPluginLoaded", lua_IsPluginLoaded },
+
{ "Utf8DecodeA", lua_Utf8DecodeA },
{ "Utf8DecodeW", lua_Utf8DecodeW },
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp
index 1854f5d1e1..a165fed50e 100644
--- a/plugins/MirLua/src/m_database.cpp
+++ b/plugins/MirLua/src/m_database.cpp
@@ -345,6 +345,8 @@ static int lua_SettingIterator(lua_State *L)
static int lua_AllSettings(lua_State *L)
{
MCONTACT hContact = lua_tointeger(L, 1);
+ int tp = lua_type(L, 2);
+ const char *type = lua_typename(L, tp);
const char* szModule = luaL_checkstring(L, 2);
enumDBSettingsParam* param = (enumDBSettingsParam*)mir_alloc(sizeof(enumDBSettingsParam));
diff --git a/plugins/MirLua/src/m_protocols.cpp b/plugins/MirLua/src/m_protocols.cpp
index dcf6819fe6..3d9908a61a 100644
--- a/plugins/MirLua/src/m_protocols.cpp
+++ b/plugins/MirLua/src/m_protocols.cpp
@@ -15,11 +15,9 @@ static void MapToTable(lua_State *L, const PROTOCOLDESCRIPTOR* pd)
static int lua_GetProto(lua_State *L)
{
- ObsoleteMethod(L, "Use totable(x, \"PROTOCOLDESCRIPTOR\") instead");
+ const char *name = luaL_checkstring(L, 1);
- ptrA name(mir_utf8decodeA(luaL_checkstring(L, 1)));
-
- PROTOCOLDESCRIPTOR* pd = ::Proto_IsProtocolLoaded(name);
+ PROTOCOLDESCRIPTOR* pd = ::Proto_IsProtocolLoaded(ptrA(mir_utf8decodeA(name)));
if (pd)
MapToTable(L, pd);
@@ -95,7 +93,7 @@ static int lua_EnumProtos(lua_State *L)
static void MapToTable(lua_State *L, const PROTOACCOUNT* pa)
{
lua_newtable(L);
- lua_pushliteral(L, "InternalName");
+ lua_pushliteral(L, "ModuleName");
lua_pushstring(L, ptrA(mir_utf8encode(pa->szModuleName)));
lua_settable(L, -3);
lua_pushliteral(L, "AccountName");
@@ -113,15 +111,13 @@ static void MapToTable(lua_State *L, const PROTOACCOUNT* pa)
lua_pushliteral(L, "IsVirtual");
lua_pushboolean(L, pa->bIsVirtual);
lua_settable(L, -3);
- lua_pushliteral(L, "OldProto");
+ lua_pushliteral(L, "IsOldProto");
lua_pushboolean(L, pa->bOldProto);
lua_settable(L, -3);
}
static int lua_GetAccount(lua_State *L)
{
- ObsoleteMethod(L, "Use totable(x, \"PROTOACCOUNT\") instead");
-
ptrA moduleName(mir_utf8decodeA(luaL_checkstring(L, 1)));
PROTOACCOUNT* pa = ::Proto_GetAccount(moduleName);
@@ -396,7 +392,7 @@ static int pa__index(lua_State *L)
PROTOACCOUNT *pa = *(PROTOACCOUNT**)luaL_checkudata(L, 1, MT_PROTOACCOUNT);
const char *key = lua_tostring(L, 2);
- if (mir_strcmpi(key, "InternalName") == 0)
+ if (mir_strcmpi(key, "ModuleName") == 0)
lua_pushstring(L, ptrA(mir_utf8encode(pa->szModuleName)));
if (mir_strcmpi(key, "AccountName") == 0)
lua_pushstring(L, ptrA(mir_utf8encodeT(pa->tszAccountName)));
@@ -408,7 +404,7 @@ static int pa__index(lua_State *L)
lua_pushboolean(L, pa->bIsVisible);
if (mir_strcmpi(key, "IsVirtual") == 0)
lua_pushboolean(L, pa->bIsVirtual);
- if (mir_strcmpi(key, "OldProto") == 0)
+ if (mir_strcmpi(key, "IsOldProto") == 0)
lua_pushboolean(L, pa->bOldProto);
else
lua_pushnil(L);