diff --git a/spotifyblob/blob/spotifyclient.cpp b/spotifyblob/blob/spotifyclient.cpp index 0b0e27410..005ba9ee3 100644 --- a/spotifyblob/blob/spotifyclient.cpp +++ b/spotifyblob/blob/spotifyclient.cpp @@ -317,7 +317,7 @@ void SpotifyClient::Login(const spotify_pb::LoginRequest& req) { if (error != SP_ERROR_OK) { qLog(Warning) << "Tried to relogin but no stored credentials"; SendLoginCompleted(false, sp_error_message(error), - spotify_pb::LoginResponse_Error_BadUsernameOrPassword); + spotify_pb::LoginResponse_Error_ReloginFailed); } } else { sp_session_login(session_, diff --git a/spotifyblob/common/spotifymessages.proto b/spotifyblob/common/spotifymessages.proto index db46edff6..d0c20ff8f 100644 --- a/spotifyblob/common/spotifymessages.proto +++ b/spotifyblob/common/spotifymessages.proto @@ -37,6 +37,7 @@ message LoginResponse { UserBanned = 2; UserNeedsPremium = 3; Other = 4; + ReloginFailed = 5; } required bool success = 1; diff --git a/src/internet/spotifyservice.cpp b/src/internet/spotifyservice.cpp index 735ad027f..189be3823 100644 --- a/src/internet/spotifyservice.cpp +++ b/src/internet/spotifyservice.cpp @@ -140,10 +140,9 @@ void SpotifyService::LoginCompleted(bool success, const QString& error, login_task_id_ = 0; } - login_state_ = LoginState_LoggedIn; - if (!success) { - QMessageBox::warning(NULL, tr("Spotify login error"), error, QMessageBox::Close); + bool show_error_dialog = true; + QString error_copy(error); switch (error_code) { case spotify_pb::LoginResponse_Error_BadUsernameOrPassword: @@ -158,9 +157,28 @@ void SpotifyService::LoginCompleted(bool success, const QString& error, login_state_ = LoginState_NoPremium; break; + case spotify_pb::LoginResponse_Error_ReloginFailed: + if (login_state_ == LoginState_LoggedIn) { + // This is the first time the relogin has failed - show a message this + // time only. + error_copy = tr("You have been logged out of Spotify, please re-enter your password in the Settings dialog."); + } else { + show_error_dialog = false; + } + + login_state_ = LoginState_ReloginFailed; + break; + default: login_state_ = LoginState_OtherError; + break; } + + if (show_error_dialog) { + QMessageBox::warning(NULL, tr("Spotify login error"), error_copy, QMessageBox::Close); + } + } else { + login_state_ = LoginState_LoggedIn; } QSettings s; diff --git a/src/internet/spotifyservice.h b/src/internet/spotifyservice.h index cf6b761be..d71586799 100644 --- a/src/internet/spotifyservice.h +++ b/src/internet/spotifyservice.h @@ -39,7 +39,8 @@ public: LoginState_Banned = 2, LoginState_BadCredentials = 3, LoginState_NoPremium = 4, - LoginState_OtherError = 5 + LoginState_OtherError = 5, + LoginState_ReloginFailed = 6 }; static const char* kServiceName; diff --git a/src/internet/spotifysettingspage.cpp b/src/internet/spotifysettingspage.cpp index e4a918525..085729711 100644 --- a/src/internet/spotifysettingspage.cpp +++ b/src/internet/spotifysettingspage.cpp @@ -154,6 +154,10 @@ void SpotifySettingsPage::UpdateLoginState() { ui_->login_state->SetAccountTypeText(tr("Your username or password was incorrect.")); break; + case SpotifyService::LoginState_ReloginFailed: + ui_->login_state->SetAccountTypeText(tr("You have been logged out of Spotify, please re-enter your password.")); + break; + default: ui_->login_state->SetAccountTypeText(tr("A Spotify Premium account is required.")); break; diff --git a/src/translations/translations.pot b/src/translations/translations.pot index 060c627c8..4943ffa52 100644 --- a/src/translations/translations.pot +++ b/src/translations/translations.pot @@ -244,7 +244,7 @@ msgstr "" msgid "A Grooveshark Anywhere account is required." msgstr "" -#: internet/spotifysettingspage.cpp:158 +#: internet/spotifysettingspage.cpp:162 msgid "A Spotify Premium account is required." msgstr "" @@ -1008,7 +1008,7 @@ msgstr "" msgid "Configure Shortcuts" msgstr "" -#: internet/spotifyservice.cpp:472 +#: internet/spotifyservice.cpp:490 msgid "Configure Spotify..." msgstr "" @@ -1029,7 +1029,7 @@ msgstr "" msgid "Connect device" msgstr "" -#: internet/spotifyservice.cpp:227 +#: internet/spotifyservice.cpp:245 msgid "Connecting to Spotify" msgstr "" @@ -2057,7 +2057,7 @@ msgid "" "time a song finishes." msgstr "" -#: internet/spotifyservice.cpp:328 +#: internet/spotifyservice.cpp:346 msgid "Inbox" msgstr "" @@ -2466,7 +2466,7 @@ msgstr "" msgid "Main profile (MAIN)" msgstr "" -#: internet/spotifyservice.cpp:477 +#: internet/spotifyservice.cpp:495 msgid "Make playlist available offline" msgstr "" @@ -3403,15 +3403,15 @@ msgstr "" msgid "Search Magnatune" msgstr "" -#: internet/spotifysearchplaylisttype.cpp:32 internet/spotifyservice.cpp:585 +#: internet/spotifysearchplaylisttype.cpp:32 internet/spotifyservice.cpp:603 msgid "Search Spotify" msgstr "" -#: internet/spotifyservice.cpp:319 +#: internet/spotifyservice.cpp:337 msgid "Search Spotify (opens a new tab)" msgstr "" -#: internet/spotifyservice.cpp:470 +#: internet/spotifyservice.cpp:488 msgid "Search Spotify (opens a new tab)..." msgstr "" @@ -3743,7 +3743,7 @@ msgstr "" msgid "Spotify" msgstr "" -#: internet/spotifyservice.cpp:146 +#: internet/spotifyservice.cpp:178 msgid "Spotify login error" msgstr "" @@ -3759,7 +3759,7 @@ msgstr "" msgid "Standard" msgstr "" -#: internet/spotifyservice.cpp:324 +#: internet/spotifyservice.cpp:342 msgid "Starred" msgstr "" @@ -3854,15 +3854,15 @@ msgstr "" msgid "Switch provider" msgstr "" -#: internet/spotifyservice.cpp:496 +#: internet/spotifyservice.cpp:514 msgid "Syncing Spotify inbox" msgstr "" -#: internet/spotifyservice.cpp:491 +#: internet/spotifyservice.cpp:509 msgid "Syncing Spotify playlist" msgstr "" -#: internet/spotifyservice.cpp:500 +#: internet/spotifyservice.cpp:518 msgid "Syncing Spotify starred tracks" msgstr "" @@ -4464,6 +4464,16 @@ msgstr "" msgid "You do not have a Spotify Premium account." msgstr "" +#: internet/spotifyservice.cpp:164 +msgid "" +"You have been logged out of Spotify, please re-enter your password in the " +"Settings dialog." +msgstr "" + +#: internet/spotifysettingspage.cpp:158 +msgid "You have been logged out of Spotify, please re-enter your password." +msgstr "" + #: songinfo/lastfmtrackinfoprovider.cpp:95 msgid "You love this track" msgstr ""