KMime::Message

Search for usage in LXR

#include <kmime_message.h>

Inheritance diagram for KMime::Message:

Public Types

typedef QSharedPointer< MessagePtr
 
- Public Types inherited from KMime::Content
typedef QList< KMime::Content * > List
 

Public Member Functions

 Message ()
 
 ~Message () override
 
const KMime::Headers::Bccbcc () const
 
KMime::Headers::Bccbcc (bool create=true)
 
const KMime::Headers::Cccc () const
 
KMime::Headers::Cccc (bool create=true)
 
const KMime::Headers::Datedate () const
 
KMime::Headers::Datedate (bool create=true)
 
const KMime::Headers::Fromfrom () const
 
KMime::Headers::Fromfrom (bool create=true)
 
const KMime::Headers::InReplyToinReplyTo () const
 
KMime::Headers::InReplyToinReplyTo (bool create=true)
 
ContentmainBodyPart (const QByteArray &type=QByteArray())
 
const ContentmainBodyPart (const QByteArray &type=QByteArray()) const
 
const KMime::Headers::MessageIDmessageID () const
 
KMime::Headers::MessageIDmessageID (bool create=true)
 
const KMime::Headers::Organizationorganization () const
 
KMime::Headers::Organizationorganization (bool create=true)
 
const KMime::Headers::Referencesreferences () const
 
KMime::Headers::Referencesreferences (bool create=true)
 
const KMime::Headers::ReplyToreplyTo () const
 
KMime::Headers::ReplyToreplyTo (bool create=true)
 
const KMime::Headers::Sendersender () const
 
KMime::Headers::Sendersender (bool create=true)
 
const KMime::Headers::Subjectsubject () const
 
KMime::Headers::Subjectsubject (bool create=true)
 
const KMime::Headers::Toto () const
 
KMime::Headers::Toto (bool create=true)
 
const KMime::Headers::UserAgentuserAgent () const
 
KMime::Headers::UserAgentuserAgent (bool create=true)
 
- Public Member Functions inherited from KMime::Content
 Content (Content *parent=nullptr)
 
virtual ~Content ()
 
void appendContent (Content *content)
 
void appendHeader (Headers::Base *h)
 
void assemble ()
 
QList< Content * > attachments () const
 
QByteArray body () const
 
QSharedPointer< MessagebodyAsMessage () const
 
bool bodyIsMessage () const
 
void changeEncoding (Headers::contentEncoding e)
 
void clear ()
 
void clearContents (bool del=true)
 
Contentcontent (const ContentIndex &index) const
 
const Headers::ContentDescriptioncontentDescription () const
 
Headers::ContentDescriptioncontentDescription (bool create=true)
 
const Headers::ContentDispositioncontentDisposition () const
 
Headers::ContentDispositioncontentDisposition (bool create=true)
 
const Headers::ContentIDcontentID () const
 
Headers::ContentIDcontentID (bool create=true)
 
const Headers::ContentLocationcontentLocation () const
 
Headers::ContentLocationcontentLocation (bool create=true)
 
QList< Content * > contents () const
 
const Headers::ContentTransferEncodingcontentTransferEncoding () const
 
Headers::ContentTransferEncodingcontentTransferEncoding (bool create=true)
 
const Headers::ContentTypecontentType () const
 
Headers::ContentTypecontentType (bool create=true)
 
QByteArray decodedContent () const
 
QString decodedText (bool trimText=false, bool removeTrailingNewlines=false)
 
QByteArray encodedBody () const
 
QByteArray encodedContent (bool useCrLf=false) const
 
QByteArray epilogue () const
 
void fromUnicodeString (const QString &s)
 
bool hasContent () const
 
bool hasHeader (const char *type) const
 
QByteArray head () const
 
template<typename T >
T * header () const
 
template<typename T >
T * header (bool create=false)
 
Headers::BaseheaderByType (const char *type) const
 
QList< Headers::Base * > headers () const
 
QList< Headers::Base * > headersByType (const char *type) const
 
ContentIndex index () const
 
ContentIndex indexForContent (Content *content) const
 
bool isFrozen () const
 
bool isTopLevel () const
 
Contentparent ()
 
