summaryrefslogtreecommitdiffstats
path: root/examples/maildirresource
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-09 16:31:30 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-09 16:31:30 +0100
commit9f6751df8e6f483b112c2b24c0bc725924f17356 (patch)
treedf312279bacc53e5bb6b6181fc25282ce5b0dd8e /examples/maildirresource
parent9c8e4612403fc2accc26ac2b49670394972f1293 (diff)
downloadsink-9f6751df8e6f483b112c2b24c0bc725924f17356.tar.gz
sink-9f6751df8e6f483b112c2b24c0bc725924f17356.zip
Move the BLOB property handling to the entitystore.
This is really part of the storage, and will help us to cleanly implement features like moving properties into a temporary place when reading in a clean way as well.
Diffstat (limited to 'examples/maildirresource')
-rw-r--r--examples/maildirresource/maildirresource.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp
index a05afc6..6a03263 100644
--- a/examples/maildirresource/maildirresource.cpp
+++ b/examples/maildirresource/maildirresource.cpp
@@ -132,7 +132,10 @@ public:
132 auto mail = newEntity.cast<ApplicationDomain::Mail>(); 132 auto mail = newEntity.cast<ApplicationDomain::Mail>();
133 const auto mimeMessage = mail.getMimeMessagePath(); 133 const auto mimeMessage = mail.getMimeMessagePath();
134 if (!mimeMessage.isNull()) { 134 if (!mimeMessage.isNull()) {
135 mail.setMimeMessagePath(moveMessage(mimeMessage, mail.getFolder())); 135 const auto path = moveMessage(mimeMessage, mail.getFolder());
136 auto blob = ApplicationDomain::BLOB{path};
137 blob.isExternal = false;
138 mail.setProperty(ApplicationDomain::Mail::MimeMessage::name, QVariant::fromValue(blob));
136 } 139 }
137 } 140 }
138 141
@@ -149,7 +152,9 @@ public:
149 auto newPath = moveMessage(mimeMessage, newMail.getFolder()); 152 auto newPath = moveMessage(mimeMessage, newMail.getFolder());
150 if (newPath != oldMail.getMimeMessagePath()) { 153 if (newPath != oldMail.getMimeMessagePath()) {
151 const auto oldPath = getFilePathFromMimeMessagePath(oldMail.getMimeMessagePath()); 154 const auto oldPath = getFilePathFromMimeMessagePath(oldMail.getMimeMessagePath());
152 newMail.setMimeMessagePath(newPath); 155 auto blob = ApplicationDomain::BLOB{newPath};
156 blob.isExternal = false;
157 newMail.setProperty(ApplicationDomain::Mail::MimeMessage::name, QVariant::fromValue(blob));
153 //Remove the olde mime message if there is a new one 158 //Remove the olde mime message if there is a new one
154 QFile::remove(oldPath); 159 QFile::remove(oldPath);
155 } 160 }
@@ -323,7 +328,10 @@ public:
323 Sink::ApplicationDomain::Mail mail; 328 Sink::ApplicationDomain::Mail mail;
324 mail.setFolder(folderLocalId); 329 mail.setFolder(folderLocalId);
325 //We only store the directory path + key, so we facade can add the changing bits (flags) 330 //We only store the directory path + key, so we facade can add the changing bits (flags)
326 mail.setMimeMessagePath(KPIM::Maildir::getDirectoryFromFile(filePath) + maildirKey); 331 auto path = KPIM::Maildir::getDirectoryFromFile(filePath) + maildirKey;
332 auto blob = ApplicationDomain::BLOB{path};
333 blob.isExternal = false;
334 mail.setProperty(ApplicationDomain::Mail::MimeMessage::name, QVariant::fromValue(blob));
327 mail.setUnread(!flags.testFlag(KPIM::Maildir::Seen)); 335 mail.setUnread(!flags.testFlag(KPIM::Maildir::Seen));
328 mail.setImportant(flags.testFlag(KPIM::Maildir::Flagged)); 336 mail.setImportant(flags.testFlag(KPIM::Maildir::Flagged));
329 337