summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-05-12 16:23:20 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-05-12 16:23:20 +0300
commit59c6a809e3137b088062f244f2f114e150bedd5a (patch)
treebe0a1644b9a65ad3ba8299769fcabba5a684809b
parentae5c72cf0e6e7b287d7cf77fb83cacd017ee2b58 (diff)
merge commit
-rw-r--r--include/m_database.h6
-rw-r--r--libs/win32/mir_app.libbin293700 -> 294360 bytes
-rw-r--r--libs/win64/mir_app.libbin293458 -> 294138 bytes
-rw-r--r--plugins/Dbx_sqlite/src/dbintf.cpp7
-rw-r--r--plugins/Dbx_sqlite/src/stdafx.h1
-rw-r--r--protocols/Discord/src/utils.cpp29
-rw-r--r--src/mir_app/src/chat_svc.cpp2
-rw-r--r--src/mir_app/src/db_events.cpp25
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
10 files changed, 57 insertions, 17 deletions
diff --git a/include/m_database.h b/include/m_database.h
index 03e035623d..788b627cd1 100644
--- a/include/m_database.h
+++ b/include/m_database.h
@@ -186,6 +186,7 @@ struct DBVARIANT
#define DBEF_SECURE 0x0080 // event is encrypted
#define DBEF_STRONG 0x0100 // event is encrypted by the verified sender
#define DBEF_BOOKMARK 0x0200 // event is bookmarked
+#define DBEF_JSON 0x0400 // event's body is a JSON structure
struct DBEVENTINFO
{
@@ -702,6 +703,8 @@ __inline uint32_t DBGetContactSettingRangedDword(MCONTACT hContact, const char *
#endif
+class JSONNode;
+
namespace DB
{
MIR_APP_DLL(bool) IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO &dbei);
@@ -713,6 +716,7 @@ namespace DB
{
bool m_bValid;
MEVENT m_hEvent;
+ JSONNode *m_json = 0;
public:
explicit EventInfo();
@@ -724,6 +728,7 @@ namespace DB
void unload();
void wipeNotify();
+ __forceinline JSONNode& getJson() const { return *m_json; }
__forceinline MEVENT getEvent() const { return m_hEvent; }
__forceinline operator bool() const { return m_bValid; }
@@ -732,6 +737,7 @@ namespace DB
bool isAlertable() const; // should raise SRMM window
wchar_t* getString(const char *str) const;
+ JSONNode& setJson();
};
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 0dfc6e097a..d79165e112 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 74daaab8d9..3315b2119c 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/Dbx_sqlite/src/dbintf.cpp b/plugins/Dbx_sqlite/src/dbintf.cpp
index 7d3d06a1a5..048fab793c 100644
--- a/plugins/Dbx_sqlite/src/dbintf.cpp
+++ b/plugins/Dbx_sqlite/src/dbintf.cpp
@@ -29,7 +29,7 @@ CDbxSQLite::~CDbxSQLite()
/////////////////////////////////////////////////////////////////////////////////////////
-#define CURRVER 7
+#define CURRVER 8
int CDbxSQLite::Create()
{
@@ -206,6 +206,11 @@ void CDbxSQLite::CheckConversion()
logError(rc, __FILE__, __LINE__);
}
+ if (dbv.bVal < 8) {
+ int rc = sqlite3_exec(m_db, "UPDATE events SET flags = flags + 1024 WHERE type=1002;", 0, 0, 0);
+ logError(rc, __FILE__, __LINE__);
+ }
+
dbv.bVal = CURRVER;
WriteContactSetting(0, "Compatibility", "Sqlite", &dbv);
diff --git a/plugins/Dbx_sqlite/src/stdafx.h b/plugins/Dbx_sqlite/src/stdafx.h
index e035993f8d..8661575039 100644
--- a/plugins/Dbx_sqlite/src/stdafx.h
+++ b/plugins/Dbx_sqlite/src/stdafx.h
@@ -11,6 +11,7 @@
#include <m_crypto.h>
#include <m_database.h>
#include <m_gui.h>
+#include <m_json.h>
#include <m_langpack.h>
#include <m_netlib.h>
#include <m_protocols.h>
diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp
index 2e7c5defe7..7ed5a734f1 100644
--- a/protocols/Discord/src/utils.cpp
+++ b/protocols/Discord/src/utils.cpp
@@ -237,6 +237,7 @@ void CDiscordProto::PreparePrivateChannel(const JSONNode &root)
CheckAvatarChange(si->hContact, root["icon"].as_mstring());
+ bool bHasMe = false;
GCEVENT gce = { si, GC_EVENT_JOIN };
for (auto &it : root["recipients"]) {
CMStringW wszId = it["id"].as_mstring();
@@ -244,23 +245,29 @@ void CDiscordProto::PreparePrivateChannel(const JSONNode &root)
if (wszNick.IsEmpty())
wszNick = getNick(it);
+ gce.bIsMe = _wtoi64(wszId) == m_ownId;
gce.pszUID.w = wszId;
gce.pszNick.w = wszNick;
gce.pszStatus.w = (_wtoi64(wszId) == ownerId) ? L"Owners" : L"Participants";
Chat_Event(&gce);
+
+ if (gce.bIsMe)
+ bHasMe = true;
}
- CMStringW wszId(FORMAT, L"%lld", getId(DB_KEY_ID)), wszNick;
- if (auto iDiscr = getDword(DB_KEY_DISCR))
- wszNick.Format(L"%s#%d", getMStringW(DB_KEY_NICK).c_str(), iDiscr);
- else
- wszNick = getMStringW(DB_KEY_NICK);
-
- gce.bIsMe = true;
- gce.pszUID.w = wszId;
- gce.pszNick.w = wszNick;
- gce.pszStatus.w = (_wtoi64(wszId) == ownerId) ? L"Owners" : L"Participants";
- Chat_Event(&gce);
+ if (!bHasMe) {
+ CMStringW wszId(FORMAT, L"%lld", getId(DB_KEY_ID)), wszNick;
+ if (auto iDiscr = getDword(DB_KEY_DISCR))
+ wszNick.Format(L"%s#%d", getMStringW(DB_KEY_NICK).c_str(), iDiscr);
+ else
+ wszNick = getMStringW(DB_KEY_NICK);
+
+ gce.bIsMe = true;
+ gce.pszUID.w = wszId;
+ gce.pszNick.w = wszNick;
+ gce.pszStatus.w = (_wtoi64(wszId) == ownerId) ? L"Owners" : L"Participants";
+ Chat_Event(&gce);
+ }
}
Chat_Control(si, m_bHideGroupchats ? WINDOW_HIDDEN : SESSION_INITDONE);
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index 68a50b8fc3..f644cdbeaf 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -442,8 +442,6 @@ static void AddUser(SESSION_INFO *si, GCEVENT &gce)
if (gce.bIsMe)
si->pMe = ui;
- ui->Status = status;
- ui->Status |= si->pStatuses->iStatus;
if (si->pDlg)
si->pDlg->UpdateNickList();
diff --git a/src/mir_app/src/db_events.cpp b/src/mir_app/src/db_events.cpp
index 992f4422f2..a3a22b56bf 100644
--- a/src/mir_app/src/db_events.cpp
+++ b/src/mir_app/src/db_events.cpp
@@ -272,6 +272,8 @@ DB::EventInfo& DB::EventInfo::operator=(MEVENT hEvent)
DB::EventInfo::~EventInfo()
{
+ delete m_json;
+
if (m_bValid)
mir_free(pBlob);
}
@@ -280,7 +282,12 @@ bool DB::EventInfo::fetch(bool bFetchBlob)
{
if (bFetchBlob)
cbBlob = -1;
- return m_bValid = ::db_event_get(m_hEvent, this) == 0;
+
+ if (m_bValid = ::db_event_get(m_hEvent, this) == 0)
+ if ((flags & DBEF_JSON) && pBlob)
+ m_json = new JSONNode(JSONNode::parse((const char *)pBlob));
+
+ return m_bValid;
}
void DB::EventInfo::unload()
@@ -341,6 +348,18 @@ wchar_t* DB::EventInfo::getString(const char *str) const
return mir_a2u(str);
}
+JSONNode& DB::EventInfo::setJson()
+{
+ if (!(flags & DBEF_JSON)) {
+ if (m_json == nullptr)
+ m_json = new JSONNode(JSONNode::parse((const char*)pBlob));
+
+ flags |= DBEF_JSON;
+ }
+
+ return *m_json;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// File blob helper
@@ -357,8 +376,8 @@ DB::FILE_BLOB::FILE_BLOB(const wchar_t *pwszName, const wchar_t *pwszDescr) :
DB::FILE_BLOB::FILE_BLOB(const DB::EventInfo &dbei)
{
- JSONNode root = JSONNode::parse((const char *)dbei.pBlob);
- if (root) {
+ auto &root = dbei.getJson();
+ if (&root) {
m_wszFileName = root["f"].as_mstring().Detach();
m_wszDescription = root["d"].as_mstring().Detach();
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 33fdcbda22..3b8d298865 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -971,3 +971,5 @@ _Netlib_DownloadFile@20 @1099 NONAME
?GetPreviewPath@PROTO_INTERFACE@@QBE?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@XZ @1107 NONAME
g_hevEventDelivered @1108 NONAME
g_hevEventSetJson @1109 NONAME
+?getJson@EventInfo@DB@@QBEAAVJSONNode@@XZ @1110 NONAME
+?setJson@EventInfo@DB@@QAEAAVJSONNode@@XZ @1111 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 567e6bc7c0..69c96d691b 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -971,3 +971,5 @@ Netlib_DownloadFile @1093 NONAME
?GetPreviewPath@PROTO_INTERFACE@@QEBA?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@XZ @1101 NONAME
g_hevEventDelivered @1102 NONAME
g_hevEventSetJson @1103 NONAME
+?getJson@EventInfo@DB@@QEBAAEAVJSONNode@@XZ @1104 NONAME
+?setJson@EventInfo@DB@@QEAAAEAVJSONNode@@XZ @1105 NONAME