diff options
Diffstat (limited to 'common/domain')
-rw-r--r-- | common/domain/addressbook.fbs | 9 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.cpp | 80 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.h | 144 | ||||
-rw-r--r-- | common/domain/applicationdomaintype_p.h | 8 | ||||
-rw-r--r-- | common/domain/contact.cpp | 57 | ||||
-rw-r--r-- | common/domain/contact.fbs | 10 | ||||
-rw-r--r-- | common/domain/contact.h | 57 | ||||
-rw-r--r-- | common/domain/domaintypes.h | 5 | ||||
-rw-r--r-- | common/domain/event.cpp | 57 | ||||
-rw-r--r-- | common/domain/event.h | 57 | ||||
-rw-r--r-- | common/domain/folder.cpp | 60 | ||||
-rw-r--r-- | common/domain/folder.h | 51 | ||||
-rw-r--r-- | common/domain/mail.h | 52 | ||||
-rw-r--r-- | common/domain/propertyregistry.cpp | 18 | ||||
-rw-r--r-- | common/domain/propertyregistry.h | 3 | ||||
-rw-r--r-- | common/domain/typeimplementations.cpp (renamed from common/domain/mail.cpp) | 118 | ||||
-rw-r--r-- | common/domain/typeimplementations.h | 101 |
17 files changed, 382 insertions, 505 deletions
diff --git a/common/domain/addressbook.fbs b/common/domain/addressbook.fbs new file mode 100644 index 0000000..c2bda2b --- /dev/null +++ b/common/domain/addressbook.fbs | |||
@@ -0,0 +1,9 @@ | |||
1 | namespace Sink.ApplicationDomain.Buffer; | ||
2 | |||
3 | table Addressbook { | ||
4 | name:string; | ||
5 | parent:string; | ||
6 | } | ||
7 | |||
8 | root_type Addressbook; | ||
9 | file_identifier "AKFB"; | ||
diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index fd88570..44f5a75 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp | |||
@@ -65,6 +65,9 @@ int registerProperty() { | |||
65 | return 0; | 65 | return 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | #define SINK_REGISTER_ENTITY(ENTITY) \ | ||
69 | constexpr const char *ENTITY::name; | ||
70 | |||
68 | #define SINK_REGISTER_PROPERTY(ENTITYTYPE, PROPERTY) \ | 71 | #define SINK_REGISTER_PROPERTY(ENTITYTYPE, PROPERTY) \ |
69 | constexpr const char *ENTITYTYPE::PROPERTY::name; \ | 72 | constexpr const char *ENTITYTYPE::PROPERTY::name; \ |
70 | static int foo##ENTITYTYPE##PROPERTY = registerProperty<ENTITYTYPE, ENTITYTYPE::PROPERTY>(); | 73 | static int foo##ENTITYTYPE##PROPERTY = registerProperty<ENTITYTYPE, ENTITYTYPE::PROPERTY>(); |
@@ -72,6 +75,10 @@ int registerProperty() { | |||
72 | namespace Sink { | 75 | namespace Sink { |
73 | namespace ApplicationDomain { | 76 | namespace ApplicationDomain { |
74 | 77 | ||
78 | constexpr const char *SinkResource::name; | ||
79 | constexpr const char *SinkAccount::name; | ||
80 | |||
81 | SINK_REGISTER_ENTITY(Mail); | ||
75 | SINK_REGISTER_PROPERTY(Mail, Sender); | 82 | SINK_REGISTER_PROPERTY(Mail, Sender); |
76 | SINK_REGISTER_PROPERTY(Mail, To); | 83 | SINK_REGISTER_PROPERTY(Mail, To); |
77 | SINK_REGISTER_PROPERTY(Mail, Cc); | 84 | SINK_REGISTER_PROPERTY(Mail, Cc); |
@@ -90,11 +97,28 @@ SINK_REGISTER_PROPERTY(Mail, MessageId); | |||
90 | SINK_REGISTER_PROPERTY(Mail, ParentMessageId); | 97 | SINK_REGISTER_PROPERTY(Mail, ParentMessageId); |
91 | SINK_REGISTER_PROPERTY(Mail, ThreadId); | 98 | SINK_REGISTER_PROPERTY(Mail, ThreadId); |
92 | 99 | ||
100 | SINK_REGISTER_ENTITY(Folder); | ||
93 | SINK_REGISTER_PROPERTY(Folder, Name); | 101 | SINK_REGISTER_PROPERTY(Folder, Name); |
94 | SINK_REGISTER_PROPERTY(Folder, Icon); | 102 | SINK_REGISTER_PROPERTY(Folder, Icon); |
95 | SINK_REGISTER_PROPERTY(Folder, SpecialPurpose); | 103 | SINK_REGISTER_PROPERTY(Folder, SpecialPurpose); |
96 | SINK_REGISTER_PROPERTY(Folder, Enabled); | 104 | SINK_REGISTER_PROPERTY(Folder, Enabled); |
97 | SINK_REGISTER_PROPERTY(Folder, Parent); | 105 | SINK_REGISTER_PROPERTY(Folder, Parent); |
106 | SINK_REGISTER_PROPERTY(Folder, Count); | ||
107 | SINK_REGISTER_PROPERTY(Folder, FullContentAvailable); | ||
108 | |||
109 | SINK_REGISTER_ENTITY(Contact); | ||
110 | SINK_REGISTER_PROPERTY(Contact, Uid); | ||
111 | SINK_REGISTER_PROPERTY(Contact, Fn); | ||
112 | SINK_REGISTER_PROPERTY(Contact, Firstname); | ||
113 | SINK_REGISTER_PROPERTY(Contact, Lastname); | ||
114 | SINK_REGISTER_PROPERTY(Contact, Emails); | ||
115 | SINK_REGISTER_PROPERTY(Contact, Vcard); | ||
116 | SINK_REGISTER_PROPERTY(Contact, Addressbook); | ||
117 | |||
118 | SINK_REGISTER_ENTITY(Addressbook); | ||
119 | SINK_REGISTER_PROPERTY(Addressbook, Name); | ||
120 | SINK_REGISTER_PROPERTY(Addressbook, Parent); | ||
121 | SINK_REGISTER_PROPERTY(Addressbook, LastUpdated); | ||
98 | 122 | ||
99 | static const int foo = [] { | 123 | static const int foo = [] { |
100 | QMetaType::registerEqualsComparator<Reference>(); | 124 | QMetaType::registerEqualsComparator<Reference>(); |
@@ -115,10 +139,8 @@ void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::Applicatio | |||
115 | for (const auto &property : propertiesToCopy) { | 139 | for (const auto &property : propertiesToCopy) { |
116 | const auto value = buffer.getProperty(property); | 140 | const auto value = buffer.getProperty(property); |
117 | if (copyBlobs && value.canConvert<BLOB>()) { | 141 | if (copyBlobs && value.canConvert<BLOB>()) { |
118 | auto oldPath = value.value<BLOB>().value; | 142 | const auto oldPath = value.value<BLOB>().value; |
119 | //FIXME: This is neither pretty nor save if we have multiple modifications of the same property (the first modification will remove the file). | 143 | const auto newPath = Sink::temporaryFileLocation() + "/" + QUuid::createUuid().toString(); |
120 | //At least if the modification fails the file will be removed once the entity is removed. | ||
121 | auto newPath = oldPath + "copy"; | ||
122 | QFile::copy(oldPath, newPath); | 144 | QFile::copy(oldPath, newPath); |
123 | memoryAdaptor.setProperty(property, QVariant::fromValue(BLOB{newPath})); | 145 | memoryAdaptor.setProperty(property, QVariant::fromValue(BLOB{newPath})); |
124 | } else if (pruneReferences && value.canConvert<Reference>()) { | 146 | } else if (pruneReferences && value.canConvert<Reference>()) { |
@@ -364,52 +386,12 @@ SinkResource ImapResource::create(const QByteArray &account) | |||
364 | return resource; | 386 | return resource; |
365 | } | 387 | } |
366 | 388 | ||
367 | template<> | 389 | SinkResource CardDavResource::create(const QByteArray &account) |
368 | QByteArray getTypeName<Contact>() | ||
369 | { | ||
370 | return "contact"; | ||
371 | } | ||
372 | |||
373 | template<> | ||
374 | QByteArray getTypeName<Event>() | ||
375 | { | ||
376 | return "event"; | ||
377 | } | ||
378 | |||
379 | template<> | ||
380 | QByteArray getTypeName<Todo>() | ||
381 | { | ||
382 | return "todo"; | ||
383 | } | ||
384 | |||
385 | template<> | ||
386 | QByteArray getTypeName<SinkResource>() | ||
387 | { | ||
388 | return "resource"; | ||
389 | } | ||
390 | |||
391 | template<> | ||
392 | QByteArray getTypeName<SinkAccount>() | ||
393 | { | ||
394 | return "account"; | ||
395 | } | ||
396 | |||
397 | template<> | ||
398 | QByteArray getTypeName<Identity>() | ||
399 | { | ||
400 | return "identity"; | ||
401 | } | ||
402 | |||
403 | template<> | ||
404 | QByteArray getTypeName<Mail>() | ||
405 | { | 390 | { |
406 | return "mail"; | 391 | auto &&resource = ApplicationDomainType::createEntity<SinkResource>(); |
407 | } | 392 | resource.setResourceType("sink.dav"); |
408 | 393 | resource.setAccount(account); | |
409 | template<> | 394 | return resource; |
410 | QByteArray getTypeName<Folder>() | ||
411 | { | ||
412 | return "folder"; | ||
413 | } | 395 | } |
414 | 396 | ||
415 | QByteArrayList getTypeNames() | 397 | QByteArrayList getTypeNames() |
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index be04db9..e5aa46e 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -28,7 +28,8 @@ | |||
28 | #include <QUuid> | 28 | #include <QUuid> |
29 | #include "bufferadaptor.h" | 29 | #include "bufferadaptor.h" |
30 | 30 | ||
31 | #define SINK_ENTITY(TYPE) \ | 31 | #define SINK_ENTITY(TYPE, LOWERCASENAME) \ |
32 | static constexpr const char *name = #LOWERCASENAME; \ | ||
32 | typedef QSharedPointer<TYPE> Ptr; \ | 33 | typedef QSharedPointer<TYPE> Ptr; \ |
33 | using Entity::Entity; \ | 34 | using Entity::Entity; \ |
34 | TYPE() = default; \ | 35 | TYPE() = default; \ |
@@ -92,6 +93,43 @@ | |||
92 | namespace Sink { | 93 | namespace Sink { |
93 | namespace ApplicationDomain { | 94 | namespace ApplicationDomain { |
94 | 95 | ||
96 | enum SINK_EXPORT ErrorCode { | ||
97 | NoError = 0, | ||
98 | UnknownError, | ||
99 | NoServerError, | ||
100 | ConnectionError, | ||
101 | LoginError, | ||
102 | ConfigurationError, | ||
103 | TransmissionError, | ||
104 | }; | ||
105 | |||
106 | enum SINK_EXPORT SuccessCode { | ||
107 | TransmissionSuccess | ||
108 | }; | ||
109 | |||
110 | enum SINK_EXPORT SyncStatus { | ||
111 | NoSyncStatus, | ||
112 | SyncInProgress, | ||
113 | SyncError, | ||
114 | SyncSuccess | ||
115 | }; | ||
116 | |||
117 | /** | ||
118 | * The status of an account or resource. | ||
119 | * | ||
120 | * It is set as follows: | ||
121 | * * By default the status is offline. | ||
122 | * * If a connection to the server could be established the status is Connected. | ||
123 | * * If an error occurred that keeps the resource from operating (so non transient), the resource enters the error state. | ||
124 | * * If a long running operation is started the resource goes to the busy state (and return to the previous state after that). | ||
125 | */ | ||
126 | enum SINK_EXPORT Status { | ||
127 | OfflineStatus, | ||
128 | ConnectedStatus, | ||
129 | BusyStatus, | ||
130 | ErrorStatus | ||
131 | }; | ||
132 | |||
95 | struct SINK_EXPORT Error { | 133 | struct SINK_EXPORT Error { |
96 | 134 | ||
97 | }; | 135 | }; |
@@ -100,6 +138,11 @@ struct SINK_EXPORT Progress { | |||
100 | 138 | ||
101 | }; | 139 | }; |
102 | 140 | ||
141 | /** | ||
142 | * Internal type. | ||
143 | * | ||
144 | * Represents a BLOB property. | ||
145 | */ | ||
103 | struct BLOB { | 146 | struct BLOB { |
104 | BLOB() = default; | 147 | BLOB() = default; |
105 | BLOB(const BLOB &) = default; | 148 | BLOB(const BLOB &) = default; |
@@ -268,6 +311,7 @@ SINK_EXPORT QDebug operator<< (QDebug d, const BLOB &blob); | |||
268 | 311 | ||
269 | 312 | ||
270 | struct SINK_EXPORT SinkAccount : public ApplicationDomainType { | 313 | struct SINK_EXPORT SinkAccount : public ApplicationDomainType { |
314 | static constexpr const char *name = "account"; | ||
271 | typedef QSharedPointer<SinkAccount> Ptr; | 315 | typedef QSharedPointer<SinkAccount> Ptr; |
272 | explicit SinkAccount(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor); | 316 | explicit SinkAccount(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor); |
273 | explicit SinkAccount(const QByteArray &identifier); | 317 | explicit SinkAccount(const QByteArray &identifier); |
@@ -278,8 +322,6 @@ struct SINK_EXPORT SinkAccount : public ApplicationDomainType { | |||
278 | SINK_PROPERTY(QString, Icon, icon); | 322 | SINK_PROPERTY(QString, Icon, icon); |
279 | SINK_PROPERTY(QString, AccountType, type); | 323 | SINK_PROPERTY(QString, AccountType, type); |
280 | SINK_STATUS_PROPERTY(int, Status, status); | 324 | SINK_STATUS_PROPERTY(int, Status, status); |
281 | SINK_STATUS_PROPERTY(ApplicationDomain::Error, Error, error); | ||
282 | SINK_STATUS_PROPERTY(ApplicationDomain::Progress, Progress, progress); | ||
283 | }; | 325 | }; |
284 | 326 | ||
285 | 327 | ||
@@ -290,6 +332,7 @@ struct SINK_EXPORT SinkAccount : public ApplicationDomainType { | |||
290 | * and for creating and removing resource instances. | 332 | * and for creating and removing resource instances. |
291 | */ | 333 | */ |
292 | struct SINK_EXPORT SinkResource : public ApplicationDomainType { | 334 | struct SINK_EXPORT SinkResource : public ApplicationDomainType { |
335 | static constexpr const char *name = "resource"; | ||
293 | typedef QSharedPointer<SinkResource> Ptr; | 336 | typedef QSharedPointer<SinkResource> Ptr; |
294 | explicit SinkResource(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor); | 337 | explicit SinkResource(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor); |
295 | explicit SinkResource(const QByteArray &identifier); | 338 | explicit SinkResource(const QByteArray &identifier); |
@@ -300,8 +343,6 @@ struct SINK_EXPORT SinkResource : public ApplicationDomainType { | |||
300 | SINK_PROPERTY(QByteArray, ResourceType, type); | 343 | SINK_PROPERTY(QByteArray, ResourceType, type); |
301 | SINK_PROPERTY(QByteArrayList, Capabilities, capabilities); | 344 | SINK_PROPERTY(QByteArrayList, Capabilities, capabilities); |
302 | SINK_STATUS_PROPERTY(int, Status, status); | 345 | SINK_STATUS_PROPERTY(int, Status, status); |
303 | SINK_STATUS_PROPERTY(ApplicationDomain::Error, Error, error); | ||
304 | SINK_STATUS_PROPERTY(ApplicationDomain::Progress, Progress, progress); | ||
305 | }; | 346 | }; |
306 | 347 | ||
307 | struct SINK_EXPORT Entity : public ApplicationDomainType { | 348 | struct SINK_EXPORT Entity : public ApplicationDomainType { |
@@ -312,16 +353,35 @@ struct SINK_EXPORT Entity : public ApplicationDomainType { | |||
312 | virtual ~Entity() = default; | 353 | virtual ~Entity() = default; |
313 | }; | 354 | }; |
314 | 355 | ||
356 | struct SINK_EXPORT Addressbook : public Entity { | ||
357 | SINK_ENTITY(Addressbook, addressbook); | ||
358 | SINK_REFERENCE_PROPERTY(Addressbook, Parent, parent); | ||
359 | SINK_PROPERTY(QString, Name, name); | ||
360 | SINK_EXTRACTED_PROPERTY(QDateTime, LastUpdated, lastUpdated); | ||
361 | }; | ||
362 | |||
315 | struct SINK_EXPORT Contact : public Entity { | 363 | struct SINK_EXPORT Contact : public Entity { |
316 | SINK_ENTITY(Contact); | 364 | struct SINK_EXPORT Email { |
365 | enum Type { | ||
366 | Undefined, | ||
367 | Work, | ||
368 | Home | ||
369 | }; | ||
370 | Type type; | ||
371 | QString email; | ||
372 | }; | ||
373 | SINK_ENTITY(Contact, contact); | ||
317 | SINK_PROPERTY(QString, Uid, uid); | 374 | SINK_PROPERTY(QString, Uid, uid); |
318 | SINK_PROPERTY(QString, Fn, fn); | 375 | SINK_PROPERTY(QString, Fn, fn); |
319 | SINK_PROPERTY(QByteArrayList, Emails, emails); | 376 | SINK_PROPERTY(QString, Firstname, firstname); |
377 | SINK_PROPERTY(QString, Lastname, lastname); | ||
378 | SINK_PROPERTY(QList<Email>, Emails, emails); | ||
320 | SINK_PROPERTY(QByteArray, Vcard, vcard); | 379 | SINK_PROPERTY(QByteArray, Vcard, vcard); |
380 | SINK_REFERENCE_PROPERTY(Addressbook, Addressbook, addressbook); | ||
321 | }; | 381 | }; |
322 | 382 | ||
323 | struct SINK_EXPORT Event : public Entity { | 383 | struct SINK_EXPORT Event : public Entity { |
324 | SINK_ENTITY(Event); | 384 | SINK_ENTITY(Event, event); |
325 | SINK_PROPERTY(QString, Uid, uid); | 385 | SINK_PROPERTY(QString, Uid, uid); |
326 | SINK_PROPERTY(QString, Summary, summary); | 386 | SINK_PROPERTY(QString, Summary, summary); |
327 | SINK_PROPERTY(QString, Description, description); | 387 | SINK_PROPERTY(QString, Description, description); |
@@ -329,20 +389,23 @@ struct SINK_EXPORT Event : public Entity { | |||
329 | }; | 389 | }; |
330 | 390 | ||
331 | struct SINK_EXPORT Todo : public Entity { | 391 | struct SINK_EXPORT Todo : public Entity { |
332 | SINK_ENTITY(Todo); | 392 | SINK_ENTITY(Todo, todo); |
333 | }; | 393 | }; |
334 | 394 | ||
335 | struct SINK_EXPORT Calendar : public Entity { | 395 | struct SINK_EXPORT Calendar : public Entity { |
336 | SINK_ENTITY(Calendar); | 396 | SINK_ENTITY(Calendar, calendar); |
337 | }; | 397 | }; |
338 | 398 | ||
339 | struct SINK_EXPORT Folder : public Entity { | 399 | struct SINK_EXPORT Folder : public Entity { |
340 | SINK_ENTITY(Folder); | 400 | SINK_ENTITY(Folder, folder); |
341 | SINK_REFERENCE_PROPERTY(Folder, Parent, parent); | 401 | SINK_REFERENCE_PROPERTY(Folder, Parent, parent); |
342 | SINK_PROPERTY(QString, Name, name); | 402 | SINK_PROPERTY(QString, Name, name); |
343 | SINK_PROPERTY(QByteArray, Icon, icon); | 403 | SINK_PROPERTY(QByteArray, Icon, icon); |
344 | SINK_PROPERTY(QByteArrayList, SpecialPurpose, specialpurpose); | 404 | SINK_PROPERTY(QByteArrayList, SpecialPurpose, specialpurpose); |
345 | SINK_PROPERTY(bool, Enabled, enabled); | 405 | SINK_PROPERTY(bool, Enabled, enabled); |
406 | SINK_EXTRACTED_PROPERTY(QDateTime, LastUpdated, lastUpdated); | ||
407 | SINK_EXTRACTED_PROPERTY(int, Count, count); | ||
408 | SINK_EXTRACTED_PROPERTY(bool, FullContentAvailable, fullContentAvailable); | ||
346 | }; | 409 | }; |
347 | 410 | ||
348 | struct SINK_EXPORT Mail : public Entity { | 411 | struct SINK_EXPORT Mail : public Entity { |
@@ -351,7 +414,7 @@ struct SINK_EXPORT Mail : public Entity { | |||
351 | QString emailAddress; | 414 | QString emailAddress; |
352 | }; | 415 | }; |
353 | 416 | ||
354 | SINK_ENTITY(Mail); | 417 | SINK_ENTITY(Mail, mail); |
355 | SINK_EXTRACTED_PROPERTY(Contact, Sender, sender); | 418 | SINK_EXTRACTED_PROPERTY(Contact, Sender, sender); |
356 | SINK_EXTRACTED_PROPERTY(QList<Contact>, To, to); | 419 | SINK_EXTRACTED_PROPERTY(QList<Contact>, To, to); |
357 | SINK_EXTRACTED_PROPERTY(QList<Contact>, Cc, cc); | 420 | SINK_EXTRACTED_PROPERTY(QList<Contact>, Cc, cc); |
@@ -373,23 +436,8 @@ struct SINK_EXPORT Mail : public Entity { | |||
373 | 436 | ||
374 | SINK_EXPORT QDebug operator<< (QDebug d, const Mail::Contact &c); | 437 | SINK_EXPORT QDebug operator<< (QDebug d, const Mail::Contact &c); |
375 | 438 | ||
376 | /** | ||
377 | * The status of an account or resource. | ||
378 | * | ||
379 | * It is set as follows: | ||
380 | * * By default the status is offline. | ||
381 | * * If a connection to the server could be established the status is Connected. | ||
382 | * * If an error occurred that keeps the resource from operating (so non transient), the resource enters the error state. | ||
383 | * * If a long running operation is started the resource goes to the busy state (and return to the previous state after that). | ||
384 | */ | ||
385 | enum SINK_EXPORT Status { | ||
386 | OfflineStatus, | ||
387 | ConnectedStatus, | ||
388 | BusyStatus, | ||
389 | ErrorStatus | ||
390 | }; | ||
391 | |||
392 | struct SINK_EXPORT Identity : public ApplicationDomainType { | 439 | struct SINK_EXPORT Identity : public ApplicationDomainType { |
440 | static constexpr const char *name = "identity"; | ||
393 | typedef QSharedPointer<Identity> Ptr; | 441 | typedef QSharedPointer<Identity> Ptr; |
394 | explicit Identity(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor); | 442 | explicit Identity(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor); |
395 | explicit Identity(const QByteArray &identifier); | 443 | explicit Identity(const QByteArray &identifier); |
@@ -416,6 +464,10 @@ struct SINK_EXPORT ImapResource { | |||
416 | static SinkResource create(const QByteArray &account); | 464 | static SinkResource create(const QByteArray &account); |
417 | }; | 465 | }; |
418 | 466 | ||
467 | struct SINK_EXPORT CardDavResource { | ||
468 | static SinkResource create(const QByteArray &account); | ||
469 | }; | ||
470 | |||
419 | namespace ResourceCapabilities { | 471 | namespace ResourceCapabilities { |
420 | namespace Mail { | 472 | namespace Mail { |
421 | static constexpr const char *mail = "mail"; | 473 | static constexpr const char *mail = "mail"; |
@@ -427,6 +479,11 @@ namespace Mail { | |||
427 | static constexpr const char *transport = "mail.transport"; | 479 | static constexpr const char *transport = "mail.transport"; |
428 | static constexpr const char *folderhierarchy = "mail.folderhierarchy"; | 480 | static constexpr const char *folderhierarchy = "mail.folderhierarchy"; |
429 | }; | 481 | }; |
482 | namespace Contact { | ||
483 | static constexpr const char *contact = "contact"; | ||
484 | static constexpr const char *addressbook = "addressbook"; | ||
485 | static constexpr const char *storage = "contact.storage"; | ||
486 | }; | ||
430 | }; | 487 | }; |
431 | 488 | ||
432 | namespace SpecialPurpose { | 489 | namespace SpecialPurpose { |
@@ -444,31 +501,10 @@ namespace Mail { | |||
444 | * Do not store these types to disk, they may change over time. | 501 | * Do not store these types to disk, they may change over time. |
445 | */ | 502 | */ |
446 | template<class DomainType> | 503 | template<class DomainType> |
447 | QByteArray SINK_EXPORT getTypeName(); | 504 | QByteArray SINK_EXPORT getTypeName() |
448 | 505 | { | |
449 | template<> | 506 | return DomainType::name; |
450 | QByteArray SINK_EXPORT getTypeName<Contact>(); | 507 | } |
451 | |||
452 | template<> | ||
453 | QByteArray SINK_EXPORT getTypeName<Event>(); | ||
454 | |||
455 | template<> | ||
456 | QByteArray SINK_EXPORT getTypeName<Todo>(); | ||
457 | |||
458 | template<> | ||
459 | QByteArray SINK_EXPORT getTypeName<SinkResource>(); | ||
460 | |||
461 | template<> | ||
462 | QByteArray SINK_EXPORT getTypeName<SinkAccount>(); | ||
463 | |||
464 | template<> | ||
465 | QByteArray SINK_EXPORT getTypeName<Identity>(); | ||
466 | |||
467 | template<> | ||
468 | QByteArray SINK_EXPORT getTypeName<Mail>(); | ||
469 | |||
470 | template<> | ||
471 | QByteArray SINK_EXPORT getTypeName<Folder>(); | ||
472 | 508 | ||
473 | QByteArrayList SINK_EXPORT getTypeNames(); | 509 | QByteArrayList SINK_EXPORT getTypeNames(); |
474 | 510 | ||
@@ -499,6 +535,7 @@ class SINK_EXPORT TypeImplementation; | |||
499 | */ | 535 | */ |
500 | #define SINK_REGISTER_TYPES() \ | 536 | #define SINK_REGISTER_TYPES() \ |
501 | REGISTER_TYPE(Sink::ApplicationDomain::Contact) \ | 537 | REGISTER_TYPE(Sink::ApplicationDomain::Contact) \ |
538 | REGISTER_TYPE(Sink::ApplicationDomain::Addressbook) \ | ||
502 | REGISTER_TYPE(Sink::ApplicationDomain::Event) \ | 539 | REGISTER_TYPE(Sink::ApplicationDomain::Event) \ |
503 | REGISTER_TYPE(Sink::ApplicationDomain::Mail) \ | 540 | REGISTER_TYPE(Sink::ApplicationDomain::Mail) \ |
504 | REGISTER_TYPE(Sink::ApplicationDomain::Folder) \ | 541 | REGISTER_TYPE(Sink::ApplicationDomain::Folder) \ |
@@ -520,6 +557,7 @@ Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType::Ptr) | |||
520 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity) | 557 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity) |
521 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity::Ptr) | 558 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity::Ptr) |
522 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Mail::Contact) | 559 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Mail::Contact) |
560 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Contact::Email) | ||
523 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Error) | 561 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Error) |
524 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Progress) | 562 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Progress) |
525 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::BLOB) | 563 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::BLOB) |
diff --git a/common/domain/applicationdomaintype_p.h b/common/domain/applicationdomaintype_p.h index 4b06864..a5a6b1d 100644 --- a/common/domain/applicationdomaintype_p.h +++ b/common/domain/applicationdomaintype_p.h | |||
@@ -33,13 +33,15 @@ struct TypeHelper { | |||
33 | template <typename R, typename ...Args> | 33 | template <typename R, typename ...Args> |
34 | R operator()(Args && ... args) const { | 34 | R operator()(Args && ... args) const { |
35 | if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Folder>()) { | 35 | if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Folder>()) { |
36 | return Func<Sink::ApplicationDomain::Folder>{}(std::forward<Args...>(args...)); | 36 | return Func<Sink::ApplicationDomain::Folder>{}(std::forward<Args...>(args...)); |
37 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Mail>()) { | 37 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Mail>()) { |
38 | return Func<Sink::ApplicationDomain::Mail>{}(std::forward<Args...>(args...)); | 38 | return Func<Sink::ApplicationDomain::Mail>{}(std::forward<Args...>(args...)); |
39 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>()) { | 39 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Event>()) { |
40 | return Func<Sink::ApplicationDomain::Event>{}(std::forward<Args...>(args...)); | 40 | return Func<Sink::ApplicationDomain::Event>{}(std::forward<Args...>(args...)); |
41 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Contact>()) { | 41 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Contact>()) { |
42 | return Func<Sink::ApplicationDomain::Contact>{}(std::forward<Args...>(args...)); | 42 | return Func<Sink::ApplicationDomain::Contact>{}(std::forward<Args...>(args...)); |
43 | } else if (type == Sink::ApplicationDomain::getTypeName<Sink::ApplicationDomain::Addressbook>()) { | ||
44 | return Func<Sink::ApplicationDomain::Addressbook>{}(std::forward<Args...>(args...)); | ||
43 | } else { | 45 | } else { |
44 | Q_ASSERT(false); | 46 | Q_ASSERT(false); |
45 | } | 47 | } |
diff --git a/common/domain/contact.cpp b/common/domain/contact.cpp deleted file mode 100644 index ea7cac2..0000000 --- a/common/domain/contact.cpp +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 Sandro Knauß <knauss@kolabsys.com> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #include "contact.h" | ||
20 | |||
21 | #include <QVector> | ||
22 | #include <QByteArray> | ||
23 | #include <QString> | ||
24 | |||
25 | #include "../propertymapper.h" | ||
26 | #include "../typeindex.h" | ||
27 | #include "entity_generated.h" | ||
28 | |||
29 | #include "contact_generated.h" | ||
30 | |||
31 | using namespace Sink::ApplicationDomain; | ||
32 | |||
33 | void TypeImplementation<Contact>::configure(TypeIndex &index) | ||
34 | { | ||
35 | index.addProperty<QByteArray>(Contact::Uid::name); | ||
36 | } | ||
37 | |||
38 | void TypeImplementation<Contact>::configure(ReadPropertyMapper<Buffer> &propertyMapper) | ||
39 | { | ||
40 | propertyMapper.addMapping<Contact::Uid, Buffer>(&Buffer::uid); | ||
41 | propertyMapper.addMapping<Contact::Fn, Buffer>(&Buffer::fn); | ||
42 | propertyMapper.addMapping<Contact::Emails, Buffer>(&Buffer::emails); | ||
43 | propertyMapper.addMapping<Contact::Vcard, Buffer>(&Buffer::vcard); | ||
44 | } | ||
45 | |||
46 | void TypeImplementation<Contact>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper) | ||
47 | { | ||
48 | propertyMapper.addMapping<Contact::Uid>(&BufferBuilder::add_uid); | ||
49 | propertyMapper.addMapping<Contact::Fn>(&BufferBuilder::add_fn); | ||
50 | propertyMapper.addMapping<Contact::Emails>(&BufferBuilder::add_emails); | ||
51 | propertyMapper.addMapping<Contact::Vcard>(&BufferBuilder::add_vcard); | ||
52 | } | ||
53 | |||
54 | void TypeImplementation<Contact>::configure(IndexPropertyMapper &) | ||
55 | { | ||
56 | |||
57 | } | ||
diff --git a/common/domain/contact.fbs b/common/domain/contact.fbs index 34fb1d6..d941d5a 100644 --- a/common/domain/contact.fbs +++ b/common/domain/contact.fbs | |||
@@ -1,9 +1,17 @@ | |||
1 | namespace Sink.ApplicationDomain.Buffer; | 1 | namespace Sink.ApplicationDomain.Buffer; |
2 | 2 | ||
3 | table ContactEmail { | ||
4 | type: int; | ||
5 | email: string; | ||
6 | } | ||
7 | |||
3 | table Contact { | 8 | table Contact { |
4 | uid:string; | 9 | uid:string; |
5 | fn:string; | 10 | fn:string; |
6 | emails: [string]; | 11 | firstname:string; |
12 | lastname:string; | ||
13 | addressbook:string; | ||
14 | emails: [ContactEmail]; | ||
7 | vcard: string; | 15 | vcard: string; |
8 | } | 16 | } |
9 | 17 | ||
diff --git a/common/domain/contact.h b/common/domain/contact.h deleted file mode 100644 index c803a9f..0000000 --- a/common/domain/contact.h +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 Sandro Knauß <knauss@kolabsys.com> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include "applicationdomaintype.h" | ||
22 | |||
23 | class QByteArray; | ||
24 | |||
25 | template<typename T> | ||
26 | class ReadPropertyMapper; | ||
27 | template<typename T> | ||
28 | class WritePropertyMapper; | ||
29 | class IndexPropertyMapper; | ||
30 | |||
31 | class TypeIndex; | ||
32 | |||
33 | namespace Sink { | ||
34 | namespace ApplicationDomain { | ||
35 | namespace Buffer { | ||
36 | struct Contact; | ||
37 | struct ContactBuilder; | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * Implements all type-specific code such as updating and querying indexes. | ||
42 | * | ||
43 | * These are type specifiy default implementations. Theoretically a resource could implement it's own implementation. | ||
44 | */ | ||
45 | template<> | ||
46 | class TypeImplementation<Sink::ApplicationDomain::Contact> { | ||
47 | public: | ||
48 | typedef Sink::ApplicationDomain::Buffer::Contact Buffer; | ||
49 | typedef Sink::ApplicationDomain::Buffer::ContactBuilder BufferBuilder; | ||
50 | static void configure(TypeIndex &); | ||
51 | static void configure(ReadPropertyMapper<Buffer> &); | ||
52 | static void configure(WritePropertyMapper<BufferBuilder> &); | ||
53 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
54 | }; | ||
55 | |||
56 | } | ||
57 | } | ||
diff --git a/common/domain/domaintypes.h b/common/domain/domaintypes.h deleted file mode 100644 index 0abdee7..0000000 --- a/common/domain/domaintypes.h +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | |||
2 | #include "contact.h" | ||
3 | #include "mail.h" | ||
4 | #include "folder.h" | ||
5 | #include "event.h" | ||
diff --git a/common/domain/event.cpp b/common/domain/event.cpp deleted file mode 100644 index 10c92bb..0000000 --- a/common/domain/event.cpp +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #include "event.h" | ||
20 | |||
21 | #include <QVector> | ||
22 | #include <QByteArray> | ||
23 | #include <QString> | ||
24 | |||
25 | #include "../propertymapper.h" | ||
26 | #include "../typeindex.h" | ||
27 | #include "entity_generated.h" | ||
28 | |||
29 | #include "event_generated.h" | ||
30 | |||
31 | using namespace Sink::ApplicationDomain; | ||
32 | |||
33 | void TypeImplementation<Event>::configure(TypeIndex &index) | ||
34 | { | ||
35 | index.addProperty<QByteArray>(Event::Uid::name); | ||
36 | } | ||
37 | |||
38 | void TypeImplementation<Event>::configure(ReadPropertyMapper<Buffer> &propertyMapper) | ||
39 | { | ||
40 | propertyMapper.addMapping<Event::Summary, Buffer>(&Buffer::summary); | ||
41 | propertyMapper.addMapping<Event::Description, Buffer>(&Buffer::description); | ||
42 | propertyMapper.addMapping<Event::Uid, Buffer>(&Buffer::uid); | ||
43 | propertyMapper.addMapping<Event::Attachment, Buffer>(&Buffer::attachment); | ||
44 | } | ||
45 | |||
46 | void TypeImplementation<Event>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper) | ||
47 | { | ||
48 | propertyMapper.addMapping<Event::Summary>(&BufferBuilder::add_summary); | ||
49 | propertyMapper.addMapping<Event::Description>(&BufferBuilder::add_description); | ||
50 | propertyMapper.addMapping<Event::Uid>(&BufferBuilder::add_uid); | ||
51 | propertyMapper.addMapping<Event::Attachment>(&BufferBuilder::add_attachment); | ||
52 | } | ||
53 | |||
54 | void TypeImplementation<Event>::configure(IndexPropertyMapper &) | ||
55 | { | ||
56 | |||
57 | } | ||
diff --git a/common/domain/event.h b/common/domain/event.h deleted file mode 100644 index b683f5f..0000000 --- a/common/domain/event.h +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include "applicationdomaintype.h" | ||
22 | |||
23 | class QByteArray; | ||
24 | |||
25 | template<typename T> | ||
26 | class ReadPropertyMapper; | ||
27 | template<typename T> | ||
28 | class WritePropertyMapper; | ||
29 | class IndexPropertyMapper; | ||
30 | |||
31 | class TypeIndex; | ||
32 | |||
33 | namespace Sink { | ||
34 | namespace ApplicationDomain { | ||
35 | namespace Buffer { | ||
36 | struct Event; | ||
37 | struct EventBuilder; | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * Implements all type-specific code such as updating and querying indexes. | ||
42 | * | ||
43 | * These are type specifiy default implementations. Theoretically a resource could implement it's own implementation. | ||
44 | */ | ||
45 | template<> | ||
46 | class TypeImplementation<Sink::ApplicationDomain::Event> { | ||
47 | public: | ||
48 | typedef Sink::ApplicationDomain::Buffer::Event Buffer; | ||
49 | typedef Sink::ApplicationDomain::Buffer::EventBuilder BufferBuilder; | ||
50 | static void configure(TypeIndex &); | ||
51 | static void configure(ReadPropertyMapper<Buffer> &); | ||
52 | static void configure(WritePropertyMapper<BufferBuilder> &); | ||
53 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
54 | }; | ||
55 | |||
56 | } | ||
57 | } | ||
diff --git a/common/domain/folder.cpp b/common/domain/folder.cpp deleted file mode 100644 index 6717661..0000000 --- a/common/domain/folder.cpp +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastfolder.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #include "folder.h" | ||
20 | |||
21 | #include <QByteArray> | ||
22 | #include <QString> | ||
23 | |||
24 | #include "../propertymapper.h" | ||
25 | #include "../typeindex.h" | ||
26 | #include "entitybuffer.h" | ||
27 | #include "entity_generated.h" | ||
28 | |||
29 | #include "folder_generated.h" | ||
30 | |||
31 | using namespace Sink::ApplicationDomain; | ||
32 | |||
33 | void TypeImplementation<Folder>::configure(TypeIndex &index) | ||
34 | { | ||
35 | index.addProperty<QByteArray>(Folder::Parent::name); | ||
36 | index.addProperty<QString>(Folder::Name::name); | ||
37 | } | ||
38 | |||
39 | void TypeImplementation<Folder>::configure(ReadPropertyMapper<Buffer> &propertyMapper) | ||
40 | { | ||
41 | propertyMapper.addMapping<Folder::Parent, Buffer>(&Buffer::parent); | ||
42 | propertyMapper.addMapping<Folder::Name, Buffer>(&Buffer::name); | ||
43 | propertyMapper.addMapping<Folder::Icon, Buffer>(&Buffer::icon); | ||
44 | propertyMapper.addMapping<Folder::SpecialPurpose, Buffer>(&Buffer::specialpurpose); | ||
45 | propertyMapper.addMapping<Folder::Enabled, Buffer>(&Buffer::enabled); | ||
46 | } | ||
47 | |||
48 | void TypeImplementation<Folder>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper) | ||
49 | { | ||
50 | propertyMapper.addMapping<Folder::Parent>(&BufferBuilder::add_parent); | ||
51 | propertyMapper.addMapping<Folder::Name>(&BufferBuilder::add_name); | ||
52 | propertyMapper.addMapping<Folder::Icon>(&BufferBuilder::add_icon); | ||
53 | propertyMapper.addMapping<Folder::SpecialPurpose>(&BufferBuilder::add_specialpurpose); | ||
54 | propertyMapper.addMapping<Folder::Enabled>(&BufferBuilder::add_enabled); | ||
55 | } | ||
56 | |||
57 | void TypeImplementation<Folder>::configure(IndexPropertyMapper &) | ||
58 | { | ||
59 | |||
60 | } | ||
diff --git a/common/domain/folder.h b/common/domain/folder.h deleted file mode 100644 index f232ab5..0000000 --- a/common/domain/folder.h +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include "applicationdomaintype.h" | ||
22 | |||
23 | template<typename T> | ||
24 | class ReadPropertyMapper; | ||
25 | template<typename T> | ||
26 | class WritePropertyMapper; | ||
27 | class IndexPropertyMapper; | ||
28 | |||
29 | class TypeIndex; | ||
30 | |||
31 | namespace Sink { | ||
32 | |||
33 | namespace ApplicationDomain { | ||
34 | namespace Buffer { | ||
35 | struct Folder; | ||
36 | struct FolderBuilder; | ||
37 | } | ||
38 | |||
39 | template<> | ||
40 | class TypeImplementation<Sink::ApplicationDomain::Folder> { | ||
41 | public: | ||
42 | typedef Sink::ApplicationDomain::Buffer::Folder Buffer; | ||
43 | typedef Sink::ApplicationDomain::Buffer::FolderBuilder BufferBuilder; | ||
44 | static void configure(TypeIndex &); | ||
45 | static void configure(ReadPropertyMapper<Buffer> &); | ||
46 | static void configure(WritePropertyMapper<BufferBuilder> &); | ||
47 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
48 | }; | ||
49 | |||
50 | } | ||
51 | } | ||
diff --git a/common/domain/mail.h b/common/domain/mail.h deleted file mode 100644 index e052448..0000000 --- a/common/domain/mail.h +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include "applicationdomaintype.h" | ||
22 | |||
23 | class QByteArray; | ||
24 | |||
25 | template<typename T> | ||
26 | class ReadPropertyMapper; | ||
27 | template<typename T> | ||
28 | class WritePropertyMapper; | ||
29 | class IndexPropertyMapper; | ||
30 | |||
31 | class TypeIndex; | ||
32 | |||
33 | namespace Sink { | ||
34 | namespace ApplicationDomain { | ||
35 | namespace Buffer { | ||
36 | struct Mail; | ||
37 | struct MailBuilder; | ||
38 | } | ||
39 | |||
40 | template<> | ||
41 | class TypeImplementation<Sink::ApplicationDomain::Mail> { | ||
42 | public: | ||
43 | typedef Sink::ApplicationDomain::Buffer::Mail Buffer; | ||
44 | typedef Sink::ApplicationDomain::Buffer::MailBuilder BufferBuilder; | ||
45 | static void configure(TypeIndex &index); | ||
46 | static void configure(ReadPropertyMapper<Buffer> &propertyMapper); | ||
47 | static void configure(WritePropertyMapper<BufferBuilder> &propertyMapper); | ||
48 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
49 | }; | ||
50 | |||
51 | } | ||
52 | } | ||
diff --git a/common/domain/propertyregistry.cpp b/common/domain/propertyregistry.cpp index 2208193..7b9b61a 100644 --- a/common/domain/propertyregistry.cpp +++ b/common/domain/propertyregistry.cpp | |||
@@ -64,6 +64,17 @@ QVariant parseString<bool>(const QString &s) | |||
64 | } | 64 | } |
65 | 65 | ||
66 | template <> | 66 | template <> |
67 | QVariant parseString<int>(const QString &s) | ||
68 | { | ||
69 | bool ok = false; | ||
70 | auto n = s.toInt(&ok); | ||
71 | if (ok) { | ||
72 | return QVariant::fromValue(n); | ||
73 | } | ||
74 | return {}; | ||
75 | } | ||
76 | |||
77 | template <> | ||
67 | QVariant parseString<QList<QByteArray>>(const QString &s) | 78 | QVariant parseString<QList<QByteArray>>(const QString &s) |
68 | { | 79 | { |
69 | auto list = s.split(','); | 80 | auto list = s.split(','); |
@@ -92,6 +103,13 @@ QVariant parseString<QList<Sink::ApplicationDomain::Mail::Contact>>(const QStrin | |||
92 | return QVariant{}; | 103 | return QVariant{}; |
93 | } | 104 | } |
94 | 105 | ||
106 | template <> | ||
107 | QVariant parseString<QList<Sink::ApplicationDomain::Contact::Email>>(const QString &s) | ||
108 | { | ||
109 | Q_ASSERT(false); | ||
110 | return QVariant{}; | ||
111 | } | ||
112 | |||
95 | PropertyRegistry &PropertyRegistry::instance() | 113 | PropertyRegistry &PropertyRegistry::instance() |
96 | { | 114 | { |
97 | static PropertyRegistry instance; | 115 | static PropertyRegistry instance; |
diff --git a/common/domain/propertyregistry.h b/common/domain/propertyregistry.h index 16df23b..758c10d 100644 --- a/common/domain/propertyregistry.h +++ b/common/domain/propertyregistry.h | |||
@@ -49,6 +49,9 @@ template <> | |||
49 | QVariant parseString<bool>(const QString &s); | 49 | QVariant parseString<bool>(const QString &s); |
50 | 50 | ||
51 | template <> | 51 | template <> |
52 | QVariant parseString<int>(const QString &s); | ||
53 | |||
54 | template <> | ||
52 | QVariant parseString<QList<QByteArray>>(const QString &s); | 55 | QVariant parseString<QList<QByteArray>>(const QString &s); |
53 | 56 | ||
54 | template <> | 57 | template <> |
diff --git a/common/domain/mail.cpp b/common/domain/typeimplementations.cpp index 8cbe61b..eb3851e 100644 --- a/common/domain/mail.cpp +++ b/common/domain/typeimplementations.cpp | |||
@@ -16,7 +16,7 @@ | |||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 | */ | 18 | */ |
19 | #include "mail.h" | 19 | #include "typeimplementations.h" |
20 | 20 | ||
21 | #include <QVector> | 21 | #include <QVector> |
22 | #include <QByteArray> | 22 | #include <QByteArray> |
@@ -29,8 +29,6 @@ | |||
29 | #include "mail/threadindexer.h" | 29 | #include "mail/threadindexer.h" |
30 | #include "domainadaptor.h" | 30 | #include "domainadaptor.h" |
31 | 31 | ||
32 | #include "mail_generated.h" | ||
33 | |||
34 | using namespace Sink; | 32 | using namespace Sink; |
35 | using namespace Sink::ApplicationDomain; | 33 | using namespace Sink::ApplicationDomain; |
36 | 34 | ||
@@ -102,3 +100,117 @@ void TypeImplementation<Mail>::configure(WritePropertyMapper<BufferBuilder> &pro | |||
102 | propertyMapper.addMapping<Mail::MessageId>(&BufferBuilder::add_messageId); | 100 | propertyMapper.addMapping<Mail::MessageId>(&BufferBuilder::add_messageId); |
103 | propertyMapper.addMapping<Mail::ParentMessageId>(&BufferBuilder::add_parentMessageId); | 101 | propertyMapper.addMapping<Mail::ParentMessageId>(&BufferBuilder::add_parentMessageId); |
104 | } | 102 | } |
103 | |||
104 | |||
105 | void TypeImplementation<Folder>::configure(TypeIndex &index) | ||
106 | { | ||
107 | index.addProperty<QByteArray>(Folder::Parent::name); | ||
108 | index.addProperty<QString>(Folder::Name::name); | ||
109 | } | ||
110 | |||
111 | void TypeImplementation<Folder>::configure(ReadPropertyMapper<Buffer> &propertyMapper) | ||
112 | { | ||
113 | propertyMapper.addMapping<Folder::Parent, Buffer>(&Buffer::parent); | ||
114 | propertyMapper.addMapping<Folder::Name, Buffer>(&Buffer::name); | ||
115 | propertyMapper.addMapping<Folder::Icon, Buffer>(&Buffer::icon); | ||
116 | propertyMapper.addMapping<Folder::SpecialPurpose, Buffer>(&Buffer::specialpurpose); | ||
117 | propertyMapper.addMapping<Folder::Enabled, Buffer>(&Buffer::enabled); | ||
118 | } | ||
119 | |||
120 | void TypeImplementation<Folder>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper) | ||
121 | { | ||
122 | propertyMapper.addMapping<Folder::Parent>(&BufferBuilder::add_parent); | ||
123 | propertyMapper.addMapping<Folder::Name>(&BufferBuilder::add_name); | ||
124 | propertyMapper.addMapping<Folder::Icon>(&BufferBuilder::add_icon); | ||
125 | propertyMapper.addMapping<Folder::SpecialPurpose>(&BufferBuilder::add_specialpurpose); | ||
126 | propertyMapper.addMapping<Folder::Enabled>(&BufferBuilder::add_enabled); | ||
127 | } | ||
128 | |||
129 | void TypeImplementation<Folder>::configure(IndexPropertyMapper &) | ||
130 | { | ||
131 | |||
132 | } | ||
133 | |||
134 | |||
135 | void TypeImplementation<Contact>::configure(TypeIndex &index) | ||
136 | { | ||
137 | index.addProperty<QByteArray>(Contact::Uid::name); | ||
138 | } | ||
139 | |||
140 | void TypeImplementation<Contact>::configure(ReadPropertyMapper<Buffer> &propertyMapper) | ||
141 | { | ||
142 | propertyMapper.addMapping<Contact::Uid, Buffer>(&Buffer::uid); | ||
143 | propertyMapper.addMapping<Contact::Fn, Buffer>(&Buffer::fn); | ||
144 | propertyMapper.addMapping<Contact::Emails, Buffer>(&Buffer::emails); | ||
145 | propertyMapper.addMapping<Contact::Vcard, Buffer>(&Buffer::vcard); | ||
146 | propertyMapper.addMapping<Contact::Addressbook, Buffer>(&Buffer::addressbook); | ||
147 | propertyMapper.addMapping<Contact::Firstname, Buffer>(&Buffer::firstname); | ||
148 | propertyMapper.addMapping<Contact::Lastname, Buffer>(&Buffer::lastname); | ||
149 | } | ||
150 | |||
151 | void TypeImplementation<Contact>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper) | ||
152 | { | ||
153 | propertyMapper.addMapping<Contact::Uid>(&BufferBuilder::add_uid); | ||
154 | propertyMapper.addMapping<Contact::Fn>(&BufferBuilder::add_fn); | ||
155 | propertyMapper.addMapping<Contact::Emails>(&BufferBuilder::add_emails); | ||
156 | propertyMapper.addMapping<Contact::Vcard>(&BufferBuilder::add_vcard); | ||
157 | propertyMapper.addMapping<Contact::Addressbook>(&BufferBuilder::add_addressbook); | ||
158 | propertyMapper.addMapping<Contact::Firstname>(&BufferBuilder::add_firstname); | ||
159 | propertyMapper.addMapping<Contact::Lastname>(&BufferBuilder::add_lastname); | ||
160 | } | ||
161 | |||
162 | void TypeImplementation<Contact>::configure(IndexPropertyMapper &) | ||
163 | { | ||
164 | |||
165 | } | ||
166 | |||
167 | |||
168 | void TypeImplementation<Addressbook>::configure(TypeIndex &index) | ||
169 | { | ||
170 | index.addProperty<QByteArray>(Addressbook::Parent::name); | ||
171 | index.addProperty<QString>(Addressbook::Name::name); | ||
172 | } | ||
173 | |||
174 | void TypeImplementation<Addressbook>::configure(ReadPropertyMapper<Buffer> &propertyMapper) | ||
175 | { | ||
176 | propertyMapper.addMapping<Addressbook::Parent, Buffer>(&Buffer::parent); | ||
177 | propertyMapper.addMapping<Addressbook::Name, Buffer>(&Buffer::name); | ||
178 | } | ||
179 | |||
180 | void TypeImplementation<Addressbook>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper) | ||
181 | { | ||
182 | propertyMapper.addMapping<Addressbook::Parent>(&BufferBuilder::add_parent); | ||
183 | propertyMapper.addMapping<Addressbook::Name>(&BufferBuilder::add_name); | ||
184 | } | ||
185 | |||
186 | void TypeImplementation<Addressbook>::configure(IndexPropertyMapper &) | ||
187 | { | ||
188 | |||
189 | } | ||
190 | |||
191 | |||
192 | void TypeImplementation<Event>::configure(TypeIndex &index) | ||
193 | { | ||
194 | index.addProperty<QByteArray>(Event::Uid::name); | ||
195 | } | ||
196 | |||
197 | void TypeImplementation<Event>::configure(ReadPropertyMapper<Buffer> &propertyMapper) | ||
198 | { | ||
199 | propertyMapper.addMapping<Event::Summary, Buffer>(&Buffer::summary); | ||
200 | propertyMapper.addMapping<Event::Description, Buffer>(&Buffer::description); | ||
201 | propertyMapper.addMapping<Event::Uid, Buffer>(&Buffer::uid); | ||
202 | propertyMapper.addMapping<Event::Attachment, Buffer>(&Buffer::attachment); | ||
203 | } | ||
204 | |||
205 | void TypeImplementation<Event>::configure(WritePropertyMapper<BufferBuilder> &propertyMapper) | ||
206 | { | ||
207 | propertyMapper.addMapping<Event::Summary>(&BufferBuilder::add_summary); | ||
208 | propertyMapper.addMapping<Event::Description>(&BufferBuilder::add_description); | ||
209 | propertyMapper.addMapping<Event::Uid>(&BufferBuilder::add_uid); | ||
210 | propertyMapper.addMapping<Event::Attachment>(&BufferBuilder::add_attachment); | ||
211 | } | ||
212 | |||
213 | void TypeImplementation<Event>::configure(IndexPropertyMapper &) | ||
214 | { | ||
215 | |||
216 | } | ||
diff --git a/common/domain/typeimplementations.h b/common/domain/typeimplementations.h new file mode 100644 index 0000000..37d6ca9 --- /dev/null +++ b/common/domain/typeimplementations.h | |||
@@ -0,0 +1,101 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include "applicationdomaintype.h" | ||
22 | |||
23 | #include "mail_generated.h" | ||
24 | #include "folder_generated.h" | ||
25 | #include "event_generated.h" | ||
26 | #include "contact_generated.h" | ||
27 | #include "addressbook_generated.h" | ||
28 | |||
29 | template<typename T> | ||
30 | class ReadPropertyMapper; | ||
31 | template<typename T> | ||
32 | class WritePropertyMapper; | ||
33 | class IndexPropertyMapper; | ||
34 | |||
35 | class TypeIndex; | ||
36 | |||
37 | /** | ||
38 | * Implements all type-specific code such as updating and querying indexes. | ||
39 | * | ||
40 | * These are type specifiy default implementations. Theoretically a resource could implement it's own implementation. | ||
41 | */ | ||
42 | namespace Sink { | ||
43 | namespace ApplicationDomain { | ||
44 | |||
45 | template<> | ||
46 | class TypeImplementation<Sink::ApplicationDomain::Mail> { | ||
47 | public: | ||
48 | typedef Sink::ApplicationDomain::Buffer::Mail Buffer; | ||
49 | typedef Sink::ApplicationDomain::Buffer::MailBuilder BufferBuilder; | ||
50 | static void configure(TypeIndex &index); | ||
51 | static void configure(ReadPropertyMapper<Buffer> &propertyMapper); | ||
52 | static void configure(WritePropertyMapper<BufferBuilder> &propertyMapper); | ||
53 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
54 | }; | ||
55 | |||
56 | template<> | ||
57 | class TypeImplementation<Sink::ApplicationDomain::Folder> { | ||
58 | public: | ||
59 | typedef Sink::ApplicationDomain::Buffer::Folder Buffer; | ||
60 | typedef Sink::ApplicationDomain::Buffer::FolderBuilder BufferBuilder; | ||
61 | static void configure(TypeIndex &); | ||
62 | static void configure(ReadPropertyMapper<Buffer> &); | ||
63 | static void configure(WritePropertyMapper<BufferBuilder> &); | ||
64 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
65 | }; | ||
66 | |||
67 | template<> | ||
68 | class TypeImplementation<Sink::ApplicationDomain::Contact> { | ||
69 | public: | ||
70 | typedef Sink::ApplicationDomain::Buffer::Contact Buffer; | ||
71 | typedef Sink::ApplicationDomain::Buffer::ContactBuilder BufferBuilder; | ||
72 | static void configure(TypeIndex &); | ||
73 | static void configure(ReadPropertyMapper<Buffer> &); | ||
74 | static void configure(WritePropertyMapper<BufferBuilder> &); | ||
75 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
76 | }; | ||
77 | |||
78 | template<> | ||
79 | class TypeImplementation<Sink::ApplicationDomain::Addressbook> { | ||
80 | public: | ||
81 | typedef Sink::ApplicationDomain::Buffer::Addressbook Buffer; | ||
82 | typedef Sink::ApplicationDomain::Buffer::AddressbookBuilder BufferBuilder; | ||
83 | static void configure(TypeIndex &); | ||
84 | static void configure(ReadPropertyMapper<Buffer> &); | ||
85 | static void configure(WritePropertyMapper<BufferBuilder> &); | ||
86 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
87 | }; | ||
88 | |||
89 | template<> | ||
90 | class TypeImplementation<Sink::ApplicationDomain::Event> { | ||
91 | public: | ||
92 | typedef Sink::ApplicationDomain::Buffer::Event Buffer; | ||
93 | typedef Sink::ApplicationDomain::Buffer::EventBuilder BufferBuilder; | ||
94 | static void configure(TypeIndex &); | ||
95 | static void configure(ReadPropertyMapper<Buffer> &); | ||
96 | static void configure(WritePropertyMapper<BufferBuilder> &); | ||
97 | static void configure(IndexPropertyMapper &indexPropertyMapper); | ||
98 | }; | ||
99 | |||
100 | } | ||
101 | } | ||