From 3c58e2a8ed09a12a016ef2cce151aee68db4efd8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 21 Aug 2014 18:03:43 +0000 Subject: Import: - fix for duplicated old/disabled/virtual accounts; - fix for the automatic account mapping; - stubs for metas; git-svn-id: http://svn.miranda-ng.org/main/trunk@10263 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Import/src/import.cpp | 52 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 'plugins/Import/src/import.cpp') diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 634e6b716e..403cf703ec 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -40,7 +40,23 @@ static int CompareAccs(const AccountMap *p1, const AccountMap *p2) { return stricmp(p1->szSrcAcc, p2->szSrcAcc); } +///////////////////////////////////////////////////////////////////////////////////////// + +struct ContactMap +{ + ContactMap(MCONTACT _src, MCONTACT _dst) : + srcID(_src), + dstID(_dst) + {} + + MCONTACT srcID, dstID; +}; + +///////////////////////////////////////////////////////////////////////////////////////// + static OBJLIST arAccountMap(5, CompareAccs); +static OBJLIST arContactMap(50, NumericKeySortT); +static LIST arMetas(10); ///////////////////////////////////////////////////////////////////////////////////////// // local data @@ -191,7 +207,8 @@ static PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto) if (lstrcmpA(pa->szProtoName, szBaseProto)) continue; - if (pa->bOldProto) + // these protocols have no accounts, and their name match -> success + if (pa->bOldProto || pa->bIsVirtual || pa->bDynDisabled) return pa; char *pszUniqueSetting = (char*)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); @@ -297,6 +314,8 @@ static MCONTACT AddContact(HWND hdlgProgress, char* szProto, char* pszUniqueSett return hContact; } +///////////////////////////////////////////////////////////////////////////////////////// + static int ImportGroup(const char* szSettingName, LPARAM lParam) { int *pnGroups = (int*)lParam; @@ -310,8 +329,6 @@ static int ImportGroup(const char* szSettingName, LPARAM lParam) return 0; } -///////////////////////////////////////////////////////////////////////////////////////// - static int ImportGroups() { int nGroups = 0; @@ -324,6 +341,15 @@ static int ImportGroups() return nGroups; } +///////////////////////////////////////////////////////////////////////////////////////// + +void ImportMeta(DBCachedContact *cc) +{ + +} + +///////////////////////////////////////////////////////////////////////////////////////// + static MCONTACT ImportContact(MCONTACT hSrc) { TCHAR id[40], *pszUniqueID; @@ -335,6 +361,11 @@ static MCONTACT ImportContact(MCONTACT hSrc) return NULL; } + if (cc->IsMeta()) { + arMetas.insert(cc); + return NULL; + } + AccountMap *pda = arAccountMap.find((AccountMap*)&cc->szProto); if (pda == NULL) { AddMessage(LPGENT("Skipping contact, account %S cannot be mapped."), cc->szProto); @@ -354,7 +385,11 @@ static MCONTACT ImportContact(MCONTACT hSrc) } DBVARIANT dbv; - if (myGet(hSrc, cc->szProto, pszUniqueSetting, &dbv)) { + if (!strcmp(cc->szProto, META_PROTO)) { + dbv.type = DBVT_DWORD; + dbv.dVal = hSrc; + } + else if (myGet(hSrc, cc->szProto, pszUniqueSetting, &dbv)) { AddMessage(LPGENT("Skipping %S contact, ID not found"), cc->szProto); return NULL; } @@ -387,6 +422,8 @@ static MCONTACT ImportContact(MCONTACT hSrc) hDst = AddContact(hdlgProgress, pda->szDstAcc, pszUniqueSetting, &dbv, pszUniqueID, tszNick, tszGroup); mir_free(tszGroup), mir_free(tszNick); + arContactMap.insert(new ContactMap(hSrc, hDst)); + if (hDst != INVALID_CONTACT_ID) { // Hidden? if (!myGet(hSrc, "CList", "Hidden", &dbv)) { @@ -673,6 +710,9 @@ void MirandaImport(HWND hdlg) // Get next contact in chain hContact = srcDb->FindNextContact(hContact); } + + for (i = 0; i < arMetas.getCount(); i++) + ImportMeta(arMetas[i]); } else AddMessage(LPGENT("Skipping new contacts import.")); AddMessage(_T("")); @@ -736,4 +776,8 @@ void MirandaImport(HWND hdlg) LPGENT("Skipped %d duplicates and %d filtered events.") : LPGENT("Skipped %d duplicates."), nDupes, nSkippedEvents); } + + arMetas.destroy(); + arAccountMap.destroy(); + arContactMap.destroy(); } -- cgit v1.2.3