コード例 #1
0
ファイル: sites.cpp プロジェクト: serghei/kde3-kdemultimedia
    QValueList<Mirror>
  Sites::siteList()
  {
    KURL url;
    url.setProtocol( "http" );
    url.setHost( "freedb.freedb.org" );
    url.setPort( 80 );
    url.setPath( "/~cddb/cddb.cgi" );

    url.setQuery( QString::null );

    QString hello = QString("%1 %2 %3 %4")
        .arg(user_, localHostName_, clientName(), clientVersion());

    url.addQueryItem( "cmd", "sites" );
    url.addQueryItem( "hello", hello );
    url.addQueryItem( "proto", "5" );

    QValueList<Mirror> result;

    QString tmpFile;
    if( KIO::NetAccess::download( url, tmpFile, 0 ) )
    {
      result = readFile( tmpFile );
      KIO::NetAccess::removeTempFile( tmpFile );
    }

    return result;
  }
コード例 #2
0
const KURL PublicService::toInvitation(const QString &host)
{
    KURL url;
    url.setProtocol("invitation");
    if(host.isEmpty())
    { // select best address
        unsigned long s_address = publicIP();
        if(!s_address)
            return KURL();
        KNetwork::KIpAddress addr(s_address);
        url.setHost(addr.toString());
    }
    else
        url.setHost(host);
    // FIXME: if there is no public interface, select any non-loopback
    url.setPort(m_port);
    url.setPath("/" + m_type + "/" + KURL::encode_string(m_serviceName));
    QString query;
    QMap< QString, QString >::ConstIterator itEnd = m_textData.end();
    for(QMap< QString, QString >::ConstIterator it = m_textData.begin(); it != itEnd; ++it)
        url.addQueryItem(it.key(), it.data());
    ;
    return url;
}
コード例 #3
0
void HTTPTracker::doRequest(WaitJob* wjob)
{
    const TorrentStats & s = tor->getStats();

    KURL u = url;
    if (!url.isValid())
    {
        requestPending();
        QTimer::singleShot(500,this,SLOT(emitInvalidURLFailure()));
        return;
    }

    Uint16 port = Globals::instance().getServer().getPortInUse();;

    u.addQueryItem("peer_id",peer_id.toString());
    u.addQueryItem("port",QString::number(port));
    u.addQueryItem("uploaded",QString::number(s.trk_bytes_uploaded));
    u.addQueryItem("downloaded",QString::number(s.trk_bytes_downloaded));

    if (event == "completed")
        u.addQueryItem("left","0"); // need to send 0 when we are completed
    else
        u.addQueryItem("left",QString::number(s.bytes_left));

    u.addQueryItem("compact","1");
    if (event != "stopped")
        u.addQueryItem("numwant","100");
    else
        u.addQueryItem("numwant","0");

    u.addQueryItem("key",QString::number(key));
    QString cip = Tracker::getCustomIP();
    if (!cip.isNull())
        u.addQueryItem("ip",cip);

    if (event != QString::null)
        u.addQueryItem("event",event);
    QString epq = u.encodedPathAndQuery();
    const SHA1Hash & info_hash = tor->getInfoHash();
    epq += "&info_hash=" + info_hash.toURLString();


    u.setEncodedPathAndQuery(epq);

    if (active_job)
    {
        announce_queue.append(u);
        Out(SYS_TRK|LOG_NOTICE) << "Announce ongoing, queueing announce" << endl;
    }
    else
    {
        doAnnounce(u);
        // if there is a wait job, add this job to the waitjob
        if (wjob)
            wjob->addExitOperation(new kt::ExitJobOperation(active_job));
    }
}