The QMessage class provides a convenient interface for working with messages. More...
#include <QMessage>
Inherits: QMessageContentContainer.
This class was introduced in Qt Mobility 1.0.
enum | Priority { HighPriority, NormalPriority, LowPriority } |
enum | ResponseType { ReplyToSender, ReplyToAll, Forward } |
enum | StandardFolder { InboxFolder, DraftsFolder, OutboxFolder, SentFolder, TrashFolder } |
enum | Status { Read, HasAttachments, Incoming, Removed } |
flags | StatusFlags |
enum | Type { NoType, Mms, Sms, Email, InstantMessage, AnyType } |
flags | TypeFlags |
QMessage () | |
QMessage ( const QMessageId & id ) | |
QMessage ( const QMessage & other ) | |
virtual | ~QMessage () |
void | appendAttachments ( const QStringList & fileNames ) |
QMessageContentContainerIdList | attachmentIds () const |
QMessageAddressList | bcc () const |
QMessageContentContainerId | bodyId () const |
QMessageAddressList | cc () const |
void | clearAttachments () |
QMessage | createResponseMessage ( ResponseType type ) const |
QDateTime | date () const |
QMessageAddress | from () const |
QMessageId | id () const |
bool | isModified () const |
QMessageAccountId | parentAccountId () const |
QMessageFolderId | parentFolderId () const |
Priority | priority () const |
QDateTime | receivedDate () const |
void | setBcc ( const QMessageAddressList & bccList ) |
void | setBody ( const QString & body, const QByteArray & mimeType = QByteArray() ) |
void | setBody ( QTextStream & in, const QByteArray & mimeType = QByteArray() ) |
void | setCc ( const QMessageAddressList & ccList ) |
void | setDate ( const QDateTime & d ) |
void | setFrom ( const QMessageAddress & address ) |
void | setParentAccountId ( const QMessageAccountId & accountId ) |
void | setPriority ( Priority newPriority ) |
void | setReceivedDate ( const QDateTime & d ) |
void | setStatus ( StatusFlags newStatus ) |
void | setStatus ( Status flag, bool set = true ) |
void | setSubject ( const QString & text ) |
void | setTo ( const QMessageAddressList & toList ) |
void | setTo ( const QMessageAddress & address ) |
void | setType ( Type t ) |
int | size () const |
StandardFolder | standardFolder () const |
StatusFlags | status () const |
QString | subject () const |
QMessageAddressList | to () const |
Type | type () const |
QByteArray | preferredCharsetFor ( const QString & text ) |
QList<QByteArray> | preferredCharsets () |
void | setPreferredCharsets ( const QList<QByteArray> & charsetNames ) |
The QMessage class provides a convenient interface for working with messages.
QMessage supports a number of types. Including internet email messages, and the telephony types SMS and MMS.
The QMessageId identifier for a message is returned by id(). Messages can be constructed by retrieval from the messaging store via their identifier using QMessageManager::message(). A QMessage can also be constructed piece by piece using functions such as setType(), setFrom(), setTo(), setSubject(), setBody() and appendAttachments().
If a message has been modified since it was last constructed isModified() returns true.
A list of attachments identifiers will be returned by attachmentIds() and an identifier for the message body will be returned by bodyId(). Attachments can be appended to the content of the message using appendAttachments(), the body of the message can be set with setBody().
The folder and account a message is associated with are returned by parentFolderId() and parentAccountId() respectively.
Message data that is less commonly accessed or relatively large should be lazily retrieved on demand by the associated getter function.
Only phone numbers are valid destination addresses for SMS messages, only email addresses are valid destination addresses for Email messages, MMS messages may be addressed to either phone numbers or email addresses.
On symbian platform there is no support for email messages containing alternative versions (multipart/alternative) of the same text content. Only one version is allowed. In the case where an email message containing alternative versions is received only plain text content is accessible.
See also QMessageContentContainer, QMessageManager, and QMessageId.
Defines the priority of a message.
Constant | Value | Description |
---|---|---|
QMessage::HighPriority | 1 | The message is high priority. |
QMessage::NormalPriority | 2 | The message is normal priority. |
QMessage::LowPriority | 3 | The message is low priority. |
Defines the type of a response to an existing message.
Constant | Value | Description |
---|---|---|
QMessage::ReplyToSender | 1 | A response to the sender of the existing message. |
QMessage::ReplyToAll | 2 | A response to the sender of the existing message, and any other recipients of that message. |
QMessage::Forward | 3 | A response created to copy the content of the existing message to a new recipient. |
Defines the standard folders.
Constant | Value | Description |
---|---|---|
QMessage::InboxFolder | 1 | Represents the standard inbox folder. |
QMessage::DraftsFolder | 3 | Represents the standard drafts folder. |
QMessage::OutboxFolder | 2 | Represents the standard outbox folder. |
QMessage::SentFolder | 4 | Represents the standard sent folder. |
QMessage::TrashFolder | 5 | Represents the standard trash folder. |
This enum type is used to describe the status of a message.
Constant | Value | Description |
---|---|---|
QMessage::Read | 0x1 | This flag indicates that the content of this message has been displayed to the user. |
QMessage::HasAttachments | 0x2 | This flag indicates that the message contains at least one sub-part with 'Attachment' disposition. |
QMessage::Incoming | 0x4 | This flag indicates that the message has been sent from an external source. |
QMessage::Removed | 0x8 | This flag indicates that the message has been deleted from or moved on the originating server. |
The StatusFlags type is a typedef for QFlags<Status>. It stores an OR combination of Status values.
See also status() and setStatus().
This enum type is used to describe the type of a message.
Constant | Value | Description |
---|---|---|
QMessage::NoType | 0 | The message type is not defined. |
QMessage::Mms | 0x1 | The message is an MMS, Multimedia Messaging Service object. |
QMessage::Sms | 0x2 | The message is an SMS, Short Message Service object. |
QMessage::Email | 0x4 | The message is an Email, Internet Message Format object. |
QMessage::InstantMessage | 0x8 | The message is an instant message object, such as XMPP. |
QMessage::AnyType | 0xFFFFFFFF | Bitflag value that matches any message type defined. |
The TypeFlags type is a typedef for QFlags<Type>. It stores an OR combination of Type values.
Constructs an empty message.
Constructs a message from data stored in the messaging store with identifier id.
This function was introduced in Qt Mobility 1.0.
See also QMessageManager::message().
Constructs a copy of other.
This function was introduced in Qt Mobility 1.0.
Destroys the message.
Append the contents of the files specified by fileNames to the end of the list of attachments for the message. The internet media (MIME) type of the attachments will be determined by examining the files or file names.
Symbian OS based devices have a limit for MMS message size. The message size limit varies between different devices, but is frequently 600 000 bytes. If the attachment size is greater than the limit then message sending will fail when QMessageService::send() is called.
This function was introduced in Qt Mobility 1.0.
See also attachmentIds() and clearAttachments().
Returns a list of attachment identifiers for the message.
The body of the message will not be included in the list.
This function was introduced in Qt Mobility 1.0.
See also appendAttachments() and clearAttachments().
Returns the list of all the bcc (blind carbon copy) recipients specified for the message.
This function was introduced in Qt Mobility 1.0.
See also to(), cc(), and setBcc().
Returns the identifier for the body content contained by the Message if a body exists; otherwise returns an invalid identifier.
This function was introduced in Qt Mobility 1.0.
See also QMessageContentContainer and setBody().
Returns the list of all the cc (carbon copy) recipients specified for the message.
This function was introduced in Qt Mobility 1.0.
See also to(), bcc(), setCc(), and QMessageFilter::byRecipients().
Clears the list of attachments for the message, leaving only the message body, if any.
This function was introduced in Qt Mobility 1.0.
See also attachmentIds() and appendAttachments().
Creates a new message as a response to this message, with properties predetermined according to type.
This function was introduced in Qt Mobility 1.0.
See also QMessageService::compose().
Returns the timestamp contained in the origination date header field of the message, if present; otherwise returns a null timestamp.
This function was introduced in Qt Mobility 1.0.
See also setDate() and QMessageFilter::byTimeStamp().
Returns the originating address of the message.
This function was introduced in Qt Mobility 1.0.
See also setFrom() and QMessageFilter::bySender().
Returns the identifier of the message.
This function was introduced in Qt Mobility 1.0.
See also QMessageFilter::byId().
Returns true if the message has been modified since it was constructed; otherwise returns false.
This function was introduced in Qt Mobility 1.0.
Returns the identifier of the parent account of the message if any; otherwise returns an invalid identifier.
This function was introduced in Qt Mobility 1.0.
See also setParentAccountId().
Returns the identifier of the folder that contains the message if any; otherwise returns an invalid identifier.
This function was introduced in Qt Mobility 1.0.
Returns the first charset from the preferred list that is capable of encoding the content of text.
This function was introduced in Qt Mobility 1.0.
See also preferredCharsets() and setBody().
Returns an ordered-by-preference list of charset names to use when encoding unicode QString data to a serialized form.
This function was introduced in Qt Mobility 1.0.
See also setPreferredCharsets(), preferredCharsetFor(), and setBody().
Returns the priority of the message.
The default is NormalPriority.
This function was introduced in Qt Mobility 1.0.
See also setPriority() and QMessageFilter::byPriority().
Returns the timestamp placed in the message during reception by the device, if present; otherwise returns a null timestamp.
This function was introduced in Qt Mobility 1.0.
See also setReceivedDate() and QMessageFilter::byReceptionTimeStamp().
Set the list of bcc (blind carbon copy) recipients for the message to bccList.
On Symbian bcc recipient list must not contain more than one element.
This function was introduced in Qt Mobility 1.0.
See also bcc(), setTo(), and setCc().
Sets the body text of the message to be the string body.
The internet media (MIME) content type of the body is set to mimeType, if provided. If the mimeType is not specified, the content type will default to "text/plain", and the encoding charset will be as determined by preferredCharsets().
On Symbian platform email messages with HTML body cannot be sent. If HTML content needs to be sent it can be added as attachment.
This function was introduced in Qt Mobility 1.0.
See also bodyId() and preferredCharsets().
Sets the body text of the message to be the text read from the stream in.
The internet media (MIME) content type of the body is set to mimeType, if provided. If the mimeType is not specified, the content type will default to "text/plain", and the encoding charset will be as determined by preferredCharsets().
On Symbian platform email messages with HTML body cannot be sent. If HTML content needs to be sent it can be added as attachment.
This function was introduced in Qt Mobility 1.0.
See also bodyId() and preferredCharsets().
Set the list of cc (carbon copy) recipients for the message to ccList.
On Symbian cc recipient list must not contain more than one element.
This function was introduced in Qt Mobility 1.0.
See also cc(), setTo(), and setBcc().
Sets the origination date header field specifying the timestamp of the message to d.
This function was introduced in Qt Mobility 1.0.
See also date().
Sets the from address, that is the originating address of the message to address.
This function was introduced in Qt Mobility 1.0.
See also from().
Sets the parent account of the message to the account with identifier accountId.
This operation is only permitted on new messages that have not yet been inserted into the message store. Attempting to change the parent account of a message already in the message store will result in an error when attempting to update the message with QMessageStore::update().
This function was introduced in Qt Mobility 1.0.
See also parentAccountId().
Sets the ordered-by-preference list of names of charsets to use when encoding unicode QString data to a serialized form to charsetNames.
The set of valid charset names is returned by QTextCodec::availableCodecs().
This function was introduced in Qt Mobility 1.0.
See also preferredCharsets(), preferredCharsetFor(), and setBody().
Sets the priority of the message to newPriority.
This function was introduced in Qt Mobility 1.0.
See also priority().
Sets the timestamp indicating the time of message reception by the device to d.
This function was introduced in Qt Mobility 1.0.
See also receivedDate().
Sets the status flags value for the message to newStatus.
This function was introduced in Qt Mobility 1.0.
See also status().
Sets the status flag flag for the message to have the value set.
This function was introduced in Qt Mobility 1.0.
See also status().
Sets the subject of the message to text.
This function was introduced in Qt Mobility 1.0.
See also subject().
Sets the list of primary recipients for the message to toList.
This function was introduced in Qt Mobility 1.0.
See also to().
Sets the primary recipient for the message to address.
This function was introduced in Qt Mobility 1.0.
See also to().
Sets the Type of the message to t.
The type of a message may be set for non-empty messages.
This function was introduced in Qt Mobility 1.0.
See also type().
Returns the complete size of the message as indicated on the originating server.
This function was introduced in Qt Mobility 1.0.
See also QMessageFilter::bySize().
Returns the standard folder of the message.
Defaults to DraftsFolder.
This function was introduced in Qt Mobility 1.0.
Returns the status flags value for the message.
This function was introduced in Qt Mobility 1.0.
See also setStatus() and QMessageFilter::byStatus().
Returns the subject of the message, if present; otherwise returns a null string.
This function was introduced in Qt Mobility 1.0.
See also setSubject() and QMessageFilter::bySubject().
Returns the list of primary recipients for the message.
This function was introduced in Qt Mobility 1.0.
See also setTo() and QMessageFilter::byRecipients().
Returns the Type of the message.
This function was introduced in Qt Mobility 1.0.
See also setType() and QMessageFilter::byType().