• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmail

KMMessage Class Reference

#include <kmmessage.h>

Inheritance diagram for KMMessage:

Inheritance graph
[legend]

List of all members.


Detailed Description

This is a Mime Message.

Definition at line 72 of file kmmessage.h.


Public Types

enum  HeaderFieldType { Unstructured, Structured, Address }

Public Member Functions

void addBodyPart (const KMMessagePart *aPart)
void addDwBodyPart (DwBodyPart *aDwPart)
void applyIdentity (uint id)
const DwMessage * asDwMessage ()
const DwString & asDwString () const
QString asPlainText (bool stripSignature, bool allowDecryption) const
QString asQuotedString (const QString &headerStr, const QString &indentStr, const QString &selection=QString(), bool aStripSignature=true, bool allowDecryption=true) const
QByteArray asSendableString () const
QByteArray asString () const
QString bcc () const
QByteArray body () const
QByteArray bodyDecoded () const
QByteArray bodyDecodedBinary () const
void bodyPart (int aIdx, KMMessagePart *aPart) const
QString bodyToUnicode (const QTextCodec *codec=0) const
QString cc () const
QString ccStrip () const
QByteArray charset () const
void cleanupHeader ()
const QTextCodec * codec () const
int contentTransferEncoding () const
QByteArray contentTransferEncodingStr () const
KMMessage * createDeliveryReceipt () const
DwBodyPart * createDWBodyPart (const KMMessagePart *aPart)
KMMessage * createForward (const QString &tmpl=QString())
QByteArray createForwardBody ()
KMMessage * createMDN (KMime::MDN::ActionMode a, KMime::MDN::DispositionType d, bool allowGUI=false, QList< KMime::MDN::DispositionModifier > m=QList< KMime::MDN::DispositionModifier >())
KMMessage * createRedirect (const QString &toStr)
KMMessage * createReply (KMail::ReplyStrategy replyStrategy=KMail::ReplySmart, const QString &selection=QString(), bool noQuote=false, bool allowDecryption=true, bool selectionIsBody=false, const QString &tmpl=QString())
int cte () const
QByteArray cteStr () const
time_t date () const
QString dateIsoStr () const
QByteArray dateShortStr () const
QString dateStr () const
void del ()
void deleteBodyParts ()
void deleteWhenUnused ()
QString drafts () const
DwBodyPart * dwBodyPart (int aIdx) const
DwMediaType & dwContentType ()
KMMsgEncryptionState encryptionState () const
KMime::Types::AddrSpecList extractAddrSpecs (const QByteArray &headerNames) const
QString fcc () const
QString fileName () const
DwBodyPart * findDwBodyPart (DwBodyPart *part, const QString &partSpecifier)
DwBodyPart * findDwBodyPart (const QByteArray &type, const QByteArray &subtype) const
DwBodyPart * findDwBodyPart (int type, int subtype) const
off_t folderOffset () const
QString formatString (const QString &) const
QString from () const
void fromDwString (const DwString &str, bool setStatus=false)
void fromString (const QByteArray &ba, bool setStatus=false)
QString fromStrip () const
int getCursorPos ()
DwBodyPart * getFirstDwBodyPart () const
void getLink (int n, ulong *retMsgSerNum, MessageStatus &retStatus) const
QByteArray getRefStr () const
DwMessage * getTopLevelPart () const
bool hasUnencryptedMsg () const
KMime::Types::AddressList headerAddrField (const QByteArray &name) const
QByteArray headerAsSendableString () const
QString headerAsString () const
QString headerField (const QByteArray &name) const
QStringList headerFields (const QByteArray &name) const
DwHeaders & headers () const
QByteArray id () const
uint identityUoid () const
void initFromMessage (const KMMessage *msg, bool idHeaders=true)
void initHeader (uint identity=0)
void initStrippedSubjectMD5 ()
bool isBeingParsed () const
bool isComplete () const
bool isMessage () const
bool isUrgent () const
 KMMessage (const KMMessage &other)
 KMMessage (KMMsgInfo &msgInfo)
 KMMessage (DwMessage *)
 KMMessage (KMFolder *parent=0)
