Mail Class Reference

This class represents a mail. More...

#include <mail.h>

List of all members.

Public Member Functions

 Mail (long number, const QString &unid, bool isNew, QPointer< Account > account, QObject *parent)
 Mail (const Mail &mail)
 ~Mail ()
Mailoperator= (const Mail &other)
void setSize (long size)
void setNumber (int number)
void print () const
QString getSubject () const
QString getUNID () const
long getSize () const
int getNumber () const
void setNew (bool isnew)
bool isNew () const
void setHeader (const QStringList &header)
QStringList getHeader () const
void setSubject (const QString &subject)
void setFrom (const QString &from)
void setTo (const QString &to)
void setDate (const QString &date)
KDateTime getDateTime () const
void setContent (const QString &content)
QString getContent () const
QPointer< AccountgetAccount () const
QString getFrom () const
QString getTo () const
QString getSizeSuffix () const
FilterAction_Type applyHeaderFilter (HeaderFilter *filter, QString account, QString &mailbox, FilterLog *log=NULL)
void save (QDomDocument &doc, QDomElement &parent)
bool isMarkedByFilter () const
QStringList decodeMailBody (const QStringList &body, bool preferHTML, bool &isHTML) const
QString getBoundary () const
QString getCharsetFromHeader () const
QString getTransferEncodingFromHeader () const
void writeToMoveLog (FilterLog *log, QString account, QString mailbox)
void writeToDeleteLog (FilterLog *log, QString account, KindOfMailDeleting kindDelete)
void setMarkAtNextViewRefresh ()
int compare (const Mail &other, MailSort_Type property)
QString getAccountName () const
QString getFilterName () const
void setFilterName (QString filter)

Protected Member Functions

void init ()
QString scanHeader (const QString &item) const
QString scanBodyPart (const QStringList &part, const QString &item) const
QString decodeRfc2047 (const QString &text) const
 Decodes a rfc2047 encoded string.
QString getCharset (const QStringList &text) const
QString getTransferEncoding (const QStringList &text) const
QStringList trim (QStringList text) const
void print (QStringList text) const

Private Attributes

QString unid
QString subject
QStringList header
long size
int number
bool _new
QString from
QString to
KDateTime sendDate
QString contentType
bool markedByFilter
QPointer< Accountacc
QString accountName
QString filterName

Detailed Description

This class represents a mail.

Definition at line 51 of file mail.h.


Constructor & Destructor Documentation

Mail::Mail ( long  number,
const QString &  unid,
bool  isNew,
QPointer< Account account,
QObject *  parent 
)

Constructor

Parameters:
number number of the mail on the server
Parameters:
unid Unique ID of the mail
Parameters:
isNew TRUE - mail is new; FALSE - mail is not new
Parameters:
account pointer to the parent account
Parameters:
parent parent object

Definition at line 20 of file mail.cpp.

Mail::Mail ( const Mail mail  ) 

Copy Constructor

Parameters:
mail source mail

Definition at line 33 of file mail.cpp.

Mail::~Mail (  ) 

Destructor

Definition at line 41 of file mail.cpp.


Member Function Documentation

FilterAction_Type Mail::applyHeaderFilter ( HeaderFilter filter,
QString  account,
QString &  mailbox,
FilterLog log = NULL 
)

Looks for a filter matching the mail header and returns the action recommend by this filter. If the action is MARK, it set markAtViewRefresh to True so the related view entry will be marked at the next view refresh.

Parameters:
filter pointer to the header filter
Parameters:
account name of the account
Parameters:
mailbox reference to a QString object in which the mailbox name shall be written if the action is MOVE
Parameters:
log pointer to the filter log
Returns:
recommend action
See also:
FilterAction_Type
HeaderFilter
markAtViewRefresh

Definition at line 403 of file mail.cpp.

int Mail::compare ( const Mail other,
MailSort_Type  property 
)

Compares this mail with other and returns an integer less than, equal to, or greater than zero if this mail is less than, equal to, or greater than other.

Parameters:
other other mail
Parameters:
property the mail property which will be compared

Definition at line 822 of file mail.cpp.

QStringList Mail::decodeMailBody ( const QStringList &  body,
bool  preferHTML,
bool &  isHTML 
) const

Decodes the given mail body. The mail object has to do this job, because it has stored the mail header and therefore it knows the content type and encoding of the mail. It decodes just the text or html part of the body. The rest of it will be rejected.

Parameters:
body the encoded mail (including header)
Parameters:
preferHTML decode HTML part if present
Parameters:
isHTML will be set on true, if the returned body is HTML formatted; otherwise false
Returns:
decoded mail body

Definition at line 451 of file mail.cpp.

QString Mail::decodeRfc2047 ( const QString &  text  )  const [protected]

Decodes a rfc2047 encoded string.

