示例#1
0
void HttpContainer::fetchFinished(KJob *job)
{
    if (!job->error()) {
        // We now set the data on the source with the retrieved data and some
        // additional stats. Note that we don't include the source name, as that
        // is implied as this object *is* the DataContainer. setData is called
        // with just key/value pairs.
        setData("Contents", m_data);
        setData("Size", job->processedAmount(KJob::Bytes));

        // Since we only create TransferJobs, it's safe to just static_cast here.
        // In many real-world situations, this isn't the safest thing to do and a
        // qobject_cast with a test on the result is often safer and cleaner.
        KIO::TransferJob *tjob = static_cast<KIO::TransferJob *>(job);
        setData("Error Page", tjob->isErrorPage());
        setData("Mimetype", tjob->mimetype());

        // Let DataContainer know we have data that needs storing
        setNeedsToBeStored(true);

        // Notify DataContainer that now is a good time to check to see that
        // data has been updated. This will cause visualizations to be updated.
        checkForUpdate();

        // Clean up behind ourselves so there isn't unecessary memory usage
        m_data.clear();
    }
}
示例#2
0
void ShareProvider::onTransferJobResultReceived(KJob* job)
{
    if (d->m_data.size() == 0) {
        Q_EMIT finishedError(this, i18n("Service was not available"));
        return;
    }

    KIO::TransferJob *tfJob = qobject_cast<KIO::TransferJob*>(job);
    if (tfJob) {
        QString mimeType = tfJob->mimetype();
        AbstractSharer *sharer = d->getSharer();

        if (sharer) {
            sharer->parseResponse(d->m_data);
            if (tfJob->isErrorPage() || sharer->hasError()) {
                QString errorMessage = sharer->errorMessage();
                if (!errorMessage.isEmpty()) {
                    Q_EMIT finishedError(this, errorMessage);
                } else {
                    Q_EMIT finishedError(this, tfJob->errorString());
                }
            } else {
                Q_EMIT finishedSuccess(this, sharer->imageUrl().url());
            }
        }
    }
}
示例#3
0
void TestLinkItr::slotJobResult(KJob *job)
{
    kDebug();
    m_job = 0;

    KIO::TransferJob *transfer = static_cast<KIO::TransferJob *>(job);
    const QString modDate = transfer->queryMetaData("modified");

    if (transfer->error() || transfer->isErrorPage()) {
        kDebug()<<"***********"<<transfer->error()<<"  "<<transfer->isErrorPage()<<endl;
        // can we assume that errorString will contain no entities?
        QString err = transfer->errorString();
        err.replace("\n", " ");
        setStatus(err);
    } else {
        if (!modDate.isEmpty())
            setStatus(modDate);
        else
            setStatus(i18n("OK"));
    }

    holder()->addAffectedBookmark(KBookmark::parentAddress(currentBookmark().address()));
    delayedEmitNextOne();
}
示例#4
0
void
OpmlParser::downloadResult( KJob *job )
{
    // parse more data
    continueRead();

    KIO::TransferJob *transferJob = dynamic_cast<KIO::TransferJob *>( job );
    if( job->error() || ( transferJob && transferJob->isErrorPage() ) )
    {
        QString errorMessage =
            i18n( "Reading OPML podcast from %1 failed with error:\n", m_url.url() );
        errorMessage = errorMessage.append( job->errorString() );

//        emit statusBarSorryMessage( errorMessage );
    }

    m_transferJob = 0;
}
示例#5
0
 static bool hasErrorPage(KJob* job)
 {
     KIO::TransferJob* tJob = qobject_cast<KIO::TransferJob*>(job);
     return (tJob && tJob->isErrorPage());
 }