diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp
index d553f45e12..6618e95939 100644
--- a/src/gui/accountsettings.cpp
+++ b/src/gui/accountsettings.cpp
@@ -931,8 +931,8 @@ void AccountSettings::slotUpdateQuota(qint64 total, qint64 used)
void AccountSettings::slotAccountStateChanged()
{
- int state = _accountState ? _accountState->state() : AccountState::Disconnected;
- if (_accountState) {
+ const AccountState::State state = _accountState ? _accountState->state() : AccountState::Disconnected;
+ if (state != AccountState::Disconnected) {
_ui->sslButton->updateAccountState(_accountState);
AccountPtr account = _accountState->account();
QUrl safeUrl(account->url());
@@ -942,9 +942,9 @@ void AccountSettings::slotAccountStateChanged()
_model->slotUpdateFolderState(folder);
}
- QString server = QString::fromLatin1("%2")
- .arg(Utility::escape(account->url().toString()),
- Utility::escape(safeUrl.toString()));
+ const QString server = QString::fromLatin1("%2")
+ .arg(Utility::escape(account->url().toString()),
+ Utility::escape(safeUrl.toString()));
QString serverWithUser = server;
if (AbstractCredentials *cred = account->credentials()) {
QString user = account->davDisplayName();
@@ -954,19 +954,25 @@ void AccountSettings::slotAccountStateChanged()
serverWithUser = tr("%1 as %2").arg(server, Utility::escape(user));
}
- if (state == AccountState::Connected) {
+ switch (state) {
+ case AccountState::Connected: {
QStringList errors;
if (account->serverVersionUnsupported()) {
errors << tr("The server version %1 is unsupported! Proceed at your own risk.").arg(account->serverVersion());
}
showConnectionLabel(tr("Connected to %1.").arg(serverWithUser), errors);
- } else if (state == AccountState::ServiceUnavailable) {
+ break;
+ }
+ case AccountState::ServiceUnavailable:
showConnectionLabel(tr("Server %1 is temporarily unavailable.").arg(server));
- } else if (state == AccountState::MaintenanceMode) {
+ break;
+ case AccountState::MaintenanceMode:
showConnectionLabel(tr("Server %1 is currently in maintenance mode.").arg(server));
- } else if (state == AccountState::SignedOut) {
+ break;
+ case AccountState::SignedOut:
showConnectionLabel(tr("Signed out from %1.").arg(serverWithUser));
- } else if (state == AccountState::AskingCredentials) {
+ break;
+ case AccountState::AskingCredentials: {
QUrl url;
if (auto cred = qobject_cast(account->credentials())) {
connect(cred, &HttpCredentialsGui::authorisationLinkChanged,
@@ -980,10 +986,22 @@ void AccountSettings::slotAccountStateChanged()
} else {
showConnectionLabel(tr("Connecting to %1 …").arg(serverWithUser));
}
- } else {
+ break;
+ }
+ case AccountState::NetworkError:
showConnectionLabel(tr("No connection to %1 at %2.")
.arg(Utility::escape(Theme::instance()->appNameGUI()), server),
_accountState->connectionErrors());
+ break;
+ case AccountState::ConfigurationError:
+ showConnectionLabel(tr("Server configuration error: %1 at %2.")
+ .arg(Utility::escape(Theme::instance()->appNameGUI()), server),
+ _accountState->connectionErrors());
+ break;
+ case AccountState::Disconnected:
+ // we can't end up here as the whole block is ifdeffed
+ Q_UNREACHABLE();
+ break;
}
} else {
// ownCloud is not yet configured.