Esempio n. 1
0
void ShareProvider::onFinishedReadingFile(KIO::Job* job, const QByteArray& data)
{
    job->disconnect(this);
    qobject_cast<KIO::FileJob *>(job)->close();

    if (data.length() == 0) {
        Q_EMIT finishedError(this, i18n("It was not possible to read the selected file"));
        return;
    }
    
    d->m_data.clear();

    AbstractSharer *sharer = d->getSharer();
    if (sharer) {
        KUrl sharerUrl = sharer->url();
        if (!sharerUrl.isValid()) {
            Q_EMIT finishedError(this, i18n("Service Url is not valid"));
            return;
        }
        KIO::TransferJob *tJob = KIO::http_post(sharer->url(), sharer->postBody(data), KIO::HideProgressInfo);
        tJob->setMetaData(sharer->headers());
        connect(tJob, SIGNAL(data(KIO::Job*,QByteArray)),
                this, SLOT(onTransferJobDataReceived(KIO::Job*,QByteArray)));
        connect(tJob, SIGNAL(result(KJob*)), this, SLOT(onTransferJobResultReceived(KJob*)));

    }
}
Esempio n. 2
0
void KWebPage::downloadRequest(const QNetworkRequest& request)
{
    KIO::TransferJob* job = KIO::get(request.url());
    connect(job, SIGNAL(mimetype(KIO::Job*,QString)),
            this, SLOT(_k_receivedContentType(KIO::Job*,QString)));
    connect(job, SIGNAL(result(KJob*)),
            this, SLOT(_k_receivedContentTypeResult(KJob*)));

    job->setMetaData(request.attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap());
    job->addMetaData(QL1S("MaxCacheSize"), QL1S("0")); // Don't store in http cache.
    job->addMetaData(QL1S("cache"), QL1S("cache")); // Use entry from cache if available.
    job->ui()->setWindow(d->windowWidget());
}