diff options
author | Sandro Knauß <sknauss@kde.org> | 2017-01-30 13:55:38 +0100 |
---|---|---|
committer | Sandro Knauß <sknauss@kde.org> | 2017-01-30 13:55:38 +0100 |
commit | 40a77fd82ed659381d836068ebba4af05ec4aae0 (patch) | |
tree | 27e724653b85560df45e22c74de638d4624492bc /examples/davresource/davresource.cpp | |
parent | 67a4e5d32d35afefee88eef365b3e22e3389adfb (diff) | |
download | sink-40a77fd82ed659381d836068ebba4af05ec4aae0.tar.gz sink-40a77fd82ed659381d836068ebba4af05ec4aae0.zip |
make scanForRemovals work
Diffstat (limited to 'examples/davresource/davresource.cpp')
-rw-r--r-- | examples/davresource/davresource.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
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: | |||
298 | }); | 298 | }); |
299 | return job; | 299 | return job; |
300 | } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Contact>()) { | 300 | } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Contact>()) { |
301 | auto ridList = QSharedPointer<QByteArrayList>::create(); | ||
301 | auto collectionsFetchJob = new KDAV::DavCollectionsFetchJob(mResourceUrl); | 302 | auto collectionsFetchJob = new KDAV::DavCollectionsFetchJob(mResourceUrl); |
302 | auto job = runJob(collectionsFetchJob).then<KDAV::DavCollection::List>([this, collectionsFetchJob] { | 303 | auto job = runJob(collectionsFetchJob).then<KDAV::DavCollection::List>([this, collectionsFetchJob] { |
303 | synchronizeAddressbooks(collectionsFetchJob ->collections()); | 304 | synchronizeAddressbooks(collectionsFetchJob ->collections()); |
304 | return collectionsFetchJob->collections(); | 305 | return collectionsFetchJob->collections(); |
305 | }) | 306 | }) |
306 | .serialEach<void>([this](const KDAV::DavCollection &collection) { | 307 | .serialEach<void>([this, ridList](const KDAV::DavCollection &collection) { |
307 | auto collId = collection.url().toDisplayString().toLatin1(); | 308 | auto collId = collection.url().toDisplayString().toLatin1(); |
308 | auto ctag = collection.CTag().toLatin1(); | 309 | auto ctag = collection.CTag().toLatin1(); |
309 | if (ctag != syncStore().readValue(collId + "_ctag")) { | 310 | if (ctag != syncStore().readValue(collId + "_ctag")) { |
@@ -312,11 +313,10 @@ public: | |||
312 | auto davItemsListJob = new KDAV::DavItemsListJob(collection.url(), cache); | 313 | auto davItemsListJob = new KDAV::DavItemsListJob(collection.url(), cache); |
313 | const QByteArray bufferType = ENTITY_TYPE_CONTACT; | 314 | const QByteArray bufferType = ENTITY_TYPE_CONTACT; |
314 | QHash<QByteArray, Query::Comparator> mergeCriteria; | 315 | QHash<QByteArray, Query::Comparator> mergeCriteria; |
315 | QByteArrayList ridList; | ||
316 | auto colljob = runJob(davItemsListJob).then<KDAV::DavItem::List>([davItemsListJob] { | 316 | auto colljob = runJob(davItemsListJob).then<KDAV::DavItem::List>([davItemsListJob] { |
317 | return KAsync::value(davItemsListJob->items()); | 317 | return KAsync::value(davItemsListJob->items()); |
318 | }) | 318 | }) |
319 | .serialEach<QByteArray>([this, &ridList, bufferType, mergeCriteria] (const KDAV::DavItem &item) { | 319 | .serialEach<QByteArray>([this, ridList, bufferType, mergeCriteria] (const KDAV::DavItem &item) { |
320 | QByteArray rid = item.url().toDisplayString().toUtf8(); | 320 | QByteArray rid = item.url().toDisplayString().toUtf8(); |
321 | if (item.etag().toLatin1() != syncStore().readValue(rid + "_etag")){ | 321 | if (item.etag().toLatin1() != syncStore().readValue(rid + "_etag")){ |
322 | SinkTrace() << "Updating " << rid; | 322 | SinkTrace() << "Updating " << rid; |
@@ -330,37 +330,34 @@ public: | |||
330 | createOrModify(bufferType, rid, contact, mergeCriteria); | 330 | createOrModify(bufferType, rid, contact, mergeCriteria); |
331 | return item; | 331 | return item; |
332 | }) | 332 | }) |
333 | .then<QByteArray>([this, &ridList] (const KDAV::DavItem &item) { | 333 | .then<QByteArray>([this, ridList] (const KDAV::DavItem &item) { |
334 | const auto rid = item.url().toDisplayString().toUtf8(); | 334 | const auto rid = item.url().toDisplayString().toUtf8(); |
335 | syncStore().writeValue(rid + "_etag", item.etag().toLatin1()); | 335 | syncStore().writeValue(rid + "_etag", item.etag().toLatin1()); |
336 | //ridList << rid; | 336 | ridList->append(rid); |
337 | return rid; | 337 | return rid; |
338 | }); | 338 | }); |
339 | return itemjob; | 339 | return itemjob; |
340 | } else { | 340 | } else { |
341 | //ridList << rid; | 341 | ridList->append(rid); |
342 | return KAsync::value(rid); | 342 | return KAsync::value(rid); |
343 | } | 343 | } |
344 | }) | 344 | }) |
345 | /*.then<void>([this, ridList, bufferType] () { | ||
346 | scanForRemovals(bufferType, | ||
347 | [&ridList](const QByteArray &remoteId) -> bool { | ||
348 | return ridList.contains(remoteId); | ||
349 | }); | ||
350 | })*/ | ||
351 | /*.then<void>([this, bufferType] (const QByteArrayList &ridList) { | ||
352 | scanForRemovals(bufferType, | ||
353 | [&ridList](const QByteArray &remoteId) -> bool { | ||
354 | return ridList.contains(remoteId); | ||
355 | }); | ||
356 | })*/ | ||
357 | .then<void>([this, collId, ctag] () { | 345 | .then<void>([this, collId, ctag] () { |
358 | syncStore().writeValue(collId + "_ctag", ctag); | 346 | syncStore().writeValue(collId + "_ctag", ctag); |
359 | }); | 347 | }); |
360 | return colljob; | 348 | return colljob; |
361 | } else { | 349 | } else { |
350 | // for(const auto &item : addressbook) { | ||
351 | // ridList->append(rid); | ||
352 | // } | ||
362 | return KAsync::null<void>(); | 353 | return KAsync::null<void>(); |
363 | } | 354 | } |
355 | }) | ||
356 | .then<void>([this, ridList] () { | ||
357 | scanForRemovals(ENTITY_TYPE_CONTACT, | ||
358 | [&ridList](const QByteArray &remoteId) -> bool { | ||
359 | return ridList->contains(remoteId); | ||
360 | }); | ||
364 | }); | 361 | }); |
365 | return job; | 362 | return job; |
366 | } else { | 363 | } else { |