diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/facade.h | 10 | ||||
-rw-r--r-- | common/resourceaccess.cpp | 4 | ||||
-rw-r--r-- | common/resourceaccess.h | 37 |
3 files changed, 33 insertions, 18 deletions
diff --git a/common/facade.h b/common/facade.h index 254f671..52b2134 100644 --- a/common/facade.h +++ b/common/facade.h | |||
@@ -90,7 +90,6 @@ private: | |||
90 | }; | 90 | }; |
91 | 91 | ||
92 | namespace Akonadi2 { | 92 | namespace Akonadi2 { |
93 | class ResourceAccess; | ||
94 | /** | 93 | /** |
95 | * Default facade implementation for resources that are implemented in a separate process using the ResourceAccess class. | 94 | * Default facade implementation for resources that are implemented in a separate process using the ResourceAccess class. |
96 | * | 95 | * |
@@ -112,13 +111,16 @@ public: | |||
112 | * @param resourceIdentifier is the identifier of the resource instance | 111 | * @param resourceIdentifier is the identifier of the resource instance |
113 | * @param adaptorFactory is the adaptor factory used to generate the mappings from domain to resource types and vice versa | 112 | * @param adaptorFactory is the adaptor factory used to generate the mappings from domain to resource types and vice versa |
114 | */ | 113 | */ |
115 | GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory = DomainTypeAdaptorFactoryInterface::Ptr(), const QSharedPointer<EntityStorage<DomainType> > storage = QSharedPointer<EntityStorage<DomainType> >()) | 114 | GenericFacade(const QByteArray &resourceIdentifier, const DomainTypeAdaptorFactoryInterface::Ptr &adaptorFactory = DomainTypeAdaptorFactoryInterface::Ptr(), const QSharedPointer<EntityStorage<DomainType> > storage = QSharedPointer<EntityStorage<DomainType> >(), const QSharedPointer<Akonadi2::ResourceAccessInterface> resourceAccess = QSharedPointer<Akonadi2::ResourceAccessInterface>()) |
116 | : Akonadi2::StoreFacade<DomainType>(), | 115 | : Akonadi2::StoreFacade<DomainType>(), |
117 | mResourceAccess(new ResourceAccess(resourceIdentifier)), | 116 | mResourceAccess(resourceAccess), |
118 | mStorage(storage ? storage : QSharedPointer<EntityStorage<DomainType> >::create(resourceIdentifier, adaptorFactory)), | 117 | mStorage(storage ? storage : QSharedPointer<EntityStorage<DomainType> >::create(resourceIdentifier, adaptorFactory)), |
119 | mDomainTypeAdaptorFactory(adaptorFactory), | 118 | mDomainTypeAdaptorFactory(adaptorFactory), |
120 | mResourceInstanceIdentifier(resourceIdentifier) | 119 | mResourceInstanceIdentifier(resourceIdentifier) |
121 | { | 120 | { |
121 | if (!mResourceAccess) { | ||
122 | mResourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(resourceIdentifier); | ||
123 | } | ||
122 | } | 124 | } |
123 | 125 | ||
124 | ~GenericFacade() | 126 | ~GenericFacade() |
@@ -269,7 +271,7 @@ private: | |||
269 | 271 | ||
270 | protected: | 272 | protected: |
271 | //TODO use one resource access instance per application & per resource | 273 | //TODO use one resource access instance per application & per resource |
272 | QSharedPointer<Akonadi2::ResourceAccess> mResourceAccess; | 274 | QSharedPointer<Akonadi2::ResourceAccessInterface> mResourceAccess; |
273 | QSharedPointer<EntityStorage<DomainType> > mStorage; | 275 | QSharedPointer<EntityStorage<DomainType> > mStorage; |
274 | DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory; | 276 | DomainTypeAdaptorFactoryInterface::Ptr mDomainTypeAdaptorFactory; |
275 | QByteArray mResourceInstanceIdentifier; | 277 | QByteArray mResourceInstanceIdentifier; |
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index bdebd56..a4a5795 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -208,8 +208,8 @@ static QByteArray getResourceName(const QByteArray &instanceIdentifier) | |||
208 | return split.join('.'); | 208 | return split.join('.'); |
209 | } | 209 | } |
210 | 210 | ||
211 | ResourceAccess::ResourceAccess(const QByteArray &resourceInstanceIdentifier, QObject *parent) | 211 | ResourceAccess::ResourceAccess(const QByteArray &resourceInstanceIdentifier) |
212 | : QObject(parent), | 212 | : ResourceAccessInterface(), |
213 | d(new Private(getResourceName(resourceInstanceIdentifier), resourceInstanceIdentifier, this)) | 213 | d(new Private(getResourceName(resourceInstanceIdentifier), resourceInstanceIdentifier, this)) |
214 | { | 214 | { |
215 | log("Starting access"); | 215 | log("Starting access"); |
diff --git a/common/resourceaccess.h b/common/resourceaccess.h index e873d8e..55379f3 100644 --- a/common/resourceaccess.h +++ b/common/resourceaccess.h | |||
@@ -33,33 +33,46 @@ namespace Akonadi2 | |||
33 | 33 | ||
34 | struct QueuedCommand; | 34 | struct QueuedCommand; |
35 | 35 | ||
36 | class ResourceAccess : public QObject | 36 | class ResourceAccessInterface : public QObject |
37 | { | 37 | { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | public: | ||
40 | ResourceAccessInterface() {} | ||
41 | virtual ~ResourceAccessInterface() {} | ||
42 | virtual KAsync::Job<void> sendCommand(int commandId) = 0; | ||
43 | virtual KAsync::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb) = 0; | ||
44 | virtual KAsync::Job<void> synchronizeResource(bool remoteSync, bool localSync) = 0; | ||
45 | |||
46 | Q_SIGNALS: | ||
47 | void ready(bool isReady); | ||
48 | void revisionChanged(unsigned long long revision); | ||
49 | |||
50 | public Q_SLOTS: | ||
51 | virtual void open() = 0; | ||
52 | virtual void close() = 0; | ||
53 | }; | ||
39 | 54 | ||
55 | class ResourceAccess : public ResourceAccessInterface | ||
56 | { | ||
57 | Q_OBJECT | ||
40 | public: | 58 | public: |
41 | ResourceAccess(const QByteArray &resourceName, QObject *parent = 0); | 59 | ResourceAccess(const QByteArray &resourceName); |
42 | ~ResourceAccess(); | 60 | ~ResourceAccess(); |
43 | 61 | ||
44 | QByteArray resourceName() const; | 62 | QByteArray resourceName() const; |
45 | bool isReady() const; | 63 | bool isReady() const; |
46 | 64 | ||
47 | KAsync::Job<void> sendCommand(int commandId); | 65 | KAsync::Job<void> sendCommand(int commandId) Q_DECL_OVERRIDE; |
48 | KAsync::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb); | 66 | KAsync::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb) Q_DECL_OVERRIDE; |
49 | KAsync::Job<void> synchronizeResource(bool remoteSync, bool localSync); | 67 | KAsync::Job<void> synchronizeResource(bool remoteSync, bool localSync) Q_DECL_OVERRIDE; |
50 | /** | 68 | /** |
51 | * Tries to connect to server, and returns a connected socket on success. | 69 | * Tries to connect to server, and returns a connected socket on success. |
52 | */ | 70 | */ |
53 | static KAsync::Job<QSharedPointer<QLocalSocket> > connectToServer(const QByteArray &identifier); | 71 | static KAsync::Job<QSharedPointer<QLocalSocket> > connectToServer(const QByteArray &identifier); |
54 | 72 | ||
55 | public Q_SLOTS: | 73 | public Q_SLOTS: |
56 | void open(); | 74 | void open() Q_DECL_OVERRIDE; |
57 | void close(); | 75 | void close() Q_DECL_OVERRIDE; |
58 | |||
59 | Q_SIGNALS: | ||
60 | void ready(bool isReady); | ||
61 | void revisionChanged(unsigned long long revision); | ||
62 | void commandCompleted(); | ||
63 | 76 | ||
64 | private Q_SLOTS: | 77 | private Q_SLOTS: |
65 | //TODO: move these to the Private class | 78 | //TODO: move these to the Private class |