From fcadb2787eb14ad88187862f0171c33679f8e54b Mon Sep 17 00:00:00 2001 From: Andre Heinecke <aheinecke@intevation.de> Date: Mon, 23 Nov 2015 18:56:51 +0100 Subject: [PATCH 30/74] Fix forwarding / send again of crypto mails By collecting the attachments from the decrypted node directly we don't iterate over all attachments. This works also for S/MIME where no original attachments are reported for the message. --- messagecomposer/composer/composerviewbase.cpp | 19 +++++++------------ templateparser/templateparser.cpp | 21 +++++++++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/messagecomposer/composer/composerviewbase.cpp b/messagecomposer/composer/composerviewbase.cpp index efc75ef478..f26242771f 100644 --- a/messagecomposer/composer/composerviewbase.cpp +++ b/messagecomposer/composer/composerviewbase.cpp @@ -179,21 +179,16 @@ void MessageComposer::ComposerViewBase::setMessage ( const KMime::Message::Ptr& // Load the attachments MessageCore::AttachmentCollector ac; - ac.collectAttachmentsFrom( msgContent ); + if (otp.nodeHelper()->partMetaData( msgContent ).isEncrypted ) { + ac.collectAttachmentsFrom( otp.nodeHelper()->decryptedNodeForContent( msgContent ) ); + } else { + ac.collectAttachmentsFrom( msgContent ); + } + std::vector<KMime::Content*>::const_iterator end( ac.attachments().end() ); for ( std::vector<KMime::Content*>::const_iterator it = ac.attachments().begin(); it != end ; ++it ) { - if (otp.nodeHelper()->partMetaData((*it)->parent()).isEncrypted) { // gpg mime has a msg.asc as subelement, that is recognized as attachment - MessageCore::AttachmentCollector acEnc; - acEnc.collectAttachmentsFrom(otp.nodeHelper()->decryptedNodeForContent((*it)->parent())); - std::vector<KMime::Content*>::const_iterator endEnc( acEnc.attachments().end() ); - for ( std::vector<KMime::Content*>::const_iterator itEnc = acEnc.attachments().begin(); - itEnc != endEnc ; ++itEnc ) { - addAttachmentPart( *itEnc ); - } - } else { - addAttachmentPart( *it ); - } + addAttachmentPart( *it ); } int transportId = -1; diff --git a/templateparser/templateparser.cpp b/templateparser/templateparser.cpp index 78df3ee7eb..bfca0db0e0 100644 --- a/templateparser/templateparser.cpp +++ b/templateparser/templateparser.cpp @@ -1234,10 +1234,6 @@ QString TemplateParser::getHtmlSignature() const void TemplateParser::addProcessedBodyToMessage( const QString &plainBody, const QString &htmlBody ) const { - // Get the attachments of the original mail - MessageCore::AttachmentCollector ac; - ac.collectAttachmentsFrom( mOrigMsg.get() ); - MessageCore::ImageCollector ic; ic.collectImagesFrom( mOrigMsg.get() ); @@ -1275,11 +1271,20 @@ void TemplateParser::addProcessedBodyToMessage( const QString &plainBody, // If we have some attachments, create a multipart/mixed mail and // add the normal body as well as the attachments KMime::Content *mainPart = textPart; - if ( !ac.attachments().empty() && mMode == Forward ) { - mainPart = createMultipartMixed( ac, textPart ); - mainPart->assemble(); - } + if ( mMode == Forward ) { + // Get the attachments of the original mail + MessageCore::AttachmentCollector ac; + if (mOtp->nodeHelper()->partMetaData( mOrigMsg.get() ).isEncrypted) { + ac.collectAttachmentsFrom( mOtp->nodeHelper()->decryptedNodeForContent( mOrigMsg.get() ) ); + } else { + ac.collectAttachmentsFrom( mOrigMsg.get() ); + } + if (!ac.attachments().empty()) { + mainPart = createMultipartMixed( ac, textPart ); + mainPart->assemble(); + } + } mMsg->setBody( mainPart->encodedBody() ); mMsg->setHeader( mainPart->contentType() ); mMsg->setHeader( mainPart->contentTransferEncoding() ); -- 2.14.1