22#include "kmime_version.h"
23#include "kmime_util.h"
24#include "kmime_codecs_p.h"
25#include "kmime_debug.h"
27#include <KLocalizedString>
36#include <KLazyLocalizedString>
45 DispositionType dispositionType;
48} dispositionTypes[] = {{Displayed,
50 kli18n(
"The message sent on ${date} to ${to} with subject "
51 "\"${subject}\" has been displayed. This is no guarantee that "
52 "the message has been read or understood.")},
55 kli18n(
"The message sent on ${date} to ${to} with subject "
56 "\"${subject}\" has been deleted unseen. This is no guarantee "
57 "that the message will not be \"undeleted\" and nonetheless "
61 kli18n(
"The message sent on ${date} to ${to} with subject "
62 "\"${subject}\" has been dispatched. This is no guarantee "
63 "that the message will not be read later on.")},
66 kli18n(
"The message sent on ${date} to ${to} with subject "
67 "\"${subject}\" has been processed by some automatic means.")},
70 kli18n(
"The message sent on ${date} to ${to} with subject "
71 "\"${subject}\" has been acted upon. The sender does not wish "
72 "to disclose more details to you than that.")},
75 kli18n(
"Generation of a Message Disposition Notification for the "
76 "message sent on ${date} to ${to} with subject \"${subject}\" "
77 "failed. Reason is given in the Failure: header field below.")}};
79static const int numDispositionTypes =
80 sizeof dispositionTypes /
sizeof *dispositionTypes;
82static const char *stringFor(DispositionType d)
84 for (
int i = 0 ; i < numDispositionTypes ; ++i) {
85 if (dispositionTypes[i].dispositionType == d) {
86 return dispositionTypes[i].string;
96 DispositionModifier dispositionModifier;
98} dispositionModifiers[] = {
101 { Superseded,
"superseded" },
102 { Expired,
"expired" },
103 { MailboxTerminated,
"mailbox-terminated" }
106static const int numDispositionModifiers =
107 sizeof dispositionModifiers /
sizeof *dispositionModifiers;
109static const char *stringFor(DispositionModifier m)
111 for (
int i = 0 ; i < numDispositionModifiers ; ++i) {
112 if (dispositionModifiers[i].dispositionModifier == m) {
113 return dispositionModifiers[i].string;
124 ActionMode actionMode;
127 { ManualAction,
"manual-action" },
128 { AutomaticAction,
"automatic-action" }
131static const int numActionModes =
132 sizeof actionModes /
sizeof *actionModes;
134static const char *stringFor(ActionMode a)
136 for (
int i = 0 ; i < numActionModes ; ++i) {
137 if (actionModes[i].actionMode == a) {
138 return actionModes[i].string;
149 SendingMode sendingMode;
152 { SentManually,
"MDN-sent-manually" },
153 { SentAutomatically,
"MDN-sent-automatically" }
156static const int numSendingModes =
157 sizeof sendingModes /
sizeof *sendingModes;
159static const char *stringFor(SendingMode s)
161 for (
int i = 0 ; i < numSendingModes ; ++i) {
162 if (sendingModes[i].sendingMode == s) {
163 return sendingModes[i].string;
169static QByteArray dispositionField(DispositionType d, ActionMode a,
175 result += stringFor(a);
177 result += stringFor(s);
179 result += stringFor(d);
184 mt != m.
end(); ++mt) {
191 result += stringFor(*mt);
193 return result +
'\n';
201 return "Final-Recipient: rfc822; "
211 return "Original-Recipient: " + recipient +
'\n';
220 return "Original-Message-ID: " + msgid +
'\n';
227 if (gethostname(hostName, 255)) {
230 hostName[255] =
'\0';
233 QByteArray(
"; KMime " KMIME_VERSION_STRING
"\n");
243 spec = special.left(special.length() - 1);
250 result += orginalRecipient(o);
251 result += finalRecipient(r);
252 result += originalMessageID(omid);
253 result += dispositionField(d, a, s, m);
257 result +=
"Failure: " + encodeRFC2047String(spec,
"utf-8") +
'\n';
259 result +=
"Error: " + encodeRFC2047String(spec,
"utf-8") +
'\n';
261 result +=
"Warning: " + encodeRFC2047String(spec,
"utf-8") +
'\n';
268 for (
int i = 0 ; i < numDispositionTypes ; ++i) {
269 if (dispositionTypes[i].dispositionType == d) {
270 return dispositionTypes[i].description.toString();
273 qCWarning(KMIME_LOG) <<
"KMime::MDN::descriptionFor(): No such disposition type:"
274 <<
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...
ActionMode
The following disposition modes are defined:
DispositionType
The following disposition-types are defined:
AKONADI_MIME_EXPORT const char Deleted[]
KCODECS_EXPORT QByteArray encodeRFC2047String(QStringView src, const QByteArray &charset)
bool isEmpty() const const
bool contains(const AT &value) const const
bool isEmpty() const const