PageRenderTime 142ms CodeModel.GetById 80ms app.highlight 4ms RepoModel.GetById 57ms app.codeStats 0ms

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