Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QMessage Class Reference

The QMessage class provides a convenient interface for working with messages. More...

 #include <QMessage>

Inherits QMessageContentContainer.

Public Types

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

Public Functions

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

Static Public Members

QByteArray preferredCharsetFor ( const QString & text )
QList<QByteArray> preferredCharsets ()
void setPreferredCharsets ( const QList<QByteArray> & charsetNames )

Detailed Description

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.

See also QMessageContentContainer, QMessageManager, and QMessageId.

Member Type Documentation

enum QMessage::Priority

Defines the priority of a message.

ConstantValueDescription
QMessage::HighPriority1The message is high priority.
QMessage::NormalPriority2The message is normal priority.
QMessage::LowPriority3The message is low priority.

enum QMessage::ResponseType

Defines the type of a response to an existing message.

ConstantValueDescription
QMessage::ReplyToSender1A response to the sender of the existing message.
QMessage::ReplyToAll2A response to the sender of the existing message, and any other recipients of that message.
QMessage::Forward3A response created to copy the content of the existing message to a new recipient.

enum QMessage::StandardFolder

Defines the standard folders.

ConstantValueDescription
QMessage::InboxFolder1Represents the standard inbox folder.
QMessage::DraftsFolder3Represents the standard drafts folder.
QMessage::OutboxFolder2Represents the standard outbox folder.
QMessage::SentFolder4Represents the standard sent folder.
QMessage::TrashFolder5Represents the standard trash folder.

enum QMessage::Status
flags QMessage::StatusFlags

This enum type is used to describe the status of a message.

ConstantValueDescription
QMessage::Read0x1This flag indicates that the content of this message has been displayed to the user.
QMessage::HasAttachments0x2This flag indicates that the message contains at least one sub-part with 'Attachment' disposition.
QMessage::Incoming0x4This flag indicates that the message has been sent from an external source.
QMessage::Removed0x8This 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().

enum QMessage::Type
flags QMessage::TypeFlags

This enum type is used to describe the type of a message.

ConstantValueDescription
QMessage::NoType0The message type is not defined.
QMessage::Mms0x1The message is an MMS, Multimedia Messaging Service object.
QMessage::Sms0x2The message is an SMS, Short Message Service object.
QMessage::Email0x4The message is an Email, Internet Message Format object.
QMessage::InstantMessage0x8The message is an instant message object, such as XMPP.
QMessage::AnyType0xFFFFFFFFBitflag value that matches any message type defined.

The TypeFlags type is a typedef for QFlags<Type>. It stores an OR combination of Type values.

See also type() and setType().

Member Function Documentation

QMessage::QMessage ()

Constructs an empty message.

QMessage::QMessage ( const QMessageId & id )

Constructs a message from data stored in the messaging store with identifier id.

See also QMessageManager::message().

QMessage::QMessage ( const QMessage & other )

Constructs a copy of other.

QMessage::~QMessage () [virtual]

Destroys the message.

void QMessage::appendAttachments ( const QStringList & fileNames )

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.

See also attachmentIds() and clearAttachments().

QMessageContentContainerIdList QMessage::attachmentIds () const

Returns a list of attachment identifiers for the message.

The body of the message will not be included in the list.

See also appendAttachments() and clearAttachments().

QMessageAddressList QMessage::bcc () const

Returns the list of all the bcc (blind carbon copy) recipients specified for the message.

See also to(), cc(), and setBcc().

QMessageContentContainerId QMessage::bodyId () const

Returns the identifier for the body content contained by the Message if a body exists; otherwise returns an invalid identifier.

See also QMessageContentContainer and setBody().

QMessageAddressList QMessage::cc () const

Returns the list of all the cc (carbon copy) recipients specified for the message.

See also to(), bcc(), setCc(), and QMessageFilter::byRecipients().

void QMessage::clearAttachments ()

Clears the list of attachments for the message, leaving only the message body, if any.

See also attachmentIds() and appendAttachments().

QMessage QMessage::createResponseMessage ( ResponseType type ) const

Creates a new message as a response to this message, with properties predetermined according to type.

See also QMessageService::compose().

QDateTime QMessage::date () const

Returns the timestamp contained in the origination date header field of the message, if present; otherwise returns a null timestamp.

See also setDate() and QMessageFilter::byTimeStamp().

QMessageAddress QMessage::from () const

Returns the originating address of the message.