Parameters:
text text to encode

Definition at line 224 of file mail.cpp.

QPointer< Account > Mail::getAccount (  )  const

Returns a pointer to the account which contains this mail.

Returns:
account

Definition at line 357 of file mail.cpp.

QString Mail::getAccountName (  )  const

Returns the name of the parent account.

Returns:
name of the parent account
See also:
accountName

Definition at line 897 of file mail.cpp.

QString Mail::getBoundary (  )  const

Returns the boundary, if the mail has a multi part body. Otherwise it returns an empty string.

Returns:
boundary

Definition at line 686 of file mail.cpp.

QString Mail::getCharset ( const QStringList &  text  )  const [protected]

Returns the charset of the given header or body part.

It looks for the charset tag and returns the string behind this.

Parameters:
text body part or header
Returns:
charset string

Definition at line 727 of file mail.cpp.

QString Mail::getCharsetFromHeader (  )  const

Returns the char set of the content (e.g. iso-8859-1) from the header. If no char set is denoted, it will returns an empty string.

Returns:
charset

Definition at line 722 of file mail.cpp.

QString Mail::getContent (  )  const

Returns the content type.

Returns:
content type

Definition at line 398 of file mail.cpp.

KDateTime Mail::getDateTime (  )  const

Returns the datetime of mail send

Definition at line 393 of file mail.cpp.

QString Mail::getFilterName (  )  const

Returns the name of the filter which has caught this mail.

Returns:
name of the filter which has caught this mail

Definition at line 963 of file mail.cpp.

QString Mail::getFrom (  )  const

Returns the sender address.

Returns:
sender address

Definition at line 362 of file mail.cpp.

QStringList Mail::getHeader (  )  const

Returns the header

Returns:
mail header

Definition at line 219 of file mail.cpp.

int Mail::getNumber (  )  const

Returns the number of this mail on the server

Returns:
number

Definition at line 78 of file mail.cpp.

long Mail::getSize (  )  const

Returns the size of this mail

Returns:
mail size (Bytes)

Definition at line 73 of file mail.cpp.

QString Mail::getSizeSuffix (  )  const

Returns the mails size as string with suffix

Definition at line 372 of file mail.cpp.

QString Mail::getSubject (  )  const

Returns the subject

Returns:
subject

Definition at line 63 of file mail.cpp.

QString Mail::getTo (  )  const

Returns the addressee.

Returns:
the addressee

Definition at line 367 of file mail.cpp.

QString Mail::getTransferEncoding ( const QStringList &  text  )  const [protected]

Returns the transfer encoding of the given header or body part.

It looks for the transfer encoding tag and returns the string behind this.

Parameters:
text body part or header
Returns:
charset string

Definition at line 800 of file mail.cpp.

QString Mail::getTransferEncodingFromHeader (  )  const

Returns the transfer encoding string from the header if existing. Otherwise it returns an empty string.

Returns:
transfer encoding

Definition at line 795 of file mail.cpp.

QString Mail::getUNID (  )  const

Returns the UNID.

Returns:
UNID

Definition at line 68 of file mail.cpp.

void Mail::init (  )  [protected]

Initiates the object

Definition at line 88 of file mail.cpp.

bool Mail::isMarkedByFilter (  )  const

Returns whether this mail was marked by filter.

Returns:
TRUE - marked; FALSE - not marked

Definition at line 446 of file mail.cpp.

bool Mail::isNew (  )  const

Returns whether the mail is new or not.

Returns:
TRUE - mail is new
FALSE - mail is not new

Definition at line 99 of file mail.cpp.

Mail & Mail::operator= ( const Mail other  ) 

Assign operator

Parameters:
other other mail

Definition at line 902 of file mail.cpp.

void Mail::print ( QStringList  text  )  const [protected]

Prints the given text to StdOut.

Parameters:
text Text to print

Definition at line 955 of file mail.cpp.

void Mail::print (  )  const

Prints the data of this mail to stdout

Definition at line 50 of file mail.cpp.

void Mail::save ( QDomDocument &  doc,
QDomElement &  parent 
)

Creates a new DOM element in the given DOM document and add it to given DOM parent element

Parameters:
doc the DOM document in that all options are stored
Parameters:
parent the parent element (account) of the mail

Definition at line 422 of file mail.cpp.

QString Mail::scanBodyPart ( const QStringList &  part,
const QString &  item 
) const [protected]

Searches in the given body part for a line which starts with the given item. For example: scanBodyPart( "Content-Transfer-Encoding") will find the line "Content-Transfer-Encoding: 7bit" and returns "7bit" Returns an empty string (""), if nothing was found.

Parameters:
part the body part
Parameters:
item the search item
Returns:
the content of the found line

Definition at line 167 of file mail.cpp.

