From: Christian Kamm Date: Fri, 24 Apr 2015 09:32:47 +0000 (+0200) Subject: AccountState: Treat *any* 503 as a temporary error. #3113 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~1803^2~122 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=73e2254a808c85afa54f2d54497b120b36e122fc;p=nextcloud-desktop.git AccountState: Treat *any* 503 as a temporary error. #3113 --- diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index f46cf80b1..919bae587 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -234,7 +234,7 @@ void AccountSettings::slotAddFolder( Folder *folder ) if( ! folder || folder->alias().isEmpty() ) return; QStandardItem *item = new QStandardItem(); - folderToModelItem( item, folder, _accountState && _accountState->isConnectedOrMaintenance()); + folderToModelItem( item, folder, _accountState && _accountState->isConnectedOrTemporarilyUnavailable()); _model->appendRow( item ); // in order to update the enabled state of the "Sync now" button connect(folder, SIGNAL(syncStateChange()), this, SLOT(slotFolderSyncStateChange()), Qt::UniqueConnection); @@ -537,7 +537,7 @@ void AccountSettings::slotUpdateFolderState( Folder *folder ) } if( item ) { - folderToModelItem( item, folder, _accountState->isConnectedOrMaintenance() ); + folderToModelItem( item, folder, _accountState->isConnectedOrTemporarilyUnavailable() ); } else { // the dialog is not visible. } @@ -794,7 +794,7 @@ void AccountSettings::slotAccountStateChanged(int state) foreach (Folder *folder, folderMan->map().values()) { slotUpdateFolderState(folder); } - if (state == AccountState::Connected || state == AccountState::ServerMaintenance) { + if (state == AccountState::Connected || state == AccountState::ServiceUnavailable) { QString user; if (AbstractCredentials *cred = account->credentials()) { user = cred->user(); diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp index 43f876246..a2c9cf63e 100644 --- a/src/gui/accountstate.cpp +++ b/src/gui/accountstate.cpp @@ -129,8 +129,8 @@ QString AccountState::stateString(State state) return QLatin1String("Disconnected"); case Connected: return QLatin1String("Connected"); - case ServerMaintenance: - return QLatin1String("ServerMaintenance"); + case ServiceUnavailable: + return QLatin1String("ServiceUnavailable"); case NetworkError: return QLatin1String("NetworkError"); case ConfigurationError: @@ -158,9 +158,9 @@ bool AccountState::isConnected() const return _state == Connected; } -bool AccountState::isConnectedOrMaintenance() const +bool AccountState::isConnectedOrTemporarilyUnavailable() const { - return isConnected() || _state == ServerMaintenance; + return isConnected() || _state == ServiceUnavailable; } QuotaInfo *AccountState::quotaInfo() @@ -234,8 +234,8 @@ void AccountState::slotConnectionValidatorResult(ConnectionValidator::Status sta case ConnectionValidator::UserCanceledCredentials: setState(SignedOut); break; - case ConnectionValidator::ServerMaintenance: - setState(ServerMaintenance); + case ConnectionValidator::ServiceUnavailable: + setState(ServiceUnavailable); break; case ConnectionValidator::Timeout: setState(NetworkError); diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h index 8da575be4..c21b25ead 100644 --- a/src/gui/accountstate.h +++ b/src/gui/accountstate.h @@ -67,9 +67,9 @@ public: /// The account is successfully talking to the server. Connected, - /// The account is talking to the server, but the server is in - /// maintenance mode. - ServerMaintenance, + /// There's a temporary problem with talking to the server, + /// don't bother the user too much and try again. + ServiceUnavailable, /// Could not communicate with the server for some reason. /// We assume this may resolve itself over time and will try @@ -100,7 +100,7 @@ public: void setSignedOut(bool signedOut); bool isConnected() const; - bool isConnectedOrMaintenance() const; + bool isConnectedOrTemporarilyUnavailable() const; QuotaInfo *quotaInfo(); diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 946384ea1..2ed510cbe 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -270,7 +270,7 @@ void Application::slotAccountStateChanged(int state) folderMan->setSyncEnabled(true); folderMan->slotScheduleAllFolders(); break; - case AccountState::ServerMaintenance: + case AccountState::ServiceUnavailable: case AccountState::SignedOut: case AccountState::ConfigurationError: case AccountState::NetworkError: diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 48ec2b526..689448382 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -221,7 +221,7 @@ void ownCloudGui::slotComputeOverallSyncStatus() _tray->setToolTip(tr("Please sign in")); return; } - if (!a->isConnectedOrMaintenance()) { + if (!a->isConnectedOrTemporarilyUnavailable()) { _tray->setIcon(Theme::instance()->folderOfflineIcon(true)); _tray->setToolTip(tr("Disconnected from server")); return; diff --git a/src/libsync/connectionvalidator.cpp b/src/libsync/connectionvalidator.cpp index b79b11b4d..89e61eda8 100644 --- a/src/libsync/connectionvalidator.cpp +++ b/src/libsync/connectionvalidator.cpp @@ -48,8 +48,8 @@ QString ConnectionValidator::statusString( Status stat ) return QLatin1String("Status not found"); case UserCanceledCredentials: return QLatin1String("User canceled credentials"); - case ServerMaintenance: - return QLatin1String("Server in maintenance mode"); + case ServiceUnavailable: + return QLatin1String("Service unavailable"); case Timeout: return QLatin1String("Timeout"); } @@ -192,13 +192,8 @@ void ConnectionValidator::slotAuthFailed(QNetworkReply *reply) const int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if ( httpStatus == 503 ) { - // Is this a maintenance mode reply from the server - // or a regular 503 from somewhere else? - QByteArray body = reply->readAll(); - if ( body.contains("Sabre\\DAV\\Exception\\ServiceUnavailable") ) { - _errors.clear(); - stat = ServerMaintenance; - } + _errors.clear(); + stat = ServiceUnavailable; } } diff --git a/src/libsync/connectionvalidator.h b/src/libsync/connectionvalidator.h index 92ffae505..4beb8dfba 100644 --- a/src/libsync/connectionvalidator.h +++ b/src/libsync/connectionvalidator.h @@ -77,7 +77,7 @@ public: CredentialsWrong, StatusNotFound, UserCanceledCredentials, - ServerMaintenance, + ServiceUnavailable, // actually also used for other errors on the authed request Timeout };