DwBodyPart * lastUpdatedPart ()
void link (const KMMessage *aMsg, const MessageStatus &aStatus)
QByteArray mboxMessageSeparator ()
KMMsgMDNSentState mdnSentState () const
QString msgId () const
QString msgIdMD5 () const
size_t msgLength () const
size_t msgSize () const
size_t msgSizeServer () const
int numBodyParts () const
void parseTextStringFromDwPart (partNode *root, QByteArray &parsedString, const QTextCodec *&codec, bool &isHTML) const
int partNumber (DwBodyPart *aDwBodyPart) const
QByteArray rawHeaderField (const QByteArray &name) const
QList< QByteArray > rawHeaderFields (const QByteArray &field) const
bool readyToShow () const
QString references () const
void removeHeaderField (const QByteArray &name)
void removeHeaderFields (const QByteArray &name)
void removePrivateHeaderFields ()
QString replaceHeadersInString (const QString &s) const
QString replyTo () const
QString replyToAuxIdMD5 () const
QString replyToId () const
QString replyToIdMD5 () const
void sanitizeHeaders (const QStringList &whiteList=QStringList())
QString sender () const
void setAutomaticFields (bool isMultipart=false)
void setBcc (const QString &aStr)
void setBody (const QByteArray &aStr)
void setBodyAndGuessCte (const QByteArray &aBuf, QList< int > &allowedCte, bool allow8Bit=false, bool willBeSigned=false)
void setBodyEncoded (const QByteArray &aStr)
void setBodyEncodedBinary (const QByteArray &aStr)
void setBodyFromUnicode (const QString &str)
void setCc (const QString &aStr)
void setCharset (const QByteArray &aStr)
void setComplete (bool v)
void setContentTransferEncoding (int aCte)
void setContentTransferEncodingStr (const QByteArray &aStr)
void setContentTypeParam (const QByteArray &attr, const QByteArray &val)
void setCte (int aCte)
void setCteStr (const QByteArray &aStr)
void setCursorPos (int pos)
void setDate (time_t aUnixTime)
void setDate (const QByteArray &str)
void setDateToday ()
void setDecodeHTML (bool aDecodeHTML)
void setDrafts (const QString &aStr)
void setEncryptionState (const KMMsgEncryptionState, int idx=-1)
void setFcc (const QString &aStr)
void setFileName (const QString &file)
void setFolderOffset (off_t offs)
void setFrom (const QString &aStr)
void setHeaderField (const QByteArray &name, const QString &value, HeaderFieldType type=Unstructured, bool prepend=false)
void setIsBeingParsed (bool t)
void setMDNSentState (KMMsgMDNSentState status, int idx=-1)
void setMsgId (const QString &aStr)
void setMsgLength (size_t sz)
void setMsgSerNum (unsigned long newMsgSerNum=0)
void setMsgSize (size_t sz)
void setMsgSizeServer (size_t sz)
void setMultiPartBody (const QByteArray &aStr)
void setNeedsAssembly ()
void setOverrideCodec (const QTextCodec *codec)
void setReadyToShow (bool v)
void setReferences (const QByteArray &aStr)
void setReplyTo (KMMessage *)
void setReplyTo (const QString &aStr)
void setReplyToId (const QString &aStr)
void setSignatureState (const KMMsgSignatureState, int idx=-1)
void setStatus (const char *s1, const char *s2=0)
void setStatus (const MessageStatus &status, int idx=-1)
void setStatusFields ()
void setSubject (const QString &aStr)
void setSubtype (int aSubtype)
void setSubtypeStr (const QByteArray &aStr)
void setTemplates (const QString &aStr)
void setTo (const QString &aStr)
void setTransferInProgress (bool value, bool force=false)
void setType (int aType)
void setTypeStr (const QByteArray &aStr)
void setUID (ulong uid)
void setUnencryptedMsg (KMMessage *unencrypted)
void setXMark (const QString &aStr)
KMMsgSignatureState signatureState () const
MessageStatus & status ()
QString strippedSubjectMD5 () const
QString subject () const
bool subjectIsPrefixed () const
QString subjectMD5 () const
int subtype () const
QByteArray subtypeStr () const
virtual KMMessageTagList * tagList (void) const
virtual QString tagString (void) const
KMMessage * takeUnencryptedMsg ()
QString templates () const
QString to () const
const KMMsgBase & toMsgBase () const
KMMsgBase & toMsgBase ()
QString toStrip () const
void touch ()
bool transferInProgress () const
int type () const
QByteArray typeStr () const
ulong UID () const
void undel ()
KMMessage * unencryptedMsg () const
void updateAttachmentState (DwBodyPart *part=0)
void updateBodyPart (const QString partSpecifier, const QByteArray &data)
QString who () const
QString xmark () const
virtual ~KMMessage ()

