diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-01-20 19:07:07 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-01-20 19:07:07 +0100 |
commit | bdb01c2c068df326f5a8328ed1492ab1bea388c5 (patch) | |
tree | 25c2ee1b29bc481b6914c244ed9ca194b1415d16 /common | |
parent | 17e7ee40c9185c0505883853345fd6024c675b1a (diff) | |
download | sink-bdb01c2c068df326f5a8328ed1492ab1bea388c5.tar.gz sink-bdb01c2c068df326f5a8328ed1492ab1bea388c5.zip |
Renamed Akonadi2 to Sink
(except for documentation).
Diffstat (limited to 'common')
82 files changed, 642 insertions, 642 deletions
diff --git a/common/Akonadi2CommonConfig.cmake.in b/common/Akonadi2CommonConfig.cmake.in deleted file mode 100644 index ae0aefc..0000000 --- a/common/Akonadi2CommonConfig.cmake.in +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | @PACKAGE_INIT@ | ||
2 | |||
3 | find_dependency(KF5Mime "@KMIME_LIB_VERSION@") | ||
4 | |||
5 | include("${CMAKE_CURRENT_LIST_DIR}/Akonadi2CommonTargets.cmake") | ||
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 06b2af6..e9cf78f 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt | |||
@@ -1,31 +1,31 @@ | |||
1 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) | 1 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
2 | include_directories(domain) | 2 | include_directories(domain) |
3 | 3 | ||
4 | project(akonadi2common) | 4 | project(sinkcommon) |
5 | 5 | ||
6 | ecm_setup_version("0.1" VARIABLE_PREFIX Akonadi2Common | 6 | ecm_setup_version("0.1" VARIABLE_PREFIX SinkCommon |
7 | VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/akonadi2common_version.h" | 7 | VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/sinkcommon_version.h" |
8 | PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/Akonadi2CommonConfigVersion.cmake" | 8 | PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/SinkCommonConfigVersion.cmake" |
9 | SOVERSION 0 | 9 | SOVERSION 0 |
10 | ) | 10 | ) |
11 | 11 | ||
12 | ########### CMake Config Files ########### | 12 | ########### CMake Config Files ########### |
13 | set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/Akonadi2Common") | 13 | set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/SinkCommon") |
14 | 14 | ||
15 | ecm_configure_package_config_file( | 15 | ecm_configure_package_config_file( |
16 | "${CMAKE_CURRENT_SOURCE_DIR}/Akonadi2CommonConfig.cmake.in" | 16 | "${CMAKE_CURRENT_SOURCE_DIR}/SinkCommonConfig.cmake.in" |
17 | "${CMAKE_CURRENT_BINARY_DIR}/Akonadi2CommonConfig.cmake" | 17 | "${CMAKE_CURRENT_BINARY_DIR}/SinkCommonConfig.cmake" |
18 | INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} | 18 | INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} |
19 | ) | 19 | ) |
20 | 20 | ||
21 | install(FILES | 21 | install(FILES |
22 | "${CMAKE_CURRENT_BINARY_DIR}/Akonadi2CommonConfig.cmake" | 22 | "${CMAKE_CURRENT_BINARY_DIR}/SinkCommonConfig.cmake" |
23 | "${CMAKE_CURRENT_BINARY_DIR}/Akonadi2CommonConfigVersion.cmake" | 23 | "${CMAKE_CURRENT_BINARY_DIR}/SinkCommonConfigVersion.cmake" |
24 | DESTINATION "${CMAKECONFIG_INSTALL_DIR}" | 24 | DESTINATION "${CMAKECONFIG_INSTALL_DIR}" |
25 | COMPONENT Devel | 25 | COMPONENT Devel |
26 | ) | 26 | ) |
27 | 27 | ||
28 | install(EXPORT Akonadi2CommonTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE Akonadi2CommonTargets.cmake NAMESPACE KF5::) | 28 | install(EXPORT SinkCommonTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE SinkCommonTargets.cmake NAMESPACE KF5::) |
29 | 29 | ||
30 | set(storage_SRCS storage_lmdb.cpp) | 30 | set(storage_SRCS storage_lmdb.cpp) |
31 | set(storage_LIBS lmdb) | 31 | set(storage_LIBS lmdb) |
@@ -85,7 +85,7 @@ generate_flatbuffers( | |||
85 | queuedcommand | 85 | queuedcommand |
86 | ) | 86 | ) |
87 | 87 | ||
88 | generate_export_header(${PROJECT_NAME} BASE_NAME Akonadi2Common EXPORT_FILE_NAME akonadi2common_export.h) | 88 | generate_export_header(${PROJECT_NAME} BASE_NAME SinkCommon EXPORT_FILE_NAME sinkcommon_export.h) |
89 | SET_TARGET_PROPERTIES(${PROJECT_NAME} | 89 | SET_TARGET_PROPERTIES(${PROJECT_NAME} |
90 | PROPERTIES LINKER_LANGUAGE CXX | 90 | PROPERTIES LINKER_LANGUAGE CXX |
91 | VERSION "0.1" | 91 | VERSION "0.1" |
@@ -95,7 +95,7 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} | |||
95 | qt5_use_modules(${PROJECT_NAME} Network) | 95 | qt5_use_modules(${PROJECT_NAME} Network) |
96 | target_link_libraries(${PROJECT_NAME} ${storage_LIBS} KF5::Async) | 96 | target_link_libraries(${PROJECT_NAME} ${storage_LIBS} KF5::Async) |
97 | install(TARGETS ${PROJECT_NAME} | 97 | install(TARGETS ${PROJECT_NAME} |
98 | EXPORT Akonadi2CommonTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ${LIBRARY_NAMELINK} ) | 98 | EXPORT SinkCommonTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ${LIBRARY_NAMELINK} ) |
99 | 99 | ||
100 | install(FILES | 100 | install(FILES |
101 | clientapi.h | 101 | clientapi.h |
diff --git a/common/SinkCommonConfig.cmake.in b/common/SinkCommonConfig.cmake.in new file mode 100644 index 0000000..6c2a1c2 --- /dev/null +++ b/common/SinkCommonConfig.cmake.in | |||
@@ -0,0 +1,5 @@ | |||
1 | @PACKAGE_INIT@ | ||
2 | |||
3 | find_dependency(KF5Mime "@KMIME_LIB_VERSION@") | ||
4 | |||
5 | include("${CMAKE_CURRENT_LIST_DIR}/SinkCommonTargets.cmake") | ||
diff --git a/common/bufferadaptor.h b/common/bufferadaptor.h index aaff1c2..892635f 100644 --- a/common/bufferadaptor.h +++ b/common/bufferadaptor.h | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <QByteArray> | 23 | #include <QByteArray> |
24 | #include <QHash> | 24 | #include <QHash> |
25 | 25 | ||
26 | namespace Akonadi2 { | 26 | namespace Sink { |
27 | 27 | ||
28 | namespace ApplicationDomain { | 28 | namespace ApplicationDomain { |
29 | 29 | ||
diff --git a/common/bufferutils.h b/common/bufferutils.h index b0fb75a..b08b7f8 100644 --- a/common/bufferutils.h +++ b/common/bufferutils.h | |||
@@ -3,7 +3,7 @@ | |||
3 | #include <flatbuffers/flatbuffers.h> | 3 | #include <flatbuffers/flatbuffers.h> |
4 | #include <QByteArray> | 4 | #include <QByteArray> |
5 | 5 | ||
6 | namespace Akonadi2 { | 6 | namespace Sink { |
7 | namespace BufferUtils { | 7 | namespace BufferUtils { |
8 | template<typename T> | 8 | template<typename T> |
9 | static QByteArray extractBuffer(const T *data) | 9 | static QByteArray extractBuffer(const T *data) |
diff --git a/common/clientapi.cpp b/common/clientapi.cpp index 824ef19..be9f3fd 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp | |||
@@ -39,23 +39,23 @@ | |||
39 | #include "storage.h" | 39 | #include "storage.h" |
40 | #include "log.h" | 40 | #include "log.h" |
41 | 41 | ||
42 | namespace Akonadi2 | 42 | namespace Sink |
43 | { | 43 | { |
44 | 44 | ||
45 | QString Store::storageLocation() | 45 | QString Store::storageLocation() |
46 | { | 46 | { |
47 | return Akonadi2::storageLocation(); | 47 | return Sink::storageLocation(); |
48 | } | 48 | } |
49 | 49 | ||
50 | QByteArray Store::resourceName(const QByteArray &instanceIdentifier) | 50 | QByteArray Store::resourceName(const QByteArray &instanceIdentifier) |
51 | { | 51 | { |
52 | return Akonadi2::resourceName(instanceIdentifier); | 52 | return Sink::resourceName(instanceIdentifier); |
53 | } | 53 | } |
54 | 54 | ||
55 | static QList<QByteArray> getResources(const QList<QByteArray> &resourceFilter, const QByteArray &type) | 55 | static QList<QByteArray> getResources(const QList<QByteArray> &resourceFilter, const QByteArray &type) |
56 | { | 56 | { |
57 | //Return the global resource (signified by an empty name) for types that don't eblong to a specific resource | 57 | //Return the global resource (signified by an empty name) for types that don't eblong to a specific resource |
58 | if (type == "akonadiresource") { | 58 | if (type == "sinkresource") { |
59 | return QList<QByteArray>() << ""; | 59 | return QList<QByteArray>() << ""; |
60 | } | 60 | } |
61 | QList<QByteArray> resources; | 61 | QList<QByteArray> resources; |
@@ -162,9 +162,9 @@ KAsync::Job<void> Store::shutdown(const QByteArray &identifier) | |||
162 | return ResourceAccess::connectToServer(identifier).then<void, QSharedPointer<QLocalSocket>>([identifier](QSharedPointer<QLocalSocket> socket, KAsync::Future<void> &future) { | 162 | return ResourceAccess::connectToServer(identifier).then<void, QSharedPointer<QLocalSocket>>([identifier](QSharedPointer<QLocalSocket> socket, KAsync::Future<void> &future) { |
163 | //We can't currently reuse the socket | 163 | //We can't currently reuse the socket |
164 | socket->close(); | 164 | socket->close(); |
165 | auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(identifier); | 165 | auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(identifier); |
166 | resourceAccess->open(); | 166 | resourceAccess->open(); |
167 | resourceAccess->sendCommand(Akonadi2::Commands::ShutdownCommand).then<void>([&future, resourceAccess]() { | 167 | resourceAccess->sendCommand(Sink::Commands::ShutdownCommand).then<void>([&future, resourceAccess]() { |
168 | Trace() << "Shutdown complete"; | 168 | Trace() << "Shutdown complete"; |
169 | future.setFinished(); | 169 | future.setFinished(); |
170 | }).exec(); | 170 | }).exec(); |
@@ -180,9 +180,9 @@ KAsync::Job<void> Store::shutdown(const QByteArray &identifier) | |||
180 | KAsync::Job<void> Store::start(const QByteArray &identifier) | 180 | KAsync::Job<void> Store::start(const QByteArray &identifier) |
181 | { | 181 | { |
182 | Trace() << "start " << identifier; | 182 | Trace() << "start " << identifier; |
183 | auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(identifier); | 183 | auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(identifier); |
184 | resourceAccess->open(); | 184 | resourceAccess->open(); |
185 | return resourceAccess->sendCommand(Akonadi2::Commands::PingCommand).then<void>([resourceAccess]() { | 185 | return resourceAccess->sendCommand(Sink::Commands::PingCommand).then<void>([resourceAccess]() { |
186 | Trace() << "Start complete"; | 186 | Trace() << "Start complete"; |
187 | }); | 187 | }); |
188 | } | 188 | } |
@@ -191,19 +191,19 @@ void Store::removeFromDisk(const QByteArray &identifier) | |||
191 | { | 191 | { |
192 | //TODO By calling the resource executable with a --remove option instead | 192 | //TODO By calling the resource executable with a --remove option instead |
193 | //we can ensure that no other resource process is running at the same time | 193 | //we can ensure that no other resource process is running at the same time |
194 | QDir dir(Akonadi2::storageLocation()); | 194 | QDir dir(Sink::storageLocation()); |
195 | for (const auto &folder : dir.entryList(QStringList() << identifier + "*")) { | 195 | for (const auto &folder : dir.entryList(QStringList() << identifier + "*")) { |
196 | Akonadi2::Storage(Akonadi2::storageLocation(), folder, Akonadi2::Storage::ReadWrite).removeFromDisk(); | 196 | Sink::Storage(Sink::storageLocation(), folder, Sink::Storage::ReadWrite).removeFromDisk(); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | KAsync::Job<void> Store::synchronize(const Akonadi2::Query &query) | 200 | KAsync::Job<void> Store::synchronize(const Sink::Query &query) |
201 | { | 201 | { |
202 | Trace() << "synchronize" << query.resources; | 202 | Trace() << "synchronize" << query.resources; |
203 | return KAsync::iterate(query.resources) | 203 | return KAsync::iterate(query.resources) |
204 | .template each<void, QByteArray>([query](const QByteArray &resource, KAsync::Future<void> &future) { | 204 | .template each<void, QByteArray>([query](const QByteArray &resource, KAsync::Future<void> &future) { |
205 | Trace() << "Synchronizing " << resource; | 205 | Trace() << "Synchronizing " << resource; |
206 | auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(resource); | 206 | auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(resource); |
207 | resourceAccess->open(); | 207 | resourceAccess->open(); |
208 | resourceAccess->synchronizeResource(true, false).then<void>([&future, resourceAccess]() { | 208 | resourceAccess->synchronizeResource(true, false).then<void>([&future, resourceAccess]() { |
209 | future.setFinished(); | 209 | future.setFinished(); |
@@ -219,7 +219,7 @@ KAsync::Job<void> Store::flushMessageQueue(const QByteArrayList &resourceIdentif | |||
219 | return KAsync::iterate(resourceIdentifier) | 219 | return KAsync::iterate(resourceIdentifier) |
220 | .template each<void, QByteArray>([](const QByteArray &resource, KAsync::Future<void> &future) { | 220 | .template each<void, QByteArray>([](const QByteArray &resource, KAsync::Future<void> &future) { |
221 | Trace() << "Flushing message queue " << resource; | 221 | Trace() << "Flushing message queue " << resource; |
222 | auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(resource); | 222 | auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(resource); |
223 | resourceAccess->open(); | 223 | resourceAccess->open(); |
224 | resourceAccess->synchronizeResource(false, true).then<void>([&future, resourceAccess]() { | 224 | resourceAccess->synchronizeResource(false, true).then<void>([&future, resourceAccess]() { |
225 | future.setFinished(); | 225 | future.setFinished(); |
@@ -235,7 +235,7 @@ KAsync::Job<void> Store::flushReplayQueue(const QByteArrayList &resourceIdentifi | |||
235 | } | 235 | } |
236 | 236 | ||
237 | template <class DomainType> | 237 | template <class DomainType> |
238 | KAsync::Job<DomainType> Store::fetchOne(const Akonadi2::Query &query) | 238 | KAsync::Job<DomainType> Store::fetchOne(const Sink::Query &query) |
239 | { | 239 | { |
240 | return KAsync::start<DomainType>([query](KAsync::Future<DomainType> &future) { | 240 | return KAsync::start<DomainType>([query](KAsync::Future<DomainType> &future) { |
241 | //FIXME We could do this more elegantly if composed jobs would have the correct type (In that case we'd simply return the value from then continuation, and could avoid the outer job entirely) | 241 | //FIXME We could do this more elegantly if composed jobs would have the correct type (In that case we'd simply return the value from then continuation, and could avoid the outer job entirely) |
@@ -251,13 +251,13 @@ KAsync::Job<DomainType> Store::fetchOne(const Akonadi2::Query &query) | |||
251 | } | 251 | } |
252 | 252 | ||
253 | template <class DomainType> | 253 | template <class DomainType> |
254 | KAsync::Job<QList<typename DomainType::Ptr> > Store::fetchAll(const Akonadi2::Query &query) | 254 | KAsync::Job<QList<typename DomainType::Ptr> > Store::fetchAll(const Sink::Query &query) |
255 | { | 255 | { |
256 | return fetch<DomainType>(query); | 256 | return fetch<DomainType>(query); |
257 | } | 257 | } |
258 | 258 | ||
259 | template <class DomainType> | 259 | template <class DomainType> |
260 | KAsync::Job<QList<typename DomainType::Ptr> > Store::fetch(const Akonadi2::Query &query, int minimumAmount) | 260 | KAsync::Job<QList<typename DomainType::Ptr> > Store::fetch(const Sink::Query &query, int minimumAmount) |
261 | { | 261 | { |
262 | auto model = loadModel<DomainType>(query); | 262 | auto model = loadModel<DomainType>(query); |
263 | auto list = QSharedPointer<QList<typename DomainType::Ptr> >::create(); | 263 | auto list = QSharedPointer<QList<typename DomainType::Ptr> >::create(); |
@@ -265,12 +265,12 @@ KAsync::Job<QList<typename DomainType::Ptr> > Store::fetch(const Akonadi2::Query | |||
265 | return KAsync::start<QList<typename DomainType::Ptr> >([model, list, context, minimumAmount](KAsync::Future<QList<typename DomainType::Ptr> > &future) { | 265 | return KAsync::start<QList<typename DomainType::Ptr> >([model, list, context, minimumAmount](KAsync::Future<QList<typename DomainType::Ptr> > &future) { |
266 | if (model->rowCount() >= 1) { | 266 | if (model->rowCount() >= 1) { |
267 | for (int i = 0; i < model->rowCount(); i++) { | 267 | for (int i = 0; i < model->rowCount(); i++) { |
268 | list->append(model->index(i, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).template value<typename DomainType::Ptr>()); | 268 | list->append(model->index(i, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).template value<typename DomainType::Ptr>()); |
269 | } | 269 | } |
270 | } else { | 270 | } else { |
271 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, context.data(), [model, &future, list](const QModelIndex &index, int start, int end) { | 271 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, context.data(), [model, &future, list](const QModelIndex &index, int start, int end) { |
272 | for (int i = start; i <= end; i++) { | 272 | for (int i = start; i <= end; i++) { |
273 | list->append(model->index(i, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).template value<typename DomainType::Ptr>()); | 273 | list->append(model->index(i, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).template value<typename DomainType::Ptr>()); |
274 | } | 274 | } |
275 | }); | 275 | }); |
276 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, context.data(), [model, &future, list, minimumAmount](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { | 276 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, context.data(), [model, &future, list, minimumAmount](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { |
@@ -301,9 +301,9 @@ KAsync::Job<void> Resources::inspect(const Inspection &inspectionCommand) | |||
301 | auto resource = inspectionCommand.resourceIdentifier; | 301 | auto resource = inspectionCommand.resourceIdentifier; |
302 | 302 | ||
303 | Trace() << "Sending inspection " << resource; | 303 | Trace() << "Sending inspection " << resource; |
304 | auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(resource); | 304 | auto resourceAccess = QSharedPointer<Sink::ResourceAccess>::create(resource); |
305 | resourceAccess->open(); | 305 | resourceAccess->open(); |
306 | auto notifier = QSharedPointer<Akonadi2::Notifier>::create(resourceAccess); | 306 | auto notifier = QSharedPointer<Sink::Notifier>::create(resourceAccess); |
307 | auto id = QUuid::createUuid().toByteArray(); | 307 | auto id = QUuid::createUuid().toByteArray(); |
308 | return resourceAccess->sendInspectionCommand(id, ApplicationDomain::getTypeName<DomainType>(), inspectionCommand.entityIdentifier, inspectionCommand.property, inspectionCommand.expectedValue) | 308 | return resourceAccess->sendInspectionCommand(id, ApplicationDomain::getTypeName<DomainType>(), inspectionCommand.entityIdentifier, inspectionCommand.property, inspectionCommand.expectedValue) |
309 | .template then<void>([resourceAccess, notifier, id](KAsync::Future<void> &future) { | 309 | .template then<void>([resourceAccess, notifier, id](KAsync::Future<void> &future) { |
@@ -319,7 +319,7 @@ KAsync::Job<void> Resources::inspect(const Inspection &inspectionCommand) | |||
319 | }); | 319 | }); |
320 | } | 320 | } |
321 | 321 | ||
322 | class Akonadi2::Notifier::Private { | 322 | class Sink::Notifier::Private { |
323 | public: | 323 | public: |
324 | Private() | 324 | Private() |
325 | : context(new QObject) | 325 | : context(new QObject) |
@@ -332,7 +332,7 @@ public: | |||
332 | }; | 332 | }; |
333 | 333 | ||
334 | Notifier::Notifier(const QSharedPointer<ResourceAccess> &resourceAccess) | 334 | Notifier::Notifier(const QSharedPointer<ResourceAccess> &resourceAccess) |
335 | : d(new Akonadi2::Notifier::Private) | 335 | : d(new Sink::Notifier::Private) |
336 | { | 336 | { |
337 | QObject::connect(resourceAccess.data(), &ResourceAccess::notification, d->context.data(), [this](const Notification ¬ification) { | 337 | QObject::connect(resourceAccess.data(), &ResourceAccess::notification, d->context.data(), [this](const Notification ¬ification) { |
338 | for (const auto &handler : d->handler) { | 338 | for (const auto &handler : d->handler) { |
@@ -359,7 +359,7 @@ void Notifier::registerHandler(std::function<void(const Notification &)> handler | |||
359 | REGISTER_TYPE(ApplicationDomain::Event); | 359 | REGISTER_TYPE(ApplicationDomain::Event); |
360 | REGISTER_TYPE(ApplicationDomain::Mail); | 360 | REGISTER_TYPE(ApplicationDomain::Mail); |
361 | REGISTER_TYPE(ApplicationDomain::Folder); | 361 | REGISTER_TYPE(ApplicationDomain::Folder); |
362 | REGISTER_TYPE(ApplicationDomain::AkonadiResource); | 362 | REGISTER_TYPE(ApplicationDomain::SinkResource); |
363 | 363 | ||
364 | } // namespace Akonadi2 | 364 | } // namespace Sink |
365 | 365 | ||
diff --git a/common/clientapi.h b/common/clientapi.h index 06376c2..64c4f64 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | class QAbstractItemModel; | 32 | class QAbstractItemModel; |
33 | 33 | ||
34 | namespace Akonadi2 { | 34 | namespace Sink { |
35 | class ResourceAccess; | 35 | class ResourceAccess; |
36 | class Notification; | 36 | class Notification; |
37 | 37 | ||
@@ -78,7 +78,7 @@ public: | |||
78 | /** | 78 | /** |
79 | * Synchronize data to local cache. | 79 | * Synchronize data to local cache. |
80 | */ | 80 | */ |
81 | static KAsync::Job<void> synchronize(const Akonadi2::Query &query); | 81 | static KAsync::Job<void> synchronize(const Sink::Query &query); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Shutdown resource. | 84 | * Shutdown resource. |
@@ -110,13 +110,13 @@ public: | |||
110 | static void removeFromDisk(const QByteArray &resourceIdentifier); | 110 | static void removeFromDisk(const QByteArray &resourceIdentifier); |
111 | 111 | ||
112 | template <class DomainType> | 112 | template <class DomainType> |
113 | static KAsync::Job<DomainType> fetchOne(const Akonadi2::Query &query); | 113 | static KAsync::Job<DomainType> fetchOne(const Sink::Query &query); |
114 | 114 | ||
115 | template <class DomainType> | 115 | template <class DomainType> |
116 | static KAsync::Job<QList<typename DomainType::Ptr> > fetchAll(const Akonadi2::Query &query); | 116 | static KAsync::Job<QList<typename DomainType::Ptr> > fetchAll(const Sink::Query &query); |
117 | 117 | ||
118 | template <class DomainType> | 118 | template <class DomainType> |
119 | static KAsync::Job<QList<typename DomainType::Ptr> > fetch(const Akonadi2::Query &query, int minimumAmount = 0); | 119 | static KAsync::Job<QList<typename DomainType::Ptr> > fetch(const Sink::Query &query, int minimumAmount = 0); |
120 | }; | 120 | }; |
121 | 121 | ||
122 | namespace Resources { | 122 | namespace Resources { |
diff --git a/common/commands.cpp b/common/commands.cpp index 35dfb13..8b915f0 100644 --- a/common/commands.cpp +++ b/common/commands.cpp | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | #include <QIODevice> | 23 | #include <QIODevice> |
24 | 24 | ||
25 | namespace Akonadi2 | 25 | namespace Sink |
26 | { | 26 | { |
27 | 27 | ||
28 | namespace Commands | 28 | namespace Commands |
@@ -102,4 +102,4 @@ void write(QIODevice *device, int messageId, int commandId, flatbuffers::FlatBuf | |||
102 | 102 | ||
103 | } // namespace Commands | 103 | } // namespace Commands |
104 | 104 | ||
105 | } // namespace Akonadi2 | 105 | } // namespace Sink |
diff --git a/common/commands.h b/common/commands.h index 33d5cd7..19c827e 100644 --- a/common/commands.h +++ b/common/commands.h | |||
@@ -20,13 +20,13 @@ | |||
20 | 20 | ||
21 | #pragma once | 21 | #pragma once |
22 | 22 | ||
23 | #include <akonadi2common_export.h> | 23 | #include <sinkcommon_export.h> |
24 | #include <flatbuffers/flatbuffers.h> | 24 | #include <flatbuffers/flatbuffers.h> |
25 | #include <QByteArray> | 25 | #include <QByteArray> |
26 | 26 | ||
27 | class QIODevice; | 27 | class QIODevice; |
28 | 28 | ||
29 | namespace Akonadi2 | 29 | namespace Sink |
30 | { | 30 | { |
31 | 31 | ||
32 | namespace Commands | 32 | namespace Commands |
@@ -54,11 +54,11 @@ enum CommandIds { | |||
54 | 54 | ||
55 | QByteArray name(int commandId); | 55 | QByteArray name(int commandId); |
56 | 56 | ||
57 | int AKONADI2COMMON_EXPORT headerSize(); | 57 | int SINKCOMMON_EXPORT headerSize(); |
58 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId); | 58 | void SINKCOMMON_EXPORT write(QIODevice *device, int messageId, int commandId); |
59 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId, const char *buffer, uint size); | 59 | void SINKCOMMON_EXPORT write(QIODevice *device, int messageId, int commandId, const char *buffer, uint size); |
60 | void AKONADI2COMMON_EXPORT write(QIODevice *device, int messageId, int commandId, flatbuffers::FlatBufferBuilder &fbb); | 60 | void SINKCOMMON_EXPORT write(QIODevice *device, int messageId, int commandId, flatbuffers::FlatBufferBuilder &fbb); |
61 | 61 | ||
62 | } | 62 | } |
63 | 63 | ||
64 | } // namespace Akonadi2 | 64 | } // namespace Sink |
diff --git a/common/commands/commandcompletion.fbs b/common/commands/commandcompletion.fbs index de7ec14..6d95dbc 100644 --- a/common/commands/commandcompletion.fbs +++ b/common/commands/commandcompletion.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.Commands; | 1 | namespace Sink.Commands; |
2 | 2 | ||
3 | table CommandCompletion { | 3 | table CommandCompletion { |
4 | id: ulong; | 4 | id: ulong; |
diff --git a/common/commands/createentity.fbs b/common/commands/createentity.fbs index 5358dea..b97e8f6 100644 --- a/common/commands/createentity.fbs +++ b/common/commands/createentity.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.Commands; | 1 | namespace Sink.Commands; |
2 | 2 | ||
3 | table CreateEntity { | 3 | table CreateEntity { |
4 | entityId: string; | 4 | entityId: string; |
diff --git a/common/commands/deleteentity.fbs b/common/commands/deleteentity.fbs index 9f865be..c3a3fc7 100644 --- a/common/commands/deleteentity.fbs +++ b/common/commands/deleteentity.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.Commands; | 1 | namespace Sink.Commands; |
2 | 2 | ||
3 | table DeleteEntity { | 3 | table DeleteEntity { |
4 | revision: ulong; | 4 | revision: ulong; |
diff --git a/common/commands/fetchentity.fbs b/common/commands/fetchentity.fbs index 7a1d74d..bceafbd 100644 --- a/common/commands/fetchentity.fbs +++ b/common/commands/fetchentity.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.Commands; | 1 | namespace Sink.Commands; |
2 | 2 | ||
3 | table FetchEntity { | 3 | table FetchEntity { |
4 | revision: ulong; | 4 | revision: ulong; |
diff --git a/common/commands/handshake.fbs b/common/commands/handshake.fbs index e824715..1d0b3cb 100644 --- a/common/commands/handshake.fbs +++ b/common/commands/handshake.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.Commands; | 1 | namespace Sink.Commands; |
2 | 2 | ||
3 | table Handshake { | 3 | table Handshake { |
4 | name: string; | 4 | name: string; |
diff --git a/common/commands/inspection.fbs b/common/commands/inspection.fbs index aaae1ae..e99fc71 100644 --- a/common/commands/inspection.fbs +++ b/common/commands/inspection.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.Commands; | 1 | namespace Sink.Commands; |
2 | 2 | ||
3 | table Inspection { | 3 | table Inspection { |
4 | id: string; | 4 | id: string; |
diff --git a/common/commands/modifyentity.fbs b/common/commands/modifyentity.fbs index 03b543f..efa2fa0 100644 --- a/common/commands/modifyentity.fbs +++ b/common/commands/modifyentity.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.Commands; | 1 | namespace Sink.Commands; |
2 | 2 | ||
3 | table ModifyEntity { | 3 | table ModifyEntity { |
4 | revision: ulong; | 4 | revision: ulong; |
diff --git a/common/commands/notification.fbs b/common/commands/notification.fbs index 89687cf..ff01fc5 100644 --- a/common/commands/notification.fbs +++ b/common/commands/notification.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.Commands; | 1 | namespace Sink.Commands; |
2 | 2 | ||
3 | enum NotificationType : byte { Shutdown = 1, Status, Warning, Progress, Inspection } | 3 | enum NotificationType : byte { Shutdown = 1, Status, Warning, Progress, Inspection } |
4 | enum NotificationCode : byte { Success = 0, Failure = 1, UserCode } | 4 | enum NotificationCode : byte { Success = 0, Failure = 1, UserCode } |
diff --git a/common/commands/revisionreplayed.fbs b/common/commands/revisionreplayed.fbs index e1b11e3..f110ff9 100644 --- a/common/commands/revisionreplayed.fbs +++ b/common/commands/revisionreplayed.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.Commands; | 1 | namespace Sink.Commands; |
2 | 2 | ||
3 | table RevisionReplayed { | 3 | table RevisionReplayed { |
4 | revision: ulong; | 4 | revision: ulong; |
diff --git a/common/commands/revisionupdate.fbs b/common/commands/revisionupdate.fbs index 93fbe34..cc092e4 100644 --- a/common/commands/revisionupdate.fbs +++ b/common/commands/revisionupdate.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.Commands; | 1 | namespace Sink.Commands; |
2 | 2 | ||
3 | table RevisionUpdate { | 3 | table RevisionUpdate { |
4 | revision: ulong; | 4 | revision: ulong; |
diff --git a/common/commands/synchronize.fbs b/common/commands/synchronize.fbs index 7c3ae9a..5528166 100644 --- a/common/commands/synchronize.fbs +++ b/common/commands/synchronize.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.Commands; | 1 | namespace Sink.Commands; |
2 | 2 | ||
3 | table Synchronize { | 3 | table Synchronize { |
4 | sourceSync: bool; //Synchronize with source | 4 | sourceSync: bool; //Synchronize with source |
diff --git a/common/definitions.cpp b/common/definitions.cpp index 33512ad..daf354c 100644 --- a/common/definitions.cpp +++ b/common/definitions.cpp | |||
@@ -22,12 +22,12 @@ | |||
22 | 22 | ||
23 | #include <QStandardPaths> | 23 | #include <QStandardPaths> |
24 | 24 | ||
25 | QString Akonadi2::storageLocation() | 25 | QString Sink::storageLocation() |
26 | { | 26 | { |
27 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage"; | 27 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/storage"; |
28 | } | 28 | } |
29 | 29 | ||
30 | QByteArray Akonadi2::resourceName(const QByteArray &instanceIdentifier) | 30 | QByteArray Sink::resourceName(const QByteArray &instanceIdentifier) |
31 | { | 31 | { |
32 | auto split = instanceIdentifier.split('.'); | 32 | auto split = instanceIdentifier.split('.'); |
33 | if (split.size() <= 1) { | 33 | if (split.size() <= 1) { |
diff --git a/common/definitions.h b/common/definitions.h index 333d106..5834f01 100644 --- a/common/definitions.h +++ b/common/definitions.h | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <QString> | 23 | #include <QString> |
24 | #include <QByteArray> | 24 | #include <QByteArray> |
25 | 25 | ||
26 | namespace Akonadi2 { | 26 | namespace Sink { |
27 | QString storageLocation(); | 27 | QString storageLocation(); |
28 | QByteArray resourceName(const QByteArray &instanceIdentifier); | 28 | QByteArray resourceName(const QByteArray &instanceIdentifier); |
29 | } | 29 | } |
diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index c9a8bba..b0433be 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp | |||
@@ -21,7 +21,7 @@ | |||
21 | #include "log.h" | 21 | #include "log.h" |
22 | #include "../bufferadaptor.h" | 22 | #include "../bufferadaptor.h" |
23 | 23 | ||
24 | namespace Akonadi2 { | 24 | namespace Sink { |
25 | namespace ApplicationDomain { | 25 | namespace ApplicationDomain { |
26 | 26 | ||
27 | ApplicationDomainType::ApplicationDomainType() | 27 | ApplicationDomainType::ApplicationDomainType() |
@@ -113,9 +113,9 @@ QByteArray getTypeName<Todo>() | |||
113 | } | 113 | } |
114 | 114 | ||
115 | template<> | 115 | template<> |
116 | QByteArray getTypeName<AkonadiResource>() | 116 | QByteArray getTypeName<SinkResource>() |
117 | { | 117 | { |
118 | return "akonadiresource"; | 118 | return "sinkresource"; |
119 | } | 119 | } |
120 | 120 | ||
121 | template<> | 121 | template<> |
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 44d8743..63f030c 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <QByteArray> | 24 | #include <QByteArray> |
25 | #include "bufferadaptor.h" | 25 | #include "bufferadaptor.h" |
26 | 26 | ||
27 | namespace Akonadi2 { | 27 | namespace Sink { |
28 | 28 | ||
29 | namespace ApplicationDomain { | 29 | namespace ApplicationDomain { |
30 | 30 | ||
@@ -48,7 +48,7 @@ public: | |||
48 | template <typename DomainType> | 48 | template <typename DomainType> |
49 | static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType, const QList<QByteArray> properties = QList<QByteArray>()) | 49 | static typename DomainType::Ptr getInMemoryRepresentation(const ApplicationDomainType &domainType, const QList<QByteArray> properties = QList<QByteArray>()) |
50 | { | 50 | { |
51 | auto memoryAdaptor = QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create(*(domainType.mAdaptor), properties); | 51 | auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create(*(domainType.mAdaptor), properties); |
52 | //The identifier still internal refers to the memory-mapped pointer, we need to copy the memory or it will become invalid | 52 | //The identifier still internal refers to the memory-mapped pointer, we need to copy the memory or it will become invalid |
53 | return QSharedPointer<DomainType>::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor); | 53 | return QSharedPointer<DomainType>::create(domainType.mResourceInstanceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.mIdentifier.size()), domainType.mRevision, memoryAdaptor); |
54 | } | 54 | } |
@@ -113,13 +113,13 @@ struct Folder : public Entity { | |||
113 | }; | 113 | }; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * Represents an akonadi resource. | 116 | * Represents an sink resource. |
117 | * | 117 | * |
118 | * This type is used for configuration of resources, | 118 | * This type is used for configuration of resources, |
119 | * and for creating and removing resource instances. | 119 | * and for creating and removing resource instances. |
120 | */ | 120 | */ |
121 | struct AkonadiResource : public ApplicationDomainType { | 121 | struct SinkResource : public ApplicationDomainType { |
122 | typedef QSharedPointer<AkonadiResource> Ptr; | 122 | typedef QSharedPointer<SinkResource> Ptr; |
123 | using ApplicationDomainType::ApplicationDomainType; | 123 | using ApplicationDomainType::ApplicationDomainType; |
124 | }; | 124 | }; |
125 | 125 | ||
@@ -138,7 +138,7 @@ template<> | |||
138 | QByteArray getTypeName<Todo>(); | 138 | QByteArray getTypeName<Todo>(); |
139 | 139 | ||
140 | template<> | 140 | template<> |
141 | QByteArray getTypeName<AkonadiResource>(); | 141 | QByteArray getTypeName<SinkResource>(); |
142 | 142 | ||
143 | template<> | 143 | template<> |
144 | QByteArray getTypeName<Mail>(); | 144 | QByteArray getTypeName<Mail>(); |
@@ -158,15 +158,15 @@ class TypeImplementation; | |||
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::ApplicationDomainType) | 161 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType) |
162 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr) | 162 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType::Ptr) |
163 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Entity) | 163 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity) |
164 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Entity::Ptr) | 164 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity::Ptr) |
165 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event) | 165 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Event) |
166 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Event::Ptr) | 166 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Event::Ptr) |
167 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Mail) | 167 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Mail) |
168 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Mail::Ptr) | 168 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Mail::Ptr) |
169 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Folder) | 169 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Folder) |
170 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::Folder::Ptr) | 170 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Folder::Ptr) |
171 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::AkonadiResource) | 171 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::SinkResource) |
172 | Q_DECLARE_METATYPE(Akonadi2::ApplicationDomain::AkonadiResource::Ptr) | 172 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::SinkResource::Ptr) |
diff --git a/common/domain/dummy.fbs b/common/domain/dummy.fbs index 8816b09..4b12827 100644 --- a/common/domain/dummy.fbs +++ b/common/domain/dummy.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.ApplicationDomain.Buffer; | 1 | namespace Sink.ApplicationDomain.Buffer; |
2 | 2 | ||
3 | table Dummy { | 3 | table Dummy { |
4 | } | 4 | } |
diff --git a/common/domain/event.cpp b/common/domain/event.cpp index 18009fc..9f81eb8 100644 --- a/common/domain/event.cpp +++ b/common/domain/event.cpp | |||
@@ -37,7 +37,7 @@ | |||
37 | 37 | ||
38 | static QMutex sMutex; | 38 | static QMutex sMutex; |
39 | 39 | ||
40 | using namespace Akonadi2::ApplicationDomain; | 40 | using namespace Sink::ApplicationDomain; |
41 | 41 | ||
42 | static TypeIndex &getIndex() | 42 | static TypeIndex &getIndex() |
43 | { | 43 | { |
@@ -50,17 +50,17 @@ static TypeIndex &getIndex() | |||
50 | return *index; | 50 | return *index; |
51 | } | 51 | } |
52 | 52 | ||
53 | ResultSet TypeImplementation<Event>::queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction) | 53 | ResultSet TypeImplementation<Event>::queryIndexes(const Sink::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Sink::Storage::Transaction &transaction) |
54 | { | 54 | { |
55 | return getIndex().query(query, appliedFilters, transaction); | 55 | return getIndex().query(query, appliedFilters, transaction); |
56 | } | 56 | } |
57 | 57 | ||
58 | void TypeImplementation<Event>::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | 58 | void TypeImplementation<Event>::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction) |
59 | { | 59 | { |
60 | return getIndex().add(identifier, bufferAdaptor, transaction); | 60 | return getIndex().add(identifier, bufferAdaptor, transaction); |
61 | } | 61 | } |
62 | 62 | ||
63 | void TypeImplementation<Event>::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | 63 | void TypeImplementation<Event>::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction) |
64 | { | 64 | { |
65 | return getIndex().remove(identifier, bufferAdaptor, transaction); | 65 | return getIndex().remove(identifier, bufferAdaptor, transaction); |
66 | } | 66 | } |
diff --git a/common/domain/event.fbs b/common/domain/event.fbs index 0c6628b..69148ef 100644 --- a/common/domain/event.fbs +++ b/common/domain/event.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.ApplicationDomain.Buffer; | 1 | namespace Sink.ApplicationDomain.Buffer; |
2 | 2 | ||
3 | table Event { | 3 | table Event { |
4 | uid:string; | 4 | uid:string; |
diff --git a/common/domain/event.h b/common/domain/event.h index 577367b..479969d 100644 --- a/common/domain/event.h +++ b/common/domain/event.h | |||
@@ -30,7 +30,7 @@ class ReadPropertyMapper; | |||
30 | template<typename T> | 30 | template<typename T> |
31 | class WritePropertyMapper; | 31 | class WritePropertyMapper; |
32 | 32 | ||
33 | namespace Akonadi2 { | 33 | namespace Sink { |
34 | class Query; | 34 | class Query; |
35 | 35 | ||
36 | namespace ApplicationDomain { | 36 | namespace ApplicationDomain { |
@@ -45,19 +45,19 @@ namespace ApplicationDomain { | |||
45 | * These are type specifiy default implementations. Theoretically a resource could implement it's own implementation. | 45 | * These are type specifiy default implementations. Theoretically a resource could implement it's own implementation. |
46 | */ | 46 | */ |
47 | template<> | 47 | template<> |
48 | class TypeImplementation<Akonadi2::ApplicationDomain::Event> { | 48 | class TypeImplementation<Sink::ApplicationDomain::Event> { |
49 | public: | 49 | public: |
50 | typedef Akonadi2::ApplicationDomain::Buffer::Event Buffer; | 50 | typedef Sink::ApplicationDomain::Buffer::Event Buffer; |
51 | typedef Akonadi2::ApplicationDomain::Buffer::EventBuilder BufferBuilder; | 51 | typedef Sink::ApplicationDomain::Buffer::EventBuilder BufferBuilder; |
52 | static QSet<QByteArray> indexedProperties(); | 52 | static QSet<QByteArray> indexedProperties(); |
53 | /** | 53 | /** |
54 | * Returns the potential result set based on the indexes. | 54 | * Returns the potential result set based on the indexes. |
55 | * | 55 | * |
56 | * An empty result set indicates that a full scan is required. | 56 | * An empty result set indicates that a full scan is required. |
57 | */ | 57 | */ |
58 | static ResultSet queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction); | 58 | static ResultSet queryIndexes(const Sink::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Sink::Storage::Transaction &transaction); |
59 | static void index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | 59 | static void index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction); |
60 | static void removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | 60 | static void removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction); |
61 | static QSharedPointer<ReadPropertyMapper<Buffer> > initializeReadPropertyMapper(); | 61 | static QSharedPointer<ReadPropertyMapper<Buffer> > initializeReadPropertyMapper(); |
62 | static QSharedPointer<WritePropertyMapper<BufferBuilder> > initializeWritePropertyMapper(); | 62 | static QSharedPointer<WritePropertyMapper<BufferBuilder> > initializeWritePropertyMapper(); |
63 | }; | 63 | }; |
diff --git a/common/domain/folder.cpp b/common/domain/folder.cpp index 7934841..16b2ec9 100644 --- a/common/domain/folder.cpp +++ b/common/domain/folder.cpp | |||
@@ -37,7 +37,7 @@ | |||
37 | 37 | ||
38 | static QMutex sMutex; | 38 | static QMutex sMutex; |
39 | 39 | ||
40 | using namespace Akonadi2::ApplicationDomain; | 40 | using namespace Sink::ApplicationDomain; |
41 | 41 | ||
42 | static TypeIndex &getIndex() | 42 | static TypeIndex &getIndex() |
43 | { | 43 | { |
@@ -51,18 +51,18 @@ static TypeIndex &getIndex() | |||
51 | return *index; | 51 | return *index; |
52 | } | 52 | } |
53 | 53 | ||
54 | ResultSet TypeImplementation<Folder>::queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction) | 54 | ResultSet TypeImplementation<Folder>::queryIndexes(const Sink::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Sink::Storage::Transaction &transaction) |
55 | { | 55 | { |
56 | return getIndex().query(query, appliedFilters, transaction); | 56 | return getIndex().query(query, appliedFilters, transaction); |
57 | } | 57 | } |
58 | 58 | ||
59 | void TypeImplementation<Folder>::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | 59 | void TypeImplementation<Folder>::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction) |
60 | { | 60 | { |
61 | Trace() << "Indexing " << identifier; | 61 | Trace() << "Indexing " << identifier; |
62 | getIndex().add(identifier, bufferAdaptor, transaction); | 62 | getIndex().add(identifier, bufferAdaptor, transaction); |
63 | } | 63 | } |
64 | 64 | ||
65 | void TypeImplementation<Folder>::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | 65 | void TypeImplementation<Folder>::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction) |
66 | { | 66 | { |
67 | getIndex().remove(identifier, bufferAdaptor, transaction); | 67 | getIndex().remove(identifier, bufferAdaptor, transaction); |
68 | } | 68 | } |
diff --git a/common/domain/folder.fbs b/common/domain/folder.fbs index 31dc32a..b5d01ef 100644 --- a/common/domain/folder.fbs +++ b/common/domain/folder.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.ApplicationDomain.Buffer; | 1 | namespace Sink.ApplicationDomain.Buffer; |
2 | 2 | ||
3 | table Folder { | 3 | table Folder { |
4 | name:string; | 4 | name:string; |
diff --git a/common/domain/folder.h b/common/domain/folder.h index 545836f..40c799c 100644 --- a/common/domain/folder.h +++ b/common/domain/folder.h | |||
@@ -30,7 +30,7 @@ class ReadPropertyMapper; | |||
30 | template<typename T> | 30 | template<typename T> |
31 | class WritePropertyMapper; | 31 | class WritePropertyMapper; |
32 | 32 | ||
33 | namespace Akonadi2 { | 33 | namespace Sink { |
34 | class Query; | 34 | class Query; |
35 | 35 | ||
36 | namespace ApplicationDomain { | 36 | namespace ApplicationDomain { |
@@ -40,14 +40,14 @@ namespace ApplicationDomain { | |||
40 | } | 40 | } |
41 | 41 | ||
42 | template<> | 42 | template<> |
43 | class TypeImplementation<Akonadi2::ApplicationDomain::Folder> { | 43 | class TypeImplementation<Sink::ApplicationDomain::Folder> { |
44 | public: | 44 | public: |
45 | typedef Akonadi2::ApplicationDomain::Buffer::Folder Buffer; | 45 | typedef Sink::ApplicationDomain::Buffer::Folder Buffer; |
46 | typedef Akonadi2::ApplicationDomain::Buffer::FolderBuilder BufferBuilder; | 46 | typedef Sink::ApplicationDomain::Buffer::FolderBuilder BufferBuilder; |
47 | static QSet<QByteArray> indexedProperties(); | 47 | static QSet<QByteArray> indexedProperties(); |
48 | static ResultSet queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction); | 48 | static ResultSet queryIndexes(const Sink::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Sink::Storage::Transaction &transaction); |
49 | static void index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | 49 | static void index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction); |
50 | static void removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | 50 | static void removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction); |
51 | static QSharedPointer<ReadPropertyMapper<Buffer> > initializeReadPropertyMapper(); | 51 | static QSharedPointer<ReadPropertyMapper<Buffer> > initializeReadPropertyMapper(); |
52 | static QSharedPointer<WritePropertyMapper<BufferBuilder> > initializeWritePropertyMapper(); | 52 | static QSharedPointer<WritePropertyMapper<BufferBuilder> > initializeWritePropertyMapper(); |
53 | }; | 53 | }; |
diff --git a/common/domain/mail.cpp b/common/domain/mail.cpp index 8875d88..518331f 100644 --- a/common/domain/mail.cpp +++ b/common/domain/mail.cpp | |||
@@ -37,7 +37,7 @@ | |||
37 | 37 | ||
38 | static QMutex sMutex; | 38 | static QMutex sMutex; |
39 | 39 | ||
40 | using namespace Akonadi2::ApplicationDomain; | 40 | using namespace Sink::ApplicationDomain; |
41 | 41 | ||
42 | static TypeIndex &getIndex() | 42 | static TypeIndex &getIndex() |
43 | { | 43 | { |
@@ -55,18 +55,18 @@ static TypeIndex &getIndex() | |||
55 | return *index; | 55 | return *index; |
56 | } | 56 | } |
57 | 57 | ||
58 | ResultSet TypeImplementation<Mail>::queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction) | 58 | ResultSet TypeImplementation<Mail>::queryIndexes(const Sink::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Sink::Storage::Transaction &transaction) |
59 | { | 59 | { |
60 | return getIndex().query(query, appliedFilters, transaction); | 60 | return getIndex().query(query, appliedFilters, transaction); |
61 | } | 61 | } |
62 | 62 | ||
63 | void TypeImplementation<Mail>::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | 63 | void TypeImplementation<Mail>::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction) |
64 | { | 64 | { |
65 | Trace() << "Indexing " << identifier; | 65 | Trace() << "Indexing " << identifier; |
66 | getIndex().add(identifier, bufferAdaptor, transaction); | 66 | getIndex().add(identifier, bufferAdaptor, transaction); |
67 | } | 67 | } |
68 | 68 | ||
69 | void TypeImplementation<Mail>::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | 69 | void TypeImplementation<Mail>::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction) |
70 | { | 70 | { |
71 | getIndex().remove(identifier, bufferAdaptor, transaction); | 71 | getIndex().remove(identifier, bufferAdaptor, transaction); |
72 | } | 72 | } |
diff --git a/common/domain/mail.fbs b/common/domain/mail.fbs index 17b29a0..0d11e32 100644 --- a/common/domain/mail.fbs +++ b/common/domain/mail.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2.ApplicationDomain.Buffer; | 1 | namespace Sink.ApplicationDomain.Buffer; |
2 | 2 | ||
3 | table Mail { | 3 | table Mail { |
4 | uid:string; | 4 | uid:string; |
diff --git a/common/domain/mail.h b/common/domain/mail.h index d1ef8d6..e45d64d 100644 --- a/common/domain/mail.h +++ b/common/domain/mail.h | |||
@@ -30,7 +30,7 @@ class ReadPropertyMapper; | |||
30 | template<typename T> | 30 | template<typename T> |
31 | class WritePropertyMapper; | 31 | class WritePropertyMapper; |
32 | 32 | ||
33 | namespace Akonadi2 { | 33 | namespace Sink { |
34 | class Query; | 34 | class Query; |
35 | 35 | ||
36 | namespace ApplicationDomain { | 36 | namespace ApplicationDomain { |
@@ -40,19 +40,19 @@ namespace ApplicationDomain { | |||
40 | } | 40 | } |
41 | 41 | ||
42 | template<> | 42 | template<> |
43 | class TypeImplementation<Akonadi2::ApplicationDomain::Mail> { | 43 | class TypeImplementation<Sink::ApplicationDomain::Mail> { |
44 | public: | 44 | public: |
45 | typedef Akonadi2::ApplicationDomain::Buffer::Mail Buffer; | 45 | typedef Sink::ApplicationDomain::Buffer::Mail Buffer; |
46 | typedef Akonadi2::ApplicationDomain::Buffer::MailBuilder BufferBuilder; | 46 | typedef Sink::ApplicationDomain::Buffer::MailBuilder BufferBuilder; |
47 | static QSet<QByteArray> indexedProperties(); | 47 | static QSet<QByteArray> indexedProperties(); |
48 | /** | 48 | /** |
49 | * Returns the potential result set based on the indexes. | 49 | * Returns the potential result set based on the indexes. |
50 | * | 50 | * |
51 | * An empty result set indicates that a full scan is required. | 51 | * An empty result set indicates that a full scan is required. |
52 | */ | 52 | */ |
53 | static ResultSet queryIndexes(const Akonadi2::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction); | 53 | static ResultSet queryIndexes(const Sink::Query &query, const QByteArray &resourceInstanceIdentifier, QSet<QByteArray> &appliedFilters, Sink::Storage::Transaction &transaction); |
54 | static void index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | 54 | static void index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction); |
55 | static void removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | 55 | static void removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction); |
56 | static QSharedPointer<ReadPropertyMapper<Buffer> > initializeReadPropertyMapper(); | 56 | static QSharedPointer<ReadPropertyMapper<Buffer> > initializeReadPropertyMapper(); |
57 | static QSharedPointer<WritePropertyMapper<BufferBuilder> > initializeWritePropertyMapper(); | 57 | static QSharedPointer<WritePropertyMapper<BufferBuilder> > initializeWritePropertyMapper(); |
58 | }; | 58 | }; |
diff --git a/common/domainadaptor.h b/common/domainadaptor.h index 39bd3b8..d43fad7 100644 --- a/common/domainadaptor.h +++ b/common/domainadaptor.h | |||
@@ -39,7 +39,7 @@ | |||
39 | * Create a buffer from a domain object using the provided mappings | 39 | * Create a buffer from a domain object using the provided mappings |
40 | */ | 40 | */ |
41 | template <class Builder, class Buffer> | 41 | template <class Builder, class Buffer> |
42 | flatbuffers::Offset<Buffer> createBufferPart(const Akonadi2::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, const WritePropertyMapper<Builder> &mapper) | 42 | flatbuffers::Offset<Buffer> createBufferPart(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, const WritePropertyMapper<Builder> &mapper) |
43 | { | 43 | { |
44 | //First create a primitives such as strings using the mappings | 44 | //First create a primitives such as strings using the mappings |
45 | QList<std::function<void(Builder &)> > propertiesToAddToResource; | 45 | QList<std::function<void(Builder &)> > propertiesToAddToResource; |
@@ -67,11 +67,11 @@ flatbuffers::Offset<Buffer> createBufferPart(const Akonadi2::ApplicationDomain:: | |||
67 | * After this the buffer can be extracted from the FlatBufferBuilder object. | 67 | * After this the buffer can be extracted from the FlatBufferBuilder object. |
68 | */ | 68 | */ |
69 | template <typename Buffer, typename BufferBuilder> | 69 | template <typename Buffer, typename BufferBuilder> |
70 | static void createBufferPartBuffer(const Akonadi2::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, WritePropertyMapper<BufferBuilder> &mapper) | 70 | static void createBufferPartBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, WritePropertyMapper<BufferBuilder> &mapper) |
71 | { | 71 | { |
72 | auto pos = createBufferPart<BufferBuilder, Buffer>(domainObject, fbb, mapper); | 72 | auto pos = createBufferPart<BufferBuilder, Buffer>(domainObject, fbb, mapper); |
73 | // Because we cannot template the following call | 73 | // Because we cannot template the following call |
74 | // Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(fbb, pos); | 74 | // Sink::ApplicationDomain::Buffer::FinishEventBuffer(fbb, pos); |
75 | // FIXME: This means all buffers in here must have the AKFB identifier | 75 | // FIXME: This means all buffers in here must have the AKFB identifier |
76 | fbb.Finish(pos, "AKFB"); | 76 | fbb.Finish(pos, "AKFB"); |
77 | flatbuffers::Verifier verifier(fbb.GetBufferPointer(), fbb.GetSize()); | 77 | flatbuffers::Verifier verifier(fbb.GetBufferPointer(), fbb.GetSize()); |
@@ -84,7 +84,7 @@ static void createBufferPartBuffer(const Akonadi2::ApplicationDomain::Applicatio | |||
84 | * A generic adaptor implementation that uses a property mapper to read/write values. | 84 | * A generic adaptor implementation that uses a property mapper to read/write values. |
85 | */ | 85 | */ |
86 | template <class LocalBuffer, class ResourceBuffer> | 86 | template <class LocalBuffer, class ResourceBuffer> |
87 | class GenericBufferAdaptor : public Akonadi2::ApplicationDomain::BufferAdaptor | 87 | class GenericBufferAdaptor : public Sink::ApplicationDomain::BufferAdaptor |
88 | { | 88 | { |
89 | public: | 89 | public: |
90 | GenericBufferAdaptor() | 90 | GenericBufferAdaptor() |
@@ -123,13 +123,13 @@ public: | |||
123 | template<typename DomainType, typename ResourceBuffer, typename ResourceBuilder> | 123 | template<typename DomainType, typename ResourceBuffer, typename ResourceBuilder> |
124 | class DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInterface | 124 | class DomainTypeAdaptorFactory : public DomainTypeAdaptorFactoryInterface |
125 | { | 125 | { |
126 | typedef typename Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::Buffer LocalBuffer; | 126 | typedef typename Sink::ApplicationDomain::TypeImplementation<DomainType>::Buffer LocalBuffer; |
127 | typedef typename Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::BufferBuilder LocalBuilder; | 127 | typedef typename Sink::ApplicationDomain::TypeImplementation<DomainType>::BufferBuilder LocalBuilder; |
128 | public: | 128 | public: |
129 | DomainTypeAdaptorFactory() : | 129 | DomainTypeAdaptorFactory() : |
130 | mLocalMapper(Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::initializeReadPropertyMapper()), | 130 | mLocalMapper(Sink::ApplicationDomain::TypeImplementation<DomainType>::initializeReadPropertyMapper()), |
131 | mResourceMapper(QSharedPointer<ReadPropertyMapper<ResourceBuffer> >::create()), | 131 | mResourceMapper(QSharedPointer<ReadPropertyMapper<ResourceBuffer> >::create()), |
132 | mLocalWriteMapper(Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::initializeWritePropertyMapper()), | 132 | mLocalWriteMapper(Sink::ApplicationDomain::TypeImplementation<DomainType>::initializeWritePropertyMapper()), |
133 | mResourceWriteMapper(QSharedPointer<WritePropertyMapper<ResourceBuilder> >::create()) | 133 | mResourceWriteMapper(QSharedPointer<WritePropertyMapper<ResourceBuilder> >::create()) |
134 | {}; | 134 | {}; |
135 | virtual ~DomainTypeAdaptorFactory() {}; | 135 | virtual ~DomainTypeAdaptorFactory() {}; |
@@ -139,11 +139,11 @@ public: | |||
139 | * | 139 | * |
140 | * This returns by default a GenericBufferAdaptor initialized with the corresponding property mappers. | 140 | * This returns by default a GenericBufferAdaptor initialized with the corresponding property mappers. |
141 | */ | 141 | */ |
142 | virtual QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor> createAdaptor(const Akonadi2::Entity &entity) Q_DECL_OVERRIDE | 142 | virtual QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> createAdaptor(const Sink::Entity &entity) Q_DECL_OVERRIDE |
143 | { | 143 | { |
144 | const auto resourceBuffer = Akonadi2::EntityBuffer::readBuffer<ResourceBuffer>(entity.resource()); | 144 | const auto resourceBuffer = Sink::EntityBuffer::readBuffer<ResourceBuffer>(entity.resource()); |
145 | const auto localBuffer = Akonadi2::EntityBuffer::readBuffer<LocalBuffer>(entity.local()); | 145 | const auto localBuffer = Sink::EntityBuffer::readBuffer<LocalBuffer>(entity.local()); |
146 | // const auto metadataBuffer = Akonadi2::EntityBuffer::readBuffer<Akonadi2::Metadata>(entity.metadata()); | 146 | // const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); |
147 | 147 | ||
148 | auto adaptor = QSharedPointer<GenericBufferAdaptor<LocalBuffer, ResourceBuffer> >::create(); | 148 | auto adaptor = QSharedPointer<GenericBufferAdaptor<LocalBuffer, ResourceBuffer> >::create(); |
149 | adaptor->mLocalBuffer = localBuffer; | 149 | adaptor->mLocalBuffer = localBuffer; |
@@ -153,7 +153,7 @@ public: | |||
153 | return adaptor; | 153 | return adaptor; |
154 | } | 154 | } |
155 | 155 | ||
156 | virtual void createBuffer(const Akonadi2::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, void const *metadataData = 0, size_t metadataSize = 0) Q_DECL_OVERRIDE | 156 | virtual void createBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainObject, flatbuffers::FlatBufferBuilder &fbb, void const *metadataData = 0, size_t metadataSize = 0) Q_DECL_OVERRIDE |
157 | { | 157 | { |
158 | flatbuffers::FlatBufferBuilder localFbb; | 158 | flatbuffers::FlatBufferBuilder localFbb; |
159 | if (mLocalWriteMapper) { | 159 | if (mLocalWriteMapper) { |
@@ -167,7 +167,7 @@ public: | |||
167 | createBufferPartBuffer<ResourceBuffer, ResourceBuilder>(domainObject, resFbb, *mResourceWriteMapper); | 167 | createBufferPartBuffer<ResourceBuffer, ResourceBuilder>(domainObject, resFbb, *mResourceWriteMapper); |
168 | } | 168 | } |
169 | 169 | ||
170 | Akonadi2::EntityBuffer::assembleEntityBuffer(fbb, metadataData, metadataSize, resFbb.GetBufferPointer(), resFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); | 170 | Sink::EntityBuffer::assembleEntityBuffer(fbb, metadataData, metadataSize, resFbb.GetBufferPointer(), resFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
diff --git a/common/domaintypeadaptorfactoryinterface.h b/common/domaintypeadaptorfactoryinterface.h index 8c99aa1..d974bbf 100644 --- a/common/domaintypeadaptorfactoryinterface.h +++ b/common/domaintypeadaptorfactoryinterface.h | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | #include <QSharedPointer> | 21 | #include <QSharedPointer> |
22 | 22 | ||
23 | namespace Akonadi2 { | 23 | namespace Sink { |
24 | namespace ApplicationDomain { | 24 | namespace ApplicationDomain { |
25 | class BufferAdaptor; | 25 | class BufferAdaptor; |
26 | class ApplicationDomainType; | 26 | class ApplicationDomainType; |
@@ -37,6 +37,6 @@ class DomainTypeAdaptorFactoryInterface | |||
37 | public: | 37 | public: |
38 | typedef QSharedPointer<DomainTypeAdaptorFactoryInterface> Ptr; | 38 | typedef QSharedPointer<DomainTypeAdaptorFactoryInterface> Ptr; |
39 | virtual ~DomainTypeAdaptorFactoryInterface() {}; | 39 | virtual ~DomainTypeAdaptorFactoryInterface() {}; |
40 | virtual QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor> createAdaptor(const Akonadi2::Entity &entity) = 0; | 40 | virtual QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> createAdaptor(const Sink::Entity &entity) = 0; |
41 | virtual void createBuffer(const Akonadi2::ApplicationDomain::ApplicationDomainType &domainType, flatbuffers::FlatBufferBuilder &fbb, void const *metadataData = 0, size_t metadataSize = 0) = 0; | 41 | virtual void createBuffer(const Sink::ApplicationDomain::ApplicationDomainType &domainType, flatbuffers::FlatBufferBuilder &fbb, void const *metadataData = 0, size_t metadataSize = 0) = 0; |
42 | }; | 42 | }; |
diff --git a/common/entity.fbs b/common/entity.fbs index 565b1a7..fe9b727 100644 --- a/common/entity.fbs +++ b/common/entity.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2; | 1 | namespace Sink; |
2 | 2 | ||
3 | table Entity { | 3 | table Entity { |
4 | metadata: [ubyte]; | 4 | metadata: [ubyte]; |
diff --git a/common/entitybuffer.cpp b/common/entitybuffer.cpp index c14c86d..0e5435a 100644 --- a/common/entitybuffer.cpp +++ b/common/entitybuffer.cpp | |||
@@ -4,17 +4,17 @@ | |||
4 | #include "metadata_generated.h" | 4 | #include "metadata_generated.h" |
5 | #include <QDebug> | 5 | #include <QDebug> |
6 | 6 | ||
7 | using namespace Akonadi2; | 7 | using namespace Sink; |
8 | 8 | ||
9 | EntityBuffer::EntityBuffer(const void *dataValue, int dataSize) | 9 | EntityBuffer::EntityBuffer(const void *dataValue, int dataSize) |
10 | : mEntity(nullptr) | 10 | : mEntity(nullptr) |
11 | { | 11 | { |
12 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(dataValue), dataSize); | 12 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(dataValue), dataSize); |
13 | // Q_ASSERT(Akonadi2::VerifyEntity(verifyer)); | 13 | // Q_ASSERT(Sink::VerifyEntity(verifyer)); |
14 | if (!Akonadi2::VerifyEntityBuffer(verifyer)) { | 14 | if (!Sink::VerifyEntityBuffer(verifyer)) { |
15 | qWarning() << "invalid buffer"; | 15 | qWarning() << "invalid buffer"; |
16 | } else { | 16 | } else { |
17 | mEntity = Akonadi2::GetEntity(dataValue); | 17 | mEntity = Sink::GetEntity(dataValue); |
18 | } | 18 | } |
19 | } | 19 | } |
20 | 20 | ||
@@ -23,7 +23,7 @@ bool EntityBuffer::isValid() const | |||
23 | return mEntity; | 23 | return mEntity; |
24 | } | 24 | } |
25 | 25 | ||
26 | const Akonadi2::Entity &EntityBuffer::entity() | 26 | const Sink::Entity &EntityBuffer::entity() |
27 | { | 27 | { |
28 | return *mEntity; | 28 | return *mEntity; |
29 | } | 29 | } |
@@ -55,7 +55,7 @@ const uint8_t* EntityBuffer::localBuffer() | |||
55 | 55 | ||
56 | void EntityBuffer::extractResourceBuffer(void *dataValue, int dataSize, const std::function<void(const uint8_t *, size_t size)> &handler) | 56 | void EntityBuffer::extractResourceBuffer(void *dataValue, int dataSize, const std::function<void(const uint8_t *, size_t size)> &handler) |
57 | { | 57 | { |
58 | Akonadi2::EntityBuffer buffer(dataValue, dataSize); | 58 | Sink::EntityBuffer buffer(dataValue, dataSize); |
59 | if (auto resourceData = buffer.entity().resource()) { | 59 | if (auto resourceData = buffer.entity().resource()) { |
60 | handler(resourceData->Data(), resourceData->size()); | 60 | handler(resourceData->Data(), resourceData->size()); |
61 | } | 61 | } |
@@ -76,7 +76,7 @@ void EntityBuffer::assembleEntityBuffer(flatbuffers::FlatBufferBuilder &fbb, voi | |||
76 | auto metadata = appendAsVector(fbb, metadataData, metadataSize); | 76 | auto metadata = appendAsVector(fbb, metadataData, metadataSize); |
77 | auto resource = appendAsVector(fbb, resourceData, resourceSize); | 77 | auto resource = appendAsVector(fbb, resourceData, resourceSize); |
78 | auto local = appendAsVector(fbb, localData, localSize); | 78 | auto local = appendAsVector(fbb, localData, localSize); |
79 | auto entity = Akonadi2::CreateEntity(fbb, metadata, resource, local); | 79 | auto entity = Sink::CreateEntity(fbb, metadata, resource, local); |
80 | Akonadi2::FinishEntityBuffer(fbb, entity); | 80 | Sink::FinishEntityBuffer(fbb, entity); |
81 | } | 81 | } |
82 | 82 | ||
diff --git a/common/entitybuffer.h b/common/entitybuffer.h index a58aae9..c9c2453 100644 --- a/common/entitybuffer.h +++ b/common/entitybuffer.h | |||
@@ -3,7 +3,7 @@ | |||
3 | #include <functional> | 3 | #include <functional> |
4 | #include <flatbuffers/flatbuffers.h> | 4 | #include <flatbuffers/flatbuffers.h> |
5 | 5 | ||
6 | namespace Akonadi2 { | 6 | namespace Sink { |
7 | struct Entity; | 7 | struct Entity; |
8 | 8 | ||
9 | class EntityBuffer { | 9 | class EntityBuffer { |
diff --git a/common/facade.cpp b/common/facade.cpp index 91021db..8cb776c 100644 --- a/common/facade.cpp +++ b/common/facade.cpp | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "queryrunner.h" | 27 | #include "queryrunner.h" |
28 | #include "bufferutils.h" | 28 | #include "bufferutils.h" |
29 | 29 | ||
30 | using namespace Akonadi2; | 30 | using namespace Sink; |
31 | 31 | ||
32 | class ResourceAccessFactory { | 32 | class ResourceAccessFactory { |
33 | public: | 33 | public: |
@@ -40,7 +40,7 @@ public: | |||
40 | return *instance; | 40 | return *instance; |
41 | } | 41 | } |
42 | 42 | ||
43 | Akonadi2::ResourceAccess::Ptr getAccess(const QByteArray &instanceIdentifier) | 43 | Sink::ResourceAccess::Ptr getAccess(const QByteArray &instanceIdentifier) |
44 | { | 44 | { |
45 | if (!mCache.contains(instanceIdentifier)) { | 45 | if (!mCache.contains(instanceIdentifier)) { |
46 | //Reuse the pointer if something else kept the resourceaccess alive | 46 | //Reuse the pointer if something else kept the resourceaccess alive |
@@ -52,8 +52,8 @@ public: | |||
52 | } | 52 | } |
53 | if (!mCache.contains(instanceIdentifier)) { | 53 | if (!mCache.contains(instanceIdentifier)) { |
54 | //Create a new instance if necessary | 54 | //Create a new instance if necessary |
55 | auto sharedPointer = Akonadi2::ResourceAccess::Ptr::create(instanceIdentifier); | 55 | auto sharedPointer = Sink::ResourceAccess::Ptr::create(instanceIdentifier); |
56 | QObject::connect(sharedPointer.data(), &Akonadi2::ResourceAccess::ready, sharedPointer.data(), [this, instanceIdentifier](bool ready) { | 56 | QObject::connect(sharedPointer.data(), &Sink::ResourceAccess::ready, sharedPointer.data(), [this, instanceIdentifier](bool ready) { |
57 | if (!ready) { | 57 | if (!ready) { |
58 | mCache.remove(instanceIdentifier); | 58 | mCache.remove(instanceIdentifier); |
59 | } | 59 | } |
@@ -76,14 +76,14 @@ public: | |||
76 | return mCache.value(instanceIdentifier); | 76 | return mCache.value(instanceIdentifier); |
77 | } | 77 | } |
78 | 78 | ||
79 | QHash<QByteArray, QWeakPointer<Akonadi2::ResourceAccess> > mWeakCache; | 79 | QHash<QByteArray, QWeakPointer<Sink::ResourceAccess> > mWeakCache; |
80 | QHash<QByteArray, Akonadi2::ResourceAccess::Ptr> mCache; | 80 | QHash<QByteArray, Sink::ResourceAccess::Ptr> mCache; |
81 | QHash<QByteArray, QTimer*> mTimer; | 81 | QHash<QByteArray, QTimer*> mTimer; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | template<class DomainType> | 84 | template<class DomainType> |
85 | GenericFacade<DomainType>::GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory , const QSharedPointer<Akonadi2::ResourceAccessInterface> resourceAccess) | 85 | GenericFacade<DomainType>::GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory , const QSharedPointer<Sink::ResourceAccessInterface> resourceAccess) |
86 | : Akonadi2::StoreFacade<DomainType>(), | 86 | : Sink::StoreFacade<DomainType>(), |
87 | mResourceAccess(resourceAccess), | 87 | mResourceAccess(resourceAccess), |
88 | mDomainTypeAdaptorFactory(adaptorFactory), | 88 | mDomainTypeAdaptorFactory(adaptorFactory), |
89 | mResourceInstanceIdentifier(resourceIdentifier) | 89 | mResourceInstanceIdentifier(resourceIdentifier) |
@@ -102,7 +102,7 @@ template<class DomainType> | |||
102 | QByteArray GenericFacade<DomainType>::bufferTypeForDomainType() | 102 | QByteArray GenericFacade<DomainType>::bufferTypeForDomainType() |
103 | { | 103 | { |
104 | //We happen to have a one to one mapping | 104 | //We happen to have a one to one mapping |
105 | return Akonadi2::ApplicationDomain::getTypeName<DomainType>(); | 105 | return Sink::ApplicationDomain::getTypeName<DomainType>(); |
106 | } | 106 | } |
107 | 107 | ||
108 | template<class DomainType> | 108 | template<class DomainType> |
@@ -136,7 +136,7 @@ KAsync::Job<void> GenericFacade<DomainType>::remove(const DomainType &domainObje | |||
136 | } | 136 | } |
137 | 137 | ||
138 | template<class DomainType> | 138 | template<class DomainType> |
139 | QPair<KAsync::Job<void>, typename ResultEmitter<typename DomainType::Ptr>::Ptr> GenericFacade<DomainType>::load(const Akonadi2::Query &query) | 139 | QPair<KAsync::Job<void>, typename ResultEmitter<typename DomainType::Ptr>::Ptr> GenericFacade<DomainType>::load(const Sink::Query &query) |
140 | { | 140 | { |
141 | //The runner lives for the lifetime of the query | 141 | //The runner lives for the lifetime of the query |
142 | auto runner = new QueryRunner<DomainType>(query, mResourceAccess, mResourceInstanceIdentifier, mDomainTypeAdaptorFactory, bufferTypeForDomainType()); | 142 | auto runner = new QueryRunner<DomainType>(query, mResourceAccess, mResourceInstanceIdentifier, mDomainTypeAdaptorFactory, bufferTypeForDomainType()); |
@@ -144,8 +144,8 @@ QPair<KAsync::Job<void>, typename ResultEmitter<typename DomainType::Ptr>::Ptr> | |||
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | template class Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Folder>; | 147 | template class Sink::GenericFacade<Sink::ApplicationDomain::Folder>; |
148 | template class Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Mail>; | 148 | template class Sink::GenericFacade<Sink::ApplicationDomain::Mail>; |
149 | template class Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>; | 149 | template class Sink::GenericFacade<Sink::ApplicationDomain::Event>; |
150 | 150 | ||
151 | #include "facade.moc" | 151 | #include "facade.moc" |
diff --git a/common/facade.h b/common/facade.h index de67e05..c25464f 100644 --- a/common/facade.h +++ b/common/facade.h | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "domaintypeadaptorfactoryinterface.h" | 29 | #include "domaintypeadaptorfactoryinterface.h" |
30 | #include "storage.h" | 30 | #include "storage.h" |
31 | 31 | ||
32 | namespace Akonadi2 { | 32 | namespace Sink { |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Default facade implementation for resources that are implemented in a separate process using the ResourceAccess class. | 35 | * Default facade implementation for resources that are implemented in a separate process using the ResourceAccess class. |
@@ -43,7 +43,7 @@ namespace Akonadi2 { | |||
43 | * Additionally a resource only has to provide a synchronizer plugin to execute the synchronization | 43 | * Additionally a resource only has to provide a synchronizer plugin to execute the synchronization |
44 | */ | 44 | */ |
45 | template <typename DomainType> | 45 | template <typename DomainType> |
46 | class GenericFacade: public Akonadi2::StoreFacade<DomainType> | 46 | class GenericFacade: public Sink::StoreFacade<DomainType> |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | /** | 49 | /** |
@@ -52,18 +52,18 @@ public: | |||
52 | * @param resourceIdentifier is the identifier of the resource instance | 52 | * @param resourceIdentifier is the identifier of the resource instance |
53 | * @param adaptorFactory is the adaptor factory used to generate the mappings from domain to resource types and vice versa | 53 | * @param adaptorFactory is the adaptor factory used to generate the mappings from domain to resource types and vice versa |
54 | */ | 54 | */ |
55 | GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory = DomainTypeAdaptorFactoryInterface::Ptr(), const QSharedPointer<Akonadi2::ResourceAccessInterface> resourceAccess = QSharedPointer<Akonadi2::ResourceAccessInterface>()); | 55 | GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory = DomainTypeAdaptorFactoryInterface::Ptr(), const QSharedPointer<Sink::ResourceAccessInterface> resourceAccess = QSharedPointer<Sink::ResourceAccessInterface>()); |
56 | ~GenericFacade(); | 56 | ~GenericFacade(); |
57 | 57 | ||
58 | static QByteArray bufferTypeForDomainType(); | 58 | static QByteArray bufferTypeForDomainType(); |
59 | KAsync::Job<void> create(const DomainType &domainObject) Q_DECL_OVERRIDE; | 59 | KAsync::Job<void> create(const DomainType &domainObject) Q_DECL_OVERRIDE; |
60 | KAsync::Job<void> modify(const DomainType &domainObject) Q_DECL_OVERRIDE; | 60 | KAsync::Job<void> modify(const DomainType &domainObject) Q_DECL_OVERRIDE; |
61 | KAsync::Job<void> remove(const DomainType &domainObject) Q_DECL_OVERRIDE; | 61 | KAsync::Job<void> remove(const DomainType &domainObject) Q_DECL_OVERRIDE; |
62 | QPair<KAsync::Job<void>, typename ResultEmitter<typename DomainType::Ptr>::Ptr> load(const Akonadi2::Query &query) Q_DECL_OVERRIDE; | 62 | QPair<KAsync::Job<void>, typename ResultEmitter<typename DomainType::Ptr>::Ptr> load(const Sink::Query &query) Q_DECL_OVERRIDE; |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | //TODO use one resource access instance per application & per resource | 65 | //TODO use one resource access instance per application & per resource |
66 | QSharedPointer<Akonadi2::ResourceAccessInterface> mResourceAccess; | 66 | QSharedPointer<Sink::ResourceAccessInterface> mResourceAccess; |
67 | DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory; | 67 | DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory; |
68 | QByteArray mResourceInstanceIdentifier; | 68 | QByteArray mResourceInstanceIdentifier; |
69 | }; | 69 | }; |
diff --git a/common/facadefactory.cpp b/common/facadefactory.cpp index 707d9ad..d9ee5f7 100644 --- a/common/facadefactory.cpp +++ b/common/facadefactory.cpp | |||
@@ -22,7 +22,7 @@ | |||
22 | #include "resourcefacade.h" | 22 | #include "resourcefacade.h" |
23 | #include "resource.h" | 23 | #include "resource.h" |
24 | 24 | ||
25 | using namespace Akonadi2; | 25 | using namespace Sink; |
26 | 26 | ||
27 | QMutex FacadeFactory::sMutex; | 27 | QMutex FacadeFactory::sMutex; |
28 | 28 | ||
@@ -54,7 +54,7 @@ void FacadeFactory::resetFactory() | |||
54 | 54 | ||
55 | void FacadeFactory::registerStaticFacades() | 55 | void FacadeFactory::registerStaticFacades() |
56 | { | 56 | { |
57 | registerFacade<Akonadi2::ApplicationDomain::AkonadiResource, ResourceFacade>(QByteArray()); | 57 | registerFacade<Sink::ApplicationDomain::SinkResource, ResourceFacade>(QByteArray()); |
58 | } | 58 | } |
59 | 59 | ||
60 | std::shared_ptr<void> FacadeFactory::getFacade(const QByteArray &resource, const QByteArray &instanceIdentifier, const QByteArray &typeName) | 60 | std::shared_ptr<void> FacadeFactory::getFacade(const QByteArray &resource, const QByteArray &instanceIdentifier, const QByteArray &typeName) |
@@ -65,7 +65,7 @@ std::shared_ptr<void> FacadeFactory::getFacade(const QByteArray &resource, const | |||
65 | if (!mFacadeRegistry.contains(k)) { | 65 | if (!mFacadeRegistry.contains(k)) { |
66 | locker.unlock(); | 66 | locker.unlock(); |
67 | //This will call FacadeFactory::instace() internally | 67 | //This will call FacadeFactory::instace() internally |
68 | Akonadi2::ResourceFactory::load(QString::fromLatin1(resource)); | 68 | Sink::ResourceFactory::load(QString::fromLatin1(resource)); |
69 | locker.relock(); | 69 | locker.relock(); |
70 | } | 70 | } |
71 | 71 | ||
diff --git a/common/facadefactory.h b/common/facadefactory.h index 19d1f40..3dca63b 100644 --- a/common/facadefactory.h +++ b/common/facadefactory.h | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "applicationdomaintype.h" | 30 | #include "applicationdomaintype.h" |
31 | #include "log.h" | 31 | #include "log.h" |
32 | 32 | ||
33 | namespace Akonadi2 { | 33 | namespace Sink { |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * Facade factory that returns a store facade implementation, by loading a plugin and providing the relevant implementation. | 36 | * Facade factory that returns a store facade implementation, by loading a plugin and providing the relevant implementation. |
diff --git a/common/facadeinterface.h b/common/facadeinterface.h index 318abf3..17cba5e 100644 --- a/common/facadeinterface.h +++ b/common/facadeinterface.h | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "applicationdomaintype.h" | 27 | #include "applicationdomaintype.h" |
28 | #include "resultprovider.h" | 28 | #include "resultprovider.h" |
29 | 29 | ||
30 | namespace Akonadi2 { | 30 | namespace Sink { |
31 | class Query; | 31 | class Query; |
32 | 32 | ||
33 | /** | 33 | /** |
@@ -68,7 +68,7 @@ public: | |||
68 | /** | 68 | /** |
69 | * Load entities from the store. | 69 | * Load entities from the store. |
70 | */ | 70 | */ |
71 | virtual QPair<KAsync::Job<void>, typename Akonadi2::ResultEmitter<typename DomainType::Ptr>::Ptr > load(const Query &query) = 0; | 71 | virtual QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr > load(const Query &query) = 0; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | template<class DomainType> | 74 | template<class DomainType> |
@@ -90,9 +90,9 @@ public: | |||
90 | return KAsync::error<void>(-1, "Failed to create a facade"); | 90 | return KAsync::error<void>(-1, "Failed to create a facade"); |
91 | } | 91 | } |
92 | 92 | ||
93 | QPair<KAsync::Job<void>, typename Akonadi2::ResultEmitter<typename DomainType::Ptr>::Ptr > load(const Query &query) | 93 | QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr > load(const Query &query) |
94 | { | 94 | { |
95 | return qMakePair(KAsync::null<void>(), typename Akonadi2::ResultEmitter<typename DomainType::Ptr>::Ptr()); | 95 | return qMakePair(KAsync::null<void>(), typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr()); |
96 | } | 96 | } |
97 | }; | 97 | }; |
98 | 98 | ||
diff --git a/common/genericresource.cpp b/common/genericresource.cpp index c7f323a..c7326d3 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | static int sBatchSize = 100; | 21 | static int sBatchSize = 100; |
22 | 22 | ||
23 | using namespace Akonadi2; | 23 | using namespace Sink; |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * Replays changes from the storage one by one. | 26 | * Replays changes from the storage one by one. |
@@ -105,8 +105,8 @@ public Q_SLOTS: | |||
105 | } | 105 | } |
106 | 106 | ||
107 | private: | 107 | private: |
108 | Akonadi2::Storage mStorage; | 108 | Sink::Storage mStorage; |
109 | Akonadi2::Storage mChangeReplayStore; | 109 | Sink::Storage mChangeReplayStore; |
110 | ReplayFunction mReplayFunction; | 110 | ReplayFunction mReplayFunction; |
111 | }; | 111 | }; |
112 | 112 | ||
@@ -118,7 +118,7 @@ class CommandProcessor : public QObject | |||
118 | Q_OBJECT | 118 | Q_OBJECT |
119 | typedef std::function<KAsync::Job<void>(void const *, size_t)> InspectionFunction; | 119 | typedef std::function<KAsync::Job<void>(void const *, size_t)> InspectionFunction; |
120 | public: | 120 | public: |
121 | CommandProcessor(Akonadi2::Pipeline *pipeline, QList<MessageQueue*> commandQueues) | 121 | CommandProcessor(Sink::Pipeline *pipeline, QList<MessageQueue*> commandQueues) |
122 | : QObject(), | 122 | : QObject(), |
123 | mPipeline(pipeline), | 123 | mPipeline(pipeline), |
124 | mCommandQueues(commandQueues), | 124 | mCommandQueues(commandQueues), |
@@ -175,18 +175,18 @@ private slots: | |||
175 | }).exec(); | 175 | }).exec(); |
176 | } | 176 | } |
177 | 177 | ||
178 | KAsync::Job<qint64> processQueuedCommand(const Akonadi2::QueuedCommand *queuedCommand) | 178 | KAsync::Job<qint64> processQueuedCommand(const Sink::QueuedCommand *queuedCommand) |
179 | { | 179 | { |
180 | Log() << "Processing command: " << Akonadi2::Commands::name(queuedCommand->commandId()); | 180 | Log() << "Processing command: " << Sink::Commands::name(queuedCommand->commandId()); |
181 | //Throw command into appropriate pipeline | 181 | //Throw command into appropriate pipeline |
182 | switch (queuedCommand->commandId()) { | 182 | switch (queuedCommand->commandId()) { |
183 | case Akonadi2::Commands::DeleteEntityCommand: | 183 | case Sink::Commands::DeleteEntityCommand: |
184 | return mPipeline->deletedEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()); | 184 | return mPipeline->deletedEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()); |
185 | case Akonadi2::Commands::ModifyEntityCommand: | 185 | case Sink::Commands::ModifyEntityCommand: |
186 | return mPipeline->modifiedEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()); | 186 | return mPipeline->modifiedEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()); |
187 | case Akonadi2::Commands::CreateEntityCommand: | 187 | case Sink::Commands::CreateEntityCommand: |
188 | return mPipeline->newEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()); | 188 | return mPipeline->newEntity(queuedCommand->command()->Data(), queuedCommand->command()->size()); |
189 | case Akonadi2::Commands::InspectionCommand: | 189 | case Sink::Commands::InspectionCommand: |
190 | if (mInspect) { | 190 | if (mInspect) { |
191 | return mInspect(queuedCommand->command()->Data(), queuedCommand->command()->size()).then<qint64>([]() { | 191 | return mInspect(queuedCommand->command()->Data(), queuedCommand->command()->size()).then<qint64>([]() { |
192 | return -1; | 192 | return -1; |
@@ -203,16 +203,16 @@ private slots: | |||
203 | KAsync::Job<qint64, qint64> processQueuedCommand(const QByteArray &data) | 203 | KAsync::Job<qint64, qint64> processQueuedCommand(const QByteArray &data) |
204 | { | 204 | { |
205 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(data.constData()), data.size()); | 205 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(data.constData()), data.size()); |
206 | if (!Akonadi2::VerifyQueuedCommandBuffer(verifyer)) { | 206 | if (!Sink::VerifyQueuedCommandBuffer(verifyer)) { |
207 | Warning() << "invalid buffer"; | 207 | Warning() << "invalid buffer"; |
208 | // return KAsync::error<void, qint64>(1, "Invalid Buffer"); | 208 | // return KAsync::error<void, qint64>(1, "Invalid Buffer"); |
209 | } | 209 | } |
210 | auto queuedCommand = Akonadi2::GetQueuedCommand(data.constData()); | 210 | auto queuedCommand = Sink::GetQueuedCommand(data.constData()); |
211 | const auto commandId = queuedCommand->commandId(); | 211 | const auto commandId = queuedCommand->commandId(); |
212 | Trace() << "Dequeued Command: " << Akonadi2::Commands::name(commandId); | 212 | Trace() << "Dequeued Command: " << Sink::Commands::name(commandId); |
213 | return processQueuedCommand(queuedCommand).then<qint64, qint64>( | 213 | return processQueuedCommand(queuedCommand).then<qint64, qint64>( |
214 | [commandId](qint64 createdRevision) -> qint64 { | 214 | [commandId](qint64 createdRevision) -> qint64 { |
215 | Trace() << "Command pipeline processed: " << Akonadi2::Commands::name(commandId); | 215 | Trace() << "Command pipeline processed: " << Sink::Commands::name(commandId); |
216 | return createdRevision; | 216 | return createdRevision; |
217 | } | 217 | } |
218 | , | 218 | , |
@@ -278,7 +278,7 @@ private slots: | |||
278 | } | 278 | } |
279 | 279 | ||
280 | private: | 280 | private: |
281 | Akonadi2::Pipeline *mPipeline; | 281 | Sink::Pipeline *mPipeline; |
282 | //Ordered by priority | 282 | //Ordered by priority |
283 | QList<MessageQueue*> mCommandQueues; | 283 | QList<MessageQueue*> mCommandQueues; |
284 | bool mProcessingLock; | 284 | bool mProcessingLock; |
@@ -289,19 +289,19 @@ private: | |||
289 | 289 | ||
290 | 290 | ||
291 | GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, const QSharedPointer<Pipeline> &pipeline) | 291 | GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, const QSharedPointer<Pipeline> &pipeline) |
292 | : Akonadi2::Resource(), | 292 | : Sink::Resource(), |
293 | mUserQueue(Akonadi2::storageLocation(), resourceInstanceIdentifier + ".userqueue"), | 293 | mUserQueue(Sink::storageLocation(), resourceInstanceIdentifier + ".userqueue"), |
294 | mSynchronizerQueue(Akonadi2::storageLocation(), resourceInstanceIdentifier + ".synchronizerqueue"), | 294 | mSynchronizerQueue(Sink::storageLocation(), resourceInstanceIdentifier + ".synchronizerqueue"), |
295 | mResourceInstanceIdentifier(resourceInstanceIdentifier), | 295 | mResourceInstanceIdentifier(resourceInstanceIdentifier), |
296 | mPipeline(pipeline ? pipeline : QSharedPointer<Akonadi2::Pipeline>::create(resourceInstanceIdentifier)), | 296 | mPipeline(pipeline ? pipeline : QSharedPointer<Sink::Pipeline>::create(resourceInstanceIdentifier)), |
297 | mError(0), | 297 | mError(0), |
298 | mClientLowerBoundRevision(std::numeric_limits<qint64>::max()) | 298 | mClientLowerBoundRevision(std::numeric_limits<qint64>::max()) |
299 | { | 299 | { |
300 | mProcessor = new CommandProcessor(mPipeline.data(), QList<MessageQueue*>() << &mUserQueue << &mSynchronizerQueue); | 300 | mProcessor = new CommandProcessor(mPipeline.data(), QList<MessageQueue*>() << &mUserQueue << &mSynchronizerQueue); |
301 | mProcessor->setInspectionCommand([this](void const *command, size_t size) { | 301 | mProcessor->setInspectionCommand([this](void const *command, size_t size) { |
302 | flatbuffers::Verifier verifier((const uint8_t *)command, size); | 302 | flatbuffers::Verifier verifier((const uint8_t *)command, size); |
303 | if (Akonadi2::Commands::VerifyInspectionBuffer(verifier)) { | 303 | if (Sink::Commands::VerifyInspectionBuffer(verifier)) { |
304 | auto buffer = Akonadi2::Commands::GetInspection(command); | 304 | auto buffer = Sink::Commands::GetInspection(command); |
305 | int inspectionType = buffer->type(); | 305 | int inspectionType = buffer->type(); |
306 | 306 | ||
307 | QByteArray inspectionId = BufferUtils::extractBuffer(buffer->id()); | 307 | QByteArray inspectionId = BufferUtils::extractBuffer(buffer->id()); |
@@ -313,17 +313,17 @@ GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, c | |||
313 | QVariant expectedValue; | 313 | QVariant expectedValue; |
314 | s >> expectedValue; | 314 | s >> expectedValue; |
315 | inspect(inspectionType, inspectionId, domainType, entityId, property, expectedValue).then<void>([=]() { | 315 | inspect(inspectionType, inspectionId, domainType, entityId, property, expectedValue).then<void>([=]() { |
316 | Akonadi2::Notification n; | 316 | Sink::Notification n; |
317 | n.type = Akonadi2::Commands::NotificationType_Inspection; | 317 | n.type = Sink::Commands::NotificationType_Inspection; |
318 | n.id = inspectionId; | 318 | n.id = inspectionId; |
319 | n.code = Akonadi2::Commands::NotificationCode_Success; | 319 | n.code = Sink::Commands::NotificationCode_Success; |
320 | emit notify(n); | 320 | emit notify(n); |
321 | }, [=](int code, const QString &message) { | 321 | }, [=](int code, const QString &message) { |
322 | Akonadi2::Notification n; | 322 | Sink::Notification n; |
323 | n.type = Akonadi2::Commands::NotificationType_Inspection; | 323 | n.type = Sink::Commands::NotificationType_Inspection; |
324 | n.message = message; | 324 | n.message = message; |
325 | n.id = inspectionId; | 325 | n.id = inspectionId; |
326 | n.code = Akonadi2::Commands::NotificationCode_Failure; | 326 | n.code = Sink::Commands::NotificationCode_Failure; |
327 | emit notify(n); | 327 | emit notify(n); |
328 | }).exec(); | 328 | }).exec(); |
329 | return KAsync::null<void>(); | 329 | return KAsync::null<void>(); |
@@ -334,7 +334,7 @@ GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, c | |||
334 | QObject::connect(mPipeline.data(), &Pipeline::revisionUpdated, this, &Resource::revisionUpdated); | 334 | QObject::connect(mPipeline.data(), &Pipeline::revisionUpdated, this, &Resource::revisionUpdated); |
335 | mSourceChangeReplay = new ChangeReplay(resourceInstanceIdentifier, [this](const QByteArray &type, const QByteArray &key, const QByteArray &value) { | 335 | mSourceChangeReplay = new ChangeReplay(resourceInstanceIdentifier, [this](const QByteArray &type, const QByteArray &key, const QByteArray &value) { |
336 | //This results in a deadlock when a sync is in progress and we try to create a second writing transaction (which is why we turn changereplay off during the sync) | 336 | //This results in a deadlock when a sync is in progress and we try to create a second writing transaction (which is why we turn changereplay off during the sync) |
337 | auto synchronizationStore = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite); | 337 | auto synchronizationStore = QSharedPointer<Sink::Storage>::create(Sink::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Sink::Storage::ReadWrite); |
338 | return this->replay(*synchronizationStore, type, key, value).then<void>([synchronizationStore](){}); | 338 | return this->replay(*synchronizationStore, type, key, value).then<void>([synchronizationStore](){}); |
339 | }); | 339 | }); |
340 | enableChangeReplay(true); | 340 | enableChangeReplay(true); |
@@ -370,13 +370,13 @@ void GenericResource::enableChangeReplay(bool enable) | |||
370 | } | 370 | } |
371 | } | 371 | } |
372 | 372 | ||
373 | void GenericResource::addType(const QByteArray &type, DomainTypeAdaptorFactoryInterface::Ptr factory, const QVector<Akonadi2::Preprocessor*> &preprocessors) | 373 | void GenericResource::addType(const QByteArray &type, DomainTypeAdaptorFactoryInterface::Ptr factory, const QVector<Sink::Preprocessor*> &preprocessors) |
374 | { | 374 | { |
375 | mPipeline->setPreprocessors(type, preprocessors); | 375 | mPipeline->setPreprocessors(type, preprocessors); |
376 | mPipeline->setAdaptorFactory(type, factory); | 376 | mPipeline->setAdaptorFactory(type, factory); |
377 | } | 377 | } |
378 | 378 | ||
379 | KAsync::Job<void> GenericResource::replay(Akonadi2::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) | 379 | KAsync::Job<void> GenericResource::replay(Sink::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) |
380 | { | 380 | { |
381 | return KAsync::null<void>(); | 381 | return KAsync::null<void>(); |
382 | } | 382 | } |
@@ -384,18 +384,18 @@ KAsync::Job<void> GenericResource::replay(Akonadi2::Storage &synchronizationStor | |||
384 | void GenericResource::removeFromDisk(const QByteArray &instanceIdentifier) | 384 | void GenericResource::removeFromDisk(const QByteArray &instanceIdentifier) |
385 | { | 385 | { |
386 | Warning() << "Removing from generic resource"; | 386 | Warning() << "Removing from generic resource"; |
387 | Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier, Akonadi2::Storage::ReadWrite).removeFromDisk(); | 387 | Sink::Storage(Sink::storageLocation(), instanceIdentifier, Sink::Storage::ReadWrite).removeFromDisk(); |
388 | Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier + ".userqueue", Akonadi2::Storage::ReadWrite).removeFromDisk(); | 388 | Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".userqueue", Sink::Storage::ReadWrite).removeFromDisk(); |
389 | Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier + ".synchronizerqueue", Akonadi2::Storage::ReadWrite).removeFromDisk(); | 389 | Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".synchronizerqueue", Sink::Storage::ReadWrite).removeFromDisk(); |
390 | Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier + ".changereplay", Akonadi2::Storage::ReadWrite).removeFromDisk(); | 390 | Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".changereplay", Sink::Storage::ReadWrite).removeFromDisk(); |
391 | } | 391 | } |
392 | 392 | ||
393 | qint64 GenericResource::diskUsage(const QByteArray &instanceIdentifier) | 393 | qint64 GenericResource::diskUsage(const QByteArray &instanceIdentifier) |
394 | { | 394 | { |
395 | auto size = Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier, Akonadi2::Storage::ReadOnly).diskUsage(); | 395 | auto size = Sink::Storage(Sink::storageLocation(), instanceIdentifier, Sink::Storage::ReadOnly).diskUsage(); |
396 | size += Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier + ".userqueue", Akonadi2::Storage::ReadOnly).diskUsage(); | 396 | size += Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".userqueue", Sink::Storage::ReadOnly).diskUsage(); |
397 | size += Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier + ".synchronizerqueue", Akonadi2::Storage::ReadOnly).diskUsage(); | 397 | size += Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".synchronizerqueue", Sink::Storage::ReadOnly).diskUsage(); |
398 | size += Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier + ".changereplay", Akonadi2::Storage::ReadOnly).diskUsage(); | 398 | size += Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".changereplay", Sink::Storage::ReadOnly).diskUsage(); |
399 | return size; | 399 | return size; |
400 | } | 400 | } |
401 | 401 | ||
@@ -413,9 +413,9 @@ int GenericResource::error() const | |||
413 | void GenericResource::enqueueCommand(MessageQueue &mq, int commandId, const QByteArray &data) | 413 | void GenericResource::enqueueCommand(MessageQueue &mq, int commandId, const QByteArray &data) |
414 | { | 414 | { |
415 | flatbuffers::FlatBufferBuilder fbb; | 415 | flatbuffers::FlatBufferBuilder fbb; |
416 | auto commandData = Akonadi2::EntityBuffer::appendAsVector(fbb, data.constData(), data.size()); | 416 | auto commandData = Sink::EntityBuffer::appendAsVector(fbb, data.constData(), data.size()); |
417 | auto buffer = Akonadi2::CreateQueuedCommand(fbb, commandId, commandData); | 417 | auto buffer = Sink::CreateQueuedCommand(fbb, commandId, commandData); |
418 | Akonadi2::FinishQueuedCommandBuffer(fbb, buffer); | 418 | Sink::FinishQueuedCommandBuffer(fbb, buffer); |
419 | mq.enqueue(fbb.GetBufferPointer(), fbb.GetSize()); | 419 | mq.enqueue(fbb.GetBufferPointer(), fbb.GetSize()); |
420 | } | 420 | } |
421 | 421 | ||
@@ -440,8 +440,8 @@ KAsync::Job<void> GenericResource::synchronizeWithSource() | |||
440 | Log() << " Synchronizing"; | 440 | Log() << " Synchronizing"; |
441 | //Changereplay would deadlock otherwise when trying to open the synchronization store | 441 | //Changereplay would deadlock otherwise when trying to open the synchronization store |
442 | enableChangeReplay(false); | 442 | enableChangeReplay(false); |
443 | auto mainStore = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::storageLocation(), mResourceInstanceIdentifier, Akonadi2::Storage::ReadOnly); | 443 | auto mainStore = QSharedPointer<Sink::Storage>::create(Sink::storageLocation(), mResourceInstanceIdentifier, Sink::Storage::ReadOnly); |
444 | auto syncStore = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite); | 444 | auto syncStore = QSharedPointer<Sink::Storage>::create(Sink::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Sink::Storage::ReadWrite); |
445 | synchronizeWithSource(*mainStore, *syncStore).then<void>([this, mainStore, syncStore]() { | 445 | synchronizeWithSource(*mainStore, *syncStore).then<void>([this, mainStore, syncStore]() { |
446 | Log() << "Done Synchronizing"; | 446 | Log() << "Done Synchronizing"; |
447 | enableChangeReplay(true); | 447 | enableChangeReplay(true); |
@@ -449,7 +449,7 @@ KAsync::Job<void> GenericResource::synchronizeWithSource() | |||
449 | }); | 449 | }); |
450 | } | 450 | } |
451 | 451 | ||
452 | KAsync::Job<void> GenericResource::synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore) | 452 | KAsync::Job<void> GenericResource::synchronizeWithSource(Sink::Storage &mainStore, Sink::Storage &synchronizationStore) |
453 | { | 453 | { |
454 | return KAsync::null<void>(); | 454 | return KAsync::null<void>(); |
455 | } | 455 | } |
@@ -508,7 +508,7 @@ void GenericResource::setLowerBoundRevision(qint64 revision) | |||
508 | updateLowerBoundRevision(); | 508 | updateLowerBoundRevision(); |
509 | } | 509 | } |
510 | 510 | ||
511 | void GenericResource::createEntity(const QByteArray &akonadiId, const QByteArray &bufferType, const Akonadi2::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback) | 511 | void GenericResource::createEntity(const QByteArray &sinkId, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback) |
512 | { | 512 | { |
513 | //These changes are coming from the source | 513 | //These changes are coming from the source |
514 | const auto replayToSource = false; | 514 | const auto replayToSource = false; |
@@ -516,45 +516,45 @@ void GenericResource::createEntity(const QByteArray &akonadiId, const QByteArray | |||
516 | adaptorFactory.createBuffer(domainObject, entityFbb); | 516 | adaptorFactory.createBuffer(domainObject, entityFbb); |
517 | flatbuffers::FlatBufferBuilder fbb; | 517 | flatbuffers::FlatBufferBuilder fbb; |
518 | //This is the resource type and not the domain type | 518 | //This is the resource type and not the domain type |
519 | auto entityId = fbb.CreateString(akonadiId.toStdString()); | 519 | auto entityId = fbb.CreateString(sinkId.toStdString()); |
520 | auto type = fbb.CreateString(bufferType.toStdString()); | 520 | auto type = fbb.CreateString(bufferType.toStdString()); |
521 | auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 521 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
522 | auto location = Akonadi2::Commands::CreateCreateEntity(fbb, entityId, type, delta, replayToSource); | 522 | auto location = Sink::Commands::CreateCreateEntity(fbb, entityId, type, delta, replayToSource); |
523 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 523 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); |
524 | callback(BufferUtils::extractBuffer(fbb)); | 524 | callback(BufferUtils::extractBuffer(fbb)); |
525 | } | 525 | } |
526 | 526 | ||
527 | void GenericResource::modifyEntity(const QByteArray &akonadiId, qint64 revision, const QByteArray &bufferType, const Akonadi2::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback) | 527 | void GenericResource::modifyEntity(const QByteArray &sinkId, qint64 revision, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback) |
528 | { | 528 | { |
529 | //These changes are coming from the source | 529 | //These changes are coming from the source |
530 | const auto replayToSource = false; | 530 | const auto replayToSource = false; |
531 | flatbuffers::FlatBufferBuilder entityFbb; | 531 | flatbuffers::FlatBufferBuilder entityFbb; |
532 | adaptorFactory.createBuffer(domainObject, entityFbb); | 532 | adaptorFactory.createBuffer(domainObject, entityFbb); |
533 | flatbuffers::FlatBufferBuilder fbb; | 533 | flatbuffers::FlatBufferBuilder fbb; |
534 | auto entityId = fbb.CreateString(akonadiId.toStdString()); | 534 | auto entityId = fbb.CreateString(sinkId.toStdString()); |
535 | //This is the resource type and not the domain type | 535 | //This is the resource type and not the domain type |
536 | auto type = fbb.CreateString(bufferType.toStdString()); | 536 | auto type = fbb.CreateString(bufferType.toStdString()); |
537 | auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 537 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
538 | //TODO removals | 538 | //TODO removals |
539 | auto location = Akonadi2::Commands::CreateModifyEntity(fbb, revision, entityId, 0, type, delta, replayToSource); | 539 | auto location = Sink::Commands::CreateModifyEntity(fbb, revision, entityId, 0, type, delta, replayToSource); |
540 | Akonadi2::Commands::FinishModifyEntityBuffer(fbb, location); | 540 | Sink::Commands::FinishModifyEntityBuffer(fbb, location); |
541 | callback(BufferUtils::extractBuffer(fbb)); | 541 | callback(BufferUtils::extractBuffer(fbb)); |
542 | } | 542 | } |
543 | 543 | ||
544 | void GenericResource::deleteEntity(const QByteArray &akonadiId, qint64 revision, const QByteArray &bufferType, std::function<void(const QByteArray &)> callback) | 544 | void GenericResource::deleteEntity(const QByteArray &sinkId, qint64 revision, const QByteArray &bufferType, std::function<void(const QByteArray &)> callback) |
545 | { | 545 | { |
546 | //These changes are coming from the source | 546 | //These changes are coming from the source |
547 | const auto replayToSource = false; | 547 | const auto replayToSource = false; |
548 | flatbuffers::FlatBufferBuilder fbb; | 548 | flatbuffers::FlatBufferBuilder fbb; |
549 | auto entityId = fbb.CreateString(akonadiId.toStdString()); | 549 | auto entityId = fbb.CreateString(sinkId.toStdString()); |
550 | //This is the resource type and not the domain type | 550 | //This is the resource type and not the domain type |
551 | auto type = fbb.CreateString(bufferType.toStdString()); | 551 | auto type = fbb.CreateString(bufferType.toStdString()); |
552 | auto location = Akonadi2::Commands::CreateDeleteEntity(fbb, revision, entityId, type, replayToSource); | 552 | auto location = Sink::Commands::CreateDeleteEntity(fbb, revision, entityId, type, replayToSource); |
553 | Akonadi2::Commands::FinishDeleteEntityBuffer(fbb, location); | 553 | Sink::Commands::FinishDeleteEntityBuffer(fbb, location); |
554 | callback(BufferUtils::extractBuffer(fbb)); | 554 | callback(BufferUtils::extractBuffer(fbb)); |
555 | } | 555 | } |
556 | 556 | ||
557 | void GenericResource::recordRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Akonadi2::Storage::Transaction &transaction) | 557 | void GenericResource::recordRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Sink::Storage::Transaction &transaction) |
558 | { | 558 | { |
559 | Index index("rid.mapping." + bufferType, transaction); | 559 | Index index("rid.mapping." + bufferType, transaction); |
560 | Index localIndex("localid.mapping." + bufferType, transaction); | 560 | Index localIndex("localid.mapping." + bufferType, transaction); |
@@ -562,7 +562,7 @@ void GenericResource::recordRemoteId(const QByteArray &bufferType, const QByteAr | |||
562 | localIndex.add(localId, remoteId); | 562 | localIndex.add(localId, remoteId); |
563 | } | 563 | } |
564 | 564 | ||
565 | void GenericResource::removeRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Akonadi2::Storage::Transaction &transaction) | 565 | void GenericResource::removeRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Sink::Storage::Transaction &transaction) |
566 | { | 566 | { |
567 | Index index("rid.mapping." + bufferType, transaction); | 567 | Index index("rid.mapping." + bufferType, transaction); |
568 | Index localIndex("localid.mapping." + bufferType, transaction); | 568 | Index localIndex("localid.mapping." + bufferType, transaction); |
@@ -570,21 +570,21 @@ void GenericResource::removeRemoteId(const QByteArray &bufferType, const QByteAr | |||
570 | localIndex.remove(localId, remoteId); | 570 | localIndex.remove(localId, remoteId); |
571 | } | 571 | } |
572 | 572 | ||
573 | QByteArray GenericResource::resolveRemoteId(const QByteArray &bufferType, const QByteArray &remoteId, Akonadi2::Storage::Transaction &transaction) | 573 | QByteArray GenericResource::resolveRemoteId(const QByteArray &bufferType, const QByteArray &remoteId, Sink::Storage::Transaction &transaction) |
574 | { | 574 | { |
575 | //Lookup local id for remote id, or insert a new pair otherwise | 575 | //Lookup local id for remote id, or insert a new pair otherwise |
576 | Index index("rid.mapping." + bufferType, transaction); | 576 | Index index("rid.mapping." + bufferType, transaction); |
577 | Index localIndex("localid.mapping." + bufferType, transaction); | 577 | Index localIndex("localid.mapping." + bufferType, transaction); |
578 | QByteArray akonadiId = index.lookup(remoteId); | 578 | QByteArray sinkId = index.lookup(remoteId); |
579 | if (akonadiId.isEmpty()) { | 579 | if (sinkId.isEmpty()) { |
580 | akonadiId = QUuid::createUuid().toString().toUtf8(); | 580 | sinkId = QUuid::createUuid().toString().toUtf8(); |
581 | index.add(remoteId, akonadiId); | 581 | index.add(remoteId, sinkId); |
582 | localIndex.add(akonadiId, remoteId); | 582 | localIndex.add(sinkId, remoteId); |
583 | } | 583 | } |
584 | return akonadiId; | 584 | return sinkId; |
585 | } | 585 | } |
586 | 586 | ||
587 | QByteArray GenericResource::resolveLocalId(const QByteArray &bufferType, const QByteArray &localId, Akonadi2::Storage::Transaction &transaction) | 587 | QByteArray GenericResource::resolveLocalId(const QByteArray &bufferType, const QByteArray &localId, Sink::Storage::Transaction &transaction) |
588 | { | 588 | { |
589 | Index index("localid.mapping." + bufferType, transaction); | 589 | Index index("localid.mapping." + bufferType, transaction); |
590 | QByteArray remoteId = index.lookup(localId); | 590 | QByteArray remoteId = index.lookup(localId); |
@@ -595,29 +595,29 @@ QByteArray GenericResource::resolveLocalId(const QByteArray &bufferType, const Q | |||
595 | return remoteId; | 595 | return remoteId; |
596 | } | 596 | } |
597 | 597 | ||
598 | void GenericResource::scanForRemovals(Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction, const QByteArray &bufferType, const std::function<void(const std::function<void(const QByteArray &key)> &callback)> &entryGenerator, std::function<bool(const QByteArray &remoteId)> exists) | 598 | void GenericResource::scanForRemovals(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, const QByteArray &bufferType, const std::function<void(const std::function<void(const QByteArray &key)> &callback)> &entryGenerator, std::function<bool(const QByteArray &remoteId)> exists) |
599 | { | 599 | { |
600 | entryGenerator([this, &transaction, bufferType, &synchronizationTransaction, &exists](const QByteArray &key) { | 600 | entryGenerator([this, &transaction, bufferType, &synchronizationTransaction, &exists](const QByteArray &key) { |
601 | auto akonadiId = Akonadi2::Storage::uidFromKey(key); | 601 | auto sinkId = Sink::Storage::uidFromKey(key); |
602 | Trace() << "Checking for removal " << key; | 602 | Trace() << "Checking for removal " << key; |
603 | const auto remoteId = resolveLocalId(bufferType, akonadiId, synchronizationTransaction); | 603 | const auto remoteId = resolveLocalId(bufferType, sinkId, synchronizationTransaction); |
604 | //If we have no remoteId, the entity hasn't been replayed to the source yet | 604 | //If we have no remoteId, the entity hasn't been replayed to the source yet |
605 | if (!remoteId.isEmpty()) { | 605 | if (!remoteId.isEmpty()) { |
606 | if (!exists(remoteId)) { | 606 | if (!exists(remoteId)) { |
607 | Trace() << "Found a removed entity: " << akonadiId; | 607 | Trace() << "Found a removed entity: " << sinkId; |
608 | deleteEntity(akonadiId, Akonadi2::Storage::maxRevision(transaction), bufferType, [this](const QByteArray &buffer) { | 608 | deleteEntity(sinkId, Sink::Storage::maxRevision(transaction), bufferType, [this](const QByteArray &buffer) { |
609 | enqueueCommand(mSynchronizerQueue, Akonadi2::Commands::DeleteEntityCommand, buffer); | 609 | enqueueCommand(mSynchronizerQueue, Sink::Commands::DeleteEntityCommand, buffer); |
610 | }); | 610 | }); |
611 | } | 611 | } |
612 | } | 612 | } |
613 | }); | 613 | }); |
614 | } | 614 | } |
615 | 615 | ||
616 | static QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor> getLatest(const Akonadi2::Storage::NamedDatabase &db, const QByteArray &uid, DomainTypeAdaptorFactoryInterface &adaptorFactory) | 616 | static QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> getLatest(const Sink::Storage::NamedDatabase &db, const QByteArray &uid, DomainTypeAdaptorFactoryInterface &adaptorFactory) |
617 | { | 617 | { |
618 | QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor> current; | 618 | QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> current; |
619 | db.findLatest(uid, [¤t, &adaptorFactory](const QByteArray &key, const QByteArray &data) -> bool { | 619 | db.findLatest(uid, [¤t, &adaptorFactory](const QByteArray &key, const QByteArray &data) -> bool { |
620 | Akonadi2::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); | 620 | Sink::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); |
621 | if (!buffer.isValid()) { | 621 | if (!buffer.isValid()) { |
622 | Warning() << "Read invalid buffer from disk"; | 622 | Warning() << "Read invalid buffer from disk"; |
623 | } else { | 623 | } else { |
@@ -625,35 +625,35 @@ static QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor> getLatest(cons | |||
625 | } | 625 | } |
626 | return false; | 626 | return false; |
627 | }, | 627 | }, |
628 | [](const Akonadi2::Storage::Error &error) { | 628 | [](const Sink::Storage::Error &error) { |
629 | Warning() << "Failed to read current value from storage: " << error.message; | 629 | Warning() << "Failed to read current value from storage: " << error.message; |
630 | }); | 630 | }); |
631 | return current; | 631 | return current; |
632 | } | 632 | } |
633 | 633 | ||
634 | void GenericResource::createOrModify(Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction, DomainTypeAdaptorFactoryInterface &adaptorFactory, const QByteArray &bufferType, const QByteArray &remoteId, const Akonadi2::ApplicationDomain::ApplicationDomainType &entity) | 634 | void GenericResource::createOrModify(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, DomainTypeAdaptorFactoryInterface &adaptorFactory, const QByteArray &bufferType, const QByteArray &remoteId, const Sink::ApplicationDomain::ApplicationDomainType &entity) |
635 | { | 635 | { |
636 | auto mainDatabase = transaction.openDatabase(bufferType + ".main"); | 636 | auto mainDatabase = transaction.openDatabase(bufferType + ".main"); |
637 | const auto akonadiId = resolveRemoteId(bufferType, remoteId, synchronizationTransaction); | 637 | const auto sinkId = resolveRemoteId(bufferType, remoteId, synchronizationTransaction); |
638 | const auto found = mainDatabase.contains(akonadiId); | 638 | const auto found = mainDatabase.contains(sinkId); |
639 | if (!found) { | 639 | if (!found) { |
640 | Trace() << "Found a new entity: " << remoteId; | 640 | Trace() << "Found a new entity: " << remoteId; |
641 | createEntity(akonadiId, bufferType, entity, adaptorFactory, [this](const QByteArray &buffer) { | 641 | createEntity(sinkId, bufferType, entity, adaptorFactory, [this](const QByteArray &buffer) { |
642 | enqueueCommand(mSynchronizerQueue, Akonadi2::Commands::CreateEntityCommand, buffer); | 642 | enqueueCommand(mSynchronizerQueue, Sink::Commands::CreateEntityCommand, buffer); |
643 | }); | 643 | }); |
644 | } else { //modification | 644 | } else { //modification |
645 | if (auto current = getLatest(mainDatabase, akonadiId, adaptorFactory)) { | 645 | if (auto current = getLatest(mainDatabase, sinkId, adaptorFactory)) { |
646 | bool changed = false; | 646 | bool changed = false; |
647 | for (const auto &property : entity.changedProperties()) { | 647 | for (const auto &property : entity.changedProperties()) { |
648 | if (entity.getProperty(property) != current->getProperty(property)) { | 648 | if (entity.getProperty(property) != current->getProperty(property)) { |
649 | Trace() << "Property changed " << akonadiId << property; | 649 | Trace() << "Property changed " << sinkId << property; |
650 | changed = true; | 650 | changed = true; |
651 | } | 651 | } |
652 | } | 652 | } |
653 | if (changed) { | 653 | if (changed) { |
654 | Trace() << "Found a modified entity: " << remoteId; | 654 | Trace() << "Found a modified entity: " << remoteId; |
655 | modifyEntity(akonadiId, Akonadi2::Storage::maxRevision(transaction), bufferType, entity, adaptorFactory, [this](const QByteArray &buffer) { | 655 | modifyEntity(sinkId, Sink::Storage::maxRevision(transaction), bufferType, entity, adaptorFactory, [this](const QByteArray &buffer) { |
656 | enqueueCommand(mSynchronizerQueue, Akonadi2::Commands::ModifyEntityCommand, buffer); | 656 | enqueueCommand(mSynchronizerQueue, Sink::Commands::ModifyEntityCommand, buffer); |
657 | }); | 657 | }); |
658 | } | 658 | } |
659 | } else { | 659 | } else { |
diff --git a/common/genericresource.h b/common/genericresource.h index d71061c..4ae2645 100644 --- a/common/genericresource.h +++ b/common/genericresource.h | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | #pragma once | 20 | #pragma once |
21 | 21 | ||
22 | #include <akonadi2common_export.h> | 22 | #include <sinkcommon_export.h> |
23 | #include <resource.h> | 23 | #include <resource.h> |
24 | #include <messagequeue.h> | 24 | #include <messagequeue.h> |
25 | #include <flatbuffers/flatbuffers.h> | 25 | #include <flatbuffers/flatbuffers.h> |
@@ -29,7 +29,7 @@ | |||
29 | class CommandProcessor; | 29 | class CommandProcessor; |
30 | class ChangeReplay; | 30 | class ChangeReplay; |
31 | 31 | ||
32 | namespace Akonadi2 | 32 | namespace Sink |
33 | { | 33 | { |
34 | class Pipeline; | 34 | class Pipeline; |
35 | class Preprocessor; | 35 | class Preprocessor; |
@@ -37,7 +37,7 @@ class Preprocessor; | |||
37 | /** | 37 | /** |
38 | * Generic Resource implementation. | 38 | * Generic Resource implementation. |
39 | */ | 39 | */ |
40 | class AKONADI2COMMON_EXPORT GenericResource : public Resource | 40 | class SINKCOMMON_EXPORT GenericResource : public Resource |
41 | { | 41 | { |
42 | public: | 42 | public: |
43 | GenericResource(const QByteArray &resourceInstanceIdentifier, const QSharedPointer<Pipeline> &pipeline = QSharedPointer<Pipeline>()); | 43 | GenericResource(const QByteArray &resourceInstanceIdentifier, const QSharedPointer<Pipeline> &pipeline = QSharedPointer<Pipeline>()); |
@@ -45,7 +45,7 @@ public: | |||
45 | 45 | ||
46 | virtual void processCommand(int commandId, const QByteArray &data) Q_DECL_OVERRIDE; | 46 | virtual void processCommand(int commandId, const QByteArray &data) Q_DECL_OVERRIDE; |
47 | virtual KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE; | 47 | virtual KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE; |
48 | virtual KAsync::Job<void> synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore); | 48 | virtual KAsync::Job<void> synchronizeWithSource(Sink::Storage &mainStore, Sink::Storage &synchronizationStore); |
49 | virtual KAsync::Job<void> processAllMessages() Q_DECL_OVERRIDE; | 49 | virtual KAsync::Job<void> processAllMessages() Q_DECL_OVERRIDE; |
50 | virtual void setLowerBoundRevision(qint64 revision) Q_DECL_OVERRIDE; | 50 | virtual void setLowerBoundRevision(qint64 revision) Q_DECL_OVERRIDE; |
51 | virtual KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue); | 51 | virtual KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue); |
@@ -60,34 +60,34 @@ private Q_SLOTS: | |||
60 | 60 | ||
61 | protected: | 61 | protected: |
62 | void enableChangeReplay(bool); | 62 | void enableChangeReplay(bool); |
63 | void addType(const QByteArray &type, DomainTypeAdaptorFactoryInterface::Ptr factory, const QVector<Akonadi2::Preprocessor*> &preprocessors); | 63 | void addType(const QByteArray &type, DomainTypeAdaptorFactoryInterface::Ptr factory, const QVector<Sink::Preprocessor*> &preprocessors); |
64 | virtual KAsync::Job<void> replay(Akonadi2::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value); | 64 | virtual KAsync::Job<void> replay(Sink::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value); |
65 | void onProcessorError(int errorCode, const QString &errorMessage); | 65 | void onProcessorError(int errorCode, const QString &errorMessage); |
66 | void enqueueCommand(MessageQueue &mq, int commandId, const QByteArray &data); | 66 | void enqueueCommand(MessageQueue &mq, int commandId, const QByteArray &data); |
67 | 67 | ||
68 | static void createEntity(const QByteArray &localId, const QByteArray &bufferType, const Akonadi2::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback); | 68 | static void createEntity(const QByteArray &localId, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback); |
69 | static void modifyEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, const Akonadi2::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback); | 69 | static void modifyEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, const Sink::ApplicationDomain::ApplicationDomainType &domainObject, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<void(const QByteArray &)> callback); |
70 | static void deleteEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, std::function<void(const QByteArray &)> callback); | 70 | static void deleteEntity(const QByteArray &localId, qint64 revision, const QByteArray &bufferType, std::function<void(const QByteArray &)> callback); |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Records a localId to remoteId mapping | 73 | * Records a localId to remoteId mapping |
74 | */ | 74 | */ |
75 | void recordRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Akonadi2::Storage::Transaction &transaction); | 75 | void recordRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Sink::Storage::Transaction &transaction); |
76 | void removeRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Akonadi2::Storage::Transaction &transaction); | 76 | void removeRemoteId(const QByteArray &bufferType, const QByteArray &localId, const QByteArray &remoteId, Sink::Storage::Transaction &transaction); |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Tries to find a local id for the remote id, and creates a new local id otherwise. | 79 | * Tries to find a local id for the remote id, and creates a new local id otherwise. |
80 | * | 80 | * |
81 | * The new local id is recorded in the local to remote id mapping. | 81 | * The new local id is recorded in the local to remote id mapping. |
82 | */ | 82 | */ |
83 | QByteArray resolveRemoteId(const QByteArray &type, const QByteArray &remoteId, Akonadi2::Storage::Transaction &transaction); | 83 | QByteArray resolveRemoteId(const QByteArray &type, const QByteArray &remoteId, Sink::Storage::Transaction &transaction); |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Tries to find a remote id for a local id. | 86 | * Tries to find a remote id for a local id. |
87 | * | 87 | * |
88 | * This can fail if the entity hasn't been written back to the server yet. | 88 | * This can fail if the entity hasn't been written back to the server yet. |
89 | */ | 89 | */ |
90 | QByteArray resolveLocalId(const QByteArray &bufferType, const QByteArray &localId, Akonadi2::Storage::Transaction &transaction); | 90 | QByteArray resolveLocalId(const QByteArray &bufferType, const QByteArray &localId, Sink::Storage::Transaction &transaction); |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * A synchronous algorithm to remove entities that are no longer existing. | 93 | * A synchronous algorithm to remove entities that are no longer existing. |
@@ -99,14 +99,14 @@ protected: | |||
99 | * | 99 | * |
100 | * All functions are called synchronously, and both @param entryGenerator and @param exists need to be synchronous. | 100 | * All functions are called synchronously, and both @param entryGenerator and @param exists need to be synchronous. |
101 | */ | 101 | */ |
102 | void scanForRemovals(Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction, const QByteArray &bufferType, const std::function<void(const std::function<void(const QByteArray &key)> &callback)> &entryGenerator, std::function<bool(const QByteArray &remoteId)> exists); | 102 | void scanForRemovals(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, const QByteArray &bufferType, const std::function<void(const std::function<void(const QByteArray &key)> &callback)> &entryGenerator, std::function<bool(const QByteArray &remoteId)> exists); |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * An algorithm to create or modify the entity. | 105 | * An algorithm to create or modify the entity. |
106 | * | 106 | * |
107 | * Depending on whether the entity is locally available, or has changed. | 107 | * Depending on whether the entity is locally available, or has changed. |
108 | */ | 108 | */ |
109 | void createOrModify(Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction, DomainTypeAdaptorFactoryInterface &adaptorFactory, const QByteArray &bufferType, const QByteArray &remoteId, const Akonadi2::ApplicationDomain::ApplicationDomainType &entity); | 109 | void createOrModify(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, DomainTypeAdaptorFactoryInterface &adaptorFactory, const QByteArray &bufferType, const QByteArray &remoteId, const Sink::ApplicationDomain::ApplicationDomainType &entity); |
110 | 110 | ||
111 | MessageQueue mUserQueue; | 111 | MessageQueue mUserQueue; |
112 | MessageQueue mSynchronizerQueue; | 112 | MessageQueue mSynchronizerQueue; |
diff --git a/common/index.cpp b/common/index.cpp index f4de93c..25dfb7c 100644 --- a/common/index.cpp +++ b/common/index.cpp | |||
@@ -1,15 +1,15 @@ | |||
1 | #include "index.h" | 1 | #include "index.h" |
2 | #include <QDebug> | 2 | #include <QDebug> |
3 | 3 | ||
4 | Index::Index(const QString &storageRoot, const QString &name, Akonadi2::Storage::AccessMode mode) | 4 | Index::Index(const QString &storageRoot, const QString &name, Sink::Storage::AccessMode mode) |
5 | : mTransaction(Akonadi2::Storage(storageRoot, name, mode).createTransaction(mode)), | 5 | : mTransaction(Sink::Storage(storageRoot, name, mode).createTransaction(mode)), |
6 | mDb(mTransaction.openDatabase(name.toLatin1(), std::function<void(const Akonadi2::Storage::Error &)>(), true)) | 6 | mDb(mTransaction.openDatabase(name.toLatin1(), std::function<void(const Sink::Storage::Error &)>(), true)) |
7 | { | 7 | { |
8 | 8 | ||
9 | } | 9 | } |
10 | 10 | ||
11 | Index::Index(const QByteArray &name, Akonadi2::Storage::Transaction &transaction) | 11 | Index::Index(const QByteArray &name, Sink::Storage::Transaction &transaction) |
12 | : mDb(transaction.openDatabase(name, std::function<void(const Akonadi2::Storage::Error &)>(), true)) | 12 | : mDb(transaction.openDatabase(name, std::function<void(const Sink::Storage::Error &)>(), true)) |
13 | { | 13 | { |
14 | 14 | ||
15 | } | 15 | } |
@@ -31,7 +31,7 @@ void Index::lookup(const QByteArray &key, const std::function<void(const QByteAr | |||
31 | resultHandler(value); | 31 | resultHandler(value); |
32 | return true; | 32 | return true; |
33 | }, | 33 | }, |
34 | [errorHandler](const Akonadi2::Storage::Error &error) { | 34 | [errorHandler](const Sink::Storage::Error &error) { |
35 | qDebug() << "Error while retrieving value" << error.message; | 35 | qDebug() << "Error while retrieving value" << error.message; |
36 | errorHandler(Error(error.store, error.code, error.message)); | 36 | errorHandler(Error(error.store, error.code, error.message)); |
37 | } | 37 | } |
diff --git a/common/index.h b/common/index.h index 6b06d26..20213b2 100644 --- a/common/index.h +++ b/common/index.h | |||
@@ -25,8 +25,8 @@ public: | |||
25 | int code; | 25 | int code; |
26 | }; | 26 | }; |
27 | 27 | ||
28 | Index(const QString &storageRoot, const QString &name, Akonadi2::Storage::AccessMode mode = Akonadi2::Storage::ReadOnly); | 28 | Index(const QString &storageRoot, const QString &name, Sink::Storage::AccessMode mode = Sink::Storage::ReadOnly); |
29 | Index(const QByteArray &name, Akonadi2::Storage::Transaction &); | 29 | Index(const QByteArray &name, Sink::Storage::Transaction &); |
30 | 30 | ||
31 | void add(const QByteArray &key, const QByteArray &value); | 31 | void add(const QByteArray &key, const QByteArray &value); |
32 | void remove(const QByteArray &key, const QByteArray &value); | 32 | void remove(const QByteArray &key, const QByteArray &value); |
@@ -37,6 +37,6 @@ public: | |||
37 | 37 | ||
38 | private: | 38 | private: |
39 | Q_DISABLE_COPY(Index); | 39 | Q_DISABLE_COPY(Index); |
40 | Akonadi2::Storage::Transaction mTransaction; | 40 | Sink::Storage::Transaction mTransaction; |
41 | Akonadi2::Storage::NamedDatabase mDb; | 41 | Sink::Storage::NamedDatabase mDb; |
42 | }; | 42 | }; |
diff --git a/common/indexupdater.h b/common/indexupdater.h index 48144e6..ced220b 100644 --- a/common/indexupdater.h +++ b/common/indexupdater.h | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <pipeline.h> | 21 | #include <pipeline.h> |
22 | #include <index.h> | 22 | #include <index.h> |
23 | 23 | ||
24 | class IndexUpdater : public Akonadi2::Preprocessor { | 24 | class IndexUpdater : public Sink::Preprocessor { |
25 | public: | 25 | public: |
26 | IndexUpdater(const QByteArray &index, const QByteArray &type, const QByteArray &property) | 26 | IndexUpdater(const QByteArray &index, const QByteArray &type, const QByteArray &property) |
27 | :mIndexIdentifier(index), | 27 | :mIndexIdentifier(index), |
@@ -31,31 +31,31 @@ public: | |||
31 | 31 | ||
32 | } | 32 | } |
33 | 33 | ||
34 | void newEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 34 | void newEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
35 | { | 35 | { |
36 | add(newEntity.getProperty(mProperty), uid, transaction); | 36 | add(newEntity.getProperty(mProperty), uid, transaction); |
37 | } | 37 | } |
38 | 38 | ||
39 | void modifiedEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 39 | void modifiedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
40 | { | 40 | { |
41 | remove(oldEntity.getProperty(mProperty), uid, transaction); | 41 | remove(oldEntity.getProperty(mProperty), uid, transaction); |
42 | add(newEntity.getProperty(mProperty), uid, transaction); | 42 | add(newEntity.getProperty(mProperty), uid, transaction); |
43 | } | 43 | } |
44 | 44 | ||
45 | void deletedEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 45 | void deletedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
46 | { | 46 | { |
47 | remove(oldEntity.getProperty(mProperty), uid, transaction); | 47 | remove(oldEntity.getProperty(mProperty), uid, transaction); |
48 | } | 48 | } |
49 | 49 | ||
50 | private: | 50 | private: |
51 | void add(const QVariant &value, const QByteArray &uid, Akonadi2::Storage::Transaction &transaction) | 51 | void add(const QVariant &value, const QByteArray &uid, Sink::Storage::Transaction &transaction) |
52 | { | 52 | { |
53 | if (value.isValid()) { | 53 | if (value.isValid()) { |
54 | Index(mIndexIdentifier, transaction).add(value.toByteArray(), uid); | 54 | Index(mIndexIdentifier, transaction).add(value.toByteArray(), uid); |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | void remove(const QVariant &value, const QByteArray &uid, Akonadi2::Storage::Transaction &transaction) | 58 | void remove(const QVariant &value, const QByteArray &uid, Sink::Storage::Transaction &transaction) |
59 | { | 59 | { |
60 | //TODO hide notfound error | 60 | //TODO hide notfound error |
61 | Index(mIndexIdentifier, transaction).remove(value.toByteArray(), uid); | 61 | Index(mIndexIdentifier, transaction).remove(value.toByteArray(), uid); |
@@ -67,21 +67,21 @@ private: | |||
67 | }; | 67 | }; |
68 | 68 | ||
69 | template<typename DomainType> | 69 | template<typename DomainType> |
70 | class DefaultIndexUpdater : public Akonadi2::Preprocessor { | 70 | class DefaultIndexUpdater : public Sink::Preprocessor { |
71 | public: | 71 | public: |
72 | void newEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 72 | void newEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
73 | { | 73 | { |
74 | Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::index(uid, newEntity, transaction); | 74 | Sink::ApplicationDomain::TypeImplementation<DomainType>::index(uid, newEntity, transaction); |
75 | } | 75 | } |
76 | 76 | ||
77 | void modifiedEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 77 | void modifiedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
78 | { | 78 | { |
79 | Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::removeIndex(uid, oldEntity, transaction); | 79 | Sink::ApplicationDomain::TypeImplementation<DomainType>::removeIndex(uid, oldEntity, transaction); |
80 | Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::index(uid, newEntity, transaction); | 80 | Sink::ApplicationDomain::TypeImplementation<DomainType>::index(uid, newEntity, transaction); |
81 | } | 81 | } |
82 | 82 | ||
83 | void deletedEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 83 | void deletedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
84 | { | 84 | { |
85 | Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::removeIndex(uid, oldEntity, transaction); | 85 | Sink::ApplicationDomain::TypeImplementation<DomainType>::removeIndex(uid, oldEntity, transaction); |
86 | } | 86 | } |
87 | }; | 87 | }; |
diff --git a/common/inspection.h b/common/inspection.h index ecf5b3d..b9f6bf3 100644 --- a/common/inspection.h +++ b/common/inspection.h | |||
@@ -23,11 +23,11 @@ | |||
23 | #include <QVariant> | 23 | #include <QVariant> |
24 | #include "applicationdomaintype.h" | 24 | #include "applicationdomaintype.h" |
25 | 25 | ||
26 | namespace Akonadi2 { | 26 | namespace Sink { |
27 | namespace Resources { | 27 | namespace Resources { |
28 | 28 | ||
29 | struct Inspection { | 29 | struct Inspection { |
30 | static Inspection PropertyInspection(const Akonadi2::ApplicationDomain::Entity &entity, const QByteArray &property, const QVariant &expectedValue) | 30 | static Inspection PropertyInspection(const Sink::ApplicationDomain::Entity &entity, const QByteArray &property, const QVariant &expectedValue) |
31 | { | 31 | { |
32 | Inspection inspection; | 32 | Inspection inspection; |
33 | inspection.resourceIdentifier = entity.resourceInstanceIdentifier(); | 33 | inspection.resourceIdentifier = entity.resourceInstanceIdentifier(); |
@@ -37,7 +37,7 @@ struct Inspection { | |||
37 | return inspection; | 37 | return inspection; |
38 | } | 38 | } |
39 | 39 | ||
40 | static Inspection ExistenceInspection(const Akonadi2::ApplicationDomain::Entity &entity, bool exists) | 40 | static Inspection ExistenceInspection(const Sink::ApplicationDomain::Entity &entity, bool exists) |
41 | { | 41 | { |
42 | Inspection inspection; | 42 | Inspection inspection; |
43 | inspection.resourceIdentifier = entity.resourceInstanceIdentifier(); | 43 | inspection.resourceIdentifier = entity.resourceInstanceIdentifier(); |
diff --git a/common/listener.cpp b/common/listener.cpp index fa08472..13ebbbb 100644 --- a/common/listener.cpp +++ b/common/listener.cpp | |||
@@ -42,7 +42,7 @@ | |||
42 | Listener::Listener(const QByteArray &resourceInstanceIdentifier, QObject *parent) | 42 | Listener::Listener(const QByteArray &resourceInstanceIdentifier, QObject *parent) |
43 | : QObject(parent), | 43 | : QObject(parent), |
44 | m_server(new QLocalServer(this)), | 44 | m_server(new QLocalServer(this)), |
45 | m_resourceName(Akonadi2::resourceName(resourceInstanceIdentifier)), | 45 | m_resourceName(Sink::resourceName(resourceInstanceIdentifier)), |
46 | m_resourceInstanceIdentifier(resourceInstanceIdentifier), | 46 | m_resourceInstanceIdentifier(resourceInstanceIdentifier), |
47 | m_resource(0), | 47 | m_resource(0), |
48 | m_clientBufferProcessesTimer(new QTimer(this)), | 48 | m_clientBufferProcessesTimer(new QTimer(this)), |
@@ -209,20 +209,20 @@ void Listener::processCommand(int commandId, uint messageId, const QByteArray &c | |||
209 | { | 209 | { |
210 | bool success = true; | 210 | bool success = true; |
211 | switch (commandId) { | 211 | switch (commandId) { |
212 | case Akonadi2::Commands::HandshakeCommand: { | 212 | case Sink::Commands::HandshakeCommand: { |
213 | flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size()); | 213 | flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size()); |
214 | if (Akonadi2::Commands::VerifyHandshakeBuffer(verifier)) { | 214 | if (Sink::Commands::VerifyHandshakeBuffer(verifier)) { |
215 | auto buffer = Akonadi2::Commands::GetHandshake(commandBuffer.constData()); | 215 | auto buffer = Sink::Commands::GetHandshake(commandBuffer.constData()); |
216 | client.name = buffer->name()->c_str(); | 216 | client.name = buffer->name()->c_str(); |
217 | } else { | 217 | } else { |
218 | Warning() << "received invalid command"; | 218 | Warning() << "received invalid command"; |
219 | } | 219 | } |
220 | break; | 220 | break; |
221 | } | 221 | } |
222 | case Akonadi2::Commands::SynchronizeCommand: { | 222 | case Sink::Commands::SynchronizeCommand: { |
223 | flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size()); | 223 | flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size()); |
224 | if (Akonadi2::Commands::VerifySynchronizeBuffer(verifier)) { | 224 | if (Sink::Commands::VerifySynchronizeBuffer(verifier)) { |
225 | auto buffer = Akonadi2::Commands::GetSynchronize(commandBuffer.constData()); | 225 | auto buffer = Sink::Commands::GetSynchronize(commandBuffer.constData()); |
226 | Log() << QString("\tSynchronize request (id %1) from %2").arg(messageId).arg(client.name); | 226 | Log() << QString("\tSynchronize request (id %1) from %2").arg(messageId).arg(client.name); |
227 | auto timer = QSharedPointer<QTime>::create(); | 227 | auto timer = QSharedPointer<QTime>::create(); |
228 | timer->start(); | 228 | timer->start(); |
@@ -243,28 +243,28 @@ void Listener::processCommand(int commandId, uint messageId, const QByteArray &c | |||
243 | } | 243 | } |
244 | break; | 244 | break; |
245 | } | 245 | } |
246 | case Akonadi2::Commands::InspectionCommand: | 246 | case Sink::Commands::InspectionCommand: |
247 | case Akonadi2::Commands::FetchEntityCommand: | 247 | case Sink::Commands::FetchEntityCommand: |
248 | case Akonadi2::Commands::DeleteEntityCommand: | 248 | case Sink::Commands::DeleteEntityCommand: |
249 | case Akonadi2::Commands::ModifyEntityCommand: | 249 | case Sink::Commands::ModifyEntityCommand: |
250 | case Akonadi2::Commands::CreateEntityCommand: | 250 | case Sink::Commands::CreateEntityCommand: |
251 | Log() << "\tCommand id " << messageId << " of type \"" << Akonadi2::Commands::name(commandId) << "\" from " << client.name; | 251 | Log() << "\tCommand id " << messageId << " of type \"" << Sink::Commands::name(commandId) << "\" from " << client.name; |
252 | loadResource()->processCommand(commandId, commandBuffer); | 252 | loadResource()->processCommand(commandId, commandBuffer); |
253 | break; | 253 | break; |
254 | case Akonadi2::Commands::ShutdownCommand: | 254 | case Sink::Commands::ShutdownCommand: |
255 | Log() << QString("\tReceived shutdown command from %1").arg(client.name); | 255 | Log() << QString("\tReceived shutdown command from %1").arg(client.name); |
256 | //Immediately reject new connections | 256 | //Immediately reject new connections |
257 | m_server->close(); | 257 | m_server->close(); |
258 | QTimer::singleShot(0, this, &Listener::quit); | 258 | QTimer::singleShot(0, this, &Listener::quit); |
259 | break; | 259 | break; |
260 | case Akonadi2::Commands::PingCommand: | 260 | case Sink::Commands::PingCommand: |
261 | Log() << QString("\tReceived ping command from %1").arg(client.name); | 261 | Log() << QString("\tReceived ping command from %1").arg(client.name); |
262 | break; | 262 | break; |
263 | case Akonadi2::Commands::RevisionReplayedCommand: { | 263 | case Sink::Commands::RevisionReplayedCommand: { |
264 | Log() << QString("\tReceived revision replayed command from %1").arg(client.name); | 264 | Log() << QString("\tReceived revision replayed command from %1").arg(client.name); |
265 | flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size()); | 265 | flatbuffers::Verifier verifier((const uint8_t *)commandBuffer.constData(), commandBuffer.size()); |
266 | if (Akonadi2::Commands::VerifyRevisionReplayedBuffer(verifier)) { | 266 | if (Sink::Commands::VerifyRevisionReplayedBuffer(verifier)) { |
267 | auto buffer = Akonadi2::Commands::GetRevisionReplayed(commandBuffer.constData()); | 267 | auto buffer = Sink::Commands::GetRevisionReplayed(commandBuffer.constData()); |
268 | client.currentRevision = buffer->revision(); | 268 | client.currentRevision = buffer->revision(); |
269 | } else { | 269 | } else { |
270 | Warning() << "received invalid command"; | 270 | Warning() << "received invalid command"; |
@@ -273,7 +273,7 @@ void Listener::processCommand(int commandId, uint messageId, const QByteArray &c | |||
273 | } | 273 | } |
274 | break; | 274 | break; |
275 | default: | 275 | default: |
276 | if (commandId > Akonadi2::Commands::CustomCommand) { | 276 | if (commandId > Sink::Commands::CustomCommand) { |
277 | Log() << QString("\tReceived custom command from %1: ").arg(client.name) << commandId; | 277 | Log() << QString("\tReceived custom command from %1: ").arg(client.name) << commandId; |
278 | loadResource()->processCommand(commandId, commandBuffer); | 278 | loadResource()->processCommand(commandId, commandBuffer); |
279 | } else { | 279 | } else { |
@@ -303,11 +303,11 @@ qint64 Listener::lowerBoundRevision() | |||
303 | void Listener::quit() | 303 | void Listener::quit() |
304 | { | 304 | { |
305 | //Broadcast shutdown notifications to open clients, so they don't try to restart the resource | 305 | //Broadcast shutdown notifications to open clients, so they don't try to restart the resource |
306 | auto command = Akonadi2::Commands::CreateNotification(m_fbb, Akonadi2::Commands::NotificationType::NotificationType_Shutdown); | 306 | auto command = Sink::Commands::CreateNotification(m_fbb, Sink::Commands::NotificationType::NotificationType_Shutdown); |
307 | Akonadi2::Commands::FinishNotificationBuffer(m_fbb, command); | 307 | Sink::Commands::FinishNotificationBuffer(m_fbb, command); |
308 | for (Client &client : m_connections) { | 308 | for (Client &client : m_connections) { |
309 | if (client.socket && client.socket->isOpen()) { | 309 | if (client.socket && client.socket->isOpen()) { |
310 | Akonadi2::Commands::write(client.socket, ++m_messageId, Akonadi2::Commands::NotificationCommand, m_fbb); | 310 | Sink::Commands::write(client.socket, ++m_messageId, Sink::Commands::NotificationCommand, m_fbb); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | m_fbb.Clear(); | 313 | m_fbb.Clear(); |
@@ -318,7 +318,7 @@ void Listener::quit() | |||
318 | 318 | ||
319 | bool Listener::processClientBuffer(Client &client) | 319 | bool Listener::processClientBuffer(Client &client) |
320 | { | 320 | { |
321 | static const int headerSize = Akonadi2::Commands::headerSize(); | 321 | static const int headerSize = Sink::Commands::headerSize(); |
322 | if (client.commandBuffer.size() < headerSize) { | 322 | if (client.commandBuffer.size() < headerSize) { |
323 | return false; | 323 | return false; |
324 | } | 324 | } |
@@ -339,7 +339,7 @@ bool Listener::processClientBuffer(Client &client) | |||
339 | const QByteArray commandBuffer = client.commandBuffer.left(size); | 339 | const QByteArray commandBuffer = client.commandBuffer.left(size); |
340 | client.commandBuffer.remove(0, size); | 340 | client.commandBuffer.remove(0, size); |
341 | processCommand(commandId, messageId, commandBuffer, client, [this, messageId, commandId, socket, clientName](bool success) { | 341 | processCommand(commandId, messageId, commandBuffer, client, [this, messageId, commandId, socket, clientName](bool success) { |
342 | Log() << QString("\tCompleted command messageid %1 of type \"%2\" from %3").arg(messageId).arg(QString(Akonadi2::Commands::name(commandId))).arg(clientName); | 342 | Log() << QString("\tCompleted command messageid %1 of type \"%2\" from %3").arg(messageId).arg(QString(Sink::Commands::name(commandId))).arg(clientName); |
343 | if (socket) { | 343 | if (socket) { |
344 | sendCommandCompleted(socket.data(), messageId, success); | 344 | sendCommandCompleted(socket.data(), messageId, success); |
345 | } else { | 345 | } else { |
@@ -359,9 +359,9 @@ void Listener::sendCommandCompleted(QLocalSocket *socket, uint messageId, bool s | |||
359 | return; | 359 | return; |
360 | } | 360 | } |
361 | 361 | ||
362 | auto command = Akonadi2::Commands::CreateCommandCompletion(m_fbb, messageId, success); | 362 | auto command = Sink::Commands::CreateCommandCompletion(m_fbb, messageId, success); |
363 | Akonadi2::Commands::FinishCommandCompletionBuffer(m_fbb, command); | 363 | Sink::Commands::FinishCommandCompletionBuffer(m_fbb, command); |
364 | Akonadi2::Commands::write(socket, ++m_messageId, Akonadi2::Commands::CommandCompletionCommand, m_fbb); | 364 | Sink::Commands::write(socket, ++m_messageId, Sink::Commands::CommandCompletionCommand, m_fbb); |
365 | m_fbb.Clear(); | 365 | m_fbb.Clear(); |
366 | } | 366 | } |
367 | 367 | ||
@@ -372,8 +372,8 @@ void Listener::refreshRevision(qint64 revision) | |||
372 | 372 | ||
373 | void Listener::updateClientsWithRevision(qint64 revision) | 373 | void Listener::updateClientsWithRevision(qint64 revision) |
374 | { | 374 | { |
375 | auto command = Akonadi2::Commands::CreateRevisionUpdate(m_fbb, revision); | 375 | auto command = Sink::Commands::CreateRevisionUpdate(m_fbb, revision); |
376 | Akonadi2::Commands::FinishRevisionUpdateBuffer(m_fbb, command); | 376 | Sink::Commands::FinishRevisionUpdateBuffer(m_fbb, command); |
377 | 377 | ||
378 | for (const Client &client: m_connections) { | 378 | for (const Client &client: m_connections) { |
379 | if (!client.socket || !client.socket->isValid()) { | 379 | if (!client.socket || !client.socket->isValid()) { |
@@ -381,44 +381,44 @@ void Listener::updateClientsWithRevision(qint64 revision) | |||
381 | } | 381 | } |
382 | 382 | ||
383 | Trace() << "Sending revision update for " << client.name << revision; | 383 | Trace() << "Sending revision update for " << client.name << revision; |
384 | Akonadi2::Commands::write(client.socket, ++m_messageId, Akonadi2::Commands::RevisionUpdateCommand, m_fbb); | 384 | Sink::Commands::write(client.socket, ++m_messageId, Sink::Commands::RevisionUpdateCommand, m_fbb); |
385 | } | 385 | } |
386 | m_fbb.Clear(); | 386 | m_fbb.Clear(); |
387 | } | 387 | } |
388 | 388 | ||
389 | void Listener::notify(const Akonadi2::Notification ¬ification) | 389 | void Listener::notify(const Sink::Notification ¬ification) |
390 | { | 390 | { |
391 | auto messageString = m_fbb.CreateString(notification.message.toUtf8().constData(), notification.message.toUtf8().size()); | 391 | auto messageString = m_fbb.CreateString(notification.message.toUtf8().constData(), notification.message.toUtf8().size()); |
392 | auto idString = m_fbb.CreateString(notification.id.constData(), notification.id.size()); | 392 | auto idString = m_fbb.CreateString(notification.id.constData(), notification.id.size()); |
393 | Akonadi2::Commands::NotificationBuilder builder(m_fbb); | 393 | Sink::Commands::NotificationBuilder builder(m_fbb); |
394 | builder.add_type(static_cast<Akonadi2::Commands::NotificationType>(notification.type)); | 394 | builder.add_type(static_cast<Sink::Commands::NotificationType>(notification.type)); |
395 | builder.add_code(notification.code); | 395 | builder.add_code(notification.code); |
396 | builder.add_identifier(idString); | 396 | builder.add_identifier(idString); |
397 | builder.add_message(messageString); | 397 | builder.add_message(messageString); |
398 | auto command = builder.Finish(); | 398 | auto command = builder.Finish(); |
399 | Akonadi2::Commands::FinishNotificationBuffer(m_fbb, command); | 399 | Sink::Commands::FinishNotificationBuffer(m_fbb, command); |
400 | for (Client &client : m_connections) { | 400 | for (Client &client : m_connections) { |
401 | if (client.socket && client.socket->isOpen()) { | 401 | if (client.socket && client.socket->isOpen()) { |
402 | Akonadi2::Commands::write(client.socket, ++m_messageId, Akonadi2::Commands::NotificationCommand, m_fbb); | 402 | Sink::Commands::write(client.socket, ++m_messageId, Sink::Commands::NotificationCommand, m_fbb); |
403 | } | 403 | } |
404 | } | 404 | } |
405 | m_fbb.Clear(); | 405 | m_fbb.Clear(); |
406 | } | 406 | } |
407 | 407 | ||
408 | Akonadi2::Resource *Listener::loadResource() | 408 | Sink::Resource *Listener::loadResource() |
409 | { | 409 | { |
410 | if (!m_resource) { | 410 | if (!m_resource) { |
411 | if (Akonadi2::ResourceFactory *resourceFactory = Akonadi2::ResourceFactory::load(m_resourceName)) { | 411 | if (Sink::ResourceFactory *resourceFactory = Sink::ResourceFactory::load(m_resourceName)) { |
412 | m_resource = resourceFactory->createResource(m_resourceInstanceIdentifier); | 412 | m_resource = resourceFactory->createResource(m_resourceInstanceIdentifier); |
413 | Trace() << QString("Resource factory: %1").arg((qlonglong)resourceFactory); | 413 | Trace() << QString("Resource factory: %1").arg((qlonglong)resourceFactory); |
414 | Trace() << QString("\tResource: %1").arg((qlonglong)m_resource); | 414 | Trace() << QString("\tResource: %1").arg((qlonglong)m_resource); |
415 | connect(m_resource, &Akonadi2::Resource::revisionUpdated, | 415 | connect(m_resource, &Sink::Resource::revisionUpdated, |
416 | this, &Listener::refreshRevision); | 416 | this, &Listener::refreshRevision); |
417 | connect(m_resource, &Akonadi2::Resource::notify, | 417 | connect(m_resource, &Sink::Resource::notify, |
418 | this, &Listener::notify); | 418 | this, &Listener::notify); |
419 | } else { | 419 | } else { |
420 | ErrorMsg() << "Failed to load resource " << m_resourceName; | 420 | ErrorMsg() << "Failed to load resource " << m_resourceName; |
421 | m_resource = new Akonadi2::Resource; | 421 | m_resource = new Sink::Resource; |
422 | } | 422 | } |
423 | } | 423 | } |
424 | return m_resource; | 424 | return m_resource; |
diff --git a/common/listener.h b/common/listener.h index 4112a6a..e17f315 100644 --- a/common/listener.h +++ b/common/listener.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <QLocalSocket> | 25 | #include <QLocalSocket> |
26 | #include <flatbuffers/flatbuffers.h> | 26 | #include <flatbuffers/flatbuffers.h> |
27 | 27 | ||
28 | namespace Akonadi2 | 28 | namespace Sink |
29 | { | 29 | { |
30 | class Resource; | 30 | class Resource; |
31 | class Notification; | 31 | class Notification; |
@@ -77,7 +77,7 @@ private Q_SLOTS: | |||
77 | void onDataAvailable(); | 77 | void onDataAvailable(); |
78 | void processClientBuffers(); | 78 | void processClientBuffers(); |
79 | void refreshRevision(qint64); | 79 | void refreshRevision(qint64); |
80 | void notify(const Akonadi2::Notification &); | 80 | void notify(const Sink::Notification &); |
81 | void quit(); | 81 | void quit(); |
82 | 82 | ||
83 | private: | 83 | private: |
@@ -85,7 +85,7 @@ private: | |||
85 | bool processClientBuffer(Client &client); | 85 | bool processClientBuffer(Client &client); |
86 | void sendCommandCompleted(QLocalSocket *socket, uint messageId, bool success); | 86 | void sendCommandCompleted(QLocalSocket *socket, uint messageId, bool success); |
87 | void updateClientsWithRevision(qint64); | 87 | void updateClientsWithRevision(qint64); |
88 | Akonadi2::Resource *loadResource(); | 88 | Sink::Resource *loadResource(); |
89 | void readFromSocket(QLocalSocket *socket); | 89 | void readFromSocket(QLocalSocket *socket); |
90 | qint64 lowerBoundRevision(); | 90 | qint64 lowerBoundRevision(); |
91 | 91 | ||
@@ -94,7 +94,7 @@ private: | |||
94 | flatbuffers::FlatBufferBuilder m_fbb; | 94 | flatbuffers::FlatBufferBuilder m_fbb; |
95 | const QByteArray m_resourceName; | 95 | const QByteArray m_resourceName; |
96 | const QByteArray m_resourceInstanceIdentifier; | 96 | const QByteArray m_resourceInstanceIdentifier; |
97 | Akonadi2::Resource *m_resource; | 97 | Sink::Resource *m_resource; |
98 | QTimer *m_clientBufferProcessesTimer; | 98 | QTimer *m_clientBufferProcessesTimer; |
99 | QTimer *m_checkConnectionsTimer; | 99 | QTimer *m_checkConnectionsTimer; |
100 | int m_messageId; | 100 | int m_messageId; |
diff --git a/common/listmodelresult.h b/common/listmodelresult.h index a095c2a..71a0d09 100644 --- a/common/listmodelresult.h +++ b/common/listmodelresult.h | |||
@@ -39,14 +39,14 @@ public: | |||
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | ListModelResult(const QSharedPointer<Akonadi2::ResultEmitter<T> > &emitter, const QList<QByteArray> &propertyColumns) | 42 | ListModelResult(const QSharedPointer<Sink::ResultEmitter<T> > &emitter, const QList<QByteArray> &propertyColumns) |
43 | :QAbstractListModel(), | 43 | :QAbstractListModel(), |
44 | mPropertyColumns(propertyColumns) | 44 | mPropertyColumns(propertyColumns) |
45 | { | 45 | { |
46 | setEmitter(emitter); | 46 | setEmitter(emitter); |
47 | } | 47 | } |
48 | 48 | ||
49 | void setEmitter(const QSharedPointer<Akonadi2::ResultEmitter<T> > &emitter) | 49 | void setEmitter(const QSharedPointer<Sink::ResultEmitter<T> > &emitter) |
50 | { | 50 | { |
51 | beginResetModel(); | 51 | beginResetModel(); |
52 | mEntities.clear(); | 52 | mEntities.clear(); |
@@ -118,7 +118,7 @@ public: | |||
118 | } | 118 | } |
119 | 119 | ||
120 | private: | 120 | private: |
121 | QSharedPointer<Akonadi2::ResultEmitter<T> > mEmitter; | 121 | QSharedPointer<Sink::ResultEmitter<T> > mEmitter; |
122 | QMap<QByteArray, T> mEntities; | 122 | QMap<QByteArray, T> mEntities; |
123 | QList<QByteArray> mPropertyColumns; | 123 | QList<QByteArray> mPropertyColumns; |
124 | }; | 124 | }; |
diff --git a/common/log.cpp b/common/log.cpp index 489e1bd..45bbec1 100644 --- a/common/log.cpp +++ b/common/log.cpp | |||
@@ -6,7 +6,7 @@ | |||
6 | #include <iostream> | 6 | #include <iostream> |
7 | #include <unistd.h> | 7 | #include <unistd.h> |
8 | 8 | ||
9 | using namespace Akonadi2::Log; | 9 | using namespace Sink::Log; |
10 | 10 | ||
11 | class DebugStream: public QIODevice | 11 | class DebugStream: public QIODevice |
12 | { | 12 | { |
@@ -96,7 +96,7 @@ static QString colorCommand(QList<int> colorCodes) | |||
96 | return string; | 96 | return string; |
97 | } | 97 | } |
98 | 98 | ||
99 | QByteArray Akonadi2::Log::debugLevelName(DebugLevel debugLevel) | 99 | QByteArray Sink::Log::debugLevelName(DebugLevel debugLevel) |
100 | { | 100 | { |
101 | switch (debugLevel) { | 101 | switch (debugLevel) { |
102 | case DebugLevel::Trace: | 102 | case DebugLevel::Trace: |
@@ -114,7 +114,7 @@ QByteArray Akonadi2::Log::debugLevelName(DebugLevel debugLevel) | |||
114 | return QByteArray(); | 114 | return QByteArray(); |
115 | } | 115 | } |
116 | 116 | ||
117 | DebugLevel Akonadi2::Log::debugLevelFromName(const QByteArray &name) | 117 | DebugLevel Sink::Log::debugLevelFromName(const QByteArray &name) |
118 | { | 118 | { |
119 | const QByteArray lowercaseName = name.toLower(); | 119 | const QByteArray lowercaseName = name.toLower(); |
120 | if (lowercaseName == "trace") | 120 | if (lowercaseName == "trace") |
@@ -128,19 +128,19 @@ DebugLevel Akonadi2::Log::debugLevelFromName(const QByteArray &name) | |||
128 | return DebugLevel::Log; | 128 | return DebugLevel::Log; |
129 | } | 129 | } |
130 | 130 | ||
131 | void Akonadi2::Log::setDebugOutputLevel(DebugLevel debugLevel) | 131 | void Sink::Log::setDebugOutputLevel(DebugLevel debugLevel) |
132 | { | 132 | { |
133 | qputenv("AKONADI2DEBUGLEVEL", debugLevelName(debugLevel)); | 133 | qputenv("SINKDEBUGLEVEL", debugLevelName(debugLevel)); |
134 | } | 134 | } |
135 | 135 | ||
136 | Akonadi2::Log::DebugLevel Akonadi2::Log::debugOutputLevel() | 136 | Sink::Log::DebugLevel Sink::Log::debugOutputLevel() |
137 | { | 137 | { |
138 | return debugLevelFromName(qgetenv("AKONADI2DEBUGLEVEL")); | 138 | return debugLevelFromName(qgetenv("SINKDEBUGLEVEL")); |
139 | } | 139 | } |
140 | 140 | ||
141 | QDebug Akonadi2::Log::debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea) | 141 | QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea) |
142 | { | 142 | { |
143 | DebugLevel debugOutputLevel = debugLevelFromName(qgetenv("AKONADI2DEBUGLEVEL")); | 143 | DebugLevel debugOutputLevel = debugLevelFromName(qgetenv("SINKDEBUGLEVEL")); |
144 | if (debugLevel < debugOutputLevel) { | 144 | if (debugLevel < debugOutputLevel) { |
145 | static NullStream stream; | 145 | static NullStream stream; |
146 | return QDebug(&stream); | 146 | return QDebug(&stream); |
diff --git a/common/log.h b/common/log.h index e531348..483f16f 100644 --- a/common/log.h +++ b/common/log.h | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | #include <QDebug> | 3 | #include <QDebug> |
4 | 4 | ||
5 | namespace Akonadi2 { | 5 | namespace Sink { |
6 | namespace Log { | 6 | namespace Log { |
7 | 7 | ||
8 | enum DebugLevel { | 8 | enum DebugLevel { |
@@ -23,8 +23,8 @@ QDebug debugStream(DebugLevel debugLevel, int line, const char* file, const char | |||
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | #define Trace() Akonadi2::Log::debugStream(Akonadi2::Log::DebugLevel::Trace, __LINE__, __FILE__, Q_FUNC_INFO) | 26 | #define Trace() Sink::Log::debugStream(Sink::Log::DebugLevel::Trace, __LINE__, __FILE__, Q_FUNC_INFO) |
27 | #define Log() Akonadi2::Log::debugStream(Akonadi2::Log::DebugLevel::Log, __LINE__, __FILE__, Q_FUNC_INFO) | 27 | #define Log() Sink::Log::debugStream(Sink::Log::DebugLevel::Log, __LINE__, __FILE__, Q_FUNC_INFO) |
28 | #define Warning() Akonadi2::Log::debugStream(Akonadi2::Log::DebugLevel::Warning, __LINE__, __FILE__, Q_FUNC_INFO) | 28 | #define Warning() Sink::Log::debugStream(Sink::Log::DebugLevel::Warning, __LINE__, __FILE__, Q_FUNC_INFO) |
29 | //FIXME Error clashes with Storage::Error and MessageQueue::Error | 29 | //FIXME Error clashes with Storage::Error and MessageQueue::Error |
30 | #define ErrorMsg() Akonadi2::Log::debugStream(Akonadi2::Log::DebugLevel::Error, __LINE__, __FILE__, Q_FUNC_INFO) | 30 | #define ErrorMsg() Sink::Log::debugStream(Sink::Log::DebugLevel::Error, __LINE__, __FILE__, Q_FUNC_INFO) |
diff --git a/common/messagequeue.cpp b/common/messagequeue.cpp index 8e3d7d7..1055922 100644 --- a/common/messagequeue.cpp +++ b/common/messagequeue.cpp | |||
@@ -37,7 +37,7 @@ static KAsync::Job<void> waitForCompletion(QList<KAsync::Future<void> > &futures | |||
37 | } | 37 | } |
38 | 38 | ||
39 | MessageQueue::MessageQueue(const QString &storageRoot, const QString &name) | 39 | MessageQueue::MessageQueue(const QString &storageRoot, const QString &name) |
40 | : mStorage(storageRoot, name, Akonadi2::Storage::ReadWrite) | 40 | : mStorage(storageRoot, name, Sink::Storage::ReadWrite) |
41 | { | 41 | { |
42 | } | 42 | } |
43 | 43 | ||
@@ -56,13 +56,13 @@ void MessageQueue::startTransaction() | |||
56 | return; | 56 | return; |
57 | } | 57 | } |
58 | processRemovals(); | 58 | processRemovals(); |
59 | mWriteTransaction = std::move(mStorage.createTransaction(Akonadi2::Storage::ReadWrite)); | 59 | mWriteTransaction = std::move(mStorage.createTransaction(Sink::Storage::ReadWrite)); |
60 | } | 60 | } |
61 | 61 | ||
62 | void MessageQueue::commit() | 62 | void MessageQueue::commit() |
63 | { | 63 | { |
64 | mWriteTransaction.commit(); | 64 | mWriteTransaction.commit(); |
65 | mWriteTransaction = Akonadi2::Storage::Transaction(); | 65 | mWriteTransaction = Sink::Storage::Transaction(); |
66 | processRemovals(); | 66 | processRemovals(); |
67 | emit messageReady(); | 67 | emit messageReady(); |
68 | } | 68 | } |
@@ -74,10 +74,10 @@ void MessageQueue::enqueue(const QByteArray &value) | |||
74 | implicitTransaction = true; | 74 | implicitTransaction = true; |
75 | startTransaction(); | 75 | startTransaction(); |
76 | } | 76 | } |
77 | const qint64 revision = Akonadi2::Storage::maxRevision(mWriteTransaction) + 1; | 77 | const qint64 revision = Sink::Storage::maxRevision(mWriteTransaction) + 1; |
78 | const QByteArray key = QString("%1").arg(revision).toUtf8(); | 78 | const QByteArray key = QString("%1").arg(revision).toUtf8(); |
79 | mWriteTransaction.openDatabase().write(key, value); | 79 | mWriteTransaction.openDatabase().write(key, value); |
80 | Akonadi2::Storage::setMaxRevision(mWriteTransaction, revision); | 80 | Sink::Storage::setMaxRevision(mWriteTransaction, revision); |
81 | if (implicitTransaction) { | 81 | if (implicitTransaction) { |
82 | commit(); | 82 | commit(); |
83 | } | 83 | } |
@@ -88,7 +88,7 @@ void MessageQueue::processRemovals() | |||
88 | if (mWriteTransaction) { | 88 | if (mWriteTransaction) { |
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | auto transaction = std::move(mStorage.createTransaction(Akonadi2::Storage::ReadWrite)); | 91 | auto transaction = std::move(mStorage.createTransaction(Sink::Storage::ReadWrite)); |
92 | for (const auto &key : mPendingRemoval) { | 92 | for (const auto &key : mPendingRemoval) { |
93 | transaction.openDatabase().remove(key); | 93 | transaction.openDatabase().remove(key); |
94 | } | 94 | } |
@@ -117,8 +117,8 @@ KAsync::Job<void> MessageQueue::dequeueBatch(int maxBatchSize, const std::functi | |||
117 | return KAsync::start<void>([this, maxBatchSize, resultHandler, resultCount](KAsync::Future<void> &future) { | 117 | return KAsync::start<void>([this, maxBatchSize, resultHandler, resultCount](KAsync::Future<void> &future) { |
118 | int count = 0; | 118 | int count = 0; |
119 | QList<KAsync::Future<void> > waitCondition; | 119 | QList<KAsync::Future<void> > waitCondition; |
120 | mStorage.createTransaction(Akonadi2::Storage::ReadOnly).openDatabase().scan("", [this, resultHandler, resultCount, &count, maxBatchSize, &waitCondition](const QByteArray &key, const QByteArray &value) -> bool { | 120 | mStorage.createTransaction(Sink::Storage::ReadOnly).openDatabase().scan("", [this, resultHandler, resultCount, &count, maxBatchSize, &waitCondition](const QByteArray &key, const QByteArray &value) -> bool { |
121 | if (Akonadi2::Storage::isInternalKey(key) || mPendingRemoval.contains(key)) { | 121 | if (Sink::Storage::isInternalKey(key) || mPendingRemoval.contains(key)) { |
122 | return true; | 122 | return true; |
123 | } | 123 | } |
124 | *resultCount += 1; | 124 | *resultCount += 1; |
@@ -133,7 +133,7 @@ KAsync::Job<void> MessageQueue::dequeueBatch(int maxBatchSize, const std::functi | |||
133 | } | 133 | } |
134 | return false; | 134 | return false; |
135 | }, | 135 | }, |
136 | [](const Akonadi2::Storage::Error &error) { | 136 | [](const Sink::Storage::Error &error) { |
137 | ErrorMsg() << "Error while retrieving value" << error.message; | 137 | ErrorMsg() << "Error while retrieving value" << error.message; |
138 | // errorHandler(Error(error.store, error.code, error.message)); | 138 | // errorHandler(Error(error.store, error.code, error.message)); |
139 | }); | 139 | }); |
@@ -157,17 +157,17 @@ KAsync::Job<void> MessageQueue::dequeueBatch(int maxBatchSize, const std::functi | |||
157 | bool MessageQueue::isEmpty() | 157 | bool MessageQueue::isEmpty() |
158 | { | 158 | { |
159 | int count = 0; | 159 | int count = 0; |
160 | auto t = mStorage.createTransaction(Akonadi2::Storage::ReadOnly); | 160 | auto t = mStorage.createTransaction(Sink::Storage::ReadOnly); |
161 | auto db = t.openDatabase(); | 161 | auto db = t.openDatabase(); |
162 | if (db) { | 162 | if (db) { |
163 | db.scan("", [&count, this](const QByteArray &key, const QByteArray &value) -> bool { | 163 | db.scan("", [&count, this](const QByteArray &key, const QByteArray &value) -> bool { |
164 | if (!Akonadi2::Storage::isInternalKey(key) && !mPendingRemoval.contains(key)) { | 164 | if (!Sink::Storage::isInternalKey(key) && !mPendingRemoval.contains(key)) { |
165 | count++; | 165 | count++; |
166 | return false; | 166 | return false; |
167 | } | 167 | } |
168 | return true; | 168 | return true; |
169 | }, | 169 | }, |
170 | [](const Akonadi2::Storage::Error &error) { | 170 | [](const Sink::Storage::Error &error) { |
171 | ErrorMsg() << "Error while checking if empty" << error.message; | 171 | ErrorMsg() << "Error while checking if empty" << error.message; |
172 | }); | 172 | }); |
173 | } | 173 | } |
diff --git a/common/messagequeue.h b/common/messagequeue.h index a04e22f..3206388 100644 --- a/common/messagequeue.h +++ b/common/messagequeue.h | |||
@@ -54,7 +54,7 @@ private slots: | |||
54 | 54 | ||
55 | private: | 55 | private: |
56 | Q_DISABLE_COPY(MessageQueue); | 56 | Q_DISABLE_COPY(MessageQueue); |
57 | Akonadi2::Storage mStorage; | 57 | Sink::Storage mStorage; |
58 | Akonadi2::Storage::Transaction mWriteTransaction; | 58 | Sink::Storage::Transaction mWriteTransaction; |
59 | QByteArrayList mPendingRemoval; | 59 | QByteArrayList mPendingRemoval; |
60 | }; | 60 | }; |
diff --git a/common/metadata.fbs b/common/metadata.fbs index 0a709fe..f2f336d 100644 --- a/common/metadata.fbs +++ b/common/metadata.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2; | 1 | namespace Sink; |
2 | 2 | ||
3 | enum Operation : byte { Creation = 1, Modification, Removal } | 3 | enum Operation : byte { Creation = 1, Modification, Removal } |
4 | 4 | ||
diff --git a/common/modelresult.cpp b/common/modelresult.cpp index 22798d9..3a9fb95 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp | |||
@@ -24,7 +24,7 @@ | |||
24 | #include "domain/folder.h" | 24 | #include "domain/folder.h" |
25 | #include "log.h" | 25 | #include "log.h" |
26 | 26 | ||
27 | static uint qHash(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) | 27 | static uint qHash(const Sink::ApplicationDomain::ApplicationDomainType &type) |
28 | { | 28 | { |
29 | Q_ASSERT(!type.resourceInstanceIdentifier().isEmpty()); | 29 | Q_ASSERT(!type.resourceInstanceIdentifier().isEmpty()); |
30 | Q_ASSERT(!type.identifier().isEmpty()); | 30 | Q_ASSERT(!type.identifier().isEmpty()); |
@@ -32,7 +32,7 @@ static uint qHash(const Akonadi2::ApplicationDomain::ApplicationDomainType &typ | |||
32 | } | 32 | } |
33 | 33 | ||
34 | template<class T, class Ptr> | 34 | template<class T, class Ptr> |
35 | ModelResult<T, Ptr>::ModelResult(const Akonadi2::Query &query, const QList<QByteArray> &propertyColumns) | 35 | ModelResult<T, Ptr>::ModelResult(const Sink::Query &query, const QList<QByteArray> &propertyColumns) |
36 | :QAbstractItemModel(), | 36 | :QAbstractItemModel(), |
37 | mPropertyColumns(propertyColumns), | 37 | mPropertyColumns(propertyColumns), |
38 | mQuery(query) | 38 | mQuery(query) |
@@ -53,7 +53,7 @@ qint64 ModelResult<T, Ptr>::parentId(const Ptr &value) | |||
53 | if (!mQuery.parentProperty.isEmpty()) { | 53 | if (!mQuery.parentProperty.isEmpty()) { |
54 | const auto identifier = value->getProperty(mQuery.parentProperty).toByteArray(); | 54 | const auto identifier = value->getProperty(mQuery.parentProperty).toByteArray(); |
55 | if (!identifier.isEmpty()) { | 55 | if (!identifier.isEmpty()) { |
56 | return qHash(T(value->resourceInstanceIdentifier(), identifier, 0, QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor>())); | 56 | return qHash(T(value->resourceInstanceIdentifier(), identifier, 0, QSharedPointer<Sink::ApplicationDomain::BufferAdaptor>())); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | return 0; | 59 | return 0; |
@@ -91,7 +91,7 @@ QVariant ModelResult<T, Ptr>::data(const QModelIndex &index, int role) const | |||
91 | } | 91 | } |
92 | if (role == DomainObjectBaseRole) { | 92 | if (role == DomainObjectBaseRole) { |
93 | Q_ASSERT(mEntities.contains(index.internalId())); | 93 | Q_ASSERT(mEntities.contains(index.internalId())); |
94 | return QVariant::fromValue(mEntities.value(index.internalId()). template staticCast<Akonadi2::ApplicationDomain::ApplicationDomainType>()); | 94 | return QVariant::fromValue(mEntities.value(index.internalId()). template staticCast<Sink::ApplicationDomain::ApplicationDomainType>()); |
95 | } | 95 | } |
96 | if (role == ChildrenFetchedRole) { | 96 | if (role == ChildrenFetchedRole) { |
97 | return childrenFetched(index); | 97 | return childrenFetched(index); |
@@ -226,7 +226,7 @@ void ModelResult<T, Ptr>::setFetcher(const std::function<void(const Ptr &parent) | |||
226 | } | 226 | } |
227 | 227 | ||
228 | template<class T, class Ptr> | 228 | template<class T, class Ptr> |
229 | void ModelResult<T, Ptr>::setEmitter(const typename Akonadi2::ResultEmitter<Ptr>::Ptr &emitter) | 229 | void ModelResult<T, Ptr>::setEmitter(const typename Sink::ResultEmitter<Ptr>::Ptr &emitter) |
230 | { | 230 | { |
231 | setFetcher([this](const Ptr &parent) {mEmitter->fetch(parent);}); | 231 | setFetcher([this](const Ptr &parent) {mEmitter->fetch(parent);}); |
232 | emitter->onAdded([this](const Ptr &value) { | 232 | emitter->onAdded([this](const Ptr &value) { |
@@ -272,7 +272,7 @@ void ModelResult<T, Ptr>::modify(const Ptr &value) | |||
272 | emit dataChanged(idx, idx); | 272 | emit dataChanged(idx, idx); |
273 | } | 273 | } |
274 | 274 | ||
275 | template class ModelResult<Akonadi2::ApplicationDomain::Folder, Akonadi2::ApplicationDomain::Folder::Ptr>; | 275 | template class ModelResult<Sink::ApplicationDomain::Folder, Sink::ApplicationDomain::Folder::Ptr>; |
276 | template class ModelResult<Akonadi2::ApplicationDomain::Mail, Akonadi2::ApplicationDomain::Mail::Ptr>; | 276 | template class ModelResult<Sink::ApplicationDomain::Mail, Sink::ApplicationDomain::Mail::Ptr>; |
277 | template class ModelResult<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Event::Ptr>; | 277 | template class ModelResult<Sink::ApplicationDomain::Event, Sink::ApplicationDomain::Event::Ptr>; |
278 | template class ModelResult<Akonadi2::ApplicationDomain::AkonadiResource, Akonadi2::ApplicationDomain::AkonadiResource::Ptr>; | 278 | template class ModelResult<Sink::ApplicationDomain::SinkResource, Sink::ApplicationDomain::SinkResource::Ptr>; |
diff --git a/common/modelresult.h b/common/modelresult.h index ec62a67..062517f 100644 --- a/common/modelresult.h +++ b/common/modelresult.h | |||
@@ -38,9 +38,9 @@ public: | |||
38 | DomainObjectBaseRole | 38 | DomainObjectBaseRole |
39 | }; | 39 | }; |
40 | 40 | ||
41 | ModelResult(const Akonadi2::Query &query, const QList<QByteArray> &propertyColumns); | 41 | ModelResult(const Sink::Query &query, const QList<QByteArray> &propertyColumns); |
42 | 42 | ||
43 | void setEmitter(const typename Akonadi2::ResultEmitter<Ptr>::Ptr &); | 43 | void setEmitter(const typename Sink::ResultEmitter<Ptr>::Ptr &); |
44 | 44 | ||
45 | int rowCount(const QModelIndex &parent = QModelIndex()) const; | 45 | int rowCount(const QModelIndex &parent = QModelIndex()) const; |
46 | int columnCount(const QModelIndex &parent = QModelIndex()) const; | 46 | int columnCount(const QModelIndex &parent = QModelIndex()) const; |
@@ -73,8 +73,8 @@ private: | |||
73 | QSet<qint64 /* entity id */> mEntityChildrenFetched; | 73 | QSet<qint64 /* entity id */> mEntityChildrenFetched; |
74 | QSet<qint64 /* entity id */> mEntityChildrenFetchComplete; | 74 | QSet<qint64 /* entity id */> mEntityChildrenFetchComplete; |
75 | QList<QByteArray> mPropertyColumns; | 75 | QList<QByteArray> mPropertyColumns; |
76 | Akonadi2::Query mQuery; | 76 | Sink::Query mQuery; |
77 | std::function<void(const Ptr &)> loadEntities; | 77 | std::function<void(const Ptr &)> loadEntities; |
78 | typename Akonadi2::ResultEmitter<Ptr>::Ptr mEmitter; | 78 | typename Sink::ResultEmitter<Ptr>::Ptr mEmitter; |
79 | }; | 79 | }; |
80 | 80 | ||
diff --git a/common/notification.h b/common/notification.h index e1b5bff..ae24bd2 100644 --- a/common/notification.h +++ b/common/notification.h | |||
@@ -19,16 +19,16 @@ | |||
19 | */ | 19 | */ |
20 | #pragma once | 20 | #pragma once |
21 | 21 | ||
22 | #include <akonadi2common_export.h> | 22 | #include <sinkcommon_export.h> |
23 | #include <QString> | 23 | #include <QString> |
24 | 24 | ||
25 | namespace Akonadi2 | 25 | namespace Sink |
26 | { | 26 | { |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * A notification | 29 | * A notification |
30 | */ | 30 | */ |
31 | class AKONADI2COMMON_EXPORT Notification | 31 | class SINKCOMMON_EXPORT Notification |
32 | { | 32 | { |
33 | public: | 33 | public: |
34 | QByteArray id; | 34 | QByteArray id; |
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index a087def..401c26d 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -36,14 +36,14 @@ | |||
36 | #include "definitions.h" | 36 | #include "definitions.h" |
37 | #include "bufferutils.h" | 37 | #include "bufferutils.h" |
38 | 38 | ||
39 | namespace Akonadi2 | 39 | namespace Sink |
40 | { | 40 | { |
41 | 41 | ||
42 | class Pipeline::Private | 42 | class Pipeline::Private |
43 | { | 43 | { |
44 | public: | 44 | public: |
45 | Private(const QString &resourceName) | 45 | Private(const QString &resourceName) |
46 | : storage(Akonadi2::storageLocation(), resourceName, Storage::ReadWrite), | 46 | : storage(Sink::storageLocation(), resourceName, Storage::ReadWrite), |
47 | revisionChanged(false) | 47 | revisionChanged(false) |
48 | { | 48 | { |
49 | } | 49 | } |
@@ -86,7 +86,7 @@ void Pipeline::startTransaction() | |||
86 | if (d->transaction) { | 86 | if (d->transaction) { |
87 | return; | 87 | return; |
88 | } | 88 | } |
89 | d->transaction = std::move(storage().createTransaction(Akonadi2::Storage::ReadWrite)); | 89 | d->transaction = std::move(storage().createTransaction(Sink::Storage::ReadWrite)); |
90 | } | 90 | } |
91 | 91 | ||
92 | void Pipeline::commit() | 92 | void Pipeline::commit() |
@@ -96,7 +96,7 @@ void Pipeline::commit() | |||
96 | // for (auto processor : d->processors[bufferType]) { | 96 | // for (auto processor : d->processors[bufferType]) { |
97 | // processor->finalize(); | 97 | // processor->finalize(); |
98 | // } | 98 | // } |
99 | const auto revision = Akonadi2::Storage::maxRevision(d->transaction); | 99 | const auto revision = Sink::Storage::maxRevision(d->transaction); |
100 | Trace() << "Committing " << revision; | 100 | Trace() << "Committing " << revision; |
101 | if (d->transaction) { | 101 | if (d->transaction) { |
102 | d->transaction.commit(); | 102 | d->transaction.commit(); |
@@ -120,14 +120,14 @@ Storage &Pipeline::storage() const | |||
120 | 120 | ||
121 | void Pipeline::storeNewRevision(qint64 newRevision, const flatbuffers::FlatBufferBuilder &fbb, const QByteArray &bufferType, const QByteArray &uid) | 121 | void Pipeline::storeNewRevision(qint64 newRevision, const flatbuffers::FlatBufferBuilder &fbb, const QByteArray &bufferType, const QByteArray &uid) |
122 | { | 122 | { |
123 | d->transaction.openDatabase(bufferType + ".main").write(Akonadi2::Storage::assembleKey(uid, newRevision), BufferUtils::extractBuffer(fbb), | 123 | d->transaction.openDatabase(bufferType + ".main").write(Sink::Storage::assembleKey(uid, newRevision), BufferUtils::extractBuffer(fbb), |
124 | [](const Akonadi2::Storage::Error &error) { | 124 | [](const Sink::Storage::Error &error) { |
125 | Warning() << "Failed to write entity"; | 125 | Warning() << "Failed to write entity"; |
126 | } | 126 | } |
127 | ); | 127 | ); |
128 | d->revisionChanged = true; | 128 | d->revisionChanged = true; |
129 | Akonadi2::Storage::setMaxRevision(d->transaction, newRevision); | 129 | Sink::Storage::setMaxRevision(d->transaction, newRevision); |
130 | Akonadi2::Storage::recordRevision(d->transaction, newRevision, uid, bufferType); | 130 | Sink::Storage::recordRevision(d->transaction, newRevision, uid, bufferType); |
131 | } | 131 | } |
132 | 132 | ||
133 | KAsync::Job<qint64> Pipeline::newEntity(void const *command, size_t size) | 133 | KAsync::Job<qint64> Pipeline::newEntity(void const *command, size_t size) |
@@ -136,23 +136,23 @@ KAsync::Job<qint64> Pipeline::newEntity(void const *command, size_t size) | |||
136 | 136 | ||
137 | { | 137 | { |
138 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command), size); | 138 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command), size); |
139 | if (!Akonadi2::Commands::VerifyCreateEntityBuffer(verifyer)) { | 139 | if (!Sink::Commands::VerifyCreateEntityBuffer(verifyer)) { |
140 | Warning() << "invalid buffer, not a create entity buffer"; | 140 | Warning() << "invalid buffer, not a create entity buffer"; |
141 | return KAsync::error<qint64>(0); | 141 | return KAsync::error<qint64>(0); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | auto createEntity = Akonadi2::Commands::GetCreateEntity(command); | 144 | auto createEntity = Sink::Commands::GetCreateEntity(command); |
145 | 145 | ||
146 | const bool replayToSource = createEntity->replayToSource(); | 146 | const bool replayToSource = createEntity->replayToSource(); |
147 | const QByteArray bufferType = QByteArray(reinterpret_cast<char const*>(createEntity->domainType()->Data()), createEntity->domainType()->size()); | 147 | const QByteArray bufferType = QByteArray(reinterpret_cast<char const*>(createEntity->domainType()->Data()), createEntity->domainType()->size()); |
148 | { | 148 | { |
149 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(createEntity->delta()->Data()), createEntity->delta()->size()); | 149 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(createEntity->delta()->Data()), createEntity->delta()->size()); |
150 | if (!Akonadi2::VerifyEntityBuffer(verifyer)) { | 150 | if (!Sink::VerifyEntityBuffer(verifyer)) { |
151 | Warning() << "invalid buffer, not an entity buffer"; | 151 | Warning() << "invalid buffer, not an entity buffer"; |
152 | return KAsync::error<qint64>(0); | 152 | return KAsync::error<qint64>(0); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | auto entity = Akonadi2::GetEntity(createEntity->delta()->Data()); | 155 | auto entity = Sink::GetEntity(createEntity->delta()->Data()); |
156 | if (!entity->resource()->size() && !entity->local()->size()) { | 156 | if (!entity->resource()->size() && !entity->local()->size()) { |
157 | Warning() << "No local and no resource buffer while trying to create entity."; | 157 | Warning() << "No local and no resource buffer while trying to create entity."; |
158 | return KAsync::error<qint64>(0); | 158 | return KAsync::error<qint64>(0); |
@@ -171,16 +171,16 @@ KAsync::Job<qint64> Pipeline::newEntity(void const *command, size_t size) | |||
171 | key = QUuid::createUuid().toString().toUtf8(); | 171 | key = QUuid::createUuid().toString().toUtf8(); |
172 | } | 172 | } |
173 | Q_ASSERT(!key.isEmpty()); | 173 | Q_ASSERT(!key.isEmpty()); |
174 | const qint64 newRevision = Akonadi2::Storage::maxRevision(d->transaction) + 1; | 174 | const qint64 newRevision = Sink::Storage::maxRevision(d->transaction) + 1; |
175 | 175 | ||
176 | //Add metadata buffer | 176 | //Add metadata buffer |
177 | flatbuffers::FlatBufferBuilder metadataFbb; | 177 | flatbuffers::FlatBufferBuilder metadataFbb; |
178 | auto metadataBuilder = Akonadi2::MetadataBuilder(metadataFbb); | 178 | auto metadataBuilder = Sink::MetadataBuilder(metadataFbb); |
179 | metadataBuilder.add_revision(newRevision); | 179 | metadataBuilder.add_revision(newRevision); |
180 | metadataBuilder.add_operation(Akonadi2::Operation_Creation); | 180 | metadataBuilder.add_operation(Sink::Operation_Creation); |
181 | metadataBuilder.add_replayToSource(replayToSource); | 181 | metadataBuilder.add_replayToSource(replayToSource); |
182 | auto metadataBuffer = metadataBuilder.Finish(); | 182 | auto metadataBuffer = metadataBuilder.Finish(); |
183 | Akonadi2::FinishMetadataBuffer(metadataFbb, metadataBuffer); | 183 | Sink::FinishMetadataBuffer(metadataFbb, metadataBuffer); |
184 | 184 | ||
185 | flatbuffers::FlatBufferBuilder fbb; | 185 | flatbuffers::FlatBufferBuilder fbb; |
186 | EntityBuffer::assembleEntityBuffer(fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize(), entity->resource()->Data(), entity->resource()->size(), entity->local()->Data(), entity->local()->size()); | 186 | EntityBuffer::assembleEntityBuffer(fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize(), entity->resource()->Data(), entity->resource()->size(), entity->local()->Data(), entity->local()->size()); |
@@ -194,14 +194,14 @@ KAsync::Job<qint64> Pipeline::newEntity(void const *command, size_t size) | |||
194 | } | 194 | } |
195 | 195 | ||
196 | Log() << "Pipeline: wrote entity: " << key << newRevision << bufferType; | 196 | Log() << "Pipeline: wrote entity: " << key << newRevision << bufferType; |
197 | d->transaction.openDatabase(bufferType + ".main").scan(Akonadi2::Storage::assembleKey(key, newRevision), [this, bufferType, newRevision, adaptorFactory, key](const QByteArray &, const QByteArray &value) -> bool { | 197 | d->transaction.openDatabase(bufferType + ".main").scan(Sink::Storage::assembleKey(key, newRevision), [this, bufferType, newRevision, adaptorFactory, key](const QByteArray &, const QByteArray &value) -> bool { |
198 | auto entity = Akonadi2::GetEntity(value); | 198 | auto entity = Sink::GetEntity(value); |
199 | auto adaptor = adaptorFactory->createAdaptor(*entity); | 199 | auto adaptor = adaptorFactory->createAdaptor(*entity); |
200 | for (auto processor : d->processors[bufferType]) { | 200 | for (auto processor : d->processors[bufferType]) { |
201 | processor->newEntity(key, newRevision, *adaptor, d->transaction); | 201 | processor->newEntity(key, newRevision, *adaptor, d->transaction); |
202 | } | 202 | } |
203 | return false; | 203 | return false; |
204 | }, [this](const Akonadi2::Storage::Error &error) { | 204 | }, [this](const Sink::Storage::Error &error) { |
205 | ErrorMsg() << "Failed to find value in pipeline: " << error.message; | 205 | ErrorMsg() << "Failed to find value in pipeline: " << error.message; |
206 | }); | 206 | }); |
207 | return KAsync::start<qint64>([newRevision](){ | 207 | return KAsync::start<qint64>([newRevision](){ |
@@ -213,16 +213,16 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
213 | { | 213 | { |
214 | Trace() << "Pipeline: Modified Entity"; | 214 | Trace() << "Pipeline: Modified Entity"; |
215 | 215 | ||
216 | const qint64 newRevision = Akonadi2::Storage::maxRevision(d->transaction) + 1; | 216 | const qint64 newRevision = Sink::Storage::maxRevision(d->transaction) + 1; |
217 | 217 | ||
218 | { | 218 | { |
219 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command), size); | 219 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command), size); |
220 | if (!Akonadi2::Commands::VerifyModifyEntityBuffer(verifyer)) { | 220 | if (!Sink::Commands::VerifyModifyEntityBuffer(verifyer)) { |
221 | Warning() << "invalid buffer, not a modify entity buffer"; | 221 | Warning() << "invalid buffer, not a modify entity buffer"; |
222 | return KAsync::error<qint64>(0); | 222 | return KAsync::error<qint64>(0); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | auto modifyEntity = Akonadi2::Commands::GetModifyEntity(command); | 225 | auto modifyEntity = Sink::Commands::GetModifyEntity(command); |
226 | Q_ASSERT(modifyEntity); | 226 | Q_ASSERT(modifyEntity); |
227 | 227 | ||
228 | const qint64 baseRevision = modifyEntity->revision(); | 228 | const qint64 baseRevision = modifyEntity->revision(); |
@@ -236,7 +236,7 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
236 | } | 236 | } |
237 | { | 237 | { |
238 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(modifyEntity->delta()->Data()), modifyEntity->delta()->size()); | 238 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(modifyEntity->delta()->Data()), modifyEntity->delta()->size()); |
239 | if (!Akonadi2::VerifyEntityBuffer(verifyer)) { | 239 | if (!Sink::VerifyEntityBuffer(verifyer)) { |
240 | Warning() << "invalid buffer, not an entity buffer"; | 240 | Warning() << "invalid buffer, not an entity buffer"; |
241 | return KAsync::error<qint64>(0); | 241 | return KAsync::error<qint64>(0); |
242 | } | 242 | } |
@@ -249,13 +249,13 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
249 | return KAsync::error<qint64>(0); | 249 | return KAsync::error<qint64>(0); |
250 | } | 250 | } |
251 | 251 | ||
252 | auto diffEntity = Akonadi2::GetEntity(modifyEntity->delta()->Data()); | 252 | auto diffEntity = Sink::GetEntity(modifyEntity->delta()->Data()); |
253 | Q_ASSERT(diffEntity); | 253 | Q_ASSERT(diffEntity); |
254 | auto diff = adaptorFactory->createAdaptor(*diffEntity); | 254 | auto diff = adaptorFactory->createAdaptor(*diffEntity); |
255 | 255 | ||
256 | QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor> current; | 256 | QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> current; |
257 | d->transaction.openDatabase(bufferType + ".main").findLatest(key, [¤t, adaptorFactory](const QByteArray &key, const QByteArray &data) -> bool { | 257 | d->transaction.openDatabase(bufferType + ".main").findLatest(key, [¤t, adaptorFactory](const QByteArray &key, const QByteArray &data) -> bool { |
258 | Akonadi2::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); | 258 | Sink::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); |
259 | if (!buffer.isValid()) { | 259 | if (!buffer.isValid()) { |
260 | Warning() << "Read invalid buffer from disk"; | 260 | Warning() << "Read invalid buffer from disk"; |
261 | } else { | 261 | } else { |
@@ -273,8 +273,8 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
273 | } | 273 | } |
274 | 274 | ||
275 | //resource and uid don't matter at this point | 275 | //resource and uid don't matter at this point |
276 | const Akonadi2::ApplicationDomain::ApplicationDomainType existingObject("", "", newRevision, current); | 276 | const Sink::ApplicationDomain::ApplicationDomainType existingObject("", "", newRevision, current); |
277 | auto newObject = Akonadi2::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<Akonadi2::ApplicationDomain::ApplicationDomainType>(existingObject); | 277 | auto newObject = Sink::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<Sink::ApplicationDomain::ApplicationDomainType>(existingObject); |
278 | 278 | ||
279 | //Apply diff | 279 | //Apply diff |
280 | //FIXME only apply the properties that are available in the buffer | 280 | //FIXME only apply the properties that are available in the buffer |
@@ -292,26 +292,26 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
292 | 292 | ||
293 | //Add metadata buffer | 293 | //Add metadata buffer |
294 | flatbuffers::FlatBufferBuilder metadataFbb; | 294 | flatbuffers::FlatBufferBuilder metadataFbb; |
295 | auto metadataBuilder = Akonadi2::MetadataBuilder(metadataFbb); | 295 | auto metadataBuilder = Sink::MetadataBuilder(metadataFbb); |
296 | metadataBuilder.add_revision(newRevision); | 296 | metadataBuilder.add_revision(newRevision); |
297 | metadataBuilder.add_operation(Akonadi2::Operation_Modification); | 297 | metadataBuilder.add_operation(Sink::Operation_Modification); |
298 | metadataBuilder.add_replayToSource(replayToSource); | 298 | metadataBuilder.add_replayToSource(replayToSource); |
299 | auto metadataBuffer = metadataBuilder.Finish(); | 299 | auto metadataBuffer = metadataBuilder.Finish(); |
300 | Akonadi2::FinishMetadataBuffer(metadataFbb, metadataBuffer); | 300 | Sink::FinishMetadataBuffer(metadataFbb, metadataBuffer); |
301 | 301 | ||
302 | flatbuffers::FlatBufferBuilder fbb; | 302 | flatbuffers::FlatBufferBuilder fbb; |
303 | adaptorFactory->createBuffer(*newObject, fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize()); | 303 | adaptorFactory->createBuffer(*newObject, fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize()); |
304 | 304 | ||
305 | storeNewRevision(newRevision, fbb, bufferType, key); | 305 | storeNewRevision(newRevision, fbb, bufferType, key); |
306 | Log() << "Pipeline: modified entity: " << key << newRevision << bufferType; | 306 | Log() << "Pipeline: modified entity: " << key << newRevision << bufferType; |
307 | d->transaction.openDatabase(bufferType + ".main").scan(Akonadi2::Storage::assembleKey(key, newRevision), [this, bufferType, newRevision, adaptorFactory, current, key](const QByteArray &, const QByteArray &value) -> bool { | 307 | d->transaction.openDatabase(bufferType + ".main").scan(Sink::Storage::assembleKey(key, newRevision), [this, bufferType, newRevision, adaptorFactory, current, key](const QByteArray &, const QByteArray &value) -> bool { |
308 | auto entity = Akonadi2::GetEntity(value); | 308 | auto entity = Sink::GetEntity(value); |
309 | auto newEntity = adaptorFactory->createAdaptor(*entity); | 309 | auto newEntity = adaptorFactory->createAdaptor(*entity); |
310 | for (auto processor : d->processors[bufferType]) { | 310 | for (auto processor : d->processors[bufferType]) { |
311 | processor->modifiedEntity(key, newRevision, *current, *newEntity, d->transaction); | 311 | processor->modifiedEntity(key, newRevision, *current, *newEntity, d->transaction); |
312 | } | 312 | } |
313 | return false; | 313 | return false; |
314 | }, [this](const Akonadi2::Storage::Error &error) { | 314 | }, [this](const Sink::Storage::Error &error) { |
315 | ErrorMsg() << "Failed to find value in pipeline: " << error.message; | 315 | ErrorMsg() << "Failed to find value in pipeline: " << error.message; |
316 | }); | 316 | }); |
317 | return KAsync::start<qint64>([newRevision](){ | 317 | return KAsync::start<qint64>([newRevision](){ |
@@ -325,12 +325,12 @@ KAsync::Job<qint64> Pipeline::deletedEntity(void const *command, size_t size) | |||
325 | 325 | ||
326 | { | 326 | { |
327 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command), size); | 327 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command), size); |
328 | if (!Akonadi2::Commands::VerifyDeleteEntityBuffer(verifyer)) { | 328 | if (!Sink::Commands::VerifyDeleteEntityBuffer(verifyer)) { |
329 | Warning() << "invalid buffer, not a delete entity buffer"; | 329 | Warning() << "invalid buffer, not a delete entity buffer"; |
330 | return KAsync::error<qint64>(0); | 330 | return KAsync::error<qint64>(0); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | auto deleteEntity = Akonadi2::Commands::GetDeleteEntity(command); | 333 | auto deleteEntity = Sink::Commands::GetDeleteEntity(command); |
334 | 334 | ||
335 | const bool replayToSource = deleteEntity->replayToSource(); | 335 | const bool replayToSource = deleteEntity->replayToSource(); |
336 | const QByteArray bufferType = QByteArray(reinterpret_cast<char const*>(deleteEntity->domainType()->Data()), deleteEntity->domainType()->size()); | 336 | const QByteArray bufferType = QByteArray(reinterpret_cast<char const*>(deleteEntity->domainType()->Data()), deleteEntity->domainType()->size()); |
@@ -339,12 +339,12 @@ KAsync::Job<qint64> Pipeline::deletedEntity(void const *command, size_t size) | |||
339 | bool found = false; | 339 | bool found = false; |
340 | bool alreadyRemoved = false; | 340 | bool alreadyRemoved = false; |
341 | d->transaction.openDatabase(bufferType + ".main").findLatest(key, [&found, &alreadyRemoved](const QByteArray &key, const QByteArray &data) -> bool { | 341 | d->transaction.openDatabase(bufferType + ".main").findLatest(key, [&found, &alreadyRemoved](const QByteArray &key, const QByteArray &data) -> bool { |
342 | Akonadi2::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); | 342 | Sink::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); |
343 | auto entity = Akonadi2::GetEntity(data.data()); | 343 | auto entity = Sink::GetEntity(data.data()); |
344 | if (entity && entity->metadata()) { | 344 | if (entity && entity->metadata()) { |
345 | auto metadata = Akonadi2::GetMetadata(entity->metadata()->Data()); | 345 | auto metadata = Sink::GetMetadata(entity->metadata()->Data()); |
346 | found = true; | 346 | found = true; |
347 | if (metadata->operation() == Akonadi2::Operation_Removal) { | 347 | if (metadata->operation() == Sink::Operation_Removal) { |
348 | alreadyRemoved = true; | 348 | alreadyRemoved = true; |
349 | } | 349 | } |
350 | 350 | ||
@@ -364,16 +364,16 @@ KAsync::Job<qint64> Pipeline::deletedEntity(void const *command, size_t size) | |||
364 | return KAsync::error<qint64>(0); | 364 | return KAsync::error<qint64>(0); |
365 | } | 365 | } |
366 | 366 | ||
367 | const qint64 newRevision = Akonadi2::Storage::maxRevision(d->transaction) + 1; | 367 | const qint64 newRevision = Sink::Storage::maxRevision(d->transaction) + 1; |
368 | 368 | ||
369 | //Add metadata buffer | 369 | //Add metadata buffer |
370 | flatbuffers::FlatBufferBuilder metadataFbb; | 370 | flatbuffers::FlatBufferBuilder metadataFbb; |
371 | auto metadataBuilder = Akonadi2::MetadataBuilder(metadataFbb); | 371 | auto metadataBuilder = Sink::MetadataBuilder(metadataFbb); |
372 | metadataBuilder.add_revision(newRevision); | 372 | metadataBuilder.add_revision(newRevision); |
373 | metadataBuilder.add_operation(Akonadi2::Operation_Removal); | 373 | metadataBuilder.add_operation(Sink::Operation_Removal); |
374 | metadataBuilder.add_replayToSource(replayToSource); | 374 | metadataBuilder.add_replayToSource(replayToSource); |
375 | auto metadataBuffer = metadataBuilder.Finish(); | 375 | auto metadataBuffer = metadataBuilder.Finish(); |
376 | Akonadi2::FinishMetadataBuffer(metadataFbb, metadataBuffer); | 376 | Sink::FinishMetadataBuffer(metadataFbb, metadataBuffer); |
377 | 377 | ||
378 | flatbuffers::FlatBufferBuilder fbb; | 378 | flatbuffers::FlatBufferBuilder fbb; |
379 | EntityBuffer::assembleEntityBuffer(fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize(), 0, 0, 0, 0); | 379 | EntityBuffer::assembleEntityBuffer(fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize(), 0, 0, 0, 0); |
@@ -384,16 +384,16 @@ KAsync::Job<qint64> Pipeline::deletedEntity(void const *command, size_t size) | |||
384 | return KAsync::error<qint64>(0); | 384 | return KAsync::error<qint64>(0); |
385 | } | 385 | } |
386 | 386 | ||
387 | QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor> current; | 387 | QSharedPointer<Sink::ApplicationDomain::BufferAdaptor> current; |
388 | d->transaction.openDatabase(bufferType + ".main").findLatest(key, [this, bufferType, newRevision, adaptorFactory, key, ¤t](const QByteArray &, const QByteArray &data) -> bool { | 388 | d->transaction.openDatabase(bufferType + ".main").findLatest(key, [this, bufferType, newRevision, adaptorFactory, key, ¤t](const QByteArray &, const QByteArray &data) -> bool { |
389 | Akonadi2::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); | 389 | Sink::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); |
390 | if (!buffer.isValid()) { | 390 | if (!buffer.isValid()) { |
391 | Warning() << "Read invalid buffer from disk"; | 391 | Warning() << "Read invalid buffer from disk"; |
392 | } else { | 392 | } else { |
393 | current = adaptorFactory->createAdaptor(buffer.entity()); | 393 | current = adaptorFactory->createAdaptor(buffer.entity()); |
394 | } | 394 | } |
395 | return false; | 395 | return false; |
396 | }, [this](const Akonadi2::Storage::Error &error) { | 396 | }, [this](const Sink::Storage::Error &error) { |
397 | ErrorMsg() << "Failed to find value in pipeline: " << error.message; | 397 | ErrorMsg() << "Failed to find value in pipeline: " << error.message; |
398 | }); | 398 | }); |
399 | 399 | ||
@@ -411,33 +411,33 @@ KAsync::Job<qint64> Pipeline::deletedEntity(void const *command, size_t size) | |||
411 | 411 | ||
412 | void Pipeline::cleanupRevision(qint64 revision) | 412 | void Pipeline::cleanupRevision(qint64 revision) |
413 | { | 413 | { |
414 | const auto uid = Akonadi2::Storage::getUidFromRevision(d->transaction, revision); | 414 | const auto uid = Sink::Storage::getUidFromRevision(d->transaction, revision); |
415 | const auto bufferType = Akonadi2::Storage::getTypeFromRevision(d->transaction, revision); | 415 | const auto bufferType = Sink::Storage::getTypeFromRevision(d->transaction, revision); |
416 | Trace() << "Cleaning up revision " << revision << uid << bufferType; | 416 | Trace() << "Cleaning up revision " << revision << uid << bufferType; |
417 | d->transaction.openDatabase(bufferType + ".main").scan(uid, [&](const QByteArray &key, const QByteArray &data) -> bool { | 417 | d->transaction.openDatabase(bufferType + ".main").scan(uid, [&](const QByteArray &key, const QByteArray &data) -> bool { |
418 | Akonadi2::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); | 418 | Sink::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); |
419 | if (!buffer.isValid()) { | 419 | if (!buffer.isValid()) { |
420 | Warning() << "Read invalid buffer from disk"; | 420 | Warning() << "Read invalid buffer from disk"; |
421 | } else { | 421 | } else { |
422 | const auto metadata = flatbuffers::GetRoot<Akonadi2::Metadata>(buffer.metadataBuffer()); | 422 | const auto metadata = flatbuffers::GetRoot<Sink::Metadata>(buffer.metadataBuffer()); |
423 | const qint64 rev = metadata->revision(); | 423 | const qint64 rev = metadata->revision(); |
424 | //Remove old revisions, and the current if the entity has already been removed | 424 | //Remove old revisions, and the current if the entity has already been removed |
425 | if (rev < revision || metadata->operation() == Akonadi2::Operation_Removal) { | 425 | if (rev < revision || metadata->operation() == Sink::Operation_Removal) { |
426 | Akonadi2::Storage::removeRevision(d->transaction, rev); | 426 | Sink::Storage::removeRevision(d->transaction, rev); |
427 | d->transaction.openDatabase(bufferType + ".main").remove(key); | 427 | d->transaction.openDatabase(bufferType + ".main").remove(key); |
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | return true; | 431 | return true; |
432 | }, [](const Akonadi2::Storage::Error &error) { | 432 | }, [](const Sink::Storage::Error &error) { |
433 | Warning() << "Error while reading: " << error.message; | 433 | Warning() << "Error while reading: " << error.message; |
434 | }, true); | 434 | }, true); |
435 | Akonadi2::Storage::setCleanedUpRevision(d->transaction, revision); | 435 | Sink::Storage::setCleanedUpRevision(d->transaction, revision); |
436 | } | 436 | } |
437 | 437 | ||
438 | qint64 Pipeline::cleanedUpRevision() | 438 | qint64 Pipeline::cleanedUpRevision() |
439 | { | 439 | { |
440 | return Akonadi2::Storage::cleanedUpRevision(d->transaction); | 440 | return Sink::Storage::cleanedUpRevision(d->transaction); |
441 | } | 441 | } |
442 | 442 | ||
443 | Preprocessor::Preprocessor() | 443 | Preprocessor::Preprocessor() |
@@ -457,5 +457,5 @@ void Preprocessor::finalize() | |||
457 | { | 457 | { |
458 | } | 458 | } |
459 | 459 | ||
460 | } // namespace Akonadi2 | 460 | } // namespace Sink |
461 | 461 | ||
diff --git a/common/pipeline.h b/common/pipeline.h index f11d880..60a5fa5 100644 --- a/common/pipeline.h +++ b/common/pipeline.h | |||
@@ -25,19 +25,19 @@ | |||
25 | #include <QSharedDataPointer> | 25 | #include <QSharedDataPointer> |
26 | #include <QObject> | 26 | #include <QObject> |
27 | 27 | ||
28 | #include <akonadi2common_export.h> | 28 | #include <sinkcommon_export.h> |
29 | #include <storage.h> | 29 | #include <storage.h> |
30 | 30 | ||
31 | #include <Async/Async> | 31 | #include <Async/Async> |
32 | 32 | ||
33 | #include "domainadaptor.h" | 33 | #include "domainadaptor.h" |
34 | 34 | ||
35 | namespace Akonadi2 | 35 | namespace Sink |
36 | { | 36 | { |
37 | 37 | ||
38 | class Preprocessor; | 38 | class Preprocessor; |
39 | 39 | ||
40 | class AKONADI2COMMON_EXPORT Pipeline : public QObject | 40 | class SINKCOMMON_EXPORT Pipeline : public QObject |
41 | { | 41 | { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | 43 | ||
@@ -79,16 +79,16 @@ private: | |||
79 | Private * const d; | 79 | Private * const d; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | class AKONADI2COMMON_EXPORT Preprocessor | 82 | class SINKCOMMON_EXPORT Preprocessor |
83 | { | 83 | { |
84 | public: | 84 | public: |
85 | Preprocessor(); | 85 | Preprocessor(); |
86 | virtual ~Preprocessor(); | 86 | virtual ~Preprocessor(); |
87 | 87 | ||
88 | virtual void startBatch(); | 88 | virtual void startBatch(); |
89 | virtual void newEntity(const QByteArray &key, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) = 0; | 89 | virtual void newEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) = 0; |
90 | virtual void modifiedEntity(const QByteArray &key, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) = 0; | 90 | virtual void modifiedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) = 0; |
91 | virtual void deletedEntity(const QByteArray &key, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, Akonadi2::Storage::Transaction &transaction) = 0; | 91 | virtual void deletedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::Transaction &transaction) = 0; |
92 | virtual void finalize(); | 92 | virtual void finalize(); |
93 | 93 | ||
94 | private: | 94 | private: |
@@ -96,5 +96,5 @@ private: | |||
96 | Private * const d; | 96 | Private * const d; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | } // namespace Akonadi2 | 99 | } // namespace Sink |
100 | 100 | ||
diff --git a/common/query.h b/common/query.h index 1df32da..a0a50ba 100644 --- a/common/query.h +++ b/common/query.h | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <QSet> | 24 | #include <QSet> |
25 | #include "applicationdomaintype.h" | 25 | #include "applicationdomaintype.h" |
26 | 26 | ||
27 | namespace Akonadi2 { | 27 | namespace Sink { |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * A query that matches a set of entities. | 30 | * A query that matches a set of entities. |
@@ -64,7 +64,7 @@ public: | |||
64 | return query; | 64 | return query; |
65 | } | 65 | } |
66 | 66 | ||
67 | static Query ResourceFilter(const ApplicationDomain::AkonadiResource &entity) | 67 | static Query ResourceFilter(const ApplicationDomain::SinkResource &entity) |
68 | { | 68 | { |
69 | return ResourceFilter(entity.identifier()); | 69 | return ResourceFilter(entity.identifier()); |
70 | } | 70 | } |
@@ -138,4 +138,4 @@ public: | |||
138 | 138 | ||
139 | } | 139 | } |
140 | 140 | ||
141 | Q_DECLARE_OPERATORS_FOR_FLAGS(Akonadi2::Query::Flags) | 141 | Q_DECLARE_OPERATORS_FOR_FLAGS(Sink::Query::Flags) |
diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp index 89610e3..25d69b1 100644 --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "domainadaptor.h" | 26 | #include "domainadaptor.h" |
27 | #include "asyncutils.h" | 27 | #include "asyncutils.h" |
28 | 28 | ||
29 | using namespace Akonadi2; | 29 | using namespace Sink; |
30 | 30 | ||
31 | /* | 31 | /* |
32 | * This class wraps the actual query implementation. | 32 | * This class wraps the actual query implementation. |
@@ -38,34 +38,34 @@ template<typename DomainType> | |||
38 | class QueryWorker : public QObject | 38 | class QueryWorker : public QObject |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | QueryWorker(const Akonadi2::Query &query, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &, const QByteArray &bufferType); | 41 | QueryWorker(const Sink::Query &query, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &, const QByteArray &bufferType); |
42 | virtual ~QueryWorker(); | 42 | virtual ~QueryWorker(); |
43 | 43 | ||
44 | qint64 executeIncrementalQuery(const Akonadi2::Query &query, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider); | 44 | qint64 executeIncrementalQuery(const Sink::Query &query, Sink::ResultProviderInterface<typename DomainType::Ptr> &resultProvider); |
45 | qint64 executeInitialQuery(const Akonadi2::Query &query, const typename DomainType::Ptr &parent, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider); | 45 | qint64 executeInitialQuery(const Sink::Query &query, const typename DomainType::Ptr &parent, Sink::ResultProviderInterface<typename DomainType::Ptr> &resultProvider); |
46 | 46 | ||
47 | private: | 47 | private: |
48 | static void replaySet(ResultSet &resultSet, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, const QList<QByteArray> &properties); | 48 | static void replaySet(ResultSet &resultSet, Sink::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, const QList<QByteArray> &properties); |
49 | 49 | ||
50 | void readEntity(const Akonadi2::Storage::NamedDatabase &db, const QByteArray &key, const std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)> &resultCallback); | 50 | void readEntity(const Sink::Storage::NamedDatabase &db, const QByteArray &key, const std::function<void(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &, Sink::Operation)> &resultCallback); |
51 | 51 | ||
52 | ResultSet loadInitialResultSet(const Akonadi2::Query &query, Akonadi2::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters); | 52 | ResultSet loadInitialResultSet(const Sink::Query &query, Sink::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters); |
53 | ResultSet loadIncrementalResultSet(qint64 baseRevision, const Akonadi2::Query &query, Akonadi2::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters); | 53 | ResultSet loadIncrementalResultSet(qint64 baseRevision, const Sink::Query &query, Sink::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters); |
54 | 54 | ||
55 | ResultSet filterSet(const ResultSet &resultSet, const std::function<bool(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> &filter, const Akonadi2::Storage::NamedDatabase &db, bool initialQuery); | 55 | ResultSet filterSet(const ResultSet &resultSet, const std::function<bool(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> &filter, const Sink::Storage::NamedDatabase &db, bool initialQuery); |
56 | std::function<bool(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> getFilter(const QSet<QByteArray> remainingFilters, const Akonadi2::Query &query); | 56 | std::function<bool(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> getFilter(const QSet<QByteArray> remainingFilters, const Sink::Query &query); |
57 | qint64 load(const Akonadi2::Query &query, const std::function<ResultSet(Akonadi2::Storage::Transaction &, QSet<QByteArray> &)> &baseSetRetriever, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, bool initialQuery); | 57 | qint64 load(const Sink::Query &query, const std::function<ResultSet(Sink::Storage::Transaction &, QSet<QByteArray> &)> &baseSetRetriever, Sink::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, bool initialQuery); |
58 | 58 | ||
59 | private: | 59 | private: |
60 | DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory; | 60 | DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory; |
61 | QByteArray mResourceInstanceIdentifier; | 61 | QByteArray mResourceInstanceIdentifier; |
62 | QByteArray mBufferType; | 62 | QByteArray mBufferType; |
63 | Akonadi2::Query mQuery; | 63 | Sink::Query mQuery; |
64 | }; | 64 | }; |
65 | 65 | ||
66 | 66 | ||
67 | template<class DomainType> | 67 | template<class DomainType> |
68 | QueryRunner<DomainType>::QueryRunner(const Akonadi2::Query &query, const Akonadi2::ResourceAccessInterface::Ptr &resourceAccess, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &factory, const QByteArray &bufferType) | 68 | QueryRunner<DomainType>::QueryRunner(const Sink::Query &query, const Sink::ResourceAccessInterface::Ptr &resourceAccess, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &factory, const QByteArray &bufferType) |
69 | : QueryRunnerBase(), | 69 | : QueryRunnerBase(), |
70 | mResourceAccess(resourceAccess), | 70 | mResourceAccess(resourceAccess), |
71 | mResultProvider(new ResultProvider<typename DomainType::Ptr>) | 71 | mResultProvider(new ResultProvider<typename DomainType::Ptr>) |
@@ -107,7 +107,7 @@ QueryRunner<DomainType>::QueryRunner(const Akonadi2::Query &query, const Akonadi | |||
107 | //Ensure the connection is open, if it wasn't already opened | 107 | //Ensure the connection is open, if it wasn't already opened |
108 | //TODO If we are not connected already, we have to check for the latest revision once connected, otherwise we could miss some updates | 108 | //TODO If we are not connected already, we have to check for the latest revision once connected, otherwise we could miss some updates |
109 | mResourceAccess->open(); | 109 | mResourceAccess->open(); |
110 | QObject::connect(mResourceAccess.data(), &Akonadi2::ResourceAccess::revisionChanged, this, &QueryRunner::revisionChanged); | 110 | QObject::connect(mResourceAccess.data(), &Sink::ResourceAccess::revisionChanged, this, &QueryRunner::revisionChanged); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
@@ -118,26 +118,26 @@ QueryRunner<DomainType>::~QueryRunner() | |||
118 | } | 118 | } |
119 | 119 | ||
120 | template<class DomainType> | 120 | template<class DomainType> |
121 | typename Akonadi2::ResultEmitter<typename DomainType::Ptr>::Ptr QueryRunner<DomainType>::emitter() | 121 | typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr QueryRunner<DomainType>::emitter() |
122 | { | 122 | { |
123 | return mResultProvider->emitter(); | 123 | return mResultProvider->emitter(); |
124 | } | 124 | } |
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | static inline ResultSet fullScan(const Akonadi2::Storage::Transaction &transaction, const QByteArray &bufferType) | 128 | static inline ResultSet fullScan(const Sink::Storage::Transaction &transaction, const QByteArray &bufferType) |
129 | { | 129 | { |
130 | //TODO use a result set with an iterator, to read values on demand | 130 | //TODO use a result set with an iterator, to read values on demand |
131 | QVector<QByteArray> keys; | 131 | QVector<QByteArray> keys; |
132 | transaction.openDatabase(bufferType + ".main").scan(QByteArray(), [&](const QByteArray &key, const QByteArray &value) -> bool { | 132 | transaction.openDatabase(bufferType + ".main").scan(QByteArray(), [&](const QByteArray &key, const QByteArray &value) -> bool { |
133 | //Skip internals | 133 | //Skip internals |
134 | if (Akonadi2::Storage::isInternalKey(key)) { | 134 | if (Sink::Storage::isInternalKey(key)) { |
135 | return true; | 135 | return true; |
136 | } | 136 | } |
137 | keys << Akonadi2::Storage::uidFromKey(key); | 137 | keys << Sink::Storage::uidFromKey(key); |
138 | return true; | 138 | return true; |
139 | }, | 139 | }, |
140 | [](const Akonadi2::Storage::Error &error) { | 140 | [](const Sink::Storage::Error &error) { |
141 | qWarning() << "Error during query: " << error.message; | 141 | qWarning() << "Error during query: " << error.message; |
142 | }); | 142 | }); |
143 | 143 | ||
@@ -147,7 +147,7 @@ static inline ResultSet fullScan(const Akonadi2::Storage::Transaction &transacti | |||
147 | 147 | ||
148 | 148 | ||
149 | template<class DomainType> | 149 | template<class DomainType> |
150 | QueryWorker<DomainType>::QueryWorker(const Akonadi2::Query &query, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &factory, const QByteArray &bufferType) | 150 | QueryWorker<DomainType>::QueryWorker(const Sink::Query &query, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &factory, const QByteArray &bufferType) |
151 | : QObject(), | 151 | : QObject(), |
152 | mDomainTypeAdaptorFactory(factory), | 152 | mDomainTypeAdaptorFactory(factory), |
153 | mResourceInstanceIdentifier(instanceIdentifier), | 153 | mResourceInstanceIdentifier(instanceIdentifier), |
@@ -164,23 +164,23 @@ QueryWorker<DomainType>::~QueryWorker() | |||
164 | } | 164 | } |
165 | 165 | ||
166 | template<class DomainType> | 166 | template<class DomainType> |
167 | void QueryWorker<DomainType>::replaySet(ResultSet &resultSet, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, const QList<QByteArray> &properties) | 167 | void QueryWorker<DomainType>::replaySet(ResultSet &resultSet, Sink::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, const QList<QByteArray> &properties) |
168 | { | 168 | { |
169 | int counter = 0; | 169 | int counter = 0; |
170 | while (resultSet.next([&resultProvider, &counter, &properties](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &value, Akonadi2::Operation operation) -> bool { | 170 | while (resultSet.next([&resultProvider, &counter, &properties](const Sink::ApplicationDomain::ApplicationDomainType::Ptr &value, Sink::Operation operation) -> bool { |
171 | counter++; | 171 | counter++; |
172 | switch (operation) { | 172 | switch (operation) { |
173 | case Akonadi2::Operation_Creation: | 173 | case Sink::Operation_Creation: |
174 | // Trace() << "Got creation"; | 174 | // Trace() << "Got creation"; |
175 | resultProvider.add(Akonadi2::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value, properties).template staticCast<DomainType>()); | 175 | resultProvider.add(Sink::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value, properties).template staticCast<DomainType>()); |
176 | break; | 176 | break; |
177 | case Akonadi2::Operation_Modification: | 177 | case Sink::Operation_Modification: |
178 | // Trace() << "Got modification"; | 178 | // Trace() << "Got modification"; |
179 | resultProvider.modify(Akonadi2::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value, properties).template staticCast<DomainType>()); | 179 | resultProvider.modify(Sink::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value, properties).template staticCast<DomainType>()); |
180 | break; | 180 | break; |
181 | case Akonadi2::Operation_Removal: | 181 | case Sink::Operation_Removal: |
182 | // Trace() << "Got removal"; | 182 | // Trace() << "Got removal"; |
183 | resultProvider.remove(Akonadi2::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value, properties).template staticCast<DomainType>()); | 183 | resultProvider.remove(Sink::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(*value, properties).template staticCast<DomainType>()); |
184 | break; | 184 | break; |
185 | } | 185 | } |
186 | return true; | 186 | return true; |
@@ -189,35 +189,35 @@ void QueryWorker<DomainType>::replaySet(ResultSet &resultSet, Akonadi2::ResultPr | |||
189 | } | 189 | } |
190 | 190 | ||
191 | template<class DomainType> | 191 | template<class DomainType> |
192 | void QueryWorker<DomainType>::readEntity(const Akonadi2::Storage::NamedDatabase &db, const QByteArray &key, const std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)> &resultCallback) | 192 | void QueryWorker<DomainType>::readEntity(const Sink::Storage::NamedDatabase &db, const QByteArray &key, const std::function<void(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &, Sink::Operation)> &resultCallback) |
193 | { | 193 | { |
194 | //This only works for a 1:1 mapping of resource to domain types. | 194 | //This only works for a 1:1 mapping of resource to domain types. |
195 | //Not i.e. for tags that are stored as flags in each entity of an imap store. | 195 | //Not i.e. for tags that are stored as flags in each entity of an imap store. |
196 | //additional properties that don't have a 1:1 mapping (such as separately stored tags), | 196 | //additional properties that don't have a 1:1 mapping (such as separately stored tags), |
197 | //could be added to the adaptor. | 197 | //could be added to the adaptor. |
198 | db.findLatest(key, [=](const QByteArray &key, const QByteArray &value) -> bool { | 198 | db.findLatest(key, [=](const QByteArray &key, const QByteArray &value) -> bool { |
199 | Akonadi2::EntityBuffer buffer(value.data(), value.size()); | 199 | Sink::EntityBuffer buffer(value.data(), value.size()); |
200 | const Akonadi2::Entity &entity = buffer.entity(); | 200 | const Sink::Entity &entity = buffer.entity(); |
201 | const auto metadataBuffer = Akonadi2::EntityBuffer::readBuffer<Akonadi2::Metadata>(entity.metadata()); | 201 | const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); |
202 | Q_ASSERT(metadataBuffer); | 202 | Q_ASSERT(metadataBuffer); |
203 | const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; | 203 | const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; |
204 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Akonadi2::Operation_Creation; | 204 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; |
205 | resultCallback(DomainType::Ptr::create(mResourceInstanceIdentifier, Akonadi2::Storage::uidFromKey(key), revision, mDomainTypeAdaptorFactory->createAdaptor(entity)), operation); | 205 | resultCallback(DomainType::Ptr::create(mResourceInstanceIdentifier, Sink::Storage::uidFromKey(key), revision, mDomainTypeAdaptorFactory->createAdaptor(entity)), operation); |
206 | return false; | 206 | return false; |
207 | }, | 207 | }, |
208 | [](const Akonadi2::Storage::Error &error) { | 208 | [](const Sink::Storage::Error &error) { |
209 | qWarning() << "Error during query: " << error.message; | 209 | qWarning() << "Error during query: " << error.message; |
210 | }); | 210 | }); |
211 | } | 211 | } |
212 | 212 | ||
213 | template<class DomainType> | 213 | template<class DomainType> |
214 | ResultSet QueryWorker<DomainType>::loadInitialResultSet(const Akonadi2::Query &query, Akonadi2::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters) | 214 | ResultSet QueryWorker<DomainType>::loadInitialResultSet(const Sink::Query &query, Sink::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters) |
215 | { | 215 | { |
216 | if (!query.ids.isEmpty()) { | 216 | if (!query.ids.isEmpty()) { |
217 | return ResultSet(query.ids.toVector()); | 217 | return ResultSet(query.ids.toVector()); |
218 | } | 218 | } |
219 | QSet<QByteArray> appliedFilters; | 219 | QSet<QByteArray> appliedFilters; |
220 | auto resultSet = Akonadi2::ApplicationDomain::TypeImplementation<DomainType>::queryIndexes(query, mResourceInstanceIdentifier, appliedFilters, transaction); | 220 | auto resultSet = Sink::ApplicationDomain::TypeImplementation<DomainType>::queryIndexes(query, mResourceInstanceIdentifier, appliedFilters, transaction); |
221 | remainingFilters = query.propertyFilter.keys().toSet() - appliedFilters; | 221 | remainingFilters = query.propertyFilter.keys().toSet() - appliedFilters; |
222 | 222 | ||
223 | //We do a full scan if there were no indexes available to create the initial set. | 223 | //We do a full scan if there were no indexes available to create the initial set. |
@@ -229,24 +229,24 @@ ResultSet QueryWorker<DomainType>::loadInitialResultSet(const Akonadi2::Query &q | |||
229 | } | 229 | } |
230 | 230 | ||
231 | template<class DomainType> | 231 | template<class DomainType> |
232 | ResultSet QueryWorker<DomainType>::loadIncrementalResultSet(qint64 baseRevision, const Akonadi2::Query &query, Akonadi2::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters) | 232 | ResultSet QueryWorker<DomainType>::loadIncrementalResultSet(qint64 baseRevision, const Sink::Query &query, Sink::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters) |
233 | { | 233 | { |
234 | const auto bufferType = mBufferType; | 234 | const auto bufferType = mBufferType; |
235 | auto revisionCounter = QSharedPointer<qint64>::create(baseRevision); | 235 | auto revisionCounter = QSharedPointer<qint64>::create(baseRevision); |
236 | remainingFilters = query.propertyFilter.keys().toSet(); | 236 | remainingFilters = query.propertyFilter.keys().toSet(); |
237 | return ResultSet([bufferType, revisionCounter, &transaction]() -> QByteArray { | 237 | return ResultSet([bufferType, revisionCounter, &transaction]() -> QByteArray { |
238 | const qint64 topRevision = Akonadi2::Storage::maxRevision(transaction); | 238 | const qint64 topRevision = Sink::Storage::maxRevision(transaction); |
239 | //Spit out the revision keys one by one. | 239 | //Spit out the revision keys one by one. |
240 | while (*revisionCounter <= topRevision) { | 240 | while (*revisionCounter <= topRevision) { |
241 | const auto uid = Akonadi2::Storage::getUidFromRevision(transaction, *revisionCounter); | 241 | const auto uid = Sink::Storage::getUidFromRevision(transaction, *revisionCounter); |
242 | const auto type = Akonadi2::Storage::getTypeFromRevision(transaction, *revisionCounter); | 242 | const auto type = Sink::Storage::getTypeFromRevision(transaction, *revisionCounter); |
243 | // Trace() << "Revision" << *revisionCounter << type << uid; | 243 | // Trace() << "Revision" << *revisionCounter << type << uid; |
244 | if (type != bufferType) { | 244 | if (type != bufferType) { |
245 | //Skip revision | 245 | //Skip revision |
246 | *revisionCounter += 1; | 246 | *revisionCounter += 1; |
247 | continue; | 247 | continue; |
248 | } | 248 | } |
249 | const auto key = Akonadi2::Storage::assembleKey(uid, *revisionCounter); | 249 | const auto key = Sink::Storage::assembleKey(uid, *revisionCounter); |
250 | *revisionCounter += 1; | 250 | *revisionCounter += 1; |
251 | return key; | 251 | return key; |
252 | } | 252 | } |
@@ -257,21 +257,21 @@ ResultSet QueryWorker<DomainType>::loadIncrementalResultSet(qint64 baseRevision, | |||
257 | } | 257 | } |
258 | 258 | ||
259 | template<class DomainType> | 259 | template<class DomainType> |
260 | ResultSet QueryWorker<DomainType>::filterSet(const ResultSet &resultSet, const std::function<bool(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> &filter, const Akonadi2::Storage::NamedDatabase &db, bool initialQuery) | 260 | ResultSet QueryWorker<DomainType>::filterSet(const ResultSet &resultSet, const std::function<bool(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> &filter, const Sink::Storage::NamedDatabase &db, bool initialQuery) |
261 | { | 261 | { |
262 | auto resultSetPtr = QSharedPointer<ResultSet>::create(resultSet); | 262 | auto resultSetPtr = QSharedPointer<ResultSet>::create(resultSet); |
263 | 263 | ||
264 | //Read through the source values and return whatever matches the filter | 264 | //Read through the source values and return whatever matches the filter |
265 | std::function<bool(std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)>)> generator = [this, resultSetPtr, &db, filter, initialQuery](std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)> callback) -> bool { | 265 | std::function<bool(std::function<void(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &, Sink::Operation)>)> generator = [this, resultSetPtr, &db, filter, initialQuery](std::function<void(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &, Sink::Operation)> callback) -> bool { |
266 | if (resultSetPtr->next()) { | 266 | if (resultSetPtr->next()) { |
267 | //readEntity is only necessary if we actually want to filter or know the operation type (but not a big deal if we do it always I guess) | 267 | //readEntity is only necessary if we actually want to filter or know the operation type (but not a big deal if we do it always I guess) |
268 | readEntity(db, resultSetPtr->id(), [this, filter, callback, initialQuery](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject, Akonadi2::Operation operation) { | 268 | readEntity(db, resultSetPtr->id(), [this, filter, callback, initialQuery](const Sink::ApplicationDomain::ApplicationDomainType::Ptr &domainObject, Sink::Operation operation) { |
269 | //Always remove removals, they probably don't match due to non-available properties | 269 | //Always remove removals, they probably don't match due to non-available properties |
270 | if (filter(domainObject) || operation == Akonadi2::Operation_Removal) { | 270 | if (filter(domainObject) || operation == Sink::Operation_Removal) { |
271 | if (initialQuery) { | 271 | if (initialQuery) { |
272 | //We're not interested in removals during the initial query | 272 | //We're not interested in removals during the initial query |
273 | if (operation != Akonadi2::Operation_Removal) { | 273 | if (operation != Sink::Operation_Removal) { |
274 | callback(domainObject, Akonadi2::Operation_Creation); | 274 | callback(domainObject, Sink::Operation_Creation); |
275 | } | 275 | } |
276 | } else { | 276 | } else { |
277 | callback(domainObject, operation); | 277 | callback(domainObject, operation); |
@@ -287,9 +287,9 @@ ResultSet QueryWorker<DomainType>::filterSet(const ResultSet &resultSet, const s | |||
287 | } | 287 | } |
288 | 288 | ||
289 | template<class DomainType> | 289 | template<class DomainType> |
290 | std::function<bool(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> QueryWorker<DomainType>::getFilter(const QSet<QByteArray> remainingFilters, const Akonadi2::Query &query) | 290 | std::function<bool(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> QueryWorker<DomainType>::getFilter(const QSet<QByteArray> remainingFilters, const Sink::Query &query) |
291 | { | 291 | { |
292 | return [remainingFilters, query](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject) -> bool { | 292 | return [remainingFilters, query](const Sink::ApplicationDomain::ApplicationDomainType::Ptr &domainObject) -> bool { |
293 | if (!query.ids.isEmpty()) { | 293 | if (!query.ids.isEmpty()) { |
294 | if (!query.ids.contains(domainObject->identifier())) { | 294 | if (!query.ids.contains(domainObject->identifier())) { |
295 | return false; | 295 | return false; |
@@ -312,32 +312,32 @@ std::function<bool(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr | |||
312 | } | 312 | } |
313 | 313 | ||
314 | template<class DomainType> | 314 | template<class DomainType> |
315 | qint64 QueryWorker<DomainType>::load(const Akonadi2::Query &query, const std::function<ResultSet(Akonadi2::Storage::Transaction &, QSet<QByteArray> &)> &baseSetRetriever, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, bool initialQuery) | 315 | qint64 QueryWorker<DomainType>::load(const Sink::Query &query, const std::function<ResultSet(Sink::Storage::Transaction &, QSet<QByteArray> &)> &baseSetRetriever, Sink::ResultProviderInterface<typename DomainType::Ptr> &resultProvider, bool initialQuery) |
316 | { | 316 | { |
317 | Akonadi2::Storage storage(Akonadi2::storageLocation(), mResourceInstanceIdentifier); | 317 | Sink::Storage storage(Sink::storageLocation(), mResourceInstanceIdentifier); |
318 | storage.setDefaultErrorHandler([](const Akonadi2::Storage::Error &error) { | 318 | storage.setDefaultErrorHandler([](const Sink::Storage::Error &error) { |
319 | Warning() << "Error during query: " << error.store << error.message; | 319 | Warning() << "Error during query: " << error.store << error.message; |
320 | }); | 320 | }); |
321 | auto transaction = storage.createTransaction(Akonadi2::Storage::ReadOnly); | 321 | auto transaction = storage.createTransaction(Sink::Storage::ReadOnly); |
322 | auto db = transaction.openDatabase(mBufferType + ".main"); | 322 | auto db = transaction.openDatabase(mBufferType + ".main"); |
323 | 323 | ||
324 | QSet<QByteArray> remainingFilters; | 324 | QSet<QByteArray> remainingFilters; |
325 | auto resultSet = baseSetRetriever(transaction, remainingFilters); | 325 | auto resultSet = baseSetRetriever(transaction, remainingFilters); |
326 | auto filteredSet = filterSet(resultSet, getFilter(remainingFilters, query), db, initialQuery); | 326 | auto filteredSet = filterSet(resultSet, getFilter(remainingFilters, query), db, initialQuery); |
327 | replaySet(filteredSet, resultProvider, query.requestedProperties); | 327 | replaySet(filteredSet, resultProvider, query.requestedProperties); |
328 | resultProvider.setRevision(Akonadi2::Storage::maxRevision(transaction)); | 328 | resultProvider.setRevision(Sink::Storage::maxRevision(transaction)); |
329 | return Akonadi2::Storage::maxRevision(transaction); | 329 | return Sink::Storage::maxRevision(transaction); |
330 | } | 330 | } |
331 | 331 | ||
332 | template<class DomainType> | 332 | template<class DomainType> |
333 | qint64 QueryWorker<DomainType>::executeIncrementalQuery(const Akonadi2::Query &query, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider) | 333 | qint64 QueryWorker<DomainType>::executeIncrementalQuery(const Sink::Query &query, Sink::ResultProviderInterface<typename DomainType::Ptr> &resultProvider) |
334 | { | 334 | { |
335 | QTime time; | 335 | QTime time; |
336 | time.start(); | 336 | time.start(); |
337 | 337 | ||
338 | const qint64 baseRevision = resultProvider.revision() + 1; | 338 | const qint64 baseRevision = resultProvider.revision() + 1; |
339 | Trace() << "Running incremental query " << baseRevision; | 339 | Trace() << "Running incremental query " << baseRevision; |
340 | auto revision = load(query, [&](Akonadi2::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters) -> ResultSet { | 340 | auto revision = load(query, [&](Sink::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters) -> ResultSet { |
341 | return loadIncrementalResultSet(baseRevision, query, transaction, remainingFilters); | 341 | return loadIncrementalResultSet(baseRevision, query, transaction, remainingFilters); |
342 | }, resultProvider, false); | 342 | }, resultProvider, false); |
343 | Trace() << "Incremental query took: " << time.elapsed() << " ms"; | 343 | Trace() << "Incremental query took: " << time.elapsed() << " ms"; |
@@ -345,7 +345,7 @@ qint64 QueryWorker<DomainType>::executeIncrementalQuery(const Akonadi2::Query &q | |||
345 | } | 345 | } |
346 | 346 | ||
347 | template<class DomainType> | 347 | template<class DomainType> |
348 | qint64 QueryWorker<DomainType>::executeInitialQuery(const Akonadi2::Query &query, const typename DomainType::Ptr &parent, Akonadi2::ResultProviderInterface<typename DomainType::Ptr> &resultProvider) | 348 | qint64 QueryWorker<DomainType>::executeInitialQuery(const Sink::Query &query, const typename DomainType::Ptr &parent, Sink::ResultProviderInterface<typename DomainType::Ptr> &resultProvider) |
349 | { | 349 | { |
350 | QTime time; | 350 | QTime time; |
351 | time.start(); | 351 | time.start(); |
@@ -360,7 +360,7 @@ qint64 QueryWorker<DomainType>::executeInitialQuery(const Akonadi2::Query &query | |||
360 | modifiedQuery.propertyFilter.insert(query.parentProperty, QVariant()); | 360 | modifiedQuery.propertyFilter.insert(query.parentProperty, QVariant()); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | auto revision = load(modifiedQuery, [&](Akonadi2::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters) -> ResultSet { | 363 | auto revision = load(modifiedQuery, [&](Sink::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters) -> ResultSet { |
364 | return loadInitialResultSet(modifiedQuery, transaction, remainingFilters); | 364 | return loadInitialResultSet(modifiedQuery, transaction, remainingFilters); |
365 | }, resultProvider, true); | 365 | }, resultProvider, true); |
366 | Trace() << "Initial query took: " << time.elapsed() << " ms"; | 366 | Trace() << "Initial query took: " << time.elapsed() << " ms"; |
@@ -368,9 +368,9 @@ qint64 QueryWorker<DomainType>::executeInitialQuery(const Akonadi2::Query &query | |||
368 | return revision; | 368 | return revision; |
369 | } | 369 | } |
370 | 370 | ||
371 | template class QueryRunner<Akonadi2::ApplicationDomain::Folder>; | 371 | template class QueryRunner<Sink::ApplicationDomain::Folder>; |
372 | template class QueryRunner<Akonadi2::ApplicationDomain::Mail>; | 372 | template class QueryRunner<Sink::ApplicationDomain::Mail>; |
373 | template class QueryRunner<Akonadi2::ApplicationDomain::Event>; | 373 | template class QueryRunner<Sink::ApplicationDomain::Event>; |
374 | template class QueryWorker<Akonadi2::ApplicationDomain::Folder>; | 374 | template class QueryWorker<Sink::ApplicationDomain::Folder>; |
375 | template class QueryWorker<Akonadi2::ApplicationDomain::Mail>; | 375 | template class QueryWorker<Sink::ApplicationDomain::Mail>; |
376 | template class QueryWorker<Akonadi2::ApplicationDomain::Event>; | 376 | template class QueryWorker<Sink::ApplicationDomain::Event>; |
diff --git a/common/queryrunner.h b/common/queryrunner.h index aba7912..0ee6a81 100644 --- a/common/queryrunner.h +++ b/common/queryrunner.h | |||
@@ -79,13 +79,13 @@ template<typename DomainType> | |||
79 | class QueryRunner : public QueryRunnerBase | 79 | class QueryRunner : public QueryRunnerBase |
80 | { | 80 | { |
81 | public: | 81 | public: |
82 | QueryRunner(const Akonadi2::Query &query, const Akonadi2::ResourceAccessInterface::Ptr &, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &, const QByteArray &bufferType); | 82 | QueryRunner(const Sink::Query &query, const Sink::ResourceAccessInterface::Ptr &, const QByteArray &instanceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &, const QByteArray &bufferType); |
83 | virtual ~QueryRunner(); | 83 | virtual ~QueryRunner(); |
84 | 84 | ||
85 | typename Akonadi2::ResultEmitter<typename DomainType::Ptr>::Ptr emitter(); | 85 | typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr emitter(); |
86 | 86 | ||
87 | private: | 87 | private: |
88 | QSharedPointer<Akonadi2::ResourceAccessInterface> mResourceAccess; | 88 | QSharedPointer<Sink::ResourceAccessInterface> mResourceAccess; |
89 | QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > mResultProvider; | 89 | QSharedPointer<Sink::ResultProvider<typename DomainType::Ptr> > mResultProvider; |
90 | }; | 90 | }; |
91 | 91 | ||
diff --git a/common/queuedcommand.fbs b/common/queuedcommand.fbs index 0ca899f..06226d3 100644 --- a/common/queuedcommand.fbs +++ b/common/queuedcommand.fbs | |||
@@ -1,4 +1,4 @@ | |||
1 | namespace Akonadi2; | 1 | namespace Sink; |
2 | 2 | ||
3 | table QueuedCommand { | 3 | table QueuedCommand { |
4 | commandId: int; | 4 | commandId: int; |
diff --git a/common/resource.cpp b/common/resource.cpp index 4541726..8c448a8 100644 --- a/common/resource.cpp +++ b/common/resource.cpp | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | #include "facadefactory.h" | 28 | #include "facadefactory.h" |
29 | 29 | ||
30 | namespace Akonadi2 | 30 | namespace Sink |
31 | { | 31 | { |
32 | 32 | ||
33 | Resource::Resource() | 33 | Resource::Resource() |
@@ -94,8 +94,8 @@ ResourceFactory *ResourceFactory::load(const QString &resourceName) | |||
94 | if (path.endsWith(QLatin1String("plugins"))) { | 94 | if (path.endsWith(QLatin1String("plugins"))) { |
95 | QDir pluginDir(path); | 95 | QDir pluginDir(path); |
96 | //TODO: centralize this so that it is easy to change centrally | 96 | //TODO: centralize this so that it is easy to change centrally |
97 | // also ref'd in cmake as ${AKONADI_RESOURCE_PLUGINS_PATH} | 97 | // also ref'd in cmake as ${SINK_RESOURCE_PLUGINS_PATH} |
98 | pluginDir.cd(QStringLiteral("akonadi2")); | 98 | pluginDir.cd(QStringLiteral("sink")); |
99 | pluginDir.cd(QStringLiteral("resources")); | 99 | pluginDir.cd(QStringLiteral("resources")); |
100 | 100 | ||
101 | for (const QString &fileName: pluginDir.entryList(QDir::Files)) { | 101 | for (const QString &fileName: pluginDir.entryList(QDir::Files)) { |
@@ -128,4 +128,4 @@ ResourceFactory *ResourceFactory::load(const QString &resourceName) | |||
128 | return nullptr; | 128 | return nullptr; |
129 | } | 129 | } |
130 | 130 | ||
131 | } // namespace Akonadi2 | 131 | } // namespace Sink |
diff --git a/common/resource.h b/common/resource.h index 2ae71a0..30d6c46 100644 --- a/common/resource.h +++ b/common/resource.h | |||
@@ -19,19 +19,19 @@ | |||
19 | */ | 19 | */ |
20 | #pragma once | 20 | #pragma once |
21 | 21 | ||
22 | #include <akonadi2common_export.h> | 22 | #include <sinkcommon_export.h> |
23 | 23 | ||
24 | #include <Async/Async> | 24 | #include <Async/Async> |
25 | #include "notification.h" | 25 | #include "notification.h" |
26 | 26 | ||
27 | namespace Akonadi2 | 27 | namespace Sink |
28 | { | 28 | { |
29 | class FacadeFactory; | 29 | class FacadeFactory; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * Resource interface | 32 | * Resource interface |
33 | */ | 33 | */ |
34 | class AKONADI2COMMON_EXPORT Resource : public QObject | 34 | class SINKCOMMON_EXPORT Resource : public QObject |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
@@ -83,8 +83,8 @@ private: | |||
83 | Private * const d; | 83 | Private * const d; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | } // namespace Akonadi2 | 86 | } // namespace Sink |
87 | 87 | ||
88 | Q_DECLARE_INTERFACE(Akonadi2::ResourceFactory, "org.kde.akonadi2.resourcefactory") | 88 | Q_DECLARE_INTERFACE(Sink::ResourceFactory, "org.kde.sink.resourcefactory") |
89 | 89 | ||
90 | 90 | ||
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 6592699..0c435c9 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -43,9 +43,9 @@ | |||
43 | #include <QBuffer> | 43 | #include <QBuffer> |
44 | 44 | ||
45 | #undef Trace | 45 | #undef Trace |
46 | #define Trace() Akonadi2::Log::debugStream(Akonadi2::Log::DebugLevel::Trace, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess") | 46 | #define Trace() Sink::Log::debugStream(Sink::Log::DebugLevel::Trace, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess") |
47 | #undef Log | 47 | #undef Log |
48 | #define Log(IDENTIFIER) Akonadi2::Log::debugStream(Akonadi2::Log::DebugLevel::Log, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess("+IDENTIFIER+")") | 48 | #define Log(IDENTIFIER) Sink::Log::debugStream(Sink::Log::DebugLevel::Log, __LINE__, __FILE__, Q_FUNC_INFO, "ResourceAccess("+IDENTIFIER+")") |
49 | 49 | ||
50 | static void queuedInvoke(const std::function<void()> &f, QObject *context = 0) | 50 | static void queuedInvoke(const std::function<void()> &f, QObject *context = 0) |
51 | { | 51 | { |
@@ -57,7 +57,7 @@ static void queuedInvoke(const std::function<void()> &f, QObject *context = 0) | |||
57 | timer->start(0); | 57 | timer->start(0); |
58 | } | 58 | } |
59 | 59 | ||
60 | namespace Akonadi2 | 60 | namespace Sink |
61 | { | 61 | { |
62 | 62 | ||
63 | struct QueuedCommand | 63 | struct QueuedCommand |
@@ -205,7 +205,7 @@ KAsync::Job<void> ResourceAccess::Private::initializeSocket() | |||
205 | QStringList args; | 205 | QStringList args; |
206 | args << resourceInstanceIdentifier; | 206 | args << resourceInstanceIdentifier; |
207 | qint64 pid = 0; | 207 | qint64 pid = 0; |
208 | if (QProcess::startDetached("akonadi2_synchronizer", args, QDir::homePath(), &pid)) { | 208 | if (QProcess::startDetached("sink_synchronizer", args, QDir::homePath(), &pid)) { |
209 | Trace() << "Started resource " << pid; | 209 | Trace() << "Started resource " << pid; |
210 | tryToConnect() | 210 | tryToConnect() |
211 | .then<void>([&future]() { | 211 | .then<void>([&future]() { |
@@ -298,8 +298,8 @@ KAsync::Job<void> ResourceAccess::synchronizeResource(bool sourceSync, bool loca | |||
298 | { | 298 | { |
299 | Trace() << "Sending synchronize command: " << sourceSync << localSync; | 299 | Trace() << "Sending synchronize command: " << sourceSync << localSync; |
300 | flatbuffers::FlatBufferBuilder fbb; | 300 | flatbuffers::FlatBufferBuilder fbb; |
301 | auto command = Akonadi2::Commands::CreateSynchronize(fbb, sourceSync, localSync); | 301 | auto command = Sink::Commands::CreateSynchronize(fbb, sourceSync, localSync); |
302 | Akonadi2::Commands::FinishSynchronizeBuffer(fbb, command); | 302 | Sink::Commands::FinishSynchronizeBuffer(fbb, command); |
303 | open(); | 303 | open(); |
304 | return sendCommand(Commands::SynchronizeCommand, fbb); | 304 | return sendCommand(Commands::SynchronizeCommand, fbb); |
305 | } | 305 | } |
@@ -309,11 +309,11 @@ KAsync::Job<void> ResourceAccess::sendCreateCommand(const QByteArray &resourceBu | |||
309 | flatbuffers::FlatBufferBuilder fbb; | 309 | flatbuffers::FlatBufferBuilder fbb; |
310 | //This is the resource buffer type and not the domain type | 310 | //This is the resource buffer type and not the domain type |
311 | auto type = fbb.CreateString(resourceBufferType.constData()); | 311 | auto type = fbb.CreateString(resourceBufferType.constData()); |
312 | auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size()); | 312 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size()); |
313 | auto location = Akonadi2::Commands::CreateCreateEntity(fbb, 0, type, delta); | 313 | auto location = Sink::Commands::CreateCreateEntity(fbb, 0, type, delta); |
314 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 314 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); |
315 | open(); | 315 | open(); |
316 | return sendCommand(Akonadi2::Commands::CreateEntityCommand, fbb); | 316 | return sendCommand(Sink::Commands::CreateEntityCommand, fbb); |
317 | } | 317 | } |
318 | 318 | ||
319 | KAsync::Job<void> ResourceAccess::sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer) | 319 | KAsync::Job<void> ResourceAccess::sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer) |
@@ -324,11 +324,11 @@ KAsync::Job<void> ResourceAccess::sendModifyCommand(const QByteArray &uid, qint6 | |||
324 | auto type = fbb.CreateString(resourceBufferType.constData()); | 324 | auto type = fbb.CreateString(resourceBufferType.constData()); |
325 | //FIXME | 325 | //FIXME |
326 | auto deletions = 0; | 326 | auto deletions = 0; |
327 | auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size()); | 327 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size()); |
328 | auto location = Akonadi2::Commands::CreateModifyEntity(fbb, revision, entityId, deletions, type, delta); | 328 | auto location = Sink::Commands::CreateModifyEntity(fbb, revision, entityId, deletions, type, delta); |
329 | Akonadi2::Commands::FinishModifyEntityBuffer(fbb, location); | 329 | Sink::Commands::FinishModifyEntityBuffer(fbb, location); |
330 | open(); | 330 | open(); |
331 | return sendCommand(Akonadi2::Commands::ModifyEntityCommand, fbb); | 331 | return sendCommand(Sink::Commands::ModifyEntityCommand, fbb); |
332 | } | 332 | } |
333 | 333 | ||
334 | KAsync::Job<void> ResourceAccess::sendDeleteCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType) | 334 | KAsync::Job<void> ResourceAccess::sendDeleteCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType) |
@@ -337,19 +337,19 @@ KAsync::Job<void> ResourceAccess::sendDeleteCommand(const QByteArray &uid, qint6 | |||
337 | auto entityId = fbb.CreateString(uid.constData()); | 337 | auto entityId = fbb.CreateString(uid.constData()); |
338 | //This is the resource buffer type and not the domain type | 338 | //This is the resource buffer type and not the domain type |
339 | auto type = fbb.CreateString(resourceBufferType.constData()); | 339 | auto type = fbb.CreateString(resourceBufferType.constData()); |
340 | auto location = Akonadi2::Commands::CreateDeleteEntity(fbb, revision, entityId, type); | 340 | auto location = Sink::Commands::CreateDeleteEntity(fbb, revision, entityId, type); |
341 | Akonadi2::Commands::FinishDeleteEntityBuffer(fbb, location); | 341 | Sink::Commands::FinishDeleteEntityBuffer(fbb, location); |
342 | open(); | 342 | open(); |
343 | return sendCommand(Akonadi2::Commands::DeleteEntityCommand, fbb); | 343 | return sendCommand(Sink::Commands::DeleteEntityCommand, fbb); |
344 | } | 344 | } |
345 | 345 | ||
346 | KAsync::Job<void> ResourceAccess::sendRevisionReplayedCommand(qint64 revision) | 346 | KAsync::Job<void> ResourceAccess::sendRevisionReplayedCommand(qint64 revision) |
347 | { | 347 | { |
348 | flatbuffers::FlatBufferBuilder fbb; | 348 | flatbuffers::FlatBufferBuilder fbb; |
349 | auto location = Akonadi2::Commands::CreateRevisionReplayed(fbb, revision); | 349 | auto location = Sink::Commands::CreateRevisionReplayed(fbb, revision); |
350 | Akonadi2::Commands::FinishRevisionReplayedBuffer(fbb, location); | 350 | Sink::Commands::FinishRevisionReplayedBuffer(fbb, location); |
351 | open(); | 351 | open(); |
352 | return sendCommand(Akonadi2::Commands::RevisionReplayedCommand, fbb); | 352 | return sendCommand(Sink::Commands::RevisionReplayedCommand, fbb); |
353 | } | 353 | } |
354 | 354 | ||
355 | KAsync::Job<void> ResourceAccess::sendInspectionCommand(const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) | 355 | KAsync::Job<void> ResourceAccess::sendInspectionCommand(const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) |
@@ -365,10 +365,10 @@ KAsync::Job<void> ResourceAccess::sendInspectionCommand(const QByteArray &inspec | |||
365 | s << expectedValue; | 365 | s << expectedValue; |
366 | 366 | ||
367 | auto expected = fbb.CreateString(array.toStdString()); | 367 | auto expected = fbb.CreateString(array.toStdString()); |
368 | auto location = Akonadi2::Commands::CreateInspection (fbb, id, 0, entity, domain, prop, expected); | 368 | auto location = Sink::Commands::CreateInspection (fbb, id, 0, entity, domain, prop, expected); |
369 | Akonadi2::Commands::FinishInspectionBuffer(fbb, location); | 369 | Sink::Commands::FinishInspectionBuffer(fbb, location); |
370 | open(); | 370 | open(); |
371 | return sendCommand(Akonadi2::Commands::InspectionCommand, fbb); | 371 | return sendCommand(Sink::Commands::InspectionCommand, fbb); |
372 | } | 372 | } |
373 | 373 | ||
374 | void ResourceAccess::open() | 374 | void ResourceAccess::open() |
@@ -412,7 +412,7 @@ void ResourceAccess::sendCommand(const QSharedPointer<QueuedCommand> &command) | |||
412 | //TODO: we should have a timeout for commands | 412 | //TODO: we should have a timeout for commands |
413 | d->messageId++; | 413 | d->messageId++; |
414 | const auto messageId = d->messageId; | 414 | const auto messageId = d->messageId; |
415 | log(QString("Sending command \"%1\" with messageId %2").arg(QString(Akonadi2::Commands::name(command->commandId))).arg(d->messageId)); | 415 | log(QString("Sending command \"%1\" with messageId %2").arg(QString(Sink::Commands::name(command->commandId))).arg(d->messageId)); |
416 | Q_ASSERT(command->callback); | 416 | Q_ASSERT(command->callback); |
417 | registerCallback(d->messageId, [this, messageId, command](int errorCode, QString errorMessage) { | 417 | registerCallback(d->messageId, [this, messageId, command](int errorCode, QString errorMessage) { |
418 | Trace() << "Command complete " << messageId; | 418 | Trace() << "Command complete " << messageId; |
@@ -457,8 +457,8 @@ void ResourceAccess::connected() | |||
457 | { | 457 | { |
458 | flatbuffers::FlatBufferBuilder fbb; | 458 | flatbuffers::FlatBufferBuilder fbb; |
459 | auto name = fbb.CreateString(QString("PID: %1 ResourceAccess: %2").arg(QCoreApplication::applicationPid()).arg(reinterpret_cast<qlonglong>(this)).toLatin1()); | 459 | auto name = fbb.CreateString(QString("PID: %1 ResourceAccess: %2").arg(QCoreApplication::applicationPid()).arg(reinterpret_cast<qlonglong>(this)).toLatin1()); |
460 | auto command = Akonadi2::Commands::CreateHandshake(fbb, name); | 460 | auto command = Sink::Commands::CreateHandshake(fbb, name); |
461 | Akonadi2::Commands::FinishHandshakeBuffer(fbb, command); | 461 | Sink::Commands::FinishHandshakeBuffer(fbb, command); |
462 | Commands::write(d->socket.data(), ++d->messageId, Commands::HandshakeCommand, fbb); | 462 | Commands::write(d->socket.data(), ++d->messageId, Commands::HandshakeCommand, fbb); |
463 | } | 463 | } |
464 | 464 | ||
@@ -543,11 +543,11 @@ bool ResourceAccess::processMessageBuffer() | |||
543 | case Commands::NotificationCommand: { | 543 | case Commands::NotificationCommand: { |
544 | auto buffer = Commands::GetNotification(d->partialMessageBuffer.constData() + headerSize); | 544 | auto buffer = Commands::GetNotification(d->partialMessageBuffer.constData() + headerSize); |
545 | switch (buffer->type()) { | 545 | switch (buffer->type()) { |
546 | case Akonadi2::Commands::NotificationType::NotificationType_Shutdown: | 546 | case Sink::Commands::NotificationType::NotificationType_Shutdown: |
547 | Log(d->resourceInstanceIdentifier) << "Received shutdown notification."; | 547 | Log(d->resourceInstanceIdentifier) << "Received shutdown notification."; |
548 | close(); | 548 | close(); |
549 | break; | 549 | break; |
550 | case Akonadi2::Commands::NotificationType::NotificationType_Inspection: { | 550 | case Sink::Commands::NotificationType::NotificationType_Inspection: { |
551 | Log(d->resourceInstanceIdentifier) << "Received inspection notification."; | 551 | Log(d->resourceInstanceIdentifier) << "Received inspection notification."; |
552 | Notification n; | 552 | Notification n; |
553 | if (buffer->identifier()) { | 553 | if (buffer->identifier()) { |
diff --git a/common/resourceaccess.h b/common/resourceaccess.h index 2fe83ed..73b676b 100644 --- a/common/resourceaccess.h +++ b/common/resourceaccess.h | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <flatbuffers/flatbuffers.h> | 29 | #include <flatbuffers/flatbuffers.h> |
30 | #include "notification.h" | 30 | #include "notification.h" |
31 | 31 | ||
32 | namespace Akonadi2 | 32 | namespace Sink |
33 | { | 33 | { |
34 | 34 | ||
35 | struct QueuedCommand; | 35 | struct QueuedCommand; |
diff --git a/common/resourceconfig.cpp b/common/resourceconfig.cpp index a0f39a8..a34340b 100644 --- a/common/resourceconfig.cpp +++ b/common/resourceconfig.cpp | |||
@@ -25,12 +25,12 @@ | |||
25 | 25 | ||
26 | static QSharedPointer<QSettings> getSettings() | 26 | static QSharedPointer<QSettings> getSettings() |
27 | { | 27 | { |
28 | return QSharedPointer<QSettings>::create(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/resources.ini", QSettings::IniFormat); | 28 | return QSharedPointer<QSettings>::create(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/resources.ini", QSettings::IniFormat); |
29 | } | 29 | } |
30 | 30 | ||
31 | static QSharedPointer<QSettings> getResourceConfig(const QByteArray &identifier) | 31 | static QSharedPointer<QSettings> getResourceConfig(const QByteArray &identifier) |
32 | { | 32 | { |
33 | return QSharedPointer<QSettings>::create(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/" + identifier, QSettings::IniFormat); | 33 | return QSharedPointer<QSettings>::create(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/sink/" + identifier, QSettings::IniFormat); |
34 | } | 34 | } |
35 | 35 | ||
36 | QByteArray ResourceConfig::newIdentifier(const QByteArray &type) | 36 | QByteArray ResourceConfig::newIdentifier(const QByteArray &type) |
diff --git a/common/resourcefacade.cpp b/common/resourcefacade.cpp index 20d9a7c..414e390 100644 --- a/common/resourcefacade.cpp +++ b/common/resourcefacade.cpp | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <QDir> | 25 | #include <QDir> |
26 | 26 | ||
27 | ResourceFacade::ResourceFacade(const QByteArray &) | 27 | ResourceFacade::ResourceFacade(const QByteArray &) |
28 | : Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource>() | 28 | : Sink::StoreFacade<Sink::ApplicationDomain::SinkResource>() |
29 | { | 29 | { |
30 | 30 | ||
31 | } | 31 | } |
@@ -35,7 +35,7 @@ ResourceFacade::~ResourceFacade() | |||
35 | 35 | ||
36 | } | 36 | } |
37 | 37 | ||
38 | KAsync::Job<void> ResourceFacade::create(const Akonadi2::ApplicationDomain::AkonadiResource &resource) | 38 | KAsync::Job<void> ResourceFacade::create(const Sink::ApplicationDomain::SinkResource &resource) |
39 | { | 39 | { |
40 | return KAsync::start<void>([resource, this]() { | 40 | return KAsync::start<void>([resource, this]() { |
41 | const QByteArray type = resource.getProperty("type").toByteArray(); | 41 | const QByteArray type = resource.getProperty("type").toByteArray(); |
@@ -57,7 +57,7 @@ KAsync::Job<void> ResourceFacade::create(const Akonadi2::ApplicationDomain::Akon | |||
57 | }); | 57 | }); |
58 | } | 58 | } |
59 | 59 | ||
60 | KAsync::Job<void> ResourceFacade::modify(const Akonadi2::ApplicationDomain::AkonadiResource &resource) | 60 | KAsync::Job<void> ResourceFacade::modify(const Sink::ApplicationDomain::SinkResource &resource) |
61 | { | 61 | { |
62 | return KAsync::start<void>([resource, this]() { | 62 | return KAsync::start<void>([resource, this]() { |
63 | const QByteArray identifier = resource.identifier(); | 63 | const QByteArray identifier = resource.identifier(); |
@@ -79,7 +79,7 @@ KAsync::Job<void> ResourceFacade::modify(const Akonadi2::ApplicationDomain::Akon | |||
79 | }); | 79 | }); |
80 | } | 80 | } |
81 | 81 | ||
82 | KAsync::Job<void> ResourceFacade::remove(const Akonadi2::ApplicationDomain::AkonadiResource &resource) | 82 | KAsync::Job<void> ResourceFacade::remove(const Sink::ApplicationDomain::SinkResource &resource) |
83 | { | 83 | { |
84 | return KAsync::start<void>([resource, this]() { | 84 | return KAsync::start<void>([resource, this]() { |
85 | const QByteArray identifier = resource.identifier(); | 85 | const QByteArray identifier = resource.identifier(); |
@@ -89,18 +89,18 @@ KAsync::Job<void> ResourceFacade::remove(const Akonadi2::ApplicationDomain::Akon | |||
89 | } | 89 | } |
90 | ResourceConfig::removeResource(identifier); | 90 | ResourceConfig::removeResource(identifier); |
91 | //TODO shutdown resource, or use the resource process with a --remove option to cleanup (so we can take advantage of the file locking) | 91 | //TODO shutdown resource, or use the resource process with a --remove option to cleanup (so we can take advantage of the file locking) |
92 | QDir dir(Akonadi2::storageLocation()); | 92 | QDir dir(Sink::storageLocation()); |
93 | for (const auto &folder : dir.entryList(QStringList() << identifier + "*")) { | 93 | for (const auto &folder : dir.entryList(QStringList() << identifier + "*")) { |
94 | Akonadi2::Storage(Akonadi2::storageLocation(), folder, Akonadi2::Storage::ReadWrite).removeFromDisk(); | 94 | Sink::Storage(Sink::storageLocation(), folder, Sink::Storage::ReadWrite).removeFromDisk(); |
95 | } | 95 | } |
96 | }); | 96 | }); |
97 | } | 97 | } |
98 | 98 | ||
99 | QPair<KAsync::Job<void>, typename Akonadi2::ResultEmitter<Akonadi2::ApplicationDomain::AkonadiResource::Ptr>::Ptr > ResourceFacade::load(const Akonadi2::Query &query) | 99 | QPair<KAsync::Job<void>, typename Sink::ResultEmitter<Sink::ApplicationDomain::SinkResource::Ptr>::Ptr > ResourceFacade::load(const Sink::Query &query) |
100 | { | 100 | { |
101 | auto resultProvider = new Akonadi2::ResultProvider<typename Akonadi2::ApplicationDomain::AkonadiResource::Ptr>(); | 101 | auto resultProvider = new Sink::ResultProvider<typename Sink::ApplicationDomain::SinkResource::Ptr>(); |
102 | auto emitter = resultProvider->emitter(); | 102 | auto emitter = resultProvider->emitter(); |
103 | resultProvider->setFetcher([](const QSharedPointer<Akonadi2::ApplicationDomain::AkonadiResource> &) {}); | 103 | resultProvider->setFetcher([](const QSharedPointer<Sink::ApplicationDomain::SinkResource> &) {}); |
104 | resultProvider->onDone([resultProvider]() { | 104 | resultProvider->onDone([resultProvider]() { |
105 | delete resultProvider; | 105 | delete resultProvider; |
106 | }); | 106 | }); |
@@ -109,13 +109,13 @@ QPair<KAsync::Job<void>, typename Akonadi2::ResultEmitter<Akonadi2::ApplicationD | |||
109 | for (const auto &res : configuredResources.keys()) { | 109 | for (const auto &res : configuredResources.keys()) { |
110 | const auto type = configuredResources.value(res); | 110 | const auto type = configuredResources.value(res); |
111 | if (!query.propertyFilter.contains("type") || query.propertyFilter.value("type").toByteArray() == type) { | 111 | if (!query.propertyFilter.contains("type") || query.propertyFilter.value("type").toByteArray() == type) { |
112 | auto resource = Akonadi2::ApplicationDomain::AkonadiResource::Ptr::create("", res, 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 112 | auto resource = Sink::ApplicationDomain::SinkResource::Ptr::create("", res, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
113 | resource->setProperty("type", type); | 113 | resource->setProperty("type", type); |
114 | resultProvider->add(resource); | 114 | resultProvider->add(resource); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | //TODO initialResultSetComplete should be implicit | 117 | //TODO initialResultSetComplete should be implicit |
118 | resultProvider->initialResultSetComplete(Akonadi2::ApplicationDomain::AkonadiResource::Ptr()); | 118 | resultProvider->initialResultSetComplete(Sink::ApplicationDomain::SinkResource::Ptr()); |
119 | resultProvider->complete(); | 119 | resultProvider->complete(); |
120 | }); | 120 | }); |
121 | return qMakePair(job, emitter); | 121 | return qMakePair(job, emitter); |
diff --git a/common/resourcefacade.h b/common/resourcefacade.h index 99ec632..5ddaa79 100644 --- a/common/resourcefacade.h +++ b/common/resourcefacade.h | |||
@@ -25,19 +25,19 @@ | |||
25 | #include "common/resultprovider.h" | 25 | #include "common/resultprovider.h" |
26 | #include "common/domain/applicationdomaintype.h" | 26 | #include "common/domain/applicationdomaintype.h" |
27 | 27 | ||
28 | namespace Akonadi2 { | 28 | namespace Sink { |
29 | class Query; | 29 | class Query; |
30 | class Inspection; | 30 | class Inspection; |
31 | } | 31 | } |
32 | 32 | ||
33 | class ResourceFacade : public Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource> | 33 | class ResourceFacade : public Sink::StoreFacade<Sink::ApplicationDomain::SinkResource> |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | ResourceFacade(const QByteArray &instanceIdentifier); | 36 | ResourceFacade(const QByteArray &instanceIdentifier); |
37 | virtual ~ResourceFacade(); | 37 | virtual ~ResourceFacade(); |
38 | KAsync::Job<void> create(const Akonadi2::ApplicationDomain::AkonadiResource &resource) Q_DECL_OVERRIDE; | 38 | KAsync::Job<void> create(const Sink::ApplicationDomain::SinkResource &resource) Q_DECL_OVERRIDE; |
39 | KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::AkonadiResource &resource) Q_DECL_OVERRIDE; | 39 | KAsync::Job<void> modify(const Sink::ApplicationDomain::SinkResource &resource) Q_DECL_OVERRIDE; |
40 | KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::AkonadiResource &resource) Q_DECL_OVERRIDE; | 40 | KAsync::Job<void> remove(const Sink::ApplicationDomain::SinkResource &resource) Q_DECL_OVERRIDE; |
41 | QPair<KAsync::Job<void>, typename Akonadi2::ResultEmitter<Akonadi2::ApplicationDomain::AkonadiResource::Ptr>::Ptr > load(const Akonadi2::Query &query) Q_DECL_OVERRIDE; | 41 | QPair<KAsync::Job<void>, typename Sink::ResultEmitter<Sink::ApplicationDomain::SinkResource::Ptr>::Ptr > load(const Sink::Query &query) Q_DECL_OVERRIDE; |
42 | }; | 42 | }; |
43 | 43 | ||
diff --git a/common/resultprovider.h b/common/resultprovider.h index a064ab5..6958dbf 100644 --- a/common/resultprovider.h +++ b/common/resultprovider.h | |||
@@ -29,7 +29,7 @@ | |||
29 | 29 | ||
30 | using namespace async; | 30 | using namespace async; |
31 | 31 | ||
32 | namespace Akonadi2 { | 32 | namespace Sink { |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Query result set | 35 | * Query result set |
diff --git a/common/resultset.h b/common/resultset.h index 746b94b..ec399fc 100644 --- a/common/resultset.h +++ b/common/resultset.h | |||
@@ -37,7 +37,7 @@ class ResultSet { | |||
37 | 37 | ||
38 | } | 38 | } |
39 | 39 | ||
40 | ResultSet(const std::function<bool(std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)>)> &generator) | 40 | ResultSet(const std::function<bool(std::function<void(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &, Sink::Operation)>)> &generator) |
41 | : mIt(nullptr), | 41 | : mIt(nullptr), |
42 | mValueGenerator(generator) | 42 | mValueGenerator(generator) |
43 | { | 43 | { |
@@ -76,7 +76,7 @@ class ResultSet { | |||
76 | return false; | 76 | return false; |
77 | } | 77 | } |
78 | 78 | ||
79 | bool next(std::function<bool(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &value, Akonadi2::Operation)> callback) | 79 | bool next(std::function<bool(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &value, Sink::Operation)> callback) |
80 | { | 80 | { |
81 | Q_ASSERT(mValueGenerator); | 81 | Q_ASSERT(mValueGenerator); |
82 | return mValueGenerator(callback); | 82 | return mValueGenerator(callback); |
@@ -116,6 +116,6 @@ class ResultSet { | |||
116 | QVector<QByteArray>::ConstIterator mIt; | 116 | QVector<QByteArray>::ConstIterator mIt; |
117 | QByteArray mCurrentValue; | 117 | QByteArray mCurrentValue; |
118 | std::function<QByteArray()> mGenerator; | 118 | std::function<QByteArray()> mGenerator; |
119 | std::function<bool(std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)>)> mValueGenerator; | 119 | std::function<bool(std::function<void(const Sink::ApplicationDomain::ApplicationDomainType::Ptr &, Sink::Operation)>)> mValueGenerator; |
120 | }; | 120 | }; |
121 | 121 | ||
diff --git a/common/storage.h b/common/storage.h index daeace8..2d34f1f 100644 --- a/common/storage.h +++ b/common/storage.h | |||
@@ -21,15 +21,15 @@ | |||
21 | 21 | ||
22 | #pragma once | 22 | #pragma once |
23 | 23 | ||
24 | #include <akonadi2common_export.h> | 24 | #include <sinkcommon_export.h> |
25 | #include <string> | 25 | #include <string> |
26 | #include <functional> | 26 | #include <functional> |
27 | #include <QString> | 27 | #include <QString> |
28 | 28 | ||
29 | namespace Akonadi2 | 29 | namespace Sink |
30 | { | 30 | { |
31 | 31 | ||
32 | class AKONADI2COMMON_EXPORT Storage { | 32 | class SINKCOMMON_EXPORT Storage { |
33 | public: | 33 | public: |
34 | enum AccessMode { ReadOnly, ReadWrite }; | 34 | enum AccessMode { ReadOnly, ReadWrite }; |
35 | 35 | ||
@@ -180,16 +180,16 @@ public: | |||
180 | qint64 diskUsage() const; | 180 | qint64 diskUsage() const; |
181 | void removeFromDisk() const; | 181 | void removeFromDisk() const; |
182 | 182 | ||
183 | static qint64 maxRevision(const Akonadi2::Storage::Transaction &); | 183 | static qint64 maxRevision(const Sink::Storage::Transaction &); |
184 | static void setMaxRevision(Akonadi2::Storage::Transaction &, qint64 revision); | 184 | static void setMaxRevision(Sink::Storage::Transaction &, qint64 revision); |
185 | 185 | ||
186 | static qint64 cleanedUpRevision(const Akonadi2::Storage::Transaction &); | 186 | static qint64 cleanedUpRevision(const Sink::Storage::Transaction &); |
187 | static void setCleanedUpRevision(Akonadi2::Storage::Transaction &, qint64 revision); | 187 | static void setCleanedUpRevision(Sink::Storage::Transaction &, qint64 revision); |
188 | 188 | ||
189 | static QByteArray getUidFromRevision(const Akonadi2::Storage::Transaction &, qint64 revision); | 189 | static QByteArray getUidFromRevision(const Sink::Storage::Transaction &, qint64 revision); |
190 | static QByteArray getTypeFromRevision(const Akonadi2::Storage::Transaction &, qint64 revision); | 190 | static QByteArray getTypeFromRevision(const Sink::Storage::Transaction &, qint64 revision); |
191 | static void recordRevision(Akonadi2::Storage::Transaction &, qint64 revision, const QByteArray &uid, const QByteArray &type); | 191 | static void recordRevision(Sink::Storage::Transaction &, qint64 revision, const QByteArray &uid, const QByteArray &type); |
192 | static void removeRevision(Akonadi2::Storage::Transaction &, qint64 revision); | 192 | static void removeRevision(Sink::Storage::Transaction &, qint64 revision); |
193 | 193 | ||
194 | bool exists() const; | 194 | bool exists() const; |
195 | 195 | ||
@@ -208,5 +208,5 @@ private: | |||
208 | Private * const d; | 208 | Private * const d; |
209 | }; | 209 | }; |
210 | 210 | ||
211 | } // namespace Akonadi2 | 211 | } // namespace Sink |
212 | 212 | ||
diff --git a/common/storage_common.cpp b/common/storage_common.cpp index e534bc1..ea97ac2 100644 --- a/common/storage_common.cpp +++ b/common/storage_common.cpp | |||
@@ -23,7 +23,7 @@ | |||
23 | 23 | ||
24 | #include "log.h" | 24 | #include "log.h" |
25 | 25 | ||
26 | namespace Akonadi2 | 26 | namespace Sink |
27 | { | 27 | { |
28 | 28 | ||
29 | static const char *s_internalPrefix = "__internal"; | 29 | static const char *s_internalPrefix = "__internal"; |
@@ -52,45 +52,45 @@ std::function<void(const Storage::Error &error)> Storage::defaultErrorHandler() | |||
52 | return basicErrorHandler(); | 52 | return basicErrorHandler(); |
53 | } | 53 | } |
54 | 54 | ||
55 | void Storage::setMaxRevision(Akonadi2::Storage::Transaction &transaction, qint64 revision) | 55 | void Storage::setMaxRevision(Sink::Storage::Transaction &transaction, qint64 revision) |
56 | { | 56 | { |
57 | transaction.openDatabase().write("__internal_maxRevision", QByteArray::number(revision)); | 57 | transaction.openDatabase().write("__internal_maxRevision", QByteArray::number(revision)); |
58 | } | 58 | } |
59 | 59 | ||
60 | qint64 Storage::maxRevision(const Akonadi2::Storage::Transaction &transaction) | 60 | qint64 Storage::maxRevision(const Sink::Storage::Transaction &transaction) |
61 | { | 61 | { |
62 | qint64 r = 0; | 62 | qint64 r = 0; |
63 | transaction.openDatabase().scan("__internal_maxRevision", [&](const QByteArray &, const QByteArray &revision) -> bool { | 63 | transaction.openDatabase().scan("__internal_maxRevision", [&](const QByteArray &, const QByteArray &revision) -> bool { |
64 | r = revision.toLongLong(); | 64 | r = revision.toLongLong(); |
65 | return false; | 65 | return false; |
66 | }, [](const Error &error){ | 66 | }, [](const Error &error){ |
67 | if (error.code != Akonadi2::Storage::NotFound) { | 67 | if (error.code != Sink::Storage::NotFound) { |
68 | Warning() << "Coultn'd find the maximum revision."; | 68 | Warning() << "Coultn'd find the maximum revision."; |
69 | } | 69 | } |
70 | }); | 70 | }); |
71 | return r; | 71 | return r; |
72 | } | 72 | } |
73 | 73 | ||
74 | void Storage::setCleanedUpRevision(Akonadi2::Storage::Transaction &transaction, qint64 revision) | 74 | void Storage::setCleanedUpRevision(Sink::Storage::Transaction &transaction, qint64 revision) |
75 | { | 75 | { |
76 | transaction.openDatabase().write("__internal_cleanedUpRevision", QByteArray::number(revision)); | 76 | transaction.openDatabase().write("__internal_cleanedUpRevision", QByteArray::number(revision)); |
77 | } | 77 | } |
78 | 78 | ||
79 | qint64 Storage::cleanedUpRevision(const Akonadi2::Storage::Transaction &transaction) | 79 | qint64 Storage::cleanedUpRevision(const Sink::Storage::Transaction &transaction) |
80 | { | 80 | { |
81 | qint64 r = 0; | 81 | qint64 r = 0; |
82 | transaction.openDatabase().scan("__internal_cleanedUpRevision", [&](const QByteArray &, const QByteArray &revision) -> bool { | 82 | transaction.openDatabase().scan("__internal_cleanedUpRevision", [&](const QByteArray &, const QByteArray &revision) -> bool { |
83 | r = revision.toLongLong(); | 83 | r = revision.toLongLong(); |
84 | return false; | 84 | return false; |
85 | }, [](const Error &error){ | 85 | }, [](const Error &error){ |
86 | if (error.code != Akonadi2::Storage::NotFound) { | 86 | if (error.code != Sink::Storage::NotFound) { |
87 | Warning() << "Coultn'd find the maximum revision."; | 87 | Warning() << "Coultn'd find the maximum revision."; |
88 | } | 88 | } |
89 | }); | 89 | }); |
90 | return r; | 90 | return r; |
91 | } | 91 | } |
92 | 92 | ||
93 | QByteArray Storage::getUidFromRevision(const Akonadi2::Storage::Transaction &transaction, qint64 revision) | 93 | QByteArray Storage::getUidFromRevision(const Sink::Storage::Transaction &transaction, qint64 revision) |
94 | { | 94 | { |
95 | QByteArray uid; | 95 | QByteArray uid; |
96 | transaction.openDatabase("revisions").scan(QByteArray::number(revision), [&](const QByteArray &, const QByteArray &value) -> bool { | 96 | transaction.openDatabase("revisions").scan(QByteArray::number(revision), [&](const QByteArray &, const QByteArray &value) -> bool { |
@@ -102,7 +102,7 @@ QByteArray Storage::getUidFromRevision(const Akonadi2::Storage::Transaction &tra | |||
102 | return uid; | 102 | return uid; |
103 | } | 103 | } |
104 | 104 | ||
105 | QByteArray Storage::getTypeFromRevision(const Akonadi2::Storage::Transaction &transaction, qint64 revision) | 105 | QByteArray Storage::getTypeFromRevision(const Sink::Storage::Transaction &transaction, qint64 revision) |
106 | { | 106 | { |
107 | QByteArray type; | 107 | QByteArray type; |
108 | transaction.openDatabase("revisionType").scan(QByteArray::number(revision), [&](const QByteArray &, const QByteArray &value) -> bool { | 108 | transaction.openDatabase("revisionType").scan(QByteArray::number(revision), [&](const QByteArray &, const QByteArray &value) -> bool { |
@@ -114,14 +114,14 @@ QByteArray Storage::getTypeFromRevision(const Akonadi2::Storage::Transaction &tr | |||
114 | return type; | 114 | return type; |
115 | } | 115 | } |
116 | 116 | ||
117 | void Storage::recordRevision(Akonadi2::Storage::Transaction &transaction, qint64 revision, const QByteArray &uid, const QByteArray &type) | 117 | void Storage::recordRevision(Sink::Storage::Transaction &transaction, qint64 revision, const QByteArray &uid, const QByteArray &type) |
118 | { | 118 | { |
119 | //TODO use integerkeys | 119 | //TODO use integerkeys |
120 | transaction.openDatabase("revisions").write(QByteArray::number(revision), uid); | 120 | transaction.openDatabase("revisions").write(QByteArray::number(revision), uid); |
121 | transaction.openDatabase("revisionType").write(QByteArray::number(revision), type); | 121 | transaction.openDatabase("revisionType").write(QByteArray::number(revision), type); |
122 | } | 122 | } |
123 | 123 | ||
124 | void Storage::removeRevision(Akonadi2::Storage::Transaction &transaction, qint64 revision) | 124 | void Storage::removeRevision(Sink::Storage::Transaction &transaction, qint64 revision) |
125 | { | 125 | { |
126 | transaction.openDatabase("revisions").remove(QByteArray::number(revision)); | 126 | transaction.openDatabase("revisions").remove(QByteArray::number(revision)); |
127 | } | 127 | } |
@@ -162,9 +162,9 @@ bool Storage::NamedDatabase::contains(const QByteArray &uid) | |||
162 | scan(uid, [&found](const QByteArray &, const QByteArray &) -> bool { | 162 | scan(uid, [&found](const QByteArray &, const QByteArray &) -> bool { |
163 | found = true; | 163 | found = true; |
164 | return false; | 164 | return false; |
165 | }, [this](const Akonadi2::Storage::Error &error) { | 165 | }, [this](const Sink::Storage::Error &error) { |
166 | }, true); | 166 | }, true); |
167 | return found; | 167 | return found; |
168 | } | 168 | } |
169 | 169 | ||
170 | } // namespace Akonadi2 | 170 | } // namespace Sink |
diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp index 79f32ba..6539eb0 100644 --- a/common/storage_lmdb.cpp +++ b/common/storage_lmdb.cpp | |||
@@ -33,7 +33,7 @@ | |||
33 | 33 | ||
34 | #include <lmdb.h> | 34 | #include <lmdb.h> |
35 | 35 | ||
36 | namespace Akonadi2 | 36 | namespace Sink |
37 | { | 37 | { |
38 | 38 | ||
39 | int getErrorCode(int e) | 39 | int getErrorCode(int e) |
@@ -615,4 +615,4 @@ void Storage::removeFromDisk() const | |||
615 | mdb_env_close(env); | 615 | mdb_env_close(env); |
616 | } | 616 | } |
617 | 617 | ||
618 | } // namespace Akonadi2 | 618 | } // namespace Sink |
diff --git a/common/synclistresult.h b/common/synclistresult.h index 3ae2bed..055714f 100644 --- a/common/synclistresult.h +++ b/common/synclistresult.h | |||
@@ -19,7 +19,7 @@ namespace async { | |||
19 | template<class T> | 19 | template<class T> |
20 | class SyncListResult : public QList<T> { | 20 | class SyncListResult : public QList<T> { |
21 | public: | 21 | public: |
22 | SyncListResult(const QSharedPointer<Akonadi2::ResultEmitter<T> > &emitter) | 22 | SyncListResult(const QSharedPointer<Sink::ResultEmitter<T> > &emitter) |
23 | :QList<T>(), | 23 | :QList<T>(), |
24 | mEmitter(emitter) | 24 | mEmitter(emitter) |
25 | { | 25 | { |
@@ -66,7 +66,7 @@ public: | |||
66 | } | 66 | } |
67 | 67 | ||
68 | private: | 68 | private: |
69 | QSharedPointer<Akonadi2::ResultEmitter<T> > mEmitter; | 69 | QSharedPointer<Sink::ResultEmitter<T> > mEmitter; |
70 | std::function<void()> eventLoopAborter; | 70 | std::function<void()> eventLoopAborter; |
71 | }; | 71 | }; |
72 | 72 | ||
diff --git a/common/typeindex.cpp b/common/typeindex.cpp index 19e0507..03ad8f7 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp | |||
@@ -31,7 +31,7 @@ TypeIndex::TypeIndex(const QByteArray &type) | |||
31 | template<> | 31 | template<> |
32 | void TypeIndex::addProperty<QByteArray>(const QByteArray &property) | 32 | void TypeIndex::addProperty<QByteArray>(const QByteArray &property) |
33 | { | 33 | { |
34 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Akonadi2::Storage::Transaction &transaction) { | 34 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { |
35 | // Trace() << "Indexing " << mType + ".index." + property << value.toByteArray(); | 35 | // Trace() << "Indexing " << mType + ".index." + property << value.toByteArray(); |
36 | if (value.isValid()) { | 36 | if (value.isValid()) { |
37 | Index(mType + ".index." + property, transaction).add(value.toByteArray(), identifier); | 37 | Index(mType + ".index." + property, transaction).add(value.toByteArray(), identifier); |
@@ -46,7 +46,7 @@ void TypeIndex::addProperty<QByteArray>(const QByteArray &property) | |||
46 | template<> | 46 | template<> |
47 | void TypeIndex::addProperty<QString>(const QByteArray &property) | 47 | void TypeIndex::addProperty<QString>(const QByteArray &property) |
48 | { | 48 | { |
49 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Akonadi2::Storage::Transaction &transaction) { | 49 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { |
50 | // Trace() << "Indexing " << mType + ".index." + property << value.toByteArray(); | 50 | // Trace() << "Indexing " << mType + ".index." + property << value.toByteArray(); |
51 | if (value.isValid()) { | 51 | if (value.isValid()) { |
52 | Index(mType + ".index." + property, transaction).add(value.toByteArray(), identifier); | 52 | Index(mType + ".index." + property, transaction).add(value.toByteArray(), identifier); |
@@ -61,7 +61,7 @@ void TypeIndex::addProperty<QString>(const QByteArray &property) | |||
61 | template<> | 61 | template<> |
62 | void TypeIndex::addProperty<QDateTime>(const QByteArray &property) | 62 | void TypeIndex::addProperty<QDateTime>(const QByteArray &property) |
63 | { | 63 | { |
64 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Akonadi2::Storage::Transaction &transaction) { | 64 | auto indexer = [this, property](const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction) { |
65 | const auto date = value.toDateTime(); | 65 | const auto date = value.toDateTime(); |
66 | // Trace() << "Indexing " << mType + ".index." + property << date.toString(); | 66 | // Trace() << "Indexing " << mType + ".index." + property << date.toString(); |
67 | if (date.isValid()) { | 67 | if (date.isValid()) { |
@@ -72,7 +72,7 @@ void TypeIndex::addProperty<QDateTime>(const QByteArray &property) | |||
72 | mProperties << property; | 72 | mProperties << property; |
73 | } | 73 | } |
74 | 74 | ||
75 | void TypeIndex::add(const QByteArray &identifier, const Akonadi2::ApplicationDomain::BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | 75 | void TypeIndex::add(const QByteArray &identifier, const Sink::ApplicationDomain::BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction) |
76 | { | 76 | { |
77 | for (const auto &property : mProperties) { | 77 | for (const auto &property : mProperties) { |
78 | const auto value = bufferAdaptor.getProperty(property); | 78 | const auto value = bufferAdaptor.getProperty(property); |
@@ -81,7 +81,7 @@ void TypeIndex::add(const QByteArray &identifier, const Akonadi2::ApplicationDom | |||
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | void TypeIndex::remove(const QByteArray &identifier, const Akonadi2::ApplicationDomain::BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction) | 84 | void TypeIndex::remove(const QByteArray &identifier, const Sink::ApplicationDomain::BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction) |
85 | { | 85 | { |
86 | for (const auto &property : mProperties) { | 86 | for (const auto &property : mProperties) { |
87 | const auto value = bufferAdaptor.getProperty(property); | 87 | const auto value = bufferAdaptor.getProperty(property); |
@@ -94,7 +94,7 @@ void TypeIndex::remove(const QByteArray &identifier, const Akonadi2::Application | |||
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | ResultSet TypeIndex::query(const Akonadi2::Query &query, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction) | 97 | ResultSet TypeIndex::query(const Sink::Query &query, QSet<QByteArray> &appliedFilters, Sink::Storage::Transaction &transaction) |
98 | { | 98 | { |
99 | QVector<QByteArray> keys; | 99 | QVector<QByteArray> keys; |
100 | for (const auto &property : mProperties) { | 100 | for (const auto &property : mProperties) { |
diff --git a/common/typeindex.h b/common/typeindex.h index fb66c2c..b8a6e39 100644 --- a/common/typeindex.h +++ b/common/typeindex.h | |||
@@ -32,14 +32,14 @@ public: | |||
32 | template<typename T> | 32 | template<typename T> |
33 | void addProperty(const QByteArray &property); | 33 | void addProperty(const QByteArray &property); |
34 | 34 | ||
35 | void add(const QByteArray &identifier, const Akonadi2::ApplicationDomain::BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | 35 | void add(const QByteArray &identifier, const Sink::ApplicationDomain::BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction); |
36 | void remove(const QByteArray &identifier, const Akonadi2::ApplicationDomain::BufferAdaptor &bufferAdaptor, Akonadi2::Storage::Transaction &transaction); | 36 | void remove(const QByteArray &identifier, const Sink::ApplicationDomain::BufferAdaptor &bufferAdaptor, Sink::Storage::Transaction &transaction); |
37 | 37 | ||
38 | ResultSet query(const Akonadi2::Query &query, QSet<QByteArray> &appliedFilters, Akonadi2::Storage::Transaction &transaction); | 38 | ResultSet query(const Sink::Query &query, QSet<QByteArray> &appliedFilters, Sink::Storage::Transaction &transaction); |
39 | 39 | ||
40 | private: | 40 | private: |
41 | QByteArray mType; | 41 | QByteArray mType; |
42 | QByteArrayList mProperties; | 42 | QByteArrayList mProperties; |
43 | QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, Akonadi2::Storage::Transaction &transaction)> > mIndexer; | 43 | QHash<QByteArray, std::function<void(const QByteArray &identifier, const QVariant &value, Sink::Storage::Transaction &transaction)> > mIndexer; |
44 | }; | 44 | }; |
45 | 45 | ||