summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-31 18:13:21 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-31 18:13:21 +0200
commita5d693e5b71caeb21d0337e93d62e49584ae6890 (patch)
tree7007c52c1e551ac7b1200a279abef38528f4d60d
parenteb60292cdbb872c29d9e0b3266f479de2a774473 (diff)
downloadsink-a5d693e5b71caeb21d0337e93d62e49584ae6890.tar.gz
sink-a5d693e5b71caeb21d0337e93d62e49584ae6890.zip
Fixed property extraction in imap resource
-rw-r--r--examples/imapresource/imapresource.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp
index 0e766d5..5e5aae6 100644
--- a/examples/imapresource/imapresource.cpp
+++ b/examples/imapresource/imapresource.cpp
@@ -63,6 +63,7 @@ public:
63 void updatedIndexedProperties(Sink::ApplicationDomain::BufferAdaptor &newEntity) 63 void updatedIndexedProperties(Sink::ApplicationDomain::BufferAdaptor &newEntity)
64 { 64 {
65 const auto mimeMessagePath = newEntity.getProperty("mimeMessage").toString(); 65 const auto mimeMessagePath = newEntity.getProperty("mimeMessage").toString();
66 Trace() << "Updating indexed properties " << mimeMessagePath;
66 QFile f(mimeMessagePath); 67 QFile f(mimeMessagePath);
67 if (!f.open(QIODevice::ReadOnly)) { 68 if (!f.open(QIODevice::ReadOnly)) {
68 Warning() << "Failed to open the file: " << mimeMessagePath; 69 Warning() << "Failed to open the file: " << mimeMessagePath;
@@ -178,10 +179,7 @@ public:
178 time->start(); 179 time->start();
179 const QByteArray bufferType = ENTITY_TYPE_MAIL; 180 const QByteArray bufferType = ENTITY_TYPE_MAIL;
180 181
181 182 Trace() << "Importing new mail." << path;
182 Trace() << "Importing new mail.";
183
184 // Trace() << "Looking into " << listingPath;
185 183
186 const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, path.toUtf8()); 184 const auto folderLocalId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, path.toUtf8());
187 185
@@ -195,14 +193,18 @@ public:
195 Sink::ApplicationDomain::Mail mail; 193 Sink::ApplicationDomain::Mail mail;
196 mail.setFolder(folderLocalId); 194 mail.setFolder(folderLocalId);
197 195
198 auto filePath = Sink::resourceStorageLocation(mResourceInstanceIdentifier) + "/" + remoteId; 196 const auto directory = Sink::resourceStorageLocation(mResourceInstanceIdentifier) + "/" + path.toUtf8();
199 QDir().mkpath(Sink::resourceStorageLocation(mResourceInstanceIdentifier) + "/" + path.toUtf8()); 197 QDir().mkpath(directory);
198 auto filePath = directory + "/" + QByteArray::number(message.uid);
200 QFile file(filePath); 199 QFile file(filePath);
201 if (!file.open(QIODevice::WriteOnly)) { 200 if (!file.open(QIODevice::WriteOnly)) {
202 Warning() << "Failed to open file for writing: " << file.errorString(); 201 Warning() << "Failed to open file for writing: " << file.errorString();
203 } 202 }
204 const auto content = message.msg->encodedContent(); 203 const auto content = message.msg->encodedContent();
205 file.write(content); 204 file.write(content);
205 //Close before calling createOrModify, to ensure the file is available
206 file.close();
207
206 mail.setMimeMessagePath(filePath); 208 mail.setMimeMessagePath(filePath);
207 mail.setUnread(!message.flags.contains(Imap::Flags::Seen)); 209 mail.setUnread(!message.flags.contains(Imap::Flags::Seen));
208 mail.setImportant(message.flags.contains(Imap::Flags::Flagged)); 210 mail.setImportant(message.flags.contains(Imap::Flags::Flagged));