PageRenderTime 20ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/libtomahawk/utils/JspfLoader.h

http://github.com/tomahawk-player/tomahawk
C Header | 77 lines | 42 code | 18 blank | 17 comment | 0 complexity | f58bd1c77ef6ea183166d1ad78730376 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 *
 5 *   Tomahawk 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 *
10 *   Tomahawk is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef JSPFLOADER_H
20#define JSPFLOADER_H
21
22#include <QObject>
23#include <QUrl>
24#include <QFile>
25#include <QNetworkReply>
26#include <QNetworkRequest>
27
28#include "Playlist.h"
29#include "Typedefs.h"
30
31#include "DllMacro.h"
32
33namespace Tomahawk
34{
35
36class DLLEXPORT JSPFLoader : public QObject
37{
38Q_OBJECT
39
40public:
41    explicit JSPFLoader( bool autoCreate = true, QObject* parent = 0 );
42
43    virtual ~JSPFLoader();
44
45    QList< Tomahawk::query_ptr > entries() const;
46    void setOverrideTitle( const QString& newTitle ) { m_overrideTitle = newTitle; }
47
48    void setAutoDelete( bool autoDelete ) { m_autoDelete = autoDelete; }
49
50signals:
51    void failed();
52    void ok( const Tomahawk::playlist_ptr& );
53    void tracks( const QList< Tomahawk::query_ptr > tracks );
54
55public slots:
56    void load( const QUrl& url );
57    void load( QFile& file );
58
59private slots:
60    void networkLoadFinished();
61    void networkError( QNetworkReply::NetworkError e );
62
63private:
64    void reportError();
65    void gotBody();
66
67    bool m_autoCreate, m_autoDelete;
68    QList< Tomahawk::query_ptr > m_entries;
69    QString m_title, m_info, m_creator, m_overrideTitle;
70
71    QByteArray m_body;
72    Tomahawk::playlist_ptr m_playlist;
73};
74
75}
76
77#endif // JSPFLOADER_H