diff options
author | George Hazan <george.hazan@gmail.com> | 2014-09-30 13:35:36 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-09-30 13:35:36 +0000 |
commit | fc2d8dc3298e37e459e05bf97db36e114c2e8194 (patch) | |
tree | 37e2114be1dc9b856630195c78a7d56d294c3c5e /plugins/Import | |
parent | 9980e9ed174b20dd861e3cc3fcf8f26bff1b74a5 (diff) |
fix for the metahistory import
git-svn-id: http://svn.miranda-ng.org/main/trunk@10652 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Import')
-rw-r--r-- | plugins/Import/src/import.cpp | 88 |
1 files changed, 21 insertions, 67 deletions
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index d2cbb2f39f..94e2c0854d 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -552,53 +552,12 @@ static MCONTACT ImportContact(MCONTACT hSrc) }
/////////////////////////////////////////////////////////////////////////////////////////
-// This function should always be called after contact import. That is
-// why there are no messages for errors related to contacts. Those
-// would only be a repetition of the messages printed during contact
-// import.
-
-static MCONTACT convertContact(MCONTACT hContact)
-{
- // Check what protocol this contact belongs to
- char szProto[100];
- if (myGetS(hContact, "Protocol", "p", szProto))
- return INVALID_CONTACT_ID;
-
- // Protocol installed?
- if (!IsProtocolLoaded(szProto))
- return INVALID_CONTACT_ID;
-
- // Is contact in database?
- char* pszUniqueSetting = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
-
- // Skip protocols with no unique id setting (some non IM protocols return NULL)
- MCONTACT hDst = INVALID_CONTACT_ID;
- if (pszUniqueSetting && (INT_PTR)pszUniqueSetting != CALLSERVICE_NOTFOUND) {
- DBVARIANT dbv;
- if (!myGet(hContact, szProto, pszUniqueSetting, &dbv)) {
- switch (dbv.type) {
- case DBVT_DWORD:
- hDst = HContactFromNumericID(szProto, pszUniqueSetting, dbv.dVal);
- break;
-
- case DBVT_ASCIIZ:
- hDst = HContactFromID(szProto, pszUniqueSetting, _A2T(dbv.pszVal));
- break;
-
- case DBVT_WCHAR:
- hDst = HContactFromID(szProto, pszUniqueSetting, dbv.ptszVal);
- break;
- }
- srcDb->FreeVariant(&dbv);
- }
- }
- return hDst;
-}
+// contact's history import
static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoCount)
{
// Is it contats history import?
- MCONTACT hDst = (protoCount == 0) ? convertContact(hContact) : NULL; //system history import
+ MCONTACT hDst = (protoCount == 0) ? MapContact(hContact) : NULL; //system history import
// OK to import this chain?
if (hDst == INVALID_CONTACT_ID) {
@@ -606,15 +565,13 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC return;
}
- int i = 0, skipAll = 0;
+ bool bSkipAll = false;
DWORD cbAlloc = 4096;
BYTE* eventBuf = (PBYTE)mir_alloc(cbAlloc);
// Get the start of the event chain
HANDLE hEvent = srcDb->FindFirstEvent(hContact);
- while (hEvent) {
- int skip = 0;
-
+ for (int i = 0; hEvent; i++, hEvent = srcDb->FindNextEvent(hContact, hEvent)) {
// Copy the event and import it
DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.cbBlob = srcDb->GetBlobSize(hEvent);
@@ -624,57 +581,58 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC }
dbei.pBlob = eventBuf;
+ bool bSkipThis = false;
if (!srcDb->GetEvent(hEvent, &dbei)) {
// check protocols during system history import
if (hDst == NULL) {
- skipAll = 1;
+ bSkipAll = true;
for (int i = 0; i < protoCount; i++) {
if (!strcmp(dbei.szModule, protocol[i]->szModuleName)) {
- skipAll = 0;
+ bSkipAll = false;
break;
}
}
- skip = skipAll;
+ bSkipThis = bSkipAll;
}
// custom filtering
- if (!skip && nImportOption == IMPORT_CUSTOM) {
+ if (!bSkipThis && nImportOption == IMPORT_CUSTOM) {
BOOL sent = (dbei.flags & DBEF_SENT);
if (dbei.timestamp < (DWORD)dwSinceDate)
- skip = 1;
+ bSkipThis = 1;
- if (!skip) {
+ if (!bSkipThis) {
if (hDst) {
- skip = 1;
+ bSkipThis = 1;
switch (dbei.eventType) {
case EVENTTYPE_MESSAGE:
if ((sent ? IOPT_MSGSENT : IOPT_MSGRECV) & nCustomOptions)
- skip = 0;
+ bSkipThis = 0;
break;
case EVENTTYPE_FILE:
if ((sent ? IOPT_FILESENT : IOPT_FILERECV) & nCustomOptions)
- skip = 0;
+ bSkipThis = 0;
break;
case EVENTTYPE_URL:
if ((sent ? IOPT_URLSENT : IOPT_URLRECV) & nCustomOptions)
- skip = 0;
+ bSkipThis = 0;
break;
default:
if ((sent ? IOPT_OTHERSENT : IOPT_OTHERRECV) & nCustomOptions)
- skip = 0;
+ bSkipThis = 0;
break;
}
}
else if (!(nCustomOptions & IOPT_SYSTEM))
- skip = 1;
+ bSkipThis = 1;
}
- if (skip)
+ if (bSkipThis)
nSkippedEvents++;
}
- if (!skip) {
+ if (!bSkipThis) {
// Check for duplicate entries
if (!IsDuplicateEvent(hDst, dbei)) {
// no need to display all these dialogs again
@@ -699,13 +657,9 @@ static void ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int protoC }
}
- // skip this chain if needed
- if (skipAll)
+ // bSkipThis this chain if needed
+ if (bSkipAll)
break;
-
- // Get next event
- hEvent = srcDb->FindNextEvent(hContact, hEvent);
- i++;
}
mir_free(eventBuf);
}
|