18 #include "mailheader.h"
21 mailHeader::mailHeader ()
23 setType(
"text/plain" );
27 mailHeader::~mailHeader ()
36 const QByteArray label( addLine->
getLabel() );
37 const QByteArray value( addLine->
getValue() );
39 if ( !qstricmp( label,
"Return-Path" ) ) {
40 returnpathAdr.parseAddress( value.data() );
43 if ( !qstricmp( label,
"Sender" ) ) {
44 senderAdr.parseAddress( value.data() );
47 if ( !qstricmp( label,
"From" ) ) {
48 fromAdr.parseAddress( value.data() );
51 if ( !qstricmp( label,
"Reply-To" ) ) {
52 replytoAdr.parseAddress( value.data() );
55 if ( !qstricmp( label,
"To" ) ) {
56 mailHeader::parseAddressList( value, toAdr );
59 if ( !qstricmp( label,
"CC" ) ) {
60 mailHeader::parseAddressList( value, ccAdr );
63 if ( !qstricmp( label,
"BCC" ) ) {
64 mailHeader::parseAddressList( value, bccAdr );
67 if ( !qstricmp( label,
"Subject" ) ) {
68 _subject = value.simplified();
71 if ( !qstricmp( label.data(),
"Date" ) ) {
75 if ( !qstricmp( label.data(),
"Message-ID" ) ) {
76 int start = value.lastIndexOf(
'<' );
77 int end = value.lastIndexOf(
'>' );
79 messageID = value.mid( start, end - start + 1 );
81 qWarning(
"bad Message-ID" );
86 if ( !qstricmp( label.data(),
"In-Reply-To" ) ) {
87 int start = value.lastIndexOf(
'<' );
88 int end = value.lastIndexOf(
'>' );
90 inReplyTo = value.mid( start, end - start + 1 );
96 mimeHeader::addHdrLine( inLine );
104 originalHdrLines.append( addLine );
108 mailHeader::outputHeader (
mimeIO & useIO)
110 static const QByteArray __returnPath(
"Return-Path: " );
111 static const QByteArray __from (
"From: " );
112 static const QByteArray __sender (
"Sender: " );
113 static const QByteArray __replyTo (
"Reply-To: " );
114 static const QByteArray __to (
"To: " );
115 static const QByteArray __cc (
"CC: " );
116 static const QByteArray __bcc (
"BCC: " );
117 static const QByteArray __subject (
"Subject: " );
118 static const QByteArray __messageId (
"Message-ID: " );
119 static const QByteArray __inReplyTo (
"In-Reply-To: " );
120 static const QByteArray __references(
"References: " );
121 static const QByteArray __date (
"Date: " );
123 if ( !returnpathAdr.isEmpty() ) {
124 useIO.outputMimeLine( __returnPath + returnpathAdr.getStr() );
126 if ( !fromAdr.isEmpty() ) {
127 useIO.outputMimeLine( __from + fromAdr.getStr() );
129 if ( !senderAdr.isEmpty() ) {
130 useIO.outputMimeLine( __sender + senderAdr.getStr() );
132 if ( !replytoAdr.isEmpty() ) {
133 useIO.outputMimeLine( __replyTo + replytoAdr.getStr() );
136 if ( toAdr.count() ) {
137 useIO.outputMimeLine( mimeHdrLine::truncateLine( __to +
138 mailHeader::getAddressStr( toAdr ) ) );
140 if ( ccAdr.count() ) {
141 useIO.outputMimeLine( mimeHdrLine::truncateLine( __cc +
142 mailHeader::getAddressStr( ccAdr ) ) );
144 if ( bccAdr.count() ) {
145 useIO.outputMimeLine( mimeHdrLine::truncateLine( __bcc +
146 mailHeader::getAddressStr( bccAdr ) ) );
148 if ( !_subject.isEmpty() ) {
149 useIO.outputMimeLine( mimeHdrLine::truncateLine( __subject + _subject ) );
151 if ( !messageID.isEmpty() ) {
152 useIO.outputMimeLine( mimeHdrLine::truncateLine( __messageId + messageID ) );
154 if ( !inReplyTo.isEmpty() ) {
155 useIO.outputMimeLine( mimeHdrLine::truncateLine( __inReplyTo + inReplyTo ) );
157 if ( !references.isEmpty() ) {
158 useIO.outputMimeLine( mimeHdrLine::truncateLine( __references + references ) );
161 if ( !mDate.isEmpty() ) {
162 useIO.outputMimeLine( __date + mDate );
164 mimeHeader::outputHeader( useIO );
168 mailHeader::parseAddressList (
const char *inCStr,
169 QList < mailAddress *> &aList)
173 char *aCStr = (
char *) inCStr;
179 mailAddress *aAddress =
new mailAddress;
180 skip = aAddress->parseAddress( aCStr );
188 aList.append( aAddress );
198 mailHeader::getAddressStr (QList < mailAddress *> &aList)
202 QListIterator < mailAddress *> it = QListIterator < mailAddress *>( aList );
204 while ( it.hasNext() ) {
206 retVal += addr->getStr();
207 if ( it.hasNext() ) {
const QByteArray & getValue()
return the value
const QByteArray & getLabel()
return the label