/src/libtomahawk/EchonestCatalogSynchronizer.h

http://github.com/tomahawk-player/tomahawk · C Header · 91 lines · 50 code · 23 blank · 18 comment · 1 complexity · 0bb12ebf69743c3909ee8bb54567c87f 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. #ifndef ECHONESTCATALOGSYNCHRONIZER_H
  19. #define ECHONESTCATALOGSYNCHRONIZER_H
  20. #include "DllMacro.h"
  21. #include "Query.h"
  22. #include <echonest5/Catalog.h>
  23. #include <QObject>
  24. #include <QQueue>
  25. namespace Tomahawk
  26. {
  27. class DLLEXPORT EchonestCatalogSynchronizer : public QObject
  28. {
  29. Q_OBJECT
  30. public:
  31. static EchonestCatalogSynchronizer* instance() {
  32. if ( !s_instance )
  33. {
  34. s_instance = new EchonestCatalogSynchronizer;
  35. }
  36. return s_instance;
  37. }
  38. explicit EchonestCatalogSynchronizer(QObject *parent = 0);
  39. Echonest::Catalog songCatalog() const { return m_songCatalog; }
  40. Echonest::Catalog artistCatalog() const { return m_artistCatalog; }
  41. signals:
  42. void knownCatalogsChanged();
  43. private slots:
  44. void checkSettingsChanged();
  45. void tracksAdded( const QList<unsigned int>& );
  46. void tracksRemoved( const QList<unsigned int>& );
  47. void loadedResults( const QList<Tomahawk::result_ptr>& results );
  48. // Echonest slots
  49. void songCreateFinished();
  50. void artistCreateFinished();
  51. void songUpdateFinished();
  52. void catalogDeleted();
  53. void checkTicket();
  54. void rawTracksAdd( const QList< QStringList >& tracks );
  55. private:
  56. void uploadDb();
  57. QByteArray escape( const QString& in ) const;
  58. Echonest::CatalogUpdateEntry entryFromTrack( const QStringList&, Echonest::CatalogTypes::Action action ) const;
  59. void doUploadJob();
  60. bool m_syncing;
  61. Echonest::Catalog m_songCatalog;
  62. Echonest::Catalog m_artistCatalog;
  63. QQueue< Echonest::CatalogUpdateEntries > m_queuedUpdates;
  64. static EchonestCatalogSynchronizer* s_instance;
  65. friend class DatabaseCommand_SetCollectionAttributes;
  66. };
  67. }
  68. #endif // ECHONESTCATALOGSYNCHRONIZER_H