/thirdparty/liblastfm2/src/scrobble/Audioscrobbler.h

http://github.com/tomahawk-player/tomahawk · C Header · 78 lines · 35 code · 10 blank · 33 comment · 0 complexity · 3ae8a2de032c38cf19a28dbb96d6b35f MD5 · raw file

  1. /*
  2. Copyright 2009 Last.fm Ltd.
  3. - Primarily authored by Max Howell, Jono Cole and Doug Mansell
  4. This file is part of liblastfm.
  5. liblastfm is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. liblastfm is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with liblastfm. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef LASTFM_AUDIOSCROBBLER_H
  17. #define LASTFM_AUDIOSCROBBLER_H
  18. #include <lastfm/global.h>
  19. #include <QByteArray>
  20. #include <QList>
  21. #include <QString>
  22. #include <QObject>
  23. #include <QVariant>
  24. namespace lastfm
  25. {
  26. /** @author Max Howell <max@last.fm>
  27. * An implementation of the Audioscrobbler Realtime Submissions Protocol
  28. * version 1.2.1 for a single Last.fm user
  29. * http://www.audioscrobbler.net/development/protocol/
  30. */
  31. class LASTFM_DLLEXPORT Audioscrobbler : public QObject
  32. {
  33. Q_OBJECT
  34. public:
  35. /** You will need to do QCoreApplication::setVersion and
  36. * QCoreApplication::setApplicationName for this to work, also you will
  37. * need to have set all the keys in the Ws namespace in WsKeys.h */
  38. Audioscrobbler( const QString& clientId );
  39. ~Audioscrobbler();
  40. signals:
  41. void scrobblesCached( const QList<lastfm::Track>& tracks );
  42. /* Note that this is emitted after we tried to submit the scrobbles
  43. It could just be that they have an error code */
  44. void scrobblesSubmitted( const QList<lastfm::Track>& tracks );
  45. void nowPlayingError( int code, QString message );
  46. public slots:
  47. /** will ask Last.fm to update the now playing information for the
  48. * authenticated user */
  49. void nowPlaying( const Track& );
  50. /** will cache the track and call submit() */
  51. void cache( const Track& );
  52. void cacheBatch( const QList<lastfm::Track>& );
  53. /** will submit the submission cache for this user */
  54. void submit();
  55. private slots:
  56. void onNowPlayingReturn();
  57. void onTrackScrobbleReturn();
  58. private:
  59. void parseTrack( const XmlQuery& trackXml, const Track& track );
  60. private:
  61. class AudioscrobblerPrivate* d;
  62. };
  63. }
  64. #endif