const Contentparent () const
 
void parse ()
 
QByteArray preamble () const
 
void prependContent (Content *content)
 
template<typename T >
bool removeHeader ()
 
bool removeHeader (const char *type)
 
void replaceContent (Content *oldContent, Content *newContent)
 
void setBody (const QByteArray &body)
 
void setContent (const QByteArray &s)
 
void setEpilogue (const QByteArray &epilogue)
 
void setFrozen (bool frozen=true)
 
void setHead (const QByteArray &head)
 
void setHeader (Headers::Base *h)
 
void setParent (Content *parent)
 
void setPreamble (const QByteArray &preamble)
 
int size () const
 
int storageSize () const
 
ContenttakeContent (Content *content)
 
ContenttextContent ()
 
const ContenttextContent () const
 
ContenttopLevel ()
 
const ContenttopLevel () const
 

Static Public Member Functions

static QString mimeType ()
 
- Static Public Member Functions inherited from KMime::Content
static QByteArray defaultCharset ()
 

Protected Member Functions

QByteArray assembleHeaders () override
 

Detailed Description

Represents a (email) message.

Sample how to create a multipart message:

// Set the multipart message.
Message *m = new Message;
Headers::ContentType *ct = m->contentType();
ct->setMimeType( "multipart/mixed" );
ct->setBoundary( multiPartBoundary() );
Headers::ContentTransferEncoding *cte = m->contentTransferEncoding();
cte->setEncoding(Headers::CE7Bit);
cte->setDecoded(true);
// Set the headers.
m->from()->fromUnicodeString( "some@mailaddy.com", "utf-8" );
m->to()->fromUnicodeString( "someother@mailaddy.com", "utf-8" );
m->cc()->fromUnicodeString( "some@mailaddy.com", "utf-8" );
m->date()->setDateTime( QDateTime::currentLocalDateTime() );
m->subject()->fromUnicodeString( "My Subject", "utf-8" );
// Set the first multipart, the body message.
b->contentType()->setMimeType( "text/plain" );
b->setBody( "Some text..." );
// Set the second multipart, the attachment.
d->setFilename( "cal.ics" );
d->setDisposition( KMime::Headers::CDattachment );
a->contentType()->setMimeType( "text/plain" );
a->setHeader( d );
a->setBody( "Some text in the attachment..." );
// Attach the both multiparts and assemble the message.
m->appendContent( b );
m->appendContent( a );
m->assemble();
A class that encapsulates MIME encoded Content.
Headers::ContentType * contentType(bool create=true)
Returns the Content-Type header.
void setHeader(Headers::Base *h)
Sets the specified header to this Content.
void setBody(const QByteArray &body)
Sets the Content body raw data.
Represents a "Content-Disposition" header.
void setDisposition(contentDisposition disp)
Sets the content disposition.
void setFilename(const QString &filename)
Sets the suggested filename for the associated MIME part.
Represents a "Content-Transfer-Encoding" header.
Represents a "Content-Type" header.
void setMimeType(const QByteArray &mimeType)
Sets the mimetype.
Represents a (email) message.
Message()
Creates an empty Message.

Definition at line 65 of file kmime_message.h.

Member Typedef Documentation

◆ Ptr

A shared pointer to a message object.

Definition at line 71 of file kmime_message.h.

Constructor & Destructor Documentation

◆ Message()

KMime::Message::Message ( )
default

Creates an empty Message.

◆ ~Message()

KMime::Message::~Message ( )
overridedefault

Destroys this Message.

Member Function Documentation

◆ assembleHeaders()

QByteArray KMime::Message::assembleHeaders ( )
overrideprotectedvirtual

Reimplement this method if you need to assemble additional headers in a derived class.

Don't forget to call the implementation of the base class.

Returns
The raw, assembled headers.

Reimplemented from KMime::Content.

Reimplemented in KMime::NewsArticle.

Definition at line 22 of file kmime_message.cpp.

◆ bcc() [1/2]

const KMime::Headers::Bcc * KMime::Message::bcc ( ) const

Returns the Bcc header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ bcc() [2/2]

KMime::Headers::Bcc * KMime::Message::bcc ( bool create = true)

