Commit cf68f33c authored by Shashwat Jolly's avatar Shashwat Jolly

Use etebase error codes for detecting login failures

parent 4769aebf
......@@ -83,6 +83,11 @@ bool EteSyncClientState::login(const QString &serverUrl, const QString &username
mPassword = password;
mClientXXX = etebase_client_new(QStringLiteral("Akonadi EteSync Resource"), mServerUrl);
if (!mClientXXX) {
qCDebug(ETESYNC_LOG) << "Could not initialise Etebase client";
qCDebug(ETESYNC_LOG) << "Etebase error" << etebase_error_get_message();
return false;
}
mAccountXXX = etebase_account_login(mClientXXX.get(), mUsername, mPassword);
if (!mAccountXXX) {
qCDebug(ETESYNC_LOG) << "Could not fetch Etebase account";
......
......@@ -118,11 +118,11 @@ bool LoginPage::validatePage()
{
if (!mLoginResult) {
qCDebug(ETESYNC_LOG) << "loginResult error" << mErrorCode;
if (mErrorCode == EteSyncErrorCode::ETESYNC_ERROR_CODE_UNAUTHORIZED || mErrorCode == EteSyncErrorCode::ETESYNC_ERROR_CODE_HTTP) {
if (mErrorCode == EtebaseErrorCode::ETEBASE_ERROR_CODE_UNAUTHORIZED) {
mLoginLabel->setText(i18n("Incorrect login credentials. Please try again."));
} else if (mErrorCode == EteSyncErrorCode::ETESYNC_ERROR_CODE_ENCODING) {
} else if (mErrorCode == EtebaseErrorCode::ETEBASE_ERROR_CODE_URL_PARSE) {
mLoginLabel->setText(i18n("Please ensure that the server URL is correct. The URL should start with http:// or https://."));
} else if (mErrorCode == EteSyncErrorCode::ETESYNC_ERROR_CODE_CONNECTION) {
} else if (mErrorCode == EtebaseErrorCode::ETEBASE_ERROR_CODE_CONNECTION) {
mLoginLabel->setText(i18n("Could not connect to the server. Please ensure that the server URL is correct."));
} else {
mLoginLabel->setText(i18n(charArrFromQString(mErrorMessage)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment