diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-09 16:31:30 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-12-09 16:31:30 +0100 |
commit | 9f6751df8e6f483b112c2b24c0bc725924f17356 (patch) | |
tree | df312279bacc53e5bb6b6181fc25282ce5b0dd8e /examples | |
parent | 9c8e4612403fc2accc26ac2b49670394972f1293 (diff) | |
download | sink-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')
-rw-r--r-- | examples/dummyresource/resourcefactory.cpp | 2 | ||||
-rw-r--r-- | examples/imapresource/imapresource.cpp | 2 | ||||
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 14 | ||||
-rw-r--r-- | examples/mailtransportresource/mailtransportresource.cpp | 2 |
4 files changed, 14 insertions, 6 deletions
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index 07021b9..03238ef 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp | |||
@@ -163,7 +163,7 @@ DummyResource::DummyResource(const Sink::ResourceContext &resourceContext, const | |||
163 | setupSynchronizer(QSharedPointer<DummySynchronizer>::create(resourceContext)); | 163 | setupSynchronizer(QSharedPointer<DummySynchronizer>::create(resourceContext)); |
164 | setupInspector(QSharedPointer<DummyInspector>::create(resourceContext)); | 164 | setupInspector(QSharedPointer<DummyInspector>::create(resourceContext)); |
165 | setupPreprocessors(ENTITY_TYPE_MAIL, | 165 | setupPreprocessors(ENTITY_TYPE_MAIL, |
166 | QVector<Sink::Preprocessor*>() << new MailPropertyExtractor << new MimeMessageMover << new SpecialPurposeProcessor{resourceContext.resourceType, resourceContext.instanceId()}); | 166 | QVector<Sink::Preprocessor*>() << new MailPropertyExtractor << new SpecialPurposeProcessor{resourceContext.resourceType, resourceContext.instanceId()}); |
167 | setupPreprocessors(ENTITY_TYPE_FOLDER, | 167 | setupPreprocessors(ENTITY_TYPE_FOLDER, |
168 | QVector<Sink::Preprocessor*>()); | 168 | QVector<Sink::Preprocessor*>()); |
169 | setupPreprocessors(ENTITY_TYPE_EVENT, | 169 | setupPreprocessors(ENTITY_TYPE_EVENT, |
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 238fb0c..252b910 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp | |||
@@ -737,7 +737,7 @@ ImapResource::ImapResource(const ResourceContext &resourceContext) | |||
737 | inspector->mPassword = password; | 737 | inspector->mPassword = password; |
738 | setupInspector(inspector); | 738 | setupInspector(inspector); |
739 | 739 | ||
740 | setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << new SpecialPurposeProcessor(resourceContext.resourceType, resourceContext.instanceId()) << new MimeMessageMover << new MailPropertyExtractor); | 740 | setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << new SpecialPurposeProcessor(resourceContext.resourceType, resourceContext.instanceId()) << new MailPropertyExtractor); |
741 | setupPreprocessors(ENTITY_TYPE_FOLDER, QVector<Sink::Preprocessor*>()); | 741 | setupPreprocessors(ENTITY_TYPE_FOLDER, QVector<Sink::Preprocessor*>()); |
742 | } | 742 | } |
743 | 743 | ||
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 | ||
diff --git a/examples/mailtransportresource/mailtransportresource.cpp b/examples/mailtransportresource/mailtransportresource.cpp index 08a8748..b7ee77a 100644 --- a/examples/mailtransportresource/mailtransportresource.cpp +++ b/examples/mailtransportresource/mailtransportresource.cpp | |||
@@ -182,7 +182,7 @@ MailtransportResource::MailtransportResource(const Sink::ResourceContext &resour | |||
182 | setupSynchronizer(synchronizer); | 182 | setupSynchronizer(synchronizer); |
183 | setupInspector(QSharedPointer<MailtransportInspector>::create(resourceContext)); | 183 | setupInspector(QSharedPointer<MailtransportInspector>::create(resourceContext)); |
184 | 184 | ||
185 | setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << new MimeMessageMover << new MailPropertyExtractor); | 185 | setupPreprocessors(ENTITY_TYPE_MAIL, QVector<Sink::Preprocessor*>() << new MailPropertyExtractor); |
186 | } | 186 | } |
187 | 187 | ||
188 | MailtransportResourceFactory::MailtransportResourceFactory(QObject *parent) | 188 | MailtransportResourceFactory::MailtransportResourceFactory(QObject *parent) |