Static Public Member Functions

static bool addressIsInAddressList (const QString &address, const QStringList &addresses)
static void bodyPart (DwBodyPart *aDwBodyPart, KMMessagePart *aPart, bool withBody=true)
static QString decodeMailtoUrl (const QString &url)
static QByteArray defaultCharset ()
static QList< int > determineAllowedCtes (const KMime::CharFreq &cf, bool allow8Bit, bool willBeSigned)
static QString emailAddrAsAnchor (const QString &emailAddr, bool stripped=true)
static QString encodeMailtoUrl (const QString &str)
static QString expandAliases (const QString &recipients)
static QString generateMessageId (const QString &addr)
static QString guessEmailAddressFromLoginName (const QString &userName)
static QByteArray html2source (const QByteArray &src)
static const QStringList & preferredCharsets ()
static QString quoteHtmlChars (const QString &str, bool removeLineBreaks=false)
static void readConfig ()
static void setDwMediaTypeParam (DwMediaType &mType, const QByteArray &attr, const QByteArray &val)
static QString smartQuote (const QString &msg, int maxLineLength)
static KMime::Types::AddressList splitAddrField (const QByteArray &str)
static QStringList stripAddressFromAddressList (const QString &address, const QStringList &addresses)
static QString stripEmailAddr (const QString &emailAddr)
static QByteArray stripEmailAddr (const QByteArray &emailAddr)
static QStringList stripMyAddressesFromAddressList (const QStringList &list)

Member Enumeration Documentation

enum KMMessage::HeaderFieldType

Enumerator:
Unstructured 
Structured 
Address 

Definition at line 423 of file kmmessage.h.


Constructor & Destructor Documentation

KMMessage::KMMessage ( KMFolder *  parent = 0  ) 

Straight forward initialization.

Definition at line 111 of file kmmessage.cpp.

KMMessage::KMMessage ( DwMessage *  aMsg  ) 

Constructor from a DwMessage.

KMMessage takes possession of the DwMessage, so don't dare to delete it.

Definition at line 102 of file kmmessage.cpp.

KMMessage::KMMessage ( KMMsgInfo &  msgInfo  ) 

Copy constructor.

Does *not* automatically load the message.

Definition at line 118 of file kmmessage.cpp.

KMMessage::KMMessage ( const KMMessage &  other  ) 

Copy constructor.

Definition at line 143 of file kmmessage.cpp.

KMMessage::~KMMessage (  )  [virtual]

Destructor.

Definition at line 221 of file kmmessage.cpp.


Member Function Documentation

void KMMessage::addBodyPart ( const KMMessagePart *  aPart  ) 

Append a body part to the message.

Definition at line 3240 of file kmmessage.cpp.

void KMMessage::addDwBodyPart ( DwBodyPart *  aDwPart  ) 

Append a DwBodyPart to the message.

Definition at line 3232 of file kmmessage.cpp.

bool KMMessage::addressIsInAddressList ( const QString &  address,
const QStringList &  addresses 
) [static]

Returns true if the given address is contained in the given address list.

Definition at line 3795 of file kmmessage.cpp.

void KMMessage::applyIdentity ( uint  id  ) 

Set the from, to, cc, bcc, encrytion etc headers as specified in the given identity.

Definition at line 1643 of file kmmessage.cpp.

const DwMessage * KMMessage::asDwMessage (  ) 

Definition at line 313 of file kmmessage.cpp.

