|  | Home |

# QMailMessagePartContainer Class Reference

The QMailMessagePartContainer class provides access to a collection of message parts. More...

        #include <QMailMessagePartContainer>

This class is under development and is subject to change.

Inherits QMailMessagePartContainerFwd.

Inherited by QMailMessage and QMailMessagePart.

- List of all members, including inherited members

## Public Types

class | Location

## Public Functions

virtual void | appendHeaderField ( const QString & id, const QString & value )
virtual void | appendHeaderField ( const QMailMessageHeaderField & field )
void | appendPart ( const QMailMessagePart & part )
QMailMessageBody | body () const
QByteArray | boundary () const
void | clearParts ()
virtual bool | contentAvailable () const = 0
QMailMessageContentType | contentType () const
QList<QMailMessagePartContainer::Location> | findAttachmentLocations () const
QMailMessagePartContainer * | findHtmlContainer () const
QMailMessagePartContainer * | findPlainTextContainer () const
bool | foreachPart ( F func )
bool | foreachPart ( F func ) const
bool | hasAttachments () const
bool | hasBody () const
bool | hasHtmlBody () const
bool | hasPlainTextBody () const
QMailMessageHeaderField | headerField ( const QString & id, QMailMessageHeaderField::FieldType fieldType = QMailMessageHeaderField::StructuredField ) const
QString | headerFieldText ( const QString & id ) const
QList<QMailMessageHeaderField> | headerFields ( const QString & id, QMailMessageHeaderField::FieldType fieldType = QMailMessageHeaderField::StructuredField ) const
QList<QMailMessageHeaderField> | headerFields () const
QStringList | headerFieldsText ( const QString & id ) const
MultipartType | multipartType () const
const QMailMessagePart & | partAt ( uint pos ) const
QMailMessagePart & | partAt ( uint pos )
uint | partCount () const
virtual bool | partialContentAvailable () const = 0
void | prependPart ( const QMailMessagePart & part )
virtual void | removeHeaderField ( const QString & id )
void | removePartAt ( uint pos )
void | setAttachments ( const QStringList & attachments )
void | setAttachments ( const QList<const QMailMessagePart *> attachments )
void | setBody ( const QMailMessageBody & body )
void | setBoundary ( const QByteArray & text )
virtual void | setHeaderField ( const QString & id, const QString & value )
virtual void | setHeaderField ( const QMailMessageHeaderField & field )
void | setHtmlAndPlainTextBody ( const QMailMessageBody & htmlBody, const QMailMessageBody & plainTextBody )
void | setMultipartType ( MultipartType type )
void | setPlainTextBody ( const QMailMessageBody & plainTextBody )
QMailMessageBody::TransferEncoding | transferEncoding () const

## Static Public Members

MultipartType | multipartTypeForName ( const QByteArray & name )
QByteArray | nameForMultipartType ( MultipartType type )

## Protected Functions

| QMailMessagePartContainer ( Subclass * p )

## Detailed Description

The QMailMessagePartContainer class provides access to a collection of message parts.

Message formats such as email messages conforming to RFC 2822 (Internet Message Format) can consist of multiple independent parts, whose relationship to each other is defined by the message that contains those parts. The QMailMessagePartContainer class provides storage for these related message parts, and the interface through which they are accessed.

The multipartType() function returns a member of the MultipartType enumeration, which describes the relationship of the parts in the container to each other.

The part container can instead contain a message body element. In this case, it cannot contain sub-parts, and the multipartType() function will return MultipartType::MultipartNone for the part. The body element can be accessed via the body() function.

The QMailMessagePart class is itself derived from QMailMessagePartContainer, which allows messages to support the nesting of part collections within other part collections.

See also QMailMessagePart, QMailMessage, and QMailMessageBody.

## Member Function Documentation

### QMailMessagePartContainer::QMailMessagePartContainer ( Subclass * p ) `[protected]`

Constructs an empty part container object, in the space allocated within the subclass instance at p.

### void QMailMessagePartContainer::appendHeaderField ( const QString & id, const QString & value ) `[virtual]`

Appends a new header field with id id and value value to the existing list of header fields. Any existing header fields with the same id are not modified. If value is of the form "<id>:<content>", then only the part after the semi-colon is processed.

