diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-05 17:33:08 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-05 18:14:43 +0100 |
commit | 47bfba0d9152a1f7f689d7936b107b1a899a0b76 (patch) | |
tree | d3097b1da7bc87984bd7fdffbf803ed682e95fcc /examples/maildirresource/maildirresource.cpp | |
parent | b9a79ed514e7ab6bab0d6dedfcb9a78387d2b7c1 (diff) | |
download | sink-47bfba0d9152a1f7f689d7936b107b1a899a0b76.tar.gz sink-47bfba0d9152a1f7f689d7936b107b1a899a0b76.zip |
Use property transformation for the mimeMessage
The filepath changes with every flag change. It is thus easier to only
store a limited path that remains stable, and figure out the rest as
the property is requested (we'll have to translate it anyways once we
the file handoff protocol is implemented).
The reason why we don't update the mimeMessage path on every
modification is because we move the message during change replay,
and not while storing the modification in the db. This would lead to
the message-path on disk not correspond to what is in the db for some
time.
Diffstat (limited to 'examples/maildirresource/maildirresource.cpp')
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 87623ca..d5cc24b 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -175,6 +175,7 @@ void MaildirResource::synchronizeMails(Sink::Storage::Transaction &transaction, | |||
175 | msg->parse(); | 175 | msg->parse(); |
176 | 176 | ||
177 | const auto flags = maildir.readEntryFlags(fileName); | 177 | const auto flags = maildir.readEntryFlags(fileName); |
178 | const auto maildirKey = maildir.getKeyFromFile(fileName); | ||
178 | 179 | ||
179 | Trace() << "Found a mail " << filePath << " : " << fileName << msg->subject(true)->asUnicodeString(); | 180 | Trace() << "Found a mail " << filePath << " : " << fileName << msg->subject(true)->asUnicodeString(); |
180 | 181 | ||
@@ -184,7 +185,8 @@ void MaildirResource::synchronizeMails(Sink::Storage::Transaction &transaction, | |||
184 | mail.setProperty("senderName", msg->from(true)->asUnicodeString()); | 185 | mail.setProperty("senderName", msg->from(true)->asUnicodeString()); |
185 | mail.setProperty("date", msg->date(true)->dateTime()); | 186 | mail.setProperty("date", msg->date(true)->dateTime()); |
186 | mail.setProperty("folder", folderLocalId); | 187 | mail.setProperty("folder", folderLocalId); |
187 | mail.setProperty("mimeMessage", filePath); | 188 | //We only store the directory path + key, so we facade can add the changing bits (flags) |
189 | mail.setProperty("mimeMessage", KPIM::Maildir::getDirectoryFromFile(filePath) + maildirKey); | ||
188 | mail.setProperty("unread", !flags.testFlag(KPIM::Maildir::Seen)); | 190 | mail.setProperty("unread", !flags.testFlag(KPIM::Maildir::Seen)); |
189 | mail.setProperty("important", flags.testFlag(KPIM::Maildir::Flagged)); | 191 | mail.setProperty("important", flags.testFlag(KPIM::Maildir::Flagged)); |
190 | 192 | ||
@@ -274,7 +276,7 @@ KAsync::Job<void> MaildirResource::replay(Sink::Storage &synchronizationStore, c | |||
274 | if (!maildir.isValid(true)) { | 276 | if (!maildir.isValid(true)) { |
275 | return KAsync::error<void>(1, "Invalid folder " + parentFolderPath); | 277 | return KAsync::error<void>(1, "Invalid folder " + parentFolderPath); |
276 | } | 278 | } |
277 | //FIXME assemble the MIME message | 279 | //FIXME move the mime message from the mimeMessage property to the proper place. |
278 | Trace() << "Creating a new mail."; | 280 | Trace() << "Creating a new mail."; |
279 | const auto remoteId = maildir.addEntry("foobar"); | 281 | const auto remoteId = maildir.addEntry("foobar"); |
280 | if (remoteId.isEmpty()) { | 282 | if (remoteId.isEmpty()) { |