Esempio n. 1
0
void ObjectsRequestJob::davJobFinished(KJob *job)
{
    if (job->error()) {
        setError(job->error());
        setErrorText(job->errorText());
        emitResult();
        return;
    }

    KIO::DavJob *davJob = qobject_cast<KIO::DavJob *>(job);

    const QDomDocument document = davJob->response();

    QString errorText, errorStatus;
    if (DAVUtils::davErrorOccurred(document, errorText, errorStatus)) {
        setError(UserDefinedError);
        setErrorText(errorText);
        emitResult();
        return;
    }

    QDomElement multistatus = document.documentElement();
    QDomElement response = multistatus.firstChildElement(QStringLiteral("response"));
    while (!response.isNull()) {
        const QDomNodeList props = response.elementsByTagName(QStringLiteral("prop"));
        const QDomElement prop = props.at(0).toElement();
        mObjects.append(ObjectUtils::parseObject(prop, mFolder.module()));
        response = response.nextSiblingElement();
    }

    emitResult();
}
Esempio n. 2
0
bool GroupDavGlobals::interpretListItemsJob(KPIM::GroupwareDataAdaptor *adaptor,
        KIO::Job *job)
{
    KIO::DavJob *davjob = dynamic_cast<KIO::DavJob *>(job);

    if(!davjob)
    {
        return false;
    }
    QDomDocument doc = davjob->response();

    kdDebug(7000) << " Doc: " << doc.toString() << endl;
    kdDebug(7000) << " IdMapper: " << adaptor->idMapper()->asString() << endl;

    QDomElement docElem = doc.documentElement();
    QDomNode n = docElem.firstChild();
    while(!n.isNull())
    {
        QDomElement e = n.toElement(); // try to convert the node to an element.
        n = n.nextSibling();
        if(e.isNull())
            continue;

        const KURL &entry(e.namedItem("href").toElement().text());
        QDomElement propstat = e.namedItem("propstat").toElement();
        if(propstat.isNull())
            continue;
        QDomElement prop = propstat.namedItem("prop").toElement();
        if(prop.isNull())
            continue;
        QDomElement elem = prop.namedItem("getetag").toElement();
        const QString &newFingerprint = elem.text();
        if(elem.isNull() || newFingerprint.isEmpty())
            continue;

        KPIM::FolderLister::ContentType type = getContentType(prop);

        adaptor->processDownloadListItem(entry, newFingerprint, type);
    }

    return true;
}