RFC 2822 encoding requires header fields to be transmitted in ASCII characters. If value contains non-ASCII characters, it will be encoded to ASCII via the QMailMessageHeaderField::encodeContent() function; depending on the specific header field this may result in illegal content. Where possible, clients should encode non-ASCII data prior to calling appendHeaderField.

See also QMailMessageHeaderField.

### void QMailMessagePartContainer::appendHeaderField ( const QMailMessageHeaderField & field ) `[virtual]`

Appends a new header field with the properties of field. Any existing header fields with the same id are not modified.

### void QMailMessagePartContainer::appendPart ( const QMailMessagePart & part )

Append part to the list of attachments for the message.

### QMailMessageBody QMailMessagePartContainer::body () const

Returns the body element contained by the part.

See also setBody().

### QByteArray QMailMessagePartContainer::boundary () const

Returns the boundary text used to delimit the container's parts when encoded in RFC 2822 form.

See also setBoundary().

### void QMailMessagePartContainer::clearParts ()

Clears the list of attachments associated with the message.

### bool QMailMessagePartContainer::contentAvailable () const `[pure virtual]`

Returns true if the entire content of this element is available; otherwise returns false.

### QMailMessageContentType QMailMessagePartContainer::contentType () const

Returns the content type of this part. Where hasBody() is true, the type of the contained body element is returned; otherwise a content type matching the multipartType() for this part is returned.

See also hasBody(), QMailMessageBody::contentType(), and multipartType().

### QList<QMailMessagePartContainer::Location> QMailMessagePartContainer::findAttachmentLocations () const

Returns the locations of the attachments in a container, dealing with a range of different message structures and exceptions.

### QMailMessagePartContainer * QMailMessagePartContainer::findHtmlContainer () const

Searches for the container that encapsulates the HTML body of this container, returning a pointer to it or 0 if it's not present.

### QMailMessagePartContainer * QMailMessagePartContainer::findPlainTextContainer () const

Searches for the container that encapsulates the plain text body of this container, returning a pointer to it or 0 if it's not present.

### bool QMailMessagePartContainer::foreachPart ( F func )

Applies the function or functor func to each part contained within the container. func must implement the signature 'bool operator()(QMailMessagePart &)', and must return true to indicate success, or false to end the traversal operation.

Returns true if all parts of the message were traversed, and func returned true for every invocation; else returns false.

### bool QMailMessagePartContainer::foreachPart ( F func ) const

Applies the function or functor func to each part contained within the container. func must implement the signature 'bool operator()(const QMailMessagePart &)', and must return true to indicate success, or false to end the traversal operation.

Returns true if all parts of the message were traversed, and func returned true for every invocation; else returns false.

### bool QMailMessagePartContainer::hasAttachments () const

Returns true if attachments are present in the container, dealing with a range of different message structures and exceptions.

### bool QMailMessagePartContainer::hasBody () const

Returns true if the part contains a body element; otherwise returns false.

### bool QMailMessagePartContainer::hasHtmlBody () const

Returns true if an HTML body is present in the container.

### bool QMailMessagePartContainer::hasPlainTextBody () const

Returns true if a plain text body is present in the container.

### QMailMessageHeaderField QMailMessagePartContainer::headerField ( const QString & id, QMailMessageHeaderField::FieldType fieldType = QMailMessageHeaderField::StructuredField ) const

Returns an object containing the value of the first header field with the given id. If fieldType is QMailMessageHeaderField::StructuredField, then the field content will be parsed assuming a format equivalent to that used for the RFC 2045 'Content-Type' and RFC 2183 'Content-Disposition' header fields.

See also setHeaderField().

### QString QMailMessagePartContainer::headerFieldText ( const QString & id ) const

Returns the text of the first header field with the given id.

### QList<QMailMessageHeaderField> QMailMessagePartContainer::headerFields ( const QString & id, QMailMessageHeaderField::FieldType fieldType = QMailMessageHeaderField::StructuredField ) const

Returns a list of objects containing the value of each header field with the given id. If fieldType is QMailMessageHeaderField::StructuredField, then the field content will be parsed assuming a format equivalent to that used for the RFC 2045 'Content-Type' and RFC 2183 'Content-Disposition' header fields.

### QList<QMailMessageHeaderField> QMailMessagePartContainer::headerFields () const

Returns a list of objects containing the value of each header field contained by the part. Header field objects returned by this function are not 'structured'.

