/src/libtomahawk/utils/XspfLoader.h

http://github.com/tomahawk-player/tomahawk · C Header · 86 lines · 46 code · 15 blank · 25 comment · 0 complexity · c7bfef13a6ee493c944b04bac5ec3edc MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4. * Copyright 2011-2012, Leo Franchi <lfranchi@kde.org>
  5. * Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
  6. *
  7. * Tomahawk 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. * Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #pragma once
  21. #ifndef XSPFLOADER_H
  22. #define XSPFLOADER_H
  23. #include "DllMacro.h"
  24. #include "Playlist.h"
  25. #include "Typedefs.h"
  26. #include <QFile>
  27. /**
  28. * @brief Fetches and parses an XSPF document from a QFile or QUrl.
  29. */
  30. class DLLEXPORT XSPFLoader : public QObject
  31. {
  32. Q_OBJECT
  33. public:
  34. enum XSPFErrorCode { ParseError, InvalidTrackError, FetchError };
  35. explicit XSPFLoader( bool autoCreate = true, bool autoUpdate = false, QObject* parent = 0, const QString& guid = QString() );
  36. virtual ~XSPFLoader();
  37. QList< Tomahawk::query_ptr > entries() const;
  38. QString title() const;
  39. /**
  40. * Get the playlist for the most recent parsed XSPF url.
  41. */
  42. Tomahawk::playlist_ptr getPlaylistForRecentUrl();
  43. void setOverrideTitle( const QString& newTitle );
  44. void setAutoResolveTracks( bool autoResolve );
  45. void setAutoDelete( bool autoDelete );
  46. void setErrorTitle( const QString& error );
  47. static QString errorToString( XSPFErrorCode error );
  48. signals:
  49. void error( XSPFLoader::XSPFErrorCode error );
  50. void ok( const Tomahawk::playlist_ptr& );
  51. void track( const Tomahawk::query_ptr& track );
  52. void tracks( const QList< Tomahawk::query_ptr > tracks );
  53. public slots:
  54. void load( const QUrl& url );
  55. void load( QFile& file );
  56. private slots:
  57. void networkLoadFinished();
  58. void networkError( QNetworkReply::NetworkError e );
  59. private:
  60. void reportError();
  61. void gotBody();
  62. bool m_autoCreate, m_autoUpdate, m_autoResolve, m_autoDelete;
  63. QString m_guid;
  64. QString m_NS,m_overrideTitle;
  65. QList< Tomahawk::query_ptr > m_entries;
  66. QString m_title, m_info, m_creator, m_errorTitle;
  67. QUrl m_url;
  68. QByteArray m_body;
  69. Tomahawk::playlist_ptr m_playlist;
  70. };
  71. #endif // XSPFLOADER_H