diff options
Diffstat (limited to 'common/clientapi.cpp')
-rw-r--r-- | common/clientapi.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
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 | ||