showConnectionLabel( tr("Connected to %1.").arg(serverWithUser), errors );
} else if (state == AccountState::ServiceUnavailable) {
showConnectionLabel( tr("Server %1 is temporarily unavailable.").arg(server) );
+ } else if (state == AccountState::MaintenanceMode) {
+ showConnectionLabel( tr("Server %1 is currently in maintenance mode.").arg(server) );
} else if (state == AccountState::SignedOut) {
showConnectionLabel( tr("Signed out from %1.").arg(serverWithUser) );
} else {
_connectionStatus = ConnectionValidator::Undefined;
_connectionErrors.clear();
} else if (oldState == SignedOut && _state == Disconnected) {
+ // If we stop being voluntarily signed-out, try to connect and
+ // auth right now!
+ checkConnectivity();
+ } else if (_state == ServiceUnavailable) {
+ // Check if we are actually down for maintenance.
+ // To do this we must clear the connection validator that just
+ // produced the 503. It's finished anyway and will delete itself.
+ _connectionValidator.clear();
checkConnectivity();
}
if (oldState == Connected || _state == Connected) {
return tr("Connected");
case ServiceUnavailable:
return tr("Service unavailable");
+ case MaintenanceMode:
+ return tr("Maintenance mode");
case NetworkError:
return tr("Network error");
case ConfigurationError:
return _state == Connected;
}
-bool AccountState::isConnectedOrTemporarilyUnavailable() const
-{
- return isConnected() || _state == ServiceUnavailable;
-}
-
void AccountState::tagLastSuccessfullETagRequest()
{
_timeSinceLastETagCheck.restart();
case ConnectionValidator::ServiceUnavailable:
setState(ServiceUnavailable);
break;
+ case ConnectionValidator::MaintenanceMode:
+ setState(MaintenanceMode);
+ break;
case ConnectionValidator::Timeout:
setState(NetworkError);
break;
/// don't bother the user too much and try again.
ServiceUnavailable,
+ /// Similar to ServiceUnavailable, but we know the server is down
+ /// for maintenance
+ MaintenanceMode,
+
/// Could not communicate with the server for some reason.
/// We assume this may resolve itself over time and will try
/// again automatically.
void signIn();
bool isConnected() const;
- bool isConnectedOrTemporarilyUnavailable() const;
/// Triggers a ping to the server to update state and
/// connection status and errors.
return QLatin1String("User canceled credentials");
case ServiceUnavailable:
return QLatin1String("Service unavailable");
+ case MaintenanceMode:
+ return QLatin1String("Maintenance mode");
case Timeout:
return QLatin1String("Timeout");
}
return;
}
+ if (info["maintenance"].toBool()) {
+ reportResult( MaintenanceMode );
+ return;
+ }
+
// now check the authentication
if (_account->credentials()->ready())
QTimer::singleShot( 0, this, SLOT( checkAuthentication() ));
Undefined,
Connected,
NotConfigured,
- ServerVersionMismatch,
- CredentialsMissingOrWrong,
- StatusNotFound,
- UserCanceledCredentials,
- ServiceUnavailable,
- // actually also used for other errors on the authed request
- Timeout
+ ServerVersionMismatch, // The server version is too old
+ CredentialsMissingOrWrong, // Credentials aren't ready or AuthenticationRequiredError
+ StatusNotFound, // Error retrieving status.php
+ UserCanceledCredentials, // checkAuthentication when credentials aren't ready
+ ServiceUnavailable, // 503 on authed request
+ MaintenanceMode, // maintenance enabled in status.php
+ Timeout // actually also used for other errors on the authed request
};
static QString statusString( Status );