Version: 1.4.80 (using Devel) OS: Linux When you read an email that was PGP-signed, the message isn't marked as seen/read on the server. It seems that the Exchange server doesn't like the $SIGNED flag and ignores the entire command. Fetching it: C: A000006 FETCH 9 (RFC822.SIZE INTERNALDATE BODY.PEEK[] FLAGS UID) [contents] FLAGS () UID 30051 ) S: A000006 OK FETCH completed. After I browse over it in KMail2: C: A000542 UID STORE 30051 FLAGS (\Seen $SIGNED) S: A000542 BAD Command Argument Error. 11 If I use the web interface, I can confirm that the email was still unread. The flag is kept after moving the email: C: A000543 UID COPY 30051 "INBOX/processed" S: A000543 OK COPY completed. ... C: A000548 SELECT "INBOX/processed" ... C: A000549 FETCH 1 (FLAGS UID) S: * 1 FETCH ( FLAGS () UID 8551 ) S: A000549 OK FETCH completed. Reproducible: Always OS: Linux (i686) release 2.6.35.2-server-1mnb Compiler: gcc
From a quick research indeed Exchange doesn't support custom flags. :( So we need: 1) to detect if the server we are talking to supports it or not, and if not clean the FLAGS arguments from custom flags 2) store the flags inside the mail as well, in custom headers
It gets a bit worse, since KMail also uses a few other marks. That means a replied-to message can never be marked unread again.
commit e6d4e256d84e170c25cdd833d69bd2d7339bc256 branch master Author: Volker Krause <vkrause@kde.org> Date: Tue Dec 28 12:43:19 2010 +0100 Do not try to write flags to the server that it does not support. Can happen even with servers that do support arbitrary flags, but where you lack access rights to change them in a specific folder. BUG: 259160 diff --git a/resources/imap/changeitemtask.cpp b/resources/imap/changeitemtask.cpp index 3ababf2..c1b4b73 100644 --- a/resources/imap/changeitemtask.cpp +++ b/resources/imap/changeitemtask.cpp @@ -34,6 +34,7 @@ #include "imapflags.h" #include "uidnextattribute.h" +#include "collectionflagsattribute.h" ChangeItemTask::ChangeItemTask( ResourceStateInterface::Ptr resource, QObject *parent ) : ResourceTask( DeferIfNoSession, resource, parent ), m_session( 0 ), m_oldUid( 0 ), m_newUid( 0 ) @@ -104,11 +105,25 @@ void ChangeItemTask::onPreStoreSelectDone( KJob *job ) void ChangeItemTask::triggerStoreJob() { + QList<QByteArray> flags = fromAkonadiFlags( item().flags().toList() ); + Akonadi::CollectionFlagsAttribute *flagAttr = item().parentCollection().attribute<Akonadi::CollectionFlagsAttribute>(); + // the server does not support arbitrary flags, so filter out those it can't handle + if ( flagAttr && !flagAttr->flags().isEmpty() && !flagAttr->flags().contains( "\\*" ) ) { + for ( QList< QByteArray >::iterator it = flags.begin(); it != flags.end(); ) { + if ( flagAttr->flags().contains( *it ) ) { + ++it; + } else { + kDebug() << "Server does not support flag" << *it; + it = flags.erase( it ); + } + } + } + KIMAP::StoreJob *store = new KIMAP::StoreJob( m_session ); store->setUidBased( true ); store->setSequenceSet( KIMAP::ImapSet( m_oldUid ) ); - store->setFlags( fromAkonadiFlags( item().flags().toList() ) ); + store->setFlags( flags ); store->setMode( KIMAP::StoreJob::SetFlags ); connect( store, SIGNAL( result( KJob* ) ), diff --git a/resources/imap/retrieveitemstask.cpp b/resources/imap/retrieveitemstask.cpp index 86917ec..196bba5 100644 --- a/resources/imap/retrieveitemstask.cpp +++ b/resources/imap/retrieveitemstask.cpp @@ -148,7 +148,7 @@ void RetrieveItemsTask::onFinalSelectDone( KJob *job ) const int messageCount = select->messageCount(); const qint64 uidValidity = select->uidValidity(); const qint64 nextUid = select->nextUid(); - const QList<QByteArray> flags = select->flags(); + const QList<QByteArray> flags = select->permanentFlags(); // uidvalidity can change between sessions, we don't want to refetch // folders in that case. Keep track of what is processed and what not.
Fix confirmed.