summaryrefslogtreecommitdiffstats
path: root/examples/dummyresource/resourcefactory.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-08 13:18:19 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-08 13:18:19 +0100
commitae4b64b198a143240aa5dd1e202e5016abfdae71 (patch)
tree5d9d58a512ebc60c44637d11c9424f67a02887e8 /examples/dummyresource/resourcefactory.cpp
parentf425c2070131161dc11bcf70e35f8d1848cadb65 (diff)
downloadsink-ae4b64b198a143240aa5dd1e202e5016abfdae71.tar.gz
sink-ae4b64b198a143240aa5dd1e202e5016abfdae71.zip
Wrap references in a Reerence type.
This allows us to make sure that references are not taken out of context (the resource). Because we need to use the type-specific accessors more we also ran into a problem that we cannot "downcast" a reference with the change recording still working, for that we have the cast<T>() operator now.
Diffstat (limited to 'examples/dummyresource/resourcefactory.cpp')
-rw-r--r--examples/dummyresource/resourcefactory.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp
index d230ea3..07021b9 100644
--- a/examples/dummyresource/resourcefactory.cpp
+++ b/examples/dummyresource/resourcefactory.cpp
@@ -59,34 +59,33 @@ class DummySynchronizer : public Sink::Synchronizer {
59 { 59 {
60 static uint8_t rawData[100]; 60 static uint8_t rawData[100];
61 auto event = Sink::ApplicationDomain::Event::Ptr::create(); 61 auto event = Sink::ApplicationDomain::Event::Ptr::create();
62 event->setProperty("summary", data.value("summary").toString()); 62 event->setSummary(data.value("summary").toString());
63 event->setProperty("remoteId", ridBuffer); 63 event->setProperty("remoteId", ridBuffer);
64 event->setProperty("description", data.value("description").toString()); 64 event->setDescription(data.value("description").toString());
65 event->setProperty("attachment", QByteArray::fromRawData(reinterpret_cast<const char*>(rawData), 100)); 65 event->setAttachment(QByteArray::fromRawData(reinterpret_cast<const char*>(rawData), 100));
66 return event; 66 return event;
67 } 67 }
68 68
69 Sink::ApplicationDomain::Mail::Ptr createMail(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) 69 Sink::ApplicationDomain::Mail::Ptr createMail(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data)
70 { 70 {
71 auto mail = Sink::ApplicationDomain::Mail::Ptr::create(); 71 auto mail = Sink::ApplicationDomain::Mail::Ptr::create();
72 mail->setProperty("subject", data.value("subject").toString()); 72 mail->setExtractedSubject(data.value("subject").toString());
73 mail->setProperty("senderEmail", data.value("senderEmail").toString()); 73 mail->setExtractedSender(Sink::ApplicationDomain::Mail::Contact{data.value("senderName").toString(), data.value("senderEmail").toString()});
74 mail->setProperty("senderName", data.value("senderName").toString()); 74 mail->setExtractedDate(data.value("date").toDateTime());
75 mail->setProperty("date", data.value("date").toString()); 75 mail->setFolder(syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, data.value("parentFolder").toByteArray()));
76 mail->setProperty("folder", syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, data.value("parentFolder").toByteArray())); 76 mail->setUnread(data.value("unread").toBool());
77 mail->setProperty("unread", data.value("unread").toBool()); 77 mail->setImportant(data.value("important").toBool());
78 mail->setProperty("important", data.value("important").toBool());
79 return mail; 78 return mail;
80 } 79 }
81 80
82 Sink::ApplicationDomain::Folder::Ptr createFolder(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) 81 Sink::ApplicationDomain::Folder::Ptr createFolder(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data)
83 { 82 {
84 auto folder = Sink::ApplicationDomain::Folder::Ptr::create(); 83 auto folder = Sink::ApplicationDomain::Folder::Ptr::create();
85 folder->setProperty("name", data.value("name").toString()); 84 folder->setName(data.value("name").toString());
86 folder->setProperty("icon", data.value("icon").toString()); 85 folder->setIcon(data.value("icon").toByteArray());
87 if (!data.value("parent").toString().isEmpty()) { 86 if (!data.value("parent").toString().isEmpty()) {
88 auto sinkId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, data.value("parent").toByteArray()); 87 auto sinkId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, data.value("parent").toByteArray());
89 folder->setProperty("parent", sinkId); 88 folder->setParent(sinkId);
90 } 89 }
91 return folder; 90 return folder;
92 } 91 }