aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-11-17 10:01:52 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2013-11-17 10:01:52 +0000
commit324c79580e119ea8e3c5f9beed732458a1ceb5b3 (patch)
treee67b4de2ef4634265b3d23486fba2e0940676e2f
parent0e8697935a0fc97f7658fe7b0360118c0e516198 (diff)
downloadqmmp-324c79580e119ea8e3c5f9beed732458a1ceb5b3.tar.gz
qmmp-324c79580e119ea8e3c5f9beed732458a1ceb5b3.tar.bz2
qmmp-324c79580e119ea8e3c5f9beed732458a1ceb5b3.zip
moved libre.fm scrobbler to 2.0 api
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3913 90c681e8-e032-0410-971d-27865f9a5e38
-rw-r--r--src/plugins/General/scrobbler/defines.h (renamed from src/plugins/General/scrobbler/librefmscrobbler.h)67
-rw-r--r--src/plugins/General/scrobbler/librefmscrobbler.cpp374
-rw-r--r--src/plugins/General/scrobbler/scrobbler.cpp (renamed from src/plugins/General/scrobbler/lastfmscrobbler.cpp)115
-rw-r--r--src/plugins/General/scrobbler/scrobbler.h (renamed from src/plugins/General/scrobbler/lastfmscrobbler.h)21
-rw-r--r--src/plugins/General/scrobbler/scrobbler.pro11
-rw-r--r--src/plugins/General/scrobbler/scrobblerhandler.cpp16
-rw-r--r--src/plugins/General/scrobbler/settingsdialog.cpp101
-rw-r--r--src/plugins/General/scrobbler/settingsdialog.h7
-rw-r--r--src/plugins/General/scrobbler/settingsdialog.ui88
9 files changed, 214 insertions, 586 deletions
diff --git a/src/plugins/General/scrobbler/librefmscrobbler.h b/src/plugins/General/scrobbler/defines.h
index ece5ecec1..36648fe4f 100644
--- a/src/plugins/General/scrobbler/librefmscrobbler.h
+++ b/src/plugins/General/scrobbler/defines.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2013 by Ilya Kotov *
+ * Copyright (C) 2013 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -17,65 +17,14 @@
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#ifndef LIBREFMSCROBBLER_H
-#define LIBREFMSCROBBLER_H
-#include <QMap>
-#include <QObject>
-#include <qmmp/qmmp.h>
-#include "scrobblercache.h"
+#ifndef DEFINES_H
+#define DEFINES_H
-class QNetworkAccessManager;
-class QNetworkReply;
-class QTime;
-class SoundCore;
+#define SCROBBLER_LASTFM_URL "http://ws.audioscrobbler.com/2.0/"
+#define SCROBBLER_LIBREFM_URL "http://libre.fm/2.0/"
-/**
- @author Ilya Kotov <forkotov02@hotmail.ru>
-*/
-class LibrefmScrobbler : public QObject
-{
- Q_OBJECT
-public:
- LibrefmScrobbler(const QString &login, const QString &passw, QObject *parent = 0);
+#define LASTFM_AUTH_URL "http://www.last.fm/api/auth/"
+#define LIBREFM_AUTH_URL "http://libre.fm/api/auth/"
- ~LibrefmScrobbler();
-
-private slots:
- void setState(Qmmp::State state);
- void updateMetaData();
- void processResponse(QNetworkReply *reply);
- void setupProxy();
- void handshake();
-
-private:
- enum { MIN_SONG_LENGTH = 30 };
-
- void submit();
- void sendNotification(const SongInfo &info);
- bool isReady();
-
- uint m_start_ts;
- SongInfo m_song;
- QString m_login;
- QString m_passw;
- QString m_submitUrl;
- QString m_nowPlayingUrl;
- QString m_session;
- QList <SongInfo> m_cachedSongs;
- QByteArray m_ua;
- int m_submitedSongs;
- int m_failure_count;
- int m_handshake_count;
- bool m_disabled;
- QNetworkAccessManager *m_http;
- SoundCore *m_core;
- QNetworkReply *m_handshakeReply;
- QNetworkReply *m_submitReply;
- QNetworkReply *m_notificationReply;
- QTime* m_time;
- ScrobblerCache *m_cache;
-
-};
-
-#endif
+#endif // DEFINES_H
diff --git a/src/plugins/General/scrobbler/librefmscrobbler.cpp b/src/plugins/General/scrobbler/librefmscrobbler.cpp
deleted file mode 100644
index 97bdf7d69..000000000
--- a/src/plugins/General/scrobbler/librefmscrobbler.cpp
+++ /dev/null
@@ -1,374 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2008-2013 by Ilya Kotov *
- * forkotov02@hotmail.ru *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
- ***************************************************************************/
-
-#include <QMenu>
-#include <QNetworkAccessManager>
-#include <QNetworkRequest>
-#include <QNetworkProxy>
-#include <QNetworkReply>
-#include <QByteArray>
-#include <QCryptographicHash>
-#include <QUrl>
-#include <QTime>
-#include <QTimer>
-#include <QDateTime>
-#include <QDir>
-#include <qmmp/soundcore.h>
-#include <qmmp/qmmpsettings.h>
-#include <qmmp/qmmp.h>
-#include "librefmscrobbler.h"
-
-#define PROTOCOL_VER "1.2.1"
-#define CLIENT_ID "qmm"
-#define CLIENT_VER "0.7"
-#define SCROBBLER_LIBREFM_URL "http://turtle.libre.fm/"
-
-
-LibrefmScrobbler::LibrefmScrobbler(const QString &login, const QString &passw, QObject *parent)
- : QObject(parent)
-{
- m_failure_count = 0;
- m_handshake_count = 0;
- m_submitedSongs = 0;
- m_handshakeReply = 0;
- m_submitReply = 0;
- m_notificationReply = 0;
- m_ua = QString("iScrobbler/1.5.1qmmp-plugins/%1").arg(Qmmp::strVersion()).toAscii();
- m_login = login;
- m_passw = passw;
- m_passw = QString(QCryptographicHash::hash(m_passw.toAscii(), QCryptographicHash::Md5).toHex());
- m_disabled = login.isEmpty() || passw.isEmpty();
- m_core = SoundCore::instance();
- m_cache = new ScrobblerCache(QDir::homePath() +"/.qmmp/scrobbler_librefm.cache");
- m_http = new QNetworkAccessManager(this);
- m_time = new QTime();
-
- connect(m_http, SIGNAL(finished (QNetworkReply *)), SLOT(processResponse(QNetworkReply *)));
- connect(QmmpSettings::instance(), SIGNAL(networkSettingsChanged()), SLOT(setupProxy()));
- connect (m_core, SIGNAL(metaDataChanged()), SLOT(updateMetaData()));
- connect (m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(setState(Qmmp::State)));
-
- setupProxy();
- m_cachedSongs = m_cache->load();
-
- m_start_ts = QDateTime::currentDateTime().toTime_t();
- handshake();
-}
-
-
-LibrefmScrobbler::~LibrefmScrobbler()
-{
- m_cache->save(m_cachedSongs);
- delete m_time;
- delete m_cache;
-}
-
-void LibrefmScrobbler::setState(Qmmp::State state)
-{
- static Qmmp::State previousState = state;
- static int elapsed = 0;
- switch ((uint) state)
- {
- case Qmmp::Playing:
- if (previousState != Qmmp::Paused)
- {
- m_start_ts = QDateTime::currentDateTime().toTime_t();
- elapsed = 0;
- }
- else
- {
- qDebug("LibrefmScrobbler: resuming from %d seconds played", elapsed / 1000);
- }
- m_time->restart();
- if (!isReady() && !m_handshakeReply)
- handshake();
- break;
- case Qmmp::Stopped:
- if (previousState != Qmmp::Paused)
- elapsed += m_time->elapsed();
- if (!m_song.metaData().isEmpty()
- && ((elapsed/1000 > 240) || (elapsed/1000 > int(m_song.length()/2)))
- && (m_song.length() > MIN_SONG_LENGTH))
- {
- m_song.setTimeStamp(m_start_ts);
- m_cachedSongs << m_song;
- m_cache->save(m_cachedSongs);
- }
- m_song.clear();
- if (m_cachedSongs.isEmpty())
- break;
-
- if (isReady() && !m_submitReply)
- submit();
- break;
- case Qmmp::Paused:
- elapsed += m_time->elapsed();
- qDebug("LibrefmScrobbler: pausing after %d seconds played", elapsed / 1000);
- break;
- default:
- ;
- }
- previousState = state;
-}
-
-void LibrefmScrobbler::updateMetaData()
-{
- QMap <Qmmp::MetaData, QString> metadata = m_core->metaData();
- if (m_core->state() == Qmmp::Playing
- && !metadata.value(Qmmp::TITLE).isEmpty() //skip empty tags
- && !metadata.value(Qmmp::ARTIST).isEmpty()
- && m_core->totalTime() >= 0) //skip stream
- {
- metadata[Qmmp::ARTIST].replace("%", QUrl::toPercentEncoding("%")); //replace special symbols
- metadata[Qmmp::ALBUM].replace("%", QUrl::toPercentEncoding("%"));
- metadata[Qmmp::TITLE].replace("%", QUrl::toPercentEncoding("%"));
- metadata[Qmmp::ARTIST].replace("&", QUrl::toPercentEncoding("&"));
- metadata[Qmmp::ALBUM].replace("&", QUrl::toPercentEncoding("&"));
- metadata[Qmmp::TITLE].replace("&", QUrl::toPercentEncoding("&"));
- metadata[Qmmp::ARTIST].replace("=", QUrl::toPercentEncoding("="));
- metadata[Qmmp::ALBUM].replace("=", QUrl::toPercentEncoding("="));
- metadata[Qmmp::TITLE].replace("=", QUrl::toPercentEncoding("="));
- m_song = SongInfo(metadata, m_core->totalTime()/1000);
- if (isReady() && !m_notificationReply && !m_submitReply)
- sendNotification(m_song);
- }
-}
-
-void LibrefmScrobbler::processResponse(QNetworkReply *reply)
-{
- QString data;
- if (reply->error() == QNetworkReply::NoError)
- data = reply->readAll();
- else
- data = reply->errorString ();
-
- data = data.trimmed();
- if (data.startsWith("OK"))
- {
- m_failure_count = 0;
- m_handshake_count = 0;
- }
-
- if (reply == m_handshakeReply)
- {
- m_handshakeReply = 0;
- m_submitUrl.clear();
- m_session.clear();
- m_nowPlayingUrl.clear();
- m_failure_count = 0;
- QStringList strlist = data.split("\n");
- if (!strlist[0].contains("OK") || strlist.size() < 4)
- {
- qWarning("LibrefmScrobbler: handshake phase error");
- m_disabled = true;
- if(strlist[0].contains("BANNED"))
- qWarning("LibrefmScrobbler: client has been banned");
- else if(strlist[0].contains("BADAUTH"))
- qWarning("LibrefmScrobbler: incorrect user/password");
- else if(strlist[0].contains("BADTIME"))
- qWarning("LibrefmScrobbler: incorrect system time");
- else
- {
- qWarning("LibrefmScrobbler: service error: %s", qPrintable(strlist[0]));
- m_disabled = false;
- m_handshake_count++;
- QTimer::singleShot (60000 * qMin(m_handshake_count^2, 120) , this, SLOT(handshake()));
- qWarning("LibrefmScrobbler: waiting %d minutes...", qMin(m_handshake_count^2, 120));
- }
- }
- else if (strlist.size() > 3) //process handshake response
- {
- qDebug("LibrefmScrobbler: reading handshake response");
- qDebug("LibrefmScrobbler: Session ID: %s", qPrintable(strlist[1]));
- qDebug("LibrefmScrobbler: Now-Playing URL: %s", qPrintable(strlist[2]));
- qDebug("LibrefmScrobbler: Submission URL: %s", qPrintable(strlist[3]));
- m_submitUrl = strlist[3];
- m_nowPlayingUrl = strlist[2];
- m_session = strlist[1];
- updateMetaData(); //send now-playing notification for already playing song
- if (!m_cachedSongs.isEmpty()) //submit recent songs
- submit();
- }
- }
- else if (reply == m_submitReply)
- {
- m_submitReply = 0;
- if (!data.startsWith("OK"))
- {
- qWarning("LibrefmScrobbler: submit error");
- if(data.contains("BADSESSION"))
- {
- qWarning("LibrefmScrobbler: invalid session ID");
- qWarning("LibrefmScrobbler: performing re-handshake");
- handshake();
- }
- else
- {
- qWarning("LibrefmScrobbler: %s", qPrintable(data));
- m_failure_count ++;
- }
- }
- else
- {
- qDebug("LibrefmScrobbler: submited %d song(s)", m_submitedSongs);
- while (m_submitedSongs)
- {
- m_submitedSongs--;
- m_cachedSongs.removeFirst ();
- }
- if (!m_cachedSongs.isEmpty()) //submit remaining songs
- submit();
- else
- updateMetaData();
- }
- }
- else if (reply == m_notificationReply)
- {
- m_notificationReply = 0;
- if (!data.startsWith("OK"))
- {
- qWarning("LibrefmScrobbler: notification error");
- if(data.contains("BADSESSION"))
- {
- qWarning("LibrefmScrobbler: invalid session ID");
- qWarning("LibrefmScrobbler: performing re-handshake");
- handshake();
- }
- else
- {
- qWarning("LibrefmScrobbler: %s",qPrintable(data));
- m_failure_count ++;
- }
- }
- else
- qDebug("LibrefmScrobbler: Now-Playing notification done");
- }
- if(m_failure_count >= 3)
- {
- qWarning("LibrefmScrobbler: performing re-handshake");
- handshake();
- }
- reply->deleteLater();
-}
-
-void LibrefmScrobbler::setupProxy()
-{
- QmmpSettings *gs = QmmpSettings::instance();
- if (gs->isProxyEnabled())
- {
- QNetworkProxy proxy(QNetworkProxy::HttpProxy, gs->proxy().host(), gs->proxy().port());
- if(gs->useProxyAuth())
- {
- proxy.setUser(gs->proxy().userName());
- proxy.setPassword(gs->proxy().password());
- }
- m_http->setProxy(proxy);
- }
- else
- m_http->setProxy(QNetworkProxy::NoProxy);
-}
-
-void LibrefmScrobbler::handshake()
-{
- if (m_disabled)
- return;
- qDebug("LibrefmScrobbler: handshake request");
- uint ts = QDateTime::currentDateTime().toTime_t();
- qDebug("LibrefmScrobbler: current time stamp %d",ts);
- QString auth_tmp = QString("%1%2").arg(m_passw).arg(ts);
- QByteArray auth = QCryptographicHash::hash(auth_tmp.toAscii (), QCryptographicHash::Md5);
- auth = auth.toHex();
- QUrl url(QString(SCROBBLER_LIBREFM_URL) + "?");
- url.addQueryItem("hs", "true");
- url.addQueryItem("p", PROTOCOL_VER);
- url.addQueryItem("c", CLIENT_ID);
- url.addQueryItem("v", CLIENT_VER);
- url.addQueryItem("u", m_login);
- url.addQueryItem("t", QString::number(ts));
- url.addQueryItem("a", QString(auth));
- url.setPort(80);
- qDebug("LibrefmScrobbler: request url: %s",qPrintable(url.toString()));
- QNetworkRequest request(url);
- request.setRawHeader("User-Agent", m_ua);
- request.setRawHeader("Host",url.host().toAscii());
- request.setRawHeader("Accept", "*/*");
- m_handshakeReply = m_http->get(request);
-}
-
-void LibrefmScrobbler::submit()
-{
- qDebug("LibrefmScrobbler: submit request");
- if (m_cachedSongs.isEmpty())
- return;
- m_submitedSongs = qMin(m_cachedSongs.size(),25);
- QString body = QString("s=%1").arg(m_session);
- for (int i = 0; i < m_submitedSongs; ++i)
- {
- SongInfo info = m_cachedSongs[i];
- body += QString("&a[%9]=%1&t[%9]=%2&i[%9]=%3&o[%9]=%4&r[%9]=%5&l[%9]=%6&b[%9]=%7&n[%9]=%8&m[%9]=")
- .arg(info.metaData(Qmmp::ARTIST))
- .arg(info.metaData(Qmmp::TITLE))
- .arg(info.timeStamp())
- .arg("P")
- .arg("")
- .arg(info.length())
- .arg(info.metaData(Qmmp::ALBUM))
- .arg(info.metaData(Qmmp::TRACK))
- .arg(i);
- }
- //qDebug("%s",qPrintable(body));
- QUrl url(m_submitUrl);
- url.setPort(80);
- QNetworkRequest request(url);
- request.setRawHeader("User-Agent", m_ua);
- request.setRawHeader("Host",url.host().toAscii());
- request.setRawHeader("Accept", "*/*");
- request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
- request.setHeader(QNetworkRequest::ContentLengthHeader,
- QUrl::toPercentEncoding(body,":/[]&=%").size());
- m_submitReply = m_http->post(request, QUrl::toPercentEncoding(body,":/[]&=%"));
-}
-
-void LibrefmScrobbler::sendNotification(const SongInfo &info)
-{
- qDebug("LibrefmScrobbler: sending notification");
- QString body = QString("s=%1").arg(m_session);
- body += QString("&a=%1&t=%2&b=%3&l=%4&n=%5&m=")
- .arg(info.metaData(Qmmp::ARTIST))
- .arg(info.metaData(Qmmp::TITLE))
- .arg(info.metaData(Qmmp::ALBUM))
- .arg(info.length())
- .arg(info.metaData(Qmmp::TRACK));
- QUrl url(m_nowPlayingUrl);
- url.setPort(80);
- QNetworkRequest request(url);
- request.setRawHeader("User-Agent", m_ua);
- request.setRawHeader("Host", url.host().toAscii());
- request.setRawHeader("Accept", "*/*");
- request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
- request.setHeader(QNetworkRequest::ContentLengthHeader,
- QUrl::toPercentEncoding(body,":/[]&=%").size());
- m_notificationReply = m_http->post(request, QUrl::toPercentEncoding(body,":/[]&=%"));
-}
-
-bool LibrefmScrobbler::isReady()
-{
- return !m_submitUrl.isEmpty() && !m_session.isEmpty();
-}
diff --git a/src/plugins/General/scrobbler/lastfmscrobbler.cpp b/src/plugins/General/scrobbler/scrobbler.cpp
index c3f25cd5e..526912593 100644
--- a/src/plugins/General/scrobbler/lastfmscrobbler.cpp
+++ b/src/plugins/General/scrobbler/scrobbler.cpp
@@ -35,14 +35,12 @@
#include <qmmp/soundcore.h>
#include <qmmp/qmmpsettings.h>
#include <qmmp/qmmp.h>
-#include "lastfmscrobbler.h"
+#include "scrobbler.h"
-#define SCROBBLER_LASTFM_URL "http://ws.audioscrobbler.com/2.0/"
#define API_KEY "d71c6f01b2ea562d7042bd5f5970041f"
#define SECRET "32d47bc0010473d40e1d38bdcff20968"
-
-void LastfmResponse::parse(QIODevice *device)
+void ScrobblerResponse::parse(QIODevice *device)
{
QXmlStreamReader reader(device);
QStringList tags;
@@ -80,19 +78,22 @@ void LastfmResponse::parse(QIODevice *device)
}
}
-LastfmScrobbler::LastfmScrobbler(QObject *parent) : QObject(parent)
+Scrobbler::Scrobbler(const QString &scrobblerUrl, const QString &name, QObject *parent)
+ : QObject(parent)
{
m_notificationReply = 0;
m_submitedSongs = 0;
m_submitReply = 0;
+ m_scrobblerUrl = scrobblerUrl;
+ m_name = name;
m_state = Qmmp::Stopped;
m_time = new QTime();
- m_cache = new ScrobblerCache(QDir::homePath() +"/.qmmp/scrobbler_lastfm.cache");
+ m_cache = new ScrobblerCache(QDir::homePath() +"/.qmmp/scrobbler_"+name+".cache");
m_ua = QString("qmmp-plugins/%1").arg(Qmmp::strVersion().toLower()).toAscii();
m_http = new QNetworkAccessManager(this);
m_core = SoundCore::instance();
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
- m_session = settings.value("Scrobbler/lastfm_session").toString();
+ m_session = settings.value("Scrobbler/"+name+"_session").toString();
connect(m_http, SIGNAL(finished (QNetworkReply *)), SLOT(processResponse(QNetworkReply *)));
connect(QmmpSettings::instance(), SIGNAL(networkSettingsChanged()), SLOT(setupProxy()));
@@ -113,7 +114,7 @@ LastfmScrobbler::LastfmScrobbler(QObject *parent) : QObject(parent)
}
}
-LastfmScrobbler::~LastfmScrobbler()
+Scrobbler::~Scrobbler()
{
m_cache->save(m_cachedSongs);
delete m_time;
@@ -121,7 +122,7 @@ LastfmScrobbler::~LastfmScrobbler()
}
-void LastfmScrobbler::setState(Qmmp::State state)
+void Scrobbler::setState(Qmmp::State state)
{
static Qmmp::State previousState = state;
static int elapsed = 0;
@@ -131,13 +132,13 @@ void LastfmScrobbler::setState(Qmmp::State state)
case Qmmp::Playing:
if (previousState != Qmmp::Paused)
{
- qDebug("LastfmScrobbler: new song started");
+ qDebug("Scrobbler[%s]: new song started", qPrintable(m_name));
m_start_ts = QDateTime::currentDateTime().toTime_t();
elapsed = 0;
}
else
{
- qDebug("LastfmScrobbler: resuming from %d seconds played", elapsed / 1000);
+ qDebug("Scrobbler[%s]: resuming from %d seconds played", qPrintable(m_name), elapsed / 1000);
}
m_time->restart();
break;
@@ -162,7 +163,7 @@ void LastfmScrobbler::setState(Qmmp::State state)
break;
case Qmmp::Paused:
elapsed += m_time->elapsed();
- qDebug("LastfmScrobbler: pausing after %d seconds played", elapsed / 1000);
+ qDebug("Scrobbler[%s]: pausing after %d seconds played", qPrintable(m_name), elapsed / 1000);
break;
default:
;
@@ -170,7 +171,7 @@ void LastfmScrobbler::setState(Qmmp::State state)
previousState = state;
}
-void LastfmScrobbler::updateMetaData()
+void Scrobbler::updateMetaData()
{
QMap <Qmmp::MetaData, QString> metadata = m_core->metaData();
if(m_state != Qmmp::Playing || m_core->totalTime() <= 0) //skip stream
@@ -184,14 +185,14 @@ void LastfmScrobbler::updateMetaData()
sendNotification(m_song);
}
-void LastfmScrobbler::processResponse(QNetworkReply *reply)
+void Scrobbler::processResponse(QNetworkReply *reply)
{
if (reply->error() != QNetworkReply::NoError)
{
- qWarning("LastfmScrobbler: http error: %s", qPrintable(reply->errorString()));
+ qWarning("Scrobbler[%s]: http error: %s", qPrintable(m_name), qPrintable(reply->errorString()));
}
- LastfmResponse response;
+ ScrobblerResponse response;
response.parse(reply);
QString error_code;
@@ -199,12 +200,12 @@ void LastfmScrobbler::processResponse(QNetworkReply *reply)
{
if(!response.error.isEmpty())
{
- qWarning("LastfmScrobbler: status=%s, %s-%s", qPrintable(response.status),
+ qWarning("Scrobbler[%s]: status=%s, %s-%s", qPrintable(m_name), qPrintable(response.status),
qPrintable(response.code), qPrintable(response.error));
error_code = response.code;
}
else
- qWarning("LastfmScrobbler: invalid content");
+ qWarning("Scrobbler[%s]: invalid content", qPrintable(m_name));
}
if (reply == m_submitReply)
@@ -212,7 +213,7 @@ void LastfmScrobbler::processResponse(QNetworkReply *reply)
m_submitReply = 0;
if (response.status == "ok")
{
- qDebug("LastfmScrobbler: submited %d song(s)", m_submitedSongs);
+ qDebug("Scrobbler[%s]: submited %d song(s)", qPrintable(m_name), m_submitedSongs);
while (m_submitedSongs)
{
m_submitedSongs--;
@@ -231,7 +232,7 @@ void LastfmScrobbler::processResponse(QNetworkReply *reply)
else if(error_code == "9") //invalid session key
{
m_session.clear();
- qWarning("LastfmScrobbler: invalid session key, scrobbling disabled");
+ qWarning("Scrobbler[%s]: invalid session key, scrobbling disabled", qPrintable(m_name));
}
else if(error_code == "11" || error_code == "16" || error_code.isEmpty()) //unavailable
{
@@ -240,7 +241,8 @@ void LastfmScrobbler::processResponse(QNetworkReply *reply)
else
{
m_session.clear();
- qWarning("LastfmScrobbler: service returned unrecoverable error, scrobbling disabled");
+ qWarning("Scrobbler[%s]: service returned unrecoverable error, scrobbling disabled",
+ qPrintable(m_name));
}
}
else if (reply == m_notificationReply)
@@ -248,18 +250,18 @@ void LastfmScrobbler::processResponse(QNetworkReply *reply)
m_notificationReply = 0;
if(response.status == "ok")
{
- qDebug("LastfmScrobbler: Now-Playing notification done");
+ qDebug("Scrobbler[%s]: Now-Playing notification done", qPrintable(m_name));
}
else if(error_code == "9") //invalid session key
{
m_session.clear();
- qWarning("LastfmScrobbler: invalid session key, scrobbling disabled");
+ qWarning("Scrobbler[%s]: invalid session key, scrobbling disabled", qPrintable(m_name));
}
}
reply->deleteLater();
}
-void LastfmScrobbler::setupProxy()
+void Scrobbler::setupProxy()
{
QmmpSettings *gs = QmmpSettings::instance();
if (gs->isProxyEnabled())
@@ -276,12 +278,12 @@ void LastfmScrobbler::setupProxy()
m_http->setProxy(QNetworkProxy::NoProxy);
}
-void LastfmScrobbler::submit()
+void Scrobbler::submit()
{
if (m_cachedSongs.isEmpty() || m_session.isEmpty() || m_submitReply)
return;
- qDebug("LastfmScrobbler: submit request");
+ qDebug("Scrobbler[%s]: submit request", qPrintable(m_name));
m_submitedSongs = qMin(m_cachedSongs.size(),25);
QMap <QString, QString> params;
@@ -306,7 +308,7 @@ void LastfmScrobbler::submit()
params.remove(key);
}
- QUrl url(SCROBBLER_LASTFM_URL);
+ QUrl url(m_scrobblerUrl);
url.setPort(80);
QUrl body("");
@@ -330,11 +332,11 @@ void LastfmScrobbler::submit()
m_submitReply = m_http->post(request, bodyData);
}
-void LastfmScrobbler::sendNotification(const SongInfo &info)
+void Scrobbler::sendNotification(const SongInfo &info)
{
if(m_session.isEmpty())
return;
- qDebug("LastfmScrobbler: sending notification");
+ qDebug("Scrobbler[%s]: sending notification", qPrintable(m_name));
QMap <QString, QString> params;
params.insert("track", info.metaData(Qmmp::TITLE));
@@ -354,7 +356,7 @@ void LastfmScrobbler::sendNotification(const SongInfo &info)
params.remove(key);
}
- QUrl url(SCROBBLER_LASTFM_URL);
+ QUrl url(m_scrobblerUrl);
url.setPort(80);
QUrl body("");
@@ -378,10 +380,14 @@ void LastfmScrobbler::sendNotification(const SongInfo &info)
m_notificationReply = m_http->post(request, bodyData);
}
-LastfmAuth::LastfmAuth(QObject *parent) : QObject(parent)
+ScrobblerAuth::ScrobblerAuth(const QString &scrobblerUrl, const QString &authUrl,
+ const QString &name, QObject *parent) : QObject(parent)
{
m_getTokenReply = 0;
m_getSessionReply = 0;
+ m_scrobblerUrl = scrobblerUrl;
+ m_authUrl = authUrl;
+ m_name = name;
m_ua = QString("qmmp-plugins/%1").arg(Qmmp::strVersion().toLower()).toAscii();
m_http = new QNetworkAccessManager(this);
connect(m_http, SIGNAL(finished (QNetworkReply *)), SLOT(processResponse(QNetworkReply *)));
@@ -401,11 +407,11 @@ LastfmAuth::LastfmAuth(QObject *parent) : QObject(parent)
m_http->setProxy(QNetworkProxy::NoProxy);
}
-void LastfmAuth::getToken()
+void ScrobblerAuth::getToken()
{
- qDebug("LastfmAuth: new token request");
+ qDebug("ScrobblerAuth[%s]: new token request", qPrintable(m_name));
m_session.clear();
- QUrl url(QString(SCROBBLER_LASTFM_URL) + "?");
+ QUrl url(m_scrobblerUrl + "?");
url.setPort(80);
url.addQueryItem("method", "auth.getToken");
url.addQueryItem("api_key", API_KEY);
@@ -423,10 +429,10 @@ void LastfmAuth::getToken()
m_getTokenReply = m_http->get(request);
}
-void LastfmAuth::getSession()
+void ScrobblerAuth::getSession()
{
- qDebug("LastfmAuth: new session request");
- QUrl url(QString(SCROBBLER_LASTFM_URL) + "?");
+ qDebug("ScrobblerAuth[%s]: new session request", qPrintable(m_name));
+ QUrl url(m_scrobblerUrl + "?");
url.setPort(80);
url.addQueryItem("api_key", API_KEY);
url.addQueryItem("method", "auth.getSession");
@@ -446,9 +452,9 @@ void LastfmAuth::getSession()
m_getSessionReply = m_http->get(request);
}
-void LastfmAuth::checkSession(const QString &session)
+void ScrobblerAuth::checkSession(const QString &session)
{
- qDebug("LastfmAuth: checking session...");
+ qDebug("ScrobblerAuth[%s]: checking session...", qPrintable(m_name));
m_session = session;
QMap <QString, QString> params;
params.insert("api_key", API_KEY);
@@ -456,7 +462,7 @@ void LastfmAuth::checkSession(const QString &session)
params.insert("method", "user.getRecommendedArtists");
params.insert("limit", "1");
- QUrl url(SCROBBLER_LASTFM_URL);
+ QUrl url(m_scrobblerUrl);
url.setPort(80);
QUrl body("");
@@ -480,19 +486,19 @@ void LastfmAuth::checkSession(const QString &session)
m_checkSessionReply = m_http->post(request, bodyData);
}
-QString LastfmAuth::session() const
+QString ScrobblerAuth::session() const
{
return m_session;
}
-void LastfmAuth::processResponse(QNetworkReply *reply)
+void ScrobblerAuth::processResponse(QNetworkReply *reply)
{
if (reply->error() != QNetworkReply::NoError)
{
- qWarning("LastfmAuth: http error: %s", qPrintable(reply->errorString()));
+ qWarning("ScrobblerAuth[%s]: http error: %s", qPrintable(m_name), qPrintable(reply->errorString()));
}
- LastfmResponse response;
+ ScrobblerResponse response;
response.parse(reply);
QString error_code;
@@ -500,12 +506,12 @@ void LastfmAuth::processResponse(QNetworkReply *reply)
{
if(!response.error.isEmpty())
{
- qWarning("LastfmAuth: status=%s, %s-%s", qPrintable(response.status),
+ qWarning("ScrobblerAuth[%s]: status=%s, %s-%s", qPrintable(m_name), qPrintable(response.status),
qPrintable(response.code), qPrintable(response.error));
error_code = response.code;
}
else
- qWarning("LastfmAuth: invalid content");
+ qWarning("ScrobblerAuth[%s]: invalid content", qPrintable(m_name));
}
if (reply == m_getTokenReply)
@@ -514,8 +520,8 @@ void LastfmAuth::processResponse(QNetworkReply *reply)
if(response.status == "ok")
{
m_token = response.token;
- qDebug("LastfmAuth: token: %s", qPrintable(m_token));
- QDesktopServices::openUrl("http://www.last.fm/api/auth/?api_key="API_KEY"&token="+m_token);
+ qDebug("ScrobblerAuth[%s]: token: %s", qPrintable(m_name), qPrintable(m_token));
+ QDesktopServices::openUrl(m_authUrl + "?api_key="API_KEY"&token="+m_token);
emit(tokenRequestFinished(NO_ERROR));
}
else if(error_code.isEmpty())
@@ -541,9 +547,9 @@ void LastfmAuth::processResponse(QNetworkReply *reply)
if(response.status == "ok")
{
m_session = response.key;
- qDebug("LastfmAuth: name: %s", qPrintable(response.name));
- qDebug("LastfmAuth: key: %s", qPrintable(m_session));
- qDebug("LastfmAuth: subscriber: %s", qPrintable(response.subscriber));
+ qDebug("ScrobblerAuth[%s]: name: %s", qPrintable(m_name), qPrintable(response.name));
+ qDebug("ScrobblerAuth[%s]: key: %s", qPrintable(m_name), qPrintable(m_session));
+ qDebug("ScrobblerAuth[%s]: subscriber: %s", qPrintable(m_name), qPrintable(response.subscriber));
emit sessionRequestFinished(NO_ERROR);
}
else if(error_code == "4" || error_code == "15") //invalid token
@@ -577,17 +583,18 @@ void LastfmAuth::processResponse(QNetworkReply *reply)
m_checkSessionReply = 0;
if(response.status == "ok")
{
- qDebug("LastfmAuth: session ok");
+ qDebug("ScrobblerAuth[%s]: session ok", qPrintable(m_name));
emit checkSessionFinished(NO_ERROR);
}
else if(error_code.isEmpty())
{
- qWarning("LastfmAuth: network error");
+ qWarning("ScrobblerAuth[%s]: network error", qPrintable(m_name));
emit checkSessionFinished(NETWORK_ERROR);
}
else
{
- qWarning("LastfmAuth: received last.fm error (code=%s)", qPrintable(error_code));
+ qWarning("ScrobblerAuth[%s]: received last.fm error (code=%s)",
+ qPrintable(m_name), qPrintable(error_code));
emit checkSessionFinished(LASTFM_ERROR);
}
}
diff --git a/src/plugins/General/scrobbler/lastfmscrobbler.h b/src/plugins/General/scrobbler/scrobbler.h
index c9385670e..db0e086ad 100644
--- a/src/plugins/General/scrobbler/lastfmscrobbler.h
+++ b/src/plugins/General/scrobbler/scrobbler.h
@@ -17,8 +17,8 @@
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#ifndef LASTFMSCROBBLER_H
-#define LASTFMSCROBBLER_H
+#ifndef SCROBBLER_H
+#define SCROBBLER_H
#include <QMap>
#include <QObject>
@@ -35,7 +35,7 @@ class SoundCore;
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
*/
-class LastfmResponse
+class ScrobblerResponse
{
public:
QString status;
@@ -52,12 +52,12 @@ public:
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
*/
-class LastfmScrobbler : public QObject
+class Scrobbler : public QObject
{
Q_OBJECT
public:
- LastfmScrobbler(QObject *parent = 0);
- ~LastfmScrobbler();
+ Scrobbler(const QString &scrobblerUrl, const QString &name,QObject *parent = 0);
+ ~Scrobbler();
private slots:
void setState(Qmmp::State state);
@@ -82,16 +82,18 @@ private:
QNetworkReply *m_submitReply, *m_notificationReply;
QTime *m_time;
ScrobblerCache *m_cache;
+ QString m_scrobblerUrl, m_name;
};
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
*/
-class LastfmAuth : public QObject
+class ScrobblerAuth : public QObject
{
Q_OBJECT
public:
- explicit LastfmAuth(QObject *parent = 0);
+ explicit ScrobblerAuth(const QString &scrobblerUrl, const QString &authUrl,
+ const QString &name, QObject *parent = 0);
void getToken();
void getSession();
void checkSession(const QString &session);
@@ -117,6 +119,7 @@ private:
QByteArray m_ua;
QNetworkAccessManager *m_http;
QNetworkReply *m_getTokenReply, *m_getSessionReply, *m_checkSessionReply;
+ QString m_scrobblerUrl, m_authUrl, m_name;
};
-#endif
+#endif //SCROBBLER_H
diff --git a/src/plugins/General/scrobbler/scrobbler.pro b/src/plugins/General/scrobbler/scrobbler.pro
index f40b90333..a73954b06 100644
--- a/src/plugins/General/scrobbler/scrobbler.pro
+++ b/src/plugins/General/scrobbler/scrobbler.pro
@@ -29,16 +29,15 @@ unix {
HEADERS += scrobblerfactory.h \
settingsdialog.h \
scrobblerhandler.h \
- lastfmscrobbler.h \
- librefmscrobbler.h \
- scrobblercache.h
+ scrobblercache.h \
+ scrobbler.h \
+ defines.h
win32:HEADERS += ../../../../src/qmmpui/general.h
SOURCES += scrobblerfactory.cpp \
settingsdialog.cpp \
scrobblerhandler.cpp \
- lastfmscrobbler.cpp \
- librefmscrobbler.cpp \
- scrobblercache.cpp
+ scrobblercache.cpp \
+ scrobbler.cpp
QT += network
INCLUDEPATH += ../../../
unix:LIBS += -lqmmpui \
diff --git a/src/plugins/General/scrobbler/scrobblerhandler.cpp b/src/plugins/General/scrobbler/scrobblerhandler.cpp
index 17f375f01..176f8f26e 100644
--- a/src/plugins/General/scrobbler/scrobblerhandler.cpp
+++ b/src/plugins/General/scrobbler/scrobblerhandler.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009-2012 by Ilya Kotov *
+ * Copyright (C) 2009-2013 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -19,8 +19,8 @@
***************************************************************************/
#include <QSettings>
-#include "lastfmscrobbler.h"
-#include "librefmscrobbler.h"
+#include "scrobbler.h"
+#include "defines.h"
#include "scrobblerhandler.h"
ScrobblerHandler::ScrobblerHandler(QObject *parent) : QObject(parent)
@@ -28,15 +28,9 @@ ScrobblerHandler::ScrobblerHandler(QObject *parent) : QObject(parent)
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
settings.beginGroup("Scrobbler");
if(settings.value("use_lastfm", false).toBool())
- {
- new LastfmScrobbler(this);
- }
+ new Scrobbler(SCROBBLER_LASTFM_URL, "lastfm", this);
if(settings.value("use_librefm", false).toBool())
- {
- new LibrefmScrobbler(settings.value("librefm_login").toString(),
- settings.value("librefm_password").toString(), this);
-
- }
+ new Scrobbler(SCROBBLER_LIBREFM_URL, "librefm", this);
settings.endGroup();
}
diff --git a/src/plugins/General/scrobbler/settingsdialog.cpp b/src/plugins/General/scrobbler/settingsdialog.cpp
index dad403c5f..6e3db8e50 100644
--- a/src/plugins/General/scrobbler/settingsdialog.cpp
+++ b/src/plugins/General/scrobbler/settingsdialog.cpp
@@ -21,23 +21,28 @@
#include <QSettings>
#include <QMessageBox>
#include <qmmp/qmmp.h>
-#include "lastfmscrobbler.h"
+#include "scrobbler.h"
+#include "defines.h"
#include "settingsdialog.h"
SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
{
m_ui.setupUi(this);
- m_lastfmAuth = new LastfmAuth(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);
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)));
+
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
settings.beginGroup("Scrobbler");
m_ui.lastfmGroupBox->setChecked(settings.value("use_lastfm", false).toBool());
- m_ui.sessionLineEdit_lastfm->setText(settings.value("lastfm_session").toString());
m_ui.librefmGroupBox->setChecked(settings.value("use_librefm", false).toBool());
- m_ui.userLineEdit_libre->setText(settings.value("librefm_login").toString());
- m_ui.passwordLineEdit_libre->setText(settings.value("librefm_password").toString());
+ m_ui.sessionLineEdit_lastfm->setText(settings.value("lastfm_session").toString());
+ m_ui.sessionLineEdit_librefm->setText(settings.value("librefm_session").toString());
settings.endGroup();
}
@@ -49,10 +54,9 @@ void SettingsDialog::accept()
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
settings.beginGroup("Scrobbler");
settings.setValue("use_lastfm", m_ui.lastfmGroupBox->isChecked());
- settings.setValue("lastfm_session",m_ui.sessionLineEdit_lastfm->text());
settings.setValue("use_librefm", m_ui.librefmGroupBox->isChecked());
- settings.setValue("librefm_login",m_ui.userLineEdit_libre->text());
- settings.setValue("librefm_password", m_ui.passwordLineEdit_libre->text());
+ settings.setValue("lastfm_session",m_ui.sessionLineEdit_lastfm->text());
+ settings.setValue("librefm_session",m_ui.sessionLineEdit_librefm->text());
settings.endGroup();
QDialog::accept();
}
@@ -63,24 +67,42 @@ void SettingsDialog::on_newSessionButton_lastfm_clicked()
m_lastfmAuth->getToken();
}
+void SettingsDialog::on_newSessionButton_librefm_clicked()
+{
+ m_ui.newSessionButton_librefm->setEnabled(false);
+ m_librefmAuth->getToken();
+}
+
void SettingsDialog::processTokenResponse(int error)
{
- m_ui.newSessionButton_lastfm->setEnabled(true);
+ if(sender() == m_lastfmAuth)
+ m_ui.newSessionButton_lastfm->setEnabled(true);
+ else if(sender() == m_librefmAuth)
+ m_ui.newSessionButton_librefm->setEnabled(true);
switch(error)
{
- case LastfmAuth::NO_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 Last.fm account") + "\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\""));
- m_ui.newSessionButton_lastfm->setEnabled(false);
- m_lastfmAuth->getSession();
+ if(sender() == m_lastfmAuth)
+ {
+ m_ui.newSessionButton_lastfm->setEnabled(false);
+ m_lastfmAuth->getSession();
+ }
+ else if(sender() == m_librefmAuth)
+ {
+ m_ui.newSessionButton_librefm->setEnabled(false);
+ m_librefmAuth->getSession();
+ }
break;
- case LastfmAuth::NETWORK_ERROR:
+ case ScrobblerAuth::NETWORK_ERROR:
QMessageBox::warning(this, tr("Error"), tr("Network error"));
break;
- case LastfmAuth::LASTFM_ERROR:
+ case ScrobblerAuth::LASTFM_ERROR:
default:
QMessageBox::warning(this, tr("Error"), tr("Unable to register new session"));
}
@@ -88,22 +110,32 @@ void SettingsDialog::processTokenResponse(int error)
void SettingsDialog::processSessionResponse(int error)
{
- m_ui.newSessionButton_lastfm->setEnabled(true);
+ if(sender() == m_lastfmAuth)
+ m_ui.newSessionButton_lastfm->setEnabled(true);
+ else if(sender() == m_librefmAuth)
+ m_ui.newSessionButton_librefm->setEnabled(true);
switch(error)
{
- case LastfmAuth::NO_ERROR:
+ case ScrobblerAuth::NO_ERROR:
{
QMessageBox::information(this, tr("Message"), tr("New session has been received successfully"));
- m_ui.sessionLineEdit_lastfm->setText(m_lastfmAuth->session());
-
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
- settings.setValue("Scrobbler/lastfm_session",m_ui.sessionLineEdit_lastfm->text());
+ if(sender() == m_lastfmAuth)
+ {
+ m_ui.sessionLineEdit_lastfm->setText(m_lastfmAuth->session());
+ settings.setValue("Scrobbler/lastfm_session",m_ui.sessionLineEdit_lastfm->text());
+ }
+ else if(sender() == m_librefmAuth)
+ {
+ m_ui.sessionLineEdit_librefm->setText(m_librefmAuth->session());
+ settings.setValue("Scrobbler/librefm_session",m_ui.sessionLineEdit_librefm->text());
+ }
break;
}
- case LastfmAuth::NETWORK_ERROR:
+ case ScrobblerAuth::NETWORK_ERROR:
QMessageBox::warning(this, tr("Error"), tr("Network error"));
break;
- case LastfmAuth::LASTFM_ERROR:
+ case ScrobblerAuth::LASTFM_ERROR:
default:
QMessageBox::warning(this, tr("Error"), tr("Unable to register new session"));
}
@@ -118,21 +150,36 @@ void SettingsDialog::on_checkButton_lastfm_clicked()
}
}
+void SettingsDialog::on_checkButton_librefm_clicked()
+{
+ if(!m_ui.sessionLineEdit_librefm->text().isEmpty())
+ {
+ m_ui.checkButton_librefm->setEnabled(false);
+ m_librefmAuth->checkSession(m_ui.sessionLineEdit_librefm->text());
+ }
+}
+
void SettingsDialog::processCheckResponse(int error)
{
- m_ui.checkButton_lastfm->setEnabled(true);
+ if(sender() == m_lastfmAuth)
+ m_ui.checkButton_lastfm->setEnabled(true);
+ else if(sender() == m_librefmAuth)
+ m_ui.checkButton_librefm->setEnabled(true);
switch(error)
{
- case LastfmAuth::NO_ERROR:
+ case ScrobblerAuth::NO_ERROR:
{
QMessageBox::information(this, tr("Message"), tr("Permission granted"));
- m_ui.sessionLineEdit_lastfm->setText(m_lastfmAuth->session());
+ if(sender() == m_lastfmAuth)
+ m_ui.sessionLineEdit_lastfm->setText(m_lastfmAuth->session());
+ else if(sender() == m_librefmAuth)
+ m_ui.sessionLineEdit_librefm->setText(m_librefmAuth->session());
break;
}
- case LastfmAuth::NETWORK_ERROR:
+ case ScrobblerAuth::NETWORK_ERROR:
QMessageBox::warning(this, tr("Error"), tr("Network error"));
break;
- case LastfmAuth::LASTFM_ERROR:
+ case ScrobblerAuth::LASTFM_ERROR:
default:
QMessageBox::warning(this, tr("Error"), tr("Permission denied"));
}
diff --git a/src/plugins/General/scrobbler/settingsdialog.h b/src/plugins/General/scrobbler/settingsdialog.h
index 41f81c73a..999efaaf0 100644
--- a/src/plugins/General/scrobbler/settingsdialog.h
+++ b/src/plugins/General/scrobbler/settingsdialog.h
@@ -23,7 +23,7 @@
#include <QDialog>
#include "ui_settingsdialog.h"
-class LastfmAuth;
+class ScrobblerAuth;
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
@@ -41,14 +41,17 @@ public slots:
private slots:
void on_newSessionButton_lastfm_clicked();
+ void on_newSessionButton_librefm_clicked();
void processTokenResponse(int error);
void processSessionResponse(int error);
void on_checkButton_lastfm_clicked();
+ void on_checkButton_librefm_clicked();
void processCheckResponse(int error);
private:
Ui::SettingsDialog m_ui;
- LastfmAuth *m_lastfmAuth;
+ ScrobblerAuth *m_lastfmAuth;
+ ScrobblerAuth *m_librefmAuth;
};
diff --git a/src/plugins/General/scrobbler/settingsdialog.ui b/src/plugins/General/scrobbler/settingsdialog.ui
index dd111a948..a4798f07b 100644
--- a/src/plugins/General/scrobbler/settingsdialog.ui
+++ b/src/plugins/General/scrobbler/settingsdialog.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>337</width>
- <height>227</height>
+ <width>376</width>
+ <height>255</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,9 +17,6 @@
<property name="leftMargin">
<number>6</number>
</property>
- <property name="topMargin">
- <number>9</number>
- </property>
<property name="rightMargin">
<number>6</number>
</property>
@@ -88,56 +85,59 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>User name:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="userLineEdit_libre"/>
- </item>
<item row="1" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Password:</string>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- </widget>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>189</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
</item>
<item row="1" column="1">
- <widget class="QLineEdit" name="passwordLineEdit_libre">
- <property name="echoMode">
- <enum>QLineEdit::Password</enum>
+ <widget class="QPushButton" name="newSessionButton_librefm">
+ <property name="text">
+ <string>Register new session</string>
</property>
</widget>
</item>
+ <item row="0" column="0" colspan="2">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Session:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="sessionLineEdit_librefm"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="checkButton_librefm">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Check</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>136</width>
- <height>18</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
</item>
</layout>
</widget>