From 40a77fd82ed659381d836068ebba4af05ec4aae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Mon, 30 Jan 2017 13:55:38 +0100 Subject: make scanForRemovals work --- examples/davresource/davresource.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'examples/davresource') diff --git a/examples/davresource/davresource.cpp b/examples/davresource/davresource.cpp index c5beb1c..24529e0 100644 --- a/examples/davresource/davresource.cpp +++ b/examples/davresource/davresource.cpp @@ -298,12 +298,13 @@ public: }); return job; } else if (query.type() == ApplicationDomain::getTypeName()) { + auto ridList = QSharedPointer::create(); auto collectionsFetchJob = new KDAV::DavCollectionsFetchJob(mResourceUrl); auto job = runJob(collectionsFetchJob).then([this, collectionsFetchJob] { synchronizeAddressbooks(collectionsFetchJob ->collections()); return collectionsFetchJob->collections(); }) - .serialEach([this](const KDAV::DavCollection &collection) { + .serialEach([this, ridList](const KDAV::DavCollection &collection) { auto collId = collection.url().toDisplayString().toLatin1(); auto ctag = collection.CTag().toLatin1(); if (ctag != syncStore().readValue(collId + "_ctag")) { @@ -312,11 +313,10 @@ public: auto davItemsListJob = new KDAV::DavItemsListJob(collection.url(), cache); const QByteArray bufferType = ENTITY_TYPE_CONTACT; QHash mergeCriteria; - QByteArrayList ridList; auto colljob = runJob(davItemsListJob).then([davItemsListJob] { return KAsync::value(davItemsListJob->items()); }) - .serialEach([this, &ridList, bufferType, mergeCriteria] (const KDAV::DavItem &item) { + .serialEach([this, ridList, bufferType, mergeCriteria] (const KDAV::DavItem &item) { QByteArray rid = item.url().toDisplayString().toUtf8(); if (item.etag().toLatin1() != syncStore().readValue(rid + "_etag")){ SinkTrace() << "Updating " << rid; @@ -330,37 +330,34 @@ public: createOrModify(bufferType, rid, contact, mergeCriteria); return item; }) - .then([this, &ridList] (const KDAV::DavItem &item) { + .then([this, ridList] (const KDAV::DavItem &item) { const auto rid = item.url().toDisplayString().toUtf8(); syncStore().writeValue(rid + "_etag", item.etag().toLatin1()); - //ridList << rid; + ridList->append(rid); return rid; }); return itemjob; } else { - //ridList << rid; + ridList->append(rid); return KAsync::value(rid); } }) - /*.then([this, ridList, bufferType] () { - scanForRemovals(bufferType, - [&ridList](const QByteArray &remoteId) -> bool { - return ridList.contains(remoteId); - }); - })*/ - /*.then([this, bufferType] (const QByteArrayList &ridList) { - scanForRemovals(bufferType, - [&ridList](const QByteArray &remoteId) -> bool { - return ridList.contains(remoteId); - }); - })*/ .then([this, collId, ctag] () { syncStore().writeValue(collId + "_ctag", ctag); }); return colljob; } else { + // for(const auto &item : addressbook) { + // ridList->append(rid); + // } return KAsync::null(); } + }) + .then([this, ridList] () { + scanForRemovals(ENTITY_TYPE_CONTACT, + [&ridList](const QByteArray &remoteId) -> bool { + return ridList->contains(remoteId); + }); }); return job; } else { -- cgit v1.2.3