18 #include "mailheader.h"
19 #include "rfcdecoder.h"
21 mailHeader::mailHeader ()
23 toAdr.setAutoDelete (
true);
24 ccAdr.setAutoDelete (
true);
25 bccAdr.setAutoDelete (
true);
26 setType (
"text/plain");
30 mailHeader::~mailHeader ()
39 const TQCString label(addLine->
getLabel());
40 TQCString value(addLine->
getValue());
42 if (!tqstricmp (label,
"Return-Path")) {
43 returnpathAdr.parseAddress (value.data ());
46 if (!tqstricmp (label,
"Sender")) {
47 senderAdr.parseAddress (value.data ());
50 if (!tqstricmp (label,
"From")) {
51 fromAdr.parseAddress (value.data ());
54 if (!tqstricmp (label,
"Reply-To")) {
55 replytoAdr.parseAddress (value.data ());
58 if (!tqstricmp (label,
"To")) {
59 mailHeader::parseAddressList (value, &toAdr);
62 if (!tqstricmp (label,
"CC")) {
63 mailHeader::parseAddressList (value, &ccAdr);
66 if (!tqstricmp (label,
"BCC")) {
67 mailHeader::parseAddressList (value, &bccAdr);
70 if (!tqstricmp (label,
"Subject")) {
71 _subject = value.simplifyWhiteSpace();
74 if (!tqstricmp (label.data (),
"Date")) {
78 if (!tqstricmp (label.data (),
"Message-ID")) {
79 int start = value.findRev (
'<');
80 int end = value.findRev (
'>');
82 messageID = value.mid (start, end - start + 1);
84 tqWarning(
"bad Message-ID");
89 if (!tqstricmp (label.data (),
"In-Reply-To")) {
90 int start = value.findRev (
'<');
91 int end = value.findRev (
'>');
93 inReplyTo = value.mid (start, end - start + 1);
98 mimeHeader::addHdrLine (inLine);
106 originalHdrLines.append (addLine);
110 mailHeader::outputHeader (
mimeIO & useIO)
112 static const TQCString __returnPath(
"Return-Path: ", 14);
113 static const TQCString __from (
"From: ", 7);
114 static const TQCString __sender (
"Sender: ", 9);
115 static const TQCString __replyTo (
"Reply-To: ", 11);
116 static const TQCString __to (
"To: ", 5);
117 static const TQCString __cc (
"CC: ", 5);
118 static const TQCString __bcc (
"BCC: ", 6);
119 static const TQCString __subject (
"Subject: ", 10);
120 static const TQCString __messageId (
"Message-ID: ", 13);
121 static const TQCString __inReplyTo (
"In-Reply-To: ", 14);
122 static const TQCString __references(
"References: ", 13);
123 static const TQCString __date (
"Date: ", 7);
125 if (!returnpathAdr.isEmpty())
126 useIO.outputMimeLine(__returnPath + returnpathAdr.getStr());
127 if (!fromAdr.isEmpty())
128 useIO.outputMimeLine(__from + fromAdr.getStr());
129 if (!senderAdr.isEmpty())
130 useIO.outputMimeLine(__sender + senderAdr.getStr());
131 if (!replytoAdr.isEmpty())
132 useIO.outputMimeLine(__replyTo + replytoAdr.getStr());
135 useIO.outputMimeLine(mimeHdrLine::truncateLine(__to +
136 mailHeader::getAddressStr(&toAdr)));
138 useIO.outputMimeLine(mimeHdrLine::truncateLine(__cc +
139 mailHeader::getAddressStr(&ccAdr)));
141 useIO.outputMimeLine(mimeHdrLine::truncateLine(__bcc +
142 mailHeader::getAddressStr(&bccAdr)));
143 if (!_subject.isEmpty())
144 useIO.outputMimeLine(mimeHdrLine::truncateLine(__subject + _subject));
145 if (!messageID.isEmpty())
146 useIO.outputMimeLine(mimeHdrLine::truncateLine(__messageId + messageID));
147 if (!inReplyTo.isEmpty())
148 useIO.outputMimeLine(mimeHdrLine::truncateLine(__inReplyTo + inReplyTo));
149 if (!references.isEmpty())
150 useIO.outputMimeLine(mimeHdrLine::truncateLine(__references + references));
152 if (!mDate.isEmpty())
153 useIO.outputMimeLine(__date + mDate);
154 mimeHeader::outputHeader(useIO);
158 mailHeader::parseAddressList (
const char *inCStr,
159 TQPtrList < mailAddress > *aList)
163 char *aCStr = (
char *) inCStr;
165 if (!aCStr || !aList)
169 mailAddress *aAddress =
new mailAddress;
170 skip = aAddress->parseAddress (aCStr);
178 aList->append (aAddress);
190 mailHeader::getAddressStr (TQPtrList < mailAddress > *aList)
194 TQPtrListIterator < mailAddress > it = TQPtrListIterator < mailAddress > (*aList);
195 while (it.current ())
197 retVal += it.current ()->getStr ();
const TQCString & getLabel()
return the label
const TQCString & getValue()
return the value