summaryrefslogtreecommitdiffstats
path: root/common/domain
diff options
context:
space:
mode:
Diffstat (limited to 'common/domain')
-rw-r--r--common/domain/addressbook.fbs9
-rw-r--r--common/domain/applicationdomaintype.cpp80
-rw-r--r--common/domain/applicationdomaintype.h144
-rw-r--r--common/domain/applicationdomaintype_p.h8
-rw-r--r--common/domain/contact.cpp57
-rw-r--r--common/domain/contact.fbs10
-rw-r--r--common/domain/contact.h57
-rw-r--r--common/domain/domaintypes.h5
-rw-r--r--common/domain/event.cpp57
-rw-r--r--common/domain/event.h57
-rw-r--r--common/domain/folder.cpp60
-rw-r--r--common/domain/folder.h51
-rw-r--r--common/domain/mail.h52
-rw-r--r--common/domain/propertyregistry.cpp18
-rw-r--r--common/domain/propertyregistry.h3
-rw-r--r--common/domain/typeimplementations.cpp (renamed from common/domain/mail.cpp)118
-rw-r--r--common/domain/typeimplementations.h101
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 @@
1namespace Sink.ApplicationDomain.Buffer;
2
3table Addressbook {
4 name:string;
5 parent:string;
6}
7
8root_type Addressbook;
9file_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() {
72namespace Sink { 75namespace Sink {
73namespace ApplicationDomain { 76namespace ApplicationDomain {
74 77
78constexpr const char *SinkResource::name;
79constexpr const char *SinkAccount::name;
80
81SINK_REGISTER_ENTITY(Mail);
75SINK_REGISTER_PROPERTY(Mail, Sender); 82SINK_REGISTER_PROPERTY(Mail, Sender);
76SINK_REGISTER_PROPERTY(Mail, To); 83SINK_REGISTER_PROPERTY(Mail, To);
77SINK_REGISTER_PROPERTY(Mail, Cc); 84SINK_REGISTER_PROPERTY(Mail, Cc);
@@ -90,11 +97,28 @@ SINK_REGISTER_PROPERTY(Mail, MessageId);
90SINK_REGISTER_PROPERTY(Mail, ParentMessageId); 97SINK_REGISTER_PROPERTY(Mail, ParentMessageId);
91SINK_REGISTER_PROPERTY(Mail, ThreadId); 98SINK_REGISTER_PROPERTY(Mail, ThreadId);
92 99
100SINK_REGISTER_ENTITY(Folder);
93SINK_REGISTER_PROPERTY(Folder, Name); 101SINK_REGISTER_PROPERTY(Folder, Name);
94SINK_REGISTER_PROPERTY(Folder, Icon); 102SINK_REGISTER_PROPERTY(Folder, Icon);
95SINK_REGISTER_PROPERTY(Folder, SpecialPurpose); 103SINK_REGISTER_PROPERTY(Folder, SpecialPurpose);
96SINK_REGISTER_PROPERTY(Folder, Enabled); 104SINK_REGISTER_PROPERTY(Folder, Enabled);
97SINK_REGISTER_PROPERTY(Folder, Parent); 105SINK_REGISTER_PROPERTY(Folder, Parent);
106SINK_REGISTER_PROPERTY(Folder, Count);
107SINK_REGISTER_PROPERTY(Folder, FullContentAvailable);
108
109SINK_REGISTER_ENTITY(Contact);
110SINK_REGISTER_PROPERTY(Contact, Uid);
111SINK_REGISTER_PROPERTY(Contact, Fn);
112SINK_REGISTER_PROPERTY(Contact, Firstname);
113SINK_REGISTER_PROPERTY(Contact, Lastname);
114SINK_REGISTER_PROPERTY(Contact, Emails);
115SINK_REGISTER_PROPERTY(Contact, Vcard);
116SINK_REGISTER_PROPERTY(Contact, Addressbook);
117
118SINK_REGISTER_ENTITY(Addressbook);
119SINK_REGISTER_PROPERTY(Addressbook, Name);
120SINK_REGISTER_PROPERTY(Addressbook, Parent);
121SINK_REGISTER_PROPERTY(Addressbook, LastUpdated);
98 122
99static const int foo = [] { 123static 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
367template<> 389SinkResource CardDavResource::create(const QByteArray &account)
368QByteArray getTypeName<Contact>()
369{
370 return "contact";
371}
372
373template<>
374QByteArray getTypeName<Event>()
375{
376 return "event";
377}
378
379template<>
380QByteArray getTypeName<Todo>()
381{
382 return "todo";
383}
384
385template<>
386QByteArray getTypeName<SinkResource>()
387{
388 return "resource";
389}
390
391template<>
392QByteArray getTypeName<SinkAccount>()
393{
394 return "account";
395}
396
397template<>
398QByteArray getTypeName<Identity>()
399{
400 return "identity";
401}
402
403template<>
404QByteArray getTypeName<Mail>()
405{ 390{
406 return "mail"; 391 auto &&resource = ApplicationDomainType::createEntity<SinkResource>();
407} 392 resource.setResourceType("sink.dav");
408 393 resource.setAccount(account);
409template<> 394 return resource;
410QByteArray getTypeName<Folder>()
411{
412 return "folder";
413} 395}
414 396
415QByteArrayList getTypeNames() 397QByteArrayList 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 @@
92namespace Sink { 93namespace Sink {
93namespace ApplicationDomain { 94namespace ApplicationDomain {
94 95
96enum SINK_EXPORT ErrorCode {
97 NoError = 0,
98 UnknownError,
99 NoServerError,
100 ConnectionError,
101 LoginError,
102 ConfigurationError,
103 TransmissionError,
104};
105
106enum SINK_EXPORT SuccessCode {
107 TransmissionSuccess
108};
109
110enum 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 */
126enum SINK_EXPORT Status {
127 OfflineStatus,
128 ConnectedStatus,
129 BusyStatus,
130 ErrorStatus
131};
132
95struct SINK_EXPORT Error { 133struct 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 */
103struct BLOB { 146struct 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
270struct SINK_EXPORT SinkAccount : public ApplicationDomainType { 313struct 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 */
292struct SINK_EXPORT SinkResource : public ApplicationDomainType { 334struct 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
307struct SINK_EXPORT Entity : public ApplicationDomainType { 348struct 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
356struct 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
315struct SINK_EXPORT Contact : public Entity { 363struct 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
323struct SINK_EXPORT Event : public Entity { 383struct 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
331struct SINK_EXPORT Todo : public Entity { 391struct SINK_EXPORT Todo : public Entity {
332 SINK_ENTITY(Todo); 392 SINK_ENTITY(Todo, todo);
333}; 393};
334 394
335struct SINK_EXPORT Calendar : public Entity { 395struct SINK_EXPORT Calendar : public Entity {
336 SINK_ENTITY(Calendar); 396 SINK_ENTITY(Calendar, calendar);
337}; 397};
338 398
339struct SINK_EXPORT Folder : public Entity { 399struct 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
348struct SINK_EXPORT Mail : public Entity { 411struct 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
374SINK_EXPORT QDebug operator<< (QDebug d, const Mail::Contact &c); 437SINK_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 */
385enum SINK_EXPORT Status {
386 OfflineStatus,
387 ConnectedStatus,
388 BusyStatus,
389 ErrorStatus
390};
391
392struct SINK_EXPORT Identity : public ApplicationDomainType { 439struct 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
467struct SINK_EXPORT CardDavResource {
468 static SinkResource create(const QByteArray &account);
469};
470
419namespace ResourceCapabilities { 471namespace ResourceCapabilities {
420namespace Mail { 472namespace 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};
482namespace 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
432namespace SpecialPurpose { 489namespace 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 */
446template<class DomainType> 503template<class DomainType>
447QByteArray SINK_EXPORT getTypeName(); 504QByteArray SINK_EXPORT getTypeName()
448 505{
449template<> 506 return DomainType::name;
450QByteArray SINK_EXPORT getTypeName<Contact>(); 507}
451
452template<>
453QByteArray SINK_EXPORT getTypeName<Event>();
454
455template<>
456QByteArray SINK_EXPORT getTypeName<Todo>();
457
458template<>
459QByteArray SINK_EXPORT getTypeName<SinkResource>();
460
461template<>
462QByteArray SINK_EXPORT getTypeName<SinkAccount>();
463
464template<>
465QByteArray SINK_EXPORT getTypeName<Identity>();
466
467template<>
468QByteArray SINK_EXPORT getTypeName<Mail>();
469
470template<>
471QByteArray SINK_EXPORT getTypeName<Folder>();
472 508
473QByteArrayList SINK_EXPORT getTypeNames(); 509QByteArrayList 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)
520Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity) 557Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity)
521Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity::Ptr) 558Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity::Ptr)
522Q_DECLARE_METATYPE(Sink::ApplicationDomain::Mail::Contact) 559Q_DECLARE_METATYPE(Sink::ApplicationDomain::Mail::Contact)
560Q_DECLARE_METATYPE(Sink::ApplicationDomain::Contact::Email)
523Q_DECLARE_METATYPE(Sink::ApplicationDomain::Error) 561Q_DECLARE_METATYPE(Sink::ApplicationDomain::Error)
524Q_DECLARE_METATYPE(Sink::ApplicationDomain::Progress) 562Q_DECLARE_METATYPE(Sink::ApplicationDomain::Progress)
525Q_DECLARE_METATYPE(Sink::ApplicationDomain::BLOB) 563Q_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
31using namespace Sink::ApplicationDomain;
32
33void TypeImplementation<Contact>::configure(TypeIndex &index)
34{
35 index.addProperty<QByteArray>(Contact::Uid::name);
36}
37
38void 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
46void 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
54void 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 @@
1namespace Sink.ApplicationDomain.Buffer; 1namespace Sink.ApplicationDomain.Buffer;
2 2
3table ContactEmail {
4 type: int;
5 email: string;
6}
7
3table Contact { 8table 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
23class QByteArray;
24
25template<typename T>
26class ReadPropertyMapper;
27template<typename T>
28class WritePropertyMapper;
29class IndexPropertyMapper;
30
31class TypeIndex;
32
33namespace Sink {
34namespace 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 */
45template<>
46class TypeImplementation<Sink::ApplicationDomain::Contact> {
47public:
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
31using namespace Sink::ApplicationDomain;
32
33void TypeImplementation<Event>::configure(TypeIndex &index)
34{
35 index.addProperty<QByteArray>(Event::Uid::name);
36}
37
38void 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
46void 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
54void 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
23class QByteArray;
24
25template<typename T>
26class ReadPropertyMapper;
27template<typename T>
28class WritePropertyMapper;
29class IndexPropertyMapper;
30
31class TypeIndex;
32
33namespace Sink {
34namespace 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 */
45template<>
46class TypeImplementation<Sink::ApplicationDomain::Event> {
47public:
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
31using namespace Sink::ApplicationDomain;
32
33void TypeImplementation<Folder>::configure(TypeIndex &index)
34{
35 index.addProperty<QByteArray>(Folder::Parent::name);
36 index.addProperty<QString>(Folder::Name::name);
37}
38
39void 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
48void 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
57void 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
23template<typename T>
24class ReadPropertyMapper;
25template<typename T>
26class WritePropertyMapper;
27class IndexPropertyMapper;
28
29class TypeIndex;
30
31namespace Sink {
32
33namespace ApplicationDomain {
34 namespace Buffer {
35 struct Folder;
36 struct FolderBuilder;
37 }
38
39template<>
40class TypeImplementation<Sink::ApplicationDomain::Folder> {
41public:
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
23class QByteArray;
24
25template<typename T>
26class ReadPropertyMapper;
27template<typename T>
28class WritePropertyMapper;
29class IndexPropertyMapper;
30
31class TypeIndex;
32
33namespace Sink {
34namespace ApplicationDomain {
35 namespace Buffer {
36 struct Mail;
37 struct MailBuilder;
38 }
39
40template<>
41class TypeImplementation<Sink::ApplicationDomain::Mail> {
42public:
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
66template <> 66template <>
67QVariant 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
77template <>
67QVariant parseString<QList<QByteArray>>(const QString &s) 78QVariant 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
106template <>
107QVariant parseString<QList<Sink::ApplicationDomain::Contact::Email>>(const QString &s)
108{
109 Q_ASSERT(false);
110 return QVariant{};
111}
112
95PropertyRegistry &PropertyRegistry::instance() 113PropertyRegistry &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 <>
49QVariant parseString<bool>(const QString &s); 49QVariant parseString<bool>(const QString &s);
50 50
51template <> 51template <>
52QVariant parseString<int>(const QString &s);
53
54template <>
52QVariant parseString<QList<QByteArray>>(const QString &s); 55QVariant parseString<QList<QByteArray>>(const QString &s);
53 56
54template <> 57template <>
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
34using namespace Sink; 32using namespace Sink;
35using namespace Sink::ApplicationDomain; 33using 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
105void TypeImplementation<Folder>::configure(TypeIndex &index)
106{
107 index.addProperty<QByteArray>(Folder::Parent::name);
108 index.addProperty<QString>(Folder::Name::name);
109}
110
111void 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
120void 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
129void TypeImplementation<Folder>::configure(IndexPropertyMapper &)
130{
131
132}
133
134
135void TypeImplementation<Contact>::configure(TypeIndex &index)
136{
137 index.addProperty<QByteArray>(Contact::Uid::name);
138}
139
140void 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
151void 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
162void TypeImplementation<Contact>::configure(IndexPropertyMapper &)
163{
164
165}
166
167
168void TypeImplementation<Addressbook>::configure(TypeIndex &index)
169{
170 index.addProperty<QByteArray>(Addressbook::Parent::name);
171 index.addProperty<QString>(Addressbook::Name::name);
172}
173
174void 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
180void 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
186void TypeImplementation<Addressbook>::configure(IndexPropertyMapper &)
187{
188
189}
190
191
192void TypeImplementation<Event>::configure(TypeIndex &index)
193{
194 index.addProperty<QByteArray>(Event::Uid::name);
195}
196
197void 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
205void 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
213void 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
29template<typename T>
30class ReadPropertyMapper;
31template<typename T>
32class WritePropertyMapper;
33class IndexPropertyMapper;
34
35class 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 */
42namespace Sink {
43namespace ApplicationDomain {
44
45template<>
46class TypeImplementation<Sink::ApplicationDomain::Mail> {
47public:
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
56template<>
57class TypeImplementation<Sink::ApplicationDomain::Folder> {
58public:
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
67template<>
68class TypeImplementation<Sink::ApplicationDomain::Contact> {
69public:
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
78template<>
79class TypeImplementation<Sink::ApplicationDomain::Addressbook> {
80public:
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
89template<>
90class TypeImplementation<Sink::ApplicationDomain::Event> {
91public:
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}