18 #include "mailheader.h"
21 mailHeader::mailHeader ()
23 setType(
"text/plain" );
27 mailHeader::~mailHeader ()
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" ) ) {
71 if ( !qstricmp( label.data(),
"Date" ) ) {
75 if ( !qstricmp( label.data(),
"Message-ID" ) ) {
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: " );
112 static const QByteArray __sender (
"Sender: " );
113 static const QByteArray __replyTo (
"Reply-To: " );
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: " );
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 ) ) );
149 useIO.outputMimeLine( mimeHdrLine::truncateLine( __subject + _subject ) );
152 useIO.outputMimeLine( mimeHdrLine::truncateLine( __messageId + messageID ) );
155 useIO.outputMimeLine( mimeHdrLine::truncateLine( __inReplyTo + inReplyTo ) );
158 useIO.outputMimeLine( mimeHdrLine::truncateLine( __references + references ) );
162 useIO.outputMimeLine( __date + mDate );
164 mimeHeader::outputHeader( useIO );
168 mailHeader::parseAddressList (
const char *inCStr,
173 char *aCStr = (
char *) inCStr;
179 mailAddress *aAddress =
new mailAddress;
180 skip = aAddress->parseAddress( aCStr );
206 retVal += addr->getStr();
const QByteArray & getValue()
return the value
int lastIndexOf(char ch, int from) const
int count(const T &value) const
void append(const T &value)
QByteArray mid(int pos, int len) const
const QByteArray & getLabel()
return the label
QByteArray simplified() const