1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

Add some methods for pushing supported info types out of infosystem; untested currently, but compiles

This commit is contained in:
Jeff Mitchell
2013-01-14 14:39:30 -05:00
parent e5f207f0f5
commit cd3d42dc61
5 changed files with 47 additions and 8 deletions

View File

@@ -208,6 +208,7 @@ namespace Tomahawk
class InfoPlugin; class InfoPlugin;
typedef QSet< InfoType > InfoTypeSet;
typedef QMap< InfoType, QVariant > InfoTypeMap; typedef QMap< InfoType, QVariant > InfoTypeMap;
typedef QMap< InfoType, uint > InfoTimeoutMap; typedef QMap< InfoType, uint > InfoTimeoutMap;
typedef QHash< QString, QString > InfoStringHash; typedef QHash< QString, QString > InfoStringHash;

View File

@@ -309,6 +309,22 @@ InfoSystem::removeInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin )
} }
void
InfoSystem::receiveUpdatedSupportedGetTypes( InfoTypeSet supportedTypes )
{
m_supportedGetTypes = supportedTypes;
emit updatedSupportedGetTypes( m_supportedGetTypes );
}
void
InfoSystem::receiveUpdatedSupportedPushTypes( InfoTypeSet supportedTypes )
{
m_supportedPushTypes = supportedTypes;
emit updatedSupportedPushTypes( m_supportedPushTypes );
}
QPointer< QThread > QPointer< QThread >
InfoSystem::workerThread() const InfoSystem::workerThread() const
{ {

View File

@@ -155,9 +155,11 @@ public:
virtual ~InfoSystemCacheThread(); virtual ~InfoSystemCacheThread();
void run(); void run();
InfoSystemCache* cache() const;
private: private:
friend class InfoSystem;
InfoSystemCache* cache() const;
QPointer< InfoSystemCache > m_cache; QPointer< InfoSystemCache > m_cache;
}; };
@@ -171,9 +173,12 @@ public:
virtual ~InfoSystemWorkerThread(); virtual ~InfoSystemWorkerThread();
void run(); void run();
InfoSystemWorker* worker() const;
private: private:
friend class DiagnosticsDialog;
friend class InfoSystem;
InfoSystemWorker* worker() const;
QPointer< InfoSystemWorker > m_worker; QPointer< InfoSystemWorker > m_worker;
}; };
@@ -185,14 +190,17 @@ class DLLEXPORT InfoSystem : public QObject
public: public:
static InfoSystem* instance(); static InfoSystem* instance();
InfoSystem( QObject *parent ); InfoSystem( QObject* parent );
~InfoSystem(); ~InfoSystem();
bool getInfo( const InfoRequestData &requestData ); bool getInfo( const InfoRequestData& requestData );
//WARNING: if changing timeoutMillis above, also change in below function in .cpp file //WARNING: if changing timeoutMillis above, also change in below function in .cpp file
bool getInfo( const QString &caller, const QVariantMap &customData, const InfoTypeMap &inputMap, const InfoTimeoutMap &timeoutMap = InfoTimeoutMap(), bool allSources = false ); bool getInfo( const QString &caller, const QVariantMap& customData, const InfoTypeMap& inputMap, const InfoTimeoutMap& timeoutMap = InfoTimeoutMap(), bool allSources = false );
bool pushInfo( InfoPushData pushData ); bool pushInfo( InfoPushData pushData );
bool pushInfo( const QString &caller, const InfoTypeMap &input, const PushInfoFlags pushFlags ); bool pushInfo( const QString& caller, const InfoTypeMap& input, const PushInfoFlags pushFlags );
const InfoTypeSet& supportedGetTypes() const { return m_supportedGetTypes; }
const InfoTypeSet& supportedPushTypes() const { return m_supportedPushTypes; }
QPointer< QThread > workerThread() const; QPointer< QThread > workerThread() const;
@@ -206,14 +214,22 @@ signals:
void finished( QString target ); void finished( QString target );
void finished( QString target, Tomahawk::InfoSystem::InfoType type ); void finished( QString target, Tomahawk::InfoSystem::InfoType type );
void updatedSupportedGetTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
void updatedSupportedPushTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
private slots: private slots:
void init(); void init();
void receiveUpdatedSupportedGetTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
void receiveUpdatedSupportedPushTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
private: private:
bool m_inited; bool m_inited;
InfoSystemCacheThread* m_infoSystemCacheThreadController; InfoSystemCacheThread* m_infoSystemCacheThreadController;
InfoSystemWorkerThread* m_infoSystemWorkerThreadController; InfoSystemWorkerThread* m_infoSystemWorkerThreadController;
InfoTypeSet m_supportedGetTypes;
InfoTypeSet m_supportedPushTypes;
static InfoSystem* s_instance; static InfoSystem* s_instance;
}; };

View File

@@ -29,10 +29,10 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QNetworkConfiguration>
#include <QNetworkProxy>
#include <QDir> #include <QDir>
#include <QLibrary> #include <QLibrary>
#include <QNetworkConfiguration>
#include <QNetworkProxy>
#include <QPluginLoader> #include <QPluginLoader>
namespace Tomahawk namespace Tomahawk
@@ -130,6 +130,9 @@ InfoSystemWorker::addInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin )
); );
QMetaObject::invokeMethod( plugin.data(), "init", Qt::QueuedConnection ); QMetaObject::invokeMethod( plugin.data(), "init", Qt::QueuedConnection );
emit updatedSupportedGetTypes( QSet< InfoType >::fromList( m_infoGetMap.keys() ) );
emit updatedSupportedPushTypes( QSet< InfoType >::fromList( m_infoPushMap.keys() ) );
} }

View File

@@ -55,6 +55,9 @@ signals:
void finished( QString target ); void finished( QString target );
void finished( QString target, Tomahawk::InfoSystem::InfoType type ); void finished( QString target, Tomahawk::InfoSystem::InfoType type );
void updatedSupportedGetTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
void updatedSupportedPushTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
public slots: public slots:
void init( Tomahawk::InfoSystem::InfoSystemCache* cache ); void init( Tomahawk::InfoSystem::InfoSystemCache* cache );
void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData ); void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );