From 7f61fa6455c42d52633bcc70dff1150ceaa7fa0b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 23 Mar 2018 13:33:18 +0300 Subject: Import: fix for groups order saving during import --- plugins/Import/src/import.cpp | 39 ++++++++++++++++++++++++++++++--------- plugins/Import/src/version.h | 2 +- 2 files changed, 31 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index 895c3d203e..c92deee6ff 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -568,23 +568,43 @@ void ImportContactSettings(AccountMap *pda, MCONTACT hSrc, MCONTACT hDst) ///////////////////////////////////////////////////////////////////////////////////////// -static int ImportGroup(const char* szSettingName, void *param) +struct MImportGroup { - int *pnGroups = (int*)param; + MImportGroup(int _n, wchar_t *_nm) : + wszName(_nm), + iNumber(_n) + {} - wchar_t *tszGroup = myGetWs(NULL, "CListGroups", szSettingName); - if (tszGroup != nullptr) { - if (CreateGroup(tszGroup + 1, NULL)) - pnGroups[0]++; - mir_free(tszGroup); - } + int iNumber; + ptrW wszName; +}; + +static int ImportGroup(const char* szSettingName, void *param) +{ + OBJLIST *pArray = (OBJLIST*)param; + pArray->insert(new MImportGroup(atoi(szSettingName), myGetWs(NULL, "CListGroups", szSettingName))); return 0; } static int ImportGroups() { + OBJLIST arGroups(10, NumericKeySortT); + srcDb->EnumContactSettings(NULL, ImportGroup, "CListGroups", &arGroups); + int nGroups = 0; - db_enum_settings(NULL, ImportGroup, "CListGroups", &nGroups); + for (auto &it : arGroups) { + if (Clist_GroupExists(it->wszName.get() + 1)) + continue; + + MGROUP group_id = Clist_GroupCreate(0, it->wszName.get() + 1); + if (group_id > 0) { + char szSetting[20]; + _itoa_s(group_id - 1, szSetting, 10); + db_set_ws(0, "CListGroups", szSetting, it->wszName); + nGroups++; + } + } + return nGroups; } @@ -1005,6 +1025,7 @@ void MirandaImport(HWND hdlg) DWORD dwTimer = time(nullptr); OBJLIST arSkippedAccs(1, CompareModules); + arSkippedAccs.insert(newStr("CListGroups")); if (!ImportAccounts(arSkippedAccs)) { AddMessage(LPGENW("Error mapping accounts, exiting.")); return; diff --git a/plugins/Import/src/version.h b/plugins/Import/src/version.h index 6fc4c509d7..4c1f7bccba 100644 --- a/plugins/Import/src/version.h +++ b/plugins/Import/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 95 #define __RELEASE_NUM 8 -#define __BUILD_NUM 2 +#define __BUILD_NUM 3 #include -- cgit v1.2.3