summaryrefslogtreecommitdiffstats
path: root/examples/webdavcommon/webdav.h
diff options
context:
space:
mode:
Diffstat (limited to 'examples/webdavcommon/webdav.h')
-rw-r--r--examples/webdavcommon/webdav.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/examples/webdavcommon/webdav.h b/examples/webdavcommon/webdav.h
new file mode 100644
index 0000000..3a4977c
--- /dev/null
+++ b/examples/webdavcommon/webdav.h
@@ -0,0 +1,78 @@
1/*
2 * Copyright (C) 2018 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#pragma once
21
22#include "synchronizer.h"
23
24#include <KDAV2/DavCollection>
25#include <KDAV2/DavItem>
26#include <KDAV2/DavUrl>
27
28class WebDavSynchronizer : public Sink::Synchronizer
29{
30public:
31 WebDavSynchronizer(const Sink::ResourceContext &, KDAV2::Protocol, QByteArray collectionName,
32 QByteArray itemName);
33
34 QList<Synchronizer::SyncRequest> getSyncRequests(const Sink::QueryBase &query) Q_DECL_OVERRIDE;
35 KAsync::Job<void> synchronizeWithSource(const Sink::QueryBase &query) Q_DECL_OVERRIDE;
36
37protected:
38 /**
39 * Called with the list of discovered collections. It's purpose should be
40 * adding the said collections to the store.
41 */
42 virtual void updateLocalCollections(KDAV2::DavCollection::List collections) = 0;
43
44 /**
45 * Called when discovering a new item, or when an item has been modified.
46 * It's purpose should be adding the said item to the store.
47 *
48 * `collectionLocalRid` is the local resource id of the collection the item
49 * is in.
50 */
51 virtual void updateLocalItem(KDAV2::DavItem item, const QByteArray &collectionLocalRid) = 0;
52
53 /**
54 * Get the local resource id from a collection.
55 */
56 virtual QByteArray collectionLocalResourceID(const KDAV2::DavCollection &collection) = 0;
57
58 KAsync::Job<void> synchronizeCollection(const KDAV2::DavCollection &,
59 QSharedPointer<int> progress, QSharedPointer<int> total, QSharedPointer<QSet<QByteArray>> itemsResourceIDs);
60 KAsync::Job<void> synchronizeItem(const KDAV2::DavItem &, const QByteArray &collectionLocalRid,
61 QSharedPointer<int> progress, QSharedPointer<int> total);
62
63 static QByteArray resourceID(const KDAV2::DavCollection &);
64 static QByteArray resourceID(const KDAV2::DavItem &);
65
66 bool unchanged(const KDAV2::DavCollection &);
67 bool unchanged(const KDAV2::DavItem &);
68
69 KDAV2::DavUrl serverUrl() const;
70
71private:
72 KDAV2::Protocol protocol;
73 const QByteArray collectionName;
74 const QByteArray itemName;
75
76 QUrl server;
77 QString username;
78};