diff options
author | Christian Kamm <mail@ckamm.de> | 2017-05-17 11:55:42 +0300 |
---|---|---|
committer | ckamm <mail@ckamm.de> | 2017-05-17 13:26:27 +0300 |
commit | c8d0f788e00bdae125a26d9159ce9efdd6325cd2 (patch) | |
tree | ad77cb515fe650984e6b76dfffe09838090d77bd /src/gui/accountmanager.cpp | |
parent | ae263d60bd6d1bc0eb0c3712bab11de120b8cdd3 (diff) |
Apply clang-format
Diffstat (limited to 'src/gui/accountmanager.cpp')
-rw-r--r-- | src/gui/accountmanager.cpp | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 1c1ab1754..a54a1b6c8 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -50,18 +50,18 @@ bool AccountManager::restore() auto settings = Utility::settingsWithGroup(QLatin1String(accountsC)); if (settings->status() != QSettings::NoError) { qCWarning(lcAccountManager) << "Could not read settings from" << settings->fileName() - << settings->status(); + << settings->status(); return false; } // If there are no accounts, check the old format. if (settings->childGroups().isEmpty() - && !settings->contains(QLatin1String(versionC))) { + && !settings->contains(QLatin1String(versionC))) { restoreFromLegacySettings(); return true; } - foreach (const auto& accountId, settings->childGroups()) { + foreach (const auto &accountId, settings->childGroups()) { settings->beginGroup(accountId); if (auto acc = loadAccountHelper(*settings)) { acc->_id = accountId; @@ -78,40 +78,44 @@ bool AccountManager::restore() bool AccountManager::restoreFromLegacySettings() { qCInfo(lcAccountManager) << "Migrate: restoreFromLegacySettings, checking settings group" - << Theme::instance()->appName(); + << Theme::instance()->appName(); // try to open the correctly themed settings auto settings = Utility::settingsWithGroup(Theme::instance()->appName()); // if the settings file could not be opened, the childKeys list is empty // then try to load settings from a very old place - if( settings->childKeys().isEmpty() ) { + if (settings->childKeys().isEmpty()) { // Now try to open the original ownCloud settings to see if they exist. - QString oCCfgFile = QDir::fromNativeSeparators( settings->fileName() ); + QString oCCfgFile = QDir::fromNativeSeparators(settings->fileName()); // replace the last two segments with ownCloud/owncloud.cfg - oCCfgFile = oCCfgFile.left( oCCfgFile.lastIndexOf('/')); - oCCfgFile = oCCfgFile.left( oCCfgFile.lastIndexOf('/')); + oCCfgFile = oCCfgFile.left(oCCfgFile.lastIndexOf('/')); + oCCfgFile = oCCfgFile.left(oCCfgFile.lastIndexOf('/')); oCCfgFile += QLatin1String("/ownCloud/owncloud.cfg"); qCInfo(lcAccountManager) << "Migrate: checking old config " << oCCfgFile; - QFileInfo fi( oCCfgFile ); - if( fi.isReadable() ) { + QFileInfo fi(oCCfgFile); + if (fi.isReadable()) { std::unique_ptr<QSettings> oCSettings(new QSettings(oCCfgFile, QSettings::IniFormat)); oCSettings->beginGroup(QLatin1String("ownCloud")); // Check the theme url to see if it is the same url that the oC config was for QString overrideUrl = Theme::instance()->overrideServerUrl(); - if( !overrideUrl.isEmpty() ) { - if (overrideUrl.endsWith('/')) { overrideUrl.chop(1); } + if (!overrideUrl.isEmpty()) { + if (overrideUrl.endsWith('/')) { + overrideUrl.chop(1); + } QString oCUrl = oCSettings->value(QLatin1String(urlC)).toString(); - if (oCUrl.endsWith('/')) { oCUrl.chop(1); } + if (oCUrl.endsWith('/')) { + oCUrl.chop(1); + } // in case the urls are equal reset the settings object to read from // the ownCloud settings object qCInfo(lcAccountManager) << "Migrate oC config if " << oCUrl << " == " << overrideUrl << ":" - << (oCUrl == overrideUrl ? "Yes" : "No"); - if( oCUrl == overrideUrl ) { + << (oCUrl == overrideUrl ? "Yes" : "No"); + if (oCUrl == overrideUrl) { settings = std::move(oCSettings); } } @@ -143,7 +147,7 @@ void AccountManager::save(bool saveCredentials) qCInfo(lcAccountManager) << "Saved all account settings, status:" << settings->status(); } -void AccountManager::saveAccount(Account* a) +void AccountManager::saveAccount(Account *a) { qCInfo(lcAccountManager) << "Saving account" << a->url().toString(); auto settings = Utility::settingsWithGroup(QLatin1String(accountsC)); @@ -155,7 +159,7 @@ void AccountManager::saveAccount(Account* a) qCInfo(lcAccountManager) << "Saved account settings, status:" << settings->status(); } -void AccountManager::saveAccountState(AccountState* a) +void AccountManager::saveAccountState(AccountState *a) { qCInfo(lcAccountManager) << "Saving account state" << a->account()->url().toString(); auto settings = Utility::settingsWithGroup(QLatin1String(accountsC)); @@ -167,7 +171,7 @@ void AccountManager::saveAccountState(AccountState* a) qCInfo(lcAccountManager) << "Saved account state settings, status:" << settings->status(); } -void AccountManager::saveAccountHelper(Account* acc, QSettings& settings, bool saveCredentials) +void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool saveCredentials) { settings.setValue(QLatin1String(urlC), acc->_url.toString()); settings.setValue(QLatin1String(serverVersionC), acc->_serverVersion); @@ -179,7 +183,7 @@ void AccountManager::saveAccountHelper(Account* acc, QSettings& settings, bool s // re-persisting them) acc->_credentials->persist(); } - Q_FOREACH(QString key, acc->_settingsMap.keys()) { + Q_FOREACH (QString key, acc->_settingsMap.keys()) { settings.setValue(key, acc->_settingsMap.value(key)); } settings.setValue(QLatin1String(authTypeC), acc->_credentials->authType()); @@ -193,17 +197,17 @@ void AccountManager::saveAccountHelper(Account* acc, QSettings& settings, bool s settings.beginGroup(QLatin1String("General")); qCInfo(lcAccountManager) << "Saving " << acc->approvedCerts().count() << " unknown certs."; QByteArray certs; - Q_FOREACH( const QSslCertificate& cert, acc->approvedCerts() ) { + Q_FOREACH (const QSslCertificate &cert, acc->approvedCerts()) { certs += cert.toPem() + '\n'; } if (!certs.isEmpty()) { - settings.setValue( QLatin1String(caCertsKeyC), certs ); + settings.setValue(QLatin1String(caCertsKeyC), certs); } settings.endGroup(); // Save cookies. if (acc->_am) { - CookieJar* jar = qobject_cast<CookieJar*>(acc->_am->cookieJar()); + CookieJar *jar = qobject_cast<CookieJar *>(acc->_am->cookieJar()); if (jar) { qCInfo(lcAccountManager) << "Saving cookies." << acc->cookieJarPath(); jar->save(acc->cookieJarPath()); @@ -211,7 +215,7 @@ void AccountManager::saveAccountHelper(Account* acc, QSettings& settings, bool s } } -AccountPtr AccountManager::loadAccountHelper(QSettings& settings) +AccountPtr AccountManager::loadAccountHelper(QSettings &settings) { auto urlConfig = settings.value(QLatin1String(urlC)); if (!urlConfig.isValid()) { @@ -236,7 +240,7 @@ AccountPtr AccountManager::loadAccountHelper(QSettings& settings) QString overrideUrl = Theme::instance()->overrideServerUrl(); QString forceAuth = Theme::instance()->forceConfigAuthType(); - if(!forceAuth.isEmpty() && !overrideUrl.isEmpty() ) { + if (!forceAuth.isEmpty() && !overrideUrl.isEmpty()) { // If forceAuth is set, this might also mean the overrideURL has changed. // See enterprise issues #1126 acc->setUrl(overrideUrl); @@ -252,7 +256,7 @@ AccountPtr AccountManager::loadAccountHelper(QSettings& settings) // We want to only restore settings for that auth type and the user value acc->_settingsMap.insert(QLatin1String(userC), settings.value(userC)); QString authTypePrefix = authType + "_"; - Q_FOREACH(QString key, settings.childKeys()) { + Q_FOREACH (QString key, settings.childKeys()) { if (!key.startsWith(authTypePrefix)) continue; acc->_settingsMap.insert(key, settings.value(key)); @@ -268,9 +272,9 @@ AccountPtr AccountManager::loadAccountHelper(QSettings& settings) return acc; } -AccountStatePtr AccountManager::account(const QString& name) +AccountStatePtr AccountManager::account(const QString &name) { - foreach (const auto& acc, _accounts) { + foreach (const auto &acc, _accounts) { if (acc->account()->displayName() == name) { return acc; } @@ -278,7 +282,7 @@ AccountStatePtr AccountManager::account(const QString& name) return AccountStatePtr(); } -AccountState *AccountManager::addAccount(const AccountPtr& newAccount) +AccountState *AccountManager::addAccount(const AccountPtr &newAccount) { auto id = newAccount->id(); if (id.isEmpty() || !isAccountIdAvailable(id)) { @@ -291,10 +295,12 @@ AccountState *AccountManager::addAccount(const AccountPtr& newAccount) return newAccountState; } -void AccountManager::deleteAccount(AccountState* account) +void AccountManager::deleteAccount(AccountState *account) { auto it = std::find(_accounts.begin(), _accounts.end(), account); - if (it == _accounts.end()) { return; } + if (it == _accounts.end()) { + return; + } auto copy = *it; // keep a reference to the shared pointer so it does not delete it just yet _accounts.erase(it); @@ -310,8 +316,8 @@ AccountPtr AccountManager::createAccount() { AccountPtr acc = Account::create(); acc->setSslErrorHandler(new SslDialogErrorHandler); - connect(acc.data(), SIGNAL(proxyAuthenticationRequired(QNetworkProxy, QAuthenticator*)), - ProxyAuthHandler::instance(), SLOT(handleProxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); + connect(acc.data(), SIGNAL(proxyAuthenticationRequired(QNetworkProxy, QAuthenticator *)), + ProxyAuthHandler::instance(), SLOT(handleProxyAuthenticationRequired(QNetworkProxy, QAuthenticator *))); return acc; } @@ -325,9 +331,9 @@ void AccountManager::shutdown() } } -bool AccountManager::isAccountIdAvailable(const QString& id) const +bool AccountManager::isAccountIdAvailable(const QString &id) const { - foreach (const auto& acc, _accounts) { + foreach (const auto &acc, _accounts) { if (acc->account()->id() == id) { return false; } @@ -347,15 +353,14 @@ QString AccountManager::generateFreeAccountId() const } } -void AccountManager::addAccountState(AccountState* accountState) +void AccountManager::addAccountState(AccountState *accountState) { QObject::connect(accountState->account().data(), - SIGNAL(wantsAccountSaved(Account*)), - SLOT(saveAccount(Account*))); + SIGNAL(wantsAccountSaved(Account *)), + SLOT(saveAccount(Account *))); AccountStatePtr ptr(accountState); _accounts << ptr; emit accountAdded(accountState); } - } |