int FolderMan::setupFolders() { unloadAndDeleteAllFolders(); auto settings = Account::settingsWithGroup(QLatin1String("Accounts")); const auto accountsWithSettings = settings->childGroups(); if (accountsWithSettings.isEmpty()) { int r = setupFoldersMigration(); if (r > 0) { AccountManager::instance()->save(false); // don't save credentials, they had not been loaded from keychain } return r; } qDebug() << "* Setup folders from settings file"; foreach (const auto& account, AccountManager::instance()->accounts()) { const auto id = account->account()->id(); if (!accountsWithSettings.contains(id)) { continue; } settings->beginGroup(id); settings->beginGroup(QLatin1String("Folders")); foreach (const auto& folderAlias, settings->childGroups()) { FolderDefinition folderDefinition; if (FolderDefinition::load(*settings, folderAlias, &folderDefinition)) { Folder* f = addFolderInternal(folderDefinition); if (f) { f->setAccountState( account.data() ); slotScheduleSync(f); emit folderSyncStateChange(f); } } } settings->endGroup(); // Folders settings->endGroup(); // <account> } emit folderListChanged(_folderMap); return _folderMap.size(); }
int FolderMan::setupFolders() { unloadAndDeleteAllFolders(); auto settings = ConfigFile::settingsWithGroup(QLatin1String("Accounts")); const auto accountsWithSettings = settings->childGroups(); if (accountsWithSettings.isEmpty()) { int r = setupFoldersMigration(); if (r > 0) { AccountManager::instance()->save(false); // don't save credentials, they had not been loaded from keychain } return r; } qCInfo(lcFolderMan) << "Setup folders from settings file"; foreach (const auto &account, AccountManager::instance()->accounts()) { const auto id = account->account()->id(); if (!accountsWithSettings.contains(id)) { continue; } settings->beginGroup(id); settings->beginGroup(QLatin1String("Folders")); setupFoldersHelper(*settings, account, true); settings->endGroup(); // See Folder::saveToSettings for details about why this exists. settings->beginGroup(QLatin1String("Multifolders")); setupFoldersHelper(*settings, account, false); settings->endGroup(); settings->endGroup(); // <account> } emit folderListChanged(_folderMap); return _folderMap.size(); }