diff --git a/src/internet/lastfmcompat.cpp b/src/internet/lastfmcompat.cpp index 4b843bb43..09603fb8c 100644 --- a/src/internet/lastfmcompat.cpp +++ b/src/internet/lastfmcompat.cpp @@ -82,6 +82,11 @@ bool ParseQuery(const QByteArray& data, XmlQuery* query, bool* connection_proble *connection_problems = false; } + // Check for app errors. + if (QDomElement(*query).attribute("status") == "failed") { + return false; + } + return true; } diff --git a/src/internet/lastfmservice.cpp b/src/internet/lastfmservice.cpp index 130a58ebd..072d11422 100644 --- a/src/internet/lastfmservice.cpp +++ b/src/internet/lastfmservice.cpp @@ -327,7 +327,7 @@ void LastFMService::AuthenticateReplyFinished(QNetworkReply* reply) { settings.setValue("Session", lastfm::ws::SessionKey); settings.setValue("Subscriber", is_subscriber); } else { - emit AuthenticationComplete(false); + emit AuthenticationComplete(false, lfm["error"].text().trimmed()); return; } @@ -335,7 +335,7 @@ void LastFMService::AuthenticateReplyFinished(QNetworkReply* reply) { delete scrobbler_; scrobbler_ = NULL; - emit AuthenticationComplete(true); + emit AuthenticationComplete(true, QString()); } void LastFMService::UpdateSubscriberStatus() { diff --git a/src/internet/lastfmservice.h b/src/internet/lastfmservice.h index f4256239f..a25b21f33 100644 --- a/src/internet/lastfmservice.h +++ b/src/internet/lastfmservice.h @@ -127,7 +127,7 @@ class LastFMService : public InternetService { void ToggleScrobbling(); signals: - void AuthenticationComplete(bool success); + void AuthenticationComplete(bool success, const QString& error_message); void ScrobblingEnabledChanged(bool value); void ButtonVisibilityChanged(bool value); void ScrobbleButtonVisibilityChanged(bool value); diff --git a/src/internet/lastfmsettingspage.cpp b/src/internet/lastfmsettingspage.cpp index 8e7704295..e09812e5d 100644 --- a/src/internet/lastfmsettingspage.cpp +++ b/src/internet/lastfmsettingspage.cpp @@ -38,7 +38,8 @@ LastFMSettingsPage::LastFMSettingsPage(SettingsDialog* dialog) // Icons setWindowIcon(QIcon(":/last.fm/as.png")); - connect(service_, SIGNAL(AuthenticationComplete(bool)), SLOT(AuthenticationComplete(bool))); + connect(service_, SIGNAL(AuthenticationComplete(bool,QString)), + SLOT(AuthenticationComplete(bool,QString))); connect(service_, SIGNAL(UpdatedSubscriberStatus(bool)), SLOT(UpdatedSubscriberStatus(bool))); connect(ui_->login_state, SIGNAL(LogoutClicked()), SLOT(Logout())); connect(ui_->login_state, SIGNAL(LoginClicked()), SLOT(Login())); @@ -63,7 +64,8 @@ void LastFMSettingsPage::Login() { service_->Authenticate(ui_->username->text(), ui_->password->text()); } -void LastFMSettingsPage::AuthenticationComplete(bool success) { +void LastFMSettingsPage::AuthenticationComplete(bool success, + const QString& message) { if (!waiting_for_auth_) return; // Wasn't us that was waiting for auth @@ -75,7 +77,11 @@ void LastFMSettingsPage::AuthenticationComplete(bool success) { // Save settings Save(); } else { - QMessageBox::warning(this, tr("Authentication failed"), tr("Your Last.fm credentials were incorrect")); + QString dialog_text = tr("Your Last.fm credentials were incorrect"); + if (!message.isEmpty()) { + dialog_text = message; + } + QMessageBox::warning(this, tr("Authentication failed"), dialog_text); } RefreshControls(success); diff --git a/src/internet/lastfmsettingspage.h b/src/internet/lastfmsettingspage.h index 00c701b21..30bbb604f 100644 --- a/src/internet/lastfmsettingspage.h +++ b/src/internet/lastfmsettingspage.h @@ -35,7 +35,7 @@ public: private slots: void Login(); - void AuthenticationComplete(bool success); + void AuthenticationComplete(bool success, const QString& error_message); void Logout(); void UpdatedSubscriberStatus(bool is_subscriber);