diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-02-25 15:52:10 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-02-25 15:52:10 +0000 |
| commit | bb5260ff7fc4a1a99654b39687b9d9feaeb9e958 (patch) | |
| tree | 218c14eaca61ea5330571b36d408c2a41e01f4aa | |
| parent | 246adbc50e73574d9f188b33fff1f5b35b743829 (diff) | |
| download | qmmp-bb5260ff7fc4a1a99654b39687b9d9feaeb9e958.tar.gz qmmp-bb5260ff7fc4a1a99654b39687b9d9feaeb9e958.tar.bz2 qmmp-bb5260ff7fc4a1a99654b39687b9d9feaeb9e958.zip | |
scrobbler: fixed cache lost
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1582 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/plugins/General/scrobbler/scrobbler.cpp | 46 | ||||
| -rw-r--r-- | src/plugins/General/scrobbler/scrobbler.h | 3 |
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 |
