From fbf4fc6615464c54936609c90b976a94b6194bb5 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 17 Jun 2016 08:15:18 +0000 Subject: MirLua: added CallSendChain & CallReceiveChain into m_protocols git-svn-id: http://svn.miranda-ng.org/main/trunk@16999 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/m_protocols.cpp | 49 +++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/plugins/MirLua/src/m_protocols.cpp b/plugins/MirLua/src/m_protocols.cpp index b24b610067..354a65daf5 100644 --- a/plugins/MirLua/src/m_protocols.cpp +++ b/plugins/MirLua/src/m_protocols.cpp @@ -19,6 +19,8 @@ static int lua_GetProtocol(lua_State *L) case LUA_TSTRING: name = lua_tostring(L, 1); break; + default: + luaL_argerror(L, 1, luaL_typename(L, 1)); } PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(name); @@ -64,7 +66,20 @@ static int lua_Protocols(lua_State *L) static int lua_CallService(lua_State *L) { - const char *module = luaL_checkstring(L, 1); + const char *module = NULL; + + switch (lua_type(L, 1)) + { + case LUA_TNUMBER: + module = GetContactProto(lua_tonumber(L, 1)); + break; + case LUA_TSTRING: + module = lua_tostring(L, 1); + break; + default: + luaL_argerror(L, 1, luaL_typename(L, 1)); + } + const char *service = luaL_checkstring(L, 2); WPARAM wParam = (WPARAM)luaM_tomparam(L, 3); LPARAM lParam = (LPARAM)luaM_tomparam(L, 4); @@ -75,6 +90,34 @@ static int lua_CallService(lua_State *L) return 1; } +static int lua_ChainSend(lua_State *L) +{ + MCONTACT hContact = luaL_checknumber(L, 1); + const char *service = luaL_checkstring(L, 2); + WPARAM wParam = (WPARAM)luaM_tomparam(L, 3); + LPARAM lParam = (LPARAM)luaM_tomparam(L, 4); + + CCSDATA ccs = { hContact, service, wParam, lParam }; + INT_PTR res = Proto_ChainSend(0, &ccs); + lua_pushinteger(L, res); + + return 1; +} + +static int lua_ChainRecv(lua_State *L) +{ + MCONTACT hContact = luaL_checknumber(L, 1); + const char *service = luaL_checkstring(L, 2); + WPARAM wParam = (WPARAM)luaM_tomparam(L, 3); + LPARAM lParam = (LPARAM)luaM_tomparam(L, 4); + + CCSDATA ccs = { hContact, service, wParam, lParam }; + INT_PTR res = Proto_ChainRecv(0, &ccs); + lua_pushinteger(L, res); + + return 1; +} + /***********************************************/ static int lua_GetAccount(lua_State *L) @@ -89,6 +132,8 @@ static int lua_GetAccount(lua_State *L) case LUA_TSTRING: name = lua_tostring(L, 1); break; + default: + luaL_argerror(L, 1, luaL_typename(L, 1)); } PROTOACCOUNT *pa = Proto_GetAccount(name); @@ -149,6 +194,8 @@ static luaL_Reg protocolsApi[] = { "GetProtocol", lua_GetProtocol }, { "Protocols", lua_Protocols }, { "CallService", lua_CallService }, + { "CallSendChain", lua_ChainSend }, + { "CallReceiveChain", lua_ChainRecv }, { "GetAccount", lua_GetAccount }, { "Accounts", lua_Accounts }, -- cgit v1.2.3