summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-06-29 12:09:11 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-06-29 12:09:11 +0200
commit26c27fd619857d0945b6c110a863bdc8b4a5e073 (patch)
treefa55eeaa8738f51db85ddf08fa9b9f6d299c374b
parentf3eb08a93f093ebe4ac97221993103c4f12c6212 (diff)
downloadsink-26c27fd619857d0945b6c110a863bdc8b4a5e073.tar.gz
sink-26c27fd619857d0945b6c110a863bdc8b4a5e073.zip
Ported to KDAV2, enabled the dav resource by default.
-rw-r--r--CMakeLists.txt2
-rw-r--r--examples/davresource/CMakeLists.txt4
-rw-r--r--examples/davresource/davresource.cpp38
-rw-r--r--examples/davresource/davresource.h4
4 files changed, 24 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 53716a0..7666a8c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ cmake_policy(SET CMP0028 NEW)
6project(sink VERSION 0.3) 6project(sink VERSION 0.3)
7 7
8option(BUILD_MAILDIR "BUILD_MAILDIR" ON) 8option(BUILD_MAILDIR "BUILD_MAILDIR" ON)
9option(BUILD_DAV "BUILD_DAV" OFF) 9option(BUILD_DAV "BUILD_DAV" ON)
10option(AVOID_BINDING_REBUILD "AVOID_BINDING_REBUILD" OFF) 10option(AVOID_BINDING_REBUILD "AVOID_BINDING_REBUILD" OFF)
11option(CATCH_ERRORS "CATCH_ERRORS" OFF) 11option(CATCH_ERRORS "CATCH_ERRORS" OFF)
12option(ENABLE_MEMCHECK "Build valgrind tests" OFF) 12option(ENABLE_MEMCHECK "Build valgrind tests" OFF)
diff --git a/examples/davresource/CMakeLists.txt b/examples/davresource/CMakeLists.txt
index 28829d5..7091edc 100644
--- a/examples/davresource/CMakeLists.txt
+++ b/examples/davresource/CMakeLists.txt
@@ -3,10 +3,10 @@ project(sink_resource_dav)
3add_definitions(-DQT_PLUGIN) 3add_definitions(-DQT_PLUGIN)
4include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 4include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
5 5
6find_package(KPimKDAV REQUIRED) 6find_package(KPimKDAV2 REQUIRED)
7 7
8add_library(${PROJECT_NAME} SHARED davresource.cpp) 8add_library(${PROJECT_NAME} SHARED davresource.cpp)
9qt5_use_modules(${PROJECT_NAME} Core Network) 9qt5_use_modules(${PROJECT_NAME} Core Network)
10target_link_libraries(${PROJECT_NAME} sink KPim::KDAV) 10target_link_libraries(${PROJECT_NAME} sink KPim::KDAV2)
11 11
12install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${SINK_RESOURCE_PLUGINS_PATH}) 12install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${SINK_RESOURCE_PLUGINS_PATH})
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 @@
31 31
32#include "contactpreprocessor.h" 32#include "contactpreprocessor.h"
33 33
34#include <KDAV/DavCollection> 34#include <KDAV2/DavCollection>
35#include <KDAV/DavCollectionsFetchJob> 35#include <KDAV2/DavCollectionsFetchJob>
36#include <KDAV/DavItem> 36#include <KDAV2/DavItem>
37#include <KDAV/DavItemsListJob> 37#include <KDAV2/DavItemsListJob>
38#include <KDAV/DavItemFetchJob> 38#include <KDAV2/DavItemFetchJob>
39#include <KDAV/EtagCache> 39#include <KDAV2/EtagCache>
40 40
41//This is the resources entity type, and not the domain type 41//This is the resources entity type, and not the domain type
42#define ENTITY_TYPE_CONTACT "contact" 42#define ENTITY_TYPE_CONTACT "contact"
@@ -85,7 +85,7 @@ public:
85 return remoteId; 85 return remoteId;
86 } 86 }
87 87
88 void synchronizeAddressbooks(const KDAV::DavCollection::List &addressbookList) 88 void synchronizeAddressbooks(const KDAV2::DavCollection::List &addressbookList)
89 { 89 {
90 const QByteArray bufferType = ENTITY_TYPE_ADDRESSBOOK; 90 const QByteArray bufferType = ENTITY_TYPE_ADDRESSBOOK;
91 SinkTrace() << "Found addressbooks " << addressbookList.size(); 91 SinkTrace() << "Found addressbooks " << addressbookList.size();
@@ -119,12 +119,12 @@ public:
119 return list; 119 return list;
120 } 120 }
121 121
122 static QByteArray getRid(const KDAV::DavItem &item) 122 static QByteArray getRid(const KDAV2::DavItem &item)
123 { 123 {
124 return item.url().toDisplayString().toUtf8(); 124 return item.url().toDisplayString().toUtf8();
125 } 125 }
126 126
127 static QByteArray getRid(const KDAV::DavCollection &item) 127 static QByteArray getRid(const KDAV2::DavCollection &item)
128 { 128 {
129 return item.url().toDisplayString().toUtf8(); 129 return item.url().toDisplayString().toUtf8();
130 } 130 }
@@ -133,7 +133,7 @@ public:
133 { 133 {
134 if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Addressbook>()) { 134 if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Addressbook>()) {
135 SinkLogCtx(mLogCtx) << "Synchronizing addressbooks:" << mResourceUrl.url(); 135 SinkLogCtx(mLogCtx) << "Synchronizing addressbooks:" << mResourceUrl.url();
136 auto collectionsFetchJob = new KDAV::DavCollectionsFetchJob(mResourceUrl); 136 auto collectionsFetchJob = new KDAV2::DavCollectionsFetchJob(mResourceUrl);
137 auto job = runJob(collectionsFetchJob).then([this, collectionsFetchJob] (const KAsync::Error &error) { 137 auto job = runJob(collectionsFetchJob).then([this, collectionsFetchJob] (const KAsync::Error &error) {
138 if (error) { 138 if (error) {
139 SinkWarningCtx(mLogCtx) << "Failed to synchronize addressbooks." << collectionsFetchJob->errorString(); 139 SinkWarningCtx(mLogCtx) << "Failed to synchronize addressbooks." << collectionsFetchJob->errorString();
@@ -145,29 +145,29 @@ public:
145 } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Contact>()) { 145 } else if (query.type() == ApplicationDomain::getTypeName<ApplicationDomain::Contact>()) {
146 SinkLogCtx(mLogCtx) << "Synchronizing contacts."; 146 SinkLogCtx(mLogCtx) << "Synchronizing contacts.";
147 auto ridList = QSharedPointer<QByteArrayList>::create(); 147 auto ridList = QSharedPointer<QByteArrayList>::create();
148 auto collectionsFetchJob = new KDAV::DavCollectionsFetchJob(mResourceUrl); 148 auto collectionsFetchJob = new KDAV2::DavCollectionsFetchJob(mResourceUrl);
149 auto job = runJob(collectionsFetchJob).then([this, collectionsFetchJob] { 149 auto job = runJob(collectionsFetchJob).then([this, collectionsFetchJob] {
150 synchronizeAddressbooks(collectionsFetchJob ->collections()); 150 synchronizeAddressbooks(collectionsFetchJob ->collections());
151 return collectionsFetchJob->collections(); 151 return collectionsFetchJob->collections();
152 }) 152 })
153 .serialEach([this, ridList](const KDAV::DavCollection &collection) { 153 .serialEach([this, ridList](const KDAV2::DavCollection &collection) {
154 auto collId = getRid(collection); 154 auto collId = getRid(collection);
155 const auto addressbookLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_ADDRESSBOOK, collId); 155 const auto addressbookLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_ADDRESSBOOK, collId);
156 auto ctag = collection.CTag().toLatin1(); 156 auto ctag = collection.CTag().toLatin1();
157 if (ctag != syncStore().readValue(collId + "_ctagXX")) { 157 if (ctag != syncStore().readValue(collId + "_ctagXX")) {
158 SinkTraceCtx(mLogCtx) << "Syncing " << collId; 158 SinkTraceCtx(mLogCtx) << "Syncing " << collId;
159 auto cache = std::shared_ptr<KDAV::EtagCache>(new KDAV::EtagCache()); 159 auto cache = std::shared_ptr<KDAV2::EtagCache>(new KDAV2::EtagCache());
160 auto davItemsListJob = new KDAV::DavItemsListJob(collection.url(), cache); 160 auto davItemsListJob = new KDAV2::DavItemsListJob(collection.url(), cache);
161 const QByteArray bufferType = ENTITY_TYPE_CONTACT; 161 const QByteArray bufferType = ENTITY_TYPE_CONTACT;
162 QHash<QByteArray, Query::Comparator> mergeCriteria; 162 QHash<QByteArray, Query::Comparator> mergeCriteria;
163 auto colljob = runJob(davItemsListJob).then([davItemsListJob] { 163 auto colljob = runJob(davItemsListJob).then([davItemsListJob] {
164 return KAsync::value(davItemsListJob->items()); 164 return KAsync::value(davItemsListJob->items());
165 }) 165 })
166 .serialEach([=] (const KDAV::DavItem &item) { 166 .serialEach([=] (const KDAV2::DavItem &item) {
167 QByteArray rid = getRid(item); 167 QByteArray rid = getRid(item);
168 if (item.etag().toLatin1() != syncStore().readValue(rid + "_etag")){ 168 if (item.etag().toLatin1() != syncStore().readValue(rid + "_etag")){
169 SinkTrace() << "Updating " << rid; 169 SinkTrace() << "Updating " << rid;
170 auto davItemFetchJob = new KDAV::DavItemFetchJob(item); 170 auto davItemFetchJob = new KDAV2::DavItemFetchJob(item);
171 auto itemjob = runJob(davItemFetchJob) 171 auto itemjob = runJob(davItemFetchJob)
172 .then([=] { 172 .then([=] {
173 const auto item = davItemFetchJob->item(); 173 const auto item = davItemFetchJob->item();
@@ -178,7 +178,7 @@ public:
178 createOrModify(bufferType, rid, contact, mergeCriteria); 178 createOrModify(bufferType, rid, contact, mergeCriteria);
179 return item; 179 return item;
180 }) 180 })
181 .then([this, ridList] (const KDAV::DavItem &item) { 181 .then([this, ridList] (const KDAV2::DavItem &item) {
182 const auto rid = getRid(item); 182 const auto rid = getRid(item);
183 syncStore().writeValue(rid + "_etag", item.etag().toLatin1()); 183 syncStore().writeValue(rid + "_etag", item.etag().toLatin1());
184 ridList->append(rid); 184 ridList->append(rid);
@@ -225,7 +225,7 @@ KAsync::Job<QByteArray> replay(const ApplicationDomain::Contact &contact, Sink::
225 } 225 }
226 226
227public: 227public:
228 KDAV::DavUrl mResourceUrl; 228 KDAV2::DavUrl mResourceUrl;
229}; 229};
230 230
231 231
@@ -242,7 +242,7 @@ DavResource::DavResource(const Sink::ResourceContext &resourceContext)
242 resourceUrl.setUserName(config.value("username").toString()); 242 resourceUrl.setUserName(config.value("username").toString());
243 resourceUrl.setPassword(config.value("password").toString()); 243 resourceUrl.setPassword(config.value("password").toString());
244 244
245 mResourceUrl = KDAV::DavUrl(resourceUrl, KDAV::CardDav); 245 mResourceUrl = KDAV2::DavUrl(resourceUrl, KDAV2::CardDav);
246 246
247 auto synchronizer = QSharedPointer<ContactSynchronizer>::create(resourceContext); 247 auto synchronizer = QSharedPointer<ContactSynchronizer>::create(resourceContext);
248 synchronizer->mResourceUrl = mResourceUrl; 248 synchronizer->mResourceUrl = mResourceUrl;
diff --git a/examples/davresource/davresource.h b/examples/davresource/davresource.h
index 1ce66ea..db175a4 100644
--- a/examples/davresource/davresource.h
+++ b/examples/davresource/davresource.h
@@ -21,7 +21,7 @@
21 21
22#include "common/genericresource.h" 22#include "common/genericresource.h"
23 23
24#include <KDAV/DavUrl> 24#include <KDAV2/DavUrl>
25#include <KAsync/Async> 25#include <KAsync/Async>
26 26
27#include <flatbuffers/flatbuffers.h> 27#include <flatbuffers/flatbuffers.h>
@@ -48,7 +48,7 @@ public:
48private: 48private:
49 QStringList listAvailableFolders(); 49 QStringList listAvailableFolders();
50 50
51 KDAV::DavUrl mResourceUrl; 51 KDAV2::DavUrl mResourceUrl;
52}; 52};
53 53
54class DavResourceFactory : public Sink::ResourceFactory 54class DavResourceFactory : public Sink::ResourceFactory