diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-01-19 09:52:40 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-01-19 09:52:40 +0100 |
commit | e7ddc02bce5b4e46b44e3cb39c06ed25dc291c0a (patch) | |
tree | 5ade33a7647941d536d652623a0a36633768620c | |
parent | db48154e47a9f611b7d3dceb195b14a8953e7abb (diff) | |
download | sink-e7ddc02bce5b4e46b44e3cb39c06ed25dc291c0a.tar.gz sink-e7ddc02bce5b4e46b44e3cb39c06ed25dc291c0a.zip |
Prepared maildir inspection implementation
-rw-r--r-- | common/clientapi.h | 21 | ||||
-rw-r--r-- | common/inspection.h | 50 | ||||
-rw-r--r-- | common/resourcefacade.h | 5 | ||||
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 6 | ||||
-rw-r--r-- | examples/maildirresource/maildirresource.h | 1 |
5 files changed, 63 insertions, 20 deletions
diff --git a/common/clientapi.h b/common/clientapi.h index 5ed99e0..14caa7a 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <Async/Async> | 26 | #include <Async/Async> |
27 | 27 | ||
28 | #include "query.h" | 28 | #include "query.h" |
29 | #include "inspection.h" | ||
29 | #include "applicationdomaintype.h" | 30 | #include "applicationdomaintype.h" |
30 | 31 | ||
31 | class QAbstractItemModel; | 32 | class QAbstractItemModel; |
@@ -114,26 +115,6 @@ public: | |||
114 | }; | 115 | }; |
115 | 116 | ||
116 | namespace Resources { | 117 | namespace Resources { |
117 | struct Inspection { | ||
118 | static Inspection PropertyInspection(const Akonadi2::ApplicationDomain::Entity &entity, const QByteArray &property, const QVariant &expectedValue) | ||
119 | { | ||
120 | Inspection inspection; | ||
121 | inspection.resourceIdentifier = entity.resourceInstanceIdentifier(); | ||
122 | inspection.entityIdentifier = entity.identifier(); | ||
123 | inspection.property = property; | ||
124 | inspection.expectedValue = expectedValue; | ||
125 | return inspection; | ||
126 | } | ||
127 | |||
128 | enum Type { | ||
129 | PropertyInspectionType | ||
130 | }; | ||
131 | |||
132 | QByteArray resourceIdentifier; | ||
133 | QByteArray entityIdentifier; | ||
134 | QByteArray property; | ||
135 | QVariant expectedValue; | ||
136 | }; | ||
137 | template <class DomainType> | 118 | template <class DomainType> |
138 | KAsync::Job<void> inspect(const Inspection &inspectionCommand); | 119 | KAsync::Job<void> inspect(const Inspection &inspectionCommand); |
139 | } | 120 | } |
diff --git a/common/inspection.h b/common/inspection.h new file mode 100644 index 0000000..45d599a --- /dev/null +++ b/common/inspection.h | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||
8 | * later version accepted by the membership of KDE e.V. (or its | ||
9 | * successor approved by the membership of KDE e.V.), which shall | ||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | ||
20 | #pragma once | ||
21 | |||
22 | #include <QByteArray> | ||
23 | #include <QVariant> | ||
24 | #include "applicationdomaintype.h" | ||
25 | |||
26 | namespace Akonadi2 { | ||
27 | namespace Resources { | ||
28 | |||
29 | struct Inspection { | ||
30 | static Inspection PropertyInspection(const Akonadi2::ApplicationDomain::Entity &entity, const QByteArray &property, const QVariant &expectedValue) | ||
31 | { | ||
32 | Inspection inspection; | ||
33 | inspection.resourceIdentifier = entity.resourceInstanceIdentifier(); | ||
34 | inspection.entityIdentifier = entity.identifier(); | ||
35 | inspection.property = property; | ||
36 | inspection.expectedValue = expectedValue; | ||
37 | return inspection; | ||
38 | } | ||
39 | |||
40 | enum Type { | ||
41 | PropertyInspectionType | ||
42 | }; | ||
43 | QByteArray resourceIdentifier; | ||
44 | QByteArray entityIdentifier; | ||
45 | QByteArray property; | ||
46 | QVariant expectedValue; | ||
47 | }; | ||
48 | |||
49 | } | ||
50 | } | ||
diff --git a/common/resourcefacade.h b/common/resourcefacade.h index 38e0c0e..ae3037a 100644 --- a/common/resourcefacade.h +++ b/common/resourcefacade.h | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | namespace Akonadi2 { | 28 | namespace Akonadi2 { |
29 | class Query; | 29 | class Query; |
30 | class Inspection; | ||
30 | } | 31 | } |
31 | 32 | ||
32 | class ResourceFacade : public Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource> | 33 | class ResourceFacade : public Akonadi2::StoreFacade<Akonadi2::ApplicationDomain::AkonadiResource> |
@@ -38,5 +39,9 @@ public: | |||
38 | KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::AkonadiResource &resource) Q_DECL_OVERRIDE; | 39 | KAsync::Job<void> modify(const Akonadi2::ApplicationDomain::AkonadiResource &resource) Q_DECL_OVERRIDE; |
39 | KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::AkonadiResource &resource) Q_DECL_OVERRIDE; | 40 | KAsync::Job<void> remove(const Akonadi2::ApplicationDomain::AkonadiResource &resource) Q_DECL_OVERRIDE; |
40 | 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 Akonadi2::ResultEmitter<Akonadi2::ApplicationDomain::AkonadiResource::Ptr>::Ptr > load(const Akonadi2::Query &query) Q_DECL_OVERRIDE; |
42 | KAsync::Job<void> inspect(const Akonadi2::Inspection &domainObject) Q_DECL_OVERRIDE | ||
43 | { | ||
44 | return KAsync::error<void>(-1, "Failed to inspect."); | ||
45 | } | ||
41 | }; | 46 | }; |
42 | 47 | ||
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 70f6ae5..3531b92 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "facadefactory.h" | 35 | #include "facadefactory.h" |
36 | #include "indexupdater.h" | 36 | #include "indexupdater.h" |
37 | #include "libmaildir/maildir.h" | 37 | #include "libmaildir/maildir.h" |
38 | #include "inspection.h" | ||
38 | #include <QDate> | 39 | #include <QDate> |
39 | #include <QUuid> | 40 | #include <QUuid> |
40 | #include <QDir> | 41 | #include <QDir> |
@@ -292,6 +293,11 @@ void MaildirResource::removeFromDisk(const QByteArray &instanceIdentifier) | |||
292 | Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite).removeFromDisk(); | 293 | Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite).removeFromDisk(); |
293 | } | 294 | } |
294 | 295 | ||
296 | KAsync::Job<void> MaildirResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) | ||
297 | { | ||
298 | Trace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; | ||
299 | } | ||
300 | |||
295 | MaildirResourceFactory::MaildirResourceFactory(QObject *parent) | 301 | MaildirResourceFactory::MaildirResourceFactory(QObject *parent) |
296 | : Akonadi2::ResourceFactory(parent) | 302 | : Akonadi2::ResourceFactory(parent) |
297 | { | 303 | { |
diff --git a/examples/maildirresource/maildirresource.h b/examples/maildirresource/maildirresource.h index 21ee637..5f7795b 100644 --- a/examples/maildirresource/maildirresource.h +++ b/examples/maildirresource/maildirresource.h | |||
@@ -44,6 +44,7 @@ class MaildirResource : public Akonadi2::GenericResource | |||
44 | public: | 44 | public: |
45 | MaildirResource(const QByteArray &instanceIdentifier, const QSharedPointer<Akonadi2::Pipeline> &pipeline = QSharedPointer<Akonadi2::Pipeline>()); | 45 | MaildirResource(const QByteArray &instanceIdentifier, const QSharedPointer<Akonadi2::Pipeline> &pipeline = QSharedPointer<Akonadi2::Pipeline>()); |
46 | KAsync::Job<void> synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore) Q_DECL_OVERRIDE; | 46 | KAsync::Job<void> synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::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 | static void removeFromDisk(const QByteArray &instanceIdentifier); | 48 | static void removeFromDisk(const QByteArray &instanceIdentifier); |
48 | private: | 49 | private: |
49 | KAsync::Job<void> replay(Akonadi2::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE; | 50 | KAsync::Job<void> replay(Akonadi2::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE; |