mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
* InfoSystem now emits ready() when init is done.
This commit is contained in:
@@ -80,6 +80,7 @@ InfoPlugin::setFriendlyName( const QString& friendlyName )
|
|||||||
m_friendlyName = friendlyName;
|
m_friendlyName = friendlyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString
|
const QString
|
||||||
InfoPlugin::friendlyName() const
|
InfoPlugin::friendlyName() const
|
||||||
{
|
{
|
||||||
@@ -99,7 +100,7 @@ InfoSystem::instance()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InfoSystem::InfoSystem( QObject *parent )
|
InfoSystem::InfoSystem( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_inited( false )
|
, m_inited( false )
|
||||||
, m_infoSystemCacheThreadController( 0 )
|
, m_infoSystemCacheThreadController( 0 )
|
||||||
@@ -121,7 +122,7 @@ InfoSystem::InfoSystem( QObject *parent )
|
|||||||
|
|
||||||
InfoSystem::~InfoSystem()
|
InfoSystem::~InfoSystem()
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << " beginning";
|
tDebug() << Q_FUNC_INFO << "beginning";
|
||||||
|
|
||||||
if ( m_infoSystemWorkerThreadController )
|
if ( m_infoSystemWorkerThreadController )
|
||||||
{
|
{
|
||||||
@@ -131,9 +132,9 @@ InfoSystem::~InfoSystem()
|
|||||||
delete m_infoSystemWorkerThreadController;
|
delete m_infoSystemWorkerThreadController;
|
||||||
m_infoSystemWorkerThreadController = 0;
|
m_infoSystemWorkerThreadController = 0;
|
||||||
}
|
}
|
||||||
tDebug() << Q_FUNC_INFO << " done deleting worker";
|
tDebug() << Q_FUNC_INFO << "done deleting worker";
|
||||||
|
|
||||||
if( m_infoSystemCacheThreadController )
|
if ( m_infoSystemCacheThreadController )
|
||||||
{
|
{
|
||||||
m_infoSystemCacheThreadController->quit();
|
m_infoSystemCacheThreadController->quit();
|
||||||
m_infoSystemCacheThreadController->wait( 60000 );
|
m_infoSystemCacheThreadController->wait( 60000 );
|
||||||
@@ -142,7 +143,7 @@ InfoSystem::~InfoSystem()
|
|||||||
m_infoSystemCacheThreadController = 0;
|
m_infoSystemCacheThreadController = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tDebug() << Q_FUNC_INFO << " done deleting cache";
|
tDebug() << Q_FUNC_INFO << "done deleting cache";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -182,11 +183,12 @@ InfoSystem::init()
|
|||||||
QMetaObject::invokeMethod( worker, "init", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoSystemCache*, cache ) );
|
QMetaObject::invokeMethod( worker, "init", Qt::QueuedConnection, Q_ARG( Tomahawk::InfoSystem::InfoSystemCache*, cache ) );
|
||||||
|
|
||||||
m_inited = true;
|
m_inited = true;
|
||||||
|
emit ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InfoSystem::getInfo( const InfoRequestData &requestData )
|
InfoSystem::getInfo( const InfoRequestData& requestData )
|
||||||
{
|
{
|
||||||
//qDebug() << Q_FUNC_INFO;
|
//qDebug() << Q_FUNC_INFO;
|
||||||
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
||||||
@@ -200,7 +202,7 @@ InfoSystem::getInfo( const InfoRequestData &requestData )
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InfoSystem::getInfo( const QString &caller, const QVariantMap &customData, const InfoTypeMap &inputMap, const InfoTimeoutMap &timeoutMap, bool allSources )
|
InfoSystem::getInfo( const QString& caller, const QVariantMap& customData, const InfoTypeMap& inputMap, const InfoTimeoutMap& timeoutMap, bool allSources )
|
||||||
{
|
{
|
||||||
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
||||||
{
|
{
|
||||||
@@ -211,7 +213,7 @@ InfoSystem::getInfo( const QString &caller, const QVariantMap &customData, const
|
|||||||
requestData.caller = caller;
|
requestData.caller = caller;
|
||||||
requestData.customData = customData;
|
requestData.customData = customData;
|
||||||
requestData.allSources = allSources;
|
requestData.allSources = allSources;
|
||||||
Q_FOREACH( InfoType type, inputMap.keys() )
|
foreach ( InfoType type, inputMap.keys() )
|
||||||
{
|
{
|
||||||
requestData.type = type;
|
requestData.type = type;
|
||||||
requestData.input = inputMap[ type ];
|
requestData.input = inputMap[ type ];
|
||||||
@@ -241,7 +243,7 @@ InfoSystem::pushInfo( InfoPushData pushData )
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InfoSystem::pushInfo( const QString &caller, const InfoTypeMap &input, const PushInfoFlags pushFlags )
|
InfoSystem::pushInfo( const QString& caller, const InfoTypeMap& input, const PushInfoFlags pushFlags )
|
||||||
{
|
{
|
||||||
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
if ( !m_inited || !m_infoSystemWorkerThreadController->worker() )
|
||||||
{
|
{
|
||||||
@@ -249,7 +251,7 @@ InfoSystem::pushInfo( const QString &caller, const InfoTypeMap &input, const Pus
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_FOREACH( InfoType type, input.keys() )
|
foreach ( InfoType type, input.keys() )
|
||||||
{
|
{
|
||||||
InfoPushData pushData( caller, type, input[ type ], pushFlags );
|
InfoPushData pushData( caller, type, input[ type ], pushFlags );
|
||||||
pushData.infoPair = PushInfoPair( QVariantMap(), pushData.input );
|
pushData.infoPair = PushInfoPair( QVariantMap(), pushData.input );
|
||||||
@@ -341,7 +343,7 @@ InfoSystem::workerThread() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InfoSystemCacheThread::InfoSystemCacheThread( QObject *parent )
|
InfoSystemCacheThread::InfoSystemCacheThread( QObject* parent )
|
||||||
: QThread( parent )
|
: QThread( parent )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
tDebug() << Q_FUNC_INFO;
|
||||||
@@ -373,26 +375,29 @@ InfoSystemCacheThread::cache() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InfoSystemWorkerThread::InfoSystemWorkerThread( QObject *parent )
|
InfoSystemWorkerThread::InfoSystemWorkerThread( QObject* parent )
|
||||||
: QThread( parent )
|
: QThread( parent )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
tDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InfoSystemWorkerThread::~InfoSystemWorkerThread()
|
InfoSystemWorkerThread::~InfoSystemWorkerThread()
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
tDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoSystemWorkerThread::InfoSystemWorkerThread::run()
|
InfoSystemWorkerThread::InfoSystemWorkerThread::run()
|
||||||
{
|
{
|
||||||
m_worker = QPointer< InfoSystemWorker >( new InfoSystemWorker() );
|
m_worker = QPointer< InfoSystemWorker >( new InfoSystemWorker() );
|
||||||
exec();
|
exec();
|
||||||
if( !m_worker.isNull() )
|
if ( !m_worker.isNull() )
|
||||||
delete m_worker.data();
|
delete m_worker.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InfoSystemWorker*
|
InfoSystemWorker*
|
||||||
InfoSystemWorkerThread::worker() const
|
InfoSystemWorkerThread::worker() const
|
||||||
{
|
{
|
||||||
@@ -401,7 +406,6 @@ InfoSystemWorkerThread::worker() const
|
|||||||
return m_worker.data();
|
return m_worker.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} //namespace InfoSystem
|
} //namespace InfoSystem
|
||||||
|
|
||||||
} //namespace Tomahawk
|
} //namespace Tomahawk
|
||||||
|
@@ -65,7 +65,7 @@ struct DLLEXPORT InfoRequestData {
|
|||||||
|
|
||||||
InfoRequestData();
|
InfoRequestData();
|
||||||
|
|
||||||
InfoRequestData( const quint64 rId, const QString &callr, const Tomahawk::InfoSystem::InfoType typ, const QVariant &inputvar, const QVariantMap &custom );
|
InfoRequestData( const quint64 rId, const QString& callr, const Tomahawk::InfoSystem::InfoType typ, const QVariant& inputvar, const QVariantMap& custom );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init( const QString& callr, const InfoType typ, const QVariant& inputvar, const QVariantMap& custom);
|
void init( const QString& callr, const InfoType typ, const QVariant& inputvar, const QVariantMap& custom);
|
||||||
@@ -87,7 +87,7 @@ struct InfoPushData {
|
|||||||
, infoPair( Tomahawk::InfoSystem::PushInfoPair( QVariantMap(), QVariant() ) )
|
, infoPair( Tomahawk::InfoSystem::PushInfoPair( QVariantMap(), QVariant() ) )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
InfoPushData( const QString &callr, const Tomahawk::InfoSystem::InfoType typ, const QVariant &inputvar, const Tomahawk::InfoSystem::PushInfoFlags pflags )
|
InfoPushData( const QString& callr, const Tomahawk::InfoSystem::InfoType typ, const QVariant& inputvar, const Tomahawk::InfoSystem::PushInfoFlags pflags )
|
||||||
: caller( callr )
|
: caller( callr )
|
||||||
, type( typ )
|
, type( typ )
|
||||||
, input( inputvar )
|
, input( inputvar )
|
||||||
@@ -152,7 +152,7 @@ class DLLEXPORT InfoSystemCacheThread : public QThread
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InfoSystemCacheThread( QObject *parent );
|
InfoSystemCacheThread( QObject* parent );
|
||||||
virtual ~InfoSystemCacheThread();
|
virtual ~InfoSystemCacheThread();
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
@@ -170,7 +170,7 @@ class DLLEXPORT InfoSystemWorkerThread : public QThread
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InfoSystemWorkerThread( QObject *parent );
|
InfoSystemWorkerThread( QObject* parent );
|
||||||
virtual ~InfoSystemWorkerThread();
|
virtual ~InfoSystemWorkerThread();
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
@@ -196,7 +196,7 @@ public:
|
|||||||
|
|
||||||
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 );
|
||||||
|
|
||||||
@@ -214,6 +214,7 @@ signals:
|
|||||||
void info( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
void info( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||||
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 ready();
|
||||||
|
|
||||||
void updatedSupportedGetTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
|
void updatedSupportedGetTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
|
||||||
void updatedSupportedPushTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
|
void updatedSupportedPushTypes( Tomahawk::InfoSystem::InfoTypeSet supportedTypes );
|
||||||
|
@@ -43,6 +43,7 @@ namespace InfoSystem
|
|||||||
|
|
||||||
InfoSystemWorker::InfoSystemWorker()
|
InfoSystemWorker::InfoSystemWorker()
|
||||||
: QObject()
|
: QObject()
|
||||||
|
, m_cache( 0 )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
tDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user