diff options
author | aunsane <aunsane@gmail.com> | 2016-10-13 23:06:57 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2016-10-13 23:09:04 +0300 |
commit | 3d935bbe41c0361e29757c7abefd8f2cc0c3403b (patch) | |
tree | 4eae5c79935a7cb6b9f697f06aede2919dca1deb /plugins/MirLua/src | |
parent | e5a406b5293f7bbceea54817c381d739c0cbe039 (diff) |
MirLua: added new functions into m_database
Diffstat (limited to 'plugins/MirLua/src')
-rw-r--r-- | plugins/MirLua/src/m_database.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index c7c8c091f4..b50f2d80a9 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -169,6 +169,16 @@ static int db_GetLastEvent(lua_State *L) return 1;
}
+static int db_GetFirstUnreadEvent(lua_State *L)
+{
+ MCONTACT hContact = luaL_checkinteger(L, 1);
+
+ MEVENT res = db_event_firstUnread(hContact);
+ lua_pushinteger(L, res);
+
+ return 1;
+}
+
static int db_EventIterator(lua_State *L)
{
MCONTACT hContact = luaL_checkinteger(L, lua_upvalueindex(1));
@@ -233,6 +243,36 @@ static int db_EventsFromEnd(lua_State *L) return 1;
}
+static int db_UnreadEventIterator(lua_State *L)
+{
+ MCONTACT hContact = luaL_checkinteger(L, lua_upvalueindex(1));
+ MEVENT hDbEvent = luaL_checkinteger(L, lua_upvalueindex(2));
+
+ hDbEvent = db_event_firstUnread(hContact);
+
+ if (hDbEvent)
+ {
+ lua_pushinteger(L, hDbEvent);
+ lua_pushvalue(L, -1);
+ lua_replace(L, lua_upvalueindex(2));
+ }
+ else
+ lua_pushnil(L);
+
+ return 1;
+}
+
+static int db_UnreadEvents(lua_State *L)
+{
+ MCONTACT hContact = luaL_checkinteger(L, 1);
+
+ lua_pushinteger(L, hContact);
+ lua_pushinteger(L, NULL);
+ lua_pushcclosure(L, db_UnreadEventIterator, 2);
+
+ return 1;
+}
+
void MakeDbEvent(lua_State *L, DBEVENTINFO &dbei)
{
dbei.cbSize = sizeof(dbei);
@@ -293,6 +333,17 @@ static int db_AddEvent(lua_State *L) return 1;
}
+static int db_MarkReadEvent(lua_State *L)
+{
+ MCONTACT hContact = luaL_checkinteger(L, 1);
+ MEVENT hDbEvent = luaL_checkinteger(L, 2);
+
+ int res = db_event_markRead(hContact, hDbEvent);
+ lua_pushnumber(L, res);
+
+ return 1;
+}
+
/***********************************************/
static int ModulesEnumProc(const char *szModuleName, DWORD, LPARAM lParam)
@@ -555,9 +606,12 @@ static luaL_Reg databaseApi[] = { "GetPrevEvent", db_GetPrevEvent },
{ "GetNextEvent", db_GetNextEvent },
{ "GetLastEvent", db_GetLastEvent },
+ { "GetFirstUnreadEvent", db_GetFirstUnreadEvent },
{ "Events", db_Events },
{ "EventsFromEnd", db_EventsFromEnd },
+ { "UnreadEvents", db_UnreadEvents },
{ "AddEvent", db_AddEvent },
+ { "MarkReadEvent", db_MarkReadEvent },
{ "Settings", db_Settings },
{ "Modules", db_Modules },
|