summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2025-06-06 15:36:02 +0300
committerGeorge Hazan <george.hazan@gmail.com>2025-06-06 15:36:07 +0300
commitc1cac0e54f6c6e906cacc4538c79930b7c85669b (patch)
tree80e13188253331ec68c0ba10d4bae3c5ddbb968b /src
parent59c69952e5a14de5e6a4e9d567aaaf0ce7685d86 (diff)
MsgExport: reactions to be properly exported even in the text mode
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/database.h2
-rw-r--r--src/mir_app/src/db_events.cpp32
-rw-r--r--src/mir_app/src/db_intf.cpp3
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
5 files changed, 39 insertions, 0 deletions
diff --git a/src/mir_app/src/database.h b/src/mir_app/src/database.h
index 90ca8783a9..7c3b9e68f5 100644
--- a/src/mir_app/src/database.h
+++ b/src/mir_app/src/database.h
@@ -52,3 +52,5 @@ protected:
STDMETHODIMP_(void) SetCachedVariant(DBVARIANT *s, DBVARIANT *d);
STDMETHODIMP_(DBVARIANT*) GetCachedValuePtr(MCONTACT contactID, char *szSetting, int bAllocate);
};
+
+extern HANDLE g_hevEventReaction;
diff --git a/src/mir_app/src/db_events.cpp b/src/mir_app/src/db_events.cpp
index 923724ab91..facd663864 100644
--- a/src/mir_app/src/db_events.cpp
+++ b/src/mir_app/src/db_events.cpp
@@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "stdafx.h"
+
+#include "database.h"
#include "profilemanager.h"
static int CompareEventTypes(const DBEVENTTYPEDESCR *p1, const DBEVENTTYPEDESCR *p2)
@@ -386,6 +388,10 @@ void DB::EventInfo::addReaction(const char *emoji)
(*it) = JSONNode(emoji, (*it).as_int() + 1);
flushJson();
+ db_event_setJson(getEvent(), pBlob);
+
+ DBEventReaction ev = { hContact, TRUE, emoji };
+ NotifyEventHooks(g_hevEventReaction, WPARAM(this), LPARAM(&ev));
}
void DB::EventInfo::delReaction(const char *emoji)
@@ -404,9 +410,35 @@ void DB::EventInfo::delReaction(const char *emoji)
reactions.erase(it);
flushJson();
+ db_event_setJson(getEvent(), pBlob);
+
+ DBEventReaction ev = { hContact, FALSE, emoji };
+ NotifyEventHooks(g_hevEventReaction, WPARAM(this), LPARAM(&ev));
}
}
+void DB::EventInfo::setReactions(class JSONNode &pNode)
+{
+ CMStringA szReactions;
+ for (auto &it : pNode)
+ szReactions.AppendFormat("%s ", it.name());
+ szReactions.Trim();
+
+ auto &json = setJson();
+ auto it = json.find("r");
+ if (it != json.end())
+ json.erase(it);
+
+ pNode.set_name("r");
+ json << pNode;
+ flushJson();
+
+ db_event_setJson(getEvent(), pBlob);
+
+ DBEventReaction ev = { hContact, TRUE, szReactions };
+ NotifyEventHooks(g_hevEventReaction, WPARAM(this), LPARAM(&ev));
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// File blob helper
diff --git a/src/mir_app/src/db_intf.cpp b/src/mir_app/src/db_intf.cpp
index eb522790bf..8dd71bc23f 100644
--- a/src/mir_app/src/db_intf.cpp
+++ b/src/mir_app/src/db_intf.cpp
@@ -76,6 +76,8 @@ MIR_APP_EXPORT HANDLE
g_hevEventDelivered, // ME_DB_EVENT_DELIVERED
g_hevEventFiltered;
+HANDLE g_hevEventReaction; // ME_DB_EVENT_REACTION
+
int LoadDbintfModule()
{
// create events once, they will be inherited by all database plugins
@@ -89,6 +91,7 @@ int LoadDbintfModule()
g_hevEventDeleted = CreateHookableEvent(ME_DB_EVENT_DELETED);
g_hevEventSetJson = CreateHookableEvent(ME_DB_EVENT_SETJSON);
g_hevEventDelivered = CreateHookableEvent(ME_DB_EVENT_DELIVERED);
+ g_hevEventReaction = CreateHookableEvent(ME_DB_EVENT_REACTION);
g_hevEventFiltered = CreateHookableEvent(ME_DB_EVENT_FILTER_ADD);
while (!_waccess(L"libmdbx.mir", 0)) {
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index d5916b76fa..edeb85fa99 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -1020,3 +1020,4 @@ Proto_CanDeleteHistory @1118 NONAME
?iAlpha@Clist@@3V?$CMOption@E@@A @1153 NONAME
?iAutoAlpha@Clist@@3V?$CMOption@E@@A @1154 NONAME
?SetEventJson@MDatabaseCommon@@UAGHIPBD@Z @1155 NONAME
+?setReactions@EventInfo@DB@@QAEXAAVJSONNode@@@Z @1156 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 8682876159..0ce710a638 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -1020,3 +1020,4 @@ Proto_CanDeleteHistory @1118 NONAME
?iAlpha@Clist@@3V?$CMOption@E@@A @1153 NONAME
?iAutoAlpha@Clist@@3V?$CMOption@E@@A @1154 NONAME
?SetEventJson@MDatabaseCommon@@UEAAHIPEBD@Z @1155 NONAME
+?setReactions@EventInfo@DB@@QEAAXAEAVJSONNode@@@Z @1156 NONAME