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) const
QString getBoundary () const
QString getCharsetFromHeader () const
QString getTransferEncodingFromHeader () const
void writeToMoveLog (FilterLog *log, QString account, QString mailbox)
void writeToDeleteLog (FilterLog *log, QString account)
void setMarkAtNextViewRefresh ()
int compare (const Mail &other, MailSort_Type property)
QString getAccountName () const

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


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
unid Unique ID of the mail
isNew TRUE - mail is new; FALSE - mail is not new
account pointer to the parent account
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

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

Assign operator

Parameters:
other other mail

Definition at line 852 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::setNumber ( int  number  ) 

Sets the number.

Parameters:
number the number

Definition at line 83 of file mail.cpp.

void Mail::print (  )  const

Prints the data of this mail to stdout

Definition at line 50 of file mail.cpp.

QString Mail::getSubject (  )  const

Returns the subject

Returns:
subject

Definition at line 63 of file mail.cpp.

QString Mail::getUNID (  )  const

Returns the UNID.

Returns:
UNID

Definition at line 68 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.

int Mail::getNumber (  )  const

Returns the number of this mail on the server

Returns:
number

Definition at line 78 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.

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.

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.

QStringList Mail::getHeader (  )  const

Returns the header

Returns:
mail header

Definition at line 219 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::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::setTo ( const QString &  to  ) 

Sets the given string as recipient address

Parameters:
to recipient address

Definition at line 202 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.

KDateTime Mail::getDateTime (  )  const

Returns the datetime of mail send

Definition at line 393 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.

QString Mail::getContent (  )  const

Returns the content type.

Returns:
content type

Definition at line 398 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::getFrom (  )  const

Returns the sender address.

Returns:
sender address

Definition at line 362 of file mail.cpp.

QString Mail::getTo (  )  const

Returns the addressee.

Returns:
the addressee

Definition at line 367 of file mail.cpp.

QString Mail::getSizeSuffix (  )  const

Returns the mails size as string with suffix

Definition at line 372 of file mail.cpp.

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
account name of the account
mailbox reference to a QString object in which the mailbox name shall be written if the action is MOVE
log pointer to the filter log
Returns:
recommend action
See also:
FilterAction_Type

HeaderFilter

markAtViewRefresh

Definition at line 403 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
parent the parent element (account) of the mail

Definition at line 422 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.

QStringList Mail::decodeMailBody ( const QStringList &  body,
bool  preferHTML 
) 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)
preferHTML decode HTML part if present
Returns:
decoded mail body

Definition at line 451 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 661 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 697 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 745 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
account name of the account
mailbox name of the mailbox

Definition at line 757 of file mail.cpp.

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

Writes this mail into the Delete Log.

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

Definition at line 767 of file mail.cpp.

void Mail::setMarkAtNextViewRefresh (  ) 

The mail will be marked at the next view refresh.

Definition at line 762 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
property the mail property which will be compared

Definition at line 772 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 847 of file mail.cpp.

void Mail::init (  )  [protected]

Initiates the object

Definition at line 88 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.

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
item the search item
Returns:
the content of the found line

Definition at line 167 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.

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 702 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 750 of file mail.cpp.


The documentation for this class was generated from the following files:

Generated on Tue May 18 19:43:53 2010 for KShowmail by  doxygen 1.5.6