From 9d38cf95d713574776c4892146b67c69cc96cb2c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 26 Mar 2018 17:09:02 +0300 Subject: Import: fix to prevent the user-defined accounts' order --- plugins/Import/src/import.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'plugins/Import/src/import.cpp') diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 6a43144059..84a02428d1 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -38,6 +38,7 @@ struct AccountMap ptrA szSrcAcc, szBaseProto; ptrW tszSrcName; int iSrcIndex; + int iOrder; PROTOACCOUNT *pa; }; @@ -45,6 +46,10 @@ static int CompareAccs(const AccountMap *p1, const AccountMap *p2) { return mir_strcmpi(p1->szSrcAcc, p2->szSrcAcc); } +static int CompareAccByIds(const AccountMap *p1, const AccountMap *p2) +{ return p1->iOrder - p2->iOrder; +} + ///////////////////////////////////////////////////////////////////////////////////////// struct ContactMap @@ -437,6 +442,9 @@ bool ImportAccounts(OBJLIST &arSkippedModules) AccountMap *pNew = new AccountMap(szProto, i, tszName); arAccountMap.insert(pNew); + itoa(200 + i, szSetting, 10); + pNew->iOrder = myGetD(NULL, "Protocols", szSetting, 0); + // check if it's an account-based proto or an old style proto char szBaseProto[100]; if (myGetS(NULL, szProto, "AM_BaseProto", szBaseProto)) @@ -466,7 +474,11 @@ bool ImportAccounts(OBJLIST &arSkippedModules) bool bImportSysAll = (nImportOptions & IOPT_SYS_SETTINGS) != 0; - for (auto &p : arAccountMap) { + LIST arIndexedMap(arAccountMap.getCount(), CompareAccByIds); + for (auto &it : arAccountMap) + arIndexedMap.insert(it); + + for (auto &p : arIndexedMap) { if (p->szBaseProto == NULL || !mir_strcmp(p->szSrcAcc, META_PROTO)) continue; -- cgit v1.2.3