KMime::Message

Search for usage in LXR

#include <message.h>

Inheritance diagram for KMime::Message:

Public Types

typedef QSharedPointer< MessagePtr
 
- Public Types inherited from KMime::Content
enum  DecodedTextTrimOption { NoTrim , TrimNewlines , TrimSpaces }
 
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 ()
 
auto attachments () const -> auto
 
QByteArray body () const
 
QSharedPointer< MessagebodyAsMessage ()
 
QSharedPointer< const 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 ()
 
auto contents () const -> auto
 
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, bool removeTrailingNewlines=false) const
 
QString decodedText (DecodedTextTrimOption trimOption=NoTrim) const
 
QByteArray encodedBody () const
 
QByteArray encodedContent (bool useCrLf=false) const
 
QByteArray epilogue () const
 
void fromUnicodeString (const QString &s)
 
bool hasContent () const
 
bool hasHeader (QByteArrayView type) const
 
QByteArray head () const
 
template<typename T >
T * header () const
 
template<typename T >
T * header (bool create=false)
 
Headers::BaseheaderByType (QByteArrayView type) const
 
QList< Headers::Base * > headers ()
 
auto headers () const -> auto
 
QList< Headers::Base * > headersByType (QByteArrayView 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 (QByteArrayView type)
 
void replaceContent (Content *oldContent, Content *newContent)
 
void setBody (const QByteArray &body)
 
void setContent (const QByteArray &s)
 
void setEncodedBody (const QByteArray &body)
 
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)
 
qsizetype size () const
 
qsizetype storageSize () const
 
ContenttakeContent (Content *content)
 
ContenttextContent ()
 
const ContenttextContent () const
 
ContenttopLevel ()
 
const ContenttopLevel () const
 

Static Public Member Functions

static QString mimeType ()
 

Protected Member Functions

QByteArray assembleHeaders () override
 
- Protected Member Functions inherited from KMime::Content

Detailed Description

Represents a (email) message.

Sample how to create a multipart message:

// Set the multipart message.
Message *m = new Message;
ct->setMimeType( "multipart/mixed" );
ct->setBoundary( multiPartBoundary() );
cte->setEncoding(Headers::CE7Bit);
// Set the headers.
m->from()->fromUnicodeString("some@mailaddy.com");
m->to()->fromUnicodeString("someother@mailaddy.com");
m->cc()->fromUnicodeString("some@mailaddy.com");
m->date()->setDateTime(QDateTime::currentLocalDateTime());
m->subject()->fromUnicodeString("My Subject");
// 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.
Definition content.h:108
Headers::ContentType * contentType(bool create=true)
Returns the Content-Type header.
void setHeader(Headers::Base *h)
Sets the specified header to this Content.
Definition content.cpp:592
Headers::ContentTransferEncoding * contentTransferEncoding(bool create=true)
Returns the Content-Transfer-Encoding header.
void assemble()
Generates the MIME content.
Definition content.cpp:189
void appendContent(Content *content)
Appends a new sub-Content.
Definition content.cpp:490
void setBody(const QByteArray &body)
Sets the Content decoded body raw data.
Definition content.cpp:83
Represents a "Content-Disposition" header.
Definition headers.h:1145
void setDisposition(contentDisposition disp)
Sets the content disposition.
Definition headers.cpp:1995
void setFilename(const QString &filename)
Sets the suggested filename for the associated MIME part.
Definition headers.cpp:2004
Represents a "Content-Transfer-Encoding" header.
Definition headers.h:868
void setEncoding(contentEncoding e)
Sets the encoding to e.
Definition headers.cpp:1919
Represents a "Content-Type" header.
Definition headers.h:989
void setMimeType(const QByteArray &mimeType)
Sets the mimetype.
Definition headers.cpp:1631
void setBoundary(const QByteArray &s)
Sets the multipart container boundary.
Definition headers.cpp:1701
void setDateTime(const QDateTime &dt)
Sets the date.
Definition headers.cpp:1432
void fromUnicodeString(const QString &s) override
Parses the given Unicode representation of the header content.
Definition headers.cpp:484
void fromUnicodeString(const QString &s) override
Parses the given Unicode representation of the header content.
Definition headers.cpp:272
void fromUnicodeString(const QString &s) override
Parses the given Unicode representation of the header content.
Definition headers.cpp:174
Represents a (email) message.
Definition message.h:65
KMime::Headers::Cc * cc(bool create=true)
Returns the Cc header.
KMime::Headers::To * to(bool create=true)
Returns the To header.
Message()
Creates an empty Message.
KMime::Headers::Subject * subject(bool create=true)
Returns the Subject header.
KMime::Headers::Date * date(bool create=true)
Returns the Date header.
KMime::Headers::From * from(bool create=true)
Returns the From header.

Definition at line 64 of file message.h.

Member Typedef Documentation

◆ Ptr

A shared pointer to a message object.

Definition at line 70 of file 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 message.cpp.

◆ bcc() [1/2]

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

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
nodiscard

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
nodiscard

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
nodiscard

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
nodiscard

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())
nodiscard

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 message.cpp.

◆ mainBodyPart() [2/2]

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

Definition at line 42 of file message.cpp.

◆ messageID() [1/2]

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

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 ( )
staticnodiscard

Returns the MIME type used for Messages.

Definition at line 80 of file message.cpp.

◆ organization() [1/2]

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

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
nodiscard

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
nodiscard

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
nodiscard

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
nodiscard

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
nodiscard

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
nodiscard

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 Dec 6 2024 12:11:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.