summaryrefslogtreecommitdiff
path: root/plugins/MirLua/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MirLua/Modules')
-rw-r--r--plugins/MirLua/Modules/m_popup/m_popup.vcxproj28
-rw-r--r--plugins/MirLua/Modules/m_popup/src/main.cpp129
-rw-r--r--plugins/MirLua/Modules/m_popup/src/stdafx.cxx1
-rw-r--r--plugins/MirLua/Modules/m_popup/src/stdafx.h12
4 files changed, 170 insertions, 0 deletions
diff --git a/plugins/MirLua/Modules/m_popup/m_popup.vcxproj b/plugins/MirLua/Modules/m_popup/m_popup.vcxproj
new file mode 100644
index 0000000000..eab741dac9
--- /dev/null
+++ b/plugins/MirLua/Modules/m_popup/m_popup.vcxproj
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>m_popup</ProjectName>
+ <ProjectGuid>{D5C9CA74-4E25-478A-B890-75EB13E6DB1C}</ProjectGuid>
+ </PropertyGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(ProjectDir)..\module.props" />
+ </ImportGroup>
+</Project>
diff --git a/plugins/MirLua/Modules/m_popup/src/main.cpp b/plugins/MirLua/Modules/m_popup/src/main.cpp
new file mode 100644
index 0000000000..c99ea7c146
--- /dev/null
+++ b/plugins/MirLua/Modules/m_popup/src/main.cpp
@@ -0,0 +1,129 @@
+#include "stdafx.h"
+
+static POPUPDATAT* MakePopupData(lua_State *L)
+{
+ POPUPDATAT *ppd = (POPUPDATAT*)mir_calloc(sizeof(POPUPDATAT));
+
+ lua_getfield(L, -1, "ContactName");
+ mir_tstrcpy(ppd->lptzContactName, ptrT(mir_utf8decodeT(lua_tostring(L, -1))));
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "Text");
+ mir_tstrcpy(ppd->lptzText, ptrT(mir_utf8decodeT(luaL_checkstring(L, -1))));
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "hContact");
+ ppd->lchContact = lua_tointeger(L, -1);
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "ColorBack");
+ ppd->colorBack = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "ColorText");
+ ppd->colorText = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "Seconds");
+ ppd->iSeconds = lua_tointeger(L, -1);
+ lua_pop(L, 1);
+
+ return ppd;
+}
+
+static int lua_AddPopup(lua_State *L)
+{
+ if (lua_type(L, 1) != LUA_TTABLE)
+ {
+ lua_pushlightuserdata(L, 0);
+ return 1;
+ }
+
+ mir_ptr<POPUPDATAT> ppd(MakePopupData(L));
+
+ INT_PTR res = ::CallService(MS_POPUP_ADDPOPUPT, (WPARAM)ppd, 0);
+ lua_pushinteger(L, res);
+
+ return 1;
+}
+
+static POPUPDATA2* MakePopupData2(lua_State *L)
+{
+ POPUPDATA2 *ppd = (POPUPDATA2*)mir_calloc(sizeof(POPUPDATA2));
+ ppd->cbSize = sizeof(POPUPDATA2);
+
+ lua_getfield(L, -1, "Flags");
+ ppd->flags = lua_tointeger(L, -1);
+ lua_pop(L, 1);
+
+ if (!(ppd->flags & PU2_TCHAR))
+ ppd->flags |= PU2_TCHAR;
+
+ lua_getfield(L, -1, "Title");
+ ppd->lptzTitle = mir_utf8decodeT(lua_tostring(L, -1));
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "Text");
+ ppd->lptzText = mir_utf8decodeT(luaL_checkstring(L, -1));
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "hContact");
+ ppd->lchContact = lua_tointeger(L, -1);
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "ColorBack");
+ ppd->colorBack = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "ColorText");
+ ppd->colorText = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "hEvent");
+ ppd->lchEvent = lua_touserdata(L, -1);
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "Timestamp");
+ ppd->dwTimestamp = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+
+ lua_getfield(L, -1, "Timeout");
+ ppd->iSeconds = lua_tointeger(L, -1);
+ lua_pop(L, 1);
+
+ return ppd;
+}
+
+static int lua_AddPopup2(lua_State *L)
+{
+ if (lua_type(L, 1) != LUA_TTABLE)
+ {
+ lua_pushlightuserdata(L, 0);
+ return 1;
+ }
+
+ mir_ptr<POPUPDATA2> ppd(MakePopupData2(L));
+
+ INT_PTR res = ::CallService(MS_POPUP_ADDPOPUP2, (WPARAM)ppd, 0);
+ lua_pushinteger(L, res);
+
+ mir_free(ppd->lptzTitle);
+ mir_free(ppd->lptzText);
+
+ return 1;
+}
+
+static luaL_Reg popupApi[] =
+{
+ { "AddPopup", lua_AddPopup },
+ { "AddPopup2", lua_AddPopup2 },
+
+ { NULL, NULL }
+};
+
+LUAMOD_API int luaopen_m_popup(lua_State *L)
+{
+ luaL_newlib(L, popupApi);
+
+ return 1;
+}
diff --git a/plugins/MirLua/Modules/m_popup/src/stdafx.cxx b/plugins/MirLua/Modules/m_popup/src/stdafx.cxx
new file mode 100644
index 0000000000..fd4f341c7b
--- /dev/null
+++ b/plugins/MirLua/Modules/m_popup/src/stdafx.cxx
@@ -0,0 +1 @@
+#include "stdafx.h"
diff --git a/plugins/MirLua/Modules/m_popup/src/stdafx.h b/plugins/MirLua/Modules/m_popup/src/stdafx.h
new file mode 100644
index 0000000000..e6f48ac834
--- /dev/null
+++ b/plugins/MirLua/Modules/m_popup/src/stdafx.h
@@ -0,0 +1,12 @@
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+#include <windows.h>
+
+#include <lua.hpp>
+
+#include <m_core.h>
+#include <m_utils.h>
+#include <m_popup.h>
+
+#endif //_COMMON_H_ \ No newline at end of file