diff options
| -rw-r--r-- | plugins/MirLua/src/m_message.cpp | 65 | ||||
| -rw-r--r-- | plugins/MirLua/src/mlua.cpp | 2 | ||||
| -rw-r--r-- | plugins/MirLua/src/mlua_module_loader.cpp | 3 | ||||
| -rw-r--r-- | plugins/MirLua/src/stdafx.h | 4 | 
4 files changed, 72 insertions, 2 deletions
diff --git a/plugins/MirLua/src/m_message.cpp b/plugins/MirLua/src/m_message.cpp new file mode 100644 index 0000000000..f788b93f19 --- /dev/null +++ b/plugins/MirLua/src/m_message.cpp @@ -0,0 +1,65 @@ +#include "stdafx.h"
 +
 +static int lua_Paste(lua_State *L)
 +{
 +	MCONTACT hContect = luaL_checkinteger(L, 1);
 +	ptrT text(mir_utf8decodeT(luaL_checkstring(L, 2)));
 +
 +	MessageWindowInputData mwid = { sizeof(MessageWindowInputData) };
 +	mwid.hContact = luaL_checkinteger(L, 1);
 +	mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
 +
 +	MessageWindowData mwd = { sizeof(MessageWindowData) };
 +
 +	INT_PTR res = ::CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd);
 +	lua_pushinteger(L, res);
 +	if (res)
 +		return 1;
 +
 +	HWND hEdit = GetDlgItem(mwd.hwndWindow, 1002 /*IDC_MESSAGE*/);
 +	if (!hEdit) hEdit = GetDlgItem(mwd.hwndWindow, 1009 /*IDC_CHATMESSAGE*/);
 +
 +	SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)text);
 +
 +	return 1;
 +}
 +
 +static int lua_Send(lua_State *L)
 +{
 +	MCONTACT hContect = luaL_checkinteger(L, 1);
 +	ptrT text(mir_utf8decodeT(luaL_checkstring(L, 2)));
 +
 +	MessageWindowInputData mwid = { sizeof(MessageWindowInputData) };
 +	mwid.hContact = luaL_checkinteger(L, 1);
 +	mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
 +
 +	MessageWindowData mwd = { sizeof(MessageWindowData) };
 +
 +	INT_PTR res = ::CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd);
 +	lua_pushinteger(L, res);
 +	if (res)
 +		return 1;
 +
 +	HWND hEdit = GetDlgItem(mwd.hwndWindow, 1002 /*IDC_MESSAGE*/);
 +	if (!hEdit) hEdit = GetDlgItem(mwd.hwndWindow, 1009 /*IDC_CHATMESSAGE*/);
 +
 +	SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)text);
 +	SendMessage(mwd.hwndWindow, WM_COMMAND, IDOK, 0);
 +
 +	return 1;
 +}
 +
 +static luaL_Reg messageApi[] =
 +{
 +	{ "Paste", lua_Paste },
 +	{ "Send", lua_Send },
 +
 +	{ NULL, NULL }
 +};
 +
 +LUAMOD_API int luaopen_m_message(lua_State *L)
 +{
 +	luaL_newlib(L, messageApi);
 +
 +	return 1;
 +}
 diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index 253bd2b64e..0e78810fba 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -25,7 +25,7 @@ void CMLua::Load()  	lua_pop(L, 1);
  	lua_getglobal(L, "_G");
 -	lua_pushcclosure(L, luaM_print, 0); +	lua_pushcclosure(L, luaM_print, 0);
  	lua_setfield(L, -2, "print");
  	lua_pop(L, 1);
 diff --git a/plugins/MirLua/src/mlua_module_loader.cpp b/plugins/MirLua/src/mlua_module_loader.cpp index 5be361fce6..386b592831 100644 --- a/plugins/MirLua/src/mlua_module_loader.cpp +++ b/plugins/MirLua/src/mlua_module_loader.cpp @@ -21,8 +21,9 @@ void CLuaModuleLoader::LoadModules()  	PreloadModule(MLUA_DATABASE, luaopen_m_database);
  	PreloadModule(MLUA_ICOLIB, luaopen_m_icolib);
  	PreloadModule(MLUA_GENMENU, luaopen_m_genmenu);
 +	PreloadModule(MLUA_MESSAGE, luaopen_m_message);
  	PreloadModule(MLUA_MSGBUTTONSBAR, luaopen_m_msg_buttonsbar);
 -	PreloadModule(MLUA_POPUP, luaopen_m_popup);
 +	PreloadModule(MLUA_POPUP, luaopen_m_popup);	
  	PreloadModule(MLUA_TOPTOOLBAR, luaopen_m_toptoolbar);
  	PreloadModule(MLUA_VARIABLES, luaopen_m_variables);
  }
 diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 1b463b564a..6ceb174e11 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -16,6 +16,7 @@  #include <m_genmenu.h>
  #include <m_clist.h>
  #include <m_icolib.h>
 +#include <m_message.h>
  #include <m_folders.h>
  #include <m_msg_buttonsbar.h>
 @@ -72,6 +73,9 @@ LUAMOD_API int (luaopen_m_icolib)(lua_State *L);  #include "m_genmenu.h"
 +#define MLUA_MESSAGE	"m_message"
 +LUAMOD_API int (luaopen_m_message)(lua_State *L);
 +
  #define MLUA_MSGBUTTONSBAR	"m_msg_buttonsbar"
  LUAMOD_API int (luaopen_m_msg_buttonsbar)(lua_State *L);
  | 
