From 635a81a5b4e12538d8aebf5eb85a632b08978f61 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 22 Aug 2018 19:52:27 +0300 Subject: Msg_Export: fix for export metacontact's events --- plugins/Import/src/textjson.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'plugins/Import/src') diff --git a/plugins/Import/src/textjson.cpp b/plugins/Import/src/textjson.cpp index 250884e945..d17a87984b 100644 --- a/plugins/Import/src/textjson.cpp +++ b/plugins/Import/src/textjson.cpp @@ -32,20 +32,31 @@ static int mc_makeDatabase(const wchar_t*) ///////////////////////////////////////////////////////////////////////////////////////// // JSON text driver, read-only +static int CompareModules(const char *p1, const char *p2) +{ + return mir_strcmp(p1, p2); +} + class CDbxJson : public MDatabaseReadonly, public MZeroedObject { JSONNode *m_root = nullptr; LIST m_events; + LIST m_modules; + std::string m_proto; public: CDbxJson() : - m_events(100) + m_events(100), + m_modules(10, CompareModules) {} ~CDbxJson() { if (m_root != nullptr) json_delete(m_root); + + for (auto &it : m_modules) + mir_free(it); } void Load() @@ -71,6 +82,8 @@ public: if ((m_root = json_parse(szFile)) == nullptr) return EGROKPRF_DAMAGED; + m_proto = (*m_root)["info"]["proto"].as_string(); + for (auto &it : m_root->at("history")) m_events.insert(&it); @@ -136,6 +149,16 @@ public: case 'r': dbei->flags |= DBEF_READ; break; } + std::string szModule = (*node)["module"].as_string(); + if (!szModule.empty()) + szModule = m_proto; + + dbei->szModule = m_modules.find((char*)szModule.c_str()); + if (dbei->szModule == nullptr) { + dbei->szModule = mir_strdup(szModule.c_str()); + m_modules.insert(dbei->szModule); + } + std::string szBody = (*node)["body"].as_string(); if (!szBody.empty()) { dbei->flags |= DBEF_UTF; -- cgit v1.2.3