const DwString & KMMessage::asDwString (  )  const

Return the entire message contents in the DwString.

This function is *fast* even for large message since it does *not* involve a string copy.

Definition at line 302 of file kmmessage.cpp.

QString KMMessage::asPlainText ( bool  stripSignature,
bool  allowDecryption 
) const

Return the textual content of the message as plain text, converting HTML to plain text if necessary.

Definition at line 754 of file kmmessage.cpp.

QString KMMessage::asQuotedString ( const QString &  headerStr,
const QString &  indentStr,
const QString &  selection = QString(),
bool  aStripSignature = true,
bool  allowDecryption = true 
) const

Returns message body with quoting header and indented by the given indentation string.

This is suitable for including the message in another message of for replies, forwards. The header string is a template where the following fields are replaced with the corresponding values:

        D: date of this message
        S: subject of this message
        F: sender (from) of this message
        %%: a single percent sign
    
No attachments are handled if includeAttach is false. The signature is stripped if aStripSignature is true and smart quoting is turned on. Signed or encrypted texts get converted to plain text when allowDecryption is true.

Definition at line 831 of file kmmessage.cpp.

QByteArray KMMessage::asSendableString (  )  const

Return the message contents with the headers that should not be sent stripped off.

Definition at line 329 of file kmmessage.cpp.

QByteArray KMMessage::asString (  )  const

Return the entire message contents as a string.