See also setFrom() and QMessageFilter::bySender().

QMessageId QMessage::id () const

Returns the identifier of the message.

See also QMessageFilter::byId().

bool QMessage::isModified () const

Returns true if the message has been modified since it was constructed; otherwise returns false.

QMessageAccountId QMessage::parentAccountId () const

Returns the identifier of the parent account of the message if any; otherwise returns an invalid identifier.

See also setParentAccountId().

QMessageFolderId QMessage::parentFolderId () const

Returns the identifier of the folder that contains the message if any; otherwise returns an invalid identifier.

QByteArray QMessage::preferredCharsetFor ( const QString & text ) [static]

Returns the first charset from the preferred list that is capable of encoding the content of text.

See also preferredCharsets() and setBody().

QList<QByteArray> QMessage::preferredCharsets () [static]

Returns an ordered-by-preference list of charset names to use when encoding unicode QString data to a serialized form.

See also setPreferredCharsets(), preferredCharsetFor(), and setBody().

Priority QMessage::priority () const

Returns the priority of the message.

The default is NormalPriority.

See also setPriority() and QMessageFilter::byPriority().

QDateTime QMessage::receivedDate () const

Returns the timestamp placed in the message during reception by the device, if present; otherwise returns a null timestamp.

See also setReceivedDate() and QMessageFilter::byReceptionTimeStamp().

void QMessage::setBcc ( const QMessageAddressList & bccList )

Set the list of bcc (blind carbon copy) recipients for the message to bccList.

See also bcc(), setTo(), and setCc().

void QMessage::setBody ( const QString & body, const QByteArray & mimeType = QByteArray() )

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

See also bodyId() and preferredCharsets().

void QMessage::setBody ( QTextStream & in, const QByteArray & mimeType = QByteArray() )

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

See also bodyId() and preferredCharsets().

void QMessage::setCc ( const QMessageAddressList & ccList )

Set the list of cc (carbon copy) recipients for the message to ccList.

See also cc(), setTo(), and setBcc().

void QMessage::setDate ( const QDateTime & d )

Sets the origination date header field specifying the timestamp of the message to d.

See also date().

void QMessage::setFrom ( const QMessageAddress & address )

Sets the from address, that is the originating address of the message to address.

See also from().

void QMessage::setParentAccountId ( const QMessageAccountId & accountId )

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

See also parentAccountId().

void QMessage::setPreferredCharsets ( const QList<QByteArray> & charsetNames ) [static]

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

See also preferredCharsets(), preferredCharsetFor(), and setBody().

void QMessage::setPriority ( Priority newPriority )

Sets the priority of the message to newPriority.

See also priority().

void QMessage::setReceivedDate ( const QDateTime & d )

Sets the timestamp indicating the time of message reception by the device to d.

See also receivedDate().

void QMessage::setStatus ( StatusFlags newStatus )

Sets the status flags value for the message to newStatus.

See also status().

void QMessage::setStatus ( Status flag, bool set = true )

Sets the status flag flag for the message to have the value set.

See also status().

void QMessage::setSubject ( const QString & text )

Sets the subject of the message to text.

See also subject().

void QMessage::setTo ( const QMessageAddressList & toList )

Sets the list of primary recipients for the message to toList.

See also to().

void QMessage::setTo ( const QMessageAddress & address )

Sets the primary recipient for the message to address.

See also to().

void QMessage::setType ( Type t )

Sets the Type of the message to t.

The type of a message may be set for non-empty messages.

See also type().

int QMessage::size () const

Returns the complete size of the message as indicated on the originating server.

See also QMessageFilter::bySize().

StandardFolder QMessage::standardFolder () const

Returns the standard folder of the message.

Defaults to DraftsFolder.

StatusFlags QMessage::status () const

Returns the status flags value for the message.

See also setStatus() and QMessageFilter::byStatus().

QString QMessage::subject () const

Returns the subject of the message, if present; otherwise returns a null string.

See also setSubject() and QMessageFilter::bySubject().

QMessageAddressList QMessage::to () const

Returns the list of primary recipients for the message.

See also setTo() and QMessageFilter::byRecipients().

Type QMessage::type () const

Returns the Type of the message.

See also setType() and QMessageFilter::byType().

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();
Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 88
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 31
  5. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
Page suivante

Le Qt Developer Network au hasard

Logo

Applications mobiles modernes avec Qt et QML

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtmobility-1.1
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web