PageRenderTime 87ms CodeModel.GetById 27ms app.highlight 12ms RepoModel.GetById 32ms app.codeStats 0ms

/src/libtomahawk/utils/SpotifyParser.h

http://github.com/tomahawk-player/tomahawk
C Header | 103 lines | 58 code | 18 blank | 27 comment | 0 complexity | 9da52baf5b93ef130123263310e4cb1d MD5 | raw file
  1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2 *
  3 *   Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
  4 *   Copyright 2010-2011, Hugo Lindström <hugolm84@gmail.com>
  5 *
  6 *   Tomahawk is free software: you can redistribute it and/or modify
  7 *   it under the terms of the GNU General Public License as published by
  8 *   the Free Software Foundation, either version 3 of the License, or
  9 *   (at your option) any later version.
 10 *
 11 *   Tomahawk is distributed in the hope that it will be useful,
 12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 14 *   GNU General Public License for more details.
 15 *
 16 *   You should have received a copy of the GNU General Public License
 17 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 18 */
 19
 20#ifndef SPOTIFY_PARSER_H
 21#define SPOTIFY_PARSER_H
 22
 23#include "DllMacro.h"
 24#include "Typedefs.h"
 25#include "Query.h"
 26#include "jobview/JobStatusItem.h"
 27//#include "accounts/spotify/SpotifyPlaylistUpdater.h"
 28#include "accounts/spotify/SpotifyAccount.h"
 29#include <QObject>
 30#include <QSet>
 31#include <QtCore/QStringList>
 32
 33#define SPOTIFY_PLAYLIST_API_URL "http://spotikea.tomahawk-player.org"
 34
 35/**
 36 * Small class to parse spotify links into query_ptrs
 37 *
 38 * Connect to the signals to get the results
 39 */
 40
 41class NetworkReply;
 42class SpotifyAccount;
 43
 44namespace Tomahawk
 45{
 46
 47class DropJobNotifier;
 48
 49class DLLEXPORT SpotifyParser : public QObject
 50{
 51    Q_OBJECT
 52public:
 53    friend class SpotifyJobNotifier;
 54    explicit SpotifyParser( const QString& trackUrl, bool createNewPlaylist = false, QObject* parent = 0 );
 55    explicit SpotifyParser( const QStringList& trackUrls, bool createNewPlaylist = false, QObject* parent = 0 );
 56    virtual ~SpotifyParser();
 57
 58    // if true, emits track(), if false, emits tracks().
 59    // only matters if you're using the QStrin constructor and explicityl dont' want
 60    // the single track signal
 61    void setSingleMode( bool single ) { m_single = single; }
 62
 63public slots:
 64    void  playlistListingResult( const QString& msgType, const QVariantMap& msg, const QVariant& extraData );
 65
 66signals:
 67    void track( const Tomahawk::query_ptr& track );
 68    void tracks( const QList< Tomahawk::query_ptr > tracks );
 69    void playlist( const Tomahawk::query_ptr& playlist );
 70
 71private slots:
 72    void spotifyTrackLookupFinished();
 73    void spotifyBrowseFinished();
 74
 75    void playlistCreated();
 76private:
 77    QPixmap pixmap() const;
 78
 79    void lookupUrl( const QString& url );
 80    void lookupTrack( const QString& track );
 81    void lookupSpotifyBrowse(const QString& link );
 82    void checkTrackFinished();
 83    void checkBrowseFinished();
 84
 85
 86    int  m_limit;
 87    bool m_single;
 88    bool m_trackMode;
 89    bool m_collaborative;
 90    bool m_createNewPlaylist;
 91    DropJobNotifier* m_browseJob;
 92    int m_subscribers;
 93    QList< query_ptr > m_tracks;
 94    QSet< NetworkReply* > m_queries;
 95    QString m_title, m_info, m_creator;
 96    Tomahawk::playlist_ptr m_playlist;
 97    QString m_browseUri;
 98    static QPixmap* s_pixmap;
 99};
100
101}
102
103#endif