35 #include "kmime_version.h"
36 #include "kmime_util.h"
38 #include <klocalizedstring.h>
41 #include <QtCore/QByteArray>
42 #include <QtCore/QList>
51 DispositionType dispositionType;
53 const char * description;
54 } dispositionTypes[] = {
55 { Displayed,
"displayed",
56 I18N_NOOP(
"The message sent on ${date} to ${to} with subject "
57 "\"${subject}\" has been displayed. This is no guarantee that "
58 "the message has been read or understood." ) },
60 I18N_NOOP(
"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 "
64 { Dispatched,
"dispatched",
65 I18N_NOOP(
"The message sent on ${date} to ${to} with subject "
66 "\"${subject}\" has been dispatched. This is no guarantee "
67 "that the message will not be read later on." ) },
68 { Processed,
"processed",
69 I18N_NOOP(
"The message sent on ${date} to ${to} with subject "
70 "\"${subject}\" has been processed by some automatic means." ) },
72 I18N_NOOP(
"The message sent on ${date} to ${to} with subject "
73 "\"${subject}\" has been acted upon. The sender does not wish "
74 "to disclose more details to you than that." ) },
76 I18N_NOOP(
"Generation of a Message Disposition Notification for the "
77 "message sent on ${date} to ${to} with subject \"${subject}\" "
78 "failed. Reason is given in the Failure: header field below." ) }
81 static const int numDispositionTypes =
82 sizeof dispositionTypes /
sizeof *dispositionTypes;
84 static const char *stringFor( DispositionType d )
86 for (
int i = 0 ; i < numDispositionTypes ; ++i ) {
87 if ( dispositionTypes[i].dispositionType == d ) {
88 return dispositionTypes[i].string;
98 DispositionModifier dispositionModifier;
100 } dispositionModifiers[] = {
102 { Warning,
"warning" },
103 { Superseded,
"superseded" },
104 { Expired,
"expired" },
105 { MailboxTerminated,
"mailbox-terminated" }
108 static const int numDispositionModifiers =
109 sizeof dispositionModifiers /
sizeof * dispositionModifiers;
111 static const char *stringFor( DispositionModifier m ) {
112 for (
int i = 0 ; i < numDispositionModifiers ; ++i ) {
113 if ( dispositionModifiers[i].dispositionModifier == m ) {
114 return dispositionModifiers[i].string;
124 static const struct {
125 ActionMode actionMode;
128 { ManualAction,
"manual-action" },
129 { AutomaticAction,
"automatic-action" }
132 static const int numActionModes =
133 sizeof actionModes /
sizeof *actionModes;
135 static const char *stringFor( ActionMode a ) {
136 for (
int i = 0 ; i < numActionModes ; ++i ) {
137 if ( actionModes[i].actionMode == a ) {
138 return actionModes[i].string;
148 static const struct {
149 SendingMode sendingMode;
152 { SentManually,
"MDN-sent-manually" },
153 { SentAutomatically,
"MDN-sent-automatically" }
156 static const int numSendingModes =
157 sizeof sendingModes /
sizeof *sendingModes;
159 static const char *stringFor( SendingMode s ) {
160 for (
int i = 0 ; i < numSendingModes ; ++i ) {
161 if ( sendingModes[i].sendingMode == s ) {
162 return sendingModes[i].string;
168 static QByteArray dispositionField( DispositionType d, ActionMode a, SendingMode s,
173 result += stringFor( a );
175 result += stringFor( s );
177 result += stringFor( d );
182 mt != m.
end() ; ++mt ) {
189 result += stringFor( *mt );
191 return result +
'\n';
199 return "Final-Recipient: rfc822; "
200 + encodeRFC2047String( recipient,
"utf-8" ) +
'\n';
209 return "Original-Recipient: " + recipient +
'\n';
218 return "Original-Message-ID: " + msgid +
'\n';
224 if ( gethostname( hostName, 255 ) ) {
227 hostName[255] =
'\0';
230 QByteArray(
"; KMime " KMIME_VERSION_STRING
"\n" );
252 result += orginalRecipient( o );
253 result += finalRecipient( r );
254 result += originalMessageID( omid );
255 result += dispositionField( d, a, s, m );
259 result +=
"Failure: " + encodeRFC2047String( spec,
"utf-8" ) +
'\n';
261 result +=
"Error: " + encodeRFC2047String( spec,
"utf-8" ) +
'\n';
262 }
else if ( m.
contains( Warning ) ) {
263 result +=
"Warning: " + encodeRFC2047String( spec,
"utf-8" ) +
'\n';
269 QString descriptionFor( DispositionType d,
272 for (
int i = 0 ; i < numDispositionTypes ; ++i ) {
273 if ( dispositionTypes[i].dispositionType == d ) {
274 return i18n( dispositionTypes[i].description );
277 kWarning() <<
"KMime::MDN::descriptionFor(): No such disposition type:"
This file is part of the API for handling MIME data and provides functions for supporting Message Dis...
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
bool contains(const T &value) const
QString left(int n) const