PageRenderTime 248ms CodeModel.GetById 100ms app.highlight 63ms RepoModel.GetById 78ms app.codeStats 1ms

/src/libtomahawk/utils/rdioparser.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 105 lines | 58 code | 24 blank | 23 comment | 0 complexity | 37f32d7727f443b0c4ba7fb17a8603fd 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 RDIOPARSER_H
 21#define RDIOPARSER_H
 22
 23#include "jobview/JobStatusItem.h"
 24#include "Query.h"
 25#include "config.h"
 26#include "DropJob.h"
 27#include "Typedefs.h"
 28#include "Playlist.h"
 29
 30#include <QtCore/QObject>
 31#include <QStringList>
 32#include <QSet>
 33
 34#include <QNetworkRequest>
 35
 36#ifdef QCA2_FOUND
 37#include <QtCrypto>
 38#endif
 39
 40class NetworkReply;
 41
 42namespace Tomahawk
 43{
 44
 45class DropJobNotifier;
 46
 47/**
 48 * Small class to parse spotify links into query_ptrs
 49 *
 50 * Connect to the signals to get the results
 51 */
 52
 53class RdioParser : public QObject
 54{
 55    Q_OBJECT
 56public:
 57
 58    explicit RdioParser( QObject* parent = 0 );
 59    virtual ~RdioParser();
 60
 61    void parse( const QString& url );
 62    void parse( const QStringList& urls );
 63
 64    void setCreatePlaylist( bool createPlaylist ) { m_createPlaylist = createPlaylist; }
 65
 66signals:
 67    void track( const Tomahawk::query_ptr& track );
 68    void tracks( const QList< Tomahawk::query_ptr > tracks );
 69
 70private slots:
 71    void expandedLinks( const QStringList& );
 72    void rdioReturned();
 73
 74    void playlistCreated( Tomahawk::PlaylistRevision );
 75private:
 76    void parseTrack( const QString& url );
 77    void fetchObjectsFromUrl( const QString& url, DropJob::DropType type );
 78
 79    QByteArray hmacSha1(QByteArray key, QByteArray baseString);
 80    QNetworkRequest generateRequest( const QString& method, const QString& url, const QList< QPair< QByteArray, QByteArray > >& extraParams, QByteArray* postData );
 81    QPixmap pixmap() const;
 82    void checkFinished();
 83    void parseUrl( const QString& url );
 84
 85    bool m_multi;
 86    int m_count, m_total;
 87    QSet< NetworkReply* > m_reqQueries;
 88    DropJobNotifier* m_browseJob;
 89
 90    QString m_title, m_creator;
 91    playlist_ptr m_playlist;
 92
 93    static QPixmap* s_pixmap;
 94
 95    bool m_createPlaylist;
 96    QList< query_ptr > m_tracks;
 97
 98#ifdef QCA2_FOUND
 99    static QCA::Initializer m_qcaInit;
100#endif
101};
102
103}
104
105#endif // RDIOPARSER_H