From 063b64c33b6c11db04d760a5bf0f451650e2b867 Mon Sep 17 00:00:00 2001 From: Vlad Mironov Date: Sat, 11 Jul 2015 11:43:26 +0000 Subject: MirLua: more features git-svn-id: http://svn.miranda-ng.org/main/trunk@14535 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/m_database.cpp | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index bb903db1aa..2410dec01f 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -98,6 +98,9 @@ static int lua_GetEvent(lua_State *L) lua_pushstring(L, "Type"); lua_pushinteger(L, dbei.eventType); lua_settable(L, -3); + lua_pushstring(L, "Flags"); + lua_pushinteger(L, dbei.flags); + lua_settable(L, -3); lua_pushstring(L, "Length"); lua_pushnumber(L, dbei.cbBlob); lua_settable(L, -3); @@ -218,6 +221,47 @@ static int lua_DeleteModule(lua_State *L) return 1; } +static int lua_DecodeDBCONTACTWRITESETTING(lua_State *L) +{ + DBCONTACTWRITESETTING *pDBCWS = (DBCONTACTWRITESETTING*)lua_tointeger(L, 1); + + lua_newtable(L); + lua_pushstring(L, "Module"); + lua_pushstring(L, pDBCWS->szModule); + lua_settable(L, -3); + lua_pushstring(L, "Setting"); + lua_pushstring(L, pDBCWS->szSetting); + lua_settable(L, -3); + lua_pushstring(L, "Value"); + switch (pDBCWS->value.type) + { + case DBVT_BYTE: + lua_pushinteger(L, pDBCWS->value.bVal); + break; + case DBVT_WORD: + lua_pushinteger(L, pDBCWS->value.wVal); + break; + case DBVT_DWORD: + lua_pushnumber(L, pDBCWS->value.dVal); + break; + case DBVT_ASCIIZ: + lua_pushstring(L, ptrA(mir_utf8encode(pDBCWS->value.pszVal))); + break; + case DBVT_UTF8: + lua_pushstring(L, pDBCWS->value.pszVal); + break; + case DBVT_WCHAR: + lua_pushstring(L, ptrA(mir_utf8encodeW(pDBCWS->value.pwszVal))); + break; + default: + lua_pushvalue(L, 4); + return 1; + } + lua_settable(L, -3); + + return 1; +} + typedef struct { int arrlen; @@ -300,6 +344,8 @@ static luaL_Reg databaseApi[] = { "EnumSettings", lua_EnumSettings }, + { "DecodeDBCONTACTWRITESETTING", lua_DecodeDBCONTACTWRITESETTING }, + { NULL, NULL } }; -- cgit v1.2.3