From ab030aa3915a48a7590a194bd680157958be4d54 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Tue, 29 Jan 2013 17:07:27 +0000 Subject: lastfm scrobbler: enabled 'check session' button git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3194 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/scrobbler/settingsdialog.cpp | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/plugins/General/scrobbler/settingsdialog.cpp') diff --git a/src/plugins/General/scrobbler/settingsdialog.cpp b/src/plugins/General/scrobbler/settingsdialog.cpp index 29ff3b8b5..c5ca85cc7 100644 --- a/src/plugins/General/scrobbler/settingsdialog.cpp +++ b/src/plugins/General/scrobbler/settingsdialog.cpp @@ -30,6 +30,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent) m_lastfmAuth = new LastfmAuth(this); connect(m_lastfmAuth, SIGNAL(tokenRequestFinished(int)), SLOT(processTokenResponse(int))); connect(m_lastfmAuth, SIGNAL(sessionRequestFinished(int)), SLOT(processSessionResponse(int))); + connect(m_lastfmAuth, SIGNAL(checkSessionFinished(int)), SLOT(processCheckResponse(int))); QSettings settings(Qmmp::configFile(), QSettings::IniFormat); settings.beginGroup("Scrobbler"); m_ui.lastfmGroupBox->setChecked(settings.value("use_lastfm", false).toBool()); @@ -58,11 +59,13 @@ void SettingsDialog::accept() void SettingsDialog::on_newSessionButton_lastfm_clicked() { + m_ui.newSessionButton_lastfm->setEnabled(false); m_lastfmAuth->getToken(); } void SettingsDialog::processTokenResponse(int error) { + m_ui.newSessionButton_lastfm->setEnabled(true); switch(error) { case LastfmAuth::NO_ERROR: @@ -71,6 +74,7 @@ void SettingsDialog::processTokenResponse(int error) tr("1. Wait for browser startup.") + "\n" + tr("2. Allow Qmmp to scrobble tracks to your Last.fm account.") + "\n" + tr("3. Press \"OK\".")); + m_ui.newSessionButton_lastfm->setEnabled(false); m_lastfmAuth->getSession(); break; case LastfmAuth::NETWORK_ERROR: @@ -84,6 +88,7 @@ void SettingsDialog::processTokenResponse(int error) void SettingsDialog::processSessionResponse(int error) { + m_ui.newSessionButton_lastfm->setEnabled(true); switch(error) { case LastfmAuth::NO_ERROR: @@ -103,3 +108,32 @@ void SettingsDialog::processSessionResponse(int error) QMessageBox::warning(this, tr("Error"), tr("Unable to register new session.")); } } + +void SettingsDialog::on_checkButton_lastfm_clicked() +{ + if(!m_ui.sessionLineEdit_lastfm->text().isEmpty()) + { + m_ui.checkButton_lastfm->setEnabled(false); + m_lastfmAuth->checkSession(m_ui.sessionLineEdit_lastfm->text()); + } +} + +void SettingsDialog::processCheckResponse(int error) +{ + m_ui.checkButton_lastfm->setEnabled(true); + switch(error) + { + case LastfmAuth::NO_ERROR: + { + QMessageBox::information(this, tr("Message"), tr("Permission granted.")); + m_ui.sessionLineEdit_lastfm->setText(m_lastfmAuth->session()); + break; + } + case LastfmAuth::NETWORK_ERROR: + QMessageBox::warning(this, tr("Error"), tr("Network error.")); + break; + case LastfmAuth::LASTFM_ERROR: + default: + QMessageBox::warning(this, tr("Error"), tr("Permission denied.")); + } +} -- cgit v1.2.3-13-gbd6f