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 | |
parent | 17e7ee40c9185c0505883853345fd6024c675b1a (diff) | |
download | sink-bdb01c2c068df326f5a8328ed1492ab1bea388c5.tar.gz sink-bdb01c2c068df326f5a8328ed1492ab1bea388c5.zip |
Renamed Akonadi2 to Sink
(except for documentation).
150 files changed, 1594 insertions, 1594 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cbba78..6fa2c09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -50,7 +50,7 @@ configure_file(hawd.conf hawd.conf) | |||
50 | 50 | ||
51 | enable_testing() | 51 | enable_testing() |
52 | 52 | ||
53 | set(AKONADI2_RESOURCE_PLUGINS_PATH ${QT_PLUGIN_INSTALL_DIR}/akonadi2/resources) | 53 | set(SINK_RESOURCE_PLUGINS_PATH ${QT_PLUGIN_INSTALL_DIR}/sink/resources) |
54 | 54 | ||
55 | # common, eventually a lib but right now just the command buffers | 55 | # common, eventually a lib but right now just the command buffers |
56 | add_subdirectory(common) | 56 | add_subdirectory(common) |
@@ -65,6 +65,6 @@ add_subdirectory(examples) | |||
65 | add_subdirectory(tests) | 65 | add_subdirectory(tests) |
66 | 66 | ||
67 | # cli | 67 | # cli |
68 | add_subdirectory(akonadish) | 68 | add_subdirectory(sinksh) |
69 | 69 | ||
70 | feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) | 70 | feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) |
diff --git a/akonadish/CMakeLists.txt b/akonadish/CMakeLists.txt deleted file mode 100644 index eaedf9a..0000000 --- a/akonadish/CMakeLists.txt +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | project(akonadish) | ||
2 | |||
3 | find_package(Readline REQUIRED) | ||
4 | |||
5 | |||
6 | set(akonadi2_cli_SRCS | ||
7 | main.cpp | ||
8 | syntaxtree.cpp | ||
9 | syntax_modules/core_syntax.cpp | ||
10 | syntax_modules/akonadi_list.cpp | ||
11 | syntax_modules/akonadi_clear.cpp | ||
12 | syntax_modules/akonadi_count.cpp | ||
13 | syntax_modules/akonadi_create.cpp | ||
14 | syntax_modules/akonadi_modify.cpp | ||
15 | syntax_modules/akonadi_remove.cpp | ||
16 | syntax_modules/akonadi_stat.cpp | ||
17 | syntax_modules/akonadi_sync.cpp | ||
18 | akonadish_utils.cpp | ||
19 | repl/repl.cpp | ||
20 | repl/replStates.cpp | ||
21 | state.cpp | ||
22 | utils.cpp) | ||
23 | |||
24 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | ||
25 | |||
26 | add_executable(${PROJECT_NAME} ${akonadi2_cli_SRCS}) | ||
27 | target_link_libraries(${PROJECT_NAME} Qt5::Core ${Readline_LIBRARY} akonadi2common) | ||
28 | install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) | ||
29 | |||
diff --git a/akonadish/akonadish_utils.h b/akonadish/akonadish_utils.h deleted file mode 100644 index 5dd24f1..0000000 --- a/akonadish/akonadish_utils.h +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Aaron Seigo <aseigo@kolabsystems.com> | ||
3 | * Copyright (C) 2015 Christian Mollekopf <mollekopf@kolabsystems.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the | ||
17 | * Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #pragma once | ||
22 | |||
23 | #include <QAbstractItemModel> | ||
24 | #include <QSharedPointer> | ||
25 | |||
26 | #include "common/query.h" | ||
27 | #include "common/clientapi.h" | ||
28 | |||
29 | #include "state.h" | ||
30 | |||
31 | namespace AkonadishUtils | ||
32 | { | ||
33 | |||
34 | class StoreBase; | ||
35 | |||
36 | bool isValidStoreType(const QString &type); | ||
37 | StoreBase &getStore(const QString &type); | ||
38 | QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Akonadi2::Query query); | ||
39 | QStringList resourceIds(); | ||
40 | QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state); | ||
41 | QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state); | ||
42 | QStringList typeCompleter(const QStringList &commands, const QString &fragment, State &state); | ||
43 | QMap<QString, QString> keyValueMapFromArgs(const QStringList &args); | ||
44 | |||
45 | /** | ||
46 | * A small abstraction layer to use the akonadi store with the type available as string. | ||
47 | */ | ||
48 | class StoreBase { | ||
49 | public: | ||
50 | virtual Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject() = 0; | ||
51 | virtual Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) = 0; | ||
52 | virtual KAsync::Job<void> create(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) = 0; | ||
53 | virtual KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) = 0; | ||
54 | virtual KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) = 0; | ||
55 | virtual QSharedPointer<QAbstractItemModel> loadModel(const Akonadi2::Query &query) = 0; | ||
56 | }; | ||
57 | |||
58 | template <typename T> | ||
59 | class Store : public StoreBase { | ||
60 | public: | ||
61 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject() Q_DECL_OVERRIDE { | ||
62 | return T::Ptr::create(); | ||
63 | } | ||
64 | |||
65 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) Q_DECL_OVERRIDE { | ||
66 | return T::Ptr::create(resourceInstanceIdentifier, identifier, 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | ||
67 | } | ||
68 | |||
69 | KAsync::Job<void> create(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | ||
70 | return Akonadi2::Store::create<T>(*static_cast<const T*>(&type)); | ||
71 | } | ||
72 | |||
73 | KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | ||
74 | return Akonadi2::Store::modify<T>(*static_cast<const T*>(&type)); | ||
75 | } | ||
76 | |||
77 | KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | ||
78 | return Akonadi2::Store::remove<T>(*static_cast<const T*>(&type)); | ||
79 | } | ||
80 | |||
81 | QSharedPointer<QAbstractItemModel> loadModel(const Akonadi2::Query &query) Q_DECL_OVERRIDE { | ||
82 | return Akonadi2::Store::loadModel<T>(query); | ||
83 | } | ||
84 | }; | ||
85 | |||
86 | |||
87 | } | ||
88 | |||
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 | ||
diff --git a/examples/client/CMakeLists.txt b/examples/client/CMakeLists.txt index 97b5ad2..85840c4 100644 --- a/examples/client/CMakeLists.txt +++ b/examples/client/CMakeLists.txt | |||
@@ -1,8 +1,8 @@ | |||
1 | project(akonadi2_client) | 1 | project(sink_client) |
2 | 2 | ||
3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | 3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) |
4 | 4 | ||
5 | add_executable(${PROJECT_NAME} main.cpp console.cpp) | 5 | add_executable(${PROJECT_NAME} main.cpp console.cpp) |
6 | target_link_libraries(${PROJECT_NAME} akonadi2common) | 6 | target_link_libraries(${PROJECT_NAME} sinkcommon) |
7 | qt5_use_modules(${PROJECT_NAME} Widgets Network) | 7 | qt5_use_modules(${PROJECT_NAME} Widgets Network) |
8 | install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) | 8 | install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) |
diff --git a/examples/client/main.cpp b/examples/client/main.cpp index 6660f86..f437c19 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp | |||
@@ -34,64 +34,64 @@ | |||
34 | #include <iostream> | 34 | #include <iostream> |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * A small abstraction layer to use the akonadi store with the type available as string. | 37 | * A small abstraction layer to use the sink store with the type available as string. |
38 | */ | 38 | */ |
39 | class StoreBase { | 39 | class StoreBase { |
40 | public: | 40 | public: |
41 | virtual Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject() = 0; | 41 | virtual Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject() = 0; |
42 | virtual Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) = 0; | 42 | virtual Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) = 0; |
43 | virtual KAsync::Job<void> create(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) = 0; | 43 | virtual KAsync::Job<void> create(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; |
44 | virtual KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) = 0; | 44 | virtual KAsync::Job<void> modify(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; |
45 | virtual KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) = 0; | 45 | virtual KAsync::Job<void> remove(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; |
46 | virtual QSharedPointer<QAbstractItemModel> loadModel(const Akonadi2::Query &query) = 0; | 46 | virtual QSharedPointer<QAbstractItemModel> loadModel(const Sink::Query &query) = 0; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | template <typename T> | 49 | template <typename T> |
50 | class Store : public StoreBase { | 50 | class Store : public StoreBase { |
51 | public: | 51 | public: |
52 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject() Q_DECL_OVERRIDE { | 52 | Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject() Q_DECL_OVERRIDE { |
53 | return T::Ptr::create(); | 53 | return T::Ptr::create(); |
54 | } | 54 | } |
55 | 55 | ||
56 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) Q_DECL_OVERRIDE { | 56 | Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) Q_DECL_OVERRIDE { |
57 | return T::Ptr::create(resourceInstanceIdentifier, identifier, 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 57 | return T::Ptr::create(resourceInstanceIdentifier, identifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
58 | } | 58 | } |
59 | 59 | ||
60 | KAsync::Job<void> create(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | 60 | KAsync::Job<void> create(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { |
61 | return Akonadi2::Store::create<T>(*static_cast<const T*>(&type)); | 61 | return Sink::Store::create<T>(*static_cast<const T*>(&type)); |
62 | } | 62 | } |
63 | 63 | ||
64 | KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | 64 | KAsync::Job<void> modify(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { |
65 | return Akonadi2::Store::modify<T>(*static_cast<const T*>(&type)); | 65 | return Sink::Store::modify<T>(*static_cast<const T*>(&type)); |
66 | } | 66 | } |
67 | 67 | ||
68 | KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | 68 | KAsync::Job<void> remove(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { |
69 | return Akonadi2::Store::remove<T>(*static_cast<const T*>(&type)); | 69 | return Sink::Store::remove<T>(*static_cast<const T*>(&type)); |
70 | } | 70 | } |
71 | 71 | ||
72 | QSharedPointer<QAbstractItemModel> loadModel(const Akonadi2::Query &query) Q_DECL_OVERRIDE { | 72 | QSharedPointer<QAbstractItemModel> loadModel(const Sink::Query &query) Q_DECL_OVERRIDE { |
73 | return Akonadi2::Store::loadModel<T>(query); | 73 | return Sink::Store::loadModel<T>(query); |
74 | } | 74 | } |
75 | }; | 75 | }; |
76 | 76 | ||
77 | StoreBase& getStore(const QString &type) | 77 | StoreBase& getStore(const QString &type) |
78 | { | 78 | { |
79 | if (type == "folder") { | 79 | if (type == "folder") { |
80 | static Store<Akonadi2::ApplicationDomain::Folder> store; | 80 | static Store<Sink::ApplicationDomain::Folder> store; |
81 | return store; | 81 | return store; |
82 | } else if (type == "mail") { | 82 | } else if (type == "mail") { |
83 | static Store<Akonadi2::ApplicationDomain::Mail> store; | 83 | static Store<Sink::ApplicationDomain::Mail> store; |
84 | return store; | 84 | return store; |
85 | } else if (type == "event") { | 85 | } else if (type == "event") { |
86 | static Store<Akonadi2::ApplicationDomain::Event> store; | 86 | static Store<Sink::ApplicationDomain::Event> store; |
87 | return store; | 87 | return store; |
88 | } else if (type == "resource") { | 88 | } else if (type == "resource") { |
89 | static Store<Akonadi2::ApplicationDomain::AkonadiResource> store; | 89 | static Store<Sink::ApplicationDomain::SinkResource> store; |
90 | return store; | 90 | return store; |
91 | } | 91 | } |
92 | Q_ASSERT(false); | 92 | Q_ASSERT(false); |
93 | qWarning() << "Trying to get a store that doesn't exist, falling back to event"; | 93 | qWarning() << "Trying to get a store that doesn't exist, falling back to event"; |
94 | static Store<Akonadi2::ApplicationDomain::Event> store; | 94 | static Store<Sink::ApplicationDomain::Event> store; |
95 | return store; | 95 | return store; |
96 | } | 96 | } |
97 | 97 | ||
@@ -118,17 +118,17 @@ public: | |||
118 | auto syncButton = new QPushButton(this); | 118 | auto syncButton = new QPushButton(this); |
119 | syncButton->setText("Synchronize!"); | 119 | syncButton->setText("Synchronize!"); |
120 | QObject::connect(syncButton, &QPushButton::pressed, []() { | 120 | QObject::connect(syncButton, &QPushButton::pressed, []() { |
121 | Akonadi2::Query query; | 121 | Sink::Query query; |
122 | query.resources << "org.kde.dummy.instance1"; | 122 | query.resources << "org.kde.dummy.instance1"; |
123 | Akonadi2::Store::synchronize(query).exec(); | 123 | Sink::Store::synchronize(query).exec(); |
124 | }); | 124 | }); |
125 | 125 | ||
126 | auto removeButton = new QPushButton(this); | 126 | auto removeButton = new QPushButton(this); |
127 | removeButton->setText("Remove"); | 127 | removeButton->setText("Remove"); |
128 | QObject::connect(removeButton, &QPushButton::pressed, [modelView]() { | 128 | QObject::connect(removeButton, &QPushButton::pressed, [modelView]() { |
129 | for (auto index : modelView->selectionModel()->selectedIndexes()) { | 129 | for (auto index : modelView->selectionModel()->selectedIndexes()) { |
130 | auto object = index.data(Akonadi2::Store::DomainObjectRole).value<typename T::Ptr>(); | 130 | auto object = index.data(Sink::Store::DomainObjectRole).value<typename T::Ptr>(); |
131 | Akonadi2::Store::remove(*object).exec(); | 131 | Sink::Store::remove(*object).exec(); |
132 | } | 132 | } |
133 | }); | 133 | }); |
134 | 134 | ||
@@ -142,7 +142,7 @@ public: | |||
142 | 142 | ||
143 | }; | 143 | }; |
144 | 144 | ||
145 | static QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Akonadi2::Query query) | 145 | static QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Sink::Query query) |
146 | { | 146 | { |
147 | QTime time; | 147 | QTime time; |
148 | time.start(); | 148 | time.start(); |
@@ -187,13 +187,13 @@ int main(int argc, char *argv[]) | |||
187 | QStringList args = cliOptions.positionalArguments(); | 187 | QStringList args = cliOptions.positionalArguments(); |
188 | 188 | ||
189 | if (cliOptions.isSet("debuglevel")) { | 189 | if (cliOptions.isSet("debuglevel")) { |
190 | Akonadi2::Log::setDebugOutputLevel(static_cast<Akonadi2::Log::DebugLevel>(cliOptions.value("debuglevel").toInt())); | 190 | Sink::Log::setDebugOutputLevel(static_cast<Sink::Log::DebugLevel>(cliOptions.value("debuglevel").toInt())); |
191 | } | 191 | } |
192 | 192 | ||
193 | auto type = !args.isEmpty() ? args.takeFirst() : QByteArray(); | 193 | auto type = !args.isEmpty() ? args.takeFirst() : QByteArray(); |
194 | auto resources = args; | 194 | auto resources = args; |
195 | 195 | ||
196 | Akonadi2::Query query; | 196 | Sink::Query query; |
197 | for (const auto &res : resources) { | 197 | for (const auto &res : resources) { |
198 | query.resources << res.toLatin1(); | 198 | query.resources << res.toLatin1(); |
199 | } | 199 | } |
@@ -208,13 +208,13 @@ int main(int argc, char *argv[]) | |||
208 | model->fetchMore(model->index(i, 0, index)); | 208 | model->fetchMore(model->index(i, 0, index)); |
209 | } | 209 | } |
210 | }); | 210 | }); |
211 | auto view = QSharedPointer<View<Akonadi2::ApplicationDomain::Folder> >::create(model.data()); | 211 | auto view = QSharedPointer<View<Sink::ApplicationDomain::Folder> >::create(model.data()); |
212 | app.exec(); | 212 | app.exec(); |
213 | } else if (type == "mail") { | 213 | } else if (type == "mail") { |
214 | auto view = QSharedPointer<View<Akonadi2::ApplicationDomain::Mail> >::create(model.data()); | 214 | auto view = QSharedPointer<View<Sink::ApplicationDomain::Mail> >::create(model.data()); |
215 | app.exec(); | 215 | app.exec(); |
216 | } else if (type == "event") { | 216 | } else if (type == "event") { |
217 | auto view = QSharedPointer<View<Akonadi2::ApplicationDomain::Event> >::create(model.data()); | 217 | auto view = QSharedPointer<View<Sink::ApplicationDomain::Event> >::create(model.data()); |
218 | app.exec(); | 218 | app.exec(); |
219 | } | 219 | } |
220 | return 0; | 220 | return 0; |
diff --git a/examples/dummyresource/CMakeLists.txt b/examples/dummyresource/CMakeLists.txt index 1e80f81..6ffac9a 100644 --- a/examples/dummyresource/CMakeLists.txt +++ b/examples/dummyresource/CMakeLists.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | project(akonadi2_resource_dummy) | 1 | project(sink_resource_dummy) |
2 | 2 | ||
3 | add_definitions(-DQT_PLUGIN) | 3 | add_definitions(-DQT_PLUGIN) |
4 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | 4 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) |
@@ -7,6 +7,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | |||
7 | add_library(${PROJECT_NAME} SHARED facade.cpp resourcefactory.cpp domainadaptor.cpp dummystore.cpp) | 7 | add_library(${PROJECT_NAME} SHARED facade.cpp resourcefactory.cpp domainadaptor.cpp dummystore.cpp) |
8 | generate_flatbuffers(${PROJECT_NAME} dummycalendar) | 8 | generate_flatbuffers(${PROJECT_NAME} dummycalendar) |
9 | qt5_use_modules(${PROJECT_NAME} Core Network) | 9 | qt5_use_modules(${PROJECT_NAME} Core Network) |
10 | target_link_libraries(${PROJECT_NAME} akonadi2common) | 10 | target_link_libraries(${PROJECT_NAME} sinkcommon) |
11 | 11 | ||
12 | install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${AKONADI2_RESOURCE_PLUGINS_PATH}) | 12 | install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${SINK_RESOURCE_PLUGINS_PATH}) |
diff --git a/examples/dummyresource/domainadaptor.h b/examples/dummyresource/domainadaptor.h index e5856f8..e7098e9 100644 --- a/examples/dummyresource/domainadaptor.h +++ b/examples/dummyresource/domainadaptor.h | |||
@@ -26,21 +26,21 @@ | |||
26 | #include "dummycalendar_generated.h" | 26 | #include "dummycalendar_generated.h" |
27 | #include "entity_generated.h" | 27 | #include "entity_generated.h" |
28 | 28 | ||
29 | class DummyEventAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, DummyCalendar::DummyEvent, DummyCalendar::DummyEventBuilder> | 29 | class DummyEventAdaptorFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Event, DummyCalendar::DummyEvent, DummyCalendar::DummyEventBuilder> |
30 | { | 30 | { |
31 | public: | 31 | public: |
32 | DummyEventAdaptorFactory(); | 32 | DummyEventAdaptorFactory(); |
33 | virtual ~DummyEventAdaptorFactory() {}; | 33 | virtual ~DummyEventAdaptorFactory() {}; |
34 | }; | 34 | }; |
35 | 35 | ||
36 | class DummyMailAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Mail, Akonadi2::ApplicationDomain::Buffer::Dummy, Akonadi2::ApplicationDomain::Buffer::DummyBuilder> | 36 | class DummyMailAdaptorFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Mail, Sink::ApplicationDomain::Buffer::Dummy, Sink::ApplicationDomain::Buffer::DummyBuilder> |
37 | { | 37 | { |
38 | public: | 38 | public: |
39 | DummyMailAdaptorFactory(); | 39 | DummyMailAdaptorFactory(); |
40 | virtual ~DummyMailAdaptorFactory() {}; | 40 | virtual ~DummyMailAdaptorFactory() {}; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | class DummyFolderAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Folder, Akonadi2::ApplicationDomain::Buffer::Dummy, Akonadi2::ApplicationDomain::Buffer::DummyBuilder> | 43 | class DummyFolderAdaptorFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Folder, Sink::ApplicationDomain::Buffer::Dummy, Sink::ApplicationDomain::Buffer::DummyBuilder> |
44 | { | 44 | { |
45 | public: | 45 | public: |
46 | DummyFolderAdaptorFactory(); | 46 | DummyFolderAdaptorFactory(); |
diff --git a/examples/dummyresource/facade.cpp b/examples/dummyresource/facade.cpp index f337bdc..120498a 100644 --- a/examples/dummyresource/facade.cpp +++ b/examples/dummyresource/facade.cpp | |||
@@ -22,7 +22,7 @@ | |||
22 | #include "domainadaptor.h" | 22 | #include "domainadaptor.h" |
23 | 23 | ||
24 | DummyResourceFacade::DummyResourceFacade(const QByteArray &instanceIdentifier) | 24 | DummyResourceFacade::DummyResourceFacade(const QByteArray &instanceIdentifier) |
25 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>(instanceIdentifier, QSharedPointer<DummyEventAdaptorFactory>::create()) | 25 | : Sink::GenericFacade<Sink::ApplicationDomain::Event>(instanceIdentifier, QSharedPointer<DummyEventAdaptorFactory>::create()) |
26 | { | 26 | { |
27 | } | 27 | } |
28 | 28 | ||
@@ -32,7 +32,7 @@ DummyResourceFacade::~DummyResourceFacade() | |||
32 | 32 | ||
33 | 33 | ||
34 | DummyResourceMailFacade::DummyResourceMailFacade(const QByteArray &instanceIdentifier) | 34 | DummyResourceMailFacade::DummyResourceMailFacade(const QByteArray &instanceIdentifier) |
35 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Mail>(instanceIdentifier, QSharedPointer<DummyMailAdaptorFactory>::create()) | 35 | : Sink::GenericFacade<Sink::ApplicationDomain::Mail>(instanceIdentifier, QSharedPointer<DummyMailAdaptorFactory>::create()) |
36 | { | 36 | { |
37 | } | 37 | } |
38 | 38 | ||
@@ -42,7 +42,7 @@ DummyResourceMailFacade::~DummyResourceMailFacade() | |||
42 | 42 | ||
43 | 43 | ||
44 | DummyResourceFolderFacade::DummyResourceFolderFacade(const QByteArray &instanceIdentifier) | 44 | DummyResourceFolderFacade::DummyResourceFolderFacade(const QByteArray &instanceIdentifier) |
45 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Folder>(instanceIdentifier, QSharedPointer<DummyFolderAdaptorFactory>::create()) | 45 | : Sink::GenericFacade<Sink::ApplicationDomain::Folder>(instanceIdentifier, QSharedPointer<DummyFolderAdaptorFactory>::create()) |
46 | { | 46 | { |
47 | } | 47 | } |
48 | 48 | ||
diff --git a/examples/dummyresource/facade.h b/examples/dummyresource/facade.h index b00e1d7..5e0096d 100644 --- a/examples/dummyresource/facade.h +++ b/examples/dummyresource/facade.h | |||
@@ -22,21 +22,21 @@ | |||
22 | #include "common/facade.h" | 22 | #include "common/facade.h" |
23 | #include "common/domain/event.h" | 23 | #include "common/domain/event.h" |
24 | 24 | ||
25 | class DummyResourceFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event> | 25 | class DummyResourceFacade : public Sink::GenericFacade<Sink::ApplicationDomain::Event> |
26 | { | 26 | { |
27 | public: | 27 | public: |
28 | DummyResourceFacade(const QByteArray &instanceIdentifier); | 28 | DummyResourceFacade(const QByteArray &instanceIdentifier); |
29 | virtual ~DummyResourceFacade(); | 29 | virtual ~DummyResourceFacade(); |
30 | }; | 30 | }; |
31 | 31 | ||
32 | class DummyResourceMailFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Mail> | 32 | class DummyResourceMailFacade : public Sink::GenericFacade<Sink::ApplicationDomain::Mail> |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | DummyResourceMailFacade(const QByteArray &instanceIdentifier); | 35 | DummyResourceMailFacade(const QByteArray &instanceIdentifier); |
36 | virtual ~DummyResourceMailFacade(); | 36 | virtual ~DummyResourceMailFacade(); |
37 | }; | 37 | }; |
38 | 38 | ||
39 | class DummyResourceFolderFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Folder> | 39 | class DummyResourceFolderFacade : public Sink::GenericFacade<Sink::ApplicationDomain::Folder> |
40 | { | 40 | { |
41 | public: | 41 | public: |
42 | DummyResourceFolderFacade(const QByteArray &instanceIdentifier); | 42 | DummyResourceFolderFacade(const QByteArray &instanceIdentifier); |
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index c43b5e6..31633d7 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp | |||
@@ -43,24 +43,24 @@ | |||
43 | #define ENTITY_TYPE_MAIL "mail" | 43 | #define ENTITY_TYPE_MAIL "mail" |
44 | #define ENTITY_TYPE_FOLDER "folder" | 44 | #define ENTITY_TYPE_FOLDER "folder" |
45 | 45 | ||
46 | DummyResource::DummyResource(const QByteArray &instanceIdentifier, const QSharedPointer<Akonadi2::Pipeline> &pipeline) | 46 | DummyResource::DummyResource(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::Pipeline> &pipeline) |
47 | : Akonadi2::GenericResource(instanceIdentifier, pipeline), | 47 | : Sink::GenericResource(instanceIdentifier, pipeline), |
48 | mEventAdaptorFactory(QSharedPointer<DummyEventAdaptorFactory>::create()), | 48 | mEventAdaptorFactory(QSharedPointer<DummyEventAdaptorFactory>::create()), |
49 | mMailAdaptorFactory(QSharedPointer<DummyMailAdaptorFactory>::create()), | 49 | mMailAdaptorFactory(QSharedPointer<DummyMailAdaptorFactory>::create()), |
50 | mFolderAdaptorFactory(QSharedPointer<DummyFolderAdaptorFactory>::create()) | 50 | mFolderAdaptorFactory(QSharedPointer<DummyFolderAdaptorFactory>::create()) |
51 | { | 51 | { |
52 | addType(ENTITY_TYPE_MAIL, mMailAdaptorFactory, | 52 | addType(ENTITY_TYPE_MAIL, mMailAdaptorFactory, |
53 | QVector<Akonadi2::Preprocessor*>() << new DefaultIndexUpdater<Akonadi2::ApplicationDomain::Mail>); | 53 | QVector<Sink::Preprocessor*>() << new DefaultIndexUpdater<Sink::ApplicationDomain::Mail>); |
54 | addType(ENTITY_TYPE_FOLDER, mFolderAdaptorFactory, | 54 | addType(ENTITY_TYPE_FOLDER, mFolderAdaptorFactory, |
55 | QVector<Akonadi2::Preprocessor*>() << new DefaultIndexUpdater<Akonadi2::ApplicationDomain::Folder>); | 55 | QVector<Sink::Preprocessor*>() << new DefaultIndexUpdater<Sink::ApplicationDomain::Folder>); |
56 | addType(ENTITY_TYPE_EVENT, mEventAdaptorFactory, | 56 | addType(ENTITY_TYPE_EVENT, mEventAdaptorFactory, |
57 | QVector<Akonadi2::Preprocessor*>() << new DefaultIndexUpdater<Akonadi2::ApplicationDomain::Event>); | 57 | QVector<Sink::Preprocessor*>() << new DefaultIndexUpdater<Sink::ApplicationDomain::Event>); |
58 | } | 58 | } |
59 | 59 | ||
60 | Akonadi2::ApplicationDomain::Event::Ptr DummyResource::createEvent(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Akonadi2::Storage::Transaction &transaction) | 60 | Sink::ApplicationDomain::Event::Ptr DummyResource::createEvent(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Sink::Storage::Transaction &transaction) |
61 | { | 61 | { |
62 | static uint8_t rawData[100]; | 62 | static uint8_t rawData[100]; |
63 | auto event = Akonadi2::ApplicationDomain::Event::Ptr::create(); | 63 | auto event = Sink::ApplicationDomain::Event::Ptr::create(); |
64 | event->setProperty("summary", data.value("summary").toString()); | 64 | event->setProperty("summary", data.value("summary").toString()); |
65 | event->setProperty("remoteId", ridBuffer); | 65 | event->setProperty("remoteId", ridBuffer); |
66 | event->setProperty("description", data.value("description").toString()); | 66 | event->setProperty("description", data.value("description").toString()); |
@@ -68,9 +68,9 @@ Akonadi2::ApplicationDomain::Event::Ptr DummyResource::createEvent(const QByteAr | |||
68 | return event; | 68 | return event; |
69 | } | 69 | } |
70 | 70 | ||
71 | Akonadi2::ApplicationDomain::Mail::Ptr DummyResource::createMail(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Akonadi2::Storage::Transaction &transaction) | 71 | Sink::ApplicationDomain::Mail::Ptr DummyResource::createMail(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Sink::Storage::Transaction &transaction) |
72 | { | 72 | { |
73 | auto mail = Akonadi2::ApplicationDomain::Mail::Ptr::create(); | 73 | auto mail = Sink::ApplicationDomain::Mail::Ptr::create(); |
74 | mail->setProperty("subject", data.value("subject").toString()); | 74 | mail->setProperty("subject", data.value("subject").toString()); |
75 | mail->setProperty("senderEmail", data.value("senderEmail").toString()); | 75 | mail->setProperty("senderEmail", data.value("senderEmail").toString()); |
76 | mail->setProperty("senderName", data.value("senderName").toString()); | 76 | mail->setProperty("senderName", data.value("senderName").toString()); |
@@ -81,19 +81,19 @@ Akonadi2::ApplicationDomain::Mail::Ptr DummyResource::createMail(const QByteArra | |||
81 | return mail; | 81 | return mail; |
82 | } | 82 | } |
83 | 83 | ||
84 | Akonadi2::ApplicationDomain::Folder::Ptr DummyResource::createFolder(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Akonadi2::Storage::Transaction &transaction) | 84 | Sink::ApplicationDomain::Folder::Ptr DummyResource::createFolder(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Sink::Storage::Transaction &transaction) |
85 | { | 85 | { |
86 | auto folder = Akonadi2::ApplicationDomain::Folder::Ptr::create(); | 86 | auto folder = Sink::ApplicationDomain::Folder::Ptr::create(); |
87 | folder->setProperty("name", data.value("name").toString()); | 87 | folder->setProperty("name", data.value("name").toString()); |
88 | folder->setProperty("icon", data.value("icon").toString()); | 88 | folder->setProperty("icon", data.value("icon").toString()); |
89 | if (!data.value("parent").toString().isEmpty()) { | 89 | if (!data.value("parent").toString().isEmpty()) { |
90 | auto akonadiId = resolveRemoteId(ENTITY_TYPE_FOLDER, data.value("parent").toByteArray(), transaction); | 90 | auto sinkId = resolveRemoteId(ENTITY_TYPE_FOLDER, data.value("parent").toByteArray(), transaction); |
91 | folder->setProperty("parent", akonadiId); | 91 | folder->setProperty("parent", sinkId); |
92 | } | 92 | } |
93 | return folder; | 93 | return folder; |
94 | } | 94 | } |
95 | 95 | ||
96 | void DummyResource::synchronize(const QByteArray &bufferType, const QMap<QString, QMap<QString, QVariant> > &data, Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Akonadi2::Storage::Transaction &)> createEntity) | 96 | void DummyResource::synchronize(const QByteArray &bufferType, const QMap<QString, QMap<QString, QVariant> > &data, Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<Sink::ApplicationDomain::ApplicationDomainType::Ptr(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Sink::Storage::Transaction &)> createEntity) |
97 | { | 97 | { |
98 | //TODO find items to remove | 98 | //TODO find items to remove |
99 | for (auto it = data.constBegin(); it != data.constEnd(); it++) { | 99 | for (auto it = data.constBegin(); it != data.constEnd(); it++) { |
@@ -103,26 +103,26 @@ void DummyResource::synchronize(const QByteArray &bufferType, const QMap<QString | |||
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | KAsync::Job<void> DummyResource::synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore) | 106 | KAsync::Job<void> DummyResource::synchronizeWithSource(Sink::Storage &mainStore, Sink::Storage &synchronizationStore) |
107 | { | 107 | { |
108 | Log() << " Synchronizing"; | 108 | Log() << " Synchronizing"; |
109 | return KAsync::start<void>([this, &mainStore, &synchronizationStore]() { | 109 | return KAsync::start<void>([this, &mainStore, &synchronizationStore]() { |
110 | auto transaction = mainStore.createTransaction(Akonadi2::Storage::ReadOnly); | 110 | auto transaction = mainStore.createTransaction(Sink::Storage::ReadOnly); |
111 | auto synchronizationTransaction = synchronizationStore.createTransaction(Akonadi2::Storage::ReadWrite); | 111 | auto synchronizationTransaction = synchronizationStore.createTransaction(Sink::Storage::ReadWrite); |
112 | synchronize(ENTITY_TYPE_EVENT, DummyStore::instance().events(), transaction, synchronizationTransaction, *mEventAdaptorFactory, [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Akonadi2::Storage::Transaction &synchronizationTransaction) { | 112 | synchronize(ENTITY_TYPE_EVENT, DummyStore::instance().events(), transaction, synchronizationTransaction, *mEventAdaptorFactory, [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Sink::Storage::Transaction &synchronizationTransaction) { |
113 | return createEvent(ridBuffer, data, synchronizationTransaction); | 113 | return createEvent(ridBuffer, data, synchronizationTransaction); |
114 | }); | 114 | }); |
115 | synchronize(ENTITY_TYPE_MAIL, DummyStore::instance().mails(), transaction, synchronizationTransaction, *mMailAdaptorFactory, [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Akonadi2::Storage::Transaction &synchronizationTransaction) { | 115 | synchronize(ENTITY_TYPE_MAIL, DummyStore::instance().mails(), transaction, synchronizationTransaction, *mMailAdaptorFactory, [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Sink::Storage::Transaction &synchronizationTransaction) { |
116 | return createMail(ridBuffer, data, synchronizationTransaction); | 116 | return createMail(ridBuffer, data, synchronizationTransaction); |
117 | }); | 117 | }); |
118 | synchronize(ENTITY_TYPE_FOLDER, DummyStore::instance().folders(), transaction, synchronizationTransaction, *mFolderAdaptorFactory, [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Akonadi2::Storage::Transaction &synchronizationTransaction) { | 118 | synchronize(ENTITY_TYPE_FOLDER, DummyStore::instance().folders(), transaction, synchronizationTransaction, *mFolderAdaptorFactory, [this](const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Sink::Storage::Transaction &synchronizationTransaction) { |
119 | return createFolder(ridBuffer, data, synchronizationTransaction); | 119 | return createFolder(ridBuffer, data, synchronizationTransaction); |
120 | }); | 120 | }); |
121 | Log() << "Done Synchronizing"; | 121 | Log() << "Done Synchronizing"; |
122 | }); | 122 | }); |
123 | } | 123 | } |
124 | 124 | ||
125 | KAsync::Job<void> DummyResource::replay(Akonadi2::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) | 125 | KAsync::Job<void> DummyResource::replay(Sink::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) |
126 | { | 126 | { |
127 | Trace() << "Replaying " << key; | 127 | Trace() << "Replaying " << key; |
128 | return KAsync::null<void>(); | 128 | return KAsync::null<void>(); |
@@ -131,7 +131,7 @@ KAsync::Job<void> DummyResource::replay(Akonadi2::Storage &synchronizationStore, | |||
131 | void DummyResource::removeFromDisk(const QByteArray &instanceIdentifier) | 131 | void DummyResource::removeFromDisk(const QByteArray &instanceIdentifier) |
132 | { | 132 | { |
133 | GenericResource::removeFromDisk(instanceIdentifier); | 133 | GenericResource::removeFromDisk(instanceIdentifier); |
134 | Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite).removeFromDisk(); | 134 | Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".synchronization", Sink::Storage::ReadWrite).removeFromDisk(); |
135 | } | 135 | } |
136 | 136 | ||
137 | KAsync::Job<void> DummyResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) | 137 | KAsync::Job<void> DummyResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) |
@@ -151,20 +151,20 @@ KAsync::Job<void> DummyResource::inspect(int inspectionType, const QByteArray &i | |||
151 | } | 151 | } |
152 | 152 | ||
153 | DummyResourceFactory::DummyResourceFactory(QObject *parent) | 153 | DummyResourceFactory::DummyResourceFactory(QObject *parent) |
154 | : Akonadi2::ResourceFactory(parent) | 154 | : Sink::ResourceFactory(parent) |
155 | { | 155 | { |
156 | 156 | ||
157 | } | 157 | } |
158 | 158 | ||
159 | Akonadi2::Resource *DummyResourceFactory::createResource(const QByteArray &instanceIdentifier) | 159 | Sink::Resource *DummyResourceFactory::createResource(const QByteArray &instanceIdentifier) |
160 | { | 160 | { |
161 | return new DummyResource(instanceIdentifier); | 161 | return new DummyResource(instanceIdentifier); |
162 | } | 162 | } |
163 | 163 | ||
164 | void DummyResourceFactory::registerFacades(Akonadi2::FacadeFactory &factory) | 164 | void DummyResourceFactory::registerFacades(Sink::FacadeFactory &factory) |
165 | { | 165 | { |
166 | factory.registerFacade<Akonadi2::ApplicationDomain::Event, DummyResourceFacade>(PLUGIN_NAME); | 166 | factory.registerFacade<Sink::ApplicationDomain::Event, DummyResourceFacade>(PLUGIN_NAME); |
167 | factory.registerFacade<Akonadi2::ApplicationDomain::Mail, DummyResourceMailFacade>(PLUGIN_NAME); | 167 | factory.registerFacade<Sink::ApplicationDomain::Mail, DummyResourceMailFacade>(PLUGIN_NAME); |
168 | factory.registerFacade<Akonadi2::ApplicationDomain::Folder, DummyResourceFolderFacade>(PLUGIN_NAME); | 168 | factory.registerFacade<Sink::ApplicationDomain::Folder, DummyResourceFolderFacade>(PLUGIN_NAME); |
169 | } | 169 | } |
170 | 170 | ||
diff --git a/examples/dummyresource/resourcefactory.h b/examples/dummyresource/resourcefactory.h index 634829e..240bb9f 100644 --- a/examples/dummyresource/resourcefactory.h +++ b/examples/dummyresource/resourcefactory.h | |||
@@ -33,36 +33,36 @@ class DummyEventAdaptorFactory; | |||
33 | class DummyMailAdaptorFactory; | 33 | class DummyMailAdaptorFactory; |
34 | class DummyFolderAdaptorFactory; | 34 | class DummyFolderAdaptorFactory; |
35 | 35 | ||
36 | class DummyResource : public Akonadi2::GenericResource | 36 | class DummyResource : public Sink::GenericResource |
37 | { | 37 | { |
38 | public: | 38 | public: |
39 | DummyResource(const QByteArray &instanceIdentifier, const QSharedPointer<Akonadi2::Pipeline> &pipeline = QSharedPointer<Akonadi2::Pipeline>()); | 39 | DummyResource(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::Pipeline> &pipeline = QSharedPointer<Sink::Pipeline>()); |
40 | KAsync::Job<void> synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore) Q_DECL_OVERRIDE; | 40 | KAsync::Job<void> synchronizeWithSource(Sink::Storage &mainStore, Sink::Storage &synchronizationStore) Q_DECL_OVERRIDE; |
41 | using GenericResource::synchronizeWithSource; | 41 | using GenericResource::synchronizeWithSource; |
42 | static void removeFromDisk(const QByteArray &instanceIdentifier); | 42 | static void removeFromDisk(const QByteArray &instanceIdentifier); |
43 | KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE; | 43 | KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE; |
44 | private: | 44 | private: |
45 | KAsync::Job<void> replay(Akonadi2::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE; | 45 | KAsync::Job<void> replay(Sink::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE; |
46 | Akonadi2::ApplicationDomain::Event::Ptr createEvent(const QByteArray &rid, const QMap<QString, QVariant> &data, Akonadi2::Storage::Transaction &); | 46 | Sink::ApplicationDomain::Event::Ptr createEvent(const QByteArray &rid, const QMap<QString, QVariant> &data, Sink::Storage::Transaction &); |
47 | Akonadi2::ApplicationDomain::Mail::Ptr createMail(const QByteArray &rid, const QMap<QString, QVariant> &data, Akonadi2::Storage::Transaction &); | 47 | Sink::ApplicationDomain::Mail::Ptr createMail(const QByteArray &rid, const QMap<QString, QVariant> &data, Sink::Storage::Transaction &); |
48 | Akonadi2::ApplicationDomain::Folder::Ptr createFolder(const QByteArray &rid, const QMap<QString, QVariant> &data, Akonadi2::Storage::Transaction &); | 48 | Sink::ApplicationDomain::Folder::Ptr createFolder(const QByteArray &rid, const QMap<QString, QVariant> &data, Sink::Storage::Transaction &); |
49 | void synchronize(const QByteArray &bufferType, const QMap<QString, QMap<QString, QVariant> > &data, Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Akonadi2::Storage::Transaction &)> createEntity); | 49 | void synchronize(const QByteArray &bufferType, const QMap<QString, QMap<QString, QVariant> > &data, Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, DomainTypeAdaptorFactoryInterface &adaptorFactory, std::function<Sink::ApplicationDomain::ApplicationDomainType::Ptr(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data, Sink::Storage::Transaction &)> createEntity); |
50 | 50 | ||
51 | QSharedPointer<DummyEventAdaptorFactory> mEventAdaptorFactory; | 51 | QSharedPointer<DummyEventAdaptorFactory> mEventAdaptorFactory; |
52 | QSharedPointer<DummyMailAdaptorFactory> mMailAdaptorFactory; | 52 | QSharedPointer<DummyMailAdaptorFactory> mMailAdaptorFactory; |
53 | QSharedPointer<DummyFolderAdaptorFactory> mFolderAdaptorFactory; | 53 | QSharedPointer<DummyFolderAdaptorFactory> mFolderAdaptorFactory; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | class DummyResourceFactory : public Akonadi2::ResourceFactory | 56 | class DummyResourceFactory : public Sink::ResourceFactory |
57 | { | 57 | { |
58 | Q_OBJECT | 58 | Q_OBJECT |
59 | Q_PLUGIN_METADATA(IID "org.kde.dummy") | 59 | Q_PLUGIN_METADATA(IID "org.kde.dummy") |
60 | Q_INTERFACES(Akonadi2::ResourceFactory) | 60 | Q_INTERFACES(Sink::ResourceFactory) |
61 | 61 | ||
62 | public: | 62 | public: |
63 | DummyResourceFactory(QObject *parent = 0); | 63 | DummyResourceFactory(QObject *parent = 0); |
64 | 64 | ||
65 | Akonadi2::Resource *createResource(const QByteArray &instanceIdentifier) Q_DECL_OVERRIDE; | 65 | Sink::Resource *createResource(const QByteArray &instanceIdentifier) Q_DECL_OVERRIDE; |
66 | void registerFacades(Akonadi2::FacadeFactory &factory) Q_DECL_OVERRIDE; | 66 | void registerFacades(Sink::FacadeFactory &factory) Q_DECL_OVERRIDE; |
67 | }; | 67 | }; |
68 | 68 | ||
diff --git a/examples/maildirresource/CMakeLists.txt b/examples/maildirresource/CMakeLists.txt index 2340cf6..baacd44 100644 --- a/examples/maildirresource/CMakeLists.txt +++ b/examples/maildirresource/CMakeLists.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | project(akonadi2_resource_maildir) | 1 | project(sink_resource_maildir) |
2 | 2 | ||
3 | add_definitions(-DQT_PLUGIN) | 3 | add_definitions(-DQT_PLUGIN) |
4 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | 4 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) |
@@ -8,8 +8,8 @@ find_package(KF5 COMPONENTS REQUIRED Mime) | |||
8 | add_library(${PROJECT_NAME} SHARED facade.cpp maildirresource.cpp domainadaptor.cpp) | 8 | add_library(${PROJECT_NAME} SHARED facade.cpp maildirresource.cpp domainadaptor.cpp) |
9 | # generate_flatbuffers(${PROJECT_NAME} dummycalendar) | 9 | # generate_flatbuffers(${PROJECT_NAME} dummycalendar) |
10 | qt5_use_modules(${PROJECT_NAME} Core Network) | 10 | qt5_use_modules(${PROJECT_NAME} Core Network) |
11 | target_link_libraries(${PROJECT_NAME} akonadi2common maildir KF5::Mime) | 11 | target_link_libraries(${PROJECT_NAME} sinkcommon maildir KF5::Mime) |
12 | 12 | ||
13 | install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${AKONADI2_RESOURCE_PLUGINS_PATH}) | 13 | install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${SINK_RESOURCE_PLUGINS_PATH}) |
14 | 14 | ||
15 | add_subdirectory(libmaildir) | 15 | add_subdirectory(libmaildir) |
diff --git a/examples/maildirresource/domainadaptor.h b/examples/maildirresource/domainadaptor.h index 0fc7108..700d2e5 100644 --- a/examples/maildirresource/domainadaptor.h +++ b/examples/maildirresource/domainadaptor.h | |||
@@ -23,14 +23,14 @@ | |||
23 | #include "folder_generated.h" | 23 | #include "folder_generated.h" |
24 | #include "dummy_generated.h" | 24 | #include "dummy_generated.h" |
25 | 25 | ||
26 | class MaildirMailAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Mail, Akonadi2::ApplicationDomain::Buffer::Dummy, Akonadi2::ApplicationDomain::Buffer::DummyBuilder> | 26 | class MaildirMailAdaptorFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Mail, Sink::ApplicationDomain::Buffer::Dummy, Sink::ApplicationDomain::Buffer::DummyBuilder> |
27 | { | 27 | { |
28 | public: | 28 | public: |
29 | MaildirMailAdaptorFactory(); | 29 | MaildirMailAdaptorFactory(); |
30 | virtual ~MaildirMailAdaptorFactory() {}; | 30 | virtual ~MaildirMailAdaptorFactory() {}; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | class MaildirFolderAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Folder, Akonadi2::ApplicationDomain::Buffer::Dummy, Akonadi2::ApplicationDomain::Buffer::DummyBuilder> | 33 | class MaildirFolderAdaptorFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Folder, Sink::ApplicationDomain::Buffer::Dummy, Sink::ApplicationDomain::Buffer::DummyBuilder> |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | MaildirFolderAdaptorFactory(); | 36 | MaildirFolderAdaptorFactory(); |
diff --git a/examples/maildirresource/facade.cpp b/examples/maildirresource/facade.cpp index 3cf3fde..7178ab9 100644 --- a/examples/maildirresource/facade.cpp +++ b/examples/maildirresource/facade.cpp | |||
@@ -22,7 +22,7 @@ | |||
22 | #include "domainadaptor.h" | 22 | #include "domainadaptor.h" |
23 | 23 | ||
24 | MaildirResourceMailFacade::MaildirResourceMailFacade(const QByteArray &instanceIdentifier) | 24 | MaildirResourceMailFacade::MaildirResourceMailFacade(const QByteArray &instanceIdentifier) |
25 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Mail>(instanceIdentifier, QSharedPointer<MaildirMailAdaptorFactory>::create()) | 25 | : Sink::GenericFacade<Sink::ApplicationDomain::Mail>(instanceIdentifier, QSharedPointer<MaildirMailAdaptorFactory>::create()) |
26 | { | 26 | { |
27 | } | 27 | } |
28 | 28 | ||
@@ -32,7 +32,7 @@ MaildirResourceMailFacade::~MaildirResourceMailFacade() | |||
32 | 32 | ||
33 | 33 | ||
34 | MaildirResourceFolderFacade::MaildirResourceFolderFacade(const QByteArray &instanceIdentifier) | 34 | MaildirResourceFolderFacade::MaildirResourceFolderFacade(const QByteArray &instanceIdentifier) |
35 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Folder>(instanceIdentifier, QSharedPointer<MaildirFolderAdaptorFactory>::create()) | 35 | : Sink::GenericFacade<Sink::ApplicationDomain::Folder>(instanceIdentifier, QSharedPointer<MaildirFolderAdaptorFactory>::create()) |
36 | { | 36 | { |
37 | } | 37 | } |
38 | 38 | ||
diff --git a/examples/maildirresource/facade.h b/examples/maildirresource/facade.h index 80f0d06..a243b0d 100644 --- a/examples/maildirresource/facade.h +++ b/examples/maildirresource/facade.h | |||
@@ -21,14 +21,14 @@ | |||
21 | 21 | ||
22 | #include "common/facade.h" | 22 | #include "common/facade.h" |
23 | 23 | ||
24 | class MaildirResourceMailFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Mail> | 24 | class MaildirResourceMailFacade : public Sink::GenericFacade<Sink::ApplicationDomain::Mail> |
25 | { | 25 | { |
26 | public: | 26 | public: |
27 | MaildirResourceMailFacade(const QByteArray &instanceIdentifier); | 27 | MaildirResourceMailFacade(const QByteArray &instanceIdentifier); |
28 | virtual ~MaildirResourceMailFacade(); | 28 | virtual ~MaildirResourceMailFacade(); |
29 | }; | 29 | }; |
30 | 30 | ||
31 | class MaildirResourceFolderFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Folder> | 31 | class MaildirResourceFolderFacade : public Sink::GenericFacade<Sink::ApplicationDomain::Folder> |
32 | { | 32 | { |
33 | public: | 33 | public: |
34 | MaildirResourceFolderFacade(const QByteArray &instanceIdentifier); | 34 | MaildirResourceFolderFacade(const QByteArray &instanceIdentifier); |
diff --git a/examples/maildirresource/libmaildir/maildir.cpp b/examples/maildirresource/libmaildir/maildir.cpp index 28cf46e..3d4630f 100644 --- a/examples/maildirresource/libmaildir/maildir.cpp +++ b/examples/maildirresource/libmaildir/maildir.cpp | |||
@@ -688,7 +688,7 @@ bool Maildir::removeEntry(const QString& key) | |||
688 | // return QFile::remove(realKey); | 688 | // return QFile::remove(realKey); |
689 | } | 689 | } |
690 | 690 | ||
691 | // QString Maildir::changeEntryFlags(const QString& key, const Akonadi::Item::Flags& flags) | 691 | // QString Maildir::changeEntryFlags(const QString& key, const Sink::Item::Flags& flags) |
692 | // { | 692 | // { |
693 | // QString realKey(d->findRealKey(key)); | 693 | // QString realKey(d->findRealKey(key)); |
694 | // if (realKey.isEmpty()) { | 694 | // if (realKey.isEmpty()) { |
@@ -701,16 +701,16 @@ bool Maildir::removeEntry(const QString& key) | |||
701 | // QString finalKey = key.left(key.indexOf(rx)); | 701 | // QString finalKey = key.left(key.indexOf(rx)); |
702 | // | 702 | // |
703 | // QStringList mailDirFlags; | 703 | // QStringList mailDirFlags; |
704 | // Q_FOREACH (const Akonadi::Item::Flag &flag, flags) { | 704 | // Q_FOREACH (const Sink::Item::Flag &flag, flags) { |
705 | // if (flag == Akonadi::MessageFlags::Forwarded) | 705 | // if (flag == Sink::MessageFlags::Forwarded) |
706 | // mailDirFlags << QLatin1String("P"); | 706 | // mailDirFlags << QLatin1String("P"); |
707 | // if (flag == Akonadi::MessageFlags::Replied) | 707 | // if (flag == Sink::MessageFlags::Replied) |
708 | // mailDirFlags << QLatin1String("R"); | 708 | // mailDirFlags << QLatin1String("R"); |
709 | // if (flag == Akonadi::MessageFlags::Seen) | 709 | // if (flag == Sink::MessageFlags::Seen) |
710 | // mailDirFlags << QLatin1String("S"); | 710 | // mailDirFlags << QLatin1String("S"); |
711 | // if (flag == Akonadi::MessageFlags::Deleted) | 711 | // if (flag == Sink::MessageFlags::Deleted) |
712 | // mailDirFlags << QLatin1String("T"); | 712 | // mailDirFlags << QLatin1String("T"); |
713 | // if (flag == Akonadi::MessageFlags::Flagged) | 713 | // if (flag == Sink::MessageFlags::Flagged) |
714 | // mailDirFlags << QLatin1String("F"); | 714 | // mailDirFlags << QLatin1String("F"); |
715 | // } | 715 | // } |
716 | // mailDirFlags.sort(); | 716 | // mailDirFlags.sort(); |
@@ -726,7 +726,7 @@ bool Maildir::removeEntry(const QString& key) | |||
726 | // finalKey.prepend(d->path + QString::fromLatin1("/cur/")); | 726 | // finalKey.prepend(d->path + QString::fromLatin1("/cur/")); |
727 | // | 727 | // |
728 | // if (realKey == finalKey) { | 728 | // if (realKey == finalKey) { |
729 | // // Somehow it already is named this way (e.g. migration bug -> wrong status in akonadi) | 729 | // // Somehow it already is named this way (e.g. migration bug -> wrong status in sink) |
730 | // return newUniqueKey; | 730 | // return newUniqueKey; |
731 | // } | 731 | // } |
732 | // | 732 | // |
diff --git a/examples/maildirresource/libmaildir/maildir.h b/examples/maildirresource/libmaildir/maildir.h index fefd5a7..a89a832 100644 --- a/examples/maildirresource/libmaildir/maildir.h +++ b/examples/maildirresource/libmaildir/maildir.h | |||
@@ -211,7 +211,7 @@ public: | |||
211 | * Change the flags for an entry specified by @p key. Returns the new key of the entry (the key might change because | 211 | * Change the flags for an entry specified by @p key. Returns the new key of the entry (the key might change because |
212 | * flags are stored in the unique filename). | 212 | * flags are stored in the unique filename). |
213 | */ | 213 | */ |
214 | // QString changeEntryFlags( const QString& key, const Akonadi::Item::Flags& flags ); | 214 | // QString changeEntryFlags( const QString& key, const Sink::Item::Flags& flags ); |
215 | 215 | ||
216 | /** | 216 | /** |
217 | * Moves this maildir into @p destination. | 217 | * Moves this maildir into @p destination. |
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 9280bdc..33883a7 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -46,15 +46,15 @@ | |||
46 | #define ENTITY_TYPE_MAIL "mail" | 46 | #define ENTITY_TYPE_MAIL "mail" |
47 | #define ENTITY_TYPE_FOLDER "folder" | 47 | #define ENTITY_TYPE_FOLDER "folder" |
48 | 48 | ||
49 | MaildirResource::MaildirResource(const QByteArray &instanceIdentifier, const QSharedPointer<Akonadi2::Pipeline> &pipeline) | 49 | MaildirResource::MaildirResource(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::Pipeline> &pipeline) |
50 | : Akonadi2::GenericResource(instanceIdentifier, pipeline), | 50 | : Sink::GenericResource(instanceIdentifier, pipeline), |
51 | mMailAdaptorFactory(QSharedPointer<MaildirMailAdaptorFactory>::create()), | 51 | mMailAdaptorFactory(QSharedPointer<MaildirMailAdaptorFactory>::create()), |
52 | mFolderAdaptorFactory(QSharedPointer<MaildirFolderAdaptorFactory>::create()) | 52 | mFolderAdaptorFactory(QSharedPointer<MaildirFolderAdaptorFactory>::create()) |
53 | { | 53 | { |
54 | addType(ENTITY_TYPE_MAIL, mMailAdaptorFactory, | 54 | addType(ENTITY_TYPE_MAIL, mMailAdaptorFactory, |
55 | QVector<Akonadi2::Preprocessor*>() << new DefaultIndexUpdater<Akonadi2::ApplicationDomain::Mail>); | 55 | QVector<Sink::Preprocessor*>() << new DefaultIndexUpdater<Sink::ApplicationDomain::Mail>); |
56 | addType(ENTITY_TYPE_FOLDER, mFolderAdaptorFactory, | 56 | addType(ENTITY_TYPE_FOLDER, mFolderAdaptorFactory, |
57 | QVector<Akonadi2::Preprocessor*>() << new DefaultIndexUpdater<Akonadi2::ApplicationDomain::Folder>); | 57 | QVector<Sink::Preprocessor*>() << new DefaultIndexUpdater<Sink::ApplicationDomain::Folder>); |
58 | auto config = ResourceConfig::getConfiguration(instanceIdentifier); | 58 | auto config = ResourceConfig::getConfiguration(instanceIdentifier); |
59 | mMaildirPath = QDir::cleanPath(QDir::fromNativeSeparators(config.value("path").toString())); | 59 | mMaildirPath = QDir::cleanPath(QDir::fromNativeSeparators(config.value("path").toString())); |
60 | //Chop a trailing slash if necessary | 60 | //Chop a trailing slash if necessary |
@@ -91,7 +91,7 @@ QStringList MaildirResource::listAvailableFolders() | |||
91 | return folderList; | 91 | return folderList; |
92 | } | 92 | } |
93 | 93 | ||
94 | void MaildirResource::synchronizeFolders(Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction) | 94 | void MaildirResource::synchronizeFolders(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction) |
95 | { | 95 | { |
96 | const QByteArray bufferType = ENTITY_TYPE_FOLDER; | 96 | const QByteArray bufferType = ENTITY_TYPE_FOLDER; |
97 | QStringList folderList = listAvailableFolders(); | 97 | QStringList folderList = listAvailableFolders(); |
@@ -102,7 +102,7 @@ void MaildirResource::synchronizeFolders(Akonadi2::Storage::Transaction &transac | |||
102 | //TODO Instead of iterating over all entries in the database, which can also pick up the same item multiple times, | 102 | //TODO Instead of iterating over all entries in the database, which can also pick up the same item multiple times, |
103 | //we should rather iterate over an index that contains every uid exactly once. The remoteId index would be such an index, | 103 | //we should rather iterate over an index that contains every uid exactly once. The remoteId index would be such an index, |
104 | //but we currently fail to iterate over all entries in an index it seems. | 104 | //but we currently fail to iterate over all entries in an index it seems. |
105 | // auto remoteIds = synchronizationTransaction.openDatabase("rid.mapping." + bufferType, std::function<void(const Akonadi2::Storage::Error &)>(), true); | 105 | // auto remoteIds = synchronizationTransaction.openDatabase("rid.mapping." + bufferType, std::function<void(const Sink::Storage::Error &)>(), true); |
106 | auto mainDatabase = transaction.openDatabase(bufferType + ".main"); | 106 | auto mainDatabase = transaction.openDatabase(bufferType + ".main"); |
107 | mainDatabase.scan("", [&](const QByteArray &key, const QByteArray &) { | 107 | mainDatabase.scan("", [&](const QByteArray &key, const QByteArray &) { |
108 | callback(key); | 108 | callback(key); |
@@ -119,7 +119,7 @@ void MaildirResource::synchronizeFolders(Akonadi2::Storage::Transaction &transac | |||
119 | Trace() << "Processing folder " << remoteId; | 119 | Trace() << "Processing folder " << remoteId; |
120 | KPIM::Maildir md(folderPath, folderPath == mMaildirPath); | 120 | KPIM::Maildir md(folderPath, folderPath == mMaildirPath); |
121 | 121 | ||
122 | Akonadi2::ApplicationDomain::Folder folder; | 122 | Sink::ApplicationDomain::Folder folder; |
123 | folder.setProperty("name", md.name()); | 123 | folder.setProperty("name", md.name()); |
124 | folder.setProperty("icon", "folder"); | 124 | folder.setProperty("icon", "folder"); |
125 | if (!md.isRoot()) { | 125 | if (!md.isRoot()) { |
@@ -129,7 +129,7 @@ void MaildirResource::synchronizeFolders(Akonadi2::Storage::Transaction &transac | |||
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | void MaildirResource::synchronizeMails(Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction, const QString &path) | 132 | void MaildirResource::synchronizeMails(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, const QString &path) |
133 | { | 133 | { |
134 | Trace() << "Synchronizing mails" << path; | 134 | Trace() << "Synchronizing mails" << path; |
135 | const QByteArray bufferType = ENTITY_TYPE_MAIL; | 135 | const QByteArray bufferType = ENTITY_TYPE_MAIL; |
@@ -150,8 +150,8 @@ void MaildirResource::synchronizeMails(Akonadi2::Storage::Transaction &transacti | |||
150 | scanForRemovals(transaction, synchronizationTransaction, bufferType, | 150 | scanForRemovals(transaction, synchronizationTransaction, bufferType, |
151 | [&](const std::function<void(const QByteArray &)> &callback) { | 151 | [&](const std::function<void(const QByteArray &)> &callback) { |
152 | Index index(bufferType + ".index." + property, transaction); | 152 | Index index(bufferType + ".index." + property, transaction); |
153 | index.lookup(folderLocalId, [&](const QByteArray &akonadiId) { | 153 | index.lookup(folderLocalId, [&](const QByteArray &sinkId) { |
154 | callback(akonadiId); | 154 | callback(sinkId); |
155 | }, | 155 | }, |
156 | [&](const Index::Error &error) { | 156 | [&](const Index::Error &error) { |
157 | Warning() << "Error in index: " << error.message << property; | 157 | Warning() << "Error in index: " << error.message << property; |
@@ -175,7 +175,7 @@ void MaildirResource::synchronizeMails(Akonadi2::Storage::Transaction &transacti | |||
175 | 175 | ||
176 | Trace() << "Found a mail " << filePath << " : " << fileName << msg->subject(true)->asUnicodeString(); | 176 | Trace() << "Found a mail " << filePath << " : " << fileName << msg->subject(true)->asUnicodeString(); |
177 | 177 | ||
178 | Akonadi2::ApplicationDomain::Mail mail; | 178 | Sink::ApplicationDomain::Mail mail; |
179 | mail.setProperty("subject", msg->subject(true)->asUnicodeString()); | 179 | mail.setProperty("subject", msg->subject(true)->asUnicodeString()); |
180 | mail.setProperty("sender", msg->from(true)->asUnicodeString()); | 180 | mail.setProperty("sender", msg->from(true)->asUnicodeString()); |
181 | mail.setProperty("senderName", msg->from(true)->asUnicodeString()); | 181 | mail.setProperty("senderName", msg->from(true)->asUnicodeString()); |
@@ -189,19 +189,19 @@ void MaildirResource::synchronizeMails(Akonadi2::Storage::Transaction &transacti | |||
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | KAsync::Job<void> MaildirResource::synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore) | 192 | KAsync::Job<void> MaildirResource::synchronizeWithSource(Sink::Storage &mainStore, Sink::Storage &synchronizationStore) |
193 | { | 193 | { |
194 | Log() << " Synchronizing"; | 194 | Log() << " Synchronizing"; |
195 | return KAsync::start<void>([this, &mainStore, &synchronizationStore]() { | 195 | return KAsync::start<void>([this, &mainStore, &synchronizationStore]() { |
196 | auto transaction = mainStore.createTransaction(Akonadi2::Storage::ReadOnly); | 196 | auto transaction = mainStore.createTransaction(Sink::Storage::ReadOnly); |
197 | { | 197 | { |
198 | auto synchronizationTransaction = synchronizationStore.createTransaction(Akonadi2::Storage::ReadWrite); | 198 | auto synchronizationTransaction = synchronizationStore.createTransaction(Sink::Storage::ReadWrite); |
199 | synchronizeFolders(transaction, synchronizationTransaction); | 199 | synchronizeFolders(transaction, synchronizationTransaction); |
200 | //The next sync needs the folders available | 200 | //The next sync needs the folders available |
201 | synchronizationTransaction.commit(); | 201 | synchronizationTransaction.commit(); |
202 | } | 202 | } |
203 | for (const auto &folder : listAvailableFolders()) { | 203 | for (const auto &folder : listAvailableFolders()) { |
204 | auto synchronizationTransaction = synchronizationStore.createTransaction(Akonadi2::Storage::ReadWrite); | 204 | auto synchronizationTransaction = synchronizationStore.createTransaction(Sink::Storage::ReadWrite); |
205 | synchronizeMails(transaction, synchronizationTransaction, folder); | 205 | synchronizeMails(transaction, synchronizationTransaction, folder); |
206 | //Don't let the transaction grow too much | 206 | //Don't let the transaction grow too much |
207 | synchronizationTransaction.commit(); | 207 | synchronizationTransaction.commit(); |
@@ -210,23 +210,23 @@ KAsync::Job<void> MaildirResource::synchronizeWithSource(Akonadi2::Storage &main | |||
210 | }); | 210 | }); |
211 | } | 211 | } |
212 | 212 | ||
213 | KAsync::Job<void> MaildirResource::replay(Akonadi2::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) | 213 | KAsync::Job<void> MaildirResource::replay(Sink::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) |
214 | { | 214 | { |
215 | auto synchronizationTransaction = synchronizationStore.createTransaction(Akonadi2::Storage::ReadWrite); | 215 | auto synchronizationTransaction = synchronizationStore.createTransaction(Sink::Storage::ReadWrite); |
216 | 216 | ||
217 | Trace() << "Replaying " << key << type; | 217 | Trace() << "Replaying " << key << type; |
218 | if (type == ENTITY_TYPE_FOLDER) { | 218 | if (type == ENTITY_TYPE_FOLDER) { |
219 | Akonadi2::EntityBuffer buffer(value.data(), value.size()); | 219 | Sink::EntityBuffer buffer(value.data(), value.size()); |
220 | const Akonadi2::Entity &entity = buffer.entity(); | 220 | const Sink::Entity &entity = buffer.entity(); |
221 | const auto metadataBuffer = Akonadi2::EntityBuffer::readBuffer<Akonadi2::Metadata>(entity.metadata()); | 221 | const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); |
222 | if (metadataBuffer && !metadataBuffer->replayToSource()) { | 222 | if (metadataBuffer && !metadataBuffer->replayToSource()) { |
223 | Trace() << "Change is coming from the source"; | 223 | Trace() << "Change is coming from the source"; |
224 | return KAsync::null<void>(); | 224 | return KAsync::null<void>(); |
225 | } | 225 | } |
226 | const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; | 226 | const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; |
227 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Akonadi2::Operation_Creation; | 227 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; |
228 | if (operation == Akonadi2::Operation_Creation) { | 228 | if (operation == Sink::Operation_Creation) { |
229 | const Akonadi2::ApplicationDomain::Folder folder(mResourceInstanceIdentifier, Akonadi2::Storage::uidFromKey(key), revision, mFolderAdaptorFactory->createAdaptor(entity)); | 229 | const Sink::ApplicationDomain::Folder folder(mResourceInstanceIdentifier, Sink::Storage::uidFromKey(key), revision, mFolderAdaptorFactory->createAdaptor(entity)); |
230 | auto folderName = folder.getProperty("name").toString(); | 230 | auto folderName = folder.getProperty("name").toString(); |
231 | //TODO handle non toplevel folders | 231 | //TODO handle non toplevel folders |
232 | auto path = mMaildirPath + "/" + folderName; | 232 | auto path = mMaildirPath + "/" + folderName; |
@@ -234,31 +234,31 @@ KAsync::Job<void> MaildirResource::replay(Akonadi2::Storage &synchronizationStor | |||
234 | KPIM::Maildir maildir(path, false); | 234 | KPIM::Maildir maildir(path, false); |
235 | maildir.create(); | 235 | maildir.create(); |
236 | recordRemoteId(ENTITY_TYPE_FOLDER, folder.identifier(), path.toUtf8(), synchronizationTransaction); | 236 | recordRemoteId(ENTITY_TYPE_FOLDER, folder.identifier(), path.toUtf8(), synchronizationTransaction); |
237 | } else if (operation == Akonadi2::Operation_Removal) { | 237 | } else if (operation == Sink::Operation_Removal) { |
238 | const auto uid = Akonadi2::Storage::uidFromKey(key); | 238 | const auto uid = Sink::Storage::uidFromKey(key); |
239 | const auto remoteId = resolveLocalId(ENTITY_TYPE_FOLDER, uid, synchronizationTransaction); | 239 | const auto remoteId = resolveLocalId(ENTITY_TYPE_FOLDER, uid, synchronizationTransaction); |
240 | const auto path = remoteId; | 240 | const auto path = remoteId; |
241 | Trace() << "Removing a folder: " << path; | 241 | Trace() << "Removing a folder: " << path; |
242 | KPIM::Maildir maildir(path, false); | 242 | KPIM::Maildir maildir(path, false); |
243 | maildir.remove(); | 243 | maildir.remove(); |
244 | removeRemoteId(ENTITY_TYPE_FOLDER, uid, remoteId, synchronizationTransaction); | 244 | removeRemoteId(ENTITY_TYPE_FOLDER, uid, remoteId, synchronizationTransaction); |
245 | } else if (operation == Akonadi2::Operation_Modification) { | 245 | } else if (operation == Sink::Operation_Modification) { |
246 | Warning() << "Folder modifications are not implemented"; | 246 | Warning() << "Folder modifications are not implemented"; |
247 | } else { | 247 | } else { |
248 | Warning() << "Unkown operation" << operation; | 248 | Warning() << "Unkown operation" << operation; |
249 | } | 249 | } |
250 | } else if (type == ENTITY_TYPE_MAIL) { | 250 | } else if (type == ENTITY_TYPE_MAIL) { |
251 | Akonadi2::EntityBuffer buffer(value.data(), value.size()); | 251 | Sink::EntityBuffer buffer(value.data(), value.size()); |
252 | const Akonadi2::Entity &entity = buffer.entity(); | 252 | const Sink::Entity &entity = buffer.entity(); |
253 | const auto metadataBuffer = Akonadi2::EntityBuffer::readBuffer<Akonadi2::Metadata>(entity.metadata()); | 253 | const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); |
254 | if (metadataBuffer && !metadataBuffer->replayToSource()) { | 254 | if (metadataBuffer && !metadataBuffer->replayToSource()) { |
255 | Trace() << "Change is coming from the source"; | 255 | Trace() << "Change is coming from the source"; |
256 | return KAsync::null<void>(); | 256 | return KAsync::null<void>(); |
257 | } | 257 | } |
258 | const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; | 258 | const qint64 revision = metadataBuffer ? metadataBuffer->revision() : -1; |
259 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Akonadi2::Operation_Creation; | 259 | const auto operation = metadataBuffer ? metadataBuffer->operation() : Sink::Operation_Creation; |
260 | if (operation == Akonadi2::Operation_Creation) { | 260 | if (operation == Sink::Operation_Creation) { |
261 | const Akonadi2::ApplicationDomain::Mail mail(mResourceInstanceIdentifier, Akonadi2::Storage::uidFromKey(key), revision, mMailAdaptorFactory->createAdaptor(entity)); | 261 | const Sink::ApplicationDomain::Mail mail(mResourceInstanceIdentifier, Sink::Storage::uidFromKey(key), revision, mMailAdaptorFactory->createAdaptor(entity)); |
262 | auto parentFolder = mail.getProperty("folder").toByteArray(); | 262 | auto parentFolder = mail.getProperty("folder").toByteArray(); |
263 | QByteArray parentFolderRemoteId; | 263 | QByteArray parentFolderRemoteId; |
264 | if (!parentFolder.isEmpty()) { | 264 | if (!parentFolder.isEmpty()) { |
@@ -272,13 +272,13 @@ KAsync::Job<void> MaildirResource::replay(Akonadi2::Storage &synchronizationStor | |||
272 | const auto id = maildir.addEntry("foobar"); | 272 | const auto id = maildir.addEntry("foobar"); |
273 | Trace() << "Creating a new mail: " << id; | 273 | Trace() << "Creating a new mail: " << id; |
274 | recordRemoteId(ENTITY_TYPE_MAIL, mail.identifier(), id.toUtf8(), synchronizationTransaction); | 274 | recordRemoteId(ENTITY_TYPE_MAIL, mail.identifier(), id.toUtf8(), synchronizationTransaction); |
275 | } else if (operation == Akonadi2::Operation_Removal) { | 275 | } else if (operation == Sink::Operation_Removal) { |
276 | const auto uid = Akonadi2::Storage::uidFromKey(key); | 276 | const auto uid = Sink::Storage::uidFromKey(key); |
277 | const auto remoteId = resolveLocalId(ENTITY_TYPE_MAIL, uid, synchronizationTransaction); | 277 | const auto remoteId = resolveLocalId(ENTITY_TYPE_MAIL, uid, synchronizationTransaction); |
278 | Trace() << "Removing a mail: " << remoteId; | 278 | Trace() << "Removing a mail: " << remoteId; |
279 | QFile::remove(remoteId); | 279 | QFile::remove(remoteId); |
280 | removeRemoteId(ENTITY_TYPE_MAIL, uid, remoteId, synchronizationTransaction); | 280 | removeRemoteId(ENTITY_TYPE_MAIL, uid, remoteId, synchronizationTransaction); |
281 | } else if (operation == Akonadi2::Operation_Modification) { | 281 | } else if (operation == Sink::Operation_Modification) { |
282 | Warning() << "Mail modifications are not implemented"; | 282 | Warning() << "Mail modifications are not implemented"; |
283 | } else { | 283 | } else { |
284 | Warning() << "Unkown operation" << operation; | 284 | Warning() << "Unkown operation" << operation; |
@@ -290,16 +290,16 @@ KAsync::Job<void> MaildirResource::replay(Akonadi2::Storage &synchronizationStor | |||
290 | void MaildirResource::removeFromDisk(const QByteArray &instanceIdentifier) | 290 | void MaildirResource::removeFromDisk(const QByteArray &instanceIdentifier) |
291 | { | 291 | { |
292 | GenericResource::removeFromDisk(instanceIdentifier); | 292 | GenericResource::removeFromDisk(instanceIdentifier); |
293 | Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite).removeFromDisk(); | 293 | Sink::Storage(Sink::storageLocation(), instanceIdentifier + ".synchronization", Sink::Storage::ReadWrite).removeFromDisk(); |
294 | } | 294 | } |
295 | 295 | ||
296 | KAsync::Job<void> MaildirResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) | 296 | KAsync::Job<void> MaildirResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) |
297 | { | 297 | { |
298 | auto synchronizationStore = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadOnly); | 298 | auto synchronizationStore = QSharedPointer<Sink::Storage>::create(Sink::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Sink::Storage::ReadOnly); |
299 | auto synchronizationTransaction = synchronizationStore->createTransaction(Akonadi2::Storage::ReadOnly); | 299 | auto synchronizationTransaction = synchronizationStore->createTransaction(Sink::Storage::ReadOnly); |
300 | Trace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; | 300 | Trace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; |
301 | if (domainType == ENTITY_TYPE_MAIL) { | 301 | if (domainType == ENTITY_TYPE_MAIL) { |
302 | if (inspectionType == Akonadi2::Resources::Inspection::PropertyInspectionType) { | 302 | if (inspectionType == Sink::Resources::Inspection::PropertyInspectionType) { |
303 | if (property == "unread") { | 303 | if (property == "unread") { |
304 | const auto remoteId = resolveLocalId(ENTITY_TYPE_MAIL, entityId, synchronizationTransaction); | 304 | const auto remoteId = resolveLocalId(ENTITY_TYPE_MAIL, entityId, synchronizationTransaction); |
305 | const auto flags = KPIM::Maildir::readEntryFlags(remoteId.split('/').last()); | 305 | const auto flags = KPIM::Maildir::readEntryFlags(remoteId.split('/').last()); |
@@ -312,7 +312,7 @@ KAsync::Job<void> MaildirResource::inspect(int inspectionType, const QByteArray | |||
312 | return KAsync::null<void>(); | 312 | return KAsync::null<void>(); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | if (inspectionType == Akonadi2::Resources::Inspection::ExistenceInspectionType) { | 315 | if (inspectionType == Sink::Resources::Inspection::ExistenceInspectionType) { |
316 | const auto remoteId = resolveLocalId(ENTITY_TYPE_MAIL, entityId, synchronizationTransaction); | 316 | const auto remoteId = resolveLocalId(ENTITY_TYPE_MAIL, entityId, synchronizationTransaction); |
317 | if (QFileInfo(remoteId).exists() != expectedValue.toBool()) { | 317 | if (QFileInfo(remoteId).exists() != expectedValue.toBool()) { |
318 | return KAsync::error<void>(1, "Wrong file existence: " + remoteId); | 318 | return KAsync::error<void>(1, "Wrong file existence: " + remoteId); |
@@ -323,19 +323,19 @@ KAsync::Job<void> MaildirResource::inspect(int inspectionType, const QByteArray | |||
323 | } | 323 | } |
324 | 324 | ||
325 | MaildirResourceFactory::MaildirResourceFactory(QObject *parent) | 325 | MaildirResourceFactory::MaildirResourceFactory(QObject *parent) |
326 | : Akonadi2::ResourceFactory(parent) | 326 | : Sink::ResourceFactory(parent) |
327 | { | 327 | { |
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | Akonadi2::Resource *MaildirResourceFactory::createResource(const QByteArray &instanceIdentifier) | 331 | Sink::Resource *MaildirResourceFactory::createResource(const QByteArray &instanceIdentifier) |
332 | { | 332 | { |
333 | return new MaildirResource(instanceIdentifier); | 333 | return new MaildirResource(instanceIdentifier); |
334 | } | 334 | } |
335 | 335 | ||
336 | void MaildirResourceFactory::registerFacades(Akonadi2::FacadeFactory &factory) | 336 | void MaildirResourceFactory::registerFacades(Sink::FacadeFactory &factory) |
337 | { | 337 | { |
338 | factory.registerFacade<Akonadi2::ApplicationDomain::Mail, MaildirResourceMailFacade>(PLUGIN_NAME); | 338 | factory.registerFacade<Sink::ApplicationDomain::Mail, MaildirResourceMailFacade>(PLUGIN_NAME); |
339 | factory.registerFacade<Akonadi2::ApplicationDomain::Folder, MaildirResourceFolderFacade>(PLUGIN_NAME); | 339 | factory.registerFacade<Sink::ApplicationDomain::Folder, MaildirResourceFolderFacade>(PLUGIN_NAME); |
340 | } | 340 | } |
341 | 341 | ||
diff --git a/examples/maildirresource/maildirresource.h b/examples/maildirresource/maildirresource.h index 5f7795b..9af2f39 100644 --- a/examples/maildirresource/maildirresource.h +++ b/examples/maildirresource/maildirresource.h | |||
@@ -39,34 +39,34 @@ class MaildirFolderAdaptorFactory; | |||
39 | * files: full file path | 39 | * files: full file path |
40 | * directories: full directory path | 40 | * directories: full directory path |
41 | */ | 41 | */ |
42 | class MaildirResource : public Akonadi2::GenericResource | 42 | class MaildirResource : public Sink::GenericResource |
43 | { | 43 | { |
44 | public: | 44 | public: |
45 | MaildirResource(const QByteArray &instanceIdentifier, const QSharedPointer<Akonadi2::Pipeline> &pipeline = QSharedPointer<Akonadi2::Pipeline>()); | 45 | MaildirResource(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::Pipeline> &pipeline = QSharedPointer<Sink::Pipeline>()); |
46 | KAsync::Job<void> synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore) Q_DECL_OVERRIDE; | 46 | KAsync::Job<void> synchronizeWithSource(Sink::Storage &mainStore, Sink::Storage &synchronizationStore) Q_DECL_OVERRIDE; |
47 | KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE; | 47 | KAsync::Job<void> inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE; |
48 | static void removeFromDisk(const QByteArray &instanceIdentifier); | 48 | static void removeFromDisk(const QByteArray &instanceIdentifier); |
49 | private: | 49 | private: |
50 | KAsync::Job<void> replay(Akonadi2::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE; | 50 | KAsync::Job<void> replay(Sink::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE; |
51 | 51 | ||
52 | void synchronizeFolders(Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction); | 52 | void synchronizeFolders(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction); |
53 | void synchronizeMails(Akonadi2::Storage::Transaction &transaction, Akonadi2::Storage::Transaction &synchronizationTransaction, const QString &folder); | 53 | void synchronizeMails(Sink::Storage::Transaction &transaction, Sink::Storage::Transaction &synchronizationTransaction, const QString &folder); |
54 | QStringList listAvailableFolders(); | 54 | QStringList listAvailableFolders(); |
55 | QString mMaildirPath; | 55 | QString mMaildirPath; |
56 | QSharedPointer<MaildirMailAdaptorFactory> mMailAdaptorFactory; | 56 | QSharedPointer<MaildirMailAdaptorFactory> mMailAdaptorFactory; |
57 | QSharedPointer<MaildirFolderAdaptorFactory> mFolderAdaptorFactory; | 57 | QSharedPointer<MaildirFolderAdaptorFactory> mFolderAdaptorFactory; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | class MaildirResourceFactory : public Akonadi2::ResourceFactory | 60 | class MaildirResourceFactory : public Sink::ResourceFactory |
61 | { | 61 | { |
62 | Q_OBJECT | 62 | Q_OBJECT |
63 | Q_PLUGIN_METADATA(IID "org.kde.maildir") | 63 | Q_PLUGIN_METADATA(IID "org.kde.maildir") |
64 | Q_INTERFACES(Akonadi2::ResourceFactory) | 64 | Q_INTERFACES(Sink::ResourceFactory) |
65 | 65 | ||
66 | public: | 66 | public: |
67 | MaildirResourceFactory(QObject *parent = 0); | 67 | MaildirResourceFactory(QObject *parent = 0); |
68 | 68 | ||
69 | Akonadi2::Resource *createResource(const QByteArray &instanceIdentifier) Q_DECL_OVERRIDE; | 69 | Sink::Resource *createResource(const QByteArray &instanceIdentifier) Q_DECL_OVERRIDE; |
70 | void registerFacades(Akonadi2::FacadeFactory &factory) Q_DECL_OVERRIDE; | 70 | void registerFacades(Sink::FacadeFactory &factory) Q_DECL_OVERRIDE; |
71 | }; | 71 | }; |
72 | 72 | ||
diff --git a/sinksh/CMakeLists.txt b/sinksh/CMakeLists.txt new file mode 100644 index 0000000..1489fb3 --- /dev/null +++ b/sinksh/CMakeLists.txt | |||
@@ -0,0 +1,29 @@ | |||
1 | project(sinksh) | ||
2 | |||
3 | find_package(Readline REQUIRED) | ||
4 | |||
5 | |||
6 | set(sink_cli_SRCS | ||
7 | main.cpp | ||
8 | syntaxtree.cpp | ||
9 | syntax_modules/core_syntax.cpp | ||
10 | syntax_modules/sink_list.cpp | ||
11 | syntax_modules/sink_clear.cpp | ||
12 | syntax_modules/sink_count.cpp | ||
13 | syntax_modules/sink_create.cpp | ||
14 | syntax_modules/sink_modify.cpp | ||
15 | syntax_modules/sink_remove.cpp | ||
16 | syntax_modules/sink_stat.cpp | ||
17 | syntax_modules/sink_sync.cpp | ||
18 | sinksh_utils.cpp | ||
19 | repl/repl.cpp | ||
20 | repl/replStates.cpp | ||
21 | state.cpp | ||
22 | utils.cpp) | ||
23 | |||
24 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | ||
25 | |||
26 | add_executable(${PROJECT_NAME} ${sink_cli_SRCS}) | ||
27 | target_link_libraries(${PROJECT_NAME} Qt5::Core ${Readline_LIBRARY} sinkcommon) | ||
28 | install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) | ||
29 | |||
diff --git a/akonadish/TODO b/sinksh/TODO index 93c4ff1..93c4ff1 100644 --- a/akonadish/TODO +++ b/sinksh/TODO | |||
diff --git a/akonadish/main.cpp b/sinksh/main.cpp index 4c00b9b..4c00b9b 100644 --- a/akonadish/main.cpp +++ b/sinksh/main.cpp | |||
diff --git a/akonadish/repl/repl.cpp b/sinksh/repl/repl.cpp index 499a4af..21209fc 100644 --- a/akonadish/repl/repl.cpp +++ b/sinksh/repl/repl.cpp | |||
@@ -71,7 +71,7 @@ Repl::~Repl() | |||
71 | void Repl::printWelcomeBanner() | 71 | void Repl::printWelcomeBanner() |
72 | { | 72 | { |
73 | QTextStream out(stdout); | 73 | QTextStream out(stdout); |
74 | out << QObject::tr("Welcome to the Akonadi2 interative shell!\n"); | 74 | out << QObject::tr("Welcome to the Sink interative shell!\n"); |
75 | out << QObject::tr("Type `help` for information on the available commands.\n"); | 75 | out << QObject::tr("Type `help` for information on the available commands.\n"); |
76 | out.flush(); | 76 | out.flush(); |
77 | } | 77 | } |
diff --git a/akonadish/repl/repl.h b/sinksh/repl/repl.h index d8d2533..d8d2533 100644 --- a/akonadish/repl/repl.h +++ b/sinksh/repl/repl.h | |||
diff --git a/akonadish/repl/replStates.cpp b/sinksh/repl/replStates.cpp index 55fdf39..43b1353 100644 --- a/akonadish/repl/replStates.cpp +++ b/sinksh/repl/replStates.cpp | |||
@@ -31,14 +31,14 @@ | |||
31 | 31 | ||
32 | #include "syntaxtree.h" | 32 | #include "syntaxtree.h" |
33 | 33 | ||
34 | static char *akonadi2_cli_next_tab_complete_match(const char *text, int state); | 34 | static char *sink_cli_next_tab_complete_match(const char *text, int state); |
35 | static char ** akonadi2_cli_tab_completion(const char *text, int start, int end); | 35 | static char ** sink_cli_tab_completion(const char *text, int start, int end); |
36 | 36 | ||
37 | ReadState::ReadState(QState *parent) | 37 | ReadState::ReadState(QState *parent) |
38 | : QState(parent) | 38 | : QState(parent) |
39 | { | 39 | { |
40 | rl_completion_entry_function = akonadi2_cli_next_tab_complete_match; | 40 | rl_completion_entry_function = sink_cli_next_tab_complete_match; |
41 | rl_attempted_completion_function = akonadi2_cli_tab_completion; | 41 | rl_attempted_completion_function = sink_cli_tab_completion; |
42 | } | 42 | } |
43 | 43 | ||
44 | void ReadState::onEntry(QEvent *event) | 44 | void ReadState::onEntry(QEvent *event) |
@@ -140,14 +140,14 @@ void PrintState::onEntry(QEvent *event) | |||
140 | static QStringList tab_completion_full_state; | 140 | static QStringList tab_completion_full_state; |
141 | static bool tab_completion_at_root = false; | 141 | static bool tab_completion_at_root = false; |
142 | 142 | ||
143 | static char **akonadi2_cli_tab_completion(const char *text, int start, int end) | 143 | static char **sink_cli_tab_completion(const char *text, int start, int end) |
144 | { | 144 | { |
145 | tab_completion_at_root = start == 0; | 145 | tab_completion_at_root = start == 0; |
146 | tab_completion_full_state = QString(rl_line_buffer).remove(start, end - start).split(" ", QString::SkipEmptyParts); | 146 | tab_completion_full_state = QString(rl_line_buffer).remove(start, end - start).split(" ", QString::SkipEmptyParts); |
147 | return NULL; | 147 | return NULL; |
148 | } | 148 | } |
149 | 149 | ||
150 | static char *akonadi2_cli_next_tab_complete_match(const char *text, int state) | 150 | static char *sink_cli_next_tab_complete_match(const char *text, int state) |
151 | { | 151 | { |
152 | const QString fragment(text); | 152 | const QString fragment(text); |
153 | Syntax::List nearest = SyntaxTree::self()->nearestSyntax(tab_completion_full_state, fragment); | 153 | Syntax::List nearest = SyntaxTree::self()->nearestSyntax(tab_completion_full_state, fragment); |
diff --git a/akonadish/repl/replStates.h b/sinksh/repl/replStates.h index a0d3f90..a0d3f90 100644 --- a/akonadish/repl/replStates.h +++ b/sinksh/repl/replStates.h | |||
diff --git a/akonadish/akonadish_utils.cpp b/sinksh/sinksh_utils.cpp index 27a863d..fa06b34 100644 --- a/akonadish/akonadish_utils.cpp +++ b/sinksh/sinksh_utils.cpp | |||
@@ -18,13 +18,13 @@ | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "akonadish_utils.h" | 21 | #include "sinksh_utils.h" |
22 | 22 | ||
23 | #include "common/clientapi.h" | 23 | #include "common/clientapi.h" |
24 | 24 | ||
25 | #include "utils.h" | 25 | #include "utils.h" |
26 | 26 | ||
27 | namespace AkonadishUtils | 27 | namespace SinkshUtils |
28 | { | 28 | { |
29 | 29 | ||
30 | static QStringList s_types = QStringList() << "resource" << "folder" << "mail" << "event"; | 30 | static QStringList s_types = QStringList() << "resource" << "folder" << "mail" << "event"; |
@@ -37,27 +37,27 @@ bool isValidStoreType(const QString &type) | |||
37 | StoreBase &getStore(const QString &type) | 37 | StoreBase &getStore(const QString &type) |
38 | { | 38 | { |
39 | if (type == "folder") { | 39 | if (type == "folder") { |
40 | static Store<Akonadi2::ApplicationDomain::Folder> store; | 40 | static Store<Sink::ApplicationDomain::Folder> store; |
41 | return store; | 41 | return store; |
42 | } else if (type == "mail") { | 42 | } else if (type == "mail") { |
43 | static Store<Akonadi2::ApplicationDomain::Mail> store; | 43 | static Store<Sink::ApplicationDomain::Mail> store; |
44 | return store; | 44 | return store; |
45 | } else if (type == "event") { | 45 | } else if (type == "event") { |
46 | static Store<Akonadi2::ApplicationDomain::Event> store; | 46 | static Store<Sink::ApplicationDomain::Event> store; |
47 | return store; | 47 | return store; |
48 | } else if (type == "resource") { | 48 | } else if (type == "resource") { |
49 | static Store<Akonadi2::ApplicationDomain::AkonadiResource> store; | 49 | static Store<Sink::ApplicationDomain::SinkResource> store; |
50 | return store; | 50 | return store; |
51 | } | 51 | } |
52 | 52 | ||
53 | //TODO: reinstate the warning+assert | 53 | //TODO: reinstate the warning+assert |
54 | //Q_ASSERT(false); | 54 | //Q_ASSERT(false); |
55 | //qWarning() << "Trying to get a store that doesn't exist, falling back to event"; | 55 | //qWarning() << "Trying to get a store that doesn't exist, falling back to event"; |
56 | static Store<Akonadi2::ApplicationDomain::Event> store; | 56 | static Store<Sink::ApplicationDomain::Event> store; |
57 | return store; | 57 | return store; |
58 | } | 58 | } |
59 | 59 | ||
60 | QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Akonadi2::Query query) | 60 | QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Sink::Query query) |
61 | { | 61 | { |
62 | if (type == "folder") { | 62 | if (type == "folder") { |
63 | query.requestedProperties << "name" << "parent"; | 63 | query.requestedProperties << "name" << "parent"; |
@@ -76,19 +76,19 @@ QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Akonadi2::Quer | |||
76 | QStringList resourceIds(State &state) | 76 | QStringList resourceIds(State &state) |
77 | { | 77 | { |
78 | QStringList resources; | 78 | QStringList resources; |
79 | Akonadi2::Query query; | 79 | Sink::Query query; |
80 | query.liveQuery = false; | 80 | query.liveQuery = false; |
81 | auto model = AkonadishUtils::loadModel("resource", query); | 81 | auto model = SinkshUtils::loadModel("resource", query); |
82 | 82 | ||
83 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model, &resources] (const QModelIndex &index, int start, int end) mutable { | 83 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model, &resources] (const QModelIndex &index, int start, int end) mutable { |
84 | for (int i = start; i <= end; i++) { | 84 | for (int i = start; i <= end; i++) { |
85 | auto object = model->data(model->index(i, 0, index), Akonadi2::Store::DomainObjectBaseRole).value<Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr>(); | 85 | auto object = model->data(model->index(i, 0, index), Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>(); |
86 | resources << object->identifier(); | 86 | resources << object->identifier(); |
87 | } | 87 | } |
88 | }); | 88 | }); |
89 | 89 | ||
90 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { | 90 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { |
91 | if (roles.contains(Akonadi2::Store::ChildrenFetchedRole)) { | 91 | if (roles.contains(Sink::Store::ChildrenFetchedRole)) { |
92 | state.commandFinished(); | 92 | state.commandFinished(); |
93 | } | 93 | } |
94 | }); | 94 | }); |
@@ -121,7 +121,7 @@ QStringList typeCompleter(const QStringList &commands, const QString &fragment, | |||
121 | QMap<QString, QString> keyValueMapFromArgs(const QStringList &args) | 121 | QMap<QString, QString> keyValueMapFromArgs(const QStringList &args) |
122 | { | 122 | { |
123 | //TODO: this is not the most clever of algorithms. preserved during the port of commands | 123 | //TODO: this is not the most clever of algorithms. preserved during the port of commands |
124 | // from akonadi2_client ... we can probably do better, however ;) | 124 | // from sink_client ... we can probably do better, however ;) |
125 | QMap<QString, QString> map; | 125 | QMap<QString, QString> map; |
126 | for (int i = 0; i + 2 <= args.size(); i += 2) { | 126 | for (int i = 0; i + 2 <= args.size(); i += 2) { |
127 | map.insert(args.at(i), args.at(i + 1)); | 127 | map.insert(args.at(i), args.at(i + 1)); |
diff --git a/sinksh/sinksh_utils.h b/sinksh/sinksh_utils.h new file mode 100644 index 0000000..457f644 --- /dev/null +++ b/sinksh/sinksh_utils.h | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Aaron Seigo <aseigo@kolabsystems.com> | ||
3 | * Copyright (C) 2015 Christian Mollekopf <mollekopf@kolabsystems.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the | ||
17 | * Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #pragma once | ||
22 | |||
23 | #include <QAbstractItemModel> | ||
24 | #include <QSharedPointer> | ||
25 | |||
26 | #include "common/query.h" | ||
27 | #include "common/clientapi.h" | ||
28 | |||
29 | #include "state.h" | ||
30 | |||
31 | namespace SinkshUtils | ||
32 | { | ||
33 | |||
34 | class StoreBase; | ||
35 | |||
36 | bool isValidStoreType(const QString &type); | ||
37 | StoreBase &getStore(const QString &type); | ||
38 | QSharedPointer<QAbstractItemModel> loadModel(const QString &type, Sink::Query query); | ||
39 | QStringList resourceIds(); | ||
40 | QStringList resourceCompleter(const QStringList &, const QString &fragment, State &state); | ||
41 | QStringList resourceOrTypeCompleter(const QStringList &commands, const QString &fragment, State &state); | ||
42 | QStringList typeCompleter(const QStringList &commands, const QString &fragment, State &state); | ||
43 | QMap<QString, QString> keyValueMapFromArgs(const QStringList &args); | ||
44 | |||
45 | /** | ||
46 | * A small abstraction layer to use the sink store with the type available as string. | ||
47 | */ | ||
48 | class StoreBase { | ||
49 | public: | ||
50 | virtual Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject() = 0; | ||
51 | virtual Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) = 0; | ||
52 | virtual KAsync::Job<void> create(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; | ||
53 | virtual KAsync::Job<void> modify(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; | ||
54 | virtual KAsync::Job<void> remove(const Sink::ApplicationDomain::ApplicationDomainType &type) = 0; | ||
55 | virtual QSharedPointer<QAbstractItemModel> loadModel(const Sink::Query &query) = 0; | ||
56 | }; | ||
57 | |||
58 | template <typename T> | ||
59 | class Store : public StoreBase { | ||
60 | public: | ||
61 | Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject() Q_DECL_OVERRIDE { | ||
62 | return T::Ptr::create(); | ||
63 | } | ||
64 | |||
65 | Sink::ApplicationDomain::ApplicationDomainType::Ptr getObject(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier = QByteArray()) Q_DECL_OVERRIDE { | ||
66 | return T::Ptr::create(resourceInstanceIdentifier, identifier, 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | ||
67 | } | ||
68 | |||
69 | KAsync::Job<void> create(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | ||
70 | return Sink::Store::create<T>(*static_cast<const T*>(&type)); | ||
71 | } | ||
72 | |||
73 | KAsync::Job<void> modify(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | ||
74 | return Sink::Store::modify<T>(*static_cast<const T*>(&type)); | ||
75 | } | ||
76 | |||
77 | KAsync::Job<void> remove(const Sink::ApplicationDomain::ApplicationDomainType &type) Q_DECL_OVERRIDE { | ||
78 | return Sink::Store::remove<T>(*static_cast<const T*>(&type)); | ||
79 | } | ||
80 | |||
81 | QSharedPointer<QAbstractItemModel> loadModel(const Sink::Query &query) Q_DECL_OVERRIDE { | ||
82 | return Sink::Store::loadModel<T>(query); | ||
83 | } | ||
84 | }; | ||
85 | |||
86 | |||
87 | } | ||
88 | |||
diff --git a/akonadish/state.cpp b/sinksh/state.cpp index 9fb5bcc..e03bf87 100644 --- a/akonadish/state.cpp +++ b/sinksh/state.cpp | |||
@@ -131,14 +131,14 @@ bool State::commandTiming() const | |||
131 | 131 | ||
132 | void State::setLoggingLevel(const QString &level) const | 132 | void State::setLoggingLevel(const QString &level) const |
133 | { | 133 | { |
134 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::debugLevelFromName(level.toLatin1())); | 134 | Sink::Log::setDebugOutputLevel(Sink::Log::debugLevelFromName(level.toLatin1())); |
135 | } | 135 | } |
136 | 136 | ||
137 | QString State::loggingLevel() const | 137 | QString State::loggingLevel() const |
138 | { | 138 | { |
139 | // do not turn this into a single line return: that core dumps due to allocation of | 139 | // do not turn this into a single line return: that core dumps due to allocation of |
140 | // the byte array in Akonadi2::Log | 140 | // the byte array in Sink::Log |
141 | QByteArray rv = Akonadi2::Log::debugLevelName(Akonadi2::Log::debugOutputLevel()); | 141 | QByteArray rv = Sink::Log::debugLevelName(Sink::Log::debugOutputLevel()); |
142 | return rv.toLower(); | 142 | return rv.toLower(); |
143 | } | 143 | } |
144 | 144 | ||
diff --git a/akonadish/state.h b/sinksh/state.h index 3c4c2c7..3c4c2c7 100644 --- a/akonadish/state.h +++ b/sinksh/state.h | |||
diff --git a/akonadish/syntax_modules/core_syntax.cpp b/sinksh/syntax_modules/core_syntax.cpp index ccf96c1..f5b6274 100644 --- a/akonadish/syntax_modules/core_syntax.cpp +++ b/sinksh/syntax_modules/core_syntax.cpp | |||
@@ -39,7 +39,7 @@ bool showHelp(const QStringList &commands, State &state) | |||
39 | { | 39 | { |
40 | SyntaxTree::Command command = SyntaxTree::self()->match(commands); | 40 | SyntaxTree::Command command = SyntaxTree::self()->match(commands); |
41 | if (commands.isEmpty()) { | 41 | if (commands.isEmpty()) { |
42 | state.printLine(QObject::tr("Welcome to the Akonadi2 command line tool!")); | 42 | state.printLine(QObject::tr("Welcome to the Sink command line tool!")); |
43 | state.printLine(QObject::tr("Top-level commands:")); | 43 | state.printLine(QObject::tr("Top-level commands:")); |
44 | 44 | ||
45 | QSet<QString> sorted; | 45 | QSet<QString> sorted; |
diff --git a/akonadish/syntax_modules/akonadi_clear.cpp b/sinksh/syntax_modules/sink_clear.cpp index d328849..d02c638 100644 --- a/akonadish/syntax_modules/akonadi_clear.cpp +++ b/sinksh/syntax_modules/sink_clear.cpp | |||
@@ -30,18 +30,18 @@ | |||
30 | #include "common/storage.h" | 30 | #include "common/storage.h" |
31 | #include "common/definitions.h" | 31 | #include "common/definitions.h" |
32 | 32 | ||
33 | #include "akonadish_utils.h" | 33 | #include "sinksh_utils.h" |
34 | #include "state.h" | 34 | #include "state.h" |
35 | #include "syntaxtree.h" | 35 | #include "syntaxtree.h" |
36 | 36 | ||
37 | namespace AkonadiClear | 37 | namespace SinkClear |
38 | { | 38 | { |
39 | 39 | ||
40 | bool clear(const QStringList &args, State &state) | 40 | bool clear(const QStringList &args, State &state) |
41 | { | 41 | { |
42 | for (const auto &resource : args) { | 42 | for (const auto &resource : args) { |
43 | state.print(QObject::tr("Removing local cache for '%1' ...").arg(resource)); | 43 | state.print(QObject::tr("Removing local cache for '%1' ...").arg(resource)); |
44 | Akonadi2::Store::removeFromDisk(resource.toLatin1()); | 44 | Sink::Store::removeFromDisk(resource.toLatin1()); |
45 | state.printLine(QObject::tr("done")); | 45 | state.printLine(QObject::tr("done")); |
46 | } | 46 | } |
47 | 47 | ||
@@ -50,12 +50,12 @@ bool clear(const QStringList &args, State &state) | |||
50 | 50 | ||
51 | Syntax::List syntax() | 51 | Syntax::List syntax() |
52 | { | 52 | { |
53 | Syntax clear("clear", QObject::tr("Clears the local cache of one or more resources (be careful!)"), &AkonadiClear::clear); | 53 | Syntax clear("clear", QObject::tr("Clears the local cache of one or more resources (be careful!)"), &SinkClear::clear); |
54 | clear.completer = &AkonadishUtils::resourceCompleter; | 54 | clear.completer = &SinkshUtils::resourceCompleter; |
55 | 55 | ||
56 | return Syntax::List() << clear; | 56 | return Syntax::List() << clear; |
57 | } | 57 | } |
58 | 58 | ||
59 | REGISTER_SYNTAX(AkonadiClear) | 59 | REGISTER_SYNTAX(SinkClear) |
60 | 60 | ||
61 | } | 61 | } |
diff --git a/akonadish/syntax_modules/akonadi_count.cpp b/sinksh/syntax_modules/sink_count.cpp index bb1cd19..fde7c33 100644 --- a/akonadish/syntax_modules/akonadi_count.cpp +++ b/sinksh/syntax_modules/sink_count.cpp | |||
@@ -32,11 +32,11 @@ | |||
32 | #include "common/storage.h" | 32 | #include "common/storage.h" |
33 | #include "common/definitions.h" | 33 | #include "common/definitions.h" |
34 | 34 | ||
35 | #include "akonadish_utils.h" | 35 | #include "sinksh_utils.h" |
36 | #include "state.h" | 36 | #include "state.h" |
37 | #include "syntaxtree.h" | 37 | #include "syntaxtree.h" |
38 | 38 | ||
39 | namespace AkonadiCount | 39 | namespace SinkCount |
40 | { | 40 | { |
41 | 41 | ||
42 | bool count(const QStringList &args, State &state) | 42 | bool count(const QStringList &args, State &state) |
@@ -44,26 +44,26 @@ bool count(const QStringList &args, State &state) | |||
44 | auto resources = args; | 44 | auto resources = args; |
45 | auto type = !resources.isEmpty() ? resources.takeFirst() : QString(); | 45 | auto type = !resources.isEmpty() ? resources.takeFirst() : QString(); |
46 | 46 | ||
47 | if (!type.isEmpty() && !AkonadishUtils::isValidStoreType(type)) { | 47 | if (!type.isEmpty() && !SinkshUtils::isValidStoreType(type)) { |
48 | state.printError(QObject::tr("Unknown type: %1").arg(type)); | 48 | state.printError(QObject::tr("Unknown type: %1").arg(type)); |
49 | return false; | 49 | return false; |
50 | } | 50 | } |
51 | 51 | ||
52 | Akonadi2::Query query; | 52 | Sink::Query query; |
53 | for (const auto &res : resources) { | 53 | for (const auto &res : resources) { |
54 | query.resources << res.toLatin1(); | 54 | query.resources << res.toLatin1(); |
55 | } | 55 | } |
56 | query.liveQuery = false; | 56 | query.liveQuery = false; |
57 | 57 | ||
58 | auto model = AkonadishUtils::loadModel(type, query); | 58 | auto model = SinkshUtils::loadModel(type, query); |
59 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { | 59 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { |
60 | if (roles.contains(Akonadi2::Store::ChildrenFetchedRole)) { | 60 | if (roles.contains(Sink::Store::ChildrenFetchedRole)) { |
61 | state.printLine(QObject::tr("Counted results %1").arg(model->rowCount(QModelIndex()))); | 61 | state.printLine(QObject::tr("Counted results %1").arg(model->rowCount(QModelIndex()))); |
62 | state.commandFinished(); | 62 | state.commandFinished(); |
63 | } | 63 | } |
64 | }); | 64 | }); |
65 | 65 | ||
66 | if (!model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()) { | 66 | if (!model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()) { |
67 | return true; | 67 | return true; |
68 | } | 68 | } |
69 | 69 | ||
@@ -72,12 +72,12 @@ bool count(const QStringList &args, State &state) | |||
72 | 72 | ||
73 | Syntax::List syntax() | 73 | Syntax::List syntax() |
74 | { | 74 | { |
75 | Syntax count("count", QObject::tr("Returns the number of items of a given type in a resource. Usage: count <type> <resource>"), &AkonadiCount::count, Syntax::EventDriven); | 75 | Syntax count("count", QObject::tr("Returns the number of items of a given type in a resource. Usage: count <type> <resource>"), &SinkCount::count, Syntax::EventDriven); |
76 | count.completer = &AkonadishUtils::typeCompleter; | 76 | count.completer = &SinkshUtils::typeCompleter; |
77 | 77 | ||
78 | return Syntax::List() << count; | 78 | return Syntax::List() << count; |
79 | } | 79 | } |
80 | 80 | ||
81 | REGISTER_SYNTAX(AkonadiCount) | 81 | REGISTER_SYNTAX(SinkCount) |
82 | 82 | ||
83 | } | 83 | } |
diff --git a/akonadish/syntax_modules/akonadi_create.cpp b/sinksh/syntax_modules/sink_create.cpp index 377219a..cd2cd80 100644 --- a/akonadish/syntax_modules/akonadi_create.cpp +++ b/sinksh/syntax_modules/sink_create.cpp | |||
@@ -32,33 +32,33 @@ | |||
32 | #include "common/storage.h" | 32 | #include "common/storage.h" |
33 | #include "common/definitions.h" | 33 | #include "common/definitions.h" |
34 | 34 | ||
35 | #include "akonadish_utils.h" | 35 | #include "sinksh_utils.h" |
36 | #include "state.h" | 36 | #include "state.h" |
37 | #include "syntaxtree.h" | 37 | #include "syntaxtree.h" |
38 | 38 | ||
39 | namespace AkonadiCreate | 39 | namespace SinkCreate |
40 | { | 40 | { |
41 | 41 | ||
42 | bool create(const QStringList &allArgs, State &state) | 42 | bool create(const QStringList &allArgs, State &state) |
43 | { | 43 | { |
44 | if (allArgs.isEmpty()) { | 44 | if (allArgs.isEmpty()) { |
45 | state.printError(QObject::tr("A type is required"), "akonadicreate/02"); | 45 | state.printError(QObject::tr("A type is required"), "sinkcreate/02"); |
46 | return false; | 46 | return false; |
47 | } | 47 | } |
48 | 48 | ||
49 | if (allArgs.count() < 2) { | 49 | if (allArgs.count() < 2) { |
50 | state.printError(QObject::tr("A resource ID is required to create items"), "akonadicreate/03"); | 50 | state.printError(QObject::tr("A resource ID is required to create items"), "sinkcreate/03"); |
51 | return false; | 51 | return false; |
52 | } | 52 | } |
53 | 53 | ||
54 | auto args = allArgs; | 54 | auto args = allArgs; |
55 | auto type = args.takeFirst(); | 55 | auto type = args.takeFirst(); |
56 | auto &store = AkonadishUtils::getStore(type); | 56 | auto &store = SinkshUtils::getStore(type); |
57 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object; | 57 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object; |
58 | auto resource = args.takeFirst().toLatin1(); | 58 | auto resource = args.takeFirst().toLatin1(); |
59 | object = store.getObject(resource); | 59 | object = store.getObject(resource); |
60 | 60 | ||
61 | auto map = AkonadishUtils::keyValueMapFromArgs(args); | 61 | auto map = SinkshUtils::keyValueMapFromArgs(args); |
62 | for (auto i = map.begin(); i != map.end(); ++i) { | 62 | for (auto i = map.begin(); i != map.end(); ++i) { |
63 | object->setProperty(i.key().toLatin1(), i.value()); | 63 | object->setProperty(i.key().toLatin1(), i.value()); |
64 | } | 64 | } |
@@ -76,17 +76,17 @@ bool create(const QStringList &allArgs, State &state) | |||
76 | bool resource(const QStringList &args, State &state) | 76 | bool resource(const QStringList &args, State &state) |
77 | { | 77 | { |
78 | if (args.isEmpty()) { | 78 | if (args.isEmpty()) { |
79 | state.printError(QObject::tr("A resource can not be created without a type"), "akonadicreate/01"); | 79 | state.printError(QObject::tr("A resource can not be created without a type"), "sinkcreate/01"); |
80 | return false; | 80 | return false; |
81 | } | 81 | } |
82 | 82 | ||
83 | auto &store = AkonadishUtils::getStore("resource"); | 83 | auto &store = SinkshUtils::getStore("resource"); |
84 | 84 | ||
85 | auto resourceType = args.at(0); | 85 | auto resourceType = args.at(0); |
86 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject(""); | 86 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject(""); |
87 | object->setProperty("type", resourceType); | 87 | object->setProperty("type", resourceType); |
88 | 88 | ||
89 | auto map = AkonadishUtils::keyValueMapFromArgs(args); | 89 | auto map = SinkshUtils::keyValueMapFromArgs(args); |
90 | for (auto i = map.begin(); i != map.end(); ++i) { | 90 | for (auto i = map.begin(); i != map.end(); ++i) { |
91 | object->setProperty(i.key().toLatin1(), i.value()); | 91 | object->setProperty(i.key().toLatin1(), i.value()); |
92 | } | 92 | } |
@@ -106,13 +106,13 @@ Syntax::List syntax() | |||
106 | { | 106 | { |
107 | Syntax::List syntax; | 107 | Syntax::List syntax; |
108 | 108 | ||
109 | Syntax create("create", QObject::tr("Create items in a resource"), &AkonadiCreate::create); | 109 | Syntax create("create", QObject::tr("Create items in a resource"), &SinkCreate::create); |
110 | create.children << Syntax("resource", QObject::tr("Creates a new resource"), &AkonadiCreate::resource); | 110 | create.children << Syntax("resource", QObject::tr("Creates a new resource"), &SinkCreate::resource); |
111 | 111 | ||
112 | syntax << create; | 112 | syntax << create; |
113 | return syntax; | 113 | return syntax; |
114 | } | 114 | } |
115 | 115 | ||
116 | REGISTER_SYNTAX(AkonadiCreate) | 116 | REGISTER_SYNTAX(SinkCreate) |
117 | 117 | ||
118 | } | 118 | } |
diff --git a/akonadish/syntax_modules/akonadi_list.cpp b/sinksh/syntax_modules/sink_list.cpp index 7709d3b..9712b6f 100644 --- a/akonadish/syntax_modules/akonadi_list.cpp +++ b/sinksh/syntax_modules/sink_list.cpp | |||
@@ -32,11 +32,11 @@ | |||
32 | #include "common/storage.h" | 32 | #include "common/storage.h" |
33 | #include "common/definitions.h" | 33 | #include "common/definitions.h" |
34 | 34 | ||
35 | #include "akonadish_utils.h" | 35 | #include "sinksh_utils.h" |
36 | #include "state.h" | 36 | #include "state.h" |
37 | #include "syntaxtree.h" | 37 | #include "syntaxtree.h" |
38 | 38 | ||
39 | namespace AkonadiList | 39 | namespace SinkList |
40 | { | 40 | { |
41 | 41 | ||
42 | bool list(const QStringList &args, State &state) | 42 | bool list(const QStringList &args, State &state) |
@@ -49,12 +49,12 @@ bool list(const QStringList &args, State &state) | |||
49 | auto resources = args; | 49 | auto resources = args; |
50 | auto type = !resources.isEmpty() ? resources.takeFirst() : QString(); | 50 | auto type = !resources.isEmpty() ? resources.takeFirst() : QString(); |
51 | 51 | ||
52 | if (!type.isEmpty() && !AkonadishUtils::isValidStoreType(type)) { | 52 | if (!type.isEmpty() && !SinkshUtils::isValidStoreType(type)) { |
53 | state.printError(QObject::tr("Unknown type: %1").arg(type)); | 53 | state.printError(QObject::tr("Unknown type: %1").arg(type)); |
54 | return false; | 54 | return false; |
55 | } | 55 | } |
56 | 56 | ||
57 | Akonadi2::Query query; | 57 | Sink::Query query; |
58 | for (const auto &res : resources) { | 58 | for (const auto &res : resources) { |
59 | query.resources << res.toLatin1(); | 59 | query.resources << res.toLatin1(); |
60 | } | 60 | } |
@@ -62,7 +62,7 @@ bool list(const QStringList &args, State &state) | |||
62 | 62 | ||
63 | QTime time; | 63 | QTime time; |
64 | time.start(); | 64 | time.start(); |
65 | auto model = AkonadishUtils::loadModel(type, query); | 65 | auto model = SinkshUtils::loadModel(type, query); |
66 | if (state.debugLevel() > 0) { | 66 | if (state.debugLevel() > 0) { |
67 | state.printLine(QObject::tr("Folder type %1").arg(type)); | 67 | state.printLine(QObject::tr("Folder type %1").arg(type)); |
68 | state.printLine(QObject::tr("Loaded model in %1 ms").arg(time.elapsed())); | 68 | state.printLine(QObject::tr("Loaded model in %1 ms").arg(time.elapsed())); |
@@ -79,7 +79,7 @@ bool list(const QStringList &args, State &state) | |||
79 | 79 | ||
80 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model, colSize, state](const QModelIndex &index, int start, int end) { | 80 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model, colSize, state](const QModelIndex &index, int start, int end) { |
81 | for (int i = start; i <= end; i++) { | 81 | for (int i = start; i <= end; i++) { |
82 | auto object = model->data(model->index(i, 0, index), Akonadi2::Store::DomainObjectBaseRole).value<Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr>(); | 82 | auto object = model->data(model->index(i, 0, index), Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>(); |
83 | state.print(object->resourceInstanceIdentifier().leftJustified(colSize, ' ', true)); | 83 | state.print(object->resourceInstanceIdentifier().leftJustified(colSize, ' ', true)); |
84 | state.print(object->identifier().leftJustified(colSize, ' ', true)); | 84 | state.print(object->identifier().leftJustified(colSize, ' ', true)); |
85 | for (int col = 0; col < model->columnCount(QModelIndex()); col++) { | 85 | for (int col = 0; col < model->columnCount(QModelIndex()); col++) { |
@@ -90,12 +90,12 @@ bool list(const QStringList &args, State &state) | |||
90 | }); | 90 | }); |
91 | 91 | ||
92 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { | 92 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { |
93 | if (roles.contains(Akonadi2::Store::ChildrenFetchedRole)) { | 93 | if (roles.contains(Sink::Store::ChildrenFetchedRole)) { |
94 | state.commandFinished(); | 94 | state.commandFinished(); |
95 | } | 95 | } |
96 | }); | 96 | }); |
97 | 97 | ||
98 | if (!model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()) { | 98 | if (!model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()) { |
99 | return true; | 99 | return true; |
100 | } | 100 | } |
101 | 101 | ||
@@ -104,11 +104,11 @@ bool list(const QStringList &args, State &state) | |||
104 | 104 | ||
105 | Syntax::List syntax() | 105 | Syntax::List syntax() |
106 | { | 106 | { |
107 | Syntax list("list", QObject::tr("List all resources, or the contents of one or more resources"), &AkonadiList::list, Syntax::EventDriven); | 107 | Syntax list("list", QObject::tr("List all resources, or the contents of one or more resources"), &SinkList::list, Syntax::EventDriven); |
108 | list.completer = &AkonadishUtils::resourceOrTypeCompleter; | 108 | list.completer = &SinkshUtils::resourceOrTypeCompleter; |
109 | return Syntax::List() << list; | 109 | return Syntax::List() << list; |
110 | } | 110 | } |
111 | 111 | ||
112 | REGISTER_SYNTAX(AkonadiList) | 112 | REGISTER_SYNTAX(SinkList) |
113 | 113 | ||
114 | } | 114 | } |
diff --git a/akonadish/syntax_modules/akonadi_modify.cpp b/sinksh/syntax_modules/sink_modify.cpp index 76a7f5e..4d637d8 100644 --- a/akonadish/syntax_modules/akonadi_modify.cpp +++ b/sinksh/syntax_modules/sink_modify.cpp | |||
@@ -32,27 +32,27 @@ | |||
32 | #include "common/storage.h" | 32 | #include "common/storage.h" |
33 | #include "common/definitions.h" | 33 | #include "common/definitions.h" |
34 | 34 | ||
35 | #include "akonadish_utils.h" | 35 | #include "sinksh_utils.h" |
36 | #include "state.h" | 36 | #include "state.h" |
37 | #include "syntaxtree.h" | 37 | #include "syntaxtree.h" |
38 | 38 | ||
39 | namespace AkonadiModify | 39 | namespace SinkModify |
40 | { | 40 | { |
41 | 41 | ||
42 | bool modify(const QStringList &args, State &state) | 42 | bool modify(const QStringList &args, State &state) |
43 | { | 43 | { |
44 | if (args.isEmpty()) { | 44 | if (args.isEmpty()) { |
45 | state.printError(QObject::tr("A type is required"), "akonadi_modify/02"); | 45 | state.printError(QObject::tr("A type is required"), "sink_modify/02"); |
46 | return false; | 46 | return false; |
47 | } | 47 | } |
48 | 48 | ||
49 | if (args.count() < 2) { | 49 | if (args.count() < 2) { |
50 | state.printError(QObject::tr("A resource ID is required to remove items"), "akonadi_modify/03"); | 50 | state.printError(QObject::tr("A resource ID is required to remove items"), "sink_modify/03"); |
51 | return false; | 51 | return false; |
52 | } | 52 | } |
53 | 53 | ||
54 | if (args.count() < 3) { | 54 | if (args.count() < 3) { |
55 | state.printError(QObject::tr("An object ID is required to remove items"), "akonadi_modify/03"); | 55 | state.printError(QObject::tr("An object ID is required to remove items"), "sink_modify/03"); |
56 | return false; | 56 | return false; |
57 | } | 57 | } |
58 | 58 | ||
@@ -60,10 +60,10 @@ bool modify(const QStringList &args, State &state) | |||
60 | auto resourceId = args[1]; | 60 | auto resourceId = args[1]; |
61 | auto identifier = args[2]; | 61 | auto identifier = args[2]; |
62 | 62 | ||
63 | auto &store = AkonadishUtils::getStore(type); | 63 | auto &store = SinkshUtils::getStore(type); |
64 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject(resourceId.toUtf8(), identifier.toUtf8()); | 64 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject(resourceId.toUtf8(), identifier.toUtf8()); |
65 | 65 | ||
66 | auto map = AkonadishUtils::keyValueMapFromArgs(args); | 66 | auto map = SinkshUtils::keyValueMapFromArgs(args); |
67 | for (auto i = map.begin(); i != map.end(); ++i) { | 67 | for (auto i = map.begin(); i != map.end(); ++i) { |
68 | object->setProperty(i.key().toLatin1(), i.value()); | 68 | object->setProperty(i.key().toLatin1(), i.value()); |
69 | } | 69 | } |
@@ -81,15 +81,15 @@ bool modify(const QStringList &args, State &state) | |||
81 | bool resource(const QStringList &args, State &state) | 81 | bool resource(const QStringList &args, State &state) |
82 | { | 82 | { |
83 | if (args.isEmpty()) { | 83 | if (args.isEmpty()) { |
84 | state.printError(QObject::tr("A resource can not be modified without an id"), "akonadi_modify/01"); | 84 | state.printError(QObject::tr("A resource can not be modified without an id"), "sink_modify/01"); |
85 | } | 85 | } |
86 | 86 | ||
87 | auto &store = AkonadishUtils::getStore("resource"); | 87 | auto &store = SinkshUtils::getStore("resource"); |
88 | 88 | ||
89 | auto resourceId = args.at(0); | 89 | auto resourceId = args.at(0); |
90 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject("", resourceId.toLatin1()); | 90 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject("", resourceId.toLatin1()); |
91 | 91 | ||
92 | auto map = AkonadishUtils::keyValueMapFromArgs(args); | 92 | auto map = SinkshUtils::keyValueMapFromArgs(args); |
93 | for (auto i = map.begin(); i != map.end(); ++i) { | 93 | for (auto i = map.begin(); i != map.end(); ++i) { |
94 | object->setProperty(i.key().toLatin1(), i.value()); | 94 | object->setProperty(i.key().toLatin1(), i.value()); |
95 | } | 95 | } |
@@ -107,14 +107,14 @@ bool resource(const QStringList &args, State &state) | |||
107 | 107 | ||
108 | Syntax::List syntax() | 108 | Syntax::List syntax() |
109 | { | 109 | { |
110 | Syntax modify("modify", QObject::tr("Modify items in a resource"), &AkonadiModify::modify); | 110 | Syntax modify("modify", QObject::tr("Modify items in a resource"), &SinkModify::modify); |
111 | Syntax resource("resource", QObject::tr("Modify a resource"), &AkonadiModify::resource);//, Syntax::EventDriven); | 111 | Syntax resource("resource", QObject::tr("Modify a resource"), &SinkModify::resource);//, Syntax::EventDriven); |
112 | resource.completer = &AkonadishUtils::resourceOrTypeCompleter; | 112 | resource.completer = &SinkshUtils::resourceOrTypeCompleter; |
113 | modify.children << resource; | 113 | modify.children << resource; |
114 | 114 | ||
115 | return Syntax::List() << modify; | 115 | return Syntax::List() << modify; |
116 | } | 116 | } |
117 | 117 | ||
118 | REGISTER_SYNTAX(AkonadiModify) | 118 | REGISTER_SYNTAX(SinkModify) |
119 | 119 | ||
120 | } | 120 | } |
diff --git a/akonadish/syntax_modules/akonadi_remove.cpp b/sinksh/syntax_modules/sink_remove.cpp index 9691d78..b374824 100644 --- a/akonadish/syntax_modules/akonadi_remove.cpp +++ b/sinksh/syntax_modules/sink_remove.cpp | |||
@@ -32,27 +32,27 @@ | |||
32 | #include "common/storage.h" | 32 | #include "common/storage.h" |
33 | #include "common/definitions.h" | 33 | #include "common/definitions.h" |
34 | 34 | ||
35 | #include "akonadish_utils.h" | 35 | #include "sinksh_utils.h" |
36 | #include "state.h" | 36 | #include "state.h" |
37 | #include "syntaxtree.h" | 37 | #include "syntaxtree.h" |
38 | 38 | ||
39 | namespace AkonadiRemove | 39 | namespace SinkRemove |
40 | { | 40 | { |
41 | 41 | ||
42 | bool remove(const QStringList &args, State &state) | 42 | bool remove(const QStringList &args, State &state) |
43 | { | 43 | { |
44 | if (args.isEmpty()) { | 44 | if (args.isEmpty()) { |
45 | state.printError(QObject::tr("A type is required"), "akonadi_remove/02"); | 45 | state.printError(QObject::tr("A type is required"), "sink_remove/02"); |
46 | return false; | 46 | return false; |
47 | } | 47 | } |
48 | 48 | ||
49 | if (args.count() < 2) { | 49 | if (args.count() < 2) { |
50 | state.printError(QObject::tr("A resource ID is required to remove items"), "akonadi_remove/03"); | 50 | state.printError(QObject::tr("A resource ID is required to remove items"), "sink_remove/03"); |
51 | return false; | 51 | return false; |
52 | } | 52 | } |
53 | 53 | ||
54 | if (args.count() < 3) { | 54 | if (args.count() < 3) { |
55 | state.printError(QObject::tr("An object ID is required to remove items"), "akonadi_remove/03"); | 55 | state.printError(QObject::tr("An object ID is required to remove items"), "sink_remove/03"); |
56 | return false; | 56 | return false; |
57 | } | 57 | } |
58 | 58 | ||
@@ -60,8 +60,8 @@ bool remove(const QStringList &args, State &state) | |||
60 | auto resourceId = args[1]; | 60 | auto resourceId = args[1]; |
61 | auto identifier = args[2]; | 61 | auto identifier = args[2]; |
62 | 62 | ||
63 | auto &store = AkonadishUtils::getStore(type); | 63 | auto &store = SinkshUtils::getStore(type); |
64 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject(resourceId.toUtf8(), identifier.toUtf8()); | 64 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject(resourceId.toUtf8(), identifier.toUtf8()); |
65 | 65 | ||
66 | auto result = store.remove(*object).exec(); | 66 | auto result = store.remove(*object).exec(); |
67 | result.waitForFinished(); | 67 | result.waitForFinished(); |
@@ -76,13 +76,13 @@ bool remove(const QStringList &args, State &state) | |||
76 | bool resource(const QStringList &args, State &state) | 76 | bool resource(const QStringList &args, State &state) |
77 | { | 77 | { |
78 | if (args.isEmpty()) { | 78 | if (args.isEmpty()) { |
79 | state.printError(QObject::tr("A resource can not be removed without an id"), "akonadi_remove/01"); | 79 | state.printError(QObject::tr("A resource can not be removed without an id"), "sink_remove/01"); |
80 | } | 80 | } |
81 | 81 | ||
82 | auto &store = AkonadishUtils::getStore("resource"); | 82 | auto &store = SinkshUtils::getStore("resource"); |
83 | 83 | ||
84 | auto resourceId = args.at(0); | 84 | auto resourceId = args.at(0); |
85 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject("", resourceId.toLatin1()); | 85 | Sink::ApplicationDomain::ApplicationDomainType::Ptr object = store.getObject("", resourceId.toLatin1()); |
86 | 86 | ||
87 | auto result = store.remove(*object).exec(); | 87 | auto result = store.remove(*object).exec(); |
88 | result.waitForFinished(); | 88 | result.waitForFinished(); |
@@ -97,14 +97,14 @@ bool resource(const QStringList &args, State &state) | |||
97 | 97 | ||
98 | Syntax::List syntax() | 98 | Syntax::List syntax() |
99 | { | 99 | { |
100 | Syntax remove("remove", QObject::tr("Remove items in a resource"), &AkonadiRemove::remove); | 100 | Syntax remove("remove", QObject::tr("Remove items in a resource"), &SinkRemove::remove); |
101 | Syntax resource("resource", QObject::tr("Removes a resource"), &AkonadiRemove::resource);//, Syntax::EventDriven); | 101 | Syntax resource("resource", QObject::tr("Removes a resource"), &SinkRemove::resource);//, Syntax::EventDriven); |
102 | resource.completer = &AkonadishUtils::resourceCompleter; | 102 | resource.completer = &SinkshUtils::resourceCompleter; |
103 | remove.children << resource; | 103 | remove.children << resource; |
104 | 104 | ||
105 | return Syntax::List() << remove; | 105 | return Syntax::List() << remove; |
106 | } | 106 | } |
107 | 107 | ||
108 | REGISTER_SYNTAX(AkonadiRemove) | 108 | REGISTER_SYNTAX(SinkRemove) |
109 | 109 | ||
110 | } | 110 | } |
diff --git a/akonadish/syntax_modules/akonadi_stat.cpp b/sinksh/syntax_modules/sink_stat.cpp index d10556f..06586d9 100644 --- a/akonadish/syntax_modules/akonadi_stat.cpp +++ b/sinksh/syntax_modules/sink_stat.cpp | |||
@@ -31,19 +31,19 @@ | |||
31 | #include "common/storage.h" | 31 | #include "common/storage.h" |
32 | #include "common/definitions.h" | 32 | #include "common/definitions.h" |
33 | 33 | ||
34 | #include "akonadish_utils.h" | 34 | #include "sinksh_utils.h" |
35 | #include "state.h" | 35 | #include "state.h" |
36 | #include "syntaxtree.h" | 36 | #include "syntaxtree.h" |
37 | 37 | ||
38 | namespace AkonadiStat | 38 | namespace SinkStat |
39 | { | 39 | { |
40 | 40 | ||
41 | void statResources(const QStringList &resources, const State &state) | 41 | void statResources(const QStringList &resources, const State &state) |
42 | { | 42 | { |
43 | qint64 total = 0; | 43 | qint64 total = 0; |
44 | for (const auto &resource : resources) { | 44 | for (const auto &resource : resources) { |
45 | Akonadi2::Storage storage(Akonadi2::storageLocation(), resource, Akonadi2::Storage::ReadOnly); | 45 | Sink::Storage storage(Sink::storageLocation(), resource, Sink::Storage::ReadOnly); |
46 | auto transaction = storage.createTransaction(Akonadi2::Storage::ReadOnly); | 46 | auto transaction = storage.createTransaction(Sink::Storage::ReadOnly); |
47 | 47 | ||
48 | QList<QByteArray> databases = transaction.getDatabaseNames(); | 48 | QList<QByteArray> databases = transaction.getDatabaseNames(); |
49 | for (const auto &databaseName : databases) { | 49 | for (const auto &databaseName : databases) { |
@@ -55,9 +55,9 @@ void statResources(const QStringList &resources, const State &state) | |||
55 | } | 55 | } |
56 | int diskUsage = 0; | 56 | int diskUsage = 0; |
57 | 57 | ||
58 | QDir dir(Akonadi2::storageLocation()); | 58 | QDir dir(Sink::storageLocation()); |
59 | for (const auto &folder : dir.entryList(QStringList() << resource + "*")) { | 59 | for (const auto &folder : dir.entryList(QStringList() << resource + "*")) { |
60 | diskUsage += Akonadi2::Storage(Akonadi2::storageLocation(), folder, Akonadi2::Storage::ReadOnly).diskUsage(); | 60 | diskUsage += Sink::Storage(Sink::storageLocation(), folder, Sink::Storage::ReadOnly).diskUsage(); |
61 | } | 61 | } |
62 | auto size = diskUsage / 1024; | 62 | auto size = diskUsage / 1024; |
63 | state.printLine(QObject::tr("Disk usage [kb]: %1").arg(size), 1); | 63 | state.printLine(QObject::tr("Disk usage [kb]: %1").arg(size), 1); |
@@ -68,9 +68,9 @@ void statResources(const QStringList &resources, const State &state) | |||
68 | 68 | ||
69 | bool statAllResources(State &state) | 69 | bool statAllResources(State &state) |
70 | { | 70 | { |
71 | Akonadi2::Query query; | 71 | Sink::Query query; |
72 | query.liveQuery = false; | 72 | query.liveQuery = false; |
73 | auto model = AkonadishUtils::loadModel("resource", query); | 73 | auto model = SinkshUtils::loadModel("resource", query); |
74 | 74 | ||
75 | //SUUUPER ugly, but can't think of a better way with 2 glasses of wine in me on Christmas day | 75 | //SUUUPER ugly, but can't think of a better way with 2 glasses of wine in me on Christmas day |
76 | static QStringList resources; | 76 | static QStringList resources; |
@@ -78,19 +78,19 @@ bool statAllResources(State &state) | |||
78 | 78 | ||
79 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model](const QModelIndex &index, int start, int end) mutable { | 79 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [model](const QModelIndex &index, int start, int end) mutable { |
80 | for (int i = start; i <= end; i++) { | 80 | for (int i = start; i <= end; i++) { |
81 | auto object = model->data(model->index(i, 0, index), Akonadi2::Store::DomainObjectBaseRole).value<Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr>(); | 81 | auto object = model->data(model->index(i, 0, index), Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>(); |
82 | resources << object->identifier(); | 82 | resources << object->identifier(); |
83 | } | 83 | } |
84 | }); | 84 | }); |
85 | 85 | ||
86 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { | 86 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [model, state](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { |
87 | if (roles.contains(Akonadi2::Store::ChildrenFetchedRole)) { | 87 | if (roles.contains(Sink::Store::ChildrenFetchedRole)) { |
88 | statResources(resources, state); | 88 | statResources(resources, state); |
89 | state.commandFinished(); | 89 | state.commandFinished(); |
90 | } | 90 | } |
91 | }); | 91 | }); |
92 | 92 | ||
93 | if (!model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()) { | 93 | if (!model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()) { |
94 | return true; | 94 | return true; |
95 | } | 95 | } |
96 | 96 | ||
@@ -109,12 +109,12 @@ bool stat(const QStringList &args, State &state) | |||
109 | 109 | ||
110 | Syntax::List syntax() | 110 | Syntax::List syntax() |
111 | { | 111 | { |
112 | Syntax state("stat", QObject::tr("Shows database usage for the resources requested"), &AkonadiStat::stat, Syntax::EventDriven); | 112 | Syntax state("stat", QObject::tr("Shows database usage for the resources requested"), &SinkStat::stat, Syntax::EventDriven); |
113 | state.completer = &AkonadishUtils::resourceCompleter; | 113 | state.completer = &SinkshUtils::resourceCompleter; |
114 | 114 | ||
115 | return Syntax::List() << state; | 115 | return Syntax::List() << state; |
116 | } | 116 | } |
117 | 117 | ||
118 | REGISTER_SYNTAX(AkonadiStat) | 118 | REGISTER_SYNTAX(SinkStat) |
119 | 119 | ||
120 | } | 120 | } |
diff --git a/akonadish/syntax_modules/akonadi_sync.cpp b/sinksh/syntax_modules/sink_sync.cpp index 0c994d0..3006202 100644 --- a/akonadish/syntax_modules/akonadi_sync.cpp +++ b/sinksh/syntax_modules/sink_sync.cpp | |||
@@ -30,22 +30,22 @@ | |||
30 | #include "common/storage.h" | 30 | #include "common/storage.h" |
31 | #include "common/definitions.h" | 31 | #include "common/definitions.h" |
32 | 32 | ||
33 | #include "akonadish_utils.h" | 33 | #include "sinksh_utils.h" |
34 | #include "state.h" | 34 | #include "state.h" |
35 | #include "syntaxtree.h" | 35 | #include "syntaxtree.h" |
36 | 36 | ||
37 | namespace AkonadiSync | 37 | namespace SinkSync |
38 | { | 38 | { |
39 | 39 | ||
40 | bool sync(const QStringList &args, State &state) | 40 | bool sync(const QStringList &args, State &state) |
41 | { | 41 | { |
42 | Akonadi2::Query query; | 42 | Sink::Query query; |
43 | for (const auto &res : args) { | 43 | for (const auto &res : args) { |
44 | query.resources << res.toLatin1(); | 44 | query.resources << res.toLatin1(); |
45 | } | 45 | } |
46 | 46 | ||
47 | QTimer::singleShot(0, [query, state]() { | 47 | QTimer::singleShot(0, [query, state]() { |
48 | Akonadi2::Store::synchronize(query).then<void>([state]() { | 48 | Sink::Store::synchronize(query).then<void>([state]() { |
49 | state.printLine("Synchronization complete!"); | 49 | state.printLine("Synchronization complete!"); |
50 | state.commandFinished(); | 50 | state.commandFinished(); |
51 | }).exec(); | 51 | }).exec(); |
@@ -56,12 +56,12 @@ bool sync(const QStringList &args, State &state) | |||
56 | 56 | ||
57 | Syntax::List syntax() | 57 | Syntax::List syntax() |
58 | { | 58 | { |
59 | Syntax sync("sync", QObject::tr("Syncronizes all resources that are listed; and empty list triggers a syncronizaton on all resources"), &AkonadiSync::sync, Syntax::EventDriven ); | 59 | Syntax sync("sync", QObject::tr("Syncronizes all resources that are listed; and empty list triggers a syncronizaton on all resources"), &SinkSync::sync, Syntax::EventDriven ); |
60 | sync.completer = &AkonadishUtils::resourceCompleter; | 60 | sync.completer = &SinkshUtils::resourceCompleter; |
61 | 61 | ||
62 | return Syntax::List() << sync; | 62 | return Syntax::List() << sync; |
63 | } | 63 | } |
64 | 64 | ||
65 | REGISTER_SYNTAX(AkonadiSync) | 65 | REGISTER_SYNTAX(SinkSync) |
66 | 66 | ||
67 | } | 67 | } |
diff --git a/akonadish/syntaxtree.cpp b/sinksh/syntaxtree.cpp index 4860582..4860582 100644 --- a/akonadish/syntaxtree.cpp +++ b/sinksh/syntaxtree.cpp | |||
diff --git a/akonadish/syntaxtree.h b/sinksh/syntaxtree.h index 468aad3..468aad3 100644 --- a/akonadish/syntaxtree.h +++ b/sinksh/syntaxtree.h | |||
diff --git a/akonadish/utils.cpp b/sinksh/utils.cpp index d2a28ed..d2a28ed 100644 --- a/akonadish/utils.cpp +++ b/sinksh/utils.cpp | |||
diff --git a/akonadish/utils.h b/sinksh/utils.h index 82be8d5..82be8d5 100644 --- a/akonadish/utils.h +++ b/sinksh/utils.h | |||
diff --git a/synchronizer/CMakeLists.txt b/synchronizer/CMakeLists.txt index f0c235d..f2802a4 100644 --- a/synchronizer/CMakeLists.txt +++ b/synchronizer/CMakeLists.txt | |||
@@ -1,12 +1,12 @@ | |||
1 | project(akonadi2_synchronizer) | 1 | project(sink_synchronizer) |
2 | 2 | ||
3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | 3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) |
4 | 4 | ||
5 | set(akonadi2synchronizer_SRCS | 5 | set(sinksynchronizer_SRCS |
6 | main.cpp | 6 | main.cpp |
7 | ) | 7 | ) |
8 | 8 | ||
9 | add_executable(${PROJECT_NAME} ${akonadi2synchronizer_SRCS}) | 9 | add_executable(${PROJECT_NAME} ${sinksynchronizer_SRCS}) |
10 | target_link_libraries(${PROJECT_NAME} akonadi2common KF5::Async) | 10 | target_link_libraries(${PROJECT_NAME} sinkcommon KF5::Async) |
11 | qt5_use_modules(${PROJECT_NAME} Widgets Network) | 11 | qt5_use_modules(${PROJECT_NAME} Widgets Network) |
12 | install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) | 12 | install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) |
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 38e5512..b01a329 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt | |||
@@ -15,7 +15,7 @@ macro(manual_tests) | |||
15 | add_executable(${_testname} ${_testname}.cpp testimplementations.cpp getrssusage.cpp) | 15 | add_executable(${_testname} ${_testname}.cpp testimplementations.cpp getrssusage.cpp) |
16 | generate_flatbuffers(${_testname} calendar) | 16 | generate_flatbuffers(${_testname} calendar) |
17 | qt5_use_modules(${_testname} Core Test Concurrent) | 17 | qt5_use_modules(${_testname} Core Test Concurrent) |
18 | target_link_libraries(${_testname} akonadi2common libhawd) | 18 | target_link_libraries(${_testname} sinkcommon libhawd) |
19 | endforeach(_testname) | 19 | endforeach(_testname) |
20 | endmacro(manual_tests) | 20 | endmacro(manual_tests) |
21 | 21 | ||
@@ -25,7 +25,7 @@ macro(auto_tests) | |||
25 | generate_flatbuffers(${_testname} calendar) | 25 | generate_flatbuffers(${_testname} calendar) |
26 | add_test(${_testname} ${_testname}) | 26 | add_test(${_testname} ${_testname}) |
27 | qt5_use_modules(${_testname} Core Test Concurrent) | 27 | qt5_use_modules(${_testname} Core Test Concurrent) |
28 | target_link_libraries(${_testname} akonadi2common libhawd) | 28 | target_link_libraries(${_testname} sinkcommon libhawd) |
29 | endforeach(_testname) | 29 | endforeach(_testname) |
30 | endmacro(auto_tests) | 30 | endmacro(auto_tests) |
31 | 31 | ||
@@ -53,16 +53,16 @@ auto_tests ( | |||
53 | modelinteractivitytest | 53 | modelinteractivitytest |
54 | inspectiontest | 54 | inspectiontest |
55 | ) | 55 | ) |
56 | target_link_libraries(dummyresourcetest akonadi2_resource_dummy) | 56 | target_link_libraries(dummyresourcetest sink_resource_dummy) |
57 | target_link_libraries(dummyresourcebenchmark akonadi2_resource_dummy) | 57 | target_link_libraries(dummyresourcebenchmark sink_resource_dummy) |
58 | target_link_libraries(dummyresourcewritebenchmark akonadi2_resource_dummy) | 58 | target_link_libraries(dummyresourcewritebenchmark sink_resource_dummy) |
59 | target_link_libraries(querytest akonadi2_resource_dummy) | 59 | target_link_libraries(querytest sink_resource_dummy) |
60 | target_link_libraries(modelinteractivitytest akonadi2_resource_dummy) | 60 | target_link_libraries(modelinteractivitytest sink_resource_dummy) |
61 | target_link_libraries(inspectiontest akonadi2_resource_dummy) | 61 | target_link_libraries(inspectiontest sink_resource_dummy) |
62 | 62 | ||
63 | if (BUILD_MAILDIR) | 63 | if (BUILD_MAILDIR) |
64 | auto_tests ( | 64 | auto_tests ( |
65 | maildirresourcetest | 65 | maildirresourcetest |
66 | ) | 66 | ) |
67 | target_link_libraries(maildirresourcetest akonadi2_resource_maildir) | 67 | target_link_libraries(maildirresourcetest sink_resource_maildir) |
68 | endif() | 68 | endif() |
diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp index 5942849..a85b03b 100644 --- a/tests/clientapitest.cpp +++ b/tests/clientapitest.cpp | |||
@@ -10,7 +10,7 @@ | |||
10 | #include "facadefactory.h" | 10 | #include "facadefactory.h" |
11 | 11 | ||
12 | template <typename T> | 12 | template <typename T> |
13 | class DummyResourceFacade : public Akonadi2::StoreFacade<T> | 13 | class DummyResourceFacade : public Sink::StoreFacade<T> |
14 | { | 14 | { |
15 | public: | 15 | public: |
16 | static std::shared_ptr<DummyResourceFacade<T> > registerFacade(const QByteArray &instanceIdentifier = QByteArray()) | 16 | static std::shared_ptr<DummyResourceFacade<T> > registerFacade(const QByteArray &instanceIdentifier = QByteArray()) |
@@ -19,7 +19,7 @@ public: | |||
19 | auto facade = std::make_shared<DummyResourceFacade<T> >(); | 19 | auto facade = std::make_shared<DummyResourceFacade<T> >(); |
20 | map.insert(instanceIdentifier, facade); | 20 | map.insert(instanceIdentifier, facade); |
21 | bool alwaysReturnFacade = instanceIdentifier.isEmpty(); | 21 | bool alwaysReturnFacade = instanceIdentifier.isEmpty(); |
22 | Akonadi2::FacadeFactory::instance().registerFacade<T, DummyResourceFacade<T> >("dummyresource", | 22 | Sink::FacadeFactory::instance().registerFacade<T, DummyResourceFacade<T> >("dummyresource", |
23 | [alwaysReturnFacade](const QByteArray &instanceIdentifier) { | 23 | [alwaysReturnFacade](const QByteArray &instanceIdentifier) { |
24 | if (alwaysReturnFacade) { | 24 | if (alwaysReturnFacade) { |
25 | return map.value(QByteArray()); | 25 | return map.value(QByteArray()); |
@@ -33,9 +33,9 @@ public: | |||
33 | KAsync::Job<void> create(const T &domainObject) Q_DECL_OVERRIDE { return KAsync::null<void>(); }; | 33 | KAsync::Job<void> create(const T &domainObject) Q_DECL_OVERRIDE { return KAsync::null<void>(); }; |
34 | KAsync::Job<void> modify(const T &domainObject) Q_DECL_OVERRIDE { return KAsync::null<void>(); }; | 34 | KAsync::Job<void> modify(const T &domainObject) Q_DECL_OVERRIDE { return KAsync::null<void>(); }; |
35 | KAsync::Job<void> remove(const T &domainObject) Q_DECL_OVERRIDE { return KAsync::null<void>(); }; | 35 | KAsync::Job<void> remove(const T &domainObject) Q_DECL_OVERRIDE { return KAsync::null<void>(); }; |
36 | QPair<KAsync::Job<void>, typename Akonadi2::ResultEmitter<typename T::Ptr>::Ptr > load(const Akonadi2::Query &query) Q_DECL_OVERRIDE | 36 | QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename T::Ptr>::Ptr > load(const Sink::Query &query) Q_DECL_OVERRIDE |
37 | { | 37 | { |
38 | auto resultProvider = new Akonadi2::ResultProvider<typename T::Ptr>(); | 38 | auto resultProvider = new Sink::ResultProvider<typename T::Ptr>(); |
39 | resultProvider->onDone([resultProvider]() { | 39 | resultProvider->onDone([resultProvider]() { |
40 | Trace() << "Result provider is done"; | 40 | Trace() << "Result provider is done"; |
41 | delete resultProvider; | 41 | delete resultProvider; |
@@ -67,7 +67,7 @@ public: | |||
67 | } | 67 | } |
68 | 68 | ||
69 | QList<typename T::Ptr> results; | 69 | QList<typename T::Ptr> results; |
70 | Akonadi2::ResultProviderInterface<typename T::Ptr> *mResultProvider; | 70 | Sink::ResultProviderInterface<typename T::Ptr> *mResultProvider; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | 73 | ||
@@ -83,117 +83,117 @@ private Q_SLOTS: | |||
83 | 83 | ||
84 | void initTestCase() | 84 | void initTestCase() |
85 | { | 85 | { |
86 | Akonadi2::FacadeFactory::instance().resetFactory(); | 86 | Sink::FacadeFactory::instance().resetFactory(); |
87 | ResourceConfig::clear(); | 87 | ResourceConfig::clear(); |
88 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | 88 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
89 | } | 89 | } |
90 | 90 | ||
91 | void testLoad() | 91 | void testLoad() |
92 | { | 92 | { |
93 | auto facade = DummyResourceFacade<Akonadi2::ApplicationDomain::Event>::registerFacade(); | 93 | auto facade = DummyResourceFacade<Sink::ApplicationDomain::Event>::registerFacade(); |
94 | facade->results << QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 94 | facade->results << QSharedPointer<Sink::ApplicationDomain::Event>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
95 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 95 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
96 | 96 | ||
97 | Akonadi2::Query query; | 97 | Sink::Query query; |
98 | query.resources << "dummyresource.instance1"; | 98 | query.resources << "dummyresource.instance1"; |
99 | query.liveQuery = false; | 99 | query.liveQuery = false; |
100 | 100 | ||
101 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 101 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
102 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 102 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
103 | QCOMPARE(model->rowCount(QModelIndex()), 1); | 103 | QCOMPARE(model->rowCount(QModelIndex()), 1); |
104 | } | 104 | } |
105 | 105 | ||
106 | void testLoadWithoutResource() | 106 | void testLoadWithoutResource() |
107 | { | 107 | { |
108 | Akonadi2::Query query; | 108 | Sink::Query query; |
109 | query.resources << "nonexisting.resource"; | 109 | query.resources << "nonexisting.resource"; |
110 | query.liveQuery = false; | 110 | query.liveQuery = false; |
111 | 111 | ||
112 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 112 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
113 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 113 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
114 | } | 114 | } |
115 | 115 | ||
116 | //TODO: This test doesn't belong to this testsuite | 116 | //TODO: This test doesn't belong to this testsuite |
117 | void resourceManagement() | 117 | void resourceManagement() |
118 | { | 118 | { |
119 | ResourceConfig::clear(); | 119 | ResourceConfig::clear(); |
120 | Akonadi2::FacadeFactory::instance().registerStaticFacades(); | 120 | Sink::FacadeFactory::instance().registerStaticFacades(); |
121 | 121 | ||
122 | Akonadi2::ApplicationDomain::AkonadiResource res("", "dummyresource.identifier1", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 122 | Sink::ApplicationDomain::SinkResource res("", "dummyresource.identifier1", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
123 | res.setProperty("identifier", "dummyresource.identifier1"); | 123 | res.setProperty("identifier", "dummyresource.identifier1"); |
124 | res.setProperty("type", "dummyresource"); | 124 | res.setProperty("type", "dummyresource"); |
125 | 125 | ||
126 | Akonadi2::Store::create(res).exec().waitForFinished(); | 126 | Sink::Store::create(res).exec().waitForFinished(); |
127 | { | 127 | { |
128 | Akonadi2::Query query; | 128 | Sink::Query query; |
129 | query.propertyFilter.insert("type", "dummyresource"); | 129 | query.propertyFilter.insert("type", "dummyresource"); |
130 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::AkonadiResource>(query); | 130 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(query); |
131 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 131 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
132 | } | 132 | } |
133 | 133 | ||
134 | Akonadi2::Store::remove(res).exec().waitForFinished(); | 134 | Sink::Store::remove(res).exec().waitForFinished(); |
135 | { | 135 | { |
136 | Akonadi2::Query query; | 136 | Sink::Query query; |
137 | query.propertyFilter.insert("type", "dummyresource"); | 137 | query.propertyFilter.insert("type", "dummyresource"); |
138 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::AkonadiResource>(query); | 138 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::SinkResource>(query); |
139 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 139 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
140 | QCOMPARE(model->rowCount(QModelIndex()), 0); | 140 | QCOMPARE(model->rowCount(QModelIndex()), 0); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void testModelSingle() | 144 | void testModelSingle() |
145 | { | 145 | { |
146 | auto facade = DummyResourceFacade<Akonadi2::ApplicationDomain::Folder>::registerFacade(); | 146 | auto facade = DummyResourceFacade<Sink::ApplicationDomain::Folder>::registerFacade(); |
147 | facade->results << QSharedPointer<Akonadi2::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 147 | facade->results << QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
148 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 148 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
149 | 149 | ||
150 | Akonadi2::Query query; | 150 | Sink::Query query; |
151 | query.resources << "dummyresource.instance1"; | 151 | query.resources << "dummyresource.instance1"; |
152 | query.liveQuery = false; | 152 | query.liveQuery = false; |
153 | 153 | ||
154 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 154 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
155 | QTRY_COMPARE(model->rowCount(), 1); | 155 | QTRY_COMPARE(model->rowCount(), 1); |
156 | } | 156 | } |
157 | 157 | ||
158 | void testModelNested() | 158 | void testModelNested() |
159 | { | 159 | { |
160 | auto facade = DummyResourceFacade<Akonadi2::ApplicationDomain::Folder>::registerFacade(); | 160 | auto facade = DummyResourceFacade<Sink::ApplicationDomain::Folder>::registerFacade(); |
161 | auto folder = QSharedPointer<Akonadi2::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 161 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
162 | auto subfolder = QSharedPointer<Akonadi2::ApplicationDomain::Folder>::create("resource", "subId", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 162 | auto subfolder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
163 | subfolder->setProperty("parent", "id"); | 163 | subfolder->setProperty("parent", "id"); |
164 | facade->results << folder << subfolder; | 164 | facade->results << folder << subfolder; |
165 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 165 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
166 | 166 | ||
167 | //Test | 167 | //Test |
168 | Akonadi2::Query query; | 168 | Sink::Query query; |
169 | query.resources << "dummyresource.instance1"; | 169 | query.resources << "dummyresource.instance1"; |
170 | query.liveQuery = false; | 170 | query.liveQuery = false; |
171 | query.parentProperty = "parent"; | 171 | query.parentProperty = "parent"; |
172 | 172 | ||
173 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 173 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
174 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 174 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
175 | QCOMPARE(model->rowCount(), 1); | 175 | QCOMPARE(model->rowCount(), 1); |
176 | model->fetchMore(model->index(0, 0)); | 176 | model->fetchMore(model->index(0, 0)); |
177 | QTRY_VERIFY(model->data(model->index(0, 0), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 177 | QTRY_VERIFY(model->data(model->index(0, 0), Sink::Store::ChildrenFetchedRole).toBool()); |
178 | QCOMPARE(model->rowCount(model->index(0, 0)), 1); | 178 | QCOMPARE(model->rowCount(model->index(0, 0)), 1); |
179 | } | 179 | } |
180 | 180 | ||
181 | void testModelSignals() | 181 | void testModelSignals() |
182 | { | 182 | { |
183 | auto facade = DummyResourceFacade<Akonadi2::ApplicationDomain::Folder>::registerFacade(); | 183 | auto facade = DummyResourceFacade<Sink::ApplicationDomain::Folder>::registerFacade(); |
184 | auto folder = QSharedPointer<Akonadi2::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 184 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
185 | auto subfolder = QSharedPointer<Akonadi2::ApplicationDomain::Folder>::create("resource", "subId", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 185 | auto subfolder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
186 | subfolder->setProperty("parent", "id"); | 186 | subfolder->setProperty("parent", "id"); |
187 | facade->results << folder << subfolder; | 187 | facade->results << folder << subfolder; |
188 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 188 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
189 | 189 | ||
190 | //Test | 190 | //Test |
191 | Akonadi2::Query query; | 191 | Sink::Query query; |
192 | query.resources << "dummyresource.instance1"; | 192 | query.resources << "dummyresource.instance1"; |
193 | query.liveQuery = false; | 193 | query.liveQuery = false; |
194 | query.parentProperty = "parent"; | 194 | query.parentProperty = "parent"; |
195 | 195 | ||
196 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 196 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
197 | QSignalSpy spy(model.data(), SIGNAL(rowsInserted(const QModelIndex &, int, int))); | 197 | QSignalSpy spy(model.data(), SIGNAL(rowsInserted(const QModelIndex &, int, int))); |
198 | QVERIFY(spy.isValid()); | 198 | QVERIFY(spy.isValid()); |
199 | model->fetchMore(model->index(0, 0)); | 199 | model->fetchMore(model->index(0, 0)); |
@@ -202,20 +202,20 @@ private Q_SLOTS: | |||
202 | 202 | ||
203 | void testModelNestedLive() | 203 | void testModelNestedLive() |
204 | { | 204 | { |
205 | auto facade = DummyResourceFacade<Akonadi2::ApplicationDomain::Folder>::registerFacade(); | 205 | auto facade = DummyResourceFacade<Sink::ApplicationDomain::Folder>::registerFacade(); |
206 | auto folder = QSharedPointer<Akonadi2::ApplicationDomain::Folder>::create("dummyresource.instance1", "id", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 206 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("dummyresource.instance1", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
207 | auto subfolder = QSharedPointer<Akonadi2::ApplicationDomain::Folder>::create("dummyresource.instance1", "subId", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 207 | auto subfolder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("dummyresource.instance1", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
208 | subfolder->setProperty("parent", "id"); | 208 | subfolder->setProperty("parent", "id"); |
209 | facade->results << folder << subfolder; | 209 | facade->results << folder << subfolder; |
210 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 210 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
211 | 211 | ||
212 | //Test | 212 | //Test |
213 | Akonadi2::Query query; | 213 | Sink::Query query; |
214 | query.resources << "dummyresource.instance1"; | 214 | query.resources << "dummyresource.instance1"; |
215 | query.liveQuery = true; | 215 | query.liveQuery = true; |
216 | query.parentProperty = "parent"; | 216 | query.parentProperty = "parent"; |
217 | 217 | ||
218 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 218 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
219 | QTRY_COMPARE(model->rowCount(), 1); | 219 | QTRY_COMPARE(model->rowCount(), 1); |
220 | model->fetchMore(model->index(0, 0)); | 220 | model->fetchMore(model->index(0, 0)); |
221 | QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); | 221 | QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); |
@@ -225,7 +225,7 @@ private Q_SLOTS: | |||
225 | //Test new toplevel folder | 225 | //Test new toplevel folder |
226 | { | 226 | { |
227 | QSignalSpy rowsInsertedSpy(model.data(), SIGNAL(rowsInserted(const QModelIndex &, int, int))); | 227 | QSignalSpy rowsInsertedSpy(model.data(), SIGNAL(rowsInserted(const QModelIndex &, int, int))); |
228 | auto folder2 = QSharedPointer<Akonadi2::ApplicationDomain::Folder>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 228 | auto folder2 = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "id2", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
229 | resultProvider->add(folder2); | 229 | resultProvider->add(folder2); |
230 | QTRY_COMPARE(model->rowCount(), 2); | 230 | QTRY_COMPARE(model->rowCount(), 2); |
231 | QTRY_COMPARE(rowsInsertedSpy.count(), 1); | 231 | QTRY_COMPARE(rowsInsertedSpy.count(), 1); |
@@ -255,24 +255,24 @@ private Q_SLOTS: | |||
255 | 255 | ||
256 | void testLoadMultiResource() | 256 | void testLoadMultiResource() |
257 | { | 257 | { |
258 | auto facade1 = DummyResourceFacade<Akonadi2::ApplicationDomain::Event>::registerFacade("dummyresource.instance1"); | 258 | auto facade1 = DummyResourceFacade<Sink::ApplicationDomain::Event>::registerFacade("dummyresource.instance1"); |
259 | facade1->results << QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource1", "id", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 259 | facade1->results << QSharedPointer<Sink::ApplicationDomain::Event>::create("resource1", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
260 | auto facade2 = DummyResourceFacade<Akonadi2::ApplicationDomain::Event>::registerFacade("dummyresource.instance2"); | 260 | auto facade2 = DummyResourceFacade<Sink::ApplicationDomain::Event>::registerFacade("dummyresource.instance2"); |
261 | facade2->results << QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource2", "id", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 261 | facade2->results << QSharedPointer<Sink::ApplicationDomain::Event>::create("resource2", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
262 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 262 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
263 | ResourceConfig::addResource("dummyresource.instance2", "dummyresource"); | 263 | ResourceConfig::addResource("dummyresource.instance2", "dummyresource"); |
264 | 264 | ||
265 | Akonadi2::Query query; | 265 | Sink::Query query; |
266 | query.liveQuery = false; | 266 | query.liveQuery = false; |
267 | 267 | ||
268 | int childrenFetchedCount = 0; | 268 | int childrenFetchedCount = 0; |
269 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 269 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
270 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [&childrenFetchedCount](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { | 270 | QObject::connect(model.data(), &QAbstractItemModel::dataChanged, [&childrenFetchedCount](const QModelIndex &, const QModelIndex &, const QVector<int> &roles) { |
271 | if (roles.contains(Akonadi2::Store::ChildrenFetchedRole)) { | 271 | if (roles.contains(Sink::Store::ChildrenFetchedRole)) { |
272 | childrenFetchedCount++; | 272 | childrenFetchedCount++; |
273 | } | 273 | } |
274 | }); | 274 | }); |
275 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 275 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
276 | QCOMPARE(model->rowCount(QModelIndex()), 2); | 276 | QCOMPARE(model->rowCount(QModelIndex()), 2); |
277 | //Ensure children fetched is only emitted once (when all resources are done) | 277 | //Ensure children fetched is only emitted once (when all resources are done) |
278 | QTest::qWait(50); | 278 | QTest::qWait(50); |
@@ -281,17 +281,17 @@ private Q_SLOTS: | |||
281 | 281 | ||
282 | void testImperativeLoad() | 282 | void testImperativeLoad() |
283 | { | 283 | { |
284 | auto facade = DummyResourceFacade<Akonadi2::ApplicationDomain::Event>::registerFacade(); | 284 | auto facade = DummyResourceFacade<Sink::ApplicationDomain::Event>::registerFacade(); |
285 | facade->results << QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 285 | facade->results << QSharedPointer<Sink::ApplicationDomain::Event>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
286 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 286 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
287 | 287 | ||
288 | Akonadi2::Query query; | 288 | Sink::Query query; |
289 | query.resources << "dummyresource.instance1"; | 289 | query.resources << "dummyresource.instance1"; |
290 | query.liveQuery = false; | 290 | query.liveQuery = false; |
291 | 291 | ||
292 | bool gotValue = false; | 292 | bool gotValue = false; |
293 | auto result = Akonadi2::Store::fetchOne<Akonadi2::ApplicationDomain::Event>(query) | 293 | auto result = Sink::Store::fetchOne<Sink::ApplicationDomain::Event>(query) |
294 | .then<void, Akonadi2::ApplicationDomain::Event>([&gotValue](const Akonadi2::ApplicationDomain::Event &event) { | 294 | .then<void, Sink::ApplicationDomain::Event>([&gotValue](const Sink::ApplicationDomain::Event &event) { |
295 | gotValue = true; | 295 | gotValue = true; |
296 | }).exec(); | 296 | }).exec(); |
297 | result.waitForFinished(); | 297 | result.waitForFinished(); |
diff --git a/tests/databasepopulationandfacadequerybenchmark.cpp b/tests/databasepopulationandfacadequerybenchmark.cpp index 5a96bdd..8581c49 100644 --- a/tests/databasepopulationandfacadequerybenchmark.cpp +++ b/tests/databasepopulationandfacadequerybenchmark.cpp | |||
@@ -34,12 +34,12 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject | |||
34 | 34 | ||
35 | void populateDatabase(int count) | 35 | void populateDatabase(int count) |
36 | { | 36 | { |
37 | Akonadi2::Storage(Akonadi2::storageLocation(), "identifier", Akonadi2::Storage::ReadWrite).removeFromDisk(); | 37 | Sink::Storage(Sink::storageLocation(), "identifier", Sink::Storage::ReadWrite).removeFromDisk(); |
38 | //Setup | 38 | //Setup |
39 | auto domainTypeAdaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); | 39 | auto domainTypeAdaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); |
40 | { | 40 | { |
41 | Akonadi2::Storage storage(Akonadi2::storageLocation(), identifier, Akonadi2::Storage::ReadWrite); | 41 | Sink::Storage storage(Sink::storageLocation(), identifier, Sink::Storage::ReadWrite); |
42 | auto transaction = storage.createTransaction(Akonadi2::Storage::ReadWrite); | 42 | auto transaction = storage.createTransaction(Sink::Storage::ReadWrite); |
43 | auto db = transaction.openDatabase("event.main"); | 43 | auto db = transaction.openDatabase("event.main"); |
44 | 44 | ||
45 | int bufferSizeTotal = 0; | 45 | int bufferSizeTotal = 0; |
@@ -47,7 +47,7 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject | |||
47 | QByteArray attachment; | 47 | QByteArray attachment; |
48 | attachment.fill('c', 1000); | 48 | attachment.fill('c', 1000); |
49 | for (int i = 0; i < count; i++) { | 49 | for (int i = 0; i < count; i++) { |
50 | auto domainObject = Akonadi2::ApplicationDomain::Event::Ptr::create(); | 50 | auto domainObject = Sink::ApplicationDomain::Event::Ptr::create(); |
51 | domainObject->setProperty("uid", "uid"); | 51 | domainObject->setProperty("uid", "uid"); |
52 | domainObject->setProperty("summary", "summary"); | 52 | domainObject->setProperty("summary", "summary"); |
53 | domainObject->setProperty("attachment", attachment); | 53 | domainObject->setProperty("attachment", attachment); |
@@ -82,7 +82,7 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject | |||
82 | { | 82 | { |
83 | const auto startingRss = getCurrentRSS(); | 83 | const auto startingRss = getCurrentRSS(); |
84 | 84 | ||
85 | Akonadi2::Query query; | 85 | Sink::Query query; |
86 | query.liveQuery = false; | 86 | query.liveQuery = false; |
87 | query.requestedProperties << "uid" << "summary"; | 87 | query.requestedProperties << "uid" << "summary"; |
88 | 88 | ||
@@ -90,22 +90,22 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject | |||
90 | QTime time; | 90 | QTime time; |
91 | time.start(); | 91 | time.start(); |
92 | 92 | ||
93 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); | 93 | auto resultSet = QSharedPointer<Sink::ResultProvider<Sink::ApplicationDomain::Event::Ptr> >::create(); |
94 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 94 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
95 | TestResourceFacade facade(identifier, resourceAccess); | 95 | TestResourceFacade facade(identifier, resourceAccess); |
96 | 96 | ||
97 | auto ret = facade.load(query); | 97 | auto ret = facade.load(query); |
98 | ret.first.exec().waitForFinished(); | 98 | ret.first.exec().waitForFinished(); |
99 | auto emitter = ret.second; | 99 | auto emitter = ret.second; |
100 | QList<Akonadi2::ApplicationDomain::Event::Ptr> list; | 100 | QList<Sink::ApplicationDomain::Event::Ptr> list; |
101 | emitter->onAdded([&list](const Akonadi2::ApplicationDomain::Event::Ptr &event) { | 101 | emitter->onAdded([&list](const Sink::ApplicationDomain::Event::Ptr &event) { |
102 | list << event; | 102 | list << event; |
103 | }); | 103 | }); |
104 | bool done = false; | 104 | bool done = false; |
105 | emitter->onInitialResultSetComplete([&done](const Akonadi2::ApplicationDomain::Event::Ptr &event) { | 105 | emitter->onInitialResultSetComplete([&done](const Sink::ApplicationDomain::Event::Ptr &event) { |
106 | done = true; | 106 | done = true; |
107 | }); | 107 | }); |
108 | emitter->fetch(Akonadi2::ApplicationDomain::Event::Ptr()); | 108 | emitter->fetch(Sink::ApplicationDomain::Event::Ptr()); |
109 | QTRY_VERIFY(done); | 109 | QTRY_VERIFY(done); |
110 | QCOMPARE(list.size(), count); | 110 | QCOMPARE(list.size(), count); |
111 | 111 | ||
@@ -114,7 +114,7 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject | |||
114 | const auto finalRss = getCurrentRSS(); | 114 | const auto finalRss = getCurrentRSS(); |
115 | const auto rssGrowth = finalRss - startingRss; | 115 | const auto rssGrowth = finalRss - startingRss; |
116 | //Since the database is memory mapped it is attributted to the resident set size. | 116 | //Since the database is memory mapped it is attributted to the resident set size. |
117 | const auto rssWithoutDb = finalRss - Akonadi2::Storage(Akonadi2::storageLocation(), identifier, Akonadi2::Storage::ReadWrite).diskUsage(); | 117 | const auto rssWithoutDb = finalRss - Sink::Storage(Sink::storageLocation(), identifier, Sink::Storage::ReadWrite).diskUsage(); |
118 | const auto peakRss = getPeakRSS(); | 118 | const auto peakRss = getPeakRSS(); |
119 | //How much peak deviates from final rss in percent (should be around 0) | 119 | //How much peak deviates from final rss in percent (should be around 0) |
120 | const auto percentageRssError = static_cast<double>(peakRss - finalRss)*100.0/static_cast<double>(finalRss); | 120 | const auto percentageRssError = static_cast<double>(peakRss - finalRss)*100.0/static_cast<double>(finalRss); |
diff --git a/tests/domainadaptortest.cpp b/tests/domainadaptortest.cpp index b3d2a00..ff8f639 100644 --- a/tests/domainadaptortest.cpp +++ b/tests/domainadaptortest.cpp | |||
@@ -13,12 +13,12 @@ | |||
13 | #include "metadata_generated.h" | 13 | #include "metadata_generated.h" |
14 | #include "entity_generated.h" | 14 | #include "entity_generated.h" |
15 | 15 | ||
16 | class TestFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, Akonadi2::ApplicationDomain::Buffer::EventBuilder> | 16 | class TestFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Event, Sink::ApplicationDomain::Buffer::Event, Sink::ApplicationDomain::Buffer::EventBuilder> |
17 | { | 17 | { |
18 | public: | 18 | public: |
19 | TestFactory() | 19 | TestFactory() |
20 | { | 20 | { |
21 | mResourceWriteMapper = Akonadi2::ApplicationDomain::TypeImplementation<Akonadi2::ApplicationDomain::Event>::initializeWritePropertyMapper(); | 21 | mResourceWriteMapper = Sink::ApplicationDomain::TypeImplementation<Sink::ApplicationDomain::Event>::initializeWritePropertyMapper(); |
22 | } | 22 | } |
23 | }; | 23 | }; |
24 | 24 | ||
@@ -39,27 +39,27 @@ private Q_SLOTS: | |||
39 | 39 | ||
40 | void testCreateBufferPart() | 40 | void testCreateBufferPart() |
41 | { | 41 | { |
42 | auto writeMapper = Akonadi2::ApplicationDomain::TypeImplementation<Akonadi2::ApplicationDomain::Event>::initializeWritePropertyMapper(); | 42 | auto writeMapper = Sink::ApplicationDomain::TypeImplementation<Sink::ApplicationDomain::Event>::initializeWritePropertyMapper(); |
43 | 43 | ||
44 | Akonadi2::ApplicationDomain::Event event; | 44 | Sink::ApplicationDomain::Event event; |
45 | event.setProperty("summary", "foo"); | 45 | event.setProperty("summary", "foo"); |
46 | 46 | ||
47 | flatbuffers::FlatBufferBuilder fbb; | 47 | flatbuffers::FlatBufferBuilder fbb; |
48 | auto pos = createBufferPart<Akonadi2::ApplicationDomain::Buffer::EventBuilder, Akonadi2::ApplicationDomain::Buffer::Event>(event, fbb, *writeMapper); | 48 | auto pos = createBufferPart<Sink::ApplicationDomain::Buffer::EventBuilder, Sink::ApplicationDomain::Buffer::Event>(event, fbb, *writeMapper); |
49 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(fbb, pos); | 49 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(fbb, pos); |
50 | 50 | ||
51 | flatbuffers::Verifier verifier(fbb.GetBufferPointer(), fbb.GetSize()); | 51 | flatbuffers::Verifier verifier(fbb.GetBufferPointer(), fbb.GetSize()); |
52 | QVERIFY(verifier.VerifyBuffer<Akonadi2::ApplicationDomain::Buffer::Event>()); | 52 | QVERIFY(verifier.VerifyBuffer<Sink::ApplicationDomain::Buffer::Event>()); |
53 | } | 53 | } |
54 | 54 | ||
55 | void testAdaptor() | 55 | void testAdaptor() |
56 | { | 56 | { |
57 | //Create entity buffer | 57 | //Create entity buffer |
58 | flatbuffers::FlatBufferBuilder metadataFbb; | 58 | flatbuffers::FlatBufferBuilder metadataFbb; |
59 | auto metadataBuilder = Akonadi2::MetadataBuilder(metadataFbb); | 59 | auto metadataBuilder = Sink::MetadataBuilder(metadataFbb); |
60 | metadataBuilder.add_revision(1); | 60 | metadataBuilder.add_revision(1); |
61 | auto metadataBuffer = metadataBuilder.Finish(); | 61 | auto metadataBuffer = metadataBuilder.Finish(); |
62 | Akonadi2::FinishMetadataBuffer(metadataFbb, metadataBuffer); | 62 | Sink::FinishMetadataBuffer(metadataFbb, metadataBuffer); |
63 | 63 | ||
64 | flatbuffers::FlatBufferBuilder m_fbb; | 64 | flatbuffers::FlatBufferBuilder m_fbb; |
65 | auto summary = m_fbb.CreateString("summary1"); | 65 | auto summary = m_fbb.CreateString("summary1"); |
@@ -67,20 +67,20 @@ private Q_SLOTS: | |||
67 | static uint8_t rawData[100]; | 67 | static uint8_t rawData[100]; |
68 | auto attachment = m_fbb.CreateVector(rawData, 100); | 68 | auto attachment = m_fbb.CreateVector(rawData, 100); |
69 | 69 | ||
70 | auto builder = Akonadi2::ApplicationDomain::Buffer::EventBuilder(m_fbb); | 70 | auto builder = Sink::ApplicationDomain::Buffer::EventBuilder(m_fbb); |
71 | builder.add_summary(summary); | 71 | builder.add_summary(summary); |
72 | builder.add_description(description); | 72 | builder.add_description(description); |
73 | builder.add_attachment(attachment); | 73 | builder.add_attachment(attachment); |
74 | auto buffer = builder.Finish(); | 74 | auto buffer = builder.Finish(); |
75 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(m_fbb, buffer); | 75 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(m_fbb, buffer); |
76 | 76 | ||
77 | flatbuffers::FlatBufferBuilder fbb; | 77 | flatbuffers::FlatBufferBuilder fbb; |
78 | Akonadi2::EntityBuffer::assembleEntityBuffer(fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize(), m_fbb.GetBufferPointer(), m_fbb.GetSize(), m_fbb.GetBufferPointer(), m_fbb.GetSize()); | 78 | Sink::EntityBuffer::assembleEntityBuffer(fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize(), m_fbb.GetBufferPointer(), m_fbb.GetSize(), m_fbb.GetBufferPointer(), m_fbb.GetSize()); |
79 | 79 | ||
80 | //Extract entity buffer | 80 | //Extract entity buffer |
81 | { | 81 | { |
82 | std::string data(reinterpret_cast<const char*>(fbb.GetBufferPointer()), fbb.GetSize()); | 82 | std::string data(reinterpret_cast<const char*>(fbb.GetBufferPointer()), fbb.GetSize()); |
83 | Akonadi2::EntityBuffer buffer((void*)(data.data()), data.size()); | 83 | Sink::EntityBuffer buffer((void*)(data.data()), data.size()); |
84 | 84 | ||
85 | TestFactory factory; | 85 | TestFactory factory; |
86 | auto adaptor = factory.createAdaptor(buffer.entity()); | 86 | auto adaptor = factory.createAdaptor(buffer.entity()); |
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index c52eee3..e511613 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp | |||
@@ -30,8 +30,8 @@ private: | |||
30 | private Q_SLOTS: | 30 | private Q_SLOTS: |
31 | void initTestCase() | 31 | void initTestCase() |
32 | { | 32 | { |
33 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Warning); | 33 | Sink::Log::setDebugOutputLevel(Sink::Log::Warning); |
34 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | 34 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); |
35 | QVERIFY(factory); | 35 | QVERIFY(factory); |
36 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | 36 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); |
37 | num = 5000; | 37 | num = 5000; |
@@ -79,20 +79,20 @@ private Q_SLOTS: | |||
79 | time.start(); | 79 | time.start(); |
80 | QList<KAsync::Future<void> > waitCondition; | 80 | QList<KAsync::Future<void> > waitCondition; |
81 | for (int i = 0; i < num; i++) { | 81 | for (int i = 0; i < num; i++) { |
82 | Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1"); | 82 | Sink::ApplicationDomain::Event event("org.kde.dummy.instance1"); |
83 | event.setProperty("uid", "testuid"); | 83 | event.setProperty("uid", "testuid"); |
84 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); | 84 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); |
85 | event.setProperty("summary", "summaryValue"); | 85 | event.setProperty("summary", "summaryValue"); |
86 | waitCondition << Akonadi2::Store::create<Akonadi2::ApplicationDomain::Event>(event).exec(); | 86 | waitCondition << Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec(); |
87 | } | 87 | } |
88 | waitForCompletion(waitCondition).exec().waitForFinished(); | 88 | waitForCompletion(waitCondition).exec().waitForFinished(); |
89 | auto appendTime = time.elapsed(); | 89 | auto appendTime = time.elapsed(); |
90 | 90 | ||
91 | //Ensure everything is processed | 91 | //Ensure everything is processed |
92 | { | 92 | { |
93 | Akonadi2::Query query; | 93 | Sink::Query query; |
94 | query.resources << "org.kde.dummy.instance1"; | 94 | query.resources << "org.kde.dummy.instance1"; |
95 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 95 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
96 | } | 96 | } |
97 | auto allProcessedTime = time.elapsed(); | 97 | auto allProcessedTime = time.elapsed(); |
98 | 98 | ||
@@ -119,11 +119,11 @@ private Q_SLOTS: | |||
119 | //Measure query | 119 | //Measure query |
120 | { | 120 | { |
121 | time.start(); | 121 | time.start(); |
122 | Akonadi2::Query query; | 122 | Sink::Query query; |
123 | query.resources << "org.kde.dummy.instance1"; | 123 | query.resources << "org.kde.dummy.instance1"; |
124 | 124 | ||
125 | query.propertyFilter.insert("uid", "testuid"); | 125 | query.propertyFilter.insert("uid", "testuid"); |
126 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 126 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
127 | QTRY_COMPARE(model->rowCount(QModelIndex()), num); | 127 | QTRY_COMPARE(model->rowCount(QModelIndex()), num); |
128 | } | 128 | } |
129 | auto queryTime = time.elapsed(); | 129 | auto queryTime = time.elapsed(); |
@@ -142,44 +142,44 @@ private Q_SLOTS: | |||
142 | QTime time; | 142 | QTime time; |
143 | time.start(); | 143 | time.start(); |
144 | 144 | ||
145 | auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.dummy.instance1"); | 145 | auto pipeline = QSharedPointer<Sink::Pipeline>::create("org.kde.dummy.instance1"); |
146 | DummyResource resource("org.kde.dummy.instance1", pipeline); | 146 | DummyResource resource("org.kde.dummy.instance1", pipeline); |
147 | 147 | ||
148 | flatbuffers::FlatBufferBuilder eventFbb; | 148 | flatbuffers::FlatBufferBuilder eventFbb; |
149 | eventFbb.Clear(); | 149 | eventFbb.Clear(); |
150 | { | 150 | { |
151 | auto summary = eventFbb.CreateString("summary"); | 151 | auto summary = eventFbb.CreateString("summary"); |
152 | Akonadi2::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); | 152 | Sink::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); |
153 | eventBuilder.add_summary(summary); | 153 | eventBuilder.add_summary(summary); |
154 | auto eventLocation = eventBuilder.Finish(); | 154 | auto eventLocation = eventBuilder.Finish(); |
155 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); | 155 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); |
156 | } | 156 | } |
157 | 157 | ||
158 | flatbuffers::FlatBufferBuilder localFbb; | 158 | flatbuffers::FlatBufferBuilder localFbb; |
159 | { | 159 | { |
160 | auto uid = localFbb.CreateString("testuid"); | 160 | auto uid = localFbb.CreateString("testuid"); |
161 | auto localBuilder = Akonadi2::ApplicationDomain::Buffer::EventBuilder(localFbb); | 161 | auto localBuilder = Sink::ApplicationDomain::Buffer::EventBuilder(localFbb); |
162 | localBuilder.add_uid(uid); | 162 | localBuilder.add_uid(uid); |
163 | auto location = localBuilder.Finish(); | 163 | auto location = localBuilder.Finish(); |
164 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); | 164 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); |
165 | } | 165 | } |
166 | 166 | ||
167 | flatbuffers::FlatBufferBuilder entityFbb; | 167 | flatbuffers::FlatBufferBuilder entityFbb; |
168 | Akonadi2::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); | 168 | Sink::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); |
169 | 169 | ||
170 | flatbuffers::FlatBufferBuilder fbb; | 170 | flatbuffers::FlatBufferBuilder fbb; |
171 | auto type = fbb.CreateString(Akonadi2::ApplicationDomain::getTypeName<Akonadi2::ApplicationDomain::Event>().toStdString().data()); | 171 | auto type = fbb.CreateString(Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>().toStdString().data()); |
172 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 172 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
173 | Akonadi2::Commands::CreateEntityBuilder builder(fbb); | 173 | Sink::Commands::CreateEntityBuilder builder(fbb); |
174 | builder.add_domainType(type); | 174 | builder.add_domainType(type); |
175 | builder.add_delta(delta); | 175 | builder.add_delta(delta); |
176 | auto location = builder.Finish(); | 176 | auto location = builder.Finish(); |
177 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 177 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); |
178 | 178 | ||
179 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 179 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); |
180 | 180 | ||
181 | for (int i = 0; i < num; i++) { | 181 | for (int i = 0; i < num; i++) { |
182 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); | 182 | resource.processCommand(Sink::Commands::CreateEntityCommand, command); |
183 | } | 183 | } |
184 | auto appendTime = time.elapsed(); | 184 | auto appendTime = time.elapsed(); |
185 | 185 | ||
@@ -203,7 +203,7 @@ private Q_SLOTS: | |||
203 | 203 | ||
204 | void testCreateCommand() | 204 | void testCreateCommand() |
205 | { | 205 | { |
206 | Akonadi2::ApplicationDomain::Event event; | 206 | Sink::ApplicationDomain::Event event; |
207 | 207 | ||
208 | QBENCHMARK { | 208 | QBENCHMARK { |
209 | auto mFactory = new DummyEventAdaptorFactory; | 209 | auto mFactory = new DummyEventAdaptorFactory; |
@@ -217,9 +217,9 @@ private Q_SLOTS: | |||
217 | auto entityId = fbb.CreateString(""); | 217 | auto entityId = fbb.CreateString(""); |
218 | auto type = fbb.CreateString("event"); | 218 | auto type = fbb.CreateString("event"); |
219 | // auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 219 | // auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
220 | auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 220 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
221 | auto location = Akonadi2::Commands::CreateCreateEntity(fbb, entityId, type, delta); | 221 | auto location = Sink::Commands::CreateCreateEntity(fbb, entityId, type, delta); |
222 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 222 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index 72a24b6..82c713d 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp | |||
@@ -22,8 +22,8 @@ class DummyResourceTest : public QObject | |||
22 | private Q_SLOTS: | 22 | private Q_SLOTS: |
23 | void initTestCase() | 23 | void initTestCase() |
24 | { | 24 | { |
25 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | 25 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
26 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | 26 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); |
27 | QVERIFY(factory); | 27 | QVERIFY(factory); |
28 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 28 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); |
29 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | 29 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); |
@@ -31,11 +31,11 @@ private Q_SLOTS: | |||
31 | 31 | ||
32 | void cleanup() | 32 | void cleanup() |
33 | { | 33 | { |
34 | Akonadi2::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 34 | Sink::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); |
35 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 35 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); |
36 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | 36 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); |
37 | QVERIFY(factory); | 37 | QVERIFY(factory); |
38 | Akonadi2::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 38 | Sink::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); |
39 | } | 39 | } |
40 | 40 | ||
41 | void init() | 41 | void init() |
@@ -47,54 +47,54 @@ private Q_SLOTS: | |||
47 | 47 | ||
48 | void testProperty() | 48 | void testProperty() |
49 | { | 49 | { |
50 | Akonadi2::ApplicationDomain::Event event; | 50 | Sink::ApplicationDomain::Event event; |
51 | event.setProperty("uid", "testuid"); | 51 | event.setProperty("uid", "testuid"); |
52 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); | 52 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); |
53 | } | 53 | } |
54 | 54 | ||
55 | void testWriteToFacadeAndQueryByUid() | 55 | void testWriteToFacadeAndQueryByUid() |
56 | { | 56 | { |
57 | Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1"); | 57 | Sink::ApplicationDomain::Event event("org.kde.dummy.instance1"); |
58 | event.setProperty("uid", "testuid"); | 58 | event.setProperty("uid", "testuid"); |
59 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); | 59 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); |
60 | event.setProperty("summary", "summaryValue"); | 60 | event.setProperty("summary", "summaryValue"); |
61 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Event>(event).exec().waitForFinished(); | 61 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); |
62 | 62 | ||
63 | Akonadi2::Query query; | 63 | Sink::Query query; |
64 | query.resources << "org.kde.dummy.instance1"; | 64 | query.resources << "org.kde.dummy.instance1"; |
65 | 65 | ||
66 | //Ensure all local data is processed | 66 | //Ensure all local data is processed |
67 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 67 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
68 | 68 | ||
69 | query.propertyFilter.insert("uid", "testuid"); | 69 | query.propertyFilter.insert("uid", "testuid"); |
70 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 70 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
71 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 71 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
72 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); | 72 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); |
73 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 73 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
74 | } | 74 | } |
75 | 75 | ||
76 | void testWriteToFacadeAndQueryByUid2() | 76 | void testWriteToFacadeAndQueryByUid2() |
77 | { | 77 | { |
78 | Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1"); | 78 | Sink::ApplicationDomain::Event event("org.kde.dummy.instance1"); |
79 | event.setProperty("summary", "summaryValue"); | 79 | event.setProperty("summary", "summaryValue"); |
80 | 80 | ||
81 | event.setProperty("uid", "testuid"); | 81 | event.setProperty("uid", "testuid"); |
82 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Event>(event).exec().waitForFinished(); | 82 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); |
83 | 83 | ||
84 | event.setProperty("uid", "testuid2"); | 84 | event.setProperty("uid", "testuid2"); |
85 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Event>(event).exec().waitForFinished(); | 85 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); |
86 | 86 | ||
87 | Akonadi2::Query query; | 87 | Sink::Query query; |
88 | query.resources << "org.kde.dummy.instance1"; | 88 | query.resources << "org.kde.dummy.instance1"; |
89 | 89 | ||
90 | //Ensure all local data is processed | 90 | //Ensure all local data is processed |
91 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 91 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
92 | 92 | ||
93 | query.propertyFilter.insert("uid", "testuid"); | 93 | query.propertyFilter.insert("uid", "testuid"); |
94 | 94 | ||
95 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 95 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
96 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 96 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
97 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); | 97 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); |
98 | 98 | ||
99 | qDebug() << value->getProperty("uid").toByteArray(); | 99 | qDebug() << value->getProperty("uid").toByteArray(); |
100 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 100 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
@@ -102,27 +102,27 @@ private Q_SLOTS: | |||
102 | 102 | ||
103 | void testWriteToFacadeAndQueryBySummary() | 103 | void testWriteToFacadeAndQueryBySummary() |
104 | { | 104 | { |
105 | Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1"); | 105 | Sink::ApplicationDomain::Event event("org.kde.dummy.instance1"); |
106 | 106 | ||
107 | event.setProperty("uid", "testuid"); | 107 | event.setProperty("uid", "testuid"); |
108 | event.setProperty("summary", "summaryValue1"); | 108 | event.setProperty("summary", "summaryValue1"); |
109 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Event>(event).exec().waitForFinished(); | 109 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); |
110 | 110 | ||
111 | event.setProperty("uid", "testuid2"); | 111 | event.setProperty("uid", "testuid2"); |
112 | event.setProperty("summary", "summaryValue2"); | 112 | event.setProperty("summary", "summaryValue2"); |
113 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Event>(event).exec().waitForFinished(); | 113 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); |
114 | 114 | ||
115 | Akonadi2::Query query; | 115 | Sink::Query query; |
116 | query.resources << "org.kde.dummy.instance1"; | 116 | query.resources << "org.kde.dummy.instance1"; |
117 | 117 | ||
118 | //Ensure all local data is processed | 118 | //Ensure all local data is processed |
119 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 119 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
120 | 120 | ||
121 | query.propertyFilter.insert("summary", "summaryValue2"); | 121 | query.propertyFilter.insert("summary", "summaryValue2"); |
122 | 122 | ||
123 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 123 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
124 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 124 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
125 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); | 125 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); |
126 | 126 | ||
127 | qDebug() << value->getProperty("uid").toByteArray(); | 127 | qDebug() << value->getProperty("uid").toByteArray(); |
128 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid2")); | 128 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid2")); |
@@ -130,7 +130,7 @@ private Q_SLOTS: | |||
130 | 130 | ||
131 | void testResourceSync() | 131 | void testResourceSync() |
132 | { | 132 | { |
133 | auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.dummy.instance1"); | 133 | auto pipeline = QSharedPointer<Sink::Pipeline>::create("org.kde.dummy.instance1"); |
134 | DummyResource resource("org.kde.dummy.instance1", pipeline); | 134 | DummyResource resource("org.kde.dummy.instance1", pipeline); |
135 | auto job = resource.synchronizeWithSource(); | 135 | auto job = resource.synchronizeWithSource(); |
136 | //TODO pass in optional timeout? | 136 | //TODO pass in optional timeout? |
@@ -145,16 +145,16 @@ private Q_SLOTS: | |||
145 | 145 | ||
146 | void testSyncAndFacade() | 146 | void testSyncAndFacade() |
147 | { | 147 | { |
148 | Akonadi2::Query query; | 148 | Sink::Query query; |
149 | query.resources << "org.kde.dummy.instance1"; | 149 | query.resources << "org.kde.dummy.instance1"; |
150 | 150 | ||
151 | //Ensure all local data is processed | 151 | //Ensure all local data is processed |
152 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 152 | Sink::Store::synchronize(query).exec().waitForFinished(); |
153 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 153 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
154 | 154 | ||
155 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 155 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
156 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); | 156 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); |
157 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); | 157 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); |
158 | 158 | ||
159 | QVERIFY(!value->getProperty("summary").toString().isEmpty()); | 159 | QVERIFY(!value->getProperty("summary").toString().isEmpty()); |
160 | qDebug() << value->getProperty("summary").toString(); | 160 | qDebug() << value->getProperty("summary").toString(); |
@@ -162,16 +162,16 @@ private Q_SLOTS: | |||
162 | 162 | ||
163 | void testSyncAndFacadeMail() | 163 | void testSyncAndFacadeMail() |
164 | { | 164 | { |
165 | Akonadi2::Query query; | 165 | Sink::Query query; |
166 | query.resources << "org.kde.dummy.instance1"; | 166 | query.resources << "org.kde.dummy.instance1"; |
167 | 167 | ||
168 | //Ensure all local data is processed | 168 | //Ensure all local data is processed |
169 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 169 | Sink::Store::synchronize(query).exec().waitForFinished(); |
170 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 170 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
171 | 171 | ||
172 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 172 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
173 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); | 173 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); |
174 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>(); | 174 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>(); |
175 | 175 | ||
176 | QVERIFY(!value->getProperty("subject").toString().isEmpty()); | 176 | QVERIFY(!value->getProperty("subject").toString().isEmpty()); |
177 | qDebug() << value->getProperty("subject").toString(); | 177 | qDebug() << value->getProperty("subject").toString(); |
@@ -179,25 +179,25 @@ private Q_SLOTS: | |||
179 | 179 | ||
180 | void testWriteModifyDelete() | 180 | void testWriteModifyDelete() |
181 | { | 181 | { |
182 | Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1"); | 182 | Sink::ApplicationDomain::Event event("org.kde.dummy.instance1"); |
183 | event.setProperty("uid", "testuid"); | 183 | event.setProperty("uid", "testuid"); |
184 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); | 184 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); |
185 | event.setProperty("summary", "summaryValue"); | 185 | event.setProperty("summary", "summaryValue"); |
186 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Event>(event).exec().waitForFinished(); | 186 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); |
187 | 187 | ||
188 | Akonadi2::Query query; | 188 | Sink::Query query; |
189 | query.resources << "org.kde.dummy.instance1"; | 189 | query.resources << "org.kde.dummy.instance1"; |
190 | query.propertyFilter.insert("uid", "testuid"); | 190 | query.propertyFilter.insert("uid", "testuid"); |
191 | 191 | ||
192 | //Ensure all local data is processed | 192 | //Ensure all local data is processed |
193 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 193 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
194 | 194 | ||
195 | //Test create | 195 | //Test create |
196 | Akonadi2::ApplicationDomain::Event event2; | 196 | Sink::ApplicationDomain::Event event2; |
197 | { | 197 | { |
198 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 198 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
199 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 199 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
200 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); | 200 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); |
201 | 201 | ||
202 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 202 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
203 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue")); | 203 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue")); |
@@ -206,30 +206,30 @@ private Q_SLOTS: | |||
206 | 206 | ||
207 | event2.setProperty("uid", "testuid"); | 207 | event2.setProperty("uid", "testuid"); |
208 | event2.setProperty("summary", "summaryValue2"); | 208 | event2.setProperty("summary", "summaryValue2"); |
209 | Akonadi2::Store::modify<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); | 209 | Sink::Store::modify<Sink::ApplicationDomain::Event>(event2).exec().waitForFinished(); |
210 | 210 | ||
211 | //Ensure all local data is processed | 211 | //Ensure all local data is processed |
212 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 212 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
213 | 213 | ||
214 | //Test modify | 214 | //Test modify |
215 | { | 215 | { |
216 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 216 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
217 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 217 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
218 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); | 218 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); |
219 | 219 | ||
220 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 220 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
221 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue2")); | 221 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue2")); |
222 | } | 222 | } |
223 | 223 | ||
224 | Akonadi2::Store::remove<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); | 224 | Sink::Store::remove<Sink::ApplicationDomain::Event>(event2).exec().waitForFinished(); |
225 | 225 | ||
226 | //Ensure all local data is processed | 226 | //Ensure all local data is processed |
227 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 227 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
228 | 228 | ||
229 | //Test remove | 229 | //Test remove |
230 | { | 230 | { |
231 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 231 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
232 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 232 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
233 | QTRY_COMPARE(model->rowCount(QModelIndex()), 0); | 233 | QTRY_COMPARE(model->rowCount(QModelIndex()), 0); |
234 | } | 234 | } |
235 | } | 235 | } |
@@ -237,25 +237,25 @@ private Q_SLOTS: | |||
237 | void testWriteModifyDeleteLive() | 237 | void testWriteModifyDeleteLive() |
238 | { | 238 | { |
239 | 239 | ||
240 | Akonadi2::Query query; | 240 | Sink::Query query; |
241 | query.resources << "org.kde.dummy.instance1"; | 241 | query.resources << "org.kde.dummy.instance1"; |
242 | query.liveQuery = true; | 242 | query.liveQuery = true; |
243 | query.propertyFilter.insert("uid", "testuid"); | 243 | query.propertyFilter.insert("uid", "testuid"); |
244 | 244 | ||
245 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Event>(query); | 245 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
246 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 246 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
247 | 247 | ||
248 | Akonadi2::ApplicationDomain::Event event("org.kde.dummy.instance1"); | 248 | Sink::ApplicationDomain::Event event("org.kde.dummy.instance1"); |
249 | event.setProperty("uid", "testuid"); | 249 | event.setProperty("uid", "testuid"); |
250 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); | 250 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); |
251 | event.setProperty("summary", "summaryValue"); | 251 | event.setProperty("summary", "summaryValue"); |
252 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Event>(event).exec().waitForFinished(); | 252 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); |
253 | 253 | ||
254 | //Test create | 254 | //Test create |
255 | Akonadi2::ApplicationDomain::Event event2; | 255 | Sink::ApplicationDomain::Event event2; |
256 | { | 256 | { |
257 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 257 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
258 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); | 258 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); |
259 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 259 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
260 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue")); | 260 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue")); |
261 | event2 = *value; | 261 | event2 = *value; |
@@ -263,18 +263,18 @@ private Q_SLOTS: | |||
263 | 263 | ||
264 | event2.setProperty("uid", "testuid"); | 264 | event2.setProperty("uid", "testuid"); |
265 | event2.setProperty("summary", "summaryValue2"); | 265 | event2.setProperty("summary", "summaryValue2"); |
266 | Akonadi2::Store::modify<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); | 266 | Sink::Store::modify<Sink::ApplicationDomain::Event>(event2).exec().waitForFinished(); |
267 | 267 | ||
268 | //Test modify | 268 | //Test modify |
269 | { | 269 | { |
270 | //TODO wait for a change signal | 270 | //TODO wait for a change signal |
271 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 271 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
272 | auto value = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Event::Ptr>(); | 272 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); |
273 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 273 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
274 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue2")); | 274 | QCOMPARE(value->getProperty("summary").toByteArray(), QByteArray("summaryValue2")); |
275 | } | 275 | } |
276 | 276 | ||
277 | Akonadi2::Store::remove<Akonadi2::ApplicationDomain::Event>(event2).exec().waitForFinished(); | 277 | Sink::Store::remove<Sink::ApplicationDomain::Event>(event2).exec().waitForFinished(); |
278 | 278 | ||
279 | //Test remove | 279 | //Test remove |
280 | { | 280 | { |
diff --git a/tests/dummyresourcewritebenchmark.cpp b/tests/dummyresourcewritebenchmark.cpp index 1e7f1ef..1a8893b 100644 --- a/tests/dummyresourcewritebenchmark.cpp +++ b/tests/dummyresourcewritebenchmark.cpp | |||
@@ -60,33 +60,33 @@ static QByteArray createEntityBuffer(int &bufferSize) | |||
60 | eventFbb.Clear(); | 60 | eventFbb.Clear(); |
61 | { | 61 | { |
62 | auto summary = eventFbb.CreateString("summary"); | 62 | auto summary = eventFbb.CreateString("summary"); |
63 | Akonadi2::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); | 63 | Sink::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); |
64 | eventBuilder.add_summary(summary); | 64 | eventBuilder.add_summary(summary); |
65 | auto eventLocation = eventBuilder.Finish(); | 65 | auto eventLocation = eventBuilder.Finish(); |
66 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); | 66 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); |
67 | } | 67 | } |
68 | 68 | ||
69 | flatbuffers::FlatBufferBuilder localFbb; | 69 | flatbuffers::FlatBufferBuilder localFbb; |
70 | { | 70 | { |
71 | auto uid = localFbb.CreateString("testuid"); | 71 | auto uid = localFbb.CreateString("testuid"); |
72 | auto localBuilder = Akonadi2::ApplicationDomain::Buffer::EventBuilder(localFbb); | 72 | auto localBuilder = Sink::ApplicationDomain::Buffer::EventBuilder(localFbb); |
73 | localBuilder.add_uid(uid); | 73 | localBuilder.add_uid(uid); |
74 | auto location = localBuilder.Finish(); | 74 | auto location = localBuilder.Finish(); |
75 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); | 75 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); |
76 | } | 76 | } |
77 | 77 | ||
78 | flatbuffers::FlatBufferBuilder entityFbb; | 78 | flatbuffers::FlatBufferBuilder entityFbb; |
79 | Akonadi2::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); | 79 | Sink::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); |
80 | bufferSize = entityFbb.GetSize(); | 80 | bufferSize = entityFbb.GetSize(); |
81 | 81 | ||
82 | flatbuffers::FlatBufferBuilder fbb; | 82 | flatbuffers::FlatBufferBuilder fbb; |
83 | auto type = fbb.CreateString(Akonadi2::ApplicationDomain::getTypeName<Akonadi2::ApplicationDomain::Event>().toStdString().data()); | 83 | auto type = fbb.CreateString(Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>().toStdString().data()); |
84 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 84 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
85 | Akonadi2::Commands::CreateEntityBuilder builder(fbb); | 85 | Sink::Commands::CreateEntityBuilder builder(fbb); |
86 | builder.add_domainType(type); | 86 | builder.add_domainType(type); |
87 | builder.add_delta(delta); | 87 | builder.add_delta(delta); |
88 | auto location = builder.Finish(); | 88 | auto location = builder.Finish(); |
89 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 89 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); |
90 | 90 | ||
91 | return QByteArray(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 91 | return QByteArray(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); |
92 | } | 92 | } |
@@ -109,7 +109,7 @@ class DummyResourceWriteBenchmark : public QObject | |||
109 | QTime time; | 109 | QTime time; |
110 | time.start(); | 110 | time.start(); |
111 | 111 | ||
112 | auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.dummy.instance1"); | 112 | auto pipeline = QSharedPointer<Sink::Pipeline>::create("org.kde.dummy.instance1"); |
113 | DummyResource resource("org.kde.dummy.instance1", pipeline); | 113 | DummyResource resource("org.kde.dummy.instance1", pipeline); |
114 | 114 | ||
115 | int bufferSize = 0; | 115 | int bufferSize = 0; |
@@ -117,7 +117,7 @@ class DummyResourceWriteBenchmark : public QObject | |||
117 | 117 | ||
118 | const auto startingRss = getCurrentRSS(); | 118 | const auto startingRss = getCurrentRSS(); |
119 | for (int i = 0; i < num; i++) { | 119 | for (int i = 0; i < num; i++) { |
120 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); | 120 | resource.processCommand(Sink::Commands::CreateEntityCommand, command); |
121 | } | 121 | } |
122 | auto appendTime = time.elapsed(); | 122 | auto appendTime = time.elapsed(); |
123 | auto bufferSizeTotal = bufferSize * num; | 123 | auto bufferSizeTotal = bufferSize * num; |
@@ -174,7 +174,7 @@ class DummyResourceWriteBenchmark : public QObject | |||
174 | private Q_SLOTS: | 174 | private Q_SLOTS: |
175 | void initTestCase() | 175 | void initTestCase() |
176 | { | 176 | { |
177 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Warning); | 177 | Sink::Log::setDebugOutputLevel(Sink::Log::Warning); |
178 | } | 178 | } |
179 | 179 | ||
180 | void cleanup() | 180 | void cleanup() |
@@ -215,7 +215,7 @@ private Q_SLOTS: | |||
215 | 215 | ||
216 | void getFreePages() | 216 | void getFreePages() |
217 | { | 217 | { |
218 | std::system(QString("mdb_stat %1/%2 -ff").arg(Akonadi2::storageLocation()).arg("org.kde.dummy.instance1").toLatin1().constData()); | 218 | std::system(QString("mdb_stat %1/%2 -ff").arg(Sink::storageLocation()).arg("org.kde.dummy.instance1").toLatin1().constData()); |
219 | } | 219 | } |
220 | 220 | ||
221 | //This allows to run individual parts without doing a cleanup, but still cleaning up normally | 221 | //This allows to run individual parts without doing a cleanup, but still cleaning up normally |
diff --git a/tests/genericfacadetest.cpp b/tests/genericfacadetest.cpp index bb95f4e..63e93f8 100644 --- a/tests/genericfacadetest.cpp +++ b/tests/genericfacadetest.cpp | |||
@@ -26,20 +26,20 @@ private Q_SLOTS: | |||
26 | 26 | ||
27 | void init() | 27 | void init() |
28 | { | 28 | { |
29 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | 29 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
30 | } | 30 | } |
31 | 31 | ||
32 | void testLoad() | 32 | void testLoad() |
33 | { | 33 | { |
34 | Akonadi2::Query query; | 34 | Sink::Query query; |
35 | query.liveQuery = false; | 35 | query.liveQuery = false; |
36 | 36 | ||
37 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); | 37 | auto resultSet = QSharedPointer<Sink::ResultProvider<Sink::ApplicationDomain::Event::Ptr> >::create(); |
38 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 38 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
39 | // storage->mResults << Akonadi2::ApplicationDomain::Event::Ptr::create(); | 39 | // storage->mResults << Sink::ApplicationDomain::Event::Ptr::create(); |
40 | TestResourceFacade facade("identifier", resourceAccess); | 40 | TestResourceFacade facade("identifier", resourceAccess); |
41 | 41 | ||
42 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); | 42 | async::SyncListResult<Sink::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); |
43 | 43 | ||
44 | facade.load(query, *resultSet).exec().waitForFinished(); | 44 | facade.load(query, *resultSet).exec().waitForFinished(); |
45 | resultSet->initialResultSetComplete(); | 45 | resultSet->initialResultSetComplete(); |
@@ -52,15 +52,15 @@ private Q_SLOTS: | |||
52 | 52 | ||
53 | void testLiveQuery() | 53 | void testLiveQuery() |
54 | { | 54 | { |
55 | Akonadi2::Query query; | 55 | Sink::Query query; |
56 | query.liveQuery = true; | 56 | query.liveQuery = true; |
57 | 57 | ||
58 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); | 58 | auto resultSet = QSharedPointer<Sink::ResultProvider<Sink::ApplicationDomain::Event::Ptr> >::create(); |
59 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 59 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
60 | // storage->mResults << Akonadi2::ApplicationDomain::Event::Ptr::create(); | 60 | // storage->mResults << Sink::ApplicationDomain::Event::Ptr::create(); |
61 | TestResourceFacade facade("identifier", resourceAccess); | 61 | TestResourceFacade facade("identifier", resourceAccess); |
62 | 62 | ||
63 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); | 63 | async::SyncListResult<Sink::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); |
64 | 64 | ||
65 | facade.load(query, *resultSet).exec().waitForFinished(); | 65 | facade.load(query, *resultSet).exec().waitForFinished(); |
66 | resultSet->initialResultSetComplete(); | 66 | resultSet->initialResultSetComplete(); |
@@ -70,7 +70,7 @@ private Q_SLOTS: | |||
70 | 70 | ||
71 | //Enter a second result | 71 | //Enter a second result |
72 | // storage->mResults.clear(); | 72 | // storage->mResults.clear(); |
73 | // storage->mResults << QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor>()); | 73 | // storage->mResults << QSharedPointer<Sink::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Sink::ApplicationDomain::BufferAdaptor>()); |
74 | // storage->mLatestRevision = 2; | 74 | // storage->mLatestRevision = 2; |
75 | resourceAccess->emit revisionChanged(2); | 75 | resourceAccess->emit revisionChanged(2); |
76 | 76 | ||
@@ -83,17 +83,17 @@ private Q_SLOTS: | |||
83 | 83 | ||
84 | void testLiveQueryModify() | 84 | void testLiveQueryModify() |
85 | { | 85 | { |
86 | Akonadi2::Query query; | 86 | Sink::Query query; |
87 | query.liveQuery = true; | 87 | query.liveQuery = true; |
88 | 88 | ||
89 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); | 89 | auto resultSet = QSharedPointer<Sink::ResultProvider<Sink::ApplicationDomain::Event::Ptr> >::create(); |
90 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 90 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
91 | auto entity = QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 91 | auto entity = QSharedPointer<Sink::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
92 | entity->setProperty("test", "test1"); | 92 | entity->setProperty("test", "test1"); |
93 | // storage->mResults << entity; | 93 | // storage->mResults << entity; |
94 | TestResourceFacade facade("identifier", resourceAccess); | 94 | TestResourceFacade facade("identifier", resourceAccess); |
95 | 95 | ||
96 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); | 96 | async::SyncListResult<Sink::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); |
97 | 97 | ||
98 | facade.load(query, *resultSet).exec().waitForFinished(); | 98 | facade.load(query, *resultSet).exec().waitForFinished(); |
99 | resultSet->initialResultSetComplete(); | 99 | resultSet->initialResultSetComplete(); |
@@ -103,7 +103,7 @@ private Q_SLOTS: | |||
103 | 103 | ||
104 | //Modify the entity again | 104 | //Modify the entity again |
105 | // storage->mResults.clear(); | 105 | // storage->mResults.clear(); |
106 | entity = QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 106 | entity = QSharedPointer<Sink::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
107 | entity->setProperty("test", "test2"); | 107 | entity->setProperty("test", "test2"); |
108 | // storage->mModifications << entity; | 108 | // storage->mModifications << entity; |
109 | // storage->mLatestRevision = 2; | 109 | // storage->mLatestRevision = 2; |
@@ -119,16 +119,16 @@ private Q_SLOTS: | |||
119 | 119 | ||
120 | void testLiveQueryRemove() | 120 | void testLiveQueryRemove() |
121 | { | 121 | { |
122 | Akonadi2::Query query; | 122 | Sink::Query query; |
123 | query.liveQuery = true; | 123 | query.liveQuery = true; |
124 | 124 | ||
125 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); | 125 | auto resultSet = QSharedPointer<Sink::ResultProvider<Sink::ApplicationDomain::Event::Ptr> >::create(); |
126 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 126 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
127 | auto entity = QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor>()); | 127 | auto entity = QSharedPointer<Sink::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Sink::ApplicationDomain::BufferAdaptor>()); |
128 | // storage->mResults << entity; | 128 | // storage->mResults << entity; |
129 | TestResourceFacade facade("identifier", resourceAccess); | 129 | TestResourceFacade facade("identifier", resourceAccess); |
130 | 130 | ||
131 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); | 131 | async::SyncListResult<Sink::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); |
132 | 132 | ||
133 | facade.load(query, *resultSet).exec().waitForFinished(); | 133 | facade.load(query, *resultSet).exec().waitForFinished(); |
134 | resultSet->initialResultSetComplete(); | 134 | resultSet->initialResultSetComplete(); |
diff --git a/tests/genericresourcebenchmark.cpp b/tests/genericresourcebenchmark.cpp index fbe0d12..7f0d3a2 100644 --- a/tests/genericresourcebenchmark.cpp +++ b/tests/genericresourcebenchmark.cpp | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | static void removeFromDisk(const QString &name) | 21 | static void removeFromDisk(const QString &name) |
22 | { | 22 | { |
23 | Akonadi2::Storage store(Akonadi2::storageLocation(), name, Akonadi2::Storage::ReadWrite); | 23 | Sink::Storage store(Sink::storageLocation(), name, Sink::Storage::ReadWrite); |
24 | store.removeFromDisk(); | 24 | store.removeFromDisk(); |
25 | } | 25 | } |
26 | 26 | ||
@@ -30,39 +30,39 @@ static QByteArray createEntityBuffer() | |||
30 | eventFbb.Clear(); | 30 | eventFbb.Clear(); |
31 | { | 31 | { |
32 | auto summary = eventFbb.CreateString("summary"); | 32 | auto summary = eventFbb.CreateString("summary"); |
33 | Akonadi2::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); | 33 | Sink::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); |
34 | eventBuilder.add_summary(summary); | 34 | eventBuilder.add_summary(summary); |
35 | auto eventLocation = eventBuilder.Finish(); | 35 | auto eventLocation = eventBuilder.Finish(); |
36 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); | 36 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); |
37 | } | 37 | } |
38 | 38 | ||
39 | flatbuffers::FlatBufferBuilder localFbb; | 39 | flatbuffers::FlatBufferBuilder localFbb; |
40 | { | 40 | { |
41 | auto uid = localFbb.CreateString("testuid"); | 41 | auto uid = localFbb.CreateString("testuid"); |
42 | auto localBuilder = Akonadi2::ApplicationDomain::Buffer::EventBuilder(localFbb); | 42 | auto localBuilder = Sink::ApplicationDomain::Buffer::EventBuilder(localFbb); |
43 | localBuilder.add_uid(uid); | 43 | localBuilder.add_uid(uid); |
44 | auto location = localBuilder.Finish(); | 44 | auto location = localBuilder.Finish(); |
45 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); | 45 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); |
46 | } | 46 | } |
47 | 47 | ||
48 | flatbuffers::FlatBufferBuilder entityFbb; | 48 | flatbuffers::FlatBufferBuilder entityFbb; |
49 | Akonadi2::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); | 49 | Sink::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); |
50 | 50 | ||
51 | flatbuffers::FlatBufferBuilder fbb; | 51 | flatbuffers::FlatBufferBuilder fbb; |
52 | auto type = fbb.CreateString(Akonadi2::ApplicationDomain::getTypeName<Akonadi2::ApplicationDomain::Event>().toStdString().data()); | 52 | auto type = fbb.CreateString(Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>().toStdString().data()); |
53 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 53 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
54 | Akonadi2::Commands::CreateEntityBuilder builder(fbb); | 54 | Sink::Commands::CreateEntityBuilder builder(fbb); |
55 | builder.add_domainType(type); | 55 | builder.add_domainType(type); |
56 | builder.add_delta(delta); | 56 | builder.add_delta(delta); |
57 | auto location = builder.Finish(); | 57 | auto location = builder.Finish(); |
58 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 58 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); |
59 | 59 | ||
60 | return QByteArray(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 60 | return QByteArray(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); |
61 | } | 61 | } |
62 | 62 | ||
63 | class IndexUpdater : public Akonadi2::Preprocessor { | 63 | class IndexUpdater : public Sink::Preprocessor { |
64 | public: | 64 | public: |
65 | void newEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 65 | void newEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
66 | { | 66 | { |
67 | for (int i = 0; i < 10; i++) { | 67 | for (int i = 0; i < 10; i++) { |
68 | Index ridIndex(QString("index.index%1").arg(i).toLatin1(), transaction); | 68 | Index ridIndex(QString("index.index%1").arg(i).toLatin1(), transaction); |
@@ -70,11 +70,11 @@ public: | |||
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | void modifiedEntity(const QByteArray &key, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 73 | void modifiedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
74 | { | 74 | { |
75 | } | 75 | } |
76 | 76 | ||
77 | void deletedEntity(const QByteArray &key, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 77 | void deletedEntity(const QByteArray &key, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
78 | { | 78 | { |
79 | } | 79 | } |
80 | }; | 80 | }; |
@@ -89,7 +89,7 @@ private Q_SLOTS: | |||
89 | 89 | ||
90 | void init() | 90 | void init() |
91 | { | 91 | { |
92 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Warning); | 92 | Sink::Log::setDebugOutputLevel(Sink::Log::Warning); |
93 | } | 93 | } |
94 | 94 | ||
95 | void initTestCase() | 95 | void initTestCase() |
@@ -104,7 +104,7 @@ private Q_SLOTS: | |||
104 | { | 104 | { |
105 | int num = 10000; | 105 | int num = 10000; |
106 | 106 | ||
107 | auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.test.instance1"); | 107 | auto pipeline = QSharedPointer<Sink::Pipeline>::create("org.kde.test.instance1"); |
108 | TestResource resource("org.kde.test.instance1", pipeline); | 108 | TestResource resource("org.kde.test.instance1", pipeline); |
109 | 109 | ||
110 | auto command = createEntityBuffer(); | 110 | auto command = createEntityBuffer(); |
@@ -113,7 +113,7 @@ private Q_SLOTS: | |||
113 | time.start(); | 113 | time.start(); |
114 | 114 | ||
115 | for (int i = 0; i < num; i++) { | 115 | for (int i = 0; i < num; i++) { |
116 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); | 116 | resource.processCommand(Sink::Commands::CreateEntityCommand, command); |
117 | } | 117 | } |
118 | auto appendTime = time.elapsed(); | 118 | auto appendTime = time.elapsed(); |
119 | 119 | ||
@@ -139,13 +139,13 @@ private Q_SLOTS: | |||
139 | { | 139 | { |
140 | int num = 50000; | 140 | int num = 50000; |
141 | 141 | ||
142 | auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.test.instance1"); | 142 | auto pipeline = QSharedPointer<Sink::Pipeline>::create("org.kde.test.instance1"); |
143 | 143 | ||
144 | auto eventFactory = QSharedPointer<TestEventAdaptorFactory>::create(); | 144 | auto eventFactory = QSharedPointer<TestEventAdaptorFactory>::create(); |
145 | const QByteArray resourceIdentifier = "org.kde.test.instance1"; | 145 | const QByteArray resourceIdentifier = "org.kde.test.instance1"; |
146 | auto indexer = QSharedPointer<IndexUpdater>::create(); | 146 | auto indexer = QSharedPointer<IndexUpdater>::create(); |
147 | 147 | ||
148 | pipeline->setPreprocessors("event", QVector<Akonadi2::Preprocessor*>() << indexer.data()); | 148 | pipeline->setPreprocessors("event", QVector<Sink::Preprocessor*>() << indexer.data()); |
149 | pipeline->setAdaptorFactory("event", eventFactory); | 149 | pipeline->setAdaptorFactory("event", eventFactory); |
150 | 150 | ||
151 | TestResource resource("org.kde.test.instance1", pipeline); | 151 | TestResource resource("org.kde.test.instance1", pipeline); |
@@ -156,7 +156,7 @@ private Q_SLOTS: | |||
156 | time.start(); | 156 | time.start(); |
157 | 157 | ||
158 | for (int i = 0; i < num; i++) { | 158 | for (int i = 0; i < num; i++) { |
159 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); | 159 | resource.processCommand(Sink::Commands::CreateEntityCommand, command); |
160 | } | 160 | } |
161 | auto appendTime = time.elapsed(); | 161 | auto appendTime = time.elapsed(); |
162 | 162 | ||
@@ -180,7 +180,7 @@ private Q_SLOTS: | |||
180 | 180 | ||
181 | void testCreateCommand() | 181 | void testCreateCommand() |
182 | { | 182 | { |
183 | Akonadi2::ApplicationDomain::Event event; | 183 | Sink::ApplicationDomain::Event event; |
184 | 184 | ||
185 | QBENCHMARK { | 185 | QBENCHMARK { |
186 | auto mFactory = new TestEventAdaptorFactory; | 186 | auto mFactory = new TestEventAdaptorFactory; |
@@ -193,9 +193,9 @@ private Q_SLOTS: | |||
193 | //This is the resource buffer type and not the domain type | 193 | //This is the resource buffer type and not the domain type |
194 | auto type = fbb.CreateString("event"); | 194 | auto type = fbb.CreateString("event"); |
195 | // auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 195 | // auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
196 | auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 196 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
197 | auto location = Akonadi2::Commands::CreateCreateEntity(fbb, type, delta); | 197 | auto location = Sink::Commands::CreateCreateEntity(fbb, type, delta); |
198 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 198 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
diff --git a/tests/genericresourcetest.cpp b/tests/genericresourcetest.cpp index 0c64659..76c604e 100644 --- a/tests/genericresourcetest.cpp +++ b/tests/genericresourcetest.cpp | |||
@@ -26,8 +26,8 @@ private Q_SLOTS: | |||
26 | 26 | ||
27 | void init() | 27 | void init() |
28 | { | 28 | { |
29 | Akonadi2::GenericResource::removeFromDisk("org.kde.test.instance1"); | 29 | Sink::GenericResource::removeFromDisk("org.kde.test.instance1"); |
30 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | 30 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
31 | } | 31 | } |
32 | 32 | ||
33 | ///Ensure the resource can process messages | 33 | ///Ensure the resource can process messages |
@@ -37,46 +37,46 @@ private Q_SLOTS: | |||
37 | eventFbb.Clear(); | 37 | eventFbb.Clear(); |
38 | { | 38 | { |
39 | auto summary = eventFbb.CreateString("summary"); | 39 | auto summary = eventFbb.CreateString("summary"); |
40 | Akonadi2::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); | 40 | Sink::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); |
41 | eventBuilder.add_summary(summary); | 41 | eventBuilder.add_summary(summary); |
42 | auto eventLocation = eventBuilder.Finish(); | 42 | auto eventLocation = eventBuilder.Finish(); |
43 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); | 43 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); |
44 | } | 44 | } |
45 | 45 | ||
46 | flatbuffers::FlatBufferBuilder localFbb; | 46 | flatbuffers::FlatBufferBuilder localFbb; |
47 | { | 47 | { |
48 | auto uid = localFbb.CreateString("testuid"); | 48 | auto uid = localFbb.CreateString("testuid"); |
49 | auto localBuilder = Akonadi2::ApplicationDomain::Buffer::EventBuilder(localFbb); | 49 | auto localBuilder = Sink::ApplicationDomain::Buffer::EventBuilder(localFbb); |
50 | localBuilder.add_uid(uid); | 50 | localBuilder.add_uid(uid); |
51 | auto location = localBuilder.Finish(); | 51 | auto location = localBuilder.Finish(); |
52 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); | 52 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); |
53 | } | 53 | } |
54 | 54 | ||
55 | flatbuffers::FlatBufferBuilder entityFbb; | 55 | flatbuffers::FlatBufferBuilder entityFbb; |
56 | Akonadi2::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); | 56 | Sink::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); |
57 | 57 | ||
58 | flatbuffers::FlatBufferBuilder fbb; | 58 | flatbuffers::FlatBufferBuilder fbb; |
59 | auto type = fbb.CreateString(Akonadi2::ApplicationDomain::getTypeName<Akonadi2::ApplicationDomain::Event>().toStdString().data()); | 59 | auto type = fbb.CreateString(Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>().toStdString().data()); |
60 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 60 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
61 | Akonadi2::Commands::CreateEntityBuilder builder(fbb); | 61 | Sink::Commands::CreateEntityBuilder builder(fbb); |
62 | builder.add_domainType(type); | 62 | builder.add_domainType(type); |
63 | builder.add_delta(delta); | 63 | builder.add_delta(delta); |
64 | auto location = builder.Finish(); | 64 | auto location = builder.Finish(); |
65 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 65 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); |
66 | 66 | ||
67 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 67 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); |
68 | { | 68 | { |
69 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command.data()), command.size()); | 69 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command.data()), command.size()); |
70 | QVERIFY(Akonadi2::Commands::VerifyCreateEntityBuffer(verifyer)); | 70 | QVERIFY(Sink::Commands::VerifyCreateEntityBuffer(verifyer)); |
71 | } | 71 | } |
72 | 72 | ||
73 | //Actual test | 73 | //Actual test |
74 | auto pipeline = QSharedPointer<Akonadi2::Pipeline>::create("org.kde.test.instance1"); | 74 | auto pipeline = QSharedPointer<Sink::Pipeline>::create("org.kde.test.instance1"); |
75 | QSignalSpy revisionSpy(pipeline.data(), SIGNAL(revisionUpdated(qint64))); | 75 | QSignalSpy revisionSpy(pipeline.data(), SIGNAL(revisionUpdated(qint64))); |
76 | QVERIFY(revisionSpy.isValid()); | 76 | QVERIFY(revisionSpy.isValid()); |
77 | TestResource resource("org.kde.test.instance1", pipeline); | 77 | TestResource resource("org.kde.test.instance1", pipeline); |
78 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); | 78 | resource.processCommand(Sink::Commands::CreateEntityCommand, command); |
79 | resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); | 79 | resource.processCommand(Sink::Commands::CreateEntityCommand, command); |
80 | resource.processAllMessages().exec().waitForFinished(); | 80 | resource.processAllMessages().exec().waitForFinished(); |
81 | QCOMPARE(revisionSpy.last().at(0).toInt(), 2); | 81 | QCOMPARE(revisionSpy.last().at(0).toInt(), 2); |
82 | } | 82 | } |
diff --git a/tests/hawd/CMakeLists.txt b/tests/hawd/CMakeLists.txt index 071f2ba..268e7a9 100644 --- a/tests/hawd/CMakeLists.txt +++ b/tests/hawd/CMakeLists.txt | |||
@@ -26,7 +26,7 @@ set(SRCS | |||
26 | add_library(lib${PROJECT_NAME} SHARED ${lib_SRCS}) | 26 | add_library(lib${PROJECT_NAME} SHARED ${lib_SRCS}) |
27 | generate_export_header(lib${PROJECT_NAME} BASE_NAME HAWD EXPORT_FILE_NAME hawd_export.h) | 27 | generate_export_header(lib${PROJECT_NAME} BASE_NAME HAWD EXPORT_FILE_NAME hawd_export.h) |
28 | qt5_use_modules(lib${PROJECT_NAME} Core) | 28 | qt5_use_modules(lib${PROJECT_NAME} Core) |
29 | target_link_libraries(lib${PROJECT_NAME} akonadi2common) | 29 | target_link_libraries(lib${PROJECT_NAME} sinkcommon) |
30 | if (LIBGIT2_FOUND) | 30 | if (LIBGIT2_FOUND) |
31 | target_link_libraries(lib${PROJECT_NAME} ${LIBGIT2_LIBRARIES}) | 31 | target_link_libraries(lib${PROJECT_NAME} ${LIBGIT2_LIBRARIES}) |
32 | endif(LIBGIT2_FOUND) | 32 | endif(LIBGIT2_FOUND) |
diff --git a/tests/hawd/dataset.cpp b/tests/hawd/dataset.cpp index 93eb5cd..fd931e8 100644 --- a/tests/hawd/dataset.cpp +++ b/tests/hawd/dataset.cpp | |||
@@ -215,7 +215,7 @@ QString Dataset::Row::toString(const QStringList &cols, int standardCols, const | |||
215 | 215 | ||
216 | Dataset::Dataset(const QString &name, const State &state) | 216 | Dataset::Dataset(const QString &name, const State &state) |
217 | : m_definition(state.datasetDefinition(name)), | 217 | : m_definition(state.datasetDefinition(name)), |
218 | m_storage(state.resultsPath(), name, Akonadi2::Storage::ReadWrite), | 218 | m_storage(state.resultsPath(), name, Sink::Storage::ReadWrite), |
219 | m_commitHash(state.commitHash()), | 219 | m_commitHash(state.commitHash()), |
220 | m_transaction(std::move(m_storage.createTransaction())) | 220 | m_transaction(std::move(m_storage.createTransaction())) |
221 | { | 221 | { |
@@ -270,13 +270,13 @@ void Dataset::eachRow(const std::function<void(const Row &row)> &resultHandler) | |||
270 | resultHandler(row); | 270 | resultHandler(row); |
271 | return true; | 271 | return true; |
272 | }, | 272 | }, |
273 | Akonadi2::Storage::basicErrorHandler()); | 273 | Sink::Storage::basicErrorHandler()); |
274 | } | 274 | } |
275 | 275 | ||
276 | Dataset::Row Dataset::row(qint64 key) | 276 | Dataset::Row Dataset::row(qint64 key) |
277 | { | 277 | { |
278 | if (key < 1) { | 278 | if (key < 1) { |
279 | Row row(*this, Akonadi2::Storage::maxRevision(m_transaction)); | 279 | Row row(*this, Sink::Storage::maxRevision(m_transaction)); |
280 | row.setCommitHash(m_commitHash); | 280 | row.setCommitHash(m_commitHash); |
281 | return row; | 281 | return row; |
282 | } | 282 | } |
@@ -287,7 +287,7 @@ Dataset::Row Dataset::row(qint64 key) | |||
287 | row.fromBinary(value); | 287 | row.fromBinary(value); |
288 | return true; | 288 | return true; |
289 | }, | 289 | }, |
290 | Akonadi2::Storage::basicErrorHandler() | 290 | Sink::Storage::basicErrorHandler() |
291 | ); | 291 | ); |
292 | return row; | 292 | return row; |
293 | } | 293 | } |
diff --git a/tests/hawd/dataset.h b/tests/hawd/dataset.h index cdfd3f2..0fca8f0 100644 --- a/tests/hawd/dataset.h +++ b/tests/hawd/dataset.h | |||
@@ -84,8 +84,8 @@ public: | |||
84 | 84 | ||
85 | private: | 85 | private: |
86 | DatasetDefinition m_definition; | 86 | DatasetDefinition m_definition; |
87 | Akonadi2::Storage m_storage; | 87 | Sink::Storage m_storage; |
88 | Akonadi2::Storage::Transaction m_transaction; | 88 | Sink::Storage::Transaction m_transaction; |
89 | QString m_commitHash; | 89 | QString m_commitHash; |
90 | }; | 90 | }; |
91 | 91 | ||
diff --git a/tests/indextest.cpp b/tests/indextest.cpp index edaf907..7ec95ce 100644 --- a/tests/indextest.cpp +++ b/tests/indextest.cpp | |||
@@ -16,19 +16,19 @@ class IndexTest : public QObject | |||
16 | private Q_SLOTS: | 16 | private Q_SLOTS: |
17 | void initTestCase() | 17 | void initTestCase() |
18 | { | 18 | { |
19 | Akonadi2::Storage store("./testindex", "org.kde.dummy.testindex", Akonadi2::Storage::ReadWrite); | 19 | Sink::Storage store("./testindex", "org.kde.dummy.testindex", Sink::Storage::ReadWrite); |
20 | store.removeFromDisk(); | 20 | store.removeFromDisk(); |
21 | } | 21 | } |
22 | 22 | ||
23 | void cleanup() | 23 | void cleanup() |
24 | { | 24 | { |
25 | Akonadi2::Storage store("./testindex", "org.kde.dummy.testindex", Akonadi2::Storage::ReadWrite); | 25 | Sink::Storage store("./testindex", "org.kde.dummy.testindex", Sink::Storage::ReadWrite); |
26 | store.removeFromDisk(); | 26 | store.removeFromDisk(); |
27 | } | 27 | } |
28 | 28 | ||
29 | void testIndex() | 29 | void testIndex() |
30 | { | 30 | { |
31 | Index index("./testindex", "org.kde.dummy.testindex", Akonadi2::Storage::ReadWrite); | 31 | Index index("./testindex", "org.kde.dummy.testindex", Sink::Storage::ReadWrite); |
32 | //The first key is specifically a substring of the second key | 32 | //The first key is specifically a substring of the second key |
33 | index.add("key", "value1"); | 33 | index.add("key", "value1"); |
34 | index.add("keyFoo", "value2"); | 34 | index.add("keyFoo", "value2"); |
diff --git a/tests/inspectiontest.cpp b/tests/inspectiontest.cpp index 29cce6c..c876aa9 100644 --- a/tests/inspectiontest.cpp +++ b/tests/inspectiontest.cpp | |||
@@ -18,8 +18,8 @@ class InspectionTest : public QObject | |||
18 | private Q_SLOTS: | 18 | private Q_SLOTS: |
19 | void initTestCase() | 19 | void initTestCase() |
20 | { | 20 | { |
21 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | 21 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
22 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | 22 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); |
23 | QVERIFY(factory); | 23 | QVERIFY(factory); |
24 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 24 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); |
25 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | 25 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); |
@@ -27,11 +27,11 @@ private Q_SLOTS: | |||
27 | 27 | ||
28 | void cleanup() | 28 | void cleanup() |
29 | { | 29 | { |
30 | Akonadi2::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 30 | Sink::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); |
31 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 31 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); |
32 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | 32 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); |
33 | QVERIFY(factory); | 33 | QVERIFY(factory); |
34 | Akonadi2::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 34 | Sink::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); |
35 | } | 35 | } |
36 | 36 | ||
37 | void testInspection_data() | 37 | void testInspection_data() |
@@ -44,8 +44,8 @@ private Q_SLOTS: | |||
44 | void testInspection() | 44 | void testInspection() |
45 | { | 45 | { |
46 | QFETCH(bool, success); | 46 | QFETCH(bool, success); |
47 | using namespace Akonadi2; | 47 | using namespace Sink; |
48 | using namespace Akonadi2::ApplicationDomain; | 48 | using namespace Sink::ApplicationDomain; |
49 | 49 | ||
50 | Mail mail(QByteArray("org.kde.dummy.instance1"), QByteArray("identifier"), 0, QSharedPointer<MemoryBufferAdaptor::MemoryBufferAdaptor>::create()); | 50 | Mail mail(QByteArray("org.kde.dummy.instance1"), QByteArray("identifier"), 0, QSharedPointer<MemoryBufferAdaptor::MemoryBufferAdaptor>::create()); |
51 | 51 | ||
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index ec4f6a4..6ad6ca6 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -57,18 +57,18 @@ private Q_SLOTS: | |||
57 | { | 57 | { |
58 | targetPath = tempDir.path() + "/maildir1/"; | 58 | targetPath = tempDir.path() + "/maildir1/"; |
59 | 59 | ||
60 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | 60 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
61 | MaildirResource::removeFromDisk("org.kde.maildir.instance1"); | 61 | MaildirResource::removeFromDisk("org.kde.maildir.instance1"); |
62 | Akonadi2::ApplicationDomain::AkonadiResource resource; | 62 | Sink::ApplicationDomain::SinkResource resource; |
63 | resource.setProperty("identifier", "org.kde.maildir.instance1"); | 63 | resource.setProperty("identifier", "org.kde.maildir.instance1"); |
64 | resource.setProperty("type", "org.kde.maildir"); | 64 | resource.setProperty("type", "org.kde.maildir"); |
65 | resource.setProperty("path", targetPath); | 65 | resource.setProperty("path", targetPath); |
66 | Akonadi2::Store::create(resource).exec().waitForFinished(); | 66 | Sink::Store::create(resource).exec().waitForFinished(); |
67 | } | 67 | } |
68 | 68 | ||
69 | void cleanup() | 69 | void cleanup() |
70 | { | 70 | { |
71 | Akonadi2::Store::shutdown(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); | 71 | Sink::Store::shutdown(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); |
72 | MaildirResource::removeFromDisk("org.kde.maildir.instance1"); | 72 | MaildirResource::removeFromDisk("org.kde.maildir.instance1"); |
73 | QDir dir(targetPath); | 73 | QDir dir(targetPath); |
74 | dir.removeRecursively(); | 74 | dir.removeRecursively(); |
@@ -80,46 +80,46 @@ private Q_SLOTS: | |||
80 | qDebug() << "-----------------------------------------"; | 80 | qDebug() << "-----------------------------------------"; |
81 | qDebug(); | 81 | qDebug(); |
82 | copyRecursively(TESTDATAPATH "/maildir1", targetPath); | 82 | copyRecursively(TESTDATAPATH "/maildir1", targetPath); |
83 | Akonadi2::Store::start(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); | 83 | Sink::Store::start(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); |
84 | } | 84 | } |
85 | 85 | ||
86 | void testListFolders() | 86 | void testListFolders() |
87 | { | 87 | { |
88 | Akonadi2::Query query; | 88 | Sink::Query query; |
89 | query.resources << "org.kde.maildir.instance1"; | 89 | query.resources << "org.kde.maildir.instance1"; |
90 | 90 | ||
91 | //Ensure all local data is processed | 91 | //Ensure all local data is processed |
92 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 92 | Sink::Store::synchronize(query).exec().waitForFinished(); |
93 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 93 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
94 | 94 | ||
95 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 95 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
96 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 96 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
97 | QCOMPARE(model->rowCount(QModelIndex()), 2); | 97 | QCOMPARE(model->rowCount(QModelIndex()), 2); |
98 | } | 98 | } |
99 | 99 | ||
100 | void testListFolderTree() | 100 | void testListFolderTree() |
101 | { | 101 | { |
102 | Akonadi2::Query query; | 102 | Sink::Query query; |
103 | query.resources << "org.kde.maildir.instance1"; | 103 | query.resources << "org.kde.maildir.instance1"; |
104 | query.parentProperty = "parent"; | 104 | query.parentProperty = "parent"; |
105 | 105 | ||
106 | //Ensure all local data is processed | 106 | //Ensure all local data is processed |
107 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 107 | Sink::Store::synchronize(query).exec().waitForFinished(); |
108 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 108 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
109 | 109 | ||
110 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 110 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
111 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 111 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
112 | QCOMPARE(model->rowCount(QModelIndex()), 1); | 112 | QCOMPARE(model->rowCount(QModelIndex()), 1); |
113 | auto parentIndex = model->index(0, 0, QModelIndex()); | 113 | auto parentIndex = model->index(0, 0, QModelIndex()); |
114 | model->fetchMore(parentIndex); | 114 | model->fetchMore(parentIndex); |
115 | QTRY_VERIFY(model->data(parentIndex, Akonadi2::Store::ChildrenFetchedRole).toBool()); | 115 | QTRY_VERIFY(model->data(parentIndex, Sink::Store::ChildrenFetchedRole).toBool()); |
116 | QCOMPARE(model->rowCount(parentIndex), 1); | 116 | QCOMPARE(model->rowCount(parentIndex), 1); |
117 | } | 117 | } |
118 | 118 | ||
119 | void testListMailsOfFolder() | 119 | void testListMailsOfFolder() |
120 | { | 120 | { |
121 | using namespace Akonadi2; | 121 | using namespace Sink; |
122 | using namespace Akonadi2::ApplicationDomain; | 122 | using namespace Sink::ApplicationDomain; |
123 | //Ensure all local data is processed | 123 | //Ensure all local data is processed |
124 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); | 124 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
125 | Store::synchronize(query).exec().waitForFinished(); | 125 | Store::synchronize(query).exec().waitForFinished(); |
@@ -143,18 +143,18 @@ private Q_SLOTS: | |||
143 | 143 | ||
144 | void testMailContent() | 144 | void testMailContent() |
145 | { | 145 | { |
146 | Akonadi2::Query query; | 146 | Sink::Query query; |
147 | query.resources << "org.kde.maildir.instance1"; | 147 | query.resources << "org.kde.maildir.instance1"; |
148 | query.requestedProperties << "folder" << "subject" << "mimeMessage" << "date"; | 148 | query.requestedProperties << "folder" << "subject" << "mimeMessage" << "date"; |
149 | 149 | ||
150 | //Ensure all local data is processed | 150 | //Ensure all local data is processed |
151 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 151 | Sink::Store::synchronize(query).exec().waitForFinished(); |
152 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 152 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
153 | 153 | ||
154 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 154 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
155 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 155 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
156 | QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); | 156 | QVERIFY(mailModel->rowCount(QModelIndex()) >= 1); |
157 | auto mail = mailModel->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>(); | 157 | auto mail = mailModel->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>(); |
158 | QVERIFY(!mail->getProperty("subject").toString().isEmpty()); | 158 | QVERIFY(!mail->getProperty("subject").toString().isEmpty()); |
159 | QVERIFY(!mail->getProperty("mimeMessage").toString().isEmpty()); | 159 | QVERIFY(!mail->getProperty("mimeMessage").toString().isEmpty()); |
160 | QVERIFY(mail->getProperty("date").toDateTime().isValid()); | 160 | QVERIFY(mail->getProperty("date").toDateTime().isValid()); |
@@ -163,85 +163,85 @@ private Q_SLOTS: | |||
163 | 163 | ||
164 | void testSyncFolderMove() | 164 | void testSyncFolderMove() |
165 | { | 165 | { |
166 | Akonadi2::Query query; | 166 | Sink::Query query; |
167 | query.resources << "org.kde.maildir.instance1"; | 167 | query.resources << "org.kde.maildir.instance1"; |
168 | query.requestedProperties << "name"; | 168 | query.requestedProperties << "name"; |
169 | 169 | ||
170 | //Ensure all local data is processed | 170 | //Ensure all local data is processed |
171 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 171 | Sink::Store::synchronize(query).exec().waitForFinished(); |
172 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 172 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
173 | 173 | ||
174 | auto targetPath = tempDir.path() + "/maildir1/"; | 174 | auto targetPath = tempDir.path() + "/maildir1/"; |
175 | QDir dir(targetPath); | 175 | QDir dir(targetPath); |
176 | QVERIFY(dir.rename("inbox", "newbox")); | 176 | QVERIFY(dir.rename("inbox", "newbox")); |
177 | 177 | ||
178 | //Ensure all local data is processed | 178 | //Ensure all local data is processed |
179 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 179 | Sink::Store::synchronize(query).exec().waitForFinished(); |
180 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 180 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
181 | 181 | ||
182 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 182 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
183 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 183 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
184 | QCOMPARE(model->rowCount(QModelIndex()), 2); | 184 | QCOMPARE(model->rowCount(QModelIndex()), 2); |
185 | QCOMPARE(model->match(model->index(0, 0, QModelIndex()), Qt::DisplayRole, QStringLiteral("newbox"), 1).size(), 1); | 185 | QCOMPARE(model->match(model->index(0, 0, QModelIndex()), Qt::DisplayRole, QStringLiteral("newbox"), 1).size(), 1); |
186 | } | 186 | } |
187 | 187 | ||
188 | void testReSyncMail() | 188 | void testReSyncMail() |
189 | { | 189 | { |
190 | Akonadi2::Query query; | 190 | Sink::Query query; |
191 | query.resources << "org.kde.maildir.instance1"; | 191 | query.resources << "org.kde.maildir.instance1"; |
192 | query.requestedProperties << "folder" << "subject"; | 192 | query.requestedProperties << "folder" << "subject"; |
193 | 193 | ||
194 | //Ensure all local data is processed | 194 | //Ensure all local data is processed |
195 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 195 | Sink::Store::synchronize(query).exec().waitForFinished(); |
196 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 196 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
197 | 197 | ||
198 | //Ensure all local data is processed | 198 | //Ensure all local data is processed |
199 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 199 | Sink::Store::synchronize(query).exec().waitForFinished(); |
200 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 200 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
201 | 201 | ||
202 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 202 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
203 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 203 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
204 | QCOMPARE(mailModel->rowCount(QModelIndex()), 2); | 204 | QCOMPARE(mailModel->rowCount(QModelIndex()), 2); |
205 | } | 205 | } |
206 | 206 | ||
207 | void testSyncMailRemoval() | 207 | void testSyncMailRemoval() |
208 | { | 208 | { |
209 | Akonadi2::Query query; | 209 | Sink::Query query; |
210 | query.resources << "org.kde.maildir.instance1"; | 210 | query.resources << "org.kde.maildir.instance1"; |
211 | query.requestedProperties << "folder" << "subject"; | 211 | query.requestedProperties << "folder" << "subject"; |
212 | 212 | ||
213 | //Ensure all local data is processed | 213 | //Ensure all local data is processed |
214 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 214 | Sink::Store::synchronize(query).exec().waitForFinished(); |
215 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 215 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
216 | 216 | ||
217 | auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; | 217 | auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; |
218 | QFile file(targetPath); | 218 | QFile file(targetPath); |
219 | QVERIFY(file.remove()); | 219 | QVERIFY(file.remove()); |
220 | 220 | ||
221 | //Ensure all local data is processed | 221 | //Ensure all local data is processed |
222 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 222 | Sink::Store::synchronize(query).exec().waitForFinished(); |
223 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 223 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
224 | 224 | ||
225 | auto mailModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 225 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
226 | QTRY_VERIFY(mailModel->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 226 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
227 | QCOMPARE(mailModel->rowCount(QModelIndex()), 1); | 227 | QCOMPARE(mailModel->rowCount(QModelIndex()), 1); |
228 | } | 228 | } |
229 | 229 | ||
230 | void testCreateFolder() | 230 | void testCreateFolder() |
231 | { | 231 | { |
232 | Akonadi2::Query query; | 232 | Sink::Query query; |
233 | query.resources << "org.kde.maildir.instance1"; | 233 | query.resources << "org.kde.maildir.instance1"; |
234 | 234 | ||
235 | //Ensure all local data is processed | 235 | //Ensure all local data is processed |
236 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 236 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
237 | 237 | ||
238 | Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); | 238 | Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); |
239 | folder.setProperty("name", "testCreateFolder"); | 239 | folder.setProperty("name", "testCreateFolder"); |
240 | 240 | ||
241 | Akonadi2::Store::create(folder).exec().waitForFinished(); | 241 | Sink::Store::create(folder).exec().waitForFinished(); |
242 | 242 | ||
243 | //Ensure all local data is processed | 243 | //Ensure all local data is processed |
244 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 244 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
245 | 245 | ||
246 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; | 246 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; |
247 | QFileInfo file(targetPath); | 247 | QFileInfo file(targetPath); |
@@ -251,45 +251,45 @@ private Q_SLOTS: | |||
251 | 251 | ||
252 | void testRemoveFolder() | 252 | void testRemoveFolder() |
253 | { | 253 | { |
254 | Akonadi2::Query query; | 254 | Sink::Query query; |
255 | query.resources << "org.kde.maildir.instance1"; | 255 | query.resources << "org.kde.maildir.instance1"; |
256 | 256 | ||
257 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; | 257 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; |
258 | 258 | ||
259 | Akonadi2::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); | 259 | Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); |
260 | folder.setProperty("name", "testCreateFolder"); | 260 | folder.setProperty("name", "testCreateFolder"); |
261 | Akonadi2::Store::create(folder).exec().waitForFinished(); | 261 | Sink::Store::create(folder).exec().waitForFinished(); |
262 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 262 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
263 | QTRY_VERIFY(QFileInfo(targetPath).exists()); | 263 | QTRY_VERIFY(QFileInfo(targetPath).exists()); |
264 | 264 | ||
265 | Akonadi2::Query folderQuery; | 265 | Sink::Query folderQuery; |
266 | folderQuery.resources << "org.kde.maildir.instance1"; | 266 | folderQuery.resources << "org.kde.maildir.instance1"; |
267 | folderQuery.propertyFilter.insert("name", "testCreateFolder"); | 267 | folderQuery.propertyFilter.insert("name", "testCreateFolder"); |
268 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(folderQuery); | 268 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(folderQuery); |
269 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 269 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
270 | QCOMPARE(model->rowCount(QModelIndex()), 1); | 270 | QCOMPARE(model->rowCount(QModelIndex()), 1); |
271 | auto createdFolder = model->index(0, 0, QModelIndex()).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | 271 | auto createdFolder = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); |
272 | 272 | ||
273 | Akonadi2::Store::remove(*createdFolder).exec().waitForFinished(); | 273 | Sink::Store::remove(*createdFolder).exec().waitForFinished(); |
274 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 274 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
275 | QTRY_VERIFY(!QFileInfo(targetPath).exists()); | 275 | QTRY_VERIFY(!QFileInfo(targetPath).exists()); |
276 | } | 276 | } |
277 | 277 | ||
278 | void testCreateMail() | 278 | void testCreateMail() |
279 | { | 279 | { |
280 | Akonadi2::Query query; | 280 | Sink::Query query; |
281 | query.resources << "org.kde.maildir.instance1"; | 281 | query.resources << "org.kde.maildir.instance1"; |
282 | 282 | ||
283 | //Ensure all local data is processed | 283 | //Ensure all local data is processed |
284 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 284 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
285 | 285 | ||
286 | Akonadi2::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); | 286 | Sink::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); |
287 | mail.setProperty("name", "testCreateMail"); | 287 | mail.setProperty("name", "testCreateMail"); |
288 | 288 | ||
289 | Akonadi2::Store::create(mail).exec().waitForFinished(); | 289 | Sink::Store::create(mail).exec().waitForFinished(); |
290 | 290 | ||
291 | //Ensure all local data is processed | 291 | //Ensure all local data is processed |
292 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 292 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
293 | 293 | ||
294 | auto targetPath = tempDir.path() + "/maildir1/new"; | 294 | auto targetPath = tempDir.path() + "/maildir1/new"; |
295 | QDir dir(targetPath); | 295 | QDir dir(targetPath); |
@@ -299,8 +299,8 @@ private Q_SLOTS: | |||
299 | 299 | ||
300 | void testRemoveMail() | 300 | void testRemoveMail() |
301 | { | 301 | { |
302 | using namespace Akonadi2; | 302 | using namespace Sink; |
303 | using namespace Akonadi2::ApplicationDomain; | 303 | using namespace Sink::ApplicationDomain; |
304 | 304 | ||
305 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); | 305 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
306 | Store::synchronize(query).exec().waitForFinished(); | 306 | Store::synchronize(query).exec().waitForFinished(); |
@@ -333,8 +333,8 @@ private Q_SLOTS: | |||
333 | 333 | ||
334 | void testMarkMailAsRead() | 334 | void testMarkMailAsRead() |
335 | { | 335 | { |
336 | using namespace Akonadi2; | 336 | using namespace Sink; |
337 | using namespace Akonadi2::ApplicationDomain; | 337 | using namespace Sink::ApplicationDomain; |
338 | 338 | ||
339 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); | 339 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
340 | Store::synchronize(query).exec().waitForFinished(); | 340 | Store::synchronize(query).exec().waitForFinished(); |
diff --git a/tests/messagequeuetest.cpp b/tests/messagequeuetest.cpp index 7d406ed..c835b53 100644 --- a/tests/messagequeuetest.cpp +++ b/tests/messagequeuetest.cpp | |||
@@ -17,8 +17,8 @@ class MessageQueueTest : public QObject | |||
17 | private Q_SLOTS: | 17 | private Q_SLOTS: |
18 | void initTestCase() | 18 | void initTestCase() |
19 | { | 19 | { |
20 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | 20 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
21 | Akonadi2::Storage store(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue", Akonadi2::Storage::ReadWrite); | 21 | Sink::Storage store(Sink::Store::storageLocation(), "org.kde.dummy.testqueue", Sink::Storage::ReadWrite); |
22 | store.removeFromDisk(); | 22 | store.removeFromDisk(); |
23 | } | 23 | } |
24 | 24 | ||
@@ -28,13 +28,13 @@ private Q_SLOTS: | |||
28 | 28 | ||
29 | void cleanup() | 29 | void cleanup() |
30 | { | 30 | { |
31 | Akonadi2::Storage store(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue", Akonadi2::Storage::ReadWrite); | 31 | Sink::Storage store(Sink::Store::storageLocation(), "org.kde.dummy.testqueue", Sink::Storage::ReadWrite); |
32 | store.removeFromDisk(); | 32 | store.removeFromDisk(); |
33 | } | 33 | } |
34 | 34 | ||
35 | void testEmpty() | 35 | void testEmpty() |
36 | { | 36 | { |
37 | MessageQueue queue(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue"); | 37 | MessageQueue queue(Sink::Store::storageLocation(), "org.kde.dummy.testqueue"); |
38 | QVERIFY(queue.isEmpty()); | 38 | QVERIFY(queue.isEmpty()); |
39 | queue.enqueue("value"); | 39 | queue.enqueue("value"); |
40 | QVERIFY(!queue.isEmpty()); | 40 | QVERIFY(!queue.isEmpty()); |
@@ -42,7 +42,7 @@ private Q_SLOTS: | |||
42 | 42 | ||
43 | void testDequeueEmpty() | 43 | void testDequeueEmpty() |
44 | { | 44 | { |
45 | MessageQueue queue(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue"); | 45 | MessageQueue queue(Sink::Store::storageLocation(), "org.kde.dummy.testqueue"); |
46 | bool gotValue = false; | 46 | bool gotValue = false; |
47 | bool gotError = false; | 47 | bool gotError = false; |
48 | queue.dequeue([&](void *ptr, int size, std::function<void(bool success)> callback) { | 48 | queue.dequeue([&](void *ptr, int size, std::function<void(bool success)> callback) { |
@@ -57,7 +57,7 @@ private Q_SLOTS: | |||
57 | 57 | ||
58 | void testEnqueue() | 58 | void testEnqueue() |
59 | { | 59 | { |
60 | MessageQueue queue(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue"); | 60 | MessageQueue queue(Sink::Store::storageLocation(), "org.kde.dummy.testqueue"); |
61 | QSignalSpy spy(&queue, SIGNAL(messageReady())); | 61 | QSignalSpy spy(&queue, SIGNAL(messageReady())); |
62 | queue.enqueue("value1"); | 62 | queue.enqueue("value1"); |
63 | QCOMPARE(spy.size(), 1); | 63 | QCOMPARE(spy.size(), 1); |
@@ -65,7 +65,7 @@ private Q_SLOTS: | |||
65 | 65 | ||
66 | void testDrained() | 66 | void testDrained() |
67 | { | 67 | { |
68 | MessageQueue queue(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue"); | 68 | MessageQueue queue(Sink::Store::storageLocation(), "org.kde.dummy.testqueue"); |
69 | QSignalSpy spy(&queue, SIGNAL(drained())); | 69 | QSignalSpy spy(&queue, SIGNAL(drained())); |
70 | queue.enqueue("value1"); | 70 | queue.enqueue("value1"); |
71 | 71 | ||
@@ -81,7 +81,7 @@ private Q_SLOTS: | |||
81 | values << "value1"; | 81 | values << "value1"; |
82 | values << "value2"; | 82 | values << "value2"; |
83 | 83 | ||
84 | MessageQueue queue(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue"); | 84 | MessageQueue queue(Sink::Store::storageLocation(), "org.kde.dummy.testqueue"); |
85 | for (const QByteArray &value : values) { | 85 | for (const QByteArray &value : values) { |
86 | queue.enqueue(value); | 86 | queue.enqueue(value); |
87 | } | 87 | } |
@@ -112,7 +112,7 @@ private Q_SLOTS: | |||
112 | values << "value1"; | 112 | values << "value1"; |
113 | values << "value2"; | 113 | values << "value2"; |
114 | 114 | ||
115 | MessageQueue queue(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue"); | 115 | MessageQueue queue(Sink::Store::storageLocation(), "org.kde.dummy.testqueue"); |
116 | for (const QByteArray &value : values) { | 116 | for (const QByteArray &value : values) { |
117 | queue.enqueue(value); | 117 | queue.enqueue(value); |
118 | } | 118 | } |
@@ -151,7 +151,7 @@ private Q_SLOTS: | |||
151 | */ | 151 | */ |
152 | void testNestedEnqueue() | 152 | void testNestedEnqueue() |
153 | { | 153 | { |
154 | MessageQueue queue(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue"); | 154 | MessageQueue queue(Sink::Store::storageLocation(), "org.kde.dummy.testqueue"); |
155 | queue.enqueue("value1"); | 155 | queue.enqueue("value1"); |
156 | 156 | ||
157 | bool gotError = false; | 157 | bool gotError = false; |
@@ -167,7 +167,7 @@ private Q_SLOTS: | |||
167 | 167 | ||
168 | void testBatchDequeue() | 168 | void testBatchDequeue() |
169 | { | 169 | { |
170 | MessageQueue queue(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue"); | 170 | MessageQueue queue(Sink::Store::storageLocation(), "org.kde.dummy.testqueue"); |
171 | queue.enqueue("value1"); | 171 | queue.enqueue("value1"); |
172 | queue.enqueue("value2"); | 172 | queue.enqueue("value2"); |
173 | queue.enqueue("value3"); | 173 | queue.enqueue("value3"); |
@@ -188,7 +188,7 @@ private Q_SLOTS: | |||
188 | 188 | ||
189 | void testBatchEnqueue() | 189 | void testBatchEnqueue() |
190 | { | 190 | { |
191 | MessageQueue queue(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue"); | 191 | MessageQueue queue(Sink::Store::storageLocation(), "org.kde.dummy.testqueue"); |
192 | QSignalSpy spy(&queue, SIGNAL(messageReady())); | 192 | QSignalSpy spy(&queue, SIGNAL(messageReady())); |
193 | queue.startTransaction(); | 193 | queue.startTransaction(); |
194 | queue.enqueue("value1"); | 194 | queue.enqueue("value1"); |
diff --git a/tests/modelinteractivitytest.cpp b/tests/modelinteractivitytest.cpp index 59c2c6f..14c9fd0 100644 --- a/tests/modelinteractivitytest.cpp +++ b/tests/modelinteractivitytest.cpp | |||
@@ -45,16 +45,16 @@ class ModelinteractivityTest : public QObject | |||
45 | private Q_SLOTS: | 45 | private Q_SLOTS: |
46 | void initTestCase() | 46 | void initTestCase() |
47 | { | 47 | { |
48 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Warning); | 48 | Sink::Log::setDebugOutputLevel(Sink::Log::Warning); |
49 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 49 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); |
50 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | 50 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); |
51 | } | 51 | } |
52 | 52 | ||
53 | void cleanup() | 53 | void cleanup() |
54 | { | 54 | { |
55 | Akonadi2::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 55 | Sink::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); |
56 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 56 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); |
57 | Akonadi2::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 57 | Sink::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void init() | 60 | void init() |
@@ -65,24 +65,24 @@ private Q_SLOTS: | |||
65 | { | 65 | { |
66 | //Setup | 66 | //Setup |
67 | { | 67 | { |
68 | Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 68 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); |
69 | for (int i = 0; i < 1000; i++) { | 69 | for (int i = 0; i < 1000; i++) { |
70 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 70 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | Akonadi2::Query query; | 74 | Sink::Query query; |
75 | query.resources << "org.kde.dummy.instance1"; | 75 | query.resources << "org.kde.dummy.instance1"; |
76 | query.liveQuery = true; | 76 | query.liveQuery = true; |
77 | 77 | ||
78 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 78 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
79 | 79 | ||
80 | //Test | 80 | //Test |
81 | QTime time; | 81 | QTime time; |
82 | time.start(); | 82 | time.start(); |
83 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 83 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
84 | blockingTime += time.elapsed(); | 84 | blockingTime += time.elapsed(); |
85 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 85 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
86 | //Never block longer than 10 ms | 86 | //Never block longer than 10 ms |
87 | QVERIFY2(blockingTime < 10, QString("Total blocking time: %1").arg(blockingTime).toLatin1().data()); | 87 | QVERIFY2(blockingTime < 10, QString("Total blocking time: %1").arg(blockingTime).toLatin1().data()); |
88 | } | 88 | } |
diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp index f0fd1a4..c74d319 100644 --- a/tests/pipelinetest.cpp +++ b/tests/pipelinetest.cpp | |||
@@ -22,14 +22,14 @@ | |||
22 | 22 | ||
23 | static void removeFromDisk(const QString &name) | 23 | static void removeFromDisk(const QString &name) |
24 | { | 24 | { |
25 | Akonadi2::Storage store(Akonadi2::Store::storageLocation(), name, Akonadi2::Storage::ReadWrite); | 25 | Sink::Storage store(Sink::Store::storageLocation(), name, Sink::Storage::ReadWrite); |
26 | store.removeFromDisk(); | 26 | store.removeFromDisk(); |
27 | } | 27 | } |
28 | 28 | ||
29 | static QList<QByteArray> getKeys(const QByteArray &dbEnv, const QByteArray &name) | 29 | static QList<QByteArray> getKeys(const QByteArray &dbEnv, const QByteArray &name) |
30 | { | 30 | { |
31 | Akonadi2::Storage store(Akonadi2::storageLocation(), dbEnv, Akonadi2::Storage::ReadOnly); | 31 | Sink::Storage store(Sink::storageLocation(), dbEnv, Sink::Storage::ReadOnly); |
32 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadOnly); | 32 | auto transaction = store.createTransaction(Sink::Storage::ReadOnly); |
33 | auto db = transaction.openDatabase(name, nullptr, false); | 33 | auto db = transaction.openDatabase(name, nullptr, false); |
34 | QList<QByteArray> result; | 34 | QList<QByteArray> result; |
35 | db.scan("", [&](const QByteArray &key, const QByteArray &value) { | 35 | db.scan("", [&](const QByteArray &key, const QByteArray &value) { |
@@ -41,8 +41,8 @@ static QList<QByteArray> getKeys(const QByteArray &dbEnv, const QByteArray &name | |||
41 | 41 | ||
42 | static QByteArray getEntity(const QByteArray &dbEnv, const QByteArray &name, const QByteArray &uid) | 42 | static QByteArray getEntity(const QByteArray &dbEnv, const QByteArray &name, const QByteArray &uid) |
43 | { | 43 | { |
44 | Akonadi2::Storage store(Akonadi2::storageLocation(), dbEnv, Akonadi2::Storage::ReadOnly); | 44 | Sink::Storage store(Sink::storageLocation(), dbEnv, Sink::Storage::ReadOnly); |
45 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadOnly); | 45 | auto transaction = store.createTransaction(Sink::Storage::ReadOnly); |
46 | auto db = transaction.openDatabase(name, nullptr, false); | 46 | auto db = transaction.openDatabase(name, nullptr, false); |
47 | QByteArray result; | 47 | QByteArray result; |
48 | db.scan(uid, [&](const QByteArray &key, const QByteArray &value) { | 48 | db.scan(uid, [&](const QByteArray &key, const QByteArray &value) { |
@@ -57,41 +57,41 @@ flatbuffers::FlatBufferBuilder &createEvent(flatbuffers::FlatBufferBuilder &enti | |||
57 | flatbuffers::FlatBufferBuilder eventFbb; | 57 | flatbuffers::FlatBufferBuilder eventFbb; |
58 | eventFbb.Clear(); | 58 | eventFbb.Clear(); |
59 | { | 59 | { |
60 | Akonadi2::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); | 60 | Sink::ApplicationDomain::Buffer::EventBuilder eventBuilder(eventFbb); |
61 | auto eventLocation = eventBuilder.Finish(); | 61 | auto eventLocation = eventBuilder.Finish(); |
62 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); | 62 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(eventFbb, eventLocation); |
63 | } | 63 | } |
64 | 64 | ||
65 | flatbuffers::FlatBufferBuilder localFbb; | 65 | flatbuffers::FlatBufferBuilder localFbb; |
66 | { | 66 | { |
67 | auto uid = localFbb.CreateString("testuid"); | 67 | auto uid = localFbb.CreateString("testuid"); |
68 | auto summary = localFbb.CreateString(s.toStdString()); | 68 | auto summary = localFbb.CreateString(s.toStdString()); |
69 | auto localBuilder = Akonadi2::ApplicationDomain::Buffer::EventBuilder(localFbb); | 69 | auto localBuilder = Sink::ApplicationDomain::Buffer::EventBuilder(localFbb); |
70 | localBuilder.add_uid(uid); | 70 | localBuilder.add_uid(uid); |
71 | localBuilder.add_summary(summary); | 71 | localBuilder.add_summary(summary); |
72 | auto location = localBuilder.Finish(); | 72 | auto location = localBuilder.Finish(); |
73 | Akonadi2::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); | 73 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); |
74 | } | 74 | } |
75 | 75 | ||
76 | Akonadi2::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); | 76 | Sink::EntityBuffer::assembleEntityBuffer(entityFbb, 0, 0, eventFbb.GetBufferPointer(), eventFbb.GetSize(), localFbb.GetBufferPointer(), localFbb.GetSize()); |
77 | return entityFbb; | 77 | return entityFbb; |
78 | } | 78 | } |
79 | 79 | ||
80 | QByteArray createEntityCommand(const flatbuffers::FlatBufferBuilder &entityFbb) | 80 | QByteArray createEntityCommand(const flatbuffers::FlatBufferBuilder &entityFbb) |
81 | { | 81 | { |
82 | flatbuffers::FlatBufferBuilder fbb; | 82 | flatbuffers::FlatBufferBuilder fbb; |
83 | auto type = fbb.CreateString(Akonadi2::ApplicationDomain::getTypeName<Akonadi2::ApplicationDomain::Event>().toStdString().data()); | 83 | auto type = fbb.CreateString(Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>().toStdString().data()); |
84 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 84 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
85 | Akonadi2::Commands::CreateEntityBuilder builder(fbb); | 85 | Sink::Commands::CreateEntityBuilder builder(fbb); |
86 | builder.add_domainType(type); | 86 | builder.add_domainType(type); |
87 | builder.add_delta(delta); | 87 | builder.add_delta(delta); |
88 | auto location = builder.Finish(); | 88 | auto location = builder.Finish(); |
89 | Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); | 89 | Sink::Commands::FinishCreateEntityBuffer(fbb, location); |
90 | 90 | ||
91 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 91 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); |
92 | { | 92 | { |
93 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command.data()), command.size()); | 93 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command.data()), command.size()); |
94 | Q_ASSERT(Akonadi2::Commands::VerifyCreateEntityBuffer(verifyer)); | 94 | Q_ASSERT(Sink::Commands::VerifyCreateEntityBuffer(verifyer)); |
95 | } | 95 | } |
96 | return command; | 96 | return command; |
97 | } | 97 | } |
@@ -99,22 +99,22 @@ QByteArray createEntityCommand(const flatbuffers::FlatBufferBuilder &entityFbb) | |||
99 | QByteArray modifyEntityCommand(const flatbuffers::FlatBufferBuilder &entityFbb, const QByteArray &uid, qint64 revision) | 99 | QByteArray modifyEntityCommand(const flatbuffers::FlatBufferBuilder &entityFbb, const QByteArray &uid, qint64 revision) |
100 | { | 100 | { |
101 | flatbuffers::FlatBufferBuilder fbb; | 101 | flatbuffers::FlatBufferBuilder fbb; |
102 | auto type = fbb.CreateString(Akonadi2::ApplicationDomain::getTypeName<Akonadi2::ApplicationDomain::Event>().toStdString().data()); | 102 | auto type = fbb.CreateString(Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>().toStdString().data()); |
103 | auto id = fbb.CreateString(std::string(uid.constData(), uid.size())); | 103 | auto id = fbb.CreateString(std::string(uid.constData(), uid.size())); |
104 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); | 104 | auto delta = fbb.CreateVector<uint8_t>(entityFbb.GetBufferPointer(), entityFbb.GetSize()); |
105 | // auto delta = Akonadi2::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size()); | 105 | // auto delta = Sink::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size()); |
106 | Akonadi2::Commands::ModifyEntityBuilder builder(fbb); | 106 | Sink::Commands::ModifyEntityBuilder builder(fbb); |
107 | builder.add_domainType(type); | 107 | builder.add_domainType(type); |
108 | builder.add_delta(delta); | 108 | builder.add_delta(delta); |
109 | builder.add_revision(revision); | 109 | builder.add_revision(revision); |
110 | builder.add_entityId(id); | 110 | builder.add_entityId(id); |
111 | auto location = builder.Finish(); | 111 | auto location = builder.Finish(); |
112 | Akonadi2::Commands::FinishModifyEntityBuffer(fbb, location); | 112 | Sink::Commands::FinishModifyEntityBuffer(fbb, location); |
113 | 113 | ||
114 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 114 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); |
115 | { | 115 | { |
116 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command.data()), command.size()); | 116 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command.data()), command.size()); |
117 | Q_ASSERT(Akonadi2::Commands::VerifyCreateEntityBuffer(verifyer)); | 117 | Q_ASSERT(Sink::Commands::VerifyCreateEntityBuffer(verifyer)); |
118 | } | 118 | } |
119 | return command; | 119 | return command; |
120 | } | 120 | } |
@@ -122,38 +122,38 @@ QByteArray modifyEntityCommand(const flatbuffers::FlatBufferBuilder &entityFbb, | |||
122 | QByteArray deleteEntityCommand(const QByteArray &uid, qint64 revision) | 122 | QByteArray deleteEntityCommand(const QByteArray &uid, qint64 revision) |
123 | { | 123 | { |
124 | flatbuffers::FlatBufferBuilder fbb; | 124 | flatbuffers::FlatBufferBuilder fbb; |
125 | auto type = fbb.CreateString(Akonadi2::ApplicationDomain::getTypeName<Akonadi2::ApplicationDomain::Event>().toStdString().data()); | 125 | auto type = fbb.CreateString(Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>().toStdString().data()); |
126 | auto id = fbb.CreateString(std::string(uid.constData(), uid.size())); | 126 | auto id = fbb.CreateString(std::string(uid.constData(), uid.size())); |
127 | Akonadi2::Commands::DeleteEntityBuilder builder(fbb); | 127 | Sink::Commands::DeleteEntityBuilder builder(fbb); |
128 | builder.add_domainType(type); | 128 | builder.add_domainType(type); |
129 | builder.add_revision(revision); | 129 | builder.add_revision(revision); |
130 | builder.add_entityId(id); | 130 | builder.add_entityId(id); |
131 | auto location = builder.Finish(); | 131 | auto location = builder.Finish(); |
132 | Akonadi2::Commands::FinishDeleteEntityBuffer(fbb, location); | 132 | Sink::Commands::FinishDeleteEntityBuffer(fbb, location); |
133 | 133 | ||
134 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); | 134 | const QByteArray command(reinterpret_cast<const char *>(fbb.GetBufferPointer()), fbb.GetSize()); |
135 | { | 135 | { |
136 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command.data()), command.size()); | 136 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command.data()), command.size()); |
137 | Q_ASSERT(Akonadi2::Commands::VerifyDeleteEntityBuffer(verifyer)); | 137 | Q_ASSERT(Sink::Commands::VerifyDeleteEntityBuffer(verifyer)); |
138 | } | 138 | } |
139 | return command; | 139 | return command; |
140 | } | 140 | } |
141 | 141 | ||
142 | class TestProcessor : public Akonadi2::Preprocessor { | 142 | class TestProcessor : public Sink::Preprocessor { |
143 | public: | 143 | public: |
144 | void newEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 144 | void newEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
145 | { | 145 | { |
146 | newUids << uid; | 146 | newUids << uid; |
147 | newRevisions << revision; | 147 | newRevisions << revision; |
148 | } | 148 | } |
149 | 149 | ||
150 | void modifiedEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, const Akonadi2::ApplicationDomain::BufferAdaptor &newEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 150 | void modifiedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, const Sink::ApplicationDomain::BufferAdaptor &newEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
151 | { | 151 | { |
152 | modifiedUids << uid; | 152 | modifiedUids << uid; |
153 | modifiedRevisions << revision; | 153 | modifiedRevisions << revision; |
154 | } | 154 | } |
155 | 155 | ||
156 | void deletedEntity(const QByteArray &uid, qint64 revision, const Akonadi2::ApplicationDomain::BufferAdaptor &oldEntity, Akonadi2::Storage::Transaction &transaction) Q_DECL_OVERRIDE | 156 | void deletedEntity(const QByteArray &uid, qint64 revision, const Sink::ApplicationDomain::BufferAdaptor &oldEntity, Sink::Storage::Transaction &transaction) Q_DECL_OVERRIDE |
157 | { | 157 | { |
158 | deletedUids << uid; | 158 | deletedUids << uid; |
159 | deletedRevisions << revision; | 159 | deletedRevisions << revision; |
@@ -178,7 +178,7 @@ class PipelineTest : public QObject | |||
178 | private Q_SLOTS: | 178 | private Q_SLOTS: |
179 | void initTestCase() | 179 | void initTestCase() |
180 | { | 180 | { |
181 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | 181 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
182 | } | 182 | } |
183 | 183 | ||
184 | void init() | 184 | void init() |
@@ -191,7 +191,7 @@ private Q_SLOTS: | |||
191 | flatbuffers::FlatBufferBuilder entityFbb; | 191 | flatbuffers::FlatBufferBuilder entityFbb; |
192 | auto command = createEntityCommand(createEvent(entityFbb)); | 192 | auto command = createEntityCommand(createEvent(entityFbb)); |
193 | 193 | ||
194 | Akonadi2::Pipeline pipeline("org.kde.pipelinetest.instance1"); | 194 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); |
195 | pipeline.startTransaction(); | 195 | pipeline.startTransaction(); |
196 | pipeline.newEntity(command.constData(), command.size()); | 196 | pipeline.newEntity(command.constData(), command.size()); |
197 | pipeline.commit(); | 197 | pipeline.commit(); |
@@ -205,7 +205,7 @@ private Q_SLOTS: | |||
205 | flatbuffers::FlatBufferBuilder entityFbb; | 205 | flatbuffers::FlatBufferBuilder entityFbb; |
206 | auto command = createEntityCommand(createEvent(entityFbb)); | 206 | auto command = createEntityCommand(createEvent(entityFbb)); |
207 | 207 | ||
208 | Akonadi2::Pipeline pipeline("org.kde.pipelinetest.instance1"); | 208 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); |
209 | 209 | ||
210 | auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); | 210 | auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); |
211 | pipeline.setAdaptorFactory("event", adaptorFactory); | 211 | pipeline.setAdaptorFactory("event", adaptorFactory); |
@@ -219,7 +219,7 @@ private Q_SLOTS: | |||
219 | auto keys = getKeys("org.kde.pipelinetest.instance1", "event.main"); | 219 | auto keys = getKeys("org.kde.pipelinetest.instance1", "event.main"); |
220 | QCOMPARE(keys.size(), 1); | 220 | QCOMPARE(keys.size(), 1); |
221 | const auto key = keys.first(); | 221 | const auto key = keys.first(); |
222 | const auto uid = Akonadi2::Storage::uidFromKey(key); | 222 | const auto uid = Sink::Storage::uidFromKey(key); |
223 | 223 | ||
224 | //Execute the modification | 224 | //Execute the modification |
225 | entityFbb.Clear(); | 225 | entityFbb.Clear(); |
@@ -229,9 +229,9 @@ private Q_SLOTS: | |||
229 | pipeline.commit(); | 229 | pipeline.commit(); |
230 | 230 | ||
231 | //Ensure we've got the new revision with the modification | 231 | //Ensure we've got the new revision with the modification |
232 | auto buffer = getEntity("org.kde.pipelinetest.instance1", "event.main", Akonadi2::Storage::assembleKey(uid, 2)); | 232 | auto buffer = getEntity("org.kde.pipelinetest.instance1", "event.main", Sink::Storage::assembleKey(uid, 2)); |
233 | QVERIFY(!buffer.isEmpty()); | 233 | QVERIFY(!buffer.isEmpty()); |
234 | Akonadi2::EntityBuffer entityBuffer(buffer.data(), buffer.size()); | 234 | Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); |
235 | auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); | 235 | auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); |
236 | QCOMPARE(adaptor->getProperty("summary").toString(), QString("summary2")); | 236 | QCOMPARE(adaptor->getProperty("summary").toString(), QString("summary2")); |
237 | 237 | ||
@@ -252,7 +252,7 @@ private Q_SLOTS: | |||
252 | flatbuffers::FlatBufferBuilder entityFbb; | 252 | flatbuffers::FlatBufferBuilder entityFbb; |
253 | auto command = createEntityCommand(createEvent(entityFbb)); | 253 | auto command = createEntityCommand(createEvent(entityFbb)); |
254 | 254 | ||
255 | Akonadi2::Pipeline pipeline("org.kde.pipelinetest.instance1"); | 255 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); |
256 | 256 | ||
257 | auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); | 257 | auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); |
258 | pipeline.setAdaptorFactory("event", adaptorFactory); | 258 | pipeline.setAdaptorFactory("event", adaptorFactory); |
@@ -265,7 +265,7 @@ private Q_SLOTS: | |||
265 | //Get uid of written entity | 265 | //Get uid of written entity |
266 | auto keys = getKeys("org.kde.pipelinetest.instance1", "event.main"); | 266 | auto keys = getKeys("org.kde.pipelinetest.instance1", "event.main"); |
267 | QCOMPARE(keys.size(), 1); | 267 | QCOMPARE(keys.size(), 1); |
268 | const auto uid = Akonadi2::Storage::uidFromKey(keys.first()); | 268 | const auto uid = Sink::Storage::uidFromKey(keys.first()); |
269 | 269 | ||
270 | 270 | ||
271 | //Create another operation inbetween | 271 | //Create another operation inbetween |
@@ -285,9 +285,9 @@ private Q_SLOTS: | |||
285 | pipeline.commit(); | 285 | pipeline.commit(); |
286 | 286 | ||
287 | //Ensure we've got the new revision with the modification | 287 | //Ensure we've got the new revision with the modification |
288 | auto buffer = getEntity("org.kde.pipelinetest.instance1", "event.main", Akonadi2::Storage::assembleKey(uid, 3)); | 288 | auto buffer = getEntity("org.kde.pipelinetest.instance1", "event.main", Sink::Storage::assembleKey(uid, 3)); |
289 | QVERIFY(!buffer.isEmpty()); | 289 | QVERIFY(!buffer.isEmpty()); |
290 | Akonadi2::EntityBuffer entityBuffer(buffer.data(), buffer.size()); | 290 | Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); |
291 | auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); | 291 | auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); |
292 | QCOMPARE(adaptor->getProperty("summary").toString(), QString("summary2")); | 292 | QCOMPARE(adaptor->getProperty("summary").toString(), QString("summary2")); |
293 | } | 293 | } |
@@ -296,7 +296,7 @@ private Q_SLOTS: | |||
296 | { | 296 | { |
297 | flatbuffers::FlatBufferBuilder entityFbb; | 297 | flatbuffers::FlatBufferBuilder entityFbb; |
298 | auto command = createEntityCommand(createEvent(entityFbb)); | 298 | auto command = createEntityCommand(createEvent(entityFbb)); |
299 | Akonadi2::Pipeline pipeline("org.kde.pipelinetest.instance1"); | 299 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); |
300 | pipeline.setAdaptorFactory("event", QSharedPointer<TestEventAdaptorFactory>::create()); | 300 | pipeline.setAdaptorFactory("event", QSharedPointer<TestEventAdaptorFactory>::create()); |
301 | 301 | ||
302 | //Create the initial revision | 302 | //Create the initial revision |
@@ -307,7 +307,7 @@ private Q_SLOTS: | |||
307 | auto result = getKeys("org.kde.pipelinetest.instance1", "event.main"); | 307 | auto result = getKeys("org.kde.pipelinetest.instance1", "event.main"); |
308 | QCOMPARE(result.size(), 1); | 308 | QCOMPARE(result.size(), 1); |
309 | 309 | ||
310 | const auto uid = Akonadi2::Storage::uidFromKey(result.first()); | 310 | const auto uid = Sink::Storage::uidFromKey(result.first()); |
311 | 311 | ||
312 | //Delete entity | 312 | //Delete entity |
313 | auto deleteCommand = deleteEntityCommand(uid, 1); | 313 | auto deleteCommand = deleteEntityCommand(uid, 1); |
@@ -333,8 +333,8 @@ private Q_SLOTS: | |||
333 | 333 | ||
334 | TestProcessor testProcessor; | 334 | TestProcessor testProcessor; |
335 | 335 | ||
336 | Akonadi2::Pipeline pipeline("org.kde.pipelinetest.instance1"); | 336 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); |
337 | pipeline.setPreprocessors("event", QVector<Akonadi2::Preprocessor*>() << &testProcessor); | 337 | pipeline.setPreprocessors("event", QVector<Sink::Preprocessor*>() << &testProcessor); |
338 | pipeline.startTransaction(); | 338 | pipeline.startTransaction(); |
339 | pipeline.setAdaptorFactory("event", QSharedPointer<TestEventAdaptorFactory>::create()); | 339 | pipeline.setAdaptorFactory("event", QSharedPointer<TestEventAdaptorFactory>::create()); |
340 | 340 | ||
@@ -345,21 +345,21 @@ private Q_SLOTS: | |||
345 | QCOMPARE(testProcessor.newUids.size(), 1); | 345 | QCOMPARE(testProcessor.newUids.size(), 1); |
346 | QCOMPARE(testProcessor.newRevisions.size(), 1); | 346 | QCOMPARE(testProcessor.newRevisions.size(), 1); |
347 | //Key doesn't contain revision and is just the uid | 347 | //Key doesn't contain revision and is just the uid |
348 | QCOMPARE(testProcessor.newUids.at(0), Akonadi2::Storage::uidFromKey(testProcessor.newUids.at(0))); | 348 | QCOMPARE(testProcessor.newUids.at(0), Sink::Storage::uidFromKey(testProcessor.newUids.at(0))); |
349 | } | 349 | } |
350 | pipeline.commit(); | 350 | pipeline.commit(); |
351 | entityFbb.Clear(); | 351 | entityFbb.Clear(); |
352 | pipeline.startTransaction(); | 352 | pipeline.startTransaction(); |
353 | auto keys = getKeys("org.kde.pipelinetest.instance1", "event.main"); | 353 | auto keys = getKeys("org.kde.pipelinetest.instance1", "event.main"); |
354 | QCOMPARE(keys.size(), 1); | 354 | QCOMPARE(keys.size(), 1); |
355 | const auto uid = Akonadi2::Storage::uidFromKey(keys.first()); | 355 | const auto uid = Sink::Storage::uidFromKey(keys.first()); |
356 | { | 356 | { |
357 | auto modifyCommand = modifyEntityCommand(createEvent(entityFbb, "summary2"), uid, 1); | 357 | auto modifyCommand = modifyEntityCommand(createEvent(entityFbb, "summary2"), uid, 1); |
358 | pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size()); | 358 | pipeline.modifiedEntity(modifyCommand.constData(), modifyCommand.size()); |
359 | QCOMPARE(testProcessor.modifiedUids.size(), 1); | 359 | QCOMPARE(testProcessor.modifiedUids.size(), 1); |
360 | QCOMPARE(testProcessor.modifiedRevisions.size(), 1); | 360 | QCOMPARE(testProcessor.modifiedRevisions.size(), 1); |
361 | //Key doesn't contain revision and is just the uid | 361 | //Key doesn't contain revision and is just the uid |
362 | QCOMPARE(testProcessor.modifiedUids.at(0), Akonadi2::Storage::uidFromKey(testProcessor.modifiedUids.at(0))); | 362 | QCOMPARE(testProcessor.modifiedUids.at(0), Sink::Storage::uidFromKey(testProcessor.modifiedUids.at(0))); |
363 | } | 363 | } |
364 | pipeline.commit(); | 364 | pipeline.commit(); |
365 | entityFbb.Clear(); | 365 | entityFbb.Clear(); |
@@ -371,7 +371,7 @@ private Q_SLOTS: | |||
371 | QCOMPARE(testProcessor.deletedUids.size(), 1); | 371 | QCOMPARE(testProcessor.deletedUids.size(), 1); |
372 | QCOMPARE(testProcessor.deletedSummaries.size(), 1); | 372 | QCOMPARE(testProcessor.deletedSummaries.size(), 1); |
373 | //Key doesn't contain revision and is just the uid | 373 | //Key doesn't contain revision and is just the uid |
374 | QCOMPARE(testProcessor.deletedUids.at(0), Akonadi2::Storage::uidFromKey(testProcessor.deletedUids.at(0))); | 374 | QCOMPARE(testProcessor.deletedUids.at(0), Sink::Storage::uidFromKey(testProcessor.deletedUids.at(0))); |
375 | QCOMPARE(testProcessor.deletedSummaries.at(0), QByteArray("summary2")); | 375 | QCOMPARE(testProcessor.deletedSummaries.at(0), QByteArray("summary2")); |
376 | } | 376 | } |
377 | } | 377 | } |
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index f9344cd..62db15b 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -20,8 +20,8 @@ class QueryTest : public QObject | |||
20 | private Q_SLOTS: | 20 | private Q_SLOTS: |
21 | void initTestCase() | 21 | void initTestCase() |
22 | { | 22 | { |
23 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | 23 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
24 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | 24 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); |
25 | QVERIFY(factory); | 25 | QVERIFY(factory); |
26 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 26 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); |
27 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | 27 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); |
@@ -29,11 +29,11 @@ private Q_SLOTS: | |||
29 | 29 | ||
30 | void cleanup() | 30 | void cleanup() |
31 | { | 31 | { |
32 | Akonadi2::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 32 | Sink::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); |
33 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 33 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); |
34 | auto factory = Akonadi2::ResourceFactory::load("org.kde.dummy"); | 34 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); |
35 | QVERIFY(factory); | 35 | QVERIFY(factory); |
36 | Akonadi2::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 36 | Sink::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); |
37 | } | 37 | } |
38 | 38 | ||
39 | void init() | 39 | void init() |
@@ -46,13 +46,13 @@ private Q_SLOTS: | |||
46 | void testNoResources() | 46 | void testNoResources() |
47 | { | 47 | { |
48 | //Test | 48 | //Test |
49 | Akonadi2::Query query; | 49 | Sink::Query query; |
50 | query.resources << "foobar"; | 50 | query.resources << "foobar"; |
51 | query.liveQuery = true; | 51 | query.liveQuery = true; |
52 | 52 | ||
53 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 53 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
54 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 54 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
55 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 55 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
56 | QCOMPARE(model->rowCount(), 0); | 56 | QCOMPARE(model->rowCount(), 0); |
57 | } | 57 | } |
58 | 58 | ||
@@ -61,17 +61,17 @@ private Q_SLOTS: | |||
61 | { | 61 | { |
62 | //Setup | 62 | //Setup |
63 | { | 63 | { |
64 | Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 64 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); |
65 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 65 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
66 | } | 66 | } |
67 | 67 | ||
68 | //Test | 68 | //Test |
69 | Akonadi2::Query query; | 69 | Sink::Query query; |
70 | query.resources << "org.kde.dummy.instance1"; | 70 | query.resources << "org.kde.dummy.instance1"; |
71 | query.liveQuery = true; | 71 | query.liveQuery = true; |
72 | 72 | ||
73 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 73 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
74 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 74 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
75 | model->fetchMore(QModelIndex()); | 75 | model->fetchMore(QModelIndex()); |
76 | QTRY_COMPARE(model->rowCount(), 1); | 76 | QTRY_COMPARE(model->rowCount(), 1); |
77 | } | 77 | } |
@@ -80,23 +80,23 @@ private Q_SLOTS: | |||
80 | { | 80 | { |
81 | //Setup | 81 | //Setup |
82 | { | 82 | { |
83 | Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 83 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); |
84 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 84 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
85 | } | 85 | } |
86 | 86 | ||
87 | //Test | 87 | //Test |
88 | Akonadi2::Query query; | 88 | Sink::Query query; |
89 | query.resources << "org.kde.dummy.instance1"; | 89 | query.resources << "org.kde.dummy.instance1"; |
90 | query.liveQuery = false; | 90 | query.liveQuery = false; |
91 | 91 | ||
92 | //Ensure all local data is processed | 92 | //Ensure all local data is processed |
93 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 93 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
94 | 94 | ||
95 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data | 95 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data |
96 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 96 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
97 | 97 | ||
98 | model->fetchMore(QModelIndex()); | 98 | model->fetchMore(QModelIndex()); |
99 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 99 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
100 | QCOMPARE(model->rowCount(), 1); | 100 | QCOMPARE(model->rowCount(), 1); |
101 | } | 101 | } |
102 | 102 | ||
@@ -105,31 +105,31 @@ private Q_SLOTS: | |||
105 | QByteArray id; | 105 | QByteArray id; |
106 | //Setup | 106 | //Setup |
107 | { | 107 | { |
108 | Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 108 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); |
109 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 109 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
110 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 110 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
111 | 111 | ||
112 | Akonadi2::Query query; | 112 | Sink::Query query; |
113 | query.resources << "org.kde.dummy.instance1"; | 113 | query.resources << "org.kde.dummy.instance1"; |
114 | 114 | ||
115 | //Ensure all local data is processed | 115 | //Ensure all local data is processed |
116 | Akonadi2::Store::synchronize(query).exec().waitForFinished(); | 116 | Sink::Store::synchronize(query).exec().waitForFinished(); |
117 | 117 | ||
118 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 118 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
119 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 119 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
120 | model->fetchMore(QModelIndex()); | 120 | model->fetchMore(QModelIndex()); |
121 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 121 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
122 | QVERIFY(model->rowCount() >= 1); | 122 | QVERIFY(model->rowCount() >= 1); |
123 | id = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Mail::Ptr>()->identifier(); | 123 | id = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Mail::Ptr>()->identifier(); |
124 | } | 124 | } |
125 | 125 | ||
126 | //Test | 126 | //Test |
127 | Akonadi2::Query query; | 127 | Sink::Query query; |
128 | query.resources << "org.kde.dummy.instance1"; | 128 | query.resources << "org.kde.dummy.instance1"; |
129 | query.ids << id; | 129 | query.ids << id; |
130 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 130 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
131 | model->fetchMore(QModelIndex()); | 131 | model->fetchMore(QModelIndex()); |
132 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 132 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
133 | QCOMPARE(model->rowCount(), 1); | 133 | QCOMPARE(model->rowCount(), 1); |
134 | } | 134 | } |
135 | 135 | ||
@@ -137,20 +137,20 @@ private Q_SLOTS: | |||
137 | { | 137 | { |
138 | //Setup | 138 | //Setup |
139 | { | 139 | { |
140 | Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 140 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); |
141 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(folder).exec().waitForFinished(); | 141 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); |
142 | } | 142 | } |
143 | 143 | ||
144 | //Test | 144 | //Test |
145 | Akonadi2::Query query; | 145 | Sink::Query query; |
146 | query.resources << "org.kde.dummy.instance1"; | 146 | query.resources << "org.kde.dummy.instance1"; |
147 | query.liveQuery = true; | 147 | query.liveQuery = true; |
148 | 148 | ||
149 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 149 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
150 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 150 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
151 | model->fetchMore(QModelIndex()); | 151 | model->fetchMore(QModelIndex()); |
152 | QTRY_COMPARE(model->rowCount(), 1); | 152 | QTRY_COMPARE(model->rowCount(), 1); |
153 | auto folderEntity = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | 153 | auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); |
154 | QVERIFY(!folderEntity->identifier().isEmpty()); | 154 | QVERIFY(!folderEntity->identifier().isEmpty()); |
155 | } | 155 | } |
156 | 156 | ||
@@ -158,42 +158,42 @@ private Q_SLOTS: | |||
158 | { | 158 | { |
159 | //Setup | 159 | //Setup |
160 | { | 160 | { |
161 | Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 161 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); |
162 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(folder).exec().waitForFinished(); | 162 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); |
163 | 163 | ||
164 | Akonadi2::Query query; | 164 | Sink::Query query; |
165 | query.resources << "org.kde.dummy.instance1"; | 165 | query.resources << "org.kde.dummy.instance1"; |
166 | 166 | ||
167 | //Ensure all local data is processed | 167 | //Ensure all local data is processed |
168 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 168 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
169 | 169 | ||
170 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 170 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
171 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 171 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
172 | QCOMPARE(model->rowCount(), 1); | 172 | QCOMPARE(model->rowCount(), 1); |
173 | 173 | ||
174 | auto folderEntity = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | 174 | auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); |
175 | QVERIFY(!folderEntity->identifier().isEmpty()); | 175 | QVERIFY(!folderEntity->identifier().isEmpty()); |
176 | 176 | ||
177 | Akonadi2::ApplicationDomain::Folder subfolder("org.kde.dummy.instance1"); | 177 | Sink::ApplicationDomain::Folder subfolder("org.kde.dummy.instance1"); |
178 | subfolder.setProperty("parent", folderEntity->identifier()); | 178 | subfolder.setProperty("parent", folderEntity->identifier()); |
179 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(subfolder).exec().waitForFinished(); | 179 | Sink::Store::create<Sink::ApplicationDomain::Folder>(subfolder).exec().waitForFinished(); |
180 | } | 180 | } |
181 | 181 | ||
182 | //Test | 182 | //Test |
183 | Akonadi2::Query query; | 183 | Sink::Query query; |
184 | query.resources << "org.kde.dummy.instance1"; | 184 | query.resources << "org.kde.dummy.instance1"; |
185 | query.parentProperty = "parent"; | 185 | query.parentProperty = "parent"; |
186 | 186 | ||
187 | //Ensure all local data is processed | 187 | //Ensure all local data is processed |
188 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 188 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
189 | 189 | ||
190 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data | 190 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data |
191 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 191 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
192 | model->fetchMore(QModelIndex()); | 192 | model->fetchMore(QModelIndex()); |
193 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 193 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
194 | QCOMPARE(model->rowCount(), 1); | 194 | QCOMPARE(model->rowCount(), 1); |
195 | model->fetchMore(model->index(0, 0)); | 195 | model->fetchMore(model->index(0, 0)); |
196 | QTRY_VERIFY(model->data(model->index(0, 0), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 196 | QTRY_VERIFY(model->data(model->index(0, 0), Sink::Store::ChildrenFetchedRole).toBool()); |
197 | QCOMPARE(model->rowCount(model->index(0, 0)), 1); | 197 | QCOMPARE(model->rowCount(model->index(0, 0)), 1); |
198 | } | 198 | } |
199 | 199 | ||
@@ -201,65 +201,65 @@ private Q_SLOTS: | |||
201 | { | 201 | { |
202 | //Setup | 202 | //Setup |
203 | { | 203 | { |
204 | Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 204 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); |
205 | mail.setProperty("uid", "test1"); | 205 | mail.setProperty("uid", "test1"); |
206 | mail.setProperty("sender", "doe@example.org"); | 206 | mail.setProperty("sender", "doe@example.org"); |
207 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 207 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
208 | } | 208 | } |
209 | 209 | ||
210 | //Test | 210 | //Test |
211 | Akonadi2::Query query; | 211 | Sink::Query query; |
212 | query.resources << "org.kde.dummy.instance1"; | 212 | query.resources << "org.kde.dummy.instance1"; |
213 | query.liveQuery = false; | 213 | query.liveQuery = false; |
214 | query.propertyFilter.insert("uid", "test1"); | 214 | query.propertyFilter.insert("uid", "test1"); |
215 | 215 | ||
216 | //Ensure all local data is processed | 216 | //Ensure all local data is processed |
217 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 217 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
218 | 218 | ||
219 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 219 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
220 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 220 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
221 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 221 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
222 | QCOMPARE(model->rowCount(), 1); | 222 | QCOMPARE(model->rowCount(), 1); |
223 | } | 223 | } |
224 | 224 | ||
225 | void testMailByFolder() | 225 | void testMailByFolder() |
226 | { | 226 | { |
227 | //Setup | 227 | //Setup |
228 | Akonadi2::ApplicationDomain::Folder::Ptr folderEntity; | 228 | Sink::ApplicationDomain::Folder::Ptr folderEntity; |
229 | { | 229 | { |
230 | Akonadi2::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); | 230 | Sink::ApplicationDomain::Folder folder("org.kde.dummy.instance1"); |
231 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Folder>(folder).exec().waitForFinished(); | 231 | Sink::Store::create<Sink::ApplicationDomain::Folder>(folder).exec().waitForFinished(); |
232 | 232 | ||
233 | Akonadi2::Query query; | 233 | Sink::Query query; |
234 | query.resources << "org.kde.dummy.instance1"; | 234 | query.resources << "org.kde.dummy.instance1"; |
235 | 235 | ||
236 | //Ensure all local data is processed | 236 | //Ensure all local data is processed |
237 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 237 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
238 | 238 | ||
239 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Folder>(query); | 239 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
240 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 240 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
241 | QCOMPARE(model->rowCount(), 1); | 241 | QCOMPARE(model->rowCount(), 1); |
242 | 242 | ||
243 | folderEntity = model->index(0, 0).data(Akonadi2::Store::DomainObjectRole).value<Akonadi2::ApplicationDomain::Folder::Ptr>(); | 243 | folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); |
244 | QVERIFY(!folderEntity->identifier().isEmpty()); | 244 | QVERIFY(!folderEntity->identifier().isEmpty()); |
245 | 245 | ||
246 | Akonadi2::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); | 246 | Sink::ApplicationDomain::Mail mail("org.kde.dummy.instance1"); |
247 | mail.setProperty("uid", "test1"); | 247 | mail.setProperty("uid", "test1"); |
248 | mail.setProperty("folder", folderEntity->identifier()); | 248 | mail.setProperty("folder", folderEntity->identifier()); |
249 | Akonadi2::Store::create<Akonadi2::ApplicationDomain::Mail>(mail).exec().waitForFinished(); | 249 | Sink::Store::create<Sink::ApplicationDomain::Mail>(mail).exec().waitForFinished(); |
250 | } | 250 | } |
251 | 251 | ||
252 | //Test | 252 | //Test |
253 | Akonadi2::Query query; | 253 | Sink::Query query; |
254 | query.resources << "org.kde.dummy.instance1"; | 254 | query.resources << "org.kde.dummy.instance1"; |
255 | query.propertyFilter.insert("folder", folderEntity->identifier()); | 255 | query.propertyFilter.insert("folder", folderEntity->identifier()); |
256 | 256 | ||
257 | //Ensure all local data is processed | 257 | //Ensure all local data is processed |
258 | Akonadi2::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 258 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); |
259 | 259 | ||
260 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 260 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
261 | auto model = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | 261 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
262 | QTRY_VERIFY(model->data(QModelIndex(), Akonadi2::Store::ChildrenFetchedRole).toBool()); | 262 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
263 | QCOMPARE(model->rowCount(), 1); | 263 | QCOMPARE(model->rowCount(), 1); |
264 | } | 264 | } |
265 | }; | 265 | }; |
diff --git a/tests/resourcecommunicationtest.cpp b/tests/resourcecommunicationtest.cpp index 1b09c5f..f9ea3de 100644 --- a/tests/resourcecommunicationtest.cpp +++ b/tests/resourcecommunicationtest.cpp | |||
@@ -16,9 +16,9 @@ private Q_SLOTS: | |||
16 | { | 16 | { |
17 | const QByteArray resourceIdentifier("test"); | 17 | const QByteArray resourceIdentifier("test"); |
18 | Listener listener(resourceIdentifier); | 18 | Listener listener(resourceIdentifier); |
19 | Akonadi2::ResourceAccess resourceAccess(resourceIdentifier); | 19 | Sink::ResourceAccess resourceAccess(resourceIdentifier); |
20 | 20 | ||
21 | QSignalSpy spy(&resourceAccess, &Akonadi2::ResourceAccess::ready); | 21 | QSignalSpy spy(&resourceAccess, &Sink::ResourceAccess::ready); |
22 | resourceAccess.open(); | 22 | resourceAccess.open(); |
23 | QTRY_COMPARE(spy.size(), 1); | 23 | QTRY_COMPARE(spy.size(), 1); |
24 | } | 24 | } |
@@ -27,14 +27,14 @@ private Q_SLOTS: | |||
27 | { | 27 | { |
28 | const QByteArray resourceIdentifier("test"); | 28 | const QByteArray resourceIdentifier("test"); |
29 | Listener listener(resourceIdentifier); | 29 | Listener listener(resourceIdentifier); |
30 | Akonadi2::ResourceAccess resourceAccess(resourceIdentifier); | 30 | Sink::ResourceAccess resourceAccess(resourceIdentifier); |
31 | resourceAccess.open(); | 31 | resourceAccess.open(); |
32 | 32 | ||
33 | flatbuffers::FlatBufferBuilder fbb; | 33 | flatbuffers::FlatBufferBuilder fbb; |
34 | auto name = fbb.CreateString("test"); | 34 | auto name = fbb.CreateString("test"); |
35 | auto command = Akonadi2::Commands::CreateHandshake(fbb, name); | 35 | auto command = Sink::Commands::CreateHandshake(fbb, name); |
36 | Akonadi2::Commands::FinishHandshakeBuffer(fbb, command); | 36 | Sink::Commands::FinishHandshakeBuffer(fbb, command); |
37 | auto result = resourceAccess.sendCommand(Akonadi2::Commands::HandshakeCommand, fbb).exec(); | 37 | auto result = resourceAccess.sendCommand(Sink::Commands::HandshakeCommand, fbb).exec(); |
38 | result.waitForFinished(); | 38 | result.waitForFinished(); |
39 | QVERIFY(!result.errorCode()); | 39 | QVERIFY(!result.errorCode()); |
40 | } | 40 | } |
@@ -43,14 +43,14 @@ private Q_SLOTS: | |||
43 | { | 43 | { |
44 | const QByteArray resourceIdentifier("test"); | 44 | const QByteArray resourceIdentifier("test"); |
45 | Listener listener(resourceIdentifier); | 45 | Listener listener(resourceIdentifier); |
46 | Akonadi2::ResourceAccess resourceAccess(resourceIdentifier); | 46 | Sink::ResourceAccess resourceAccess(resourceIdentifier); |
47 | resourceAccess.open(); | 47 | resourceAccess.open(); |
48 | 48 | ||
49 | const int count = 500; | 49 | const int count = 500; |
50 | int complete = 0; | 50 | int complete = 0; |
51 | int errors = 0; | 51 | int errors = 0; |
52 | for (int i = 0; i < count; i++) { | 52 | for (int i = 0; i < count; i++) { |
53 | auto result = resourceAccess.sendCommand(Akonadi2::Commands::PingCommand) | 53 | auto result = resourceAccess.sendCommand(Sink::Commands::PingCommand) |
54 | .then<void>([&complete]() { | 54 | .then<void>([&complete]() { |
55 | complete++; | 55 | complete++; |
56 | }, | 56 | }, |
@@ -69,14 +69,14 @@ private Q_SLOTS: | |||
69 | qDebug(); | 69 | qDebug(); |
70 | const QByteArray resourceIdentifier("test"); | 70 | const QByteArray resourceIdentifier("test"); |
71 | Listener listener(resourceIdentifier); | 71 | Listener listener(resourceIdentifier); |
72 | Akonadi2::ResourceAccess resourceAccess(resourceIdentifier); | 72 | Sink::ResourceAccess resourceAccess(resourceIdentifier); |
73 | resourceAccess.open(); | 73 | resourceAccess.open(); |
74 | 74 | ||
75 | const int count = 10; | 75 | const int count = 10; |
76 | int complete = 0; | 76 | int complete = 0; |
77 | int errors = 0; | 77 | int errors = 0; |
78 | for (int i = 0; i < count; i++) { | 78 | for (int i = 0; i < count; i++) { |
79 | resourceAccess.sendCommand(Akonadi2::Commands::PingCommand) | 79 | resourceAccess.sendCommand(Sink::Commands::PingCommand) |
80 | .then<void>([&complete]() { | 80 | .then<void>([&complete]() { |
81 | complete++; | 81 | complete++; |
82 | }, | 82 | }, |
diff --git a/tests/storagebenchmark.cpp b/tests/storagebenchmark.cpp index 3e7b609..eada4ee 100644 --- a/tests/storagebenchmark.cpp +++ b/tests/storagebenchmark.cpp | |||
@@ -54,7 +54,7 @@ private: | |||
54 | private Q_SLOTS: | 54 | private Q_SLOTS: |
55 | void initTestCase() | 55 | void initTestCase() |
56 | { | 56 | { |
57 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Warning); | 57 | Sink::Log::setDebugOutputLevel(Sink::Log::Warning); |
58 | testDataPath = "./testdb"; | 58 | testDataPath = "./testdb"; |
59 | dbName = "test"; | 59 | dbName = "test"; |
60 | filePath = testDataPath + "buffer.fb"; | 60 | filePath = testDataPath + "buffer.fb"; |
@@ -62,7 +62,7 @@ private Q_SLOTS: | |||
62 | 62 | ||
63 | void cleanupTestCase() | 63 | void cleanupTestCase() |
64 | { | 64 | { |
65 | Akonadi2::Storage store(testDataPath, dbName); | 65 | Sink::Storage store(testDataPath, dbName); |
66 | store.removeFromDisk(); | 66 | store.removeFromDisk(); |
67 | } | 67 | } |
68 | 68 | ||
@@ -70,7 +70,7 @@ private Q_SLOTS: | |||
70 | { | 70 | { |
71 | auto event = createEvent(); | 71 | auto event = createEvent(); |
72 | 72 | ||
73 | QScopedPointer<Akonadi2::Storage> store(new Akonadi2::Storage(testDataPath, dbName, Akonadi2::Storage::ReadWrite)); | 73 | QScopedPointer<Sink::Storage> store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadWrite)); |
74 | 74 | ||
75 | const char *keyPrefix = "key"; | 75 | const char *keyPrefix = "key"; |
76 | 76 | ||
@@ -78,12 +78,12 @@ private Q_SLOTS: | |||
78 | time.start(); | 78 | time.start(); |
79 | //Test db write time | 79 | //Test db write time |
80 | { | 80 | { |
81 | auto transaction = store->createTransaction(Akonadi2::Storage::ReadWrite); | 81 | auto transaction = store->createTransaction(Sink::Storage::ReadWrite); |
82 | for (int i = 0; i < count; i++) { | 82 | for (int i = 0; i < count; i++) { |
83 | transaction.openDatabase().write(keyPrefix + QByteArray::number(i), event); | 83 | transaction.openDatabase().write(keyPrefix + QByteArray::number(i), event); |
84 | if ((i % 10000) == 0) { | 84 | if ((i % 10000) == 0) { |
85 | transaction.commit(); | 85 | transaction.commit(); |
86 | transaction = store->createTransaction(Akonadi2::Storage::ReadWrite); | 86 | transaction = store->createTransaction(Sink::Storage::ReadWrite); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | transaction.commit(); | 89 | transaction.commit(); |
@@ -105,7 +105,7 @@ private Q_SLOTS: | |||
105 | 105 | ||
106 | //Db read time | 106 | //Db read time |
107 | { | 107 | { |
108 | auto transaction = store->createTransaction(Akonadi2::Storage::ReadOnly); | 108 | auto transaction = store->createTransaction(Sink::Storage::ReadOnly); |
109 | auto db = transaction.openDatabase(); | 109 | auto db = transaction.openDatabase(); |
110 | for (int i = 0; i < count; i++) { | 110 | for (int i = 0; i < count; i++) { |
111 | db.scan(keyPrefix + QByteArray::number(i), [](const QByteArray &key, const QByteArray &value) -> bool { return true; }); | 111 | db.scan(keyPrefix + QByteArray::number(i), [](const QByteArray &key, const QByteArray &value) -> bool { return true; }); |
@@ -126,7 +126,7 @@ private Q_SLOTS: | |||
126 | 126 | ||
127 | void testSizes() | 127 | void testSizes() |
128 | { | 128 | { |
129 | Akonadi2::Storage store(testDataPath, dbName); | 129 | Sink::Storage store(testDataPath, dbName); |
130 | qDebug() << "Database size [kb]: " << store.diskUsage()/1024; | 130 | qDebug() << "Database size [kb]: " << store.diskUsage()/1024; |
131 | 131 | ||
132 | QFileInfo fileInfo(filePath); | 132 | QFileInfo fileInfo(filePath); |
@@ -135,11 +135,11 @@ private Q_SLOTS: | |||
135 | 135 | ||
136 | void testScan() | 136 | void testScan() |
137 | { | 137 | { |
138 | QScopedPointer<Akonadi2::Storage> store(new Akonadi2::Storage(testDataPath, dbName, Akonadi2::Storage::ReadOnly)); | 138 | QScopedPointer<Sink::Storage> store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); |
139 | 139 | ||
140 | QBENCHMARK { | 140 | QBENCHMARK { |
141 | int hit = 0; | 141 | int hit = 0; |
142 | store->createTransaction(Akonadi2::Storage::ReadOnly).openDatabase().scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { | 142 | store->createTransaction(Sink::Storage::ReadOnly).openDatabase().scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { |
143 | if (key == "key10000") { | 143 | if (key == "key10000") { |
144 | //qDebug() << "hit"; | 144 | //qDebug() << "hit"; |
145 | hit++; | 145 | hit++; |
@@ -152,11 +152,11 @@ private Q_SLOTS: | |||
152 | 152 | ||
153 | void testKeyLookup() | 153 | void testKeyLookup() |
154 | { | 154 | { |
155 | QScopedPointer<Akonadi2::Storage> store(new Akonadi2::Storage(testDataPath, dbName, Akonadi2::Storage::ReadOnly)); | 155 | QScopedPointer<Sink::Storage> store(new Sink::Storage(testDataPath, dbName, Sink::Storage::ReadOnly)); |
156 | 156 | ||
157 | QBENCHMARK { | 157 | QBENCHMARK { |
158 | int hit = 0; | 158 | int hit = 0; |
159 | store->createTransaction(Akonadi2::Storage::ReadOnly).openDatabase().scan("key40000", [&](const QByteArray &key, const QByteArray &value) -> bool { | 159 | store->createTransaction(Sink::Storage::ReadOnly).openDatabase().scan("key40000", [&](const QByteArray &key, const QByteArray &value) -> bool { |
160 | hit++; | 160 | hit++; |
161 | return true; | 161 | return true; |
162 | }); | 162 | }); |
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp index d950961..b0db1ac 100644 --- a/tests/storagetest.cpp +++ b/tests/storagetest.cpp | |||
@@ -21,14 +21,14 @@ private: | |||
21 | 21 | ||
22 | void populate(int count) | 22 | void populate(int count) |
23 | { | 23 | { |
24 | Akonadi2::Storage storage(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 24 | Sink::Storage storage(testDataPath, dbName, Sink::Storage::ReadWrite); |
25 | auto transaction = storage.createTransaction(Akonadi2::Storage::ReadWrite); | 25 | auto transaction = storage.createTransaction(Sink::Storage::ReadWrite); |
26 | for (int i = 0; i < count; i++) { | 26 | for (int i = 0; i < count; i++) { |
27 | //This should perhaps become an implementation detail of the db? | 27 | //This should perhaps become an implementation detail of the db? |
28 | if (i % 10000 == 0) { | 28 | if (i % 10000 == 0) { |
29 | if (i > 0) { | 29 | if (i > 0) { |
30 | transaction.commit(); | 30 | transaction.commit(); |
31 | transaction = std::move(storage.createTransaction(Akonadi2::Storage::ReadWrite)); | 31 | transaction = std::move(storage.createTransaction(Sink::Storage::ReadWrite)); |
32 | } | 32 | } |
33 | } | 33 | } |
34 | transaction.openDatabase().write(keyPrefix + QByteArray::number(i), keyPrefix + QByteArray::number(i)); | 34 | transaction.openDatabase().write(keyPrefix + QByteArray::number(i), keyPrefix + QByteArray::number(i)); |
@@ -36,12 +36,12 @@ private: | |||
36 | transaction.commit(); | 36 | transaction.commit(); |
37 | } | 37 | } |
38 | 38 | ||
39 | bool verify(Akonadi2::Storage &storage, int i) | 39 | bool verify(Sink::Storage &storage, int i) |
40 | { | 40 | { |
41 | bool success = true; | 41 | bool success = true; |
42 | bool keyMatch = true; | 42 | bool keyMatch = true; |
43 | const auto reference = keyPrefix + QByteArray::number(i); | 43 | const auto reference = keyPrefix + QByteArray::number(i); |
44 | storage.createTransaction(Akonadi2::Storage::ReadOnly).openDatabase().scan(keyPrefix + QByteArray::number(i), | 44 | storage.createTransaction(Sink::Storage::ReadOnly).openDatabase().scan(keyPrefix + QByteArray::number(i), |
45 | [&keyMatch, &reference](const QByteArray &key, const QByteArray &value) -> bool { | 45 | [&keyMatch, &reference](const QByteArray &key, const QByteArray &value) -> bool { |
46 | if (value != reference) { | 46 | if (value != reference) { |
47 | qDebug() << "Mismatch while reading"; | 47 | qDebug() << "Mismatch while reading"; |
@@ -49,7 +49,7 @@ private: | |||
49 | } | 49 | } |
50 | return keyMatch; | 50 | return keyMatch; |
51 | }, | 51 | }, |
52 | [&success](const Akonadi2::Storage::Error &error) { | 52 | [&success](const Sink::Storage::Error &error) { |
53 | qDebug() << error.message; | 53 | qDebug() << error.message; |
54 | success = false; | 54 | success = false; |
55 | } | 55 | } |
@@ -62,20 +62,20 @@ private Q_SLOTS: | |||
62 | { | 62 | { |
63 | testDataPath = "./testdb"; | 63 | testDataPath = "./testdb"; |
64 | dbName = "test"; | 64 | dbName = "test"; |
65 | Akonadi2::Storage storage(testDataPath, dbName); | 65 | Sink::Storage storage(testDataPath, dbName); |
66 | storage.removeFromDisk(); | 66 | storage.removeFromDisk(); |
67 | } | 67 | } |
68 | 68 | ||
69 | void cleanup() | 69 | void cleanup() |
70 | { | 70 | { |
71 | Akonadi2::Storage storage(testDataPath, dbName); | 71 | Sink::Storage storage(testDataPath, dbName); |
72 | storage.removeFromDisk(); | 72 | storage.removeFromDisk(); |
73 | } | 73 | } |
74 | 74 | ||
75 | void testCleanup() | 75 | void testCleanup() |
76 | { | 76 | { |
77 | populate(1); | 77 | populate(1); |
78 | Akonadi2::Storage storage(testDataPath, dbName); | 78 | Sink::Storage storage(testDataPath, dbName); |
79 | storage.removeFromDisk(); | 79 | storage.removeFromDisk(); |
80 | QFileInfo info(testDataPath + "/" + dbName); | 80 | QFileInfo info(testDataPath + "/" + dbName); |
81 | QVERIFY(!info.exists()); | 81 | QVERIFY(!info.exists()); |
@@ -89,7 +89,7 @@ private Q_SLOTS: | |||
89 | 89 | ||
90 | //ensure we can read everything back correctly | 90 | //ensure we can read everything back correctly |
91 | { | 91 | { |
92 | Akonadi2::Storage storage(testDataPath, dbName); | 92 | Sink::Storage storage(testDataPath, dbName); |
93 | for (int i = 0; i < count; i++) { | 93 | for (int i = 0; i < count; i++) { |
94 | QVERIFY(verify(storage, i)); | 94 | QVERIFY(verify(storage, i)); |
95 | } | 95 | } |
@@ -104,8 +104,8 @@ private Q_SLOTS: | |||
104 | //ensure we can scan for values | 104 | //ensure we can scan for values |
105 | { | 105 | { |
106 | int hit = 0; | 106 | int hit = 0; |
107 | Akonadi2::Storage store(testDataPath, dbName); | 107 | Sink::Storage store(testDataPath, dbName); |
108 | store.createTransaction(Akonadi2::Storage::ReadOnly).openDatabase().scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { | 108 | store.createTransaction(Sink::Storage::ReadOnly).openDatabase().scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { |
109 | if (key == "key50") { | 109 | if (key == "key50") { |
110 | hit++; | 110 | hit++; |
111 | } | 111 | } |
@@ -118,8 +118,8 @@ private Q_SLOTS: | |||
118 | { | 118 | { |
119 | int hit = 0; | 119 | int hit = 0; |
120 | bool foundInvalidValue = false; | 120 | bool foundInvalidValue = false; |
121 | Akonadi2::Storage store(testDataPath, dbName); | 121 | Sink::Storage store(testDataPath, dbName); |
122 | store.createTransaction(Akonadi2::Storage::ReadOnly).openDatabase().scan("key50", [&](const QByteArray &key, const QByteArray &value) -> bool { | 122 | store.createTransaction(Sink::Storage::ReadOnly).openDatabase().scan("key50", [&](const QByteArray &key, const QByteArray &value) -> bool { |
123 | if (key != "key50") { | 123 | if (key != "key50") { |
124 | foundInvalidValue = true; | 124 | foundInvalidValue = true; |
125 | } | 125 | } |
@@ -134,10 +134,10 @@ private Q_SLOTS: | |||
134 | void testNestedOperations() | 134 | void testNestedOperations() |
135 | { | 135 | { |
136 | populate(3); | 136 | populate(3); |
137 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 137 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
138 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 138 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); |
139 | transaction.openDatabase().scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool { | 139 | transaction.openDatabase().scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool { |
140 | transaction.openDatabase().remove(key, [](const Akonadi2::Storage::Error &) { | 140 | transaction.openDatabase().remove(key, [](const Sink::Storage::Error &) { |
141 | QVERIFY(false); | 141 | QVERIFY(false); |
142 | }); | 142 | }); |
143 | return false; | 143 | return false; |
@@ -147,9 +147,9 @@ private Q_SLOTS: | |||
147 | void testNestedTransactions() | 147 | void testNestedTransactions() |
148 | { | 148 | { |
149 | populate(3); | 149 | populate(3); |
150 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 150 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
151 | store.createTransaction(Akonadi2::Storage::ReadOnly).openDatabase().scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool { | 151 | store.createTransaction(Sink::Storage::ReadOnly).openDatabase().scan("key1", [&](const QByteArray &key, const QByteArray &value) -> bool { |
152 | store.createTransaction(Akonadi2::Storage::ReadWrite).openDatabase().remove(key, [](const Akonadi2::Storage::Error &) { | 152 | store.createTransaction(Sink::Storage::ReadWrite).openDatabase().remove(key, [](const Sink::Storage::Error &) { |
153 | QVERIFY(false); | 153 | QVERIFY(false); |
154 | }); | 154 | }); |
155 | return false; | 155 | return false; |
@@ -160,9 +160,9 @@ private Q_SLOTS: | |||
160 | { | 160 | { |
161 | bool gotResult = false; | 161 | bool gotResult = false; |
162 | bool gotError = false; | 162 | bool gotError = false; |
163 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 163 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
164 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadOnly); | 164 | auto transaction = store.createTransaction(Sink::Storage::ReadOnly); |
165 | auto db = transaction.openDatabase("default", [&](const Akonadi2::Storage::Error &error) { | 165 | auto db = transaction.openDatabase("default", [&](const Sink::Storage::Error &error) { |
166 | qDebug() << error.message; | 166 | qDebug() << error.message; |
167 | gotError = true; | 167 | gotError = true; |
168 | }); | 168 | }); |
@@ -170,7 +170,7 @@ private Q_SLOTS: | |||
170 | gotResult = true; | 170 | gotResult = true; |
171 | return false; | 171 | return false; |
172 | }, | 172 | }, |
173 | [&](const Akonadi2::Storage::Error &error) { | 173 | [&](const Sink::Storage::Error &error) { |
174 | qDebug() << error.message; | 174 | qDebug() << error.message; |
175 | gotError = true; | 175 | gotError = true; |
176 | }); | 176 | }); |
@@ -195,8 +195,8 @@ private Q_SLOTS: | |||
195 | const int concurrencyLevel = 20; | 195 | const int concurrencyLevel = 20; |
196 | for (int num = 0; num < concurrencyLevel; num++) { | 196 | for (int num = 0; num < concurrencyLevel; num++) { |
197 | futures << QtConcurrent::run([this, count, &error](){ | 197 | futures << QtConcurrent::run([this, count, &error](){ |
198 | Akonadi2::Storage storage(testDataPath, dbName, Akonadi2::Storage::ReadOnly); | 198 | Sink::Storage storage(testDataPath, dbName, Sink::Storage::ReadOnly); |
199 | Akonadi2::Storage storage2(testDataPath, dbName + "2", Akonadi2::Storage::ReadOnly); | 199 | Sink::Storage storage2(testDataPath, dbName + "2", Sink::Storage::ReadOnly); |
200 | for (int i = 0; i < count; i++) { | 200 | for (int i = 0; i < count; i++) { |
201 | if (!verify(storage, i)) { | 201 | if (!verify(storage, i)) { |
202 | error = true; | 202 | error = true; |
@@ -212,9 +212,9 @@ private Q_SLOTS: | |||
212 | } | 212 | } |
213 | 213 | ||
214 | { | 214 | { |
215 | Akonadi2::Storage storage(testDataPath, dbName); | 215 | Sink::Storage storage(testDataPath, dbName); |
216 | storage.removeFromDisk(); | 216 | storage.removeFromDisk(); |
217 | Akonadi2::Storage storage2(testDataPath, dbName + "2"); | 217 | Sink::Storage storage2(testDataPath, dbName + "2"); |
218 | storage2.removeFromDisk(); | 218 | storage2.removeFromDisk(); |
219 | } | 219 | } |
220 | } | 220 | } |
@@ -223,8 +223,8 @@ private Q_SLOTS: | |||
223 | { | 223 | { |
224 | bool gotResult = false; | 224 | bool gotResult = false; |
225 | bool gotError = false; | 225 | bool gotError = false; |
226 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 226 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
227 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 227 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); |
228 | auto db = transaction.openDatabase("default", nullptr, false); | 228 | auto db = transaction.openDatabase("default", nullptr, false); |
229 | db.write("key","value"); | 229 | db.write("key","value"); |
230 | db.write("key","value"); | 230 | db.write("key","value"); |
@@ -233,7 +233,7 @@ private Q_SLOTS: | |||
233 | gotResult = true; | 233 | gotResult = true; |
234 | return true; | 234 | return true; |
235 | }, | 235 | }, |
236 | [&](const Akonadi2::Storage::Error &error) { | 236 | [&](const Sink::Storage::Error &error) { |
237 | qDebug() << error.message; | 237 | qDebug() << error.message; |
238 | gotError = true; | 238 | gotError = true; |
239 | }); | 239 | }); |
@@ -246,8 +246,8 @@ private Q_SLOTS: | |||
246 | { | 246 | { |
247 | bool gotResult = false; | 247 | bool gotResult = false; |
248 | bool gotError = false; | 248 | bool gotError = false; |
249 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 249 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
250 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 250 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); |
251 | auto db = transaction.openDatabase("default", nullptr, true); | 251 | auto db = transaction.openDatabase("default", nullptr, true); |
252 | db.write("key","value1"); | 252 | db.write("key","value1"); |
253 | db.write("key","value2"); | 253 | db.write("key","value2"); |
@@ -255,7 +255,7 @@ private Q_SLOTS: | |||
255 | gotResult = true; | 255 | gotResult = true; |
256 | return true; | 256 | return true; |
257 | }, | 257 | }, |
258 | [&](const Akonadi2::Storage::Error &error) { | 258 | [&](const Sink::Storage::Error &error) { |
259 | qDebug() << error.message; | 259 | qDebug() << error.message; |
260 | gotError = true; | 260 | gotError = true; |
261 | }); | 261 | }); |
@@ -268,12 +268,12 @@ private Q_SLOTS: | |||
268 | { | 268 | { |
269 | bool gotResult = false; | 269 | bool gotResult = false; |
270 | bool gotError = false; | 270 | bool gotError = false; |
271 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadOnly); | 271 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadOnly); |
272 | int numValues = store.createTransaction(Akonadi2::Storage::ReadOnly).openDatabase("test").scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { | 272 | int numValues = store.createTransaction(Sink::Storage::ReadOnly).openDatabase("test").scan("", [&](const QByteArray &key, const QByteArray &value) -> bool { |
273 | gotResult = true; | 273 | gotResult = true; |
274 | return false; | 274 | return false; |
275 | }, | 275 | }, |
276 | [&](const Akonadi2::Storage::Error &error) { | 276 | [&](const Sink::Storage::Error &error) { |
277 | qDebug() << error.message; | 277 | qDebug() << error.message; |
278 | gotError = true; | 278 | gotError = true; |
279 | }); | 279 | }); |
@@ -285,8 +285,8 @@ private Q_SLOTS: | |||
285 | void testWriteToNamedDb() | 285 | void testWriteToNamedDb() |
286 | { | 286 | { |
287 | bool gotError = false; | 287 | bool gotError = false; |
288 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 288 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
289 | store.createTransaction(Akonadi2::Storage::ReadWrite).openDatabase("test").write("key1", "value1", [&](const Akonadi2::Storage::Error &error) { | 289 | store.createTransaction(Sink::Storage::ReadWrite).openDatabase("test").write("key1", "value1", [&](const Sink::Storage::Error &error) { |
290 | qDebug() << error.message; | 290 | qDebug() << error.message; |
291 | gotError = true; | 291 | gotError = true; |
292 | }); | 292 | }); |
@@ -296,8 +296,8 @@ private Q_SLOTS: | |||
296 | void testWriteDuplicatesToNamedDb() | 296 | void testWriteDuplicatesToNamedDb() |
297 | { | 297 | { |
298 | bool gotError = false; | 298 | bool gotError = false; |
299 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 299 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
300 | store.createTransaction(Akonadi2::Storage::ReadWrite).openDatabase("test", nullptr, true).write("key1", "value1", [&](const Akonadi2::Storage::Error &error) { | 300 | store.createTransaction(Sink::Storage::ReadWrite).openDatabase("test", nullptr, true).write("key1", "value1", [&](const Sink::Storage::Error &error) { |
301 | qDebug() << error.message; | 301 | qDebug() << error.message; |
302 | gotError = true; | 302 | gotError = true; |
303 | }); | 303 | }); |
@@ -307,8 +307,8 @@ private Q_SLOTS: | |||
307 | //By default we want only exact matches | 307 | //By default we want only exact matches |
308 | void testSubstringKeys() | 308 | void testSubstringKeys() |
309 | { | 309 | { |
310 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 310 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
311 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 311 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); |
312 | auto db = transaction.openDatabase("test", nullptr, true); | 312 | auto db = transaction.openDatabase("test", nullptr, true); |
313 | db.write("sub","value1"); | 313 | db.write("sub","value1"); |
314 | db.write("subsub","value2"); | 314 | db.write("subsub","value2"); |
@@ -321,8 +321,8 @@ private Q_SLOTS: | |||
321 | 321 | ||
322 | void testFindSubstringKeys() | 322 | void testFindSubstringKeys() |
323 | { | 323 | { |
324 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 324 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
325 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 325 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); |
326 | auto db = transaction.openDatabase("test", nullptr, false); | 326 | auto db = transaction.openDatabase("test", nullptr, false); |
327 | db.write("sub","value1"); | 327 | db.write("sub","value1"); |
328 | db.write("subsub","value2"); | 328 | db.write("subsub","value2"); |
@@ -336,8 +336,8 @@ private Q_SLOTS: | |||
336 | 336 | ||
337 | void testKeySorting() | 337 | void testKeySorting() |
338 | { | 338 | { |
339 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 339 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
340 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 340 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); |
341 | auto db = transaction.openDatabase("test", nullptr, false); | 341 | auto db = transaction.openDatabase("test", nullptr, false); |
342 | db.write("sub_2","value2"); | 342 | db.write("sub_2","value2"); |
343 | db.write("sub_1","value1"); | 343 | db.write("sub_1","value1"); |
@@ -357,8 +357,8 @@ private Q_SLOTS: | |||
357 | //Ensure we don't retrieve a key that is greater than the current key. We only want equal keys. | 357 | //Ensure we don't retrieve a key that is greater than the current key. We only want equal keys. |
358 | void testKeyRange() | 358 | void testKeyRange() |
359 | { | 359 | { |
360 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 360 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
361 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 361 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); |
362 | auto db = transaction.openDatabase("test", nullptr, true); | 362 | auto db = transaction.openDatabase("test", nullptr, true); |
363 | db.write("sub1","value1"); | 363 | db.write("sub1","value1"); |
364 | int numValues = db.scan("sub", [&](const QByteArray &key, const QByteArray &value) -> bool { | 364 | int numValues = db.scan("sub", [&](const QByteArray &key, const QByteArray &value) -> bool { |
@@ -370,8 +370,8 @@ private Q_SLOTS: | |||
370 | 370 | ||
371 | void testFindLatest() | 371 | void testFindLatest() |
372 | { | 372 | { |
373 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 373 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
374 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 374 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); |
375 | auto db = transaction.openDatabase("test", nullptr, false); | 375 | auto db = transaction.openDatabase("test", nullptr, false); |
376 | db.write("sub1","value1"); | 376 | db.write("sub1","value1"); |
377 | db.write("sub2","value2"); | 377 | db.write("sub2","value2"); |
@@ -387,8 +387,8 @@ private Q_SLOTS: | |||
387 | 387 | ||
388 | void testFindLatestInSingle() | 388 | void testFindLatestInSingle() |
389 | { | 389 | { |
390 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 390 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
391 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 391 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); |
392 | auto db = transaction.openDatabase("test", nullptr, false); | 392 | auto db = transaction.openDatabase("test", nullptr, false); |
393 | db.write("sub2","value2"); | 393 | db.write("sub2","value2"); |
394 | QByteArray result; | 394 | QByteArray result; |
@@ -401,8 +401,8 @@ private Q_SLOTS: | |||
401 | 401 | ||
402 | void testFindLast() | 402 | void testFindLast() |
403 | { | 403 | { |
404 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 404 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
405 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 405 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); |
406 | auto db = transaction.openDatabase("test", nullptr, false); | 406 | auto db = transaction.openDatabase("test", nullptr, false); |
407 | db.write("sub2","value2"); | 407 | db.write("sub2","value2"); |
408 | db.write("wub3","value3"); | 408 | db.write("wub3","value3"); |
@@ -416,11 +416,11 @@ private Q_SLOTS: | |||
416 | 416 | ||
417 | void testRecordRevision() | 417 | void testRecordRevision() |
418 | { | 418 | { |
419 | Akonadi2::Storage store(testDataPath, dbName, Akonadi2::Storage::ReadWrite); | 419 | Sink::Storage store(testDataPath, dbName, Sink::Storage::ReadWrite); |
420 | auto transaction = store.createTransaction(Akonadi2::Storage::ReadWrite); | 420 | auto transaction = store.createTransaction(Sink::Storage::ReadWrite); |
421 | Akonadi2::Storage::recordRevision(transaction, 1, "uid", "type"); | 421 | Sink::Storage::recordRevision(transaction, 1, "uid", "type"); |
422 | QCOMPARE(Akonadi2::Storage::getTypeFromRevision(transaction, 1), QByteArray("type")); | 422 | QCOMPARE(Sink::Storage::getTypeFromRevision(transaction, 1), QByteArray("type")); |
423 | QCOMPARE(Akonadi2::Storage::getUidFromRevision(transaction, 1), QByteArray("uid")); | 423 | QCOMPARE(Sink::Storage::getUidFromRevision(transaction, 1), QByteArray("uid")); |
424 | } | 424 | } |
425 | }; | 425 | }; |
426 | 426 | ||
diff --git a/tests/testimplementations.h b/tests/testimplementations.h index a47a775..785c408 100644 --- a/tests/testimplementations.h +++ b/tests/testimplementations.h | |||
@@ -30,7 +30,7 @@ | |||
30 | //Replace with something different | 30 | //Replace with something different |
31 | #include "event_generated.h" | 31 | #include "event_generated.h" |
32 | 32 | ||
33 | class TestEventAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, Akonadi2::ApplicationDomain::Buffer::EventBuilder> | 33 | class TestEventAdaptorFactory : public DomainTypeAdaptorFactory<Sink::ApplicationDomain::Event, Sink::ApplicationDomain::Buffer::Event, Sink::ApplicationDomain::Buffer::EventBuilder> |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | TestEventAdaptorFactory() | 36 | TestEventAdaptorFactory() |
@@ -41,7 +41,7 @@ public: | |||
41 | virtual ~TestEventAdaptorFactory() {}; | 41 | virtual ~TestEventAdaptorFactory() {}; |
42 | }; | 42 | }; |
43 | 43 | ||
44 | class TestResourceAccess : public Akonadi2::ResourceAccessInterface | 44 | class TestResourceAccess : public Sink::ResourceAccessInterface |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | public: | 47 | public: |
@@ -55,11 +55,11 @@ public Q_SLOTS: | |||
55 | void close() Q_DECL_OVERRIDE {} | 55 | void close() Q_DECL_OVERRIDE {} |
56 | }; | 56 | }; |
57 | 57 | ||
58 | class TestResourceFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event> | 58 | class TestResourceFacade : public Sink::GenericFacade<Sink::ApplicationDomain::Event> |
59 | { | 59 | { |
60 | public: | 60 | public: |
61 | TestResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer<Akonadi2::ResourceAccessInterface> resourceAccess) | 61 | TestResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer<Sink::ResourceAccessInterface> resourceAccess) |
62 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>(instanceIdentifier, QSharedPointer<TestEventAdaptorFactory>::create(), resourceAccess) | 62 | : Sink::GenericFacade<Sink::ApplicationDomain::Event>(instanceIdentifier, QSharedPointer<TestEventAdaptorFactory>::create(), resourceAccess) |
63 | { | 63 | { |
64 | 64 | ||
65 | } | 65 | } |
@@ -69,11 +69,11 @@ public: | |||
69 | } | 69 | } |
70 | }; | 70 | }; |
71 | 71 | ||
72 | class TestResource : public Akonadi2::GenericResource | 72 | class TestResource : public Sink::GenericResource |
73 | { | 73 | { |
74 | public: | 74 | public: |
75 | TestResource(const QByteArray &instanceIdentifier, QSharedPointer<Akonadi2::Pipeline> pipeline) | 75 | TestResource(const QByteArray &instanceIdentifier, QSharedPointer<Sink::Pipeline> pipeline) |
76 | : Akonadi2::GenericResource(instanceIdentifier, pipeline) | 76 | : Sink::GenericResource(instanceIdentifier, pipeline) |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||