diff options
Diffstat (limited to 'common/domain')
-rw-r--r-- | common/domain/applicationdomaintype.h | 62 |
1 files changed, 55 insertions, 7 deletions
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 849c3e2..5efb936 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -52,6 +52,13 @@ | |||
52 | void setExtracted##NAME(const TYPE &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \ | 52 | void setExtracted##NAME(const TYPE &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \ |
53 | TYPE get##NAME() const { return getProperty(NAME::name).value<TYPE>(); } \ | 53 | TYPE get##NAME() const { return getProperty(NAME::name).value<TYPE>(); } \ |
54 | 54 | ||
55 | #define SINK_STATUS_PROPERTY(TYPE, NAME, LOWERCASENAME) \ | ||
56 | struct NAME { \ | ||
57 | static constexpr const char *name = #LOWERCASENAME; \ | ||
58 | typedef TYPE Type; \ | ||
59 | }; \ | ||
60 | void setStatus##NAME(const TYPE &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \ | ||
61 | TYPE get##NAME() const { return getProperty(NAME::name).value<TYPE>(); } \ | ||
55 | 62 | ||
56 | #define SINK_BLOB_PROPERTY(NAME, LOWERCASENAME) \ | 63 | #define SINK_BLOB_PROPERTY(NAME, LOWERCASENAME) \ |
57 | struct NAME { \ | 64 | struct NAME { \ |
@@ -76,6 +83,14 @@ | |||
76 | namespace Sink { | 83 | namespace Sink { |
77 | namespace ApplicationDomain { | 84 | namespace ApplicationDomain { |
78 | 85 | ||
86 | struct SINK_EXPORT Error { | ||
87 | |||
88 | }; | ||
89 | |||
90 | struct SINK_EXPORT Progress { | ||
91 | |||
92 | }; | ||
93 | |||
79 | /** | 94 | /** |
80 | * The domain type interface has two purposes: | 95 | * The domain type interface has two purposes: |
81 | * * provide a unified interface to read buffers (for zero-copy reading) | 96 | * * provide a unified interface to read buffers (for zero-copy reading) |
@@ -215,6 +230,38 @@ struct SINK_EXPORT Mail : public Entity { | |||
215 | }; | 230 | }; |
216 | 231 | ||
217 | /** | 232 | /** |
233 | * The status of an account or resource. | ||
234 | * | ||
235 | * It is set as follows: | ||
236 | * * By default the status is offline. | ||
237 | * * If a connection to the server could be established the status is Connected. | ||
238 | * * If an error occurred that keeps the resource from operating (so non transient), the resource enters the error state. | ||
239 | * * If a long running operation is started the resource goes to the busy state (and return to the previous state after that). | ||
240 | */ | ||
241 | enum SINK_EXPORT Status { | ||
242 | OfflineStatus, | ||
243 | ConnectedStatus, | ||
244 | BusyStatus, | ||
245 | ErrorStatus | ||
246 | }; | ||
247 | |||
248 | struct SINK_EXPORT SinkAccount : public ApplicationDomainType { | ||
249 | typedef QSharedPointer<SinkAccount> Ptr; | ||
250 | explicit SinkAccount(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor); | ||
251 | explicit SinkAccount(const QByteArray &identifier); | ||
252 | SinkAccount(); | ||
253 | virtual ~SinkAccount(); | ||
254 | |||
255 | SINK_PROPERTY(QString, Name, name); | ||
256 | SINK_PROPERTY(QString, Icon, icon); | ||
257 | SINK_PROPERTY(QString, AccountType, accountType); | ||
258 | SINK_STATUS_PROPERTY(int, Status, status); | ||
259 | SINK_STATUS_PROPERTY(ApplicationDomain::Error, Error, error); | ||
260 | SINK_STATUS_PROPERTY(ApplicationDomain::Progress, Progress, progress); | ||
261 | }; | ||
262 | |||
263 | |||
264 | /** | ||
218 | * Represents an sink resource. | 265 | * Represents an sink resource. |
219 | * | 266 | * |
220 | * This type is used for configuration of resources, | 267 | * This type is used for configuration of resources, |
@@ -226,14 +273,13 @@ struct SINK_EXPORT SinkResource : public ApplicationDomainType { | |||
226 | explicit SinkResource(const QByteArray &identifier); | 273 | explicit SinkResource(const QByteArray &identifier); |
227 | SinkResource(); | 274 | SinkResource(); |
228 | virtual ~SinkResource(); | 275 | virtual ~SinkResource(); |
229 | }; | ||
230 | 276 | ||
231 | struct SINK_EXPORT SinkAccount : public ApplicationDomainType { | 277 | SINK_REFERENCE_PROPERTY(SinkAccount, Account, account); |
232 | typedef QSharedPointer<SinkAccount> Ptr; | 278 | SINK_PROPERTY(QString, ResourceType, resourceType); |
233 | explicit SinkAccount(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor); | 279 | SINK_PROPERTY(QByteArrayList, Capabilities, capabilities); |
234 | explicit SinkAccount(const QByteArray &identifier); | 280 | SINK_STATUS_PROPERTY(int, Status, status); |
235 | SinkAccount(); | 281 | SINK_STATUS_PROPERTY(ApplicationDomain::Error, Error, error); |
236 | virtual ~SinkAccount(); | 282 | SINK_STATUS_PROPERTY(ApplicationDomain::Progress, Progress, progress); |
237 | }; | 283 | }; |
238 | 284 | ||
239 | struct SINK_EXPORT Identity : public ApplicationDomainType { | 285 | struct SINK_EXPORT Identity : public ApplicationDomainType { |
@@ -330,3 +376,5 @@ Q_DECLARE_METATYPE(Sink::ApplicationDomain::SinkAccount) | |||
330 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::SinkAccount::Ptr) | 376 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::SinkAccount::Ptr) |
331 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Identity) | 377 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Identity) |
332 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Identity::Ptr) | 378 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Identity::Ptr) |
379 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Error) | ||
380 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Progress) | ||