summaryrefslogtreecommitdiff
path: root/plugins/Import/src/import.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Import/src/import.cpp')
-rw-r--r--plugins/Import/src/import.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index d3b70833e7..c9ca158b54 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -876,15 +876,30 @@ static int CopySystemSettings(const char *szModuleName, DWORD, LPARAM param)
static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoCount)
{
MCONTACT hDst;
+ bool bIsMeta = false;
+ bool bIsRelational = srcDb->IsRelational() != 0;
// Is it contact's history import?
if (hContact) {
// we ignore history import for metacontacts
// the metahistory will be generated automatically by gathering subs' histories
DBCachedContact *cc = srcDb->m_cache->GetCachedContact(hContact);
- if (cc == NULL || cc->IsMeta())
+ if (cc == NULL)
return;
+ // for k/v databases we read history for subs only
+ if (bIsRelational) {
+ if (cc->IsMeta())
+ return;
+ }
+ // for mmap we read history for metas only
+ else {
+ if (cc->IsSub())
+ return;
+
+ bIsMeta = cc->IsMeta();
+ }
+
if ((hDst = MapContact(hContact)) == INVALID_CONTACT_ID) {
nSkippedContacts++;
return;
@@ -967,10 +982,14 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC
dbei.flags |= DBEF_READ;
// add dbevent
- if (dstDb->AddEvent(hDst, &dbei) != NULL)
- nMessagesCount++;
- else
- AddMessage(LPGENT("Failed to add message"));
+ MCONTACT hOwner = (bIsMeta) ? MapContact(srcDb->GetEventContact(hEvent)) : hDst;
+ if (hOwner != INVALID_CONTACT_ID) {
+ // add dbevent
+ if (dstDb->AddEvent(hOwner, &dbei) != NULL)
+ nMessagesCount++;
+ else
+ AddMessage(LPGENT("Failed to add message"));
+ }
}
else nDupes++;
}