summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-06-17 08:15:18 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-06-17 08:15:18 +0000
commitfbf4fc6615464c54936609c90b976a94b6194bb5 (patch)
tree6b4fc1142febeeabb906f071aa304a450b3683b7
parent1d3ab2a60e0a0ad1410b47c14897e9ebd3fcb994 (diff)
MirLua: added CallSendChain & CallReceiveChain into m_protocols
git-svn-id: http://svn.miranda-ng.org/main/trunk@16999 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/MirLua/src/m_protocols.cpp49
1 files changed, 48 insertions, 1 deletions
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 },