diff options
-rw-r--r-- | common/CMakeLists.txt | 2 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.cpp | 12 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.h | 14 | ||||
-rw-r--r-- | common/domain/contact.cpp | 57 | ||||
-rw-r--r-- | common/domain/contact.fbs | 11 | ||||
-rw-r--r-- | common/domain/contact.h | 57 | ||||
-rw-r--r-- | common/domain/domaintypes.h | 1 |
7 files changed, 154 insertions, 0 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 934d328..676342d 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt | |||
@@ -61,6 +61,7 @@ set(command_SRCS | |||
61 | configstore.cpp | 61 | configstore.cpp |
62 | resultset.cpp | 62 | resultset.cpp |
63 | domain/applicationdomaintype.cpp | 63 | domain/applicationdomaintype.cpp |
64 | domain/contact.cpp | ||
64 | domain/event.cpp | 65 | domain/event.cpp |
65 | domain/mail.cpp | 66 | domain/mail.cpp |
66 | domain/folder.cpp | 67 | domain/folder.cpp |
@@ -97,6 +98,7 @@ generate_flatbuffers( | |||
97 | commands/revisionreplayed | 98 | commands/revisionreplayed |
98 | commands/inspection | 99 | commands/inspection |
99 | commands/flush | 100 | commands/flush |
101 | domain/contact | ||
100 | domain/event | 102 | domain/event |
101 | domain/mail | 103 | domain/mail |
102 | domain/folder | 104 | domain/folder |
diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index 1647951..6d16a3c 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp | |||
@@ -206,6 +206,11 @@ Entity::~Entity() | |||
206 | 206 | ||
207 | } | 207 | } |
208 | 208 | ||
209 | Contact::~Contact() | ||
210 | { | ||
211 | |||
212 | } | ||
213 | |||
209 | Event::~Event() | 214 | Event::~Event() |
210 | { | 215 | { |
211 | 216 | ||
@@ -325,6 +330,12 @@ SinkResource ImapResource::create(const QByteArray &account) | |||
325 | } | 330 | } |
326 | 331 | ||
327 | template<> | 332 | template<> |
333 | QByteArray getTypeName<Contact>() | ||
334 | { | ||
335 | return "contact"; | ||
336 | } | ||
337 | |||
338 | template<> | ||
328 | QByteArray getTypeName<Event>() | 339 | QByteArray getTypeName<Event>() |
329 | { | 340 | { |
330 | return "event"; | 341 | return "event"; |
@@ -377,6 +388,7 @@ QByteArrayList getTypeNames() | |||
377 | types << ApplicationDomain::getTypeName<Folder>(); | 388 | types << ApplicationDomain::getTypeName<Folder>(); |
378 | types << ApplicationDomain::getTypeName<Event>(); | 389 | types << ApplicationDomain::getTypeName<Event>(); |
379 | types << ApplicationDomain::getTypeName<Todo>(); | 390 | types << ApplicationDomain::getTypeName<Todo>(); |
391 | types << ApplicationDomain::getTypeName<Contact>(); | ||
380 | } | 392 | } |
381 | return types; | 393 | return types; |
382 | } | 394 | } |
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index db7fc8d..e4ed05b 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -328,6 +328,14 @@ struct SINK_EXPORT Entity : public ApplicationDomainType { | |||
328 | virtual ~Entity(); | 328 | virtual ~Entity(); |
329 | }; | 329 | }; |
330 | 330 | ||
331 | struct SINK_EXPORT Contact : public Entity { | ||
332 | SINK_ENTITY(Contact); | ||
333 | SINK_EXTRACTED_PROPERTY(QString, Uid, uid); | ||
334 | SINK_PROPERTY(QString, Fn, fn); | ||
335 | SINK_PROPERTY(QByteArrayList, Emails, emails); | ||
336 | SINK_BLOB_PROPERTY(Vcard, vcard); | ||
337 | }; | ||
338 | |||
331 | struct SINK_EXPORT Event : public Entity { | 339 | struct SINK_EXPORT Event : public Entity { |
332 | SINK_ENTITY(Event); | 340 | SINK_ENTITY(Event); |
333 | SINK_PROPERTY(QString, Uid, uid); | 341 | SINK_PROPERTY(QString, Uid, uid); |
@@ -459,6 +467,9 @@ template<class DomainType> | |||
459 | QByteArray SINK_EXPORT getTypeName(); | 467 | QByteArray SINK_EXPORT getTypeName(); |
460 | 468 | ||
461 | template<> | 469 | template<> |
470 | QByteArray SINK_EXPORT getTypeName<Contact>(); | ||
471 | |||
472 | template<> | ||
462 | QByteArray SINK_EXPORT getTypeName<Event>(); | 473 | QByteArray SINK_EXPORT getTypeName<Event>(); |
463 | 474 | ||
464 | template<> | 475 | template<> |
@@ -507,6 +518,7 @@ class SINK_EXPORT TypeImplementation; | |||
507 | * This macro can be used to instantiate templates for all domain types. | 518 | * This macro can be used to instantiate templates for all domain types. |
508 | */ | 519 | */ |
509 | #define SINK_REGISTER_TYPES() \ | 520 | #define SINK_REGISTER_TYPES() \ |
521 | REGISTER_TYPE(Sink::ApplicationDomain::Contact); \ | ||
510 | REGISTER_TYPE(Sink::ApplicationDomain::Event); \ | 522 | REGISTER_TYPE(Sink::ApplicationDomain::Event); \ |
511 | REGISTER_TYPE(Sink::ApplicationDomain::Mail); \ | 523 | REGISTER_TYPE(Sink::ApplicationDomain::Mail); \ |
512 | REGISTER_TYPE(Sink::ApplicationDomain::Folder); \ | 524 | REGISTER_TYPE(Sink::ApplicationDomain::Folder); \ |
@@ -521,6 +533,8 @@ Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType) | |||
521 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType::Ptr) | 533 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::ApplicationDomainType::Ptr) |
522 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity) | 534 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity) |
523 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity::Ptr) | 535 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Entity::Ptr) |
536 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Contact) | ||
537 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Contact::Ptr) | ||
524 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Event) | 538 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Event) |
525 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Event::Ptr) | 539 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Event::Ptr) |
526 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Mail) | 540 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Mail) |
diff --git a/common/domain/contact.cpp b/common/domain/contact.cpp new file mode 100644 index 0000000..ea7cac2 --- /dev/null +++ b/common/domain/contact.cpp | |||
@@ -0,0 +1,57 @@ | |||
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 new file mode 100644 index 0000000..34fb1d6 --- /dev/null +++ b/common/domain/contact.fbs | |||
@@ -0,0 +1,11 @@ | |||
1 | namespace Sink.ApplicationDomain.Buffer; | ||
2 | |||
3 | table Contact { | ||
4 | uid:string; | ||
5 | fn:string; | ||
6 | emails: [string]; | ||
7 | vcard: string; | ||
8 | } | ||
9 | |||
10 | root_type Contact; | ||
11 | file_identifier "AKFB"; | ||
diff --git a/common/domain/contact.h b/common/domain/contact.h new file mode 100644 index 0000000..c803a9f --- /dev/null +++ b/common/domain/contact.h | |||
@@ -0,0 +1,57 @@ | |||
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 index 84c5bd5..0abdee7 100644 --- a/common/domain/domaintypes.h +++ b/common/domain/domaintypes.h | |||
@@ -1,4 +1,5 @@ | |||
1 | 1 | ||
2 | #include "contact.h" | ||
2 | #include "mail.h" | 3 | #include "mail.h" |
3 | #include "folder.h" | 4 | #include "folder.h" |
4 | #include "event.h" | 5 | #include "event.h" |