diff options
Diffstat (limited to 'examples/webdavcommon/webdav.cpp')
-rw-r--r-- | examples/webdavcommon/webdav.cpp | 83 |
1 files changed, 80 insertions, 3 deletions
diff --git a/examples/webdavcommon/webdav.cpp b/examples/webdavcommon/webdav.cpp index ad1af35..f97a866 100644 --- a/examples/webdavcommon/webdav.cpp +++ b/examples/webdavcommon/webdav.cpp | |||
@@ -22,8 +22,13 @@ | |||
22 | #include "applicationdomaintype.h" | 22 | #include "applicationdomaintype.h" |
23 | #include "resourceconfig.h" | 23 | #include "resourceconfig.h" |
24 | 24 | ||
25 | #include <KDAV2/DavCollectionDeleteJob> | ||
26 | #include <KDAV2/DavCollectionModifyJob> | ||
25 | #include <KDAV2/DavCollectionsFetchJob> | 27 | #include <KDAV2/DavCollectionsFetchJob> |
28 | #include <KDAV2/DavItemCreateJob> | ||
29 | #include <KDAV2/DavItemDeleteJob> | ||
26 | #include <KDAV2/DavItemFetchJob> | 30 | #include <KDAV2/DavItemFetchJob> |
31 | #include <KDAV2/DavItemModifyJob> | ||
27 | #include <KDAV2/DavItemsListJob> | 32 | #include <KDAV2/DavItemsListJob> |
28 | #include <KDAV2/EtagCache> | 33 | #include <KDAV2/EtagCache> |
29 | 34 | ||
@@ -180,7 +185,6 @@ KAsync::Job<void> WebDavSynchronizer::synchronizeCollection(const KDAV2::DavColl | |||
180 | 185 | ||
181 | auto localRid = collectionLocalResourceID(collection); | 186 | auto localRid = collectionLocalResourceID(collection); |
182 | 187 | ||
183 | // The ETag cache is useless here, since `sinkStore()` IS the cache. | ||
184 | auto cache = std::make_shared<KDAV2::EtagCache>(); | 188 | auto cache = std::make_shared<KDAV2::EtagCache>(); |
185 | auto davItemsListJob = new KDAV2::DavItemsListJob(collection.url(), std::move(cache)); | 189 | auto davItemsListJob = new KDAV2::DavItemsListJob(collection.url(), std::move(cache)); |
186 | 190 | ||
@@ -234,14 +238,87 @@ KAsync::Job<void> WebDavSynchronizer::synchronizeItem(const KDAV2::DavItem &item | |||
234 | }); | 238 | }); |
235 | } | 239 | } |
236 | 240 | ||
241 | KAsync::Job<void> WebDavSynchronizer::createItem(const KDAV2::DavItem &item) | ||
242 | { | ||
243 | auto job = new KDAV2::DavItemCreateJob(item); | ||
244 | return runJob(job).then([] { | ||
245 | SinkLog() << "Done creating item"; | ||
246 | }); | ||
247 | } | ||
248 | |||
249 | KAsync::Job<void> WebDavSynchronizer::removeItem(const KDAV2::DavItem &item) | ||
250 | { | ||
251 | auto job = new KDAV2::DavItemDeleteJob(item); | ||
252 | return runJob(job).then([] { | ||
253 | SinkLog() << "Done removing item"; | ||
254 | }); | ||
255 | } | ||
256 | |||
257 | KAsync::Job<void> WebDavSynchronizer::modifyItem(const KDAV2::DavItem &item) | ||
258 | { | ||
259 | auto job = new KDAV2::DavItemModifyJob(item); | ||
260 | return runJob(job).then([] { | ||
261 | SinkLog() << "Done modifying item"; | ||
262 | }); | ||
263 | } | ||
264 | |||
265 | /* | ||
266 | KAsync::Job<void> WebDavSynchronizer::createCollection(const KDAV2::DavCollection &collection) | ||
267 | { | ||
268 | auto job = new KDAV2::DavCollectionCreateJob(collection); | ||
269 | return runJob(job); | ||
270 | } | ||
271 | */ | ||
272 | |||
273 | KAsync::Job<void> WebDavSynchronizer::removeCollection(const KDAV2::DavUrl &url) | ||
274 | { | ||
275 | auto job = new KDAV2::DavCollectionDeleteJob(url); | ||
276 | return runJob(job); | ||
277 | } | ||
278 | |||
279 | KAsync::Job<void> WebDavSynchronizer::modifyCollection(const KDAV2::DavUrl &url) | ||
280 | { | ||
281 | auto job = new KDAV2::DavCollectionModifyJob(url); | ||
282 | return runJob(job); | ||
283 | } | ||
284 | |||
285 | /* | ||
286 | KAsync::Job<QByteArray> WebDavSynchronizer::replay(const Contact &, Sink::Operation operation, | ||
287 | const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) | ||
288 | { | ||
289 | return replayItem(Sink::ApplicationDomain::getTypeName<Contact>(), operation, oldRemoteId, | ||
290 | changedProperties); | ||
291 | } | ||
292 | |||
293 | KAsync::Job<QByteArray> WebDavSynchronizer::replay(const Addressbook &, Sink::Operation operation, | ||
294 | const QByteArray &oldRemoteId, const QList<QByteArray> &changedProperties) | ||
295 | { | ||
296 | return replayCollection(Sink::ApplicationDomain::getTypeName<Addressbook>(), operation, | ||
297 | oldRemoteId, changedProperties); | ||
298 | } | ||
299 | */ | ||
300 | |||
237 | QByteArray WebDavSynchronizer::resourceID(const KDAV2::DavCollection &collection) | 301 | QByteArray WebDavSynchronizer::resourceID(const KDAV2::DavCollection &collection) |
238 | { | 302 | { |
239 | return collection.url().toDisplayString().toUtf8(); | 303 | return collection.url().url().toEncoded(); |
240 | } | 304 | } |
241 | 305 | ||
242 | QByteArray WebDavSynchronizer::resourceID(const KDAV2::DavItem &item) | 306 | QByteArray WebDavSynchronizer::resourceID(const KDAV2::DavItem &item) |
243 | { | 307 | { |
244 | return item.url().toDisplayString().toUtf8(); | 308 | return item.url().url().toEncoded(); |
309 | } | ||
310 | |||
311 | KDAV2::DavUrl WebDavSynchronizer::urlOf(const QByteArray &remoteId) | ||
312 | { | ||
313 | auto url = QUrl::fromEncoded(remoteId); | ||
314 | auto davurl = serverUrl(); | ||
315 | davurl.setUrl(url); | ||
316 | return davurl; | ||
317 | } | ||
318 | |||
319 | KDAV2::DavUrl WebDavSynchronizer::urlOf(const QByteArray &collectionRemoteId, const QString &itemPath) | ||
320 | { | ||
321 | return urlOf(collectionRemoteId + "/" + itemPath.toUtf8()); | ||
245 | } | 322 | } |
246 | 323 | ||
247 | bool WebDavSynchronizer::unchanged(const KDAV2::DavCollection &collection) | 324 | bool WebDavSynchronizer::unchanged(const KDAV2::DavCollection &collection) |