### QStringList QMailMessagePartContainer::headerFieldsText ( const QString & id ) const

Returns a list containing the text of each header field with the given id.

### MultipartType QMailMessagePartContainer::multipartType () const

Returns the type of multipart relationship shared by the parts contained within this container, or MultipartNone if the content is not a multipart message.

See also setMultipartType().

### MultipartType QMailMessagePartContainer::multipartTypeForName ( const QByteArray & name ) `[static]`

Returns the multipart type that corresponds to the type name name.

### QByteArray QMailMessagePartContainer::nameForMultipartType ( MultipartType type ) `[static]`

Returns the standard textual representation for the multipart type type.

### const QMailMessagePart & QMailMessagePartContainer::partAt ( uint pos ) const

Returns a const reference to the item at position pos in the list of attachments for the message.

pos must be a valid index position in the list (i.e., 0 <= i < partCount()).

### QMailMessagePart & QMailMessagePartContainer::partAt ( uint pos )

Returns a non-const reference to the item at position pos in the list of attachments for the message.

pos must be a valid index position in the list (i.e., 0 <= i < partCount()).

### uint QMailMessagePartContainer::partCount () const

Returns the number of attachments the message has.

### bool QMailMessagePartContainer::partialContentAvailable () const `[pure virtual]`

Returns true if some portion of the content of this element is available; otherwise returns false.

### void QMailMessagePartContainer::prependPart ( const QMailMessagePart & part )

Prepend part to the list of attachments for the message.

### void QMailMessagePartContainer::removeHeaderField ( const QString & id ) `[virtual]`

Removes all existing header fields with id equal to id.

### void QMailMessagePartContainer::removePartAt ( uint pos )

Removes the part at the index pos.

pos must be a valid index position in the list (i.e., 0 <= i < partCount()).

### void QMailMessagePartContainer::setAttachments ( const QStringList & attachments )

Sets the attachment list of a container to attachments. `\param` attachments String paths to local files to be attached

See also hasAttachments().

### void QMailMessagePartContainer::setAttachments ( const QList<const QMailMessagePart *> attachments )

Sets the attachment list of a container to attachments. `\param` attachments List of already created message parts representing the attachments (might come from other existing messages)

### void QMailMessagePartContainer::setBody ( const QMailMessageBody & body )

Sets the part to contain the body element body.

See also body().

### void QMailMessagePartContainer::setBoundary ( const QByteArray & text )

Sets the boundary text used to delimit the container's parts when encoded in RFC 2822 form to text.

See also boundary().

### void QMailMessagePartContainer::setHeaderField ( const QString & id, const QString & value ) `[virtual]`

Sets the value of the first header field with identity id to value if it already exists; otherwise adds the header with the supplied id and value. If value is of the form "<id>:<content>", then only the part after the semi-colon is processed.

RFC 2822 encoding requires header fields to be transmitted in ASCII characters. If value contains non-ASCII characters, it will be encoded to ASCII via the QMailMessageHeaderField::encodeContent() function; depending on the specific header field this may result in illegal content. Where possible, clients should encode non-ASCII data prior to calling setHeaderField.

See also headerField() and QMailMessageHeaderField.

### void QMailMessagePartContainer::setHeaderField ( const QMailMessageHeaderField & field ) `[virtual]`

Sets the first header field with identity matching field to have the content of field.

### void QMailMessagePartContainer::setHtmlAndPlainTextBody ( const QMailMessageBody & htmlBody, const QMailMessageBody & plainTextBody )

Simultaneously sets the html and plain text body of a container to htmlBody and plainTextBody respectively.

### void QMailMessagePartContainer::setMultipartType ( MultipartType type )

Sets the multipart state of the message to type.

See also multipartType().

### void QMailMessagePartContainer::setPlainTextBody ( const QMailMessageBody & plainTextBody )

Sets the plain text body of a container to plainTextBody.

See also hasPlainTextBody().

### QMailMessageBody::TransferEncoding QMailMessagePartContainer::transferEncoding () const

Returns the transfer encoding type of this part. Where hasBody() is true, the transfer encoding type of the contained body element is returned; otherwise, the transfer encoding type specified by the 'Content-Transfer-Encoding' field of the header for this part is returned.

See also hasBody() and QMailMessageBody::transferEncoding().