From e7c82fe33fd89bc86814cdbec42905cd7a095547 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Wed, 6 Dec 2023 16:22:25 +0100 Subject: [PATCH] Apply suggestions from code review Formatting fixes Co-authored-by: Claudio Cambra Signed-off-by: Micke Nordin --- src/gui/wizard/owncloudsetuppage.cpp | 5 +++-- src/gui/wizard/owncloudwizard.cpp | 19 +++++++++++-------- src/libsync/configfile.cpp | 7 +++++-- src/libsync/networkjobs.cpp | 23 ++++++++++++----------- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/gui/wizard/owncloudsetuppage.cpp b/src/gui/wizard/owncloudsetuppage.cpp index 15be3e342dd5e..a5374eb59fc3c 100644 --- a/src/gui/wizard/owncloudsetuppage.cpp +++ b/src/gui/wizard/owncloudsetuppage.cpp @@ -213,8 +213,9 @@ int OwncloudSetupPage::nextId() const return WizardCommon::Page_Flow2AuthCreds; #ifdef WITH_WEBENGINE case DetermineAuthTypeJob::WebViewFlow: - if (this->useFlow2) - return WizardCommon::Page_Flow2AuthCreds; + if (this->useFlow2) { + return WizardCommon::Page_Flow2AuthCreds; + } return WizardCommon::Page_WebView; #endif // WITH_WEBENGINE case DetermineAuthTypeJob::NoAuthType: diff --git a/src/gui/wizard/owncloudwizard.cpp b/src/gui/wizard/owncloudwizard.cpp index a70421a762ebc..37b3ebeea4fc1 100644 --- a/src/gui/wizard/owncloudwizard.cpp +++ b/src/gui/wizard/owncloudwizard.cpp @@ -65,8 +65,9 @@ OwncloudWizard::OwncloudWizard(QWidget *parent) setPage(WizardCommon::Page_Flow2AuthCreds, _flow2CredsPage); setPage(WizardCommon::Page_AdvancedSetup, _advancedSetupPage); #ifdef WITH_WEBENGINE - if(!useFlow2()) - setPage(WizardCommon::Page_WebView, _webViewPage); + if (!useFlow2()) { + setPage(WizardCommon::Page_WebView, _webViewPage); + } #endif // WITH_WEBENGINE connect(this, &QDialog::finished, this, &OwncloudWizard::basicSetupFinished); @@ -79,8 +80,9 @@ OwncloudWizard::OwncloudWizard(QWidget *parent) connect(_httpCredsPage, &OwncloudHttpCredsPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl); connect(_flow2CredsPage, &Flow2AuthCredsPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl); #ifdef WITH_WEBENGINE - if(!useFlow2()) - connect(_webViewPage, &WebViewPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl); + if (!useFlow2()) { + connect(_webViewPage, &WebViewPage::connectToOCUrl, this, &OwncloudWizard::connectToOCUrl); + } #endif // WITH_WEBENGINE connect(_advancedSetupPage, &OwncloudAdvancedSetupPage::createLocalAndRemoteFolders, this, &OwncloudWizard::createLocalAndRemoteFolders); @@ -237,8 +239,9 @@ void OwncloudWizard::successfulStep() #ifdef WITH_WEBENGINE case WizardCommon::Page_WebView: - if(!this->useFlow2()) - _webViewPage->setConnected(); + if (!this->useFlow2()) { + _webViewPage->setConnected(); + } break; #endif // WITH_WEBENGINE @@ -280,9 +283,9 @@ void OwncloudWizard::setAuthType(DetermineAuthTypeJob::AuthType type) #ifdef WITH_WEBENGINE } else if (type == DetermineAuthTypeJob::WebViewFlow) { if(this->useFlow2()) { - _credentialsPage = _flow2CredsPage; + _credentialsPage = _flow2CredsPage; } else { - _credentialsPage = _webViewPage; + _credentialsPage = _webViewPage; } #endif // WITH_WEBENGINE } else { // try Basic auth even for "Unknown" diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 39949683f8bce..7d2ebb4f39369 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -993,10 +993,13 @@ void ConfigFile::setMoveToTrash(bool isChecked) setValue(moveToTrashC, isChecked); } -bool ConfigFile::forceLoginV2() const { +bool ConfigFile::forceLoginV2() const +{ return getValue(forceLoginV2C, QString(), false).toBool(); } -void ConfigFile::setForceLoginV2(bool isChecked) { + +void ConfigFile::setForceLoginV2(bool isChecked) +{ setValue(forceLoginV2C, isChecked); } diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 48f10eb363be3..93e220c478b5a 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -1012,9 +1012,8 @@ bool JsonApiJob::finished() DetermineAuthTypeJob::DetermineAuthTypeJob(AccountPtr account, QObject *parent) : QObject(parent) , _account(account) - { - useFlow2 = ConfigFile().forceLoginV2(); + useFlow2 = ConfigFile().forceLoginV2(); } void DetermineAuthTypeJob::start() @@ -1080,11 +1079,11 @@ void DetermineAuthTypeJob::start() if (flow != QJsonValue::Undefined) { if (flow.toInt() == 1) { #ifdef WITH_WEBENGINE - if(!this->useFlow2) { - _resultOldFlow = WebViewFlow; - } else { - qCWarning(lcDetermineAuthTypeJob) << "Server only supports flow1, but this client was configured to only use flow2"; - } + if(!this->useFlow2) { + _resultOldFlow = WebViewFlow; + } else { + qCWarning(lcDetermineAuthTypeJob) << "Server only supports flow1, but this client was configured to only use flow2"; + } #else // WITH_WEBENGINE qCWarning(lcDetermineAuthTypeJob) << "Server does only support flow1, but this client was compiled without support for flow1"; #endif // WITH_WEBENGINE @@ -1118,8 +1117,9 @@ void DetermineAuthTypeJob::checkAllDone() // WebViewFlow > Basic if (_account->serverVersionInt() >= Account::makeServerVersion(12, 0, 0)) { result = WebViewFlow; - if(useFlow2) - result = LoginFlowV2; + if (useFlow2) { + result = LoginFlowV2; + } } #endif // WITH_WEBENGINE @@ -1132,8 +1132,9 @@ void DetermineAuthTypeJob::checkAllDone() // If we determined that we need the webview flow (GS for example) then we switch to that if (_resultOldFlow == WebViewFlow) { result = WebViewFlow; - if(useFlow2) - result = LoginFlowV2; + if (useFlow2) { + result = LoginFlowV2; + } } #endif // WITH_WEBENGINE