aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/General/scrobbler/defines.h4
-rw-r--r--src/plugins/General/scrobbler/scrobblerhandler.cpp2
-rw-r--r--src/plugins/General/scrobbler/settingsdialog.cpp69
-rw-r--r--src/plugins/General/scrobbler/settingsdialog.h5
-rw-r--r--src/plugins/General/scrobbler/settingsdialog.ui80
5 files changed, 137 insertions, 23 deletions
diff --git a/src/plugins/General/scrobbler/defines.h b/src/plugins/General/scrobbler/defines.h
index 3b7ae5f14..ac8877eb5 100644
--- a/src/plugins/General/scrobbler/defines.h
+++ b/src/plugins/General/scrobbler/defines.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2013-2015 by Ilya Kotov *
+ * Copyright (C) 2013-2018 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -23,8 +23,10 @@
#define SCROBBLER_LASTFM_URL "http://ws.audioscrobbler.com/2.0/"
#define SCROBBLER_LIBREFM_URL "https://libre.fm/2.0/"
+#define SCROBBLER_LISTENBRAINZ_URL "https://api.listenbrainz.org/2.0/"
#define LASTFM_AUTH_URL "http://www.last.fm/api/auth/"
#define LIBREFM_AUTH_URL "https://libre.fm/api/auth/"
+#define LISTENBRAINZ_AUTH_URL "https://listenbrainz.org/api/auth/"
#endif // DEFINES_H
diff --git a/src/plugins/General/scrobbler/scrobblerhandler.cpp b/src/plugins/General/scrobbler/scrobblerhandler.cpp
index 469feced6..921cbf9c9 100644
--- a/src/plugins/General/scrobbler/scrobblerhandler.cpp
+++ b/src/plugins/General/scrobbler/scrobblerhandler.cpp
@@ -31,6 +31,8 @@ ScrobblerHandler::ScrobblerHandler(QObject *parent) : QObject(parent)
new Scrobbler(SCROBBLER_LASTFM_URL, "lastfm", this);
if(settings.value("use_librefm", false).toBool())
new Scrobbler(SCROBBLER_LIBREFM_URL, "librefm", this);
+ if(settings.value("use_listenbrainz", false).toBool())
+ new Scrobbler(SCROBBLER_LISTENBRAINZ_URL, "listenbrainz", this);
settings.endGroup();
}
diff --git a/src/plugins/General/scrobbler/settingsdialog.cpp b/src/plugins/General/scrobbler/settingsdialog.cpp
index e78ff7073..9dea8c77b 100644
--- a/src/plugins/General/scrobbler/settingsdialog.cpp
+++ b/src/plugins/General/scrobbler/settingsdialog.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2013 by Ilya Kotov *
+ * Copyright (C) 2008-2018 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -30,19 +30,25 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
m_ui.setupUi(this);
m_lastfmAuth = new ScrobblerAuth(SCROBBLER_LASTFM_URL, LASTFM_AUTH_URL, "lastfm", this);
m_librefmAuth = new ScrobblerAuth(SCROBBLER_LIBREFM_URL, LIBREFM_AUTH_URL, "librefm", this);
+ m_listenbrainzAuth = new ScrobblerAuth(SCROBBLER_LISTENBRAINZ_URL, LISTENBRAINZ_AUTH_URL, "listenbrainz", 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)));
connect(m_librefmAuth, SIGNAL(tokenRequestFinished(int)), SLOT(processTokenResponse(int)));
connect(m_librefmAuth, SIGNAL(sessionRequestFinished(int)), SLOT(processSessionResponse(int)));
connect(m_librefmAuth, SIGNAL(checkSessionFinished(int)), SLOT(processCheckResponse(int)));
+ connect(m_listenbrainzAuth, SIGNAL(tokenRequestFinished(int)), SLOT(processTokenResponse(int)));
+ connect(m_listenbrainzAuth, SIGNAL(sessionRequestFinished(int)), SLOT(processSessionResponse(int)));
+ connect(m_listenbrainzAuth, 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());
m_ui.librefmGroupBox->setChecked(settings.value("use_librefm", false).toBool());
+ m_ui.listenbrainzGroupBox->setChecked(settings.value("use_listenbrainz", false).toBool());
m_ui.sessionLineEdit_lastfm->setText(settings.value("lastfm_session").toString());
m_ui.sessionLineEdit_librefm->setText(settings.value("librefm_session").toString());
+ m_ui.sessionLineEdit_listenbrainz->setText(settings.value("listenbrainz_session").toString());
settings.endGroup();
}
@@ -55,8 +61,10 @@ void SettingsDialog::accept()
settings.beginGroup("Scrobbler");
settings.setValue("use_lastfm", m_ui.lastfmGroupBox->isChecked());
settings.setValue("use_librefm", m_ui.librefmGroupBox->isChecked());
+ settings.setValue("use_listenbrainz", m_ui.listenbrainzGroupBox->isChecked());
settings.setValue("lastfm_session",m_ui.sessionLineEdit_lastfm->text());
settings.setValue("librefm_session",m_ui.sessionLineEdit_librefm->text());
+ settings.setValue("listenbrainz_session",m_ui.sessionLineEdit_listenbrainz->text());
settings.endGroup();
QDialog::accept();
}
@@ -73,31 +81,54 @@ void SettingsDialog::on_newSessionButton_librefm_clicked()
m_librefmAuth->getToken();
}
+void SettingsDialog::on_newSessionButton_listenbrainz_clicked()
+{
+ m_ui.newSessionButton_listenbrainz->setEnabled(false);
+ m_listenbrainzAuth->getToken();
+}
+
void SettingsDialog::processTokenResponse(int error)
{
if(sender() == m_lastfmAuth)
m_ui.newSessionButton_lastfm->setEnabled(true);
else if(sender() == m_librefmAuth)
m_ui.newSessionButton_librefm->setEnabled(true);
+ else if(sender() == m_listenbrainzAuth)
+ m_ui.newSessionButton_listenbrainz->setEnabled(true);
switch(error)
{
case ScrobblerAuth::NO_ERROR:
- QMessageBox::information(this,
- tr("Message"),
- tr("1. Wait for browser startup") + "\n" +
- tr("2. Allow Qmmp to scrobble tracks to your %1 account")
- .arg((sender() == m_lastfmAuth) ? "Last.fm" : "Libre.fm") + "\n" +
- tr("3. Press \"OK\""));
- if(sender() == m_lastfmAuth)
+ {
+ ScrobblerAuth *auth = qobject_cast<ScrobblerAuth *>(sender());
+ QString name;
+
+ if(auth == m_lastfmAuth)
{
m_ui.newSessionButton_lastfm->setEnabled(false);
- m_lastfmAuth->getSession();
+ name = QLatin1String("Last.fm");
}
- else if(sender() == m_librefmAuth)
+ else if(auth == m_librefmAuth)
{
m_ui.newSessionButton_librefm->setEnabled(false);
- m_librefmAuth->getSession();
+ name = QLatin1String("Libre.fm");
+ }
+ else if(auth == m_listenbrainzAuth)
+ {
+ m_ui.newSessionButton_listenbrainz->setEnabled(false);
+ name = QLatin1String("ListenBrainz");
+ }
+ else
+ {
+ qWarning("SettingsDialog: invalid sender");
+ return;
}
+
+ QMessageBox::information(this, tr("Message"),
+ tr("1. Wait for browser startup") + "\n" +
+ tr("2. Allow Qmmp to scrobble tracks to your %1 account").arg(name) + "\n" +
+ tr("3. Press \"OK\""));
+ auth->getSession();
+ }
break;
case ScrobblerAuth::NETWORK_ERROR:
QMessageBox::warning(this, tr("Error"), tr("Network error"));
@@ -130,6 +161,11 @@ void SettingsDialog::processSessionResponse(int error)
m_ui.sessionLineEdit_librefm->setText(m_librefmAuth->session());
settings.setValue("Scrobbler/librefm_session",m_ui.sessionLineEdit_librefm->text());
}
+ else if(sender() == m_listenbrainzAuth)
+ {
+ m_ui.sessionLineEdit_listenbrainz->setText(m_listenbrainzAuth->session());
+ settings.setValue("Scrobbler/listenbrainz_session",m_ui.sessionLineEdit_listenbrainz->text());
+ }
break;
}
case ScrobblerAuth::NETWORK_ERROR:
@@ -159,6 +195,15 @@ void SettingsDialog::on_checkButton_librefm_clicked()
}
}
+void SettingsDialog::on_checkButton_listenbrainz_clicked()
+{
+ if(!m_ui.sessionLineEdit_listenbrainz->text().isEmpty())
+ {
+ m_ui.checkButton_listenbrainz->setEnabled(false);
+ m_listenbrainzAuth->checkSession(m_ui.sessionLineEdit_listenbrainz->text());
+ }
+}
+
void SettingsDialog::processCheckResponse(int error)
{
if(sender() == m_lastfmAuth)
@@ -174,6 +219,8 @@ void SettingsDialog::processCheckResponse(int error)
m_ui.sessionLineEdit_lastfm->setText(m_lastfmAuth->session());
else if(sender() == m_librefmAuth)
m_ui.sessionLineEdit_librefm->setText(m_librefmAuth->session());
+ else if(sender() == m_listenbrainzAuth)
+ m_ui.sessionLineEdit_listenbrainz->setText(m_listenbrainzAuth->session());
break;
}
case ScrobblerAuth::NETWORK_ERROR:
diff --git a/src/plugins/General/scrobbler/settingsdialog.h b/src/plugins/General/scrobbler/settingsdialog.h
index 884b90e36..953bc330f 100644
--- a/src/plugins/General/scrobbler/settingsdialog.h
+++ b/src/plugins/General/scrobbler/settingsdialog.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2013 by Ilya Kotov *
+ * Copyright (C) 2008-2018 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -42,16 +42,19 @@ public slots:
private slots:
void on_newSessionButton_lastfm_clicked();
void on_newSessionButton_librefm_clicked();
+ void on_newSessionButton_listenbrainz_clicked();
void processTokenResponse(int error);
void processSessionResponse(int error);
void on_checkButton_lastfm_clicked();
void on_checkButton_librefm_clicked();
+ void on_checkButton_listenbrainz_clicked();
void processCheckResponse(int error);
private:
Ui::SettingsDialog m_ui;
ScrobblerAuth *m_lastfmAuth;
ScrobblerAuth *m_librefmAuth;
+ ScrobblerAuth *m_listenbrainzAuth;
};
diff --git a/src/plugins/General/scrobbler/settingsdialog.ui b/src/plugins/General/scrobbler/settingsdialog.ui
index a4798f07b..3d3ab4f2f 100644
--- a/src/plugins/General/scrobbler/settingsdialog.ui
+++ b/src/plugins/General/scrobbler/settingsdialog.ui
@@ -7,22 +7,13 @@
<x>0</x>
<y>0</y>
<width>376</width>
- <height>255</height>
+ <height>362</height>
</rect>
</property>
<property name="windowTitle">
<string>Scrobbler Plugin Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
- <property name="leftMargin">
- <number>6</number>
- </property>
- <property name="rightMargin">
- <number>6</number>
- </property>
- <property name="bottomMargin">
- <number>6</number>
- </property>
<item>
<widget class="QGroupBox" name="lastfmGroupBox">
<property name="title">
@@ -133,6 +124,75 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="listenbrainzGroupBox">
+ <property name="title">
+ <string>ListenBrainz</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="1" column="0">
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>189</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="newSessionButton_listenbrainz">
+ <property name="text">
+ <string>Register new session</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="2">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Session:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="sessionLineEdit_listenbrainz"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="checkButton_listenbrainz">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Check</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>