Ejemplo n.º 1
0
UPnpDeviceDesc *UPnpDeviceDesc::Retrieve( QString &sURL, bool bInQtThread )
{
    UPnpDeviceDesc *pDevice = NULL;

    VERBOSE( VB_UPNP, QString( "UPnpDeviceDesc::Retrieve( %1, %2 )" )
                      .arg( sURL ).arg( bInQtThread ));

    QString sXml = HttpComms::getHttp( sURL,
                                       10000, // ms
                                       3,     // retries
                                       0,     // redirects
                                       false, // allow gzip
                                       NULL,  // login
                                       bInQtThread );

    if (sXml.startsWith( QString("<?xml") ))
    {
        QString sErrorMsg;

        QDomDocument xml( "upnp" );

        if ( xml.setContent( sXml, false, &sErrorMsg ))
        {
            pDevice = new UPnpDeviceDesc();

            pDevice->Load( xml );

            pDevice->m_HostUrl   = sURL;
            pDevice->m_sHostName = pDevice->m_HostUrl.host();
        }
        else
        {
            VERBOSE( VB_UPNP,
                     QString( "... Error parsing device description xml [%1]" )
                     .arg( sErrorMsg ));
        }
    }
    else
    {
        VERBOSE( VB_UPNP, QString( "... Invalid response '%1'" ).arg( sXml ));
    }

    return pDevice;
}
Ejemplo n.º 2
0
UPnpDeviceDesc *UPnpDeviceDesc::Retrieve( QString &sURL )
{
    UPnpDeviceDesc *pDevice = nullptr;

    LOG(VB_UPNP, LOG_DEBUG, QString("UPnpDeviceDesc::Retrieve( %1 )")
        .arg(sURL));

    QByteArray buffer;

    bool ok = GetMythDownloadManager()->download(sURL, &buffer);

    QString sXml(buffer);

    if (ok && sXml.startsWith( QString("<?xml") ))
    {
        QString sErrorMsg;

        QDomDocument xml( "upnp" );

        if ( xml.setContent( sXml, false, &sErrorMsg ))
        {
            pDevice = new UPnpDeviceDesc();
            pDevice->Load( xml );
            pDevice->m_HostUrl   = sURL;
            pDevice->m_sHostName = pDevice->m_HostUrl.host();
        }
        else
        {
            LOG(VB_UPNP, LOG_ERR,
                QString("Error parsing device description xml [%1]")
                     .arg(sErrorMsg));
        }
    }
    else
    {
        LOG(VB_UPNP, LOG_ERR, QString("Invalid response '%1'").arg(sXml));
    }

    return pDevice;
}