예제 #1
0
void
ScriptInfoPlugin::notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData )
{
    Q_D( ScriptInfoPlugin );

    QVariantMap arguments;
    arguments[ "type" ] = requestData.type;
    arguments[ "criteria" ] = convertInfoStringHashToQVariantMap( criteria );

    ScriptJob* job = m_scriptObject->invoke( "_notInCache", arguments );
    connect( job, SIGNAL( done( QVariantMap ) ), SLOT( onNotInCacheRequestDone( QVariantMap ) ) );
    d->requestDataCache[ job->id().toInt() ] = requestData;
    d->criteriaCache[ job->id().toInt() ] = criteria;

    job->start();
}
예제 #2
0
void
ScriptInfoPlugin::onNotInCacheRequestDone( const QVariantMap& result )
{
    Q_ASSERT( QThread::currentThread() == thread() );

    Q_D( ScriptInfoPlugin );

    ScriptJob* job = qobject_cast< ScriptJob* >( sender() );

    // retrieve requestData from cache and delete it
    Tomahawk::InfoSystem::InfoRequestData requestData = d->requestDataCache[ job->id().toInt() ];
    d->requestDataCache.remove( job->id().toInt() );

    emit info( requestData, result[ "data" ].toMap() );

    // retrieve criteria from cache and delete it
    Tomahawk::InfoSystem::InfoStringHash criteria = d->criteriaCache[ job->id().toInt() ];
    d->criteriaCache.remove( job->id().toInt() );

    emit updateCache( criteria, result[ "maxAge" ].toLongLong(), requestData.type, result[ "data" ].toMap() );

    sender()->deleteLater();
}
예제 #3
0
void
ScriptInfoPlugin::onGetInfoRequestDone( const QVariantMap& result )
{
    Q_ASSERT( QThread::currentThread() == thread() );

    Q_D( ScriptInfoPlugin );



    ScriptJob* job = qobject_cast< ScriptJob* >( sender() );

    if ( job->error() )
    {
        emit info( d->requestDataCache[ job->id().toInt() ], QVariantMap() );
    }
    else
    {

        emit getCachedInfo( convertQVariantMapToInfoStringHash( result[ "criteria" ].toMap() ), result[ "newMaxAge" ].toLongLong(), d->requestDataCache[ job->id().toInt() ] );
    }

    d->requestDataCache.remove( job->id().toInt() );
    sender()->deleteLater();
}
예제 #4
0
void
ScriptInfoPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
{
    Q_D( ScriptInfoPlugin );


    QVariantMap arguments;
    arguments[ "type" ] = requestData.type;
    arguments[ "data" ] = convertInfoStringHashToQVariantMap( requestData.input.value<Tomahawk::InfoSystem::InfoStringHash>() );

    ScriptJob* job = m_scriptObject->invoke( "_getInfo", arguments );
    connect( job, SIGNAL( done( QVariantMap ) ), SLOT( onGetInfoRequestDone( QVariantMap ) ) );

    d->requestDataCache[ job->id().toInt() ] = requestData;
    job->start();
}