diff options
Diffstat (limited to 'src/plugins/General/scrobbler')
| -rw-r--r-- | src/plugins/General/scrobbler/scrobbler.cpp | 31 | ||||
| -rw-r--r-- | src/plugins/General/scrobbler/scrobbler.h | 2 | ||||
| -rw-r--r-- | src/plugins/General/scrobbler/scrobblercache.cpp | 15 | ||||
| -rw-r--r-- | src/plugins/General/scrobbler/scrobblercache.h | 2 |
4 files changed, 23 insertions, 27 deletions
diff --git a/src/plugins/General/scrobbler/scrobbler.cpp b/src/plugins/General/scrobbler/scrobbler.cpp index 61c60cdff..88faf050c 100644 --- a/src/plugins/General/scrobbler/scrobbler.cpp +++ b/src/plugins/General/scrobbler/scrobbler.cpp @@ -79,15 +79,16 @@ void ScrobblerResponse::parse(QIODevice *device) } Scrobbler::Scrobbler(const QString &scrobblerUrl, const QString &name, QObject *parent) - : QObject(parent) + : QObject(parent), + m_ua(QString("qmmp-plugins/%1").arg(Qmmp::strVersion().toLower()).toLatin1()), + m_http(new QNetworkAccessManager(this)), + m_core(SoundCore::instance()), + m_time(new QElapsedTimer()), + m_cache(new ListenCache(Qmmp::configDir() + "/scrobbler_" + name + ".cache")), + m_scrobblerUrl(scrobblerUrl), + m_name(name) { - m_scrobblerUrl = scrobblerUrl; - m_name = name; - m_time = new QElapsedTimer(); - m_cache = new ListenCache(Qmmp::configDir() +"/scrobbler_"+name+".cache"); - m_ua = QString("qmmp-plugins/%1").arg(Qmmp::strVersion().toLower()).toLatin1(); - m_http = new QNetworkAccessManager(this); - m_core = SoundCore::instance(); + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); m_session = settings.value("Scrobbler/"+name+"_session").toString(); @@ -380,15 +381,13 @@ void Scrobbler::sendNotification(const SongInfo &info) } ScrobblerAuth::ScrobblerAuth(const QString &scrobblerUrl, const QString &authUrl, - const QString &name, QObject *parent) : QObject(parent) + const QString &name, QObject *parent) : QObject(parent), + m_ua(QString("qmmp-plugins/%1").arg(Qmmp::strVersion().toLower()).toLatin1()), + m_http(new QNetworkAccessManager(this)), + m_scrobblerUrl(scrobblerUrl), + m_authUrl(authUrl), + m_name(name) { - m_getTokenReply = nullptr; - m_getSessionReply = nullptr; - m_scrobblerUrl = scrobblerUrl; - m_authUrl = authUrl; - m_name = name; - m_ua = QString("qmmp-plugins/%1").arg(Qmmp::strVersion().toLower()).toLatin1(); - m_http = new QNetworkAccessManager(this); connect(m_http, SIGNAL(finished (QNetworkReply *)), SLOT(processResponse(QNetworkReply *))); QmmpSettings *gs = QmmpSettings::instance(); diff --git a/src/plugins/General/scrobbler/scrobbler.h b/src/plugins/General/scrobbler/scrobbler.h index b4f727424..29c40233c 100644 --- a/src/plugins/General/scrobbler/scrobbler.h +++ b/src/plugins/General/scrobbler/scrobbler.h @@ -118,7 +118,7 @@ private: QString m_token, m_session; QByteArray m_ua; QNetworkAccessManager *m_http; - QNetworkReply *m_getTokenReply, *m_getSessionReply, *m_checkSessionReply; + QNetworkReply *m_getTokenReply = nullptr, *m_getSessionReply = nullptr, *m_checkSessionReply = nullptr; QString m_scrobblerUrl, m_authUrl, m_name; }; diff --git a/src/plugins/General/scrobbler/scrobblercache.cpp b/src/plugins/General/scrobbler/scrobblercache.cpp index f9ed95ed8..df405a51d 100644 --- a/src/plugins/General/scrobbler/scrobblercache.cpp +++ b/src/plugins/General/scrobbler/scrobblercache.cpp @@ -61,16 +61,12 @@ uint SongInfo::timeStamp() const return m_start_ts; } -ListenCache::ListenCache(const QString &filePath) -{ - m_filePath = filePath; -} +ListenCache::ListenCache(const QString &filePath) : m_filePath(filePath) +{} QList<SongInfo> ListenCache::load() { QList<SongInfo> songs; - int s = 0; - QString line, param, value; QFile file(m_filePath); if(!file.open(QIODevice::ReadOnly)) @@ -78,12 +74,13 @@ QList<SongInfo> ListenCache::load() while (!file.atEnd()) { - line = QString::fromUtf8(file.readLine()).trimmed(); + int s; + QString line = QString::fromUtf8(file.readLine()).trimmed(); if ((s = line.indexOf("=")) < 0) continue; - param = line.left(s); - value = line.right(line.size() - s - 1); + QString param = line.left(s); + QString value = line.right(line.size() - s - 1); if (param == "title") { diff --git a/src/plugins/General/scrobbler/scrobblercache.h b/src/plugins/General/scrobbler/scrobblercache.h index 1c16968b4..c267f2d4f 100644 --- a/src/plugins/General/scrobbler/scrobblercache.h +++ b/src/plugins/General/scrobbler/scrobblercache.h @@ -31,7 +31,7 @@ class SongInfo : public TrackInfo { public: SongInfo(); - SongInfo(const TrackInfo &info); + explicit SongInfo(const TrackInfo &info); SongInfo(const SongInfo &other); ~SongInfo(); |
