22#include "kmime_version.h"
25#include "kmime_debug.h"
28#include <QCoreApplication>
43struct DispositionMetaData {
46 const char *description;
49static constexpr std::array<DispositionMetaData, 6> dispositionTypes = {
53 QT_TRANSLATE_NOOP(
"DispositionModifier",
"The message sent on ${date} to ${to} with subject "
54 "\"${subject}\" has been displayed. This is no guarantee that "
55 "the message has been read or understood.")
60 QT_TRANSLATE_NOOP(
"DispositionModifier",
"The message sent on ${date} to ${to} with subject "
61 "\"${subject}\" has been deleted unseen. This is no guarantee "
62 "that the message will not be \"undeleted\" and nonetheless "
68 QT_TRANSLATE_NOOP(
"DispositionModifier",
"The message sent on ${date} to ${to} with subject "
69 "\"${subject}\" has been dispatched. This is no guarantee "
70 "that the message will not be read later on.")
75 QT_TRANSLATE_NOOP(
"DispositionModifier",
"The message sent on ${date} to ${to} with subject "
76 "\"${subject}\" has been processed by some automatic means.")
81 QT_TRANSLATE_NOOP(
"DispositionModifier",
"The message sent on ${date} to ${to} with subject "
82 "\"${subject}\" has been acted upon. The sender does not wish "
83 "to disclose more details to you than that.")
88 QT_TRANSLATE_NOOP(
"DispositionModifier",
"Generation of a Message Disposition Notification for the "
89 "message sent on ${date} to ${to} with subject \"${subject}\" "
90 "failed. Reason is given in the Failure: header field below.")
96 for (
size_t i = 0 ; i < dispositionTypes.size() ; ++i) {
97 if (dispositionTypes[i].dispositionType == d) {
98 return dispositionTypes[i].string;
107struct DispositionModifierMetaData {
112static constexpr std::array<DispositionModifierMetaData, 5> dispositionModifiers = {
113 DispositionModifierMetaData{ Error,
"error" },
114 DispositionModifierMetaData{ Warning,
"warning" },
115 DispositionModifierMetaData{ Superseded,
"superseded" },
116 DispositionModifierMetaData{ Expired,
"expired" },
117 DispositionModifierMetaData{ MailboxTerminated,
"mailbox-terminated" }
122 for (
size_t i = 0 ; i < dispositionModifiers.size() ; ++i) {
123 if (dispositionModifiers[i].dispositionModifier == m) {
124 return dispositionModifiers[i].string;
134struct ActionModeMetaData {
139static constexpr std::array<ActionModeMetaData, 2> actionModes = {
140 ActionModeMetaData{ ManualAction,
"manual-action" },
141 ActionModeMetaData{ AutomaticAction,
"automatic-action" }
146 for (
size_t i = 0 ; i < actionModes.size() ; ++i) {
147 if (actionModes[i].actionMode == a) {
148 return actionModes[i].string;
158struct SendingModeMetaData {
163static constexpr std::array<SendingModeMetaData, 2> sendingModes = {
164 SendingModeMetaData{ SentManually,
"MDN-sent-manually" },
165 SendingModeMetaData{ SentAutomatically,
"MDN-sent-automatically" }
170 for (
size_t i = 0 ; i < sendingModes.size() ; ++i) {
171 if (sendingModes[i].sendingMode == s) {
172 return sendingModes[i].string;
180 const QList<DispositionModifier> &m) {
183 QByteArray result =
"Disposition: ";
184 result += stringFor(a);
186 result += stringFor(s);
188 result += stringFor(d);
192 for (QList<DispositionModifier>::const_iterator mt = m.
begin();
193 mt != m.
end(); ++mt) {
200 result += stringFor(*mt);
202 return result +
'\n';
205static QByteArray finalRecipient(
const QString &recipient)
210 return "Final-Recipient: rfc822; "
215static QByteArray orginalRecipient(
const QByteArray &recipient)
220 return "Original-Recipient: " + recipient +
'\n';
224static QByteArray originalMessageID(
const QByteArray &msgid)
229 return "Original-Message-ID: " + msgid +
'\n';
233static QByteArray reportingUAField()
236 if (gethostname(hostName, 255)) {
239 hostName[255] =
'\0';
241 return QByteArray(
"Reporting-UA: ") + QByteArray(hostName) +
242 QByteArray(
"; KMime " KMIME_VERSION_STRING
"\n");
252 spec = special.left(special.length() - 1);
259 result += orginalRecipient(o);
260 result += finalRecipient(r);
261 result += originalMessageID(omid);
262 result += dispositionField(d, a, s, m);
266 result +=
"Failure: " + encodeRFC2047String(spec,
"utf-8") +
'\n';
268 result +=
"Error: " + encodeRFC2047String(spec,
"utf-8") +
'\n';
270 result +=
"Warning: " + encodeRFC2047String(spec,
"utf-8") +
'\n';
277 for (
size_t i = 0 ; i < dispositionTypes.size() ; ++i) {
278 if (dispositionTypes[i].dispositionType == d) {
282 qCWarning(KMIME_LOG) <<
"KMime::MDN::descriptionFor(): No such disposition type:"
283 <<
static_cast<int>(d);
QByteArray dispositionNotificationBodyContent(const QString &r, const QByteArray &o, const QByteArray &omid, DispositionType d, ActionMode a, SendingMode s, const QList< DispositionModifier > &m, const QString &special)
Generates the content of the message/disposition-notification body part.
This file is part of the API for handling MIME data and provides functions for supporting Message Dis...
DispositionModifier
The following disposition modifiers are defined:
ActionMode
The following disposition modes are defined:
DispositionType
The following disposition-types are defined:
KCODECS_EXPORT QByteArray encodeRFC2047String(QStringView src, const QByteArray &charset)
bool isEmpty() const const
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
bool contains(const AT &value) const const
bool isEmpty() const const