From 8e0080b0ed1ca804cdb8a6e2846567231022f18d Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Mon, 16 Jan 2006 21:55:37 +0000 Subject: [PATCH] Added support for attachments of type 'message/rfc822'. --- ChangeLog | 4 + SConstruct | 4 +- src/attachmentHelper.cpp | 118 +++++++++++++++++++----- src/generatedMessageAttachment.cpp | 105 ++++++++++++++++++++++ src/parsedMessageAttachment.cpp | 114 ++++++++++++++++++++++++ tests/parser/attachmentHelperTest.cpp | 123 ++++++++++++++++++++++++++ vmime/attachmentHelper.hpp | 7 ++ vmime/bodyPartAttachment.hpp | 6 ++ vmime/generatedMessageAttachment.hpp | 79 +++++++++++++++++ vmime/messageAttachment.hpp | 55 ++++++++++++ vmime/parsedMessageAttachment.hpp | 78 ++++++++++++++++ vmime/vmime.hpp | 1 + 12 files changed, 670 insertions(+), 24 deletions(-) create mode 100644 src/generatedMessageAttachment.cpp create mode 100644 src/parsedMessageAttachment.cpp create mode 100644 vmime/generatedMessageAttachment.hpp create mode 100644 vmime/messageAttachment.hpp create mode 100644 vmime/parsedMessageAttachment.hpp diff --git a/ChangeLog b/ChangeLog index ab5cfb1c..54fe8aa3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ VERSION 0.8.1cvs ================ +2006-01-16 Vincent Richard + + * Added support for attachments of type "message/rfc822". + 2006-01-15 Vincent Richard * IMAP: implemented multi-fetching. Now using "FETCH x:y" instead of diff --git a/SConstruct b/SConstruct index c0747d93..a1d623a2 100644 --- a/SConstruct +++ b/SConstruct @@ -105,6 +105,7 @@ libvmime_sources = [ 'encoding.cpp', 'encoding.hpp', 'exception.cpp', 'exception.hpp', 'fileAttachment.cpp', 'fileAttachment.hpp', + 'generatedMessageAttachment.hpp', 'generatedMessageAttachment.cpp', 'header.cpp', 'header.hpp', 'headerFieldFactory.cpp', 'headerFieldFactory.hpp', 'headerField.cpp', 'headerField.hpp', @@ -115,6 +116,7 @@ libvmime_sources = [ 'mailboxGroup.cpp', 'mailboxGroup.hpp', 'mailboxList.cpp', 'mailboxList.hpp', 'mediaType.cpp', 'mediaType.hpp', + 'messageAttachment.hpp', 'messageBuilder.cpp', 'messageBuilder.hpp', 'message.cpp', 'message.hpp', 'messageId.cpp', 'messageId.hpp', @@ -125,6 +127,7 @@ libvmime_sources = [ 'path.cpp', 'path.hpp', 'parameter.cpp', 'parameter.hpp', 'parameterizedHeaderField.cpp', 'parameterizedHeaderField.hpp', + 'parsedMessageAttachment.cpp', 'parsedMessageAttachment.hpp', 'parserHelpers.hpp', 'plainTextPart.cpp', 'plainTextPart.hpp', 'platformDependant.cpp', 'platformDependant.hpp', @@ -2254,7 +2257,6 @@ env.Alias('msvc', env.GenerateMSVC('foo_msvc', 'SConstruct')) def appendAdditionalDistFiles(): # Generate autotools-related files generateAutotools([], [], env) - # Generate MSVC-related files generateMSVC([], [], env) diff --git a/src/attachmentHelper.cpp b/src/attachmentHelper.cpp index a4970dd0..c1a1f057 100644 --- a/src/attachmentHelper.cpp +++ b/src/attachmentHelper.cpp @@ -24,7 +24,11 @@ #include "vmime/attachmentHelper.hpp" #include "vmime/bodyPartAttachment.hpp" +#include "vmime/parsedMessageAttachment.hpp" +#include "vmime/generatedMessageAttachment.hpp" + #include "vmime/disposition.hpp" +#include "vmime/emptyContentHandler.hpp" namespace vmime @@ -88,7 +92,31 @@ ref if (!isBodyPartAnAttachment(part)) return NULL; - return vmime::create (part); + mediaType type; + + try + { + const contentTypeField& ctf = dynamic_cast + (*part->getHeader()->findField(fields::CONTENT_TYPE)); + + type = *ctf.getValue().dynamicCast (); + } + catch (exceptions::no_such_field&) + { + // No "Content-type" field: assume "application/octet-stream". + type = mediaType(mediaTypes::APPLICATION, + mediaTypes::APPLICATION_OCTET_STREAM); + } + + if (type.getType() == mediaTypes::MESSAGE && + type.getSubType() == mediaTypes::MESSAGE_RFC822) + { + return vmime::create (part); + } + else + { + return vmime::create (part); + } } @@ -144,36 +172,72 @@ void attachmentHelper::addAttachment(ref msg, ref att) if (part == NULL) // create it { - // Create a new container part for the parts that were in - // the root part of the message - ref container = vmime::create (); - - try + if (msg->getBody()->getPartCount() != 0) { - container->getHeader()->ContentType()-> - setValue(msg->getHeader()->ContentType()->getValue()); + // Create a new container part for the parts that were in + // the root part of the message + ref container = vmime::create (); + + try + { + if (msg->getHeader()->hasField(fields::CONTENT_TYPE)) + { + container->getHeader()->ContentType()->setValue + (msg->getHeader()->ContentType()->getValue()); + } + + if (msg->getHeader()->hasField(fields::CONTENT_TRANSFER_ENCODING)) + { + container->getHeader()->ContentTransferEncoding()->setValue + (msg->getHeader()->ContentTransferEncoding()->getValue()); + } + } + catch (exceptions::no_such_field&) + { + // Ignore + } + + // Move parts from the root part to this new part + const std::vector > partList = + msg->getBody()->getPartList(); + + msg->getBody()->removeAllParts(); + + for (unsigned int i = 0 ; i < partList.size() ; ++i) + container->getBody()->appendPart(partList[i]); + + msg->getBody()->appendPart(container); } - catch (exceptions::no_such_field&) + else { - // Ignore + // The message is a simple (RFC-822) message, and do not + // contains any MIME part. Move the contents from the + // root to a new child part. + ref child = vmime::create (); + + if (msg->getHeader()->hasField(fields::CONTENT_TYPE)) + { + child->getHeader()->ContentType()->setValue + (msg->getHeader()->ContentType()->getValue()); + } + + if (msg->getHeader()->hasField(fields::CONTENT_TRANSFER_ENCODING)) + { + child->getHeader()->ContentTransferEncoding()->setValue + (msg->getHeader()->ContentTransferEncoding()->getValue()); + } + + child->getBody()->setContents(msg->getBody()->getContents()); + msg->getBody()->setContents(vmime::create ()); + + msg->getBody()->appendPart(child); } - msg->getHeader()->removeAllFields(vmime::fields::CONTENT_DISPOSITION); - msg->getHeader()->removeAllFields(vmime::fields::CONTENT_TRANSFER_ENCODING); - - // Move parts from the root part to this new part - const std::vector > partList = - msg->getBody()->getPartList(); - - msg->getBody()->removeAllParts(); - - for (unsigned int i = 0 ; i < partList.size() ; ++i) - container->getBody()->appendPart(partList[i]); - // Set the root part to 'multipart/mixed' msg->getHeader()->ContentType()->setValue(mpMixed); - msg->getBody()->appendPart(container); + msg->getHeader()->removeAllFields(vmime::fields::CONTENT_DISPOSITION); + msg->getHeader()->removeAllFields(vmime::fields::CONTENT_TRANSFER_ENCODING); part = msg; } @@ -206,5 +270,13 @@ ref attachmentHelper::findBodyPart } +// static +void attachmentHelper::addAttachment(ref msg, ref amsg) +{ + ref att = vmime::create (amsg); + addAttachment(msg, att); +} + + } // vmime diff --git a/src/generatedMessageAttachment.cpp b/src/generatedMessageAttachment.cpp new file mode 100644 index 00000000..189fca58 --- /dev/null +++ b/src/generatedMessageAttachment.cpp @@ -0,0 +1,105 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002-2005 Vincent Richard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// Linking this library statically or dynamically with other modules is making +// a combined work based on this library. Thus, the terms and conditions of +// the GNU General Public License cover the whole combination. +// + +#include "vmime/generatedMessageAttachment.hpp" + + +namespace vmime +{ + + +generatedMessageAttachment::generatedMessageAttachment(ref part) + : m_bpa(vmime::create (part)) +{ +} + + +const mediaType generatedMessageAttachment::getType() const +{ + return mediaType(mediaTypes::MESSAGE, mediaTypes::MESSAGE_RFC822); +} + + +const text generatedMessageAttachment::getDescription() const +{ + return m_bpa->getDescription(); +} + + +const word generatedMessageAttachment::getName() const +{ + return m_bpa->getName(); +} + + +const ref generatedMessageAttachment::getData() const +{ + return m_bpa->getData(); +} + + +const encoding generatedMessageAttachment::getEncoding() const +{ + return m_bpa->getEncoding(); +} + + +ref generatedMessageAttachment::getPart() const +{ + return m_bpa->getPart(); +} + + +ref generatedMessageAttachment::getHeader() const +{ + return m_bpa->getHeader(); +} + + +ref generatedMessageAttachment::getMessage() const +{ + if (m_msg == NULL) + { + // Extract data + std::ostringstream oss; + utility::outputStreamAdapter os(oss); + + getData()->extract(os); + + // Parse message + m_msg = vmime::create (); + m_msg->parse(oss.str()); + } + + return m_msg; +} + + +void generatedMessageAttachment::generateIn(bodyPart& /* parent */) const +{ + // Not used (see 'parsedMessageAttachment') +} + + +} // vmime + diff --git a/src/parsedMessageAttachment.cpp b/src/parsedMessageAttachment.cpp new file mode 100644 index 00000000..9153a239 --- /dev/null +++ b/src/parsedMessageAttachment.cpp @@ -0,0 +1,114 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002-2005 Vincent Richard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// Linking this library statically or dynamically with other modules is making +// a combined work based on this library. Thus, the terms and conditions of +// the GNU General Public License cover the whole combination. +// + +#include "vmime/parsedMessageAttachment.hpp" + +#include "vmime/stringContentHandler.hpp" +#include "vmime/contentDisposition.hpp" + + +namespace vmime +{ + + +parsedMessageAttachment::parsedMessageAttachment(ref msg) + : m_msg(msg) +{ +} + + +const mediaType parsedMessageAttachment::getType() const +{ + return mediaType(mediaTypes::MESSAGE, mediaTypes::MESSAGE_RFC822); +} + + +const text parsedMessageAttachment::getDescription() const +{ + return text(); +} + + +const word parsedMessageAttachment::getName() const +{ + return word(); +} + + +const ref parsedMessageAttachment::getData() const +{ + if (m_data == NULL) + { + std::ostringstream oss; + utility::outputStreamAdapter os(oss); + + m_msg->generate(os); + + m_data = vmime::create (oss.str()); + } + + return m_data; +} + + +const encoding parsedMessageAttachment::getEncoding() const +{ + return encoding(encodingTypes::EIGHT_BIT); // not important +} + + +ref parsedMessageAttachment::getPart() const +{ + return NULL; +} + + +ref parsedMessageAttachment::getHeader() const +{ + return NULL; +} + + +ref parsedMessageAttachment::getMessage() const +{ + return m_msg; +} + + +void parsedMessageAttachment::generateIn(bodyPart& parent) const +{ + // Create and append a new part for this attachment + ref part = vmime::create (); + parent.getBody()->appendPart(part); + + // Set header fields + part->getHeader()->ContentType()->setValue(getType()); + part->getHeader()->ContentDisposition()->setValue(contentDisposition(contentDispositionTypes::ATTACHMENT)); + + // Set contents + part->getBody()->setContents(getData()); +} + + +} // vmime + diff --git a/tests/parser/attachmentHelperTest.cpp b/tests/parser/attachmentHelperTest.cpp index 5a62574c..c3550f48 100644 --- a/tests/parser/attachmentHelperTest.cpp +++ b/tests/parser/attachmentHelperTest.cpp @@ -33,10 +33,13 @@ VMIME_TEST_SUITE_BEGIN VMIME_TEST_LIST_BEGIN VMIME_TEST(testAddAttachment1) VMIME_TEST(testAddAttachment2) + VMIME_TEST(testAddAttachment3) VMIME_TEST(testIsBodyPartAnAttachment1) VMIME_TEST(testIsBodyPartAnAttachment2) VMIME_TEST(testIsBodyPartAnAttachment3) VMIME_TEST(testGetBodyPartAttachment) + VMIME_TEST(testAddAttachmentMessage1) + VMIME_TEST(testGetBodyPartAttachmentMessage) VMIME_TEST_LIST_END @@ -64,6 +67,18 @@ VMIME_TEST_SUITE_BEGIN return res + "]"; } + static const vmime::string extractBodyContents(vmime::ref part) + { + vmime::ref cth = part->getBody()->getContents(); + + vmime::string data; + vmime::utility::outputStreamStringAdapter os(data); + + cth->extract(os); + + return data; + } + void testAddAttachment1() { vmime::string data = @@ -82,6 +97,7 @@ VMIME_TEST_SUITE_BEGIN vmime::attachmentHelper::addAttachment(msg, att); VASSERT_EQ("1", "multipart/mixed[text/plain,image/jpeg]", getStructure(msg)); + VASSERT_EQ("2", "The text\r\n", extractBodyContents(msg->getBody()->getPartAt(0))); } void testAddAttachment2() @@ -110,6 +126,31 @@ VMIME_TEST_SUITE_BEGIN vmime::attachmentHelper::addAttachment(msg, att); VASSERT_EQ("1", "multipart/mixed[text/plain,application/octet-stream,image/jpeg]", getStructure(msg)); + VASSERT_EQ("2", "The text", extractBodyContents(msg->getBody()->getPartAt(0))); + VASSERT_EQ("3", "Blah", extractBodyContents(msg->getBody()->getPartAt(1))); + VASSERT_EQ("4", "test", extractBodyContents(msg->getBody()->getPartAt(2))); + } + + // Initial part is encoded + void testAddAttachment3() + { + vmime::string data = +"Content-Type: text/plain\r\n" +"Content-Transfer-Encoding: base64\r\n" +"\r\n" +"TWVzc2FnZSBib2R5"; + + vmime::ref msg = vmime::create (); + msg->parse(data); + + vmime::ref att = vmime::create + (vmime::create ("test"), + vmime::mediaType("image/jpeg")); + + vmime::attachmentHelper::addAttachment(msg, att); + + VASSERT_EQ("1", "multipart/mixed[text/plain,image/jpeg]", getStructure(msg)); + VASSERT_EQ("2", "Message body", extractBodyContents(msg->getBody()->getPartAt(0))); } // Content-Disposition: attachment @@ -201,5 +242,87 @@ VMIME_TEST_SUITE_BEGIN VASSERT_EQ("7", part->getHeader()->generate(), att->getHeader()->generate()); } + void testAddAttachmentMessage1() + { + const vmime::string data = +"Subject: Test message\r\n" +"Content-Type: text/plain\r\n" +"\r\n" +"Message body"; + + vmime::ref msg = vmime::create (); + msg->parse(data); + + const vmime::string attData = +"Subject: Attached message\r\n" +"Content-Type: text/plain\r\n" +"Content-Transfer-Encoding: base64\r\n" +"\r\n" +"QXR0YWNoZWQgbWVzc2FnZSBib2R5"; + + vmime::ref amsg = vmime::create (); + amsg->parse(attData); + + vmime::attachmentHelper::addAttachment(msg, amsg); + + VASSERT_EQ("1", "multipart/mixed[text/plain,message/rfc822]", getStructure(msg)); + VASSERT_EQ("2", "Message body", extractBodyContents(msg->getBody()->getPartAt(0))); + + // Ensure message has been encoded properly + vmime::ref attPart = msg->getBody()->getPartAt(1); + vmime::ref attCth = attPart->getBody()->getContents(); + + vmime::string attDataOut; + vmime::utility::outputStreamStringAdapter attDataOutOs(attDataOut); + + attCth->extract(attDataOutOs); + + vmime::ref amsgOut = vmime::create (); + amsgOut->parse(attDataOut); + + vmime::ref hdr = amsgOut->getHeader(); + + VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue().dynamicCast ()->generate()); + VASSERT_EQ("4", "Attached message body", extractBodyContents(amsgOut)); + } + + void testGetBodyPartAttachmentMessage() + { + const vmime::string data = +"Subject: Test message\r\n" +"Content-Type: multipart/mixed; boundary=\"foo\"\r\n" +"\r\n" +"--foo\r\n" +"Content-Type: message/rfc822\r\n" +"\r\n" +"Subject: Attached message\r\n" +"\r\n" +"Attached message body\r\n" +"--foo\r\n" +"Content-Type: text/plain\r\n" +"\r\n" +"FooBar\r\n" +"--foo--\r\n"; + + vmime::ref msg = vmime::create (); + msg->parse(data); + + vmime::ref att = vmime::attachmentHelper:: + getBodyPartAttachment(msg->getBody()->getPartAt(0)); + + VASSERT("1", att != NULL); + + vmime::ref msgAtt = + att.dynamicCast (); + + VASSERT("2", msgAtt != NULL); + + vmime::ref amsg = msgAtt->getMessage(); + vmime::ref hdr = amsg->getHeader(); + + VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue().dynamicCast ()->generate()); + VASSERT_EQ("4", "Attached message body", extractBodyContents(amsg)); + } + VMIME_TEST_SUITE_END diff --git a/vmime/attachmentHelper.hpp b/vmime/attachmentHelper.hpp index 0e8d81d8..6f622a6d 100644 --- a/vmime/attachmentHelper.hpp +++ b/vmime/attachmentHelper.hpp @@ -78,6 +78,13 @@ public: */ static void addAttachment(ref msg, ref att); + /** Add a message attachment to the specified message. + * + * @param msg message into which to add the attachment + * @param amsg message to attach + */ + static void addAttachment(ref msg, ref amsg); + protected: static const std::vector > diff --git a/vmime/bodyPartAttachment.hpp b/vmime/bodyPartAttachment.hpp index 7ac1914e..24e51423 100644 --- a/vmime/bodyPartAttachment.hpp +++ b/vmime/bodyPartAttachment.hpp @@ -25,6 +25,9 @@ #define VMIME_BODYPARTATTACHMENT_HPP_INCLUDED +#ifndef VMIME_BUILDING_DOC // implementation detail + + #include "vmime/attachment.hpp" #include "vmime/contentDispositionField.hpp" @@ -72,5 +75,8 @@ private: } // vmime +#endif // VMIME_BUILDING_DOC + + #endif // VMIME_BODYPARTATTACHMENT_HPP_INCLUDED diff --git a/vmime/generatedMessageAttachment.hpp b/vmime/generatedMessageAttachment.hpp new file mode 100644 index 00000000..814340ca --- /dev/null +++ b/vmime/generatedMessageAttachment.hpp @@ -0,0 +1,79 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002-2005 Vincent Richard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// Linking this library statically or dynamically with other modules is making +// a combined work based on this library. Thus, the terms and conditions of +// the GNU General Public License cover the whole combination. +// + +#ifndef VMIME_GENERATEDMESSAGEATTACHMENT_HPP_INCLUDED +#define VMIME_GENERATEDMESSAGEATTACHMENT_HPP_INCLUDED + + +#ifndef VMIME_BUILDING_DOC // implementation detail + + +#include "vmime/messageAttachment.hpp" +#include "vmime/bodyPartAttachment.hpp" + + +namespace vmime +{ + + +/** A message attachment that can be extracted from a message. + */ +class generatedMessageAttachment : public messageAttachment +{ +public: + + generatedMessageAttachment(ref part); + + const mediaType getType() const; + const text getDescription() const; + const word getName() const; + + const ref getData() const; + + const encoding getEncoding() const; + + ref getPart() const; + + ref getHeader() const; + + ref getMessage() const; + +protected: + + void generateIn(bodyPart& parent) const; + +private: + + ref m_bpa; + mutable ref m_msg; +}; + + +} // vmime + + +#endif // !VMIME_BUILDING_DOC + + +#endif // VMIME_GENERATEDMESSAGEATTACHMENT_HPP_INCLUDED + diff --git a/vmime/messageAttachment.hpp b/vmime/messageAttachment.hpp new file mode 100644 index 00000000..03fffb0c --- /dev/null +++ b/vmime/messageAttachment.hpp @@ -0,0 +1,55 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002-2005 Vincent Richard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// Linking this library statically or dynamically with other modules is making +// a combined work based on this library. Thus, the terms and conditions of +// the GNU General Public License cover the whole combination. +// + +#ifndef VMIME_MESSAGEATTACHMENT_HPP_INCLUDED +#define VMIME_MESSAGEATTACHMENT_HPP_INCLUDED + + +#include "vmime/attachment.hpp" +#include "vmime/message.hpp" + + +namespace vmime +{ + + +/** Attachment of type message/rfc822. + */ + +class messageAttachment : public attachment +{ +public: + + /** Return the message encapsulated in this attachment. + * + * @return encapsulated message + */ + virtual ref getMessage() const = 0; +}; + + +} // vmime + + +#endif // VMIME_MESSAGEATTACHMENT_HPP_INCLUDED + diff --git a/vmime/parsedMessageAttachment.hpp b/vmime/parsedMessageAttachment.hpp new file mode 100644 index 00000000..2bb78a63 --- /dev/null +++ b/vmime/parsedMessageAttachment.hpp @@ -0,0 +1,78 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002-2005 Vincent Richard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// Linking this library statically or dynamically with other modules is making +// a combined work based on this library. Thus, the terms and conditions of +// the GNU General Public License cover the whole combination. +// + +#ifndef VMIME_PARSEDMESSAGEATTACHMENT_HPP_INCLUDED +#define VMIME_PARSEDMESSAGEATTACHMENT_HPP_INCLUDED + + +#ifndef VMIME_BUILDING_DOC // implementation detail + + +#include "vmime/messageAttachment.hpp" + + +namespace vmime +{ + + +/** A message attachment that can be generated into a message. + */ +class parsedMessageAttachment : public messageAttachment +{ +public: + + parsedMessageAttachment(ref msg); + + const mediaType getType() const; + const text getDescription() const; + const word getName() const; + + const ref getData() const; + + const encoding getEncoding() const; + + ref getPart() const; + + ref getHeader() const; + + ref getMessage() const; + +protected: + + void generateIn(bodyPart& parent) const; + +private: + + ref m_msg; + mutable ref m_data; +}; + + +} // vmime + + +#endif // !VMIME_BUILDING_DOC + + +#endif // VMIME_PARSEDMESSAGEATTACHMENT_HPP_INCLUDED + diff --git a/vmime/vmime.hpp b/vmime/vmime.hpp index cbae859e..9d2cddb7 100644 --- a/vmime/vmime.hpp +++ b/vmime/vmime.hpp @@ -74,6 +74,7 @@ #include "vmime/fileAttachment.hpp" #include "vmime/defaultAttachment.hpp" +#include "vmime/messageAttachment.hpp" #include "vmime/plainTextPart.hpp" #include "vmime/htmlTextPart.hpp"