aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/General')
-rw-r--r--src/plugins/General/scrobbler/scrobbler.cpp46
-rw-r--r--src/plugins/General/scrobbler/scrobbler.h3
2 files changed, 27 insertions, 22 deletions
diff --git a/src/plugins/General/scrobbler/scrobbler.cpp b/src/plugins/General/scrobbler/scrobbler.cpp
index c9357bfcb..090c3e2f1 100644
--- a/src/plugins/General/scrobbler/scrobbler.cpp
+++ b/src/plugins/General/scrobbler/scrobbler.cpp
@@ -118,26 +118,7 @@ Scrobbler::Scrobbler(const QString &url,
Scrobbler::~Scrobbler()
{
delete m_time;
- QFile file(QDir::homePath() +"/.qmmp/scrobbler_" + m_name + ".cache");
- if (m_songCache.isEmpty())
- {
- file.remove();
- return;
- }
- file.open(QIODevice::WriteOnly);
- foreach(SongInfo m, m_songCache)
- {
- file.write(QString("title=%1").arg(m.metaData(Qmmp::TITLE)).toUtf8() +"\n");
- file.write(QString("artist=%1").arg(m.metaData(Qmmp::ARTIST)).toUtf8() +"\n");
- file.write(QString("album=%1").arg(m.metaData(Qmmp::ALBUM)).toUtf8() +"\n");
- file.write(QString("comment=%1").arg(m.metaData(Qmmp::COMMENT)).toUtf8() +"\n");
- file.write(QString("genre=%1").arg(m.metaData(Qmmp::GENRE)).toUtf8() +"\n");
- file.write(QString("year=%1").arg(m.metaData(Qmmp::YEAR)).toUtf8() +"\n");
- file.write(QString("track=%1").arg(m.metaData(Qmmp::TRACK)).toUtf8() +"\n");
- file.write(QString("length=%1").arg(m.length()).toUtf8() +"\n");
- file.write(QString("time=%1").arg(m.timeStamp()).toUtf8() +"\n");
- }
- file.close();
+ syncCache();
}
void Scrobbler::setState(Qmmp::State state)
@@ -158,6 +139,7 @@ void Scrobbler::setState(Qmmp::State state)
{
m_song.setTimeStamp(m_start_ts);
m_songCache << m_song;
+ syncCache();
}
m_song.clear();
@@ -413,6 +395,30 @@ bool Scrobbler::isReady()
return !m_submitUrl.isEmpty() && !m_session.isEmpty();
}
+void Scrobbler::syncCache()
+{
+ QFile file(QDir::homePath() +"/.qmmp/scrobbler_" + m_name + ".cache");
+ if (m_songCache.isEmpty())
+ {
+ file.remove();
+ return;
+ }
+ file.open(QIODevice::WriteOnly);
+ foreach(SongInfo m, m_songCache)
+ {
+ file.write(QString("title=%1").arg(m.metaData(Qmmp::TITLE)).toUtf8() +"\n");
+ file.write(QString("artist=%1").arg(m.metaData(Qmmp::ARTIST)).toUtf8() +"\n");
+ file.write(QString("album=%1").arg(m.metaData(Qmmp::ALBUM)).toUtf8() +"\n");
+ file.write(QString("comment=%1").arg(m.metaData(Qmmp::COMMENT)).toUtf8() +"\n");
+ file.write(QString("genre=%1").arg(m.metaData(Qmmp::GENRE)).toUtf8() +"\n");
+ file.write(QString("year=%1").arg(m.metaData(Qmmp::YEAR)).toUtf8() +"\n");
+ file.write(QString("track=%1").arg(m.metaData(Qmmp::TRACK)).toUtf8() +"\n");
+ file.write(QString("length=%1").arg(m.length()).toUtf8() +"\n");
+ file.write(QString("time=%1").arg(m.timeStamp()).toUtf8() +"\n");
+ }
+ file.close();
+}
+
SongInfo::SongInfo()
{
m_length = 0;
diff --git a/src/plugins/General/scrobbler/scrobbler.h b/src/plugins/General/scrobbler/scrobbler.h
index 44c5592ce..0e733321d 100644
--- a/src/plugins/General/scrobbler/scrobbler.h
+++ b/src/plugins/General/scrobbler/scrobbler.h
@@ -26,7 +26,6 @@
class QNetworkAccessManager;
class QNetworkReply;
class QTime;
-class QTimer;
class SoundCore;
/**
@@ -86,6 +85,7 @@ private:
void submit();
void sendNotification(const SongInfo &info);
bool isReady();
+ void syncCache();
uint m_start_ts;
SongInfo m_song;
QNetworkAccessManager *m_http;
@@ -107,7 +107,6 @@ private:
QNetworkReply *m_notificationReply;
bool m_disabled;
QString m_server, m_name;
- QTimer *m_timer;
};
#endif