Additional MDN fields (thanks to Mehmet Bozkurt).
This commit is contained in:
parent
9adc7c3952
commit
173c665e0c
@ -66,7 +66,7 @@ const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const ref <const
|
|||||||
const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue()
|
const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue()
|
||||||
.dynamicCast <const mailboxList>();
|
.dynamicCast <const mailboxList>();
|
||||||
|
|
||||||
for (int i = 0 ; i < dnto.getMailboxCount() ; ++i)
|
for (size_t i = 0 ; i < dnto.getMailboxCount() ; ++i)
|
||||||
result.push_back(sendableMDNInfos(msg, *dnto.getMailboxAt(i)));
|
result.push_back(sendableMDNInfos(msg, *dnto.getMailboxAt(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,8 @@ ref <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
|
|||||||
const mailbox& expeditor,
|
const mailbox& expeditor,
|
||||||
const disposition& dispo,
|
const disposition& dispo,
|
||||||
const string& reportingUA,
|
const string& reportingUA,
|
||||||
const std::vector <string>& reportingUAProducts)
|
const std::vector <string>& reportingUAProducts,
|
||||||
|
const std::map <string, string>& fields)
|
||||||
{
|
{
|
||||||
// Create a new message
|
// Create a new message
|
||||||
ref <message> msg = vmime::create <message>();
|
ref <message> msg = vmime::create <message>();
|
||||||
@ -178,7 +179,7 @@ ref <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
|
|||||||
|
|
||||||
msg->getBody()->appendPart(createFirstMDNPart(mdnInfos, text, ch));
|
msg->getBody()->appendPart(createFirstMDNPart(mdnInfos, text, ch));
|
||||||
msg->getBody()->appendPart(createSecondMDNPart(mdnInfos,
|
msg->getBody()->appendPart(createSecondMDNPart(mdnInfos,
|
||||||
dispo, reportingUA, reportingUAProducts));
|
dispo, reportingUA, reportingUAProducts, fields));
|
||||||
msg->getBody()->appendPart(createThirdMDNPart(mdnInfos));
|
msg->getBody()->appendPart(createThirdMDNPart(mdnInfos));
|
||||||
|
|
||||||
return (msg);
|
return (msg);
|
||||||
@ -208,7 +209,8 @@ ref <bodyPart> MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos
|
|||||||
ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
||||||
const disposition& dispo,
|
const disposition& dispo,
|
||||||
const string& reportingUA,
|
const string& reportingUA,
|
||||||
const std::vector <string>& reportingUAProducts)
|
const std::vector <string>& reportingUAProducts,
|
||||||
|
const std::map <string, string>& additionalFields)
|
||||||
{
|
{
|
||||||
ref <bodyPart> part = vmime::create <bodyPart>();
|
ref <bodyPart> part = vmime::create <bodyPart>();
|
||||||
|
|
||||||
@ -281,6 +283,39 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
|||||||
// -- Disposition
|
// -- Disposition
|
||||||
fields.Disposition()->setValue(dispo);
|
fields.Disposition()->setValue(dispo);
|
||||||
|
|
||||||
|
// -- Failure, Error and Warning fields
|
||||||
|
std::map <string, string>::const_iterator it;
|
||||||
|
|
||||||
|
if (additionalFields.size() > 0)
|
||||||
|
{
|
||||||
|
it = additionalFields.find(vmime::fields::ERROR);
|
||||||
|
if (it != additionalFields.end())
|
||||||
|
{
|
||||||
|
ref <headerField> error = headerFieldFactory::getInstance()->
|
||||||
|
create(vmime::fields::ERROR);
|
||||||
|
error->setValue(it->second);
|
||||||
|
fields.appendField(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
it = additionalFields.find(vmime::fields::WARNING);
|
||||||
|
if (it != additionalFields.end())
|
||||||
|
{
|
||||||
|
ref <headerField> warn = headerFieldFactory::getInstance()->
|
||||||
|
create(vmime::fields::WARNING);
|
||||||
|
warn->setValue(it->second);
|
||||||
|
fields.appendField(warn);
|
||||||
|
}
|
||||||
|
|
||||||
|
it = additionalFields.find(vmime::fields::FAILURE);
|
||||||
|
if (it != additionalFields.end())
|
||||||
|
{
|
||||||
|
ref <headerField> fail = headerFieldFactory::getInstance()->
|
||||||
|
create(vmime::fields::FAILURE);
|
||||||
|
fail->setValue(it->second);
|
||||||
|
fields.appendField(fail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
utility::outputStreamAdapter vos(oss);
|
utility::outputStreamAdapter vos(oss);
|
||||||
|
@ -102,6 +102,7 @@ public:
|
|||||||
* @param dispo disposition information
|
* @param dispo disposition information
|
||||||
* @param reportingUA name of reporting user-agent (optional)
|
* @param reportingUA name of reporting user-agent (optional)
|
||||||
* @param reportingUAProducts list of products in the 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
|
* @return a new message object containing the MDN
|
||||||
*/
|
*/
|
||||||
static ref <message> buildMDN(const sendableMDNInfos& mdnInfos,
|
static ref <message> buildMDN(const sendableMDNInfos& mdnInfos,
|
||||||
@ -111,7 +112,9 @@ public:
|
|||||||
const disposition& dispo,
|
const disposition& dispo,
|
||||||
const string& reportingUA = NULL_STRING,
|
const string& reportingUA = NULL_STRING,
|
||||||
const std::vector <string>& reportingUAProducts
|
const std::vector <string>& reportingUAProducts
|
||||||
= std::vector <string>());
|
= std::vector <string>(),
|
||||||
|
const std::map <string, string>& fields
|
||||||
|
= (std::map <string, string>()));
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -121,7 +124,9 @@ private:
|
|||||||
static ref <bodyPart> createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
static ref <bodyPart> createSecondMDNPart(const sendableMDNInfos& mdnInfos,
|
||||||
const disposition& dispo,
|
const disposition& dispo,
|
||||||
const string& reportingUA,
|
const string& reportingUA,
|
||||||
const std::vector <string>& reportingUAProducts);
|
const std::vector <string>& reportingUAProducts,
|
||||||
|
const std::map <string, string>& fields);
|
||||||
|
|
||||||
|
|
||||||
static ref <bodyPart> createThirdMDNPart(const sendableMDNInfos& mdnInfos);
|
static ref <bodyPart> createThirdMDNPart(const sendableMDNInfos& mdnInfos);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user