diff options
-rw-r--r-- | examples/maildirresource/libmaildir/maildir.cpp | 2 | ||||
-rw-r--r-- | examples/maildirresource/libmaildir/maildir.h | 2 | ||||
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 18 | ||||
-rw-r--r-- | tests/maildirresourcetest.cpp | 16 |
4 files changed, 32 insertions, 6 deletions
diff --git a/examples/maildirresource/libmaildir/maildir.cpp b/examples/maildirresource/libmaildir/maildir.cpp index 94363b8..28cf46e 100644 --- a/examples/maildirresource/libmaildir/maildir.cpp +++ b/examples/maildirresource/libmaildir/maildir.cpp | |||
@@ -770,7 +770,7 @@ bool Maildir::removeEntry(const QString& key) | |||
770 | // return newUniqueKey; | 770 | // return newUniqueKey; |
771 | // } | 771 | // } |
772 | // | 772 | // |
773 | Maildir::Flags Maildir::readEntryFlags(const QString& key) const | 773 | Maildir::Flags Maildir::readEntryFlags(const QString& key) |
774 | { | 774 | { |
775 | Flags flags; | 775 | Flags flags; |
776 | const QRegExp rx = *(statusSeparatorRx()); | 776 | const QRegExp rx = *(statusSeparatorRx()); |
diff --git a/examples/maildirresource/libmaildir/maildir.h b/examples/maildirresource/libmaildir/maildir.h index f80ba5d..fefd5a7 100644 --- a/examples/maildirresource/libmaildir/maildir.h +++ b/examples/maildirresource/libmaildir/maildir.h | |||
@@ -178,7 +178,7 @@ public: | |||
178 | /** | 178 | /** |
179 | * Return the flags encoded in the maildir file name for an entry | 179 | * Return the flags encoded in the maildir file name for an entry |
180 | **/ | 180 | **/ |
181 | Flags readEntryFlags( const QString& key ) const; | 181 | static Flags readEntryFlags( const QString& key ); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | * Return the contents of the headers section of the file the maildir with the given @p file, that | 184 | * Return the contents of the headers section of the file the maildir with the given @p file, that |
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 3531b92..5d540be 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -295,7 +295,25 @@ void MaildirResource::removeFromDisk(const QByteArray &instanceIdentifier) | |||
295 | 295 | ||
296 | KAsync::Job<void> MaildirResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) | 296 | KAsync::Job<void> MaildirResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) |
297 | { | 297 | { |
298 | auto synchronizationStore = QSharedPointer<Akonadi2::Storage>::create(Akonadi2::storageLocation(), mResourceInstanceIdentifier + ".synchronization", Akonadi2::Storage::ReadOnly); | ||
299 | auto synchronizationTransaction = synchronizationStore->createTransaction(Akonadi2::Storage::ReadOnly); | ||
298 | Trace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; | 300 | Trace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; |
301 | if (domainType == ENTITY_TYPE_MAIL) { | ||
302 | if (inspectionType == Akonadi2::Resources::Inspection::PropertyInspectionType) { | ||
303 | if (property == "unread") { | ||
304 | const auto remoteId = resolveLocalId(ENTITY_TYPE_MAIL, entityId, synchronizationTransaction); | ||
305 | const auto flags = KPIM::Maildir::readEntryFlags(remoteId.split('/').last()); | ||
306 | if (expectedValue.toBool() && !(flags & KPIM::Maildir::Seen)) { | ||
307 | return KAsync::error<void>(1, "Expected seen but couldn't find it."); | ||
308 | } | ||
309 | if (!expectedValue.toBool() && (flags & KPIM::Maildir::Seen)) { | ||
310 | return KAsync::error<void>(1, "Expected seen but couldn't find it."); | ||
311 | } | ||
312 | return KAsync::null<void>(); | ||
313 | } | ||
314 | } | ||
315 | } | ||
316 | return KAsync::null<void>(); | ||
299 | } | 317 | } |
300 | 318 | ||
301 | MaildirResourceFactory::MaildirResourceFactory(QObject *parent) | 319 | MaildirResourceFactory::MaildirResourceFactory(QObject *parent) |
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index c649536..046c920 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -353,14 +353,22 @@ private Q_SLOTS: | |||
353 | return Akonadi2::Store::modify(*mail); | 353 | return Akonadi2::Store::modify(*mail); |
354 | }) | 354 | }) |
355 | .then<void>(Akonadi2::Store::flushMessageQueue(query.resources)) | 355 | .then<void>(Akonadi2::Store::flushMessageQueue(query.resources)) |
356 | .then<void, KAsync::Job<void> >([folder]() -> KAsync::Job<void> { | 356 | .then<void, KAsync::Job<void> >([folder]() { |
357 | return Store::fetchAll<Mail>( | 357 | return Store::fetchAll<Mail>( |
358 | Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject" << "unread") | 358 | Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject" << "unread") |
359 | ) | 359 | ) |
360 | .then<void, QList<Mail::Ptr> >([](const QList<Mail::Ptr> &mails) { | 360 | .then<void, KAsync::Job<void>, QList<Mail::Ptr>>([](const QList<Mail::Ptr> &mails) { |
361 | QCOMPARE(mails.size(), 1); | 361 | //Can't use QCOMPARE because it tries to return |
362 | if (mails.size() != 1) { | ||
363 | return KAsync::error<void>(1, "Wrong number of mails."); | ||
364 | } | ||
362 | auto mail = mails.first(); | 365 | auto mail = mails.first(); |
363 | QCOMPARE(mail->getProperty("unread").toBool(), true); | 366 | //Can't use QCOMPARE because it tries to return |
367 | if (mail->getProperty("unread").toBool() != true) { | ||
368 | return KAsync::error<void>(1, "Wrong property value."); | ||
369 | } | ||
370 | auto inspectionCommand = Akonadi2::Resources::Inspection::PropertyInspection(*mail, "unread", true); | ||
371 | return Akonadi2::Resources::inspect<Mail>(inspectionCommand); | ||
364 | }) | 372 | }) |
365 | .then<void>([](){}); | 373 | .then<void>([](){}); |
366 | }); | 374 | }); |