void
ScriptCommand_AllTracks::exec()
{
    Tomahawk::ScriptCollection* collection = qobject_cast< Tomahawk::ScriptCollection* >( m_collection.data() );
    if ( collection == 0 )
    {
        reportFailure();
        return;
    }

    ScriptJob* job;
    if( m_album )
    {
        QVariantMap arguments;
        arguments[ "artist" ] = m_album->artist()->name();
        arguments[ "album" ] = m_album->name();

        job = collection->scriptObject()->invoke( "albumTracks", arguments );
    }
    else
    {
        job = collection->scriptObject()->invoke( "tracks" );
    }


    connect( job, SIGNAL( done( QVariantMap ) ), SLOT( onTracksJobDone( QVariantMap ) ), Qt::QueuedConnection );
    job->start();
}
void
ScriptCommand_AllTracks::enqueue()
{
    Tomahawk::ScriptCollection* collection = qobject_cast< Tomahawk::ScriptCollection* >( m_collection.data() );
    if ( collection == 0 )
    {
        emit tracks( QList< Tomahawk::query_ptr >() );
        return;
    }

    collection->resolver()->enqueue( QSharedPointer< ScriptCommand >( this ) );
}
void
ScriptCommand_AllArtists::exec()
{
    Tomahawk::ScriptCollection* collection = qobject_cast< Tomahawk::ScriptCollection* >( m_collection.data() );
    Q_ASSERT( collection );

    QVariantMap arguments;
    if ( !m_filter.isEmpty() )
    {
        arguments[ "filter" ] = m_filter;
    }

    ScriptJob* job = collection->scriptObject()->invoke( "artists", arguments );
    connect( job, SIGNAL( done( QVariantMap ) ), SLOT( onArtistsJobDone( QVariantMap ) ), Qt::QueuedConnection );
    job->start();
}
void
ScriptCommand_AllTracks::exec()
{
    Tomahawk::ScriptCollection* collection = qobject_cast< Tomahawk::ScriptCollection* >( m_collection.data() );
    if ( collection == 0 )
    {
        reportFailure();
        return;
    }

    if ( m_album.isNull() )
    {
        reportFailure();
        return;
    }

    connect( collection->resolver(), SIGNAL( tracksFound( QList< Tomahawk::query_ptr > ) ),
             this, SLOT( onResolverDone( QList< Tomahawk::query_ptr > ) ) );

    collection->resolver()->tracks( m_collection, m_album );
}
void
ScriptCommand_AllAlbums::exec()
{
    Tomahawk::ScriptCollection* collection = qobject_cast< Tomahawk::ScriptCollection* >( m_collection.data() );
    if ( collection == 0 )
    {
        reportFailure();
        return;
    }

    if ( !m_artist )
    {
        reportFailure();
        return;
    }

    connect( collection->resolver(), SIGNAL( albumsFound( QList< Tomahawk::album_ptr > ) ),
             this, SLOT( onResolverDone( QList< Tomahawk::album_ptr > ) ) );

    collection->resolver()->albums( m_collection, m_artist );
}
Beispiel #6
0
bool
DownloadJob::download()
{
    if ( m_state == Running )
        return true;
    setState( Running );

    if ( m_result->resolvedByCollection() )
    {
        Tomahawk::ScriptCollection* collection = qobject_cast<Tomahawk::ScriptCollection*>( m_result->resolvedByCollection().data() );
        if ( collection )
        {
            QVariantMap arguments;
            arguments[ "url" ] = m_format.url;

            // HACK: *shrug* WIP.
            Tomahawk::ScriptJob* job = collection->scriptObject()->invoke( "getStreamUrlPromise", arguments );
            connect( job, SIGNAL( done(QVariantMap) ), SLOT( onUrlRetrieved(QVariantMap) ) );
            job->start();
        }
    }
    return true;
}