/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. #ifndef SPOTIFY_PARSER_H
  20. #define SPOTIFY_PARSER_H
  21. #include "DllMacro.h"
  22. #include "Typedefs.h"
  23. #include "Query.h"
  24. #include "jobview/JobStatusItem.h"
  25. //#include "accounts/spotify/SpotifyPlaylistUpdater.h"
  26. #include "accounts/spotify/SpotifyAccount.h"
  27. #include <QObject>
  28. #include <QSet>
  29. #include <QtCore/QStringList>
  30. #define SPOTIFY_PLAYLIST_API_URL "http://spotikea.tomahawk-player.org"
  31. /**
  32. * Small class to parse spotify links into query_ptrs
  33. *
  34. * Connect to the signals to get the results
  35. */
  36. class NetworkReply;
  37. class SpotifyAccount;
  38. namespace Tomahawk
  39. {
  40. class DropJobNotifier;
  41. class DLLEXPORT SpotifyParser : public QObject
  42. {
  43. Q_OBJECT
  44. public:
  45. friend class SpotifyJobNotifier;
  46. explicit SpotifyParser( const QString& trackUrl, bool createNewPlaylist = false, QObject* parent = 0 );
  47. explicit SpotifyParser( const QStringList& trackUrls, bool createNewPlaylist = false, QObject* parent = 0 );
  48. virtual ~SpotifyParser();
  49. // if true, emits track(), if false, emits tracks().
  50. // only matters if you're using the QStrin constructor and explicityl dont' want
  51. // the single track signal
  52. void setSingleMode( bool single ) { m_single = single; }
  53. public slots:
  54. void playlistListingResult( const QString& msgType, const QVariantMap& msg, const QVariant& extraData );
  55. signals:
  56. void track( const Tomahawk::query_ptr& track );
  57. void tracks( const QList< Tomahawk::query_ptr > tracks );
  58. void playlist( const Tomahawk::query_ptr& playlist );
  59. private slots:
  60. void spotifyTrackLookupFinished();
  61. void spotifyBrowseFinished();
  62. void playlistCreated();
  63. private:
  64. QPixmap pixmap() const;
  65. void lookupUrl( const QString& url );
  66. void lookupTrack( const QString& track );
  67. void lookupSpotifyBrowse(const QString& link );
  68. void checkTrackFinished();
  69. void checkBrowseFinished();
  70. int m_limit;
  71. bool m_single;
  72. bool m_trackMode;
  73. bool m_collaborative;
  74. bool m_createNewPlaylist;
  75. DropJobNotifier* m_browseJob;
  76. int m_subscribers;
  77. QList< query_ptr > m_tracks;
  78. QSet< NetworkReply* > m_queries;
  79. QString m_title, m_info, m_creator;
  80. Tomahawk::playlist_ptr m_playlist;
  81. QString m_browseUri;
  82. static QPixmap* s_pixmap;
  83. };
  84. }
  85. #endif