This function is slow for large message since it involves a string copy. If you need the string representation only for a short time (i.e. without the chance of calling any function in the underlying mimelib, then you should use the asDwString function.

See also:
asDwString

Definition at line 324 of file kmmessage.cpp.

QString KMMessage::bcc (  )  const

Get or set the 'Bcc' header field.

Definition at line 1957 of file kmmessage.cpp.

QByteArray KMMessage::body (  )  const

Get the message body.

Does not decode the body.

Definition at line 2550 of file kmmessage.cpp.

QByteArray KMMessage::bodyDecoded (  )  const

Returns a decoded version of the body from the current content transfer encoding.

The first method returns a null terminated string, the second method is meant for binary data, not null is appended

Definition at line 2587 of file kmmessage.cpp.

QByteArray KMMessage::bodyDecodedBinary (  )  const

Definition at line 2561 of file kmmessage.cpp.

void KMMessage::bodyPart ( int  aIdx,
KMMessagePart *  aPart 
) const

Get the body part at position in aIdx.

Indexing starts at 0. If there is no body part at that index, aPart will have its attributes set to empty values.

Definition at line 3076 of file kmmessage.cpp.

void KMMessage::bodyPart ( DwBodyPart *  aDwBodyPart,
KMMessagePart *  aPart,
bool  withBody = true 
) [static]

Fill the KMMessagePart structure for a given DwBodyPart.

If withBody is false the body of the KMMessagePart will be left empty and only the headers of the part will be filled in

Definition at line 3025 of file kmmessage.cpp.

QString KMMessage::bodyToUnicode ( const QTextCodec *  codec = 0  )  const

Returns the body part decoded to unicode.

Definition at line 4283 of file kmmessage.cpp.

QString KMMessage::cc (  )  const

Get or set the 'Cc' header field.

Definition at line 1929 of file kmmessage.cpp.

QString KMMessage::ccStrip (  )  const

Definition at line 1950 of file kmmessage.cpp.

QByteArray KMMessage::charset (  )  const

Get the message charset.

Definition at line 3947 of file kmmessage.cpp.

void KMMessage::cleanupHeader (  ) 

Removes empty fields from the header, e.g.

an empty Cc: or Bcc: field.

Definition at line 1742 of file kmmessage.cpp.

const QTextCodec * KMMessage::codec (  )  const

Get a QTextCodec suitable for this message part.

Definition at line 4262 of file kmmessage.cpp.

int KMMessage::contentTransferEncoding (  )  const

Definition at line 2509 of file kmmessage.cpp.

QByteArray KMMessage::contentTransferEncodingStr (  )  const

Get or set the 'Content-Transfer-Encoding' header field The member functions that involve enumerated types (ints) will work only for well-known encodings.

Definition at line 2499 of file kmmessage.cpp.

KMMessage * KMMessage::createDeliveryReceipt (  )  const

Create a new message that is a delivery receipt of this message, filling required header fileds with the proper values.

The returned message is not stored in any folder.

Definition at line 1616 of file kmmessage.cpp.

DwBodyPart * KMMessage::createDWBodyPart ( const KMMessagePart *  aPart  ) 

Compose a DwBodyPart (needed for adding a part to the message).

Definition at line 3097 of file kmmessage.cpp.

KMMessage * KMMessage::createForward ( const QString &  tmpl = QString()  ) 

Create a new message that is a forward of this message, filling all required header fields with the proper values.

The returned message is not stored in any folder. Marks this message as forwarded.

Definition at line 1211 of file kmmessage.cpp.

QByteArray KMMessage::createForwardBody (  ) 

Create the forwarded body for the message.

Definition at line 1170 of file kmmessage.cpp.

KMMessage* KMMessage::createMDN ( KMime::MDN::ActionMode  a,
KMime::MDN::DispositionType  d,
bool  allowGUI = false,
QList< KMime::MDN::DispositionModifier >  m = QList< KMime::MDN::DispositionModifier >() 
)

Create a new message that is a MDN for this message, filling all required fields with proper values.

The returned message is not stored in any folder.

Parameters:
a Use AutomaticAction for filtering and ManualAction for user-induced events.
d See docs for KMime::MDN::DispositionType
m See docs for KMime::MDN::DispositionModifier
allowGUI Set to true if this method is allowed to ask the user questions
Returns:
The notification message or 0, if none should be sent.

KMMessage * KMMessage::createRedirect ( const QString &  toStr  ) 

Create a new message that is a redirect to this message, filling all required header fields with the proper values.

The returned message is not stored in any folder. Marks this message as replied. Redirects differ from forwards so they are forwarded to some other user, mail is not changed and the reply-to field is set to the email address of the original sender

Definition at line 1119 of file kmmessage.cpp.

KMMessage * KMMessage::createReply ( KMail::ReplyStrategy  replyStrategy = KMail::ReplySmart,
const QString &  selection = QString(),
bool  noQuote = false,
bool  allowDecryption = true,
bool  selectionIsBody = false,
const QString &  tmpl = QString() 
)

Create a new message that is a reply to this message, filling all required header fields with the proper values.

The returned message is not stored in any folder. Marks this message as replied.

Definition at line 859 of file kmmessage.cpp.

int KMMessage::cte (  )  const [inline]

Definition at line 503 of file kmmessage.h.

QByteArray KMMessage::cteStr (  )  const [inline]

Cte is short for ContentTransferEncoding.

These functions are an alternative to the ones with longer names.

Definition at line 502 of file kmmessage.h.

time_t KMMessage::date ( void   )  const [virtual]

Implements KMMsgBase.

Definition at line 1837 of file kmmessage.cpp.

QString KMMessage::dateIsoStr (  )  const

Definition at line 1822 of file kmmessage.cpp.

QByteArray KMMessage::dateShortStr (  )  const

Returns the message date in asctime format or an empty string if the message lacks a Date header.

Definition at line 1804 of file kmmessage.cpp.

QString KMMessage::dateStr ( void   )  const [virtual]

Get or set the 'Date' header field.

Reimplemented from KMMsgBase.

Definition at line 1785 of file kmmessage.cpp.

QString KMMessage::decodeMailtoUrl ( const QString &  url  )  [static]

Decodes a mailto URL.

Definition at line 3357 of file kmmessage.cpp.

QByteArray KMMessage::defaultCharset (  )  [static]

Get the default message charset.

Definition at line 3924 of file kmmessage.cpp.

void KMMessage::del (  )  [inline]

Mark the message as deleted.

Definition at line 151 of file kmmessage.h.

void KMMessage::deleteBodyParts (  ) 

Delete all body parts.

Definition at line 3091 of file kmmessage.cpp.

void KMMessage::deleteWhenUnused (  ) 

Delete this message as soon as it no longer in use.

Definition at line 4311 of file kmmessage.cpp.