mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-01 11:56:45 +01:00
Detect last.fm login failures properly. Fixes issue 3426
This commit is contained in:
parent
a652e34506
commit
f92cbb24ba
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user