diff options
Diffstat (limited to 'common/clientapi.h')
-rw-r--r-- | common/clientapi.h | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/common/clientapi.h b/common/clientapi.h index d2757e7..ba0cb19 100644 --- a/common/clientapi.h +++ b/common/clientapi.h | |||
@@ -173,18 +173,36 @@ namespace Akonadi2 { | |||
173 | */ | 173 | */ |
174 | namespace Domain { | 174 | namespace Domain { |
175 | 175 | ||
176 | /** | ||
177 | * This class has to be implemented by resources and can be used as generic interface to access the buffer properties | ||
178 | */ | ||
179 | class BufferAdaptor { | ||
180 | public: | ||
181 | virtual QVariant getProperty(const QString &key) { return QVariant(); } | ||
182 | virtual void setProperty(const QString &key, const QVariant &value) {} | ||
183 | }; | ||
184 | |||
185 | /** | ||
186 | * The domain type interface has two purposes: | ||
187 | * * provide a unified interface to read buffers (for zero-copy reading) | ||
188 | * * record changes to generate changesets for modifications | ||
189 | */ | ||
176 | class AkonadiDomainType { | 190 | class AkonadiDomainType { |
177 | public: | 191 | public: |
178 | AkonadiDomainType(const QString &resourceName, const QString &identifier, qint64 revision) | 192 | AkonadiDomainType(const QString &resourceName, const QString &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor) |
179 | : mResourceName(resourceName), | 193 | : mAdaptor(adaptor), |
194 | mResourceName(resourceName), | ||
180 | mIdentifier(identifier), | 195 | mIdentifier(identifier), |
181 | mRevision(revision) | 196 | mRevision(revision) |
182 | { | 197 | { |
183 | } | 198 | } |
184 | 199 | ||
185 | virtual QVariant getProperty(const QString &key){ return QVariant(); } | 200 | virtual QVariant getProperty(const QString &key){ return mAdaptor->getProperty(key); } |
201 | virtual void setProperty(const QString &key, const QVariant &value){ mChangeSet.insert(key, value); } | ||
186 | 202 | ||
187 | private: | 203 | private: |
204 | QSharedPointer<BufferAdaptor> mAdaptor; | ||
205 | QHash<QString, QVariant> mChangeSet; | ||
188 | /* | 206 | /* |
189 | * Each domain object needs to store the resource, identifier, revision triple so we can link back to the storage location. | 207 | * Each domain object needs to store the resource, identifier, revision triple so we can link back to the storage location. |
190 | */ | 208 | */ |
@@ -193,21 +211,19 @@ private: | |||
193 | qint64 mRevision; | 211 | qint64 mRevision; |
194 | }; | 212 | }; |
195 | 213 | ||
196 | class Event : public AkonadiDomainType { | 214 | struct Event : public AkonadiDomainType { |
197 | public: | ||
198 | typedef QSharedPointer<Event> Ptr; | 215 | typedef QSharedPointer<Event> Ptr; |
199 | Event(const QString &resource, const QString &identifier, qint64 revision):AkonadiDomainType(resource, identifier, revision){}; | 216 | using AkonadiDomainType::AkonadiDomainType; |
200 | |||
201 | }; | 217 | }; |
202 | 218 | ||
203 | class Todo : public AkonadiDomainType { | 219 | struct Todo : public AkonadiDomainType { |
204 | public: | ||
205 | typedef QSharedPointer<Todo> Ptr; | 220 | typedef QSharedPointer<Todo> Ptr; |
221 | using AkonadiDomainType::AkonadiDomainType; | ||
206 | }; | 222 | }; |
207 | 223 | ||
208 | class Calendar : public AkonadiDomainType { | 224 | struct Calendar : public AkonadiDomainType { |
209 | public: | ||
210 | typedef QSharedPointer<Calendar> Ptr; | 225 | typedef QSharedPointer<Calendar> Ptr; |
226 | using AkonadiDomainType::AkonadiDomainType; | ||
211 | }; | 227 | }; |
212 | 228 | ||
213 | class Mail : public AkonadiDomainType { | 229 | class Mail : public AkonadiDomainType { |