diff options
author | George Hazan <george.hazan@gmail.com> | 2024-05-12 16:56:59 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-05-12 16:56:59 +0300 |
commit | e11e428fa9014f0795d4c503b3afd93d0aa7c7c4 (patch) | |
tree | 82e75e7084f6fcd0248d5f8349587fc344901e81 | |
parent | 59c6a809e3137b088062f244f2f114e150bedd5a (diff) |
DB::FILE_BLOB rewritten using DB::EventInfo::m_json
-rw-r--r-- | include/m_database.h | 2 | ||||
-rw-r--r-- | src/mir_app/src/db_events.cpp | 26 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 |
4 files changed, 22 insertions, 8 deletions
diff --git a/include/m_database.h b/include/m_database.h index 788b627cd1..169ac00eb3 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -737,6 +737,8 @@ namespace DB bool isAlertable() const; // should raise SRMM window
wchar_t* getString(const char *str) const;
+
+ void flushJson();
JSONNode& setJson();
};
diff --git a/src/mir_app/src/db_events.cpp b/src/mir_app/src/db_events.cpp index a3a22b56bf..f1500bc937 100644 --- a/src/mir_app/src/db_events.cpp +++ b/src/mir_app/src/db_events.cpp @@ -348,13 +348,26 @@ wchar_t* DB::EventInfo::getString(const char *str) const return mir_a2u(str);
}
+void DB::EventInfo::flushJson()
+{
+ if (!m_json)
+ return;
+
+ std::string text = m_json->write();
+ cbBlob = (int)text.size() + 1;
+ pBlob = (char *)mir_realloc(pBlob, cbBlob);
+ memcpy(pBlob, text.c_str(), cbBlob);
+}
+
JSONNode& DB::EventInfo::setJson()
{
if (!(flags & DBEF_JSON)) {
- if (m_json == nullptr)
- m_json = new JSONNode(JSONNode::parse((const char*)pBlob));
-
flags |= DBEF_JSON;
+
+ if (m_json == nullptr)
+ m_json = new JSONNode(JSON_NODE);
+ if (pBlob)
+ *m_json << CHAR_PARAM("b", (char *)pBlob);
}
return *m_json;
@@ -409,7 +422,7 @@ bool DB::FILE_BLOB::isCompleted() const void DB::FILE_BLOB::write(DB::EventInfo &dbei)
{
- JSONNode root;
+ auto &root = dbei.setJson();
root << WCHAR_PARAM("f", m_wszFileName) << WCHAR_PARAM("d", m_wszDescription ? m_wszDescription : L"");
if (isOffline()) {
root << CHAR_PARAM("u", m_szProtoString) << INT_PARAM("fs", m_iFileSize) << INT_PARAM("ft", m_iTransferred);
@@ -417,10 +430,7 @@ void DB::FILE_BLOB::write(DB::EventInfo &dbei) root << WCHAR_PARAM("lf", m_wszLocalName);
}
- std::string text = root.write();
- dbei.cbBlob = (int)text.size() + 1;
- dbei.pBlob = (char *)mir_realloc(dbei.pBlob, dbei.cbBlob);
- memcpy(dbei.pBlob, text.c_str(), dbei.cbBlob);
+ dbei.flushJson();
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 3b8d298865..709f5a075b 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -973,3 +973,4 @@ g_hevEventDelivered @1108 NONAME g_hevEventSetJson @1109 NONAME
?getJson@EventInfo@DB@@QBEAAVJSONNode@@XZ @1110 NONAME
?setJson@EventInfo@DB@@QAEAAVJSONNode@@XZ @1111 NONAME
+?flushJson@EventInfo@DB@@QAEXXZ @1112 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 69c96d691b..37c4dd3e83 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -973,3 +973,4 @@ g_hevEventDelivered @1102 NONAME g_hevEventSetJson @1103 NONAME
?getJson@EventInfo@DB@@QEBAAEAVJSONNode@@XZ @1104 NONAME
?setJson@EventInfo@DB@@QEAAAEAVJSONNode@@XZ @1105 NONAME
+?flushJson@EventInfo@DB@@QEAAXXZ @1106 NONAME
|