diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-03 09:40:31 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-06-03 09:40:31 +0200 |
commit | b5789da647bfdba9e3cc9b0595271b4d8c42bb8c (patch) | |
tree | 421bed2f38c9eac1d2d6579bf6a45b95c33cfbbf | |
parent | f5b254c87a993988c9cb1fd06b5635f1a6b20f9f (diff) | |
download | sink-b5789da647bfdba9e3cc9b0595271b4d8c42bb8c.tar.gz sink-b5789da647bfdba9e3cc9b0595271b4d8c42bb8c.zip |
The imap resource can write-back changes
-rw-r--r-- | examples/imapresource/imapresource.cpp | 148 | ||||
-rw-r--r-- | examples/imapresource/imapserverproxy.cpp | 53 | ||||
-rw-r--r-- | examples/imapresource/imapserverproxy.h | 5 | ||||
-rw-r--r-- | tests/mailtest.cpp | 7 |
4 files changed, 204 insertions, 9 deletions
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 4122a69..2dfb2ea 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp | |||
@@ -330,6 +330,76 @@ public: | |||
330 | 330 | ||
331 | KAsync::Job<QByteArray> replay(const ApplicationDomain::Mail &mail, Sink::Operation operation, const QByteArray &oldRemoteId) | 331 | KAsync::Job<QByteArray> replay(const ApplicationDomain::Mail &mail, Sink::Operation operation, const QByteArray &oldRemoteId) |
332 | { | 332 | { |
333 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); | ||
334 | auto login = imap->login(mUser, mPassword); | ||
335 | if (operation == Sink::Operation_Creation) { | ||
336 | auto parentRemoteId = syncStore().resolveLocalId("folder", mail.getFolder()); | ||
337 | QString mailbox = parentRemoteId; | ||
338 | QByteArray content = KMime::LFtoCRLF(mail.getMimeMessage()); | ||
339 | QByteArrayList flags; | ||
340 | if (!mail.getUnread()) { | ||
341 | flags << Imap::Flags::Seen; | ||
342 | } | ||
343 | if (mail.getImportant()) { | ||
344 | flags << Imap::Flags::Flagged; | ||
345 | } | ||
346 | QDateTime internalDate = mail.getDate(); | ||
347 | auto rid = QSharedPointer<QByteArray>::create(); | ||
348 | return login.then(imap->append(mailbox, content, flags, internalDate)) | ||
349 | .then<void, qint64>([imap, mailbox, rid](qint64 uid) { | ||
350 | const auto remoteId = mailbox.toUtf8() + "/" + QByteArray::number(uid); | ||
351 | //FIXME this get's called after the final error ahndler? WTF? | ||
352 | Trace() << "Finished creating a new mail: " << remoteId; | ||
353 | *rid = remoteId; | ||
354 | }).then<QByteArray>([rid, imap]() { //FIXME fix KJob so we don't need this extra clause | ||
355 | return *rid; | ||
356 | }); | ||
357 | } else if (operation == Sink::Operation_Removal) { | ||
358 | auto ridParts = oldRemoteId.split('/'); | ||
359 | auto uid = ridParts.takeLast().toLongLong(); | ||
360 | //FIXME don't hardcode the separator | ||
361 | auto mailbox = ridParts.join('.'); | ||
362 | Trace() << "Removing a mail: " << oldRemoteId << "in the mailbox: " << mailbox; | ||
363 | KIMAP::ImapSet set; | ||
364 | set.add(uid); | ||
365 | return login.then(imap->remove(mailbox, set)) | ||
366 | .then<QByteArray>([imap, oldRemoteId]() { | ||
367 | Trace() << "Finished removing a mail: " << oldRemoteId; | ||
368 | return QByteArray(); | ||
369 | }); | ||
370 | } else if (operation == Sink::Operation_Modification) { | ||
371 | auto ridParts = oldRemoteId.split('/'); | ||
372 | auto uid = ridParts.takeLast().toLongLong(); | ||
373 | //FIXME don't hardcode the separator | ||
374 | auto mailbox = ridParts.join('.'); | ||
375 | Trace() << "Modifying a mail: " << oldRemoteId << " in the mailbox: " << mailbox; | ||
376 | //TODO if the message changed, remove old message and create a new one, | ||
377 | //otherwise only change flags | ||
378 | |||
379 | QByteArrayList flags; | ||
380 | if (!mail.getUnread()) { | ||
381 | flags << Imap::Flags::Seen; | ||
382 | } | ||
383 | if (mail.getImportant()) { | ||
384 | flags << Imap::Flags::Flagged; | ||
385 | } | ||
386 | |||
387 | QByteArray content = KMime::LFtoCRLF(mail.getMimeMessage()); | ||
388 | QDateTime internalDate = mail.getDate(); | ||
389 | auto rid = QSharedPointer<QByteArray>::create(); | ||
390 | KIMAP::ImapSet set; | ||
391 | set.add(uid); | ||
392 | return login.then(imap->append(mailbox, content, flags, internalDate)) | ||
393 | .then<void, qint64>([imap, mailbox, rid](qint64 uid) { | ||
394 | const auto remoteId = mailbox + "/" + QByteArray::number(uid); | ||
395 | Trace() << "Finished creating a modified mail: " << remoteId; | ||
396 | *rid = remoteId; | ||
397 | }) | ||
398 | .then(imap->remove(mailbox, set)) | ||
399 | .then<QByteArray>([rid, imap]() { | ||
400 | return *rid; | ||
401 | }); | ||
402 | } | ||
333 | return KAsync::null<QByteArray>(); | 403 | return KAsync::null<QByteArray>(); |
334 | } | 404 | } |
335 | 405 | ||
@@ -439,19 +509,61 @@ KAsync::Job<void> ImapResource::inspect(int inspectionType, const QByteArray &in | |||
439 | const auto folderRemoteId = syncStore->resolveLocalId(ENTITY_TYPE_FOLDER, mail.getFolder()); | 509 | const auto folderRemoteId = syncStore->resolveLocalId(ENTITY_TYPE_FOLDER, mail.getFolder()); |
440 | const auto mailRemoteId = syncStore->resolveLocalId(ENTITY_TYPE_MAIL, mail.identifier()); | 510 | const auto mailRemoteId = syncStore->resolveLocalId(ENTITY_TYPE_MAIL, mail.identifier()); |
441 | if (mailRemoteId.isEmpty() || folderRemoteId.isEmpty()) { | 511 | if (mailRemoteId.isEmpty() || folderRemoteId.isEmpty()) { |
442 | KAsync::error<void>(); | 512 | Warning() << "Missing remote id for folder or mail. " << mailRemoteId << folderRemoteId; |
513 | return KAsync::error<void>(); | ||
443 | } | 514 | } |
515 | auto uid = mailRemoteId.split('/').last().toLongLong(); | ||
444 | Trace() << "Mail remote id: " << folderRemoteId << mailRemoteId << mail.identifier() << folder.identifier(); | 516 | Trace() << "Mail remote id: " << folderRemoteId << mailRemoteId << mail.identifier() << folder.identifier(); |
445 | 517 | ||
518 | KIMAP::ImapSet set; | ||
519 | set.add(uid); | ||
520 | if (set.isEmpty()) { | ||
521 | return KAsync::error<void>(1, "Couldn't determine uid of mail."); | ||
522 | } | ||
523 | KIMAP::FetchJob::FetchScope scope; | ||
524 | scope.mode = KIMAP::FetchJob::FetchScope::Full; | ||
525 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); | ||
526 | auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); | ||
527 | auto inspectionJob = imap->login(mUser, mPassword) | ||
528 | .then<void>(imap->select(folderRemoteId)) | ||
529 | .then<void>(imap->fetch(set, scope, [imap, messageByUid](const QVector<Imap::Message> &messages) { | ||
530 | for (const auto &m : messages) { | ||
531 | messageByUid->insert(m.uid, m); | ||
532 | } | ||
533 | })); | ||
534 | |||
446 | if (inspectionType == Sink::ResourceControl::Inspection::PropertyInspectionType) { | 535 | if (inspectionType == Sink::ResourceControl::Inspection::PropertyInspectionType) { |
447 | if (property == "unread") { | 536 | if (property == "unread") { |
448 | return KAsync::null<void>(); | 537 | return inspectionJob.then<void, KAsync::Job<void>>([=]() { |
538 | auto msg = messageByUid->value(uid); | ||
539 | if (expectedValue.toBool() && msg.flags.contains(Imap::Flags::Seen)) { | ||
540 | return KAsync::error<void>(1, "Expected unread but couldn't find it."); | ||
541 | } | ||
542 | if (!expectedValue.toBool() && !msg.flags.contains(Imap::Flags::Seen)) { | ||
543 | return KAsync::error<void>(1, "Expected read but couldn't find it."); | ||
544 | } | ||
545 | return KAsync::null<void>(); | ||
546 | }); | ||
449 | } | 547 | } |
450 | if (property == "subject") { | 548 | if (property == "subject") { |
451 | return KAsync::null<void>(); | 549 | return inspectionJob.then<void, KAsync::Job<void>>([=]() { |
550 | auto msg = messageByUid->value(uid); | ||
551 | if (msg.msg->subject(true)->asUnicodeString() != expectedValue.toString()) { | ||
552 | return KAsync::error<void>(1, "Subject not as expected: " + msg.msg->subject(true)->asUnicodeString()); | ||
553 | } | ||
554 | return KAsync::null<void>(); | ||
555 | }); | ||
452 | } | 556 | } |
453 | } | 557 | } |
454 | if (inspectionType == Sink::ResourceControl::Inspection::ExistenceInspectionType) { | 558 | if (inspectionType == Sink::ResourceControl::Inspection::ExistenceInspectionType) { |
559 | return inspectionJob.then<void, KAsync::Job<void>>([=]() { | ||
560 | if (!messageByUid->contains(uid)) { | ||
561 | Warning() << "Existing messages are: " << messageByUid->keys(); | ||
562 | Warning() << "We're looking for: " << uid; | ||
563 | return KAsync::error<void>(1, "Couldn't find message: " + mailRemoteId); | ||
564 | } | ||
565 | return KAsync::null<void>(); | ||
566 | }); | ||
455 | } | 567 | } |
456 | } | 568 | } |
457 | if (domainType == ENTITY_TYPE_FOLDER) { | 569 | if (domainType == ENTITY_TYPE_FOLDER) { |
@@ -459,6 +571,36 @@ KAsync::Job<void> ImapResource::inspect(int inspectionType, const QByteArray &in | |||
459 | const auto folder = entityStore->read<Sink::ApplicationDomain::Folder>(entityId); | 571 | const auto folder = entityStore->read<Sink::ApplicationDomain::Folder>(entityId); |
460 | 572 | ||
461 | if (inspectionType == Sink::ResourceControl::Inspection::CacheIntegrityInspectionType) { | 573 | if (inspectionType == Sink::ResourceControl::Inspection::CacheIntegrityInspectionType) { |
574 | Warning() << "Inspecting cache integrity" << remoteId; | ||
575 | |||
576 | int expectedCount = 0; | ||
577 | Index index("mail.index.folder", transaction); | ||
578 | index.lookup(entityId, [&](const QByteArray &sinkId) { | ||
579 | expectedCount++; | ||
580 | }, | ||
581 | [&](const Index::Error &error) { | ||
582 | Warning() << "Error in index: " << error.message << property; | ||
583 | }); | ||
584 | |||
585 | auto set = KIMAP::ImapSet::fromImapSequenceSet("1:*"); | ||
586 | KIMAP::FetchJob::FetchScope scope; | ||
587 | scope.mode = KIMAP::FetchJob::FetchScope::Headers; | ||
588 | auto imap = QSharedPointer<ImapServerProxy>::create(mServer, mPort); | ||
589 | auto messageByUid = QSharedPointer<QHash<qint64, Imap::Message>>::create(); | ||
590 | auto inspectionJob = imap->login(mUser, mPassword) | ||
591 | .then<void>(imap->select(remoteId)) | ||
592 | .then<void>(imap->fetch(set, scope, [=](const QVector<Imap::Message> &messages) { | ||
593 | for (const auto &m : messages) { | ||
594 | messageByUid->insert(m.uid, m); | ||
595 | } | ||
596 | })) | ||
597 | .then<void, KAsync::Job<void>>([imap, messageByUid, expectedCount]() { | ||
598 | if (messageByUid->size() != expectedCount) { | ||
599 | return KAsync::error<void>(1, QString("Wrong number of files; found %1 instead of %2.").arg(messageByUid->size()).arg(expectedCount)); | ||
600 | } | ||
601 | return KAsync::null<void>(); | ||
602 | }); | ||
603 | return inspectionJob; | ||
462 | } | 604 | } |
463 | if (inspectionType == Sink::ResourceControl::Inspection::ExistenceInspectionType) { | 605 | if (inspectionType == Sink::ResourceControl::Inspection::ExistenceInspectionType) { |
464 | auto folderByPath = QSharedPointer<QSet<QString>>::create(); | 606 | auto folderByPath = QSharedPointer<QSet<QString>>::create(); |
diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp index 18b8dcf..1414dbe 100644 --- a/examples/imapresource/imapserverproxy.cpp +++ b/examples/imapresource/imapserverproxy.cpp | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <KIMAP/KIMAP/DeleteJob> | 28 | #include <KIMAP/KIMAP/DeleteJob> |
29 | #include <KIMAP/KIMAP/StoreJob> | 29 | #include <KIMAP/KIMAP/StoreJob> |
30 | #include <KIMAP/KIMAP/ExpungeJob> | 30 | #include <KIMAP/KIMAP/ExpungeJob> |
31 | #include <KIMAP/KIMAP/CapabilitiesJob> | ||
31 | 32 | ||
32 | #include <KIMAP/KIMAP/SessionUiProxy> | 33 | #include <KIMAP/KIMAP/SessionUiProxy> |
33 | #include <KCoreAddons/KJob> | 34 | #include <KCoreAddons/KJob> |
@@ -41,6 +42,22 @@ const char* Imap::Flags::Deleted = "\\Deleted"; | |||
41 | const char* Imap::Flags::Answered = "\\Answered"; | 42 | const char* Imap::Flags::Answered = "\\Answered"; |
42 | const char* Imap::Flags::Flagged = "\\Flagged"; | 43 | const char* Imap::Flags::Flagged = "\\Flagged"; |
43 | 44 | ||
45 | template <typename T> | ||
46 | static KAsync::Job<T> runJob(KJob *job, const std::function<T(KJob*)> &f) | ||
47 | { | ||
48 | return KAsync::start<T>([job, f](KAsync::Future<T> &future) { | ||
49 | QObject::connect(job, &KJob::result, [&future, f](KJob *job) { | ||
50 | if (job->error()) { | ||
51 | future.setError(job->error(), job->errorString()); | ||
52 | } else { | ||
53 | future.setValue(f(job)); | ||
54 | future.setFinished(); | ||
55 | } | ||
56 | }); | ||
57 | job->start(); | ||
58 | }); | ||
59 | } | ||
60 | |||
44 | static KAsync::Job<void> runJob(KJob *job) | 61 | static KAsync::Job<void> runJob(KJob *job) |
45 | { | 62 | { |
46 | return KAsync::start<void>([job](KAsync::Future<void> &future) { | 63 | return KAsync::start<void>([job](KAsync::Future<void> &future) { |
@@ -76,7 +93,21 @@ KAsync::Job<void> ImapServerProxy::login(const QString &username, const QString | |||
76 | loginJob->setPassword(password); | 93 | loginJob->setPassword(password); |
77 | loginJob->setAuthenticationMode(KIMAP::LoginJob::Plain); | 94 | loginJob->setAuthenticationMode(KIMAP::LoginJob::Plain); |
78 | loginJob->setEncryptionMode(KIMAP::LoginJob::EncryptionMode::AnySslVersion); | 95 | loginJob->setEncryptionMode(KIMAP::LoginJob::EncryptionMode::AnySslVersion); |
79 | return runJob(loginJob); | 96 | |
97 | auto capabilitiesJob = new KIMAP::CapabilitiesJob(mSession); | ||
98 | QObject::connect(capabilitiesJob, &KIMAP::CapabilitiesJob::capabilitiesReceived, [this](const QStringList &capabilities) { | ||
99 | mCapabilities = capabilities; | ||
100 | }); | ||
101 | return runJob(loginJob).then(runJob(capabilitiesJob)).then<void>([this](){ | ||
102 | Trace() << "Supported capabilities: " << mCapabilities; | ||
103 | QStringList requiredExtensions = QStringList() << "UIDPLUS"; | ||
104 | for (const auto &requiredExtension : requiredExtensions) { | ||
105 | if (!mCapabilities.contains(requiredExtension)) { | ||
106 | Warning() << "Server doesn't support required capability: " << requiredExtension; | ||
107 | //TODO fail the job | ||
108 | } | ||
109 | } | ||
110 | }); | ||
80 | } | 111 | } |
81 | 112 | ||
82 | KAsync::Job<void> ImapServerProxy::select(const QString &mailbox) | 113 | KAsync::Job<void> ImapServerProxy::select(const QString &mailbox) |
@@ -87,14 +118,16 @@ KAsync::Job<void> ImapServerProxy::select(const QString &mailbox) | |||
87 | return runJob(select); | 118 | return runJob(select); |
88 | } | 119 | } |
89 | 120 | ||
90 | KAsync::Job<void> ImapServerProxy::append(const QString &mailbox, const QByteArray &content, const QList<QByteArray> &flags, const QDateTime &internalDate) | 121 | KAsync::Job<qint64> ImapServerProxy::append(const QString &mailbox, const QByteArray &content, const QList<QByteArray> &flags, const QDateTime &internalDate) |
91 | { | 122 | { |
92 | auto append = new KIMAP::AppendJob(mSession); | 123 | auto append = new KIMAP::AppendJob(mSession); |
93 | append->setMailBox(mailbox); | 124 | append->setMailBox(mailbox); |
94 | append->setContent(content); | 125 | append->setContent(content); |
95 | append->setFlags(flags); | 126 | append->setFlags(flags); |
96 | append->setInternalDate(internalDate); | 127 | append->setInternalDate(internalDate); |
97 | return runJob(append); | 128 | return runJob<qint64>(append, [](KJob *job) -> qint64{ |
129 | return static_cast<KIMAP::AppendJob*>(job)->uid(); | ||
130 | }); | ||
98 | } | 131 | } |
99 | 132 | ||
100 | KAsync::Job<void> ImapServerProxy::store(const KIMAP::ImapSet &set, const QList<QByteArray> &flags) | 133 | KAsync::Job<void> ImapServerProxy::store(const KIMAP::ImapSet &set, const QList<QByteArray> &flags) |
@@ -135,6 +168,13 @@ KAsync::Job<void> ImapServerProxy::expunge() | |||
135 | return runJob(job); | 168 | return runJob(job); |
136 | } | 169 | } |
137 | 170 | ||
171 | KAsync::Job<void> ImapServerProxy::expunge(const KIMAP::ImapSet &set) | ||
172 | { | ||
173 | //FIXME implement UID EXPUNGE | ||
174 | auto job = new KIMAP::ExpungeJob(mSession); | ||
175 | return runJob(job); | ||
176 | } | ||
177 | |||
138 | KAsync::Job<void> ImapServerProxy::fetch(const KIMAP::ImapSet &set, KIMAP::FetchJob::FetchScope scope, FetchCallback callback) | 178 | KAsync::Job<void> ImapServerProxy::fetch(const KIMAP::ImapSet &set, KIMAP::FetchJob::FetchScope scope, FetchCallback callback) |
139 | { | 179 | { |
140 | auto fetch = new KIMAP::FetchJob(mSession); | 180 | auto fetch = new KIMAP::FetchJob(mSession); |
@@ -219,10 +259,15 @@ KAsync::Job<void> ImapServerProxy::list(KIMAP::ListJob::Option option, const std | |||
219 | return runJob(listJob); | 259 | return runJob(listJob); |
220 | } | 260 | } |
221 | 261 | ||
262 | KAsync::Job<void> ImapServerProxy::remove(const QString &mailbox, const KIMAP::ImapSet &set) | ||
263 | { | ||
264 | return select(mailbox).then<void>(store(set, QByteArrayList() << Flags::Deleted)).then<void>(expunge(set)); | ||
265 | } | ||
266 | |||
222 | KAsync::Job<void> ImapServerProxy::remove(const QString &mailbox, const QByteArray &imapSet) | 267 | KAsync::Job<void> ImapServerProxy::remove(const QString &mailbox, const QByteArray &imapSet) |
223 | { | 268 | { |
224 | const auto set = KIMAP::ImapSet::fromImapSequenceSet(imapSet); | 269 | const auto set = KIMAP::ImapSet::fromImapSequenceSet(imapSet); |
225 | return select(mailbox).then<void>(store(set, QByteArrayList() << Flags::Deleted)).then<void>(expunge()); | 270 | return remove(mailbox, set); |
226 | } | 271 | } |
227 | 272 | ||
228 | KAsync::Job<void> ImapServerProxy::fetchFolders(std::function<void(const QVector<Folder> &)> callback) | 273 | KAsync::Job<void> ImapServerProxy::fetchFolders(std::function<void(const QVector<Folder> &)> callback) |
diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h index cf315df..3afeee5 100644 --- a/examples/imapresource/imapserverproxy.h +++ b/examples/imapresource/imapserverproxy.h | |||
@@ -60,18 +60,20 @@ struct Folder { | |||
60 | class ImapServerProxy { | 60 | class ImapServerProxy { |
61 | KIMAP::Session *mSession; | 61 | KIMAP::Session *mSession; |
62 | QChar mSeparatorCharacter; | 62 | QChar mSeparatorCharacter; |
63 | QStringList mCapabilities; | ||
63 | public: | 64 | public: |
64 | ImapServerProxy(const QString &serverUrl, int port); | 65 | ImapServerProxy(const QString &serverUrl, int port); |
65 | 66 | ||
66 | //Standard IMAP calls | 67 | //Standard IMAP calls |
67 | KAsync::Job<void> login(const QString &username, const QString &password); | 68 | KAsync::Job<void> login(const QString &username, const QString &password); |
68 | KAsync::Job<void> select(const QString &mailbox); | 69 | KAsync::Job<void> select(const QString &mailbox); |
69 | KAsync::Job<void> append(const QString &mailbox, const QByteArray &content, const QList<QByteArray> &flags = QList<QByteArray>(), const QDateTime &internalDate = QDateTime()); | 70 | KAsync::Job<qint64> append(const QString &mailbox, const QByteArray &content, const QList<QByteArray> &flags = QList<QByteArray>(), const QDateTime &internalDate = QDateTime()); |
70 | KAsync::Job<void> store(const KIMAP::ImapSet &set, const QList<QByteArray> &flags); | 71 | KAsync::Job<void> store(const KIMAP::ImapSet &set, const QList<QByteArray> &flags); |
71 | KAsync::Job<void> create(const QString &mailbox); | 72 | KAsync::Job<void> create(const QString &mailbox); |
72 | KAsync::Job<void> rename(const QString &mailbox, const QString &newMailbox); | 73 | KAsync::Job<void> rename(const QString &mailbox, const QString &newMailbox); |
73 | KAsync::Job<void> remove(const QString &mailbox); | 74 | KAsync::Job<void> remove(const QString &mailbox); |
74 | KAsync::Job<void> expunge(); | 75 | KAsync::Job<void> expunge(); |
76 | KAsync::Job<void> expunge(const KIMAP::ImapSet &set); | ||
75 | 77 | ||
76 | typedef std::function<void(const QString &, | 78 | typedef std::function<void(const QString &, |
77 | const QMap<qint64,qint64> &, | 79 | const QMap<qint64,qint64> &, |
@@ -86,6 +88,7 @@ public: | |||
86 | 88 | ||
87 | //Composed calls that do login etc. | 89 | //Composed calls that do login etc. |
88 | KAsync::Job<QList<qint64>> fetchHeaders(const QString &mailbox); | 90 | KAsync::Job<QList<qint64>> fetchHeaders(const QString &mailbox); |
91 | KAsync::Job<void> remove(const QString &mailbox, const KIMAP::ImapSet &set); | ||
89 | KAsync::Job<void> remove(const QString &mailbox, const QByteArray &imapSet); | 92 | KAsync::Job<void> remove(const QString &mailbox, const QByteArray &imapSet); |
90 | 93 | ||
91 | KAsync::Job<void> fetchFolders(std::function<void(const QVector<Folder> &)> callback); | 94 | KAsync::Job<void> fetchFolders(std::function<void(const QVector<Folder> &)> callback); |
diff --git a/tests/mailtest.cpp b/tests/mailtest.cpp index 39a4128..912bb1c 100644 --- a/tests/mailtest.cpp +++ b/tests/mailtest.cpp | |||
@@ -171,7 +171,9 @@ void MailTest::testCreateModifyDeleteMail() | |||
171 | VERIFYEXEC(job); | 171 | VERIFYEXEC(job); |
172 | } | 172 | } |
173 | 173 | ||
174 | VERIFYEXEC(ResourceControl::flushReplayQueue(QByteArrayList() << mResourceInstanceIdentifier)); | ||
174 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Mail>(ResourceControl::Inspection::ExistenceInspection(mail, true))); | 175 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Mail>(ResourceControl::Inspection::ExistenceInspection(mail, true))); |
176 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Mail>(ResourceControl::Inspection::PropertyInspection(mail, Mail::Subject::name, subject))); | ||
175 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Folder>(ResourceControl::Inspection::CacheIntegrityInspection(folder))); | 177 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Folder>(ResourceControl::Inspection::CacheIntegrityInspection(folder))); |
176 | 178 | ||
177 | const auto subject2 = QString::fromLatin1("Foobar2"); | 179 | const auto subject2 = QString::fromLatin1("Foobar2"); |
@@ -197,7 +199,9 @@ void MailTest::testCreateModifyDeleteMail() | |||
197 | }); | 199 | }); |
198 | VERIFYEXEC(job); | 200 | VERIFYEXEC(job); |
199 | } | 201 | } |
202 | VERIFYEXEC(ResourceControl::flushReplayQueue(QByteArrayList() << mResourceInstanceIdentifier)); | ||
200 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Mail>(ResourceControl::Inspection::ExistenceInspection(mail, true))); | 203 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Mail>(ResourceControl::Inspection::ExistenceInspection(mail, true))); |
204 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Mail>(ResourceControl::Inspection::PropertyInspection(mail, Mail::Subject::name, subject2))); | ||
201 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Folder>(ResourceControl::Inspection::CacheIntegrityInspection(folder))); | 205 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Folder>(ResourceControl::Inspection::CacheIntegrityInspection(folder))); |
202 | 206 | ||
203 | VERIFYEXEC(Store::remove(mail)); | 207 | VERIFYEXEC(Store::remove(mail)); |
@@ -209,7 +213,8 @@ void MailTest::testCreateModifyDeleteMail() | |||
209 | }); | 213 | }); |
210 | VERIFYEXEC(job); | 214 | VERIFYEXEC(job); |
211 | } | 215 | } |
212 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Mail>(ResourceControl::Inspection::ExistenceInspection(mail, false))); | 216 | VERIFYEXEC(ResourceControl::flushReplayQueue(QByteArrayList() << mResourceInstanceIdentifier)); |
217 | // VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Mail>(ResourceControl::Inspection::ExistenceInspection(mail, false))); | ||
213 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Folder>(ResourceControl::Inspection::CacheIntegrityInspection(folder))); | 218 | VERIFYEXEC(ResourceControl::inspect<ApplicationDomain::Folder>(ResourceControl::Inspection::CacheIntegrityInspection(folder))); |
214 | } | 219 | } |
215 | 220 | ||