void
Reader::contentCodesReceived( int /* id */, bool error )
{
    DEBUG_BLOCK
    ContentFetcher* http = (ContentFetcher*) sender();
    disconnect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(contentCodesReceived(int,bool)) );
    if( error )
    {
        http->deleteLater();
        return;
    }

    QDataStream raw( http->results() );
    Map contentCodes = parse( raw );
    QList<QVariant> root = contentCodes["mccr"].toList();
    if( root.isEmpty() )
        return; //error
    root = root[0].toMap().value( "mdcl" ).toList();
    foreach( QVariant v, root )
    {
        Map entry = v.toMap();
        QString code = entry.value( "mcnm" ).toList().value( 0 ).toString();
        QString name = entry.value( "mcna" ).toList().value( 0 ).toString();
        ContentTypes type = ContentTypes( entry.value( "mcty" ).toList().value( 0 ).toInt() );
        if( !m_codes.contains( code ) && !code.isEmpty() && type > 0 )
        {
            m_codes[code] = Code( name, type );
            debug() << "Added DAAP code" << code << ":" << name << "with type" << type;
        }
    }
Exemple #2
0
void
Reader::updateFinished( int /*id*/, bool error )
{
    DEBUG_BLOCK
    ContentFetcher* http = (ContentFetcher*) sender();
    disconnect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( updateFinished( int, bool ) ) );
    if( error )
    {
        http->deleteLater();
        warning() << "what is going on here? " << http->error();
        return;
    }

    QDataStream raw( http->results() );
    Map updateResults = parse( raw, 0, true );
    if( updateResults["mupd"].toList().isEmpty() )
        return; //error
    if( updateResults["mupd"].toList()[0].toMap()["musr"].toList().isEmpty() )
        return; //error
    m_loginString = m_loginString + "&revision-number="  +
            QString::number( updateResults["mupd"].toList()[0].toMap()["musr"].toList()[0].toInt() );

    connect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( databaseIdFinished( int, bool ) ) );
    http->getDaap( "/databases?" + m_loginString );

}
Exemple #3
0
void
Reader::logoutRequest()
{
    ContentFetcher* http = new ContentFetcher( m_host, m_port, m_password, this, "readerLogoutHttp" );
    connect( http, SIGNAL( httpError( const QString& ) ), this, SLOT( fetchingError( const QString& ) ) );
    connect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( logoutRequest( int, bool ) ) );
    http->getDaap( "/logout?" + m_loginString );
}
void
Reader::loginRequest()
{
    DEBUG_BLOCK
    ContentFetcher* http = new ContentFetcher( m_host, m_port, m_password, this, "readerHttp");
    connect( http, SIGNAL(httpError(QString)), this, SLOT(fetchingError(QString)) );
    connect( http, SIGNAL(requestFinished(int,bool)), this, SLOT(contentCodesReceived(int,bool)) );
    http->getDaap( "/content-codes" );
}
Exemple #5
0
void
Reader::loginRequest()
{
    DEBUG_BLOCK
    ContentFetcher* http = new ContentFetcher( m_host, m_port, m_password, this, "readerHttp");
    connect( http, SIGNAL( httpError( const QString& ) ), this, SLOT( fetchingError( const QString& ) ) );
    connect( http, SIGNAL(  responseHeaderReceived( const QHttpResponseHeader & ) )
            , this, SLOT( loginHeaderReceived( const QHttpResponseHeader & ) ) );
    http->getDaap( "/login" );
}
Exemple #6
0
void
Reader::loginHeaderReceived( const QHttpResponseHeader & resp )
{
    DEBUG_BLOCK
    ContentFetcher* http = (ContentFetcher*) sender();
    disconnect( http, SIGNAL(  responseHeaderReceived( const QHttpResponseHeader & ) )
            , this, SLOT( loginHeaderReceived( const QHttpResponseHeader & ) ) );
    if( resp.statusCode() == 401 /*authorization required*/)
    {
        emit passwordRequired();
        http->deleteLater();
        return;
    }
    connect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( loginFinished( int, bool ) ) );
}
Exemple #7
0
void
Reader::songListFinished( int /*id*/, bool error )
{
    DEBUG_BLOCK
    ContentFetcher* http = (ContentFetcher*) sender();
    disconnect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( songListFinished( int, bool ) ) );
    if( error )
    {
        http->deleteLater();
        return;
    }
    QByteArray result = http->results();
    http->deleteLater();

    ThreadWeaver::Weaver::instance()->enqueue( new WorkerThread( result, this, m_memColl ) );
}
Exemple #8
0
void
Reader::songListFinished( int /*id*/, bool error )
{
    ContentFetcher* http = (ContentFetcher*) sender();
    disconnect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( songListFinished( int, bool ) ) );
    if( error )
    {
        http->deleteLater();
        return;
    }

    Map songResults = parse( http->results(), 0, true );

    SongList result;
    QValueList<QVariant> songList;
    songList = songResults["adbs"].asList()[0].asMap()["mlcl"].asList()[0].asMap()["mlit"].asList();
    debug() << "songList.count() = " << songList.count() << endl;
    QValueList<QVariant>::iterator it;
    for( it = songList.begin(); it != songList.end(); ++it )
    {
        MetaBundle* bundle = new MetaBundle();
        bundle->setTitle( (*it).asMap()["minm"].asList()[0].toString() );
//input url: daap://host:port/databaseId/music.ext
        bundle->setUrl( Amarok::QStringx("daap://%1:%2/%3/%4.%5").args(
            QStringList() << m_host
                        << QString::number( m_port )
                        << m_databaseId
                        << QString::number( (*it).asMap()["miid"].asList()[0].asInt() )
                        << (*it).asMap()["asfm"].asList()[0].asString() ) );
        bundle->setLength( (*it).asMap()["astm"].asList()[0].toInt()/1000 );
        bundle->setTrack( (*it).asMap()["astn"].asList()[0].toInt() );

        QString album = (*it).asMap()["asal"].asList()[0].toString();
        bundle->setAlbum( album );

        QString artist = (*it).asMap()["asar"].asList()[0].toString();
        bundle->setArtist( artist );
        result[ artist.lower() ][ album.lower() ].append(bundle);

        bundle->setYear( (*it).asMap()["asyr"].asList()[0].toInt() );

        bundle->setGenre( (*it).asMap()["asgn"].asList()[0].toString() );
    }
    emit daapBundles( m_host , result );
    http->deleteLater();
}
Exemple #9
0
void
Reader::databaseIdFinished( int /*id*/, bool error )
{
    ContentFetcher* http = (ContentFetcher*) sender();
    disconnect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( databaseIdFinished( int, bool ) ) );
    if( error )
    {
        http->deleteLater();
        return;
    }

    Map dbIdResults = parse( http->results(), 0, true );
    m_databaseId = QString::number( dbIdResults["avdb"].asList()[0].asMap()["mlcl"].asList()[0].asMap()["mlit"].asList()[0].asMap()["miid"].asList()[0].asInt() );
    connect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( songListFinished( int, bool ) ) );
    http->getDaap( QString("/databases/%1/items?type=music&meta=dmap.itemid,dmap.itemname,daap.songformat,daap.songartist,daap.songalbum,daap.songtime,daap.songtracknumber,daap.songcomment,daap.songyear,daap.songgenre&%2")
                .arg( m_databaseId, m_loginString ) );

}
Exemple #10
0
void
Reader::loginFinished( int /* id */, bool error )
{
    DEBUG_BLOCK
    ContentFetcher* http = (ContentFetcher*) sender();
    disconnect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( loginFinished( int, bool ) ) );
    if( error )
    {
        http->deleteLater();
        return;
    }
    Map loginResults = parse( http->results() , 0 ,true );

    m_sessionId = loginResults["mlog"].asList()[0].asMap()["mlid"].asList()[0].asInt();
    m_loginString = "session-id=" + QString::number( m_sessionId );
    connect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( updateFinished( int, bool ) ) );
    http->getDaap( "/update?" + m_loginString );
}
Exemple #11
0
void
Reader::loginFinished( int /* id */, bool error )
{
    DEBUG_BLOCK
    ContentFetcher* http = (ContentFetcher*) sender();
    disconnect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( loginFinished( int, bool ) ) );
    if( error )
    {
        http->deleteLater();
        return;
    }
    QDataStream raw( http->results() );
    Map loginResults = parse( raw , 0 ,true );
    debug() << "list size is " << loginResults["mlog"].toList().size();
    if( loginResults["mlog"].toList().size() == 0 )
        return;
    QVariant tmp = loginResults["mlog"].toList()[0];
    Debug::stamp();
    m_sessionId = tmp.toMap()["mlid"].toList()[0].toInt();
    Debug::stamp();
    m_loginString = "session-id=" + QString::number( m_sessionId );
    connect( http, SIGNAL( requestFinished( int, bool ) ), this, SLOT( updateFinished( int, bool ) ) );
    http->getDaap( "/update?" + m_loginString );
}