diff options
author | George Hazan <ghazan@miranda.im> | 2018-08-22 20:14:32 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-08-22 20:14:32 +0300 |
commit | 6b5eee23bee83dac706dcfcbc72e5cce3a89e4c8 (patch) | |
tree | 3761ebb717c407c48633b9bef0aef41824ad5687 /plugins/Import | |
parent | 635a81a5b4e12538d8aebf5eb85a632b08978f61 (diff) |
if szModule is missing in an event, it should be filled from the contact's data
Diffstat (limited to 'plugins/Import')
-rw-r--r-- | plugins/Import/src/import.cpp | 8 | ||||
-rw-r--r-- | plugins/Import/src/textjson.cpp | 18 |
2 files changed, 15 insertions, 11 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 87fc1364da..1fbd83ce0f 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -877,6 +877,7 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC MCONTACT hDst;
bool bIsMeta = false;
bool bIsRelational = srcDb->IsRelational() != 0;
+ char *szProto = nullptr;
// Is it contact's history import?
if (hContact) {
@@ -903,6 +904,10 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC nSkippedContacts++;
return;
}
+
+ cc = dstDb->getCache()->GetCachedContact(hDst);
+ if (cc != nullptr)
+ szProto = cc->szProto;
}
else hDst = NULL;
@@ -924,6 +929,9 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC bool bSkipThis = false;
if (!srcDb->GetEvent(hEvent, &dbei)) {
+ if (dbei.szModule == nullptr)
+ dbei.szModule = szProto;
+
// check protocols during system history import
if (hDst == NULL) {
bSkipAll = true;
diff --git a/plugins/Import/src/textjson.cpp b/plugins/Import/src/textjson.cpp index d17a87984b..de9a1755b1 100644 --- a/plugins/Import/src/textjson.cpp +++ b/plugins/Import/src/textjson.cpp @@ -42,7 +42,6 @@ class CDbxJson : public MDatabaseReadonly, public MZeroedObject JSONNode *m_root = nullptr; LIST<JSONNode> m_events; LIST<char> m_modules; - std::string m_proto; public: CDbxJson() : @@ -82,8 +81,6 @@ 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); @@ -150,14 +147,13 @@ public: } 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); - } + if (!szModule.empty()) { + 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()) { |