aboutsummaryrefslogtreecommitdiffstats
path: root/src/mdn
diff options
context:
space:
mode:
Diffstat (limited to 'src/mdn')
-rw-r--r--src/mdn/MDNHelper.cpp132
-rw-r--r--src/mdn/receivedMDNInfos.cpp16
-rw-r--r--src/mdn/sendableMDNInfos.cpp4
3 files changed, 77 insertions, 75 deletions
diff --git a/src/mdn/MDNHelper.cpp b/src/mdn/MDNHelper.cpp
index 324807e0..62028a12 100644
--- a/src/mdn/MDNHelper.cpp
+++ b/src/mdn/MDNHelper.cpp
@@ -27,32 +27,32 @@ namespace vmime {
namespace mdn {
-void MDNHelper::attachMDNRequest(message* msg, const mailboxList& mailboxes)
+void MDNHelper::attachMDNRequest(ref <message> msg, const mailboxList& mailboxes)
{
- header* hdr = msg->getHeader();
+ ref <header> hdr = msg->getHeader();
- hdr->DispositionNotificationTo().setValue(mailboxes);
+ hdr->DispositionNotificationTo()->setValue(mailboxes);
}
-void MDNHelper::attachMDNRequest(message* msg, const mailbox& mbox)
+void MDNHelper::attachMDNRequest(ref <message> msg, const mailbox& mbox)
{
mailboxList mboxList;
- mboxList.appendMailbox(mbox.clone());
+ mboxList.appendMailbox(mbox.clone().dynamicCast <mailbox>());
attachMDNRequest(msg, mboxList);
}
-const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const message* msg)
+const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const ref <const message> msg)
{
std::vector <sendableMDNInfos> result;
- const header* hdr = msg->getHeader();
+ const ref <const header> hdr = msg->getHeader();
if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO))
{
- const mailboxList& dnto = hdr->DispositionNotificationTo().getValue();
+ const mailboxList& dnto = hdr->DispositionNotificationTo()->getValue();
for (int i = 0 ; i < dnto.getMailboxCount() ; ++i)
result.push_back(sendableMDNInfos(msg, *dnto.getMailboxAt(i)));
@@ -62,9 +62,9 @@ const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const message* m
}
-const bool MDNHelper::isMDN(const message* msg)
+const bool MDNHelper::isMDN(const ref <const message> msg)
{
- const header* hdr = msg->getHeader();
+ const ref <const header> hdr = msg->getHeader();
// A MDN message implies the following:
// - a Content-Type field is present and its value is "multipart/report"
@@ -72,7 +72,7 @@ const bool MDNHelper::isMDN(const message* msg)
// and its value is "disposition-notification"
if (hdr->hasField(fields::CONTENT_TYPE))
{
- const contentTypeField& ctf = hdr->ContentType();
+ const contentTypeField& ctf = *(hdr->ContentType());
if (ctf.getValue().getType() == vmime::mediaTypes::MULTIPART &&
ctf.getValue().getSubType() == vmime::mediaTypes::MULTIPART_REPORT)
@@ -89,7 +89,7 @@ const bool MDNHelper::isMDN(const message* msg)
}
-receivedMDNInfos MDNHelper::getReceivedMDN(const message* msg)
+receivedMDNInfos MDNHelper::getReceivedMDN(const ref <const message> msg)
{
if (!isMDN(msg))
throw exceptions::invalid_argument();
@@ -98,7 +98,7 @@ receivedMDNInfos MDNHelper::getReceivedMDN(const message* msg)
}
-bool MDNHelper::needConfirmation(const message* msg)
+const bool MDNHelper::needConfirmation(const ref <const message> msg)
{
const header* hdr = msg->getHeader();
@@ -109,14 +109,14 @@ bool MDNHelper::needConfirmation(const message* msg)
// More than one address in Disposition-Notification-To
if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO))
{
- const mailboxList& dnto = hdr->DispositionNotificationTo().getValue();
+ const mailboxList& dnto = hdr->DispositionNotificationTo()->getValue();
if (dnto.getMailboxCount() > 1)
return (true);
// Return-Path != Disposition-Notification-To
const mailbox& mbox = *dnto.getMailboxAt(0);
- const path& rp = hdr->ReturnPath().getValue();
+ const path& rp = hdr->ReturnPath()->getValue();
if (mbox.getEmail() != rp.getLocalPart() + "@" + rp.getDomain())
return (true);
@@ -127,32 +127,32 @@ bool MDNHelper::needConfirmation(const message* msg)
}
-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)
+ref <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)
{
// Create a new message
- message* msg = new message;
+ ref <message> msg = vmime::create <message>();
// Fill-in header fields
- header* hdr = msg->getHeader();
+ ref <header> hdr = msg->getHeader();
- hdr->ContentType().setValue(mediaType(vmime::mediaTypes::MULTIPART,
- vmime::mediaTypes::MULTIPART_REPORT));
- hdr->ContentType().setReportType("disosition-notification");
+ hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MULTIPART,
+ vmime::mediaTypes::MULTIPART_REPORT));
+ hdr->ContentType()->setReportType("disosition-notification");
- hdr->Disposition().setValue(dispo);
+ hdr->Disposition()->setValue(dispo);
- hdr->To().getValue().appendAddress(new mailbox(mdnInfos.getRecipient()));
- hdr->From().getValue() = expeditor;
- hdr->Subject().getValue().appendWord(new word("Disposition notification"));
+ hdr->To()->getValue().appendAddress(vmime::create <mailbox>(mdnInfos.getRecipient()));
+ hdr->From()->getValue() = expeditor;
+ hdr->Subject()->getValue().appendWord(vmime::create <word>("Disposition notification"));
- hdr->Date().setValue(datetime::now());
- hdr->MimeVersion().setValue(string(SUPPORTED_MIME_VERSION));
+ hdr->Date()->setValue(datetime::now());
+ hdr->MimeVersion()->setValue(string(SUPPORTED_MIME_VERSION));
msg->getBody()->appendPart(createFirstMDNPart(mdnInfos, text, ch));
msg->getBody()->appendPart(createSecondMDNPart(mdnInfos,
@@ -163,39 +163,39 @@ message* MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
}
-bodyPart* MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos */,
- const string& text, const charset& ch)
+ref <bodyPart> MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos */,
+ const string& text, const charset& ch)
{
- bodyPart* part = new bodyPart;
+ ref <bodyPart> part = vmime::create <bodyPart>();
// Header
- header* hdr = part->getHeader();
+ ref <header> hdr = part->getHeader();
- hdr->ContentType().setValue(mediaType(vmime::mediaTypes::TEXT,
- vmime::mediaTypes::TEXT_PLAIN));
+ hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT,
+ vmime::mediaTypes::TEXT_PLAIN));
- hdr->ContentType().setCharset(ch);
+ hdr->ContentType()->setCharset(ch);
// Body
- part->getBody()->setContents(stringContentHandler(text));
+ part->getBody()->setContents(vmime::create <stringContentHandler>(text));
return (part);
}
-bodyPart* MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
- const disposition& dispo,
- const string& reportingUA,
- const std::vector <string>& reportingUAProducts)
+ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
+ const disposition& dispo,
+ const string& reportingUA,
+ const std::vector <string>& reportingUAProducts)
{
- bodyPart* part = new bodyPart;
+ ref <bodyPart> part = vmime::create <bodyPart>();
// Header
- header* hdr = part->getHeader();
+ ref <header> hdr = part->getHeader();
- hdr->ContentDisposition().setValue(vmime::contentDispositionTypes::INLINE);
- hdr->ContentType().setValue(mediaType(vmime::mediaTypes::MESSAGE,
- vmime::mediaTypes::MESSAGE_DISPOSITION_NOTIFICATION));
+ hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE);
+ hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MESSAGE,
+ vmime::mediaTypes::MESSAGE_DISPOSITION_NOTIFICATION));
// Body
//
@@ -233,8 +233,9 @@ bodyPart* MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
ruaText += reportingUAProducts[i];
}
- defaultField* rua = dynamic_cast <defaultField*>
- (headerFieldFactory::getInstance()->create(vmime::fields::REPORTING_UA));
+ ref <defaultField> rua =
+ (headerFieldFactory::getInstance()->create
+ (vmime::fields::REPORTING_UA)).dynamicCast <defaultField>();
rua->setValue(ruaText);
@@ -242,20 +243,21 @@ bodyPart* MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
}
// -- Final-Recipient
- defaultField* fr = dynamic_cast <defaultField*>
- (headerFieldFactory::getInstance()->create(vmime::fields::FINAL_RECIPIENT));
+ ref <defaultField> fr =
+ (headerFieldFactory::getInstance()->
+ create(vmime::fields::FINAL_RECIPIENT)).dynamicCast <defaultField>();
fr->setValue("rfc822; " + mdnInfos.getRecipient().getEmail());
// -- Original-Message-ID
if (mdnInfos.getMessage()->getHeader()->hasField(vmime::fields::MESSAGE_ID))
{
- fields.OriginalMessageId().setValue
- (mdnInfos.getMessage()->getHeader()->MessageId().getValue());
+ fields.OriginalMessageId()->setValue
+ (mdnInfos.getMessage()->getHeader()->MessageId()->getValue());
}
// -- Disposition
- fields.Disposition().setValue(dispo);
+ fields.Disposition()->setValue(dispo);
std::ostringstream oss;
@@ -263,22 +265,22 @@ bodyPart* MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
fields.generate(vos);
- part->getBody()->setContents(stringContentHandler(oss.str()));
+ part->getBody()->setContents(vmime::create <stringContentHandler>(oss.str()));
return (part);
}
-bodyPart* MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
+ref <bodyPart> MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
{
- bodyPart* part = new bodyPart;
+ ref <bodyPart> part = vmime::create <bodyPart>();
// Header
- header* hdr = part->getHeader();
+ ref <header> hdr = part->getHeader();
- hdr->ContentDisposition().setValue(vmime::contentDispositionTypes::INLINE);
- hdr->ContentType().setValue(mediaType(vmime::mediaTypes::TEXT,
- vmime::mediaTypes::TEXT_RFC822_HEADERS));
+ 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;
@@ -286,7 +288,7 @@ bodyPart* MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
mdnInfos.getMessage()->getHeader()->generate(vos);
- part->getBody()->setContents(stringContentHandler(oss.str()));
+ part->getBody()->setContents(vmime::create <stringContentHandler>(oss.str()));
return (part);
}
diff --git a/src/mdn/receivedMDNInfos.cpp b/src/mdn/receivedMDNInfos.cpp
index e9a82198..7c6f2893 100644
--- a/src/mdn/receivedMDNInfos.cpp
+++ b/src/mdn/receivedMDNInfos.cpp
@@ -24,7 +24,7 @@ namespace vmime {
namespace mdn {
-receivedMDNInfos::receivedMDNInfos(const message* msg)
+receivedMDNInfos::receivedMDNInfos(const ref <const message> msg)
: m_msg(msg)
{
extract();
@@ -45,7 +45,7 @@ receivedMDNInfos& receivedMDNInfos::operator=(const receivedMDNInfos& other)
}
-const message* receivedMDNInfos::getMessage() const
+const ref <const message> receivedMDNInfos::getMessage() const
{
return (m_msg);
}
@@ -73,16 +73,16 @@ void receivedMDNInfos::copyFrom(const receivedMDNInfos& other)
void receivedMDNInfos::extract()
{
- const body* bdy = m_msg->getBody();
+ const ref <const body> bdy = m_msg->getBody();
for (int i = 0 ; i < bdy->getPartCount() ; ++i)
{
- const bodyPart* part = bdy->getPartAt(i);
+ const ref <const bodyPart> part = bdy->getPartAt(i);
if (!part->getHeader()->hasField(fields::CONTENT_TYPE))
continue;
- const mediaType& type = part->getHeader()->ContentType().getValue();
+ const mediaType& type = part->getHeader()->ContentType()->getValue();
// Extract from second part (message/disposition-notification)
if (type.getType() == vmime::mediaTypes::MESSAGE &&
@@ -91,16 +91,16 @@ void receivedMDNInfos::extract()
std::ostringstream oss;
utility::outputStreamAdapter vos(oss);
- part->getBody()->getContents().extract(vos);
+ part->getBody()->getContents()->extract(vos);
// Body actually contains fields
header fields;
fields.parse(oss.str());
- try { m_omid = fields.OriginalMessageId().getValue(); }
+ try { m_omid = fields.OriginalMessageId()->getValue(); }
catch (exceptions::no_such_field&) { /* Ignore */ }
- try { m_disp = fields.Disposition().getValue(); }
+ try { m_disp = fields.Disposition()->getValue(); }
catch (exceptions::no_such_field&) { /* Ignore */ }
}
}
diff --git a/src/mdn/sendableMDNInfos.cpp b/src/mdn/sendableMDNInfos.cpp
index e8ae8b62..40a0fe96 100644
--- a/src/mdn/sendableMDNInfos.cpp
+++ b/src/mdn/sendableMDNInfos.cpp
@@ -24,7 +24,7 @@ namespace vmime {
namespace mdn {
-sendableMDNInfos::sendableMDNInfos(const message* msg, const mailbox& mbox)
+sendableMDNInfos::sendableMDNInfos(const ref <const message> msg, const mailbox& mbox)
: m_msg(msg), m_mailbox(mbox)
{
}
@@ -44,7 +44,7 @@ sendableMDNInfos& sendableMDNInfos::operator=(const sendableMDNInfos& other)
}
-const message* sendableMDNInfos::getMessage() const
+const ref <const message> sendableMDNInfos::getMessage() const
{
return (m_msg);
}