diff options
author | Wojtek Kosior <wk@koszkonutek-tmp.pl.eu.org> | 2021-04-30 00:33:56 +0200 |
---|---|---|
committer | Wojtek Kosior <wk@koszkonutek-tmp.pl.eu.org> | 2021-04-30 00:33:56 +0200 |
commit | aa4d426b4d3527d7e166df1a05058c9a4a0f6683 (patch) | |
tree | 4ff17ce8b89a2321b9d0ed4bcfc37c447bcb6820 /vmime-master/src/vmime/mdn | |
download | smtps-and-pop3s-console-program-aa4d426b4d3527d7e166df1a05058c9a4a0f6683.tar.gz smtps-and-pop3s-console-program-aa4d426b4d3527d7e166df1a05058c9a4a0f6683.zip |
Diffstat (limited to 'vmime-master/src/vmime/mdn')
-rw-r--r-- | vmime-master/src/vmime/mdn/MDNHelper.cpp | 362 | ||||
-rw-r--r-- | vmime-master/src/vmime/mdn/MDNHelper.hpp | 142 | ||||
-rw-r--r-- | vmime-master/src/vmime/mdn/MDNInfos.cpp | 38 | ||||
-rw-r--r-- | vmime-master/src/vmime/mdn/MDNInfos.hpp | 57 | ||||
-rw-r--r-- | vmime-master/src/vmime/mdn/receivedMDNInfos.cpp | 140 | ||||
-rw-r--r-- | vmime-master/src/vmime/mdn/receivedMDNInfos.hpp | 93 | ||||
-rw-r--r-- | vmime-master/src/vmime/mdn/sendableMDNInfos.cpp | 72 | ||||
-rw-r--r-- | vmime-master/src/vmime/mdn/sendableMDNInfos.hpp | 72 |
8 files changed, 976 insertions, 0 deletions
diff --git a/vmime-master/src/vmime/mdn/MDNHelper.cpp b/vmime-master/src/vmime/mdn/MDNHelper.cpp new file mode 100644 index 0000000..a21a181 --- /dev/null +++ b/vmime-master/src/vmime/mdn/MDNHelper.cpp @@ -0,0 +1,362 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002 Vincent Richard <vincent@vmime.org> +// +// 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 3 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/mdn/MDNHelper.hpp" + +#include "vmime/exception.hpp" +#include "vmime/stringContentHandler.hpp" + +#include "vmime/contentTypeField.hpp" + +#include "vmime/path.hpp" +#include "vmime/dateTime.hpp" + +#include "vmime/utility/outputStreamAdapter.hpp" + + +namespace vmime { +namespace mdn { + + +void MDNHelper::attachMDNRequest(const shared_ptr <message>& msg, const mailboxList& mailboxes) { + + shared_ptr <header> hdr = msg->getHeader(); + + hdr->DispositionNotificationTo()->setValue(mailboxes); +} + + +void MDNHelper::attachMDNRequest(const shared_ptr <message>& msg, const mailbox& mbox) { + + mailboxList mboxList; + mboxList.appendMailbox(vmime::clone(mbox)); + + attachMDNRequest(msg, mboxList); +} + + +const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const shared_ptr <const message>& msg) { + + std::vector <sendableMDNInfos> result; + + const shared_ptr <const header> hdr = msg->getHeader(); + + if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO)) { + + const mailboxList& dnto = + *hdr->DispositionNotificationTo()->getValue <mailboxList>(); + + for (size_t i = 0 ; i < dnto.getMailboxCount() ; ++i) { + result.push_back(sendableMDNInfos(msg, *dnto.getMailboxAt(i))); + } + } + + return result; +} + + +bool MDNHelper::isMDN(const shared_ptr <const message>& msg) +{ + const shared_ptr <const header> hdr = msg->getHeader(); + + // A MDN message implies the following: + // - a Content-Type field is present and its value is "multipart/report" + // - a "report-type" parameter is present in the Content-Type field, + // and its value is "disposition-notification" + if (hdr->hasField(fields::CONTENT_TYPE)) { + + const contentTypeField& ctf = *dynamicCast <const contentTypeField>(hdr->ContentType()); + + const mediaType type = *ctf.getValue <mediaType>(); + + if (type.getType() == vmime::mediaTypes::MULTIPART && + type.getSubType() == vmime::mediaTypes::MULTIPART_REPORT) { + + if (ctf.hasParameter("report-type") && + ctf.getReportType() == "disposition-notification") { + + return true; + } + } + } + + return false; +} + + +receivedMDNInfos MDNHelper::getReceivedMDN(const shared_ptr <const message>& msg) +{ + if (!isMDN(msg)) { + throw exceptions::invalid_argument(); + } + + return receivedMDNInfos(msg); +} + + +bool MDNHelper::needConfirmation(const shared_ptr <const message>& msg) +{ + shared_ptr <const header> hdr = msg->getHeader(); + + // No "Return-Path" field + if (!hdr->hasField(fields::RETURN_PATH)) { + return true; + } + + // More than one address in Disposition-Notification-To + if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO)) { + + const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue <mailboxList>(); + + if (dnto.getMailboxCount() > 1) { + return true; + } else if (dnto.getMailboxCount() == 0) { + return false; + } + + // Return-Path != Disposition-Notification-To + const mailbox& mbox = *dnto.getMailboxAt(0); + const path& rp = *hdr->ReturnPath()->getValue <path>(); + + if (mbox.getEmail() != rp.getLocalPart() + "@" + rp.getDomain()) { + return true; + } + } + + // User confirmation not needed + return false; +} + + +shared_ptr <message> MDNHelper::buildMDN( + const sendableMDNInfos& mdnInfos, + const string& text, + const charset& ch, + const mailbox& expeditor, + const disposition& dispo, + const string& reportingUA, + const std::vector <string>& reportingUAProducts, + const std::map <string, string>& fields +) { + + // Create a new message + shared_ptr <message> msg = make_shared <message>(); + + // Fill-in header fields + shared_ptr <header> hdr = msg->getHeader(); + + hdr->ContentType()->setValue( + mediaType(vmime::mediaTypes::MULTIPART, vmime::mediaTypes::MULTIPART_REPORT) + ); + + dynamicCast <contentTypeField>(hdr->ContentType())->setReportType("disposition-notification"); + + hdr->Disposition()->setValue(dispo); + + addressList to; + to.appendAddress(make_shared <mailbox>(mdnInfos.getRecipient())); + hdr->To()->setValue(to); + + hdr->From()->setValue(expeditor); + + hdr->Subject()->setValue(vmime::text(word("Disposition notification"))); + + hdr->Date()->setValue(datetime::now()); + hdr->MimeVersion()->setValue(string(SUPPORTED_MIME_VERSION)); + + msg->getBody()->appendPart(createFirstMDNPart(mdnInfos, text, ch)); + msg->getBody()->appendPart(createSecondMDNPart(mdnInfos, + dispo, reportingUA, reportingUAProducts, fields)); + msg->getBody()->appendPart(createThirdMDNPart(mdnInfos)); + + return msg; +} + + +shared_ptr <bodyPart> MDNHelper::createFirstMDNPart( + const sendableMDNInfos& /* mdnInfos */, + const string& text, + const charset& ch +) { + + shared_ptr <bodyPart> part = make_shared <bodyPart>(); + + // Header + shared_ptr <header> hdr = part->getHeader(); + + hdr->ContentType()->setValue( + mediaType(vmime::mediaTypes::TEXT, vmime::mediaTypes::TEXT_PLAIN) + ); + + dynamicCast <contentTypeField>(hdr->ContentType())->setCharset(ch); + + // Body + part->getBody()->setContents(make_shared <stringContentHandler>(text)); + + return part; +} + + +shared_ptr <bodyPart> MDNHelper::createSecondMDNPart( + const sendableMDNInfos& mdnInfos, + const disposition& dispo, + const string& reportingUA, + const std::vector <string>& reportingUAProducts, + const std::map <string, string>& additionalFields +) { + + shared_ptr <bodyPart> part = make_shared <bodyPart>(); + + // Header + shared_ptr <header> hdr = part->getHeader(); + + hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE); + hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MESSAGE, + vmime::mediaTypes::MESSAGE_DISPOSITION_NOTIFICATION)); + + // Body + // + // The body of a message/disposition-notification consists of one or + // more "fields" formatted according to the ABNF of [RFC-MSGFMT] header + // "fields". The syntax of the message/disposition-notification content + // is as follows: + // + // disposition-notification-content = [ reporting-ua-field CRLF ] + // [ mdn-gateway-field CRLF ] + // [ original-recipient-field CRLF ] + // final-recipient-field CRLF + // [ original-message-id-field CRLF ] + // disposition-field CRLF + // *( failure-field CRLF ) + // *( error-field CRLF ) + // *( warning-field CRLF ) + // *( extension-field CRLF ) + // + header fields; + + // -- Reporting-UA (optional) + if (!reportingUA.empty()) { + + string ruaText; + ruaText = reportingUA; + + for (unsigned int i = 0 ; i < reportingUAProducts.size() ; ++i) { + + if (i == 0) { + ruaText += "; "; + } else { + ruaText += ", "; + } + + ruaText += reportingUAProducts[i]; + } + + shared_ptr <headerField> rua = headerFieldFactory::getInstance()-> + create(vmime::fields::REPORTING_UA); + + rua->setValue(ruaText); + + fields.appendField(rua); + } + + // -- Final-Recipient + shared_ptr <headerField> fr = headerFieldFactory::getInstance()-> + create(vmime::fields::FINAL_RECIPIENT); + + fr->setValue("rfc822; " + mdnInfos.getRecipient().getEmail().generate()); + + fields.appendField(fr); + + // -- Original-Message-ID + if (mdnInfos.getMessage()->getHeader()->hasField(vmime::fields::MESSAGE_ID)) { + + fields.OriginalMessageId()->setValueConst + (mdnInfos.getMessage()->getHeader()->MessageId()->getValue()); + } + + // -- Disposition + fields.Disposition()->setValue(dispo); + + // -- Failure, Error and Warning fields + std::map <string, string>::const_iterator it; + + if (additionalFields.size() > 0) { + + if ((it = additionalFields.find(vmime::fields::ERROR)) != additionalFields.end()) { + + shared_ptr <headerField> error = headerFieldFactory::getInstance()->create(vmime::fields::ERROR); + error->setValue(it->second); + fields.appendField(error); + } + + if ((it = additionalFields.find(vmime::fields::WARNING)) != additionalFields.end()) { + + shared_ptr <headerField> warn = headerFieldFactory::getInstance()->create(vmime::fields::WARNING); + warn->setValue(it->second); + fields.appendField(warn); + } + + if ((it = additionalFields.find(vmime::fields::FAILURE)) != additionalFields.end()) { + + shared_ptr <headerField> fail = headerFieldFactory::getInstance()->create(vmime::fields::FAILURE); + fail->setValue(it->second); + fields.appendField(fail); + } + } + + std::ostringstream oss; + utility::outputStreamAdapter vos(oss); + + fields.generate(vos); + + part->getBody()->setContents(make_shared <stringContentHandler>(oss.str())); + + return part; +} + + +shared_ptr <bodyPart> MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos) { + + shared_ptr <bodyPart> part = make_shared <bodyPart>(); + + // Header + shared_ptr <header> hdr = part->getHeader(); + + hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE); + hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT, + vmime::mediaTypes::TEXT_RFC822_HEADERS)); + + // Body: original message headers + std::ostringstream oss; + utility::outputStreamAdapter vos(oss); + + mdnInfos.getMessage()->getHeader()->generate(vos); + + part->getBody()->setContents(make_shared <stringContentHandler>(oss.str())); + + return part; +} + + +} // mdn +} // vmime diff --git a/vmime-master/src/vmime/mdn/MDNHelper.hpp b/vmime-master/src/vmime/mdn/MDNHelper.hpp new file mode 100644 index 0000000..c1bec2f --- /dev/null +++ b/vmime-master/src/vmime/mdn/MDNHelper.hpp @@ -0,0 +1,142 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002 Vincent Richard <vincent@vmime.org> +// +// 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 3 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_MDN_MDNHELPER_HPP_INCLUDED +#define VMIME_MDN_MDNHELPER_HPP_INCLUDED + + +#include "vmime/mdn/receivedMDNInfos.hpp" +#include "vmime/mdn/sendableMDNInfos.hpp" + +#include "vmime/mailboxList.hpp" + + +namespace vmime { +namespace mdn { + + +/** Helper for creating or extracting Message Disposition + * Notifications (MDN), as defined in RFC-3798. + */ +class VMIME_EXPORT MDNHelper { + +public: + + /** Attach a MDN request to the specified message. + * + * @param msg message in which to add a MDN request + * @param mailboxes list of mailboxes to which the MDN will be sent + */ + static void attachMDNRequest(const shared_ptr <message>& msg, const mailboxList& mailboxes); + + /** Attach a MDN request to the specified message. + * + * @param msg message in which to add a MDN request + * @param mbox mailbox to which the MDN will be sent + */ + static void attachMDNRequest(const shared_ptr <message>& msg, const mailbox& mbox); + + /** Return a list of possible MDNs that can be generated + * for the specified message. + * + * @param msg message for which to send a MDN + * @return list of possible MDNs + */ + static const std::vector <sendableMDNInfos> getPossibleMDNs(const shared_ptr <const message>& msg); + + /** Test whether the specified message is a MDN. + * + * @param msg message + * @return true if the message is a MDN, false otherwise + */ + static bool isMDN(const shared_ptr <const message>& msg); + + /** If the specified message is a MDN, return information + * about it. + * + * @param msg message + * @throw exceptions::invalid_argument if the message is not a MDN + * @return information about the MDN + */ + static receivedMDNInfos getReceivedMDN(const shared_ptr <const message>& msg); + + /** Check whether we need user confirmation for sending a MDN even + * if he/she explicitely allowed automatic send of MDNs. This can + * happen in some situations, described in RFC-3798. + * + * @param msg message for which to send a MDN + * @return true if user confirmation should be asked, false otherwise + */ + static bool needConfirmation(const shared_ptr <const message>& msg); + + /** Build a new MDN for the message. The resulting MDN can then be + * sent over SMTP transport service. + * + * @param mdnInfos information about the MDN to construct + * @param text human readable message. The purpose of this message is + * to provide an easily-understood description of the + * condition(s) that caused the report to be generated. + * @param ch charset of the text + * @param expeditor expeditor of the MDN + * @param dispo disposition information + * @param reportingUA name of reporting user-agent (optional) + * @param reportingUAProducts list of products in the reporting user-agent (optional) + * @param fields additional MDN fields, like "Error", "Warning" or "Failure" (optional) + * @return a new message object containing the MDN + */ + static shared_ptr <message> buildMDN( + const sendableMDNInfos& mdnInfos, + const string& text, + const charset& ch, + const mailbox& expeditor, + const disposition& dispo, + const string& reportingUA = NULL_STRING, + const std::vector <string>& reportingUAProducts = std::vector <string>(), + const std::map <string, string>& fields = std::map <string, string>() + ); + +private: + + static shared_ptr <bodyPart> createFirstMDNPart( + const sendableMDNInfos& mdnInfos, + const string& text, + const charset& ch + ); + + static shared_ptr <bodyPart> createSecondMDNPart( + const sendableMDNInfos& mdnInfos, + const disposition& dispo, + const string& reportingUA, + const std::vector <string>& reportingUAProducts, + const std::map <string, string>& fields + ); + + static shared_ptr <bodyPart> createThirdMDNPart(const sendableMDNInfos& mdnInfos); +}; + + +} // mdn +} // vmime + + +#endif // VMIME_MDN_MDNHELPER_HPP_INCLUDED diff --git a/vmime-master/src/vmime/mdn/MDNInfos.cpp b/vmime-master/src/vmime/mdn/MDNInfos.cpp new file mode 100644 index 0000000..3efe9f9 --- /dev/null +++ b/vmime-master/src/vmime/mdn/MDNInfos.cpp @@ -0,0 +1,38 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002 Vincent Richard <vincent@vmime.org> +// +// 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 3 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/mdn/MDNInfos.hpp" + + +namespace vmime { +namespace mdn { + + + +MDNInfos::~MDNInfos() { + +} + + +} // mdn +} // vmime diff --git a/vmime-master/src/vmime/mdn/MDNInfos.hpp b/vmime-master/src/vmime/mdn/MDNInfos.hpp new file mode 100644 index 0000000..f6d7929 --- /dev/null +++ b/vmime-master/src/vmime/mdn/MDNInfos.hpp @@ -0,0 +1,57 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002 Vincent Richard <vincent@vmime.org> +// +// 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 3 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_MDN_MDNINFOS_HPP_INCLUDED +#define VMIME_MDN_MDNINFOS_HPP_INCLUDED + + +#include "vmime/types.hpp" +#include "vmime/message.hpp" + + +namespace vmime { +namespace mdn { + + +/** Holds information about Message Disposition Notifications (MDN). + */ +class VMIME_EXPORT MDNInfos : public object { + +public: + + virtual ~MDNInfos(); + + + /** Return the message related to this MDN. + * + * @return related message + */ + virtual const shared_ptr <const message> getMessage() const = 0; +}; + + +} // mdn +} // vmime + + +#endif // VMIME_MDN_MDNINFOS_HPP_INCLUDED diff --git a/vmime-master/src/vmime/mdn/receivedMDNInfos.cpp b/vmime-master/src/vmime/mdn/receivedMDNInfos.cpp new file mode 100644 index 0000000..6f4463e --- /dev/null +++ b/vmime-master/src/vmime/mdn/receivedMDNInfos.cpp @@ -0,0 +1,140 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002 Vincent Richard <vincent@vmime.org> +// +// 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 3 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/mdn/receivedMDNInfos.hpp" + +#include "vmime/utility/outputStreamAdapter.hpp" + + +namespace vmime { +namespace mdn { + + +receivedMDNInfos::receivedMDNInfos(const shared_ptr <const message>& msg) + : m_msg(msg) { + + extract(); +} + + +receivedMDNInfos::receivedMDNInfos(const receivedMDNInfos& other) + : MDNInfos() { + + copyFrom(other); +} + + +receivedMDNInfos& receivedMDNInfos::operator=(const receivedMDNInfos& other) { + + copyFrom(other); + return *this; +} + + +const shared_ptr <const message> receivedMDNInfos::getMessage() const { + + return m_msg; +} + + +const messageId receivedMDNInfos::getOriginalMessageId() const { + + return m_omid; +} + + +const disposition receivedMDNInfos::getDisposition() const { + + return m_disp; +} + + +const string receivedMDNInfos::getContentMIC() const { + + return m_contentMIC; +} + + +void receivedMDNInfos::copyFrom(const receivedMDNInfos& other) { + + m_msg = other.m_msg; + m_omid = other.m_omid; + m_disp = other.m_disp; + m_contentMIC = other.m_contentMIC; +} + + +void receivedMDNInfos::extract() { + + const shared_ptr <const body> bdy = m_msg->getBody(); + + for (size_t i = 0 ; i < bdy->getPartCount() ; ++i) { + + const shared_ptr <const bodyPart> part = bdy->getPartAt(i); + + if (!part->getHeader()->hasField(fields::CONTENT_TYPE)) { + continue; + } + + const mediaType& type = *part->getHeader()->ContentType()->getValue <mediaType>(); + + // Extract from second part (message/disposition-notification) + if (type.getType() == vmime::mediaTypes::MESSAGE && + type.getSubType() == vmime::mediaTypes::MESSAGE_DISPOSITION_NOTIFICATION) { + + std::ostringstream oss; + utility::outputStreamAdapter vos(oss); + + part->getBody()->getContents()->extract(vos); + + // Body actually contains fields + header fields; + fields.parse(oss.str()); + + shared_ptr <messageId> omid = + fields.findFieldValue <messageId>(fields::ORIGINAL_MESSAGE_ID); + + if (omid) { + m_omid = *omid; + } + + shared_ptr <disposition> disp = + fields.findFieldValue <disposition>(fields::DISPOSITION); + + if (disp) { + m_disp = *disp; + } + + shared_ptr <text> contentMIC = + fields.findFieldValue <text>("Received-content-MIC"); + + if (contentMIC) { + m_contentMIC = contentMIC->generate(); + } + } + } +} + + +} // mdn +} // vmime diff --git a/vmime-master/src/vmime/mdn/receivedMDNInfos.hpp b/vmime-master/src/vmime/mdn/receivedMDNInfos.hpp new file mode 100644 index 0000000..7809acb --- /dev/null +++ b/vmime-master/src/vmime/mdn/receivedMDNInfos.hpp @@ -0,0 +1,93 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002 Vincent Richard <vincent@vmime.org> +// +// 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 3 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_MDN_RECEIVEDMDNINFOS_HPP_INCLUDED +#define VMIME_MDN_RECEIVEDMDNINFOS_HPP_INCLUDED + + +#include "vmime/mdn/MDNInfos.hpp" + +#include "vmime/disposition.hpp" +#include "vmime/messageId.hpp" +#include "vmime/mailbox.hpp" + + +namespace vmime { +namespace mdn { + + +/** Holds information about a Message Disposition Notification (MDN) + * that has been received. + */ +class VMIME_EXPORT receivedMDNInfos : public MDNInfos { + +public: + + receivedMDNInfos(const shared_ptr <const message>& msg); + receivedMDNInfos(const receivedMDNInfos& other); + + receivedMDNInfos& operator=(const receivedMDNInfos& other); + + + const shared_ptr <const message> getMessage() const; + + /** Return the identifier of the message for which this MDN + * has been generated. + * + * @return original message-id + */ + const messageId getOriginalMessageId() const; + + /** Return information about the disposition. + * + * @return disposition information + */ + const disposition getDisposition() const; + + /** Return the Message Integrity Check (MIC), that is the value + * of the "Received-content-MIC" field. + * + * @return MIC hash value, or an empty string if not specified + */ + const string getContentMIC() const; + +private: + + void copyFrom(const receivedMDNInfos& other); + + void extract(); + + + shared_ptr <const message> m_msg; + + disposition m_disp; + messageId m_omid; + string m_contentMIC; +}; + + +} // mdn +} // vmime + + +#endif // VMIME_MDN_RECEIVEDMDNINFOS_HPP_INCLUDED diff --git a/vmime-master/src/vmime/mdn/sendableMDNInfos.cpp b/vmime-master/src/vmime/mdn/sendableMDNInfos.cpp new file mode 100644 index 0000000..281655f --- /dev/null +++ b/vmime-master/src/vmime/mdn/sendableMDNInfos.cpp @@ -0,0 +1,72 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002 Vincent Richard <vincent@vmime.org> +// +// 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 3 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/mdn/sendableMDNInfos.hpp" + + +namespace vmime { +namespace mdn { + + +sendableMDNInfos::sendableMDNInfos(const shared_ptr <const message>& msg, const mailbox& mbox) + : m_msg(msg), + m_mailbox(mbox) { + +} + + +sendableMDNInfos::sendableMDNInfos(const sendableMDNInfos& other) + : MDNInfos() { + + copyFrom(other); +} + + +sendableMDNInfos& sendableMDNInfos::operator=(const sendableMDNInfos& other) { + + copyFrom(other); + return *this; +} + + +const shared_ptr <const message> sendableMDNInfos::getMessage() const { + + return m_msg; +} + + +const mailbox& sendableMDNInfos::getRecipient() const { + + return m_mailbox; +} + + +void sendableMDNInfos::copyFrom(const sendableMDNInfos& other) { + + m_msg = other.m_msg; + m_mailbox = other.m_mailbox; +} + + +} // mdn +} // vmime diff --git a/vmime-master/src/vmime/mdn/sendableMDNInfos.hpp b/vmime-master/src/vmime/mdn/sendableMDNInfos.hpp new file mode 100644 index 0000000..5b69b94 --- /dev/null +++ b/vmime-master/src/vmime/mdn/sendableMDNInfos.hpp @@ -0,0 +1,72 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002 Vincent Richard <vincent@vmime.org> +// +// 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 3 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_MDN_SENDABLEMDNINFOS_HPP_INCLUDED +#define VMIME_MDN_SENDABLEMDNINFOS_HPP_INCLUDED + + +#include "vmime/mdn/MDNInfos.hpp" + +#include "vmime/mailbox.hpp" + + +namespace vmime { +namespace mdn { + + +/** Holds information about a Message Disposition Notifications (MDN) + * that is to be sent. + */ +class VMIME_EXPORT sendableMDNInfos : public MDNInfos { + +public: + + sendableMDNInfos(const shared_ptr <const message>& msg, const mailbox& mbox); + sendableMDNInfos(const sendableMDNInfos& other); + + sendableMDNInfos& operator=(const sendableMDNInfos& other); + + const shared_ptr <const message> getMessage() const; + + /** Return the recipient of the MDN (the mailbox that will receive + * the notification message). + * + * @return recipient of the MDN + */ + const mailbox& getRecipient() const; + +private: + + void copyFrom(const sendableMDNInfos& other); + + + shared_ptr <const message> m_msg; + mailbox m_mailbox; +}; + + +} // mdn +} // vmime + + +#endif // VMIME_MDN_SENDABLEMDNINFOS_HPP_INCLUDED |