QString Mail::scanHeader ( const QString &  item  )  const [protected]

Searches in the header for a line which starts with the given item. For example: scanHeader( "From") will find the line "From: Ulrich Weigelt <ulrich.weigelt@gmx.de>" and returns "Ulrich Weigelt <ulrich.weigelt@gmx.de>" Returns an empty string (""), if nothing was found.

Parameters:
item the search item
Returns:
the content of the found line

Definition at line 143 of file mail.cpp.

void Mail::setContent ( const QString &  content  ) 

Sets the given string as content type.

Parameters:
content the content type

Definition at line 214 of file mail.cpp.

void Mail::setDate ( const QString &  date  ) 

Converts the given string to a date-time value and stores it.

Parameters:
date the date

Definition at line 207 of file mail.cpp.

void Mail::setFilterName ( QString  filter  ) 

Sets the name of the filter which has caught this mail

Parameters:
filter name of the filter

Definition at line 968 of file mail.cpp.

void Mail::setFrom ( const QString &  from  ) 

Sets the given string as sender address

Parameters:
from sender address

Definition at line 197 of file mail.cpp.

void Mail::setHeader ( const QStringList &  header  ) 

Sets the mail header and extracts From, To, Subject, Date and Content Type. All parts of the header are coded according RFC 2047.

Parameters:
header the mail header

Definition at line 104 of file mail.cpp.

void Mail::setMarkAtNextViewRefresh (  ) 

The mail will be marked at the next view refresh.

Definition at line 812 of file mail.cpp.

void Mail::setNew ( bool  isnew  ) 

Sets whether the mail is new or not.

Parameters:
isnew TRUE - mail is new; FALSE - mail is not new

Definition at line 94 of file mail.cpp.

void Mail::setNumber ( int  number  ) 

Sets the number.

Parameters:
number the number

Definition at line 83 of file mail.cpp.

void Mail::setSize ( long  size  ) 

Sets the size

Parameters:
size mail size (Bytes)

Definition at line 45 of file mail.cpp.

void Mail::setSubject ( const QString &  subject  ) 

Sets the given string as subject

Parameters:
subject the mail subject

Definition at line 192 of file mail.cpp.

void Mail::setTo ( const QString &  to  ) 

Sets the given string as recipient address

Parameters:
to recipient address

Definition at line 202 of file mail.cpp.

QStringList Mail::trim ( QStringList  text  )  const [protected]

Removes all empty lines at begin and at end of text

Parameters:
text the text which shall be trimmed
Returns:
the text without empty lines at begin and at end

Definition at line 934 of file mail.cpp.

void Mail::writeToDeleteLog ( FilterLog log,
QString  account,
KindOfMailDeleting  kindDelete 
)

Writes this mail into the Delete Log.

Parameters:
log pointer to the log
Parameters:
account name of the account
Parameters:
kindDelete kind of mail deleting (by filter or manual)

Definition at line 817 of file mail.cpp.

void Mail::writeToMoveLog ( FilterLog log,
QString  account,
QString  mailbox 
)

Writes this mail into the Move Log.

Parameters:
log pointer to the log
Parameters:
account name of the account
Parameters:
mailbox name of the mailbox

Definition at line 807 of file mail.cpp.


Member Data Documentation

bool Mail::_new [private]

It is set to TRUE when the mail is new.

Definition at line 363 of file mail.h.

QPointer<Account> Mail::acc [private]

Pointer to the parent account

Definition at line 394 of file mail.h.

QString Mail::accountName [private]

Name of the parent account

Definition at line 399 of file mail.h.

QString Mail::contentType [private]

The content type

Definition at line 383 of file mail.h.

QString Mail::filterName [private]

The name of the filter which has caught this mail

Definition at line 404 of file mail.h.

QString Mail::from [private]

The sender address

Definition at line 368 of file mail.h.

QStringList Mail::header [private]

Header

Definition at line 348 of file mail.h.

bool Mail::markedByFilter [private]

TRUE - the mail was marked by the filter. It will be set to True by applyHeaderFilter() if the recommend filter action is MARK.

Definition at line 389 of file mail.h.

int Mail::number [private]

Number of this mail on the server

Definition at line 358 of file mail.h.

KDateTime Mail::sendDate [private]

The date on which the mail was sent

Definition at line 378 of file mail.h.

long Mail::size [private]

Size (Bytes)

Definition at line 353 of file mail.h.

QString Mail::subject [private]

Subject

Definition at line 343 of file mail.h.

QString Mail::to [private]

The addressee

Definition at line 373 of file mail.h.

QString Mail::unid [private]

UNID of this mail

Definition at line 338 of file mail.h.


The documentation for this class was generated from the following files:
Generated on Sun Mar 13 15:27:10 2011 for KShowmail by  doxygen 1.6.3