mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
AccountSettings: Use switch, case to ensure we handle all cases
This commit is contained in:
parent
bade7aedc6
commit
0f92713ce5
1 changed files with 29 additions and 11 deletions
|
@ -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("<a href=\"%1\">%2</a>")
|
||||
.arg(Utility::escape(account->url().toString()),
|
||||
Utility::escape(safeUrl.toString()));
|
||||
const QString server = QString::fromLatin1("<a href=\"%1\">%2</a>")
|
||||
.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 <i>%2</i>").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<HttpCredentialsGui *>(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.
|
||||
|
|
Loading…
Reference in a new issue