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