From 26c27fd619857d0945b6c110a863bdc8b4a5e073 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 29 Jun 2017 12:09:11 +0200 Subject: Ported to KDAV2, enabled the dav resource by default. --- examples/davresource/davresource.cpp | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'examples/davresource/davresource.cpp') diff --git a/examples/davresource/davresource.cpp b/examples/davresource/davresource.cpp index 88b7338..1d45f20 100644 --- a/examples/davresource/davresource.cpp +++ b/examples/davresource/davresource.cpp @@ -31,12 +31,12 @@ #include "contactpreprocessor.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include //This is the resources entity type, and not the domain type #define ENTITY_TYPE_CONTACT "contact" @@ -85,7 +85,7 @@ public: return remoteId; } - void synchronizeAddressbooks(const KDAV::DavCollection::List &addressbookList) + void synchronizeAddressbooks(const KDAV2::DavCollection::List &addressbookList) { const QByteArray bufferType = ENTITY_TYPE_ADDRESSBOOK; SinkTrace() << "Found addressbooks " << addressbookList.size(); @@ -119,12 +119,12 @@ public: return list; } - static QByteArray getRid(const KDAV::DavItem &item) + static QByteArray getRid(const KDAV2::DavItem &item) { return item.url().toDisplayString().toUtf8(); } - static QByteArray getRid(const KDAV::DavCollection &item) + static QByteArray getRid(const KDAV2::DavCollection &item) { return item.url().toDisplayString().toUtf8(); } @@ -133,7 +133,7 @@ public: { if (query.type() == ApplicationDomain::getTypeName()) { SinkLogCtx(mLogCtx) << "Synchronizing addressbooks:" << mResourceUrl.url(); - auto collectionsFetchJob = new KDAV::DavCollectionsFetchJob(mResourceUrl); + auto collectionsFetchJob = new KDAV2::DavCollectionsFetchJob(mResourceUrl); auto job = runJob(collectionsFetchJob).then([this, collectionsFetchJob] (const KAsync::Error &error) { if (error) { SinkWarningCtx(mLogCtx) << "Failed to synchronize addressbooks." << collectionsFetchJob->errorString(); @@ -145,29 +145,29 @@ public: } else if (query.type() == ApplicationDomain::getTypeName()) { SinkLogCtx(mLogCtx) << "Synchronizing contacts."; auto ridList = QSharedPointer::create(); - auto collectionsFetchJob = new KDAV::DavCollectionsFetchJob(mResourceUrl); + auto collectionsFetchJob = new KDAV2::DavCollectionsFetchJob(mResourceUrl); auto job = runJob(collectionsFetchJob).then([this, collectionsFetchJob] { synchronizeAddressbooks(collectionsFetchJob ->collections()); return collectionsFetchJob->collections(); }) - .serialEach([this, ridList](const KDAV::DavCollection &collection) { + .serialEach([this, ridList](const KDAV2::DavCollection &collection) { auto collId = getRid(collection); const auto addressbookLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_ADDRESSBOOK, collId); auto ctag = collection.CTag().toLatin1(); if (ctag != syncStore().readValue(collId + "_ctagXX")) { SinkTraceCtx(mLogCtx) << "Syncing " << collId; - auto cache = std::shared_ptr(new KDAV::EtagCache()); - auto davItemsListJob = new KDAV::DavItemsListJob(collection.url(), cache); + auto cache = std::shared_ptr(new KDAV2::EtagCache()); + auto davItemsListJob = new KDAV2::DavItemsListJob(collection.url(), cache); const QByteArray bufferType = ENTITY_TYPE_CONTACT; QHash mergeCriteria; auto colljob = runJob(davItemsListJob).then([davItemsListJob] { return KAsync::value(davItemsListJob->items()); }) - .serialEach([=] (const KDAV::DavItem &item) { + .serialEach([=] (const KDAV2::DavItem &item) { QByteArray rid = getRid(item); if (item.etag().toLatin1() != syncStore().readValue(rid + "_etag")){ SinkTrace() << "Updating " << rid; - auto davItemFetchJob = new KDAV::DavItemFetchJob(item); + auto davItemFetchJob = new KDAV2::DavItemFetchJob(item); auto itemjob = runJob(davItemFetchJob) .then([=] { const auto item = davItemFetchJob->item(); @@ -178,7 +178,7 @@ public: createOrModify(bufferType, rid, contact, mergeCriteria); return item; }) - .then([this, ridList] (const KDAV::DavItem &item) { + .then([this, ridList] (const KDAV2::DavItem &item) { const auto rid = getRid(item); syncStore().writeValue(rid + "_etag", item.etag().toLatin1()); ridList->append(rid); @@ -225,7 +225,7 @@ KAsync::Job replay(const ApplicationDomain::Contact &contact, Sink:: } public: - KDAV::DavUrl mResourceUrl; + KDAV2::DavUrl mResourceUrl; }; @@ -242,7 +242,7 @@ DavResource::DavResource(const Sink::ResourceContext &resourceContext) resourceUrl.setUserName(config.value("username").toString()); resourceUrl.setPassword(config.value("password").toString()); - mResourceUrl = KDAV::DavUrl(resourceUrl, KDAV::CardDav); + mResourceUrl = KDAV2::DavUrl(resourceUrl, KDAV2::CardDav); auto synchronizer = QSharedPointer::create(resourceContext); synchronizer->mResourceUrl = mResourceUrl; -- cgit v1.2.3