Returns the Bcc header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ cc() [1/2]

const KMime::Headers::Cc * KMime::Message::cc ( ) const

Returns the Cc header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ cc() [2/2]

KMime::Headers::Cc * KMime::Message::cc ( bool create = true)

Returns the Cc header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ date() [1/2]

const KMime::Headers::Date * KMime::Message::date ( ) const

Returns the Date header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ date() [2/2]

KMime::Headers::Date * KMime::Message::date ( bool create = true)

Returns the Date header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ from() [1/2]

const KMime::Headers::From * KMime::Message::from ( ) const

Returns the From header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ from() [2/2]

KMime::Headers::From * KMime::Message::from ( bool create = true)

Returns the From header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ inReplyTo() [1/2]

const KMime::Headers::InReplyTo * KMime::Message::inReplyTo ( ) const

Returns the In-Reply-To header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ inReplyTo() [2/2]

KMime::Headers::InReplyTo * KMime::Message::inReplyTo ( bool create = true)

Returns the In-Reply-To header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ mainBodyPart() [1/2]

Content * KMime::Message::mainBodyPart ( const QByteArray & type = QByteArray())

Returns the first main body part of a given type, taking multipart/mixed and multipart/alternative nodes into consideration.

Eg. bodyPart("text/html") will return a html content object if that is provided in a multipart/alternative node, but not if it's the non-first child node of a multipart/mixed node (ie. an attachment).

Parameters
typeThe mimetype of the body part, if not given, the first body part will be returned, regardless of it's type.

Definition at line 36 of file kmime_message.cpp.

◆ mainBodyPart() [2/2]

const Content * KMime::Message::mainBodyPart ( const QByteArray & type = QByteArray()) const

Definition at line 42 of file kmime_message.cpp.

◆ messageID() [1/2]

const KMime::Headers::MessageID * KMime::Message::messageID ( ) const

Returns the Message-ID header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ messageID() [2/2]

KMime::Headers::MessageID * KMime::Message::messageID ( bool create = true)

Returns the Message-ID header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ mimeType()

QString KMime::Message::mimeType ( )
static

Returns the MIME type used for Messages.

Definition at line 80 of file kmime_message.cpp.

◆ organization() [1/2]

const KMime::Headers::Organization * KMime::Message::organization ( ) const

Returns the Organization header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ organization() [2/2]

KMime::Headers::Organization * KMime::Message::organization ( bool create = true)

Returns the Organization header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ references() [1/2]

const KMime::Headers::References * KMime::Message::references ( ) const

Returns the References header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ references() [2/2]

KMime::Headers::References * KMime::Message::references ( bool create = true)

Returns the References header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ replyTo() [1/2]

const KMime::Headers::ReplyTo * KMime::Message::replyTo ( ) const

Returns the Reply-To header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ replyTo() [2/2]

KMime::Headers::ReplyTo * KMime::Message::replyTo ( bool create = true)

Returns the Reply-To header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ sender() [1/2]

const KMime::Headers::Sender * KMime::Message::sender ( ) const

Returns the Sender header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ sender() [2/2]

KMime::Headers::Sender * KMime::Message::sender ( bool create = true)

Returns the Sender header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ subject() [1/2]

const KMime::Headers::Subject * KMime::Message::subject ( ) const

Returns the Subject header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ subject() [2/2]

KMime::Headers::Subject * KMime::Message::subject ( bool create = true)

Returns the Subject header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ to() [1/2]

const KMime::Headers::To * KMime::Message::to ( ) const

Returns the To header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ to() [2/2]

KMime::Headers::To * KMime::Message::to ( bool create = true)

Returns the To header.

Parameters
createIf true, create the header if it doesn't exist yet.

◆ userAgent() [1/2]

const KMime::Headers::UserAgent * KMime::Message::userAgent ( ) const

Returns the User-Agent header.

Can be nullptr if the header doesn't exist.

Since
24.08

◆ userAgent() [2/2]

KMime::Headers::UserAgent * KMime::Message::userAgent ( bool create = true)

Returns the User-Agent header.

Parameters
createIf true, create the header if it doesn't exist yet.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 11:54:25 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.