PageRenderTime 224ms CodeModel.GetById 100ms app.highlight 12ms RepoModel.GetById 109ms app.codeStats 0ms

/src/libtomahawk/infosystem/InfoSystemWorker.h

http://github.com/tomahawk-player/tomahawk
C Header | 106 lines | 57 code | 29 blank | 20 comment | 0 complexity | a4453c6fef17aeedee03c6f22a94d318 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 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
  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
 20#ifndef TOMAHAWK_INFOSYSTEMWORKER_H
 21#define TOMAHAWK_INFOSYSTEMWORKER_H
 22
 23#include "infosystem/InfoSystem.h"
 24
 25#include <QtNetwork/QNetworkAccessManager>
 26#include <QtCore/QObject>
 27#include <QtCore/QtDebug>
 28#include <QtCore/QMap>
 29#include <QtCore/QSet>
 30#include <QtCore/QList>
 31#include <QtCore/QVariant>
 32#include <QtCore/QTimer>
 33
 34#include "DllMacro.h"
 35
 36namespace Tomahawk {
 37
 38namespace InfoSystem {
 39
 40class InfoSystemCache;
 41
 42
 43class DLLEXPORT InfoSystemWorker : public QObject
 44{
 45    Q_OBJECT
 46
 47public:
 48    InfoSystemWorker();
 49    ~InfoSystemWorker();
 50
 51    const QList< InfoPluginPtr > plugins() const;
 52
 53signals:
 54    void info( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
 55    void finished( QString target );
 56    void finished( QString target, Tomahawk::InfoSystem::InfoType type );
 57
 58    void updatedSupportedGetTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
 59    void updatedSupportedPushTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
 60
 61public slots:
 62    void init( Tomahawk::InfoSystem::InfoSystemCache* cache );
 63    void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
 64
 65    void pushInfo( Tomahawk::InfoSystem::InfoPushData pushData );
 66    
 67    void infoSlot( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
 68
 69    void addInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin );
 70    void removeInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin );
 71    void loadInfoPlugins();
 72
 73private slots:
 74    void checkTimeoutsTimerFired();
 75
 76private:
 77    void registerInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType > &getTypes, const QSet< InfoType > &pushTypes );
 78    void deregisterInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType > &getTypes, const QSet< InfoType > &pushTypes );
 79
 80    void checkFinished( const Tomahawk::InfoSystem::InfoRequestData &target );
 81    QList< InfoPluginPtr > determineOrderedMatches( const InfoType type ) const;
 82
 83    QHash< QString, QHash< InfoType, int > > m_dataTracker;
 84    QMultiMap< qint64, quint64 > m_timeRequestMapper;
 85    QHash< uint, bool > m_requestSatisfiedMap;
 86    QHash< uint, InfoRequestData* > m_savedRequestMap;
 87
 88    // NOTE Cache object lives in a different thread, do not call methods on it directly
 89    InfoSystemCache* m_cache;
 90
 91    // For now, statically instantiate plugins; this is just somewhere to keep them
 92    QList< InfoPluginPtr > m_plugins;
 93
 94    QMap< InfoType, QList< InfoPluginPtr > > m_infoGetMap;
 95    QMap< InfoType, QList< InfoPluginPtr > > m_infoPushMap;
 96
 97    QTimer m_checkTimeoutsTimer;
 98
 99    quint64 m_shortLinksWaiting;
100};
101
102}
103
104}
105
106#endif // TOMAHAWK_INFOSYSTEMWORKER_H