25 #include "mailaddress.h"
26 #include "rfcdecoder.h"
27 #include "mimehdrline.h"
28 #include <kmime_util.h>
30 mailAddress::mailAddress ()
34 mailAddress::mailAddress (
const mailAddress & lr):
37 rawFullName (lr.rawFullName),
38 rawComment (lr.rawComment)
43 mailAddress & mailAddress::operator = (
const mailAddress & lr)
51 rawFullName = lr.rawFullName;
52 rawComment = lr.rawComment;
62 mailAddress::~mailAddress ()
66 mailAddress::mailAddress (
char *aCStr)
72 mailAddress::parseAddress (
char *aCStr)
96 rawFullName += TQCString (aCStr, advance + 1);
100 rawComment += TQCString (aCStr, advance + 1);
104 user = TQCString (aCStr, advance + 1);
106 user = user.mid (1, len - 2);
109 host = user.right (len - pt - 1);
119 rawFullName += TQCString (aCStr, advance + 1);
149 if (rawFullName.isEmpty ())
162 else if (user.isEmpty ())
164 pt = rawFullName.find (
'@');
168 host = user.right (user.length () - pt - 1);
170 rawFullName.truncate(0);
176 if (!rawFullName.isEmpty ())
184 if (!rawComment.isEmpty ())
186 if (rawComment[0] ==
'(')
187 rawComment = rawComment.mid (1, rawComment.length () - 2);
188 rawComment = rawComment.stripWhiteSpace ();
200 mailAddress::getStr ()
const
202 TQCString retVal(128);
204 if (!rawFullName.isEmpty ())
206 TQCString tmpName( rawFullName );
207 KMime::addQuotes( tmpName,
false );
208 retVal = tmpName +
" ";
210 if (!user.isEmpty ())
214 if (!host.isEmpty ()) {
220 if (!rawComment.isEmpty ())
222 retVal +=
" (" + rawComment +
')';
229 mailAddress::isEmpty ()
const
231 return user.isEmpty ();
235 mailAddress::setFullName (
const TQString & _str)
240 mailAddress::getFullName ()
const
246 mailAddress::setCommentRaw (
const TQCString & _str)
252 mailAddress::setComment (
const TQString & _str)
257 mailAddress::getComment ()
const
263 mailAddress::getCommentRaw ()
const
269 mailAddress::emailAddrAsAnchor (
const mailAddress & adr,
bool shortAdr)
272 if (!adr.getFullName ().isEmpty ())
275 retVal += adr.getFullName () +
" ";
277 if (!adr.getUser ().isEmpty () && !shortAdr)
279 retVal +=
"<" + adr.getUser ();
280 if (!adr.getHost ().isEmpty ())
281 retVal +=
"@" + adr.getHost ();
284 if (!adr.getComment ().isEmpty ())
287 retVal =
'(' + adr.getComment () +
')';
290 if (!adr.getUser ().isEmpty ())
293 mail = adr.getUser ();
294 if (!mail.isEmpty () && !adr.getHost ().isEmpty ())
295 mail +=
"@" + adr.getHost ();
296 if (!mail.isEmpty ())
297 retVal =
"<A HREF=\"mailto:" + mail +
"\">" + retVal +
"</A>";
303 mailAddress::emailAddrAsAnchor (
const TQPtrList < mailAddress > &list,
bool value)
306 TQPtrListIterator < mailAddress > it (list);
308 while (it.current ())
310 retVal += emailAddrAsAnchor ((*it.current ()), value) +
"<BR></BR>\n";
318 void mailAddress::clear() {
321 rawFullName.truncate(0);
322 rawComment.truncate(0);
static int parseWord(const char *)
slurp one word
static int skipWS(const char *)
skip all white space characters
static int parseQuoted(char, char, const char *)
slurp one word
static const TQString decodeRFC2047String(const TQString &_str, TQString &charset, TQString &language)
decode a RFC2047 String
static const TQString encodeRFC2047String(const TQString &_str, TQString &charset, TQString &language)
encode a RFC2047 String