PageRenderTime 102ms CodeModel.GetById 61ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 0ms

/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
19#ifndef ECHONESTCATALOGSYNCHRONIZER_H
20#define ECHONESTCATALOGSYNCHRONIZER_H
21
22#include "DllMacro.h"
23#include "Query.h"
24
25#include <echonest5/Catalog.h>
26
27#include <QObject>
28#include <QQueue>
29
30namespace Tomahawk
31{
32
33class DLLEXPORT EchonestCatalogSynchronizer : public QObject
34{
35    Q_OBJECT
36public:
37    static EchonestCatalogSynchronizer* instance() {
38        if ( !s_instance )
39        {
40            s_instance = new EchonestCatalogSynchronizer;
41        }
42
43        return s_instance;
44    }
45
46    explicit EchonestCatalogSynchronizer(QObject *parent = 0);
47
48    Echonest::Catalog songCatalog() const { return m_songCatalog; }
49    Echonest::Catalog artistCatalog() const { return m_artistCatalog; }
50
51signals:
52    void knownCatalogsChanged();
53
54private slots:
55    void checkSettingsChanged();
56    void tracksAdded( const QList<unsigned int>& );
57    void tracksRemoved( const QList<unsigned int>& );
58
59    void loadedResults( const QList<Tomahawk::result_ptr>& results );
60
61    // Echonest slots
62    void songCreateFinished();
63    void artistCreateFinished();
64    void songUpdateFinished();
65    void catalogDeleted();
66
67    void checkTicket();
68
69    void rawTracksAdd( const QList< QStringList >& tracks );
70private:
71    void uploadDb();
72    QByteArray escape( const QString& in ) const;
73
74    Echonest::CatalogUpdateEntry entryFromTrack( const QStringList&, Echonest::CatalogTypes::Action action ) const;
75    void doUploadJob();
76
77    bool m_syncing;
78
79    Echonest::Catalog m_songCatalog;
80    Echonest::Catalog m_artistCatalog;
81
82    QQueue< Echonest::CatalogUpdateEntries > m_queuedUpdates;
83
84    static EchonestCatalogSynchronizer* s_instance;
85
86    friend class DatabaseCommand_SetCollectionAttributes;
87};
88
89}
90
91#endif // ECHONESTCATALOGSYNCHRONIZER_H