diff options
Diffstat (limited to 'framework/src/domain/mime/mailtemplates.cpp')
-rw-r--r-- | framework/src/domain/mime/mailtemplates.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/framework/src/domain/mime/mailtemplates.cpp b/framework/src/domain/mime/mailtemplates.cpp index 9af15e91..8e644b34 100644 --- a/framework/src/domain/mime/mailtemplates.cpp +++ b/framework/src/domain/mime/mailtemplates.cpp | |||
@@ -864,6 +864,34 @@ void MailTemplates::reply(const KMime::Message::Ptr &origMsg, const std::functio | |||
864 | }); | 864 | }); |
865 | } | 865 | } |
866 | 866 | ||
867 | void MailTemplates::forward(const KMime::Message::Ptr &origMsg, const std::function<void(const KMime::Message::Ptr &result)> &callback) | ||
868 | { | ||
869 | KMime::Message::Ptr wrapperMsg(new KMime::Message); | ||
870 | |||
871 | wrapperMsg->to()->clear(); | ||
872 | wrapperMsg->cc()->clear(); | ||
873 | |||
874 | wrapperMsg->subject()->fromUnicodeString(forwardSubject(origMsg->subject()->asUnicodeString()), "utf-8"); | ||
875 | |||
876 | const QByteArray refStr = getRefStr(origMsg); | ||
877 | if (!refStr.isEmpty()) { | ||
878 | wrapperMsg->references()->fromUnicodeString(QString::fromLocal8Bit(refStr), "utf-8"); | ||
879 | } | ||
880 | |||
881 | KMime::Content* fwdAttachment = new KMime::Content; | ||
882 | |||
883 | fwdAttachment->contentDisposition()->setDisposition(KMime::Headers::CDinline); | ||
884 | fwdAttachment->contentType()->setMimeType("message/rfc822"); | ||
885 | fwdAttachment->contentDisposition()->setFilename(origMsg->subject()->asUnicodeString() + ".eml"); | ||
886 | // The mail was parsed in loadMessage before, so no need to assemble it | ||
887 | fwdAttachment->setBody(origMsg->encodedContent()); | ||
888 | |||
889 | wrapperMsg->addContent(fwdAttachment); | ||
890 | wrapperMsg->assemble(); | ||
891 | |||
892 | callback(wrapperMsg); | ||
893 | } | ||
894 | |||
867 | QString MailTemplates::plaintextContent(const KMime::Message::Ptr &msg) | 895 | QString MailTemplates::plaintextContent(const KMime::Message::Ptr &msg) |
868 | { | 896 | { |
869 | MimeTreeParser::ObjectTreeParser otp; | 897 | MimeTreeParser::ObjectTreeParser otp; |
@@ -899,10 +927,14 @@ static KMime::Content *createAttachmentPart(const QByteArray &content, const QSt | |||
899 | } else { | 927 | } else { |
900 | part->contentDisposition(true)->setDisposition(KMime::Headers::CDattachment); | 928 | part->contentDisposition(true)->setDisposition(KMime::Headers::CDattachment); |
901 | } | 929 | } |
930 | |||
902 | part->contentType(true)->setMimeType(mimeType); | 931 | part->contentType(true)->setMimeType(mimeType); |
903 | part->contentType(true)->setName(name, "utf-8"); | 932 | part->contentType(true)->setName(name, "utf-8"); |
904 | //Just always encode attachments base64 so it's safe for binary data | 933 | // Just always encode attachments base64 so it's safe for binary data, |
905 | part->contentTransferEncoding(true)->setEncoding(KMime::Headers::CEbase64); | 934 | // except when it's another message |
935 | if(mimeType != "message/rfc822") { | ||
936 | part->contentTransferEncoding(true)->setEncoding(KMime::Headers::CEbase64); | ||
937 | } | ||
906 | part->setBody(content); | 938 | part->setBody(content); |
907 | return part; | 939 | return part; |
908 | } | 940 | } |