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  · 

QMailMessageBody Class Reference
[QtMessagingModule, QtPimModule]

The QMailMessageBody class contains the body element of a message or message part. More...

    #include <QMailMessageBody>

This class is under development and is subject to change.

Public Types

Public Functions

  • QMailMessageContentType contentType () const
  • QByteArray data ( EncodingFormat format ) const
  • QString data () const
  • bool toFile ( const QString & filename, EncodingFormat format ) const
  • bool toStream ( QDataStream & out, EncodingFormat format ) const
  • bool toStream ( QTextStream & out ) const
  • TransferEncoding transferEncoding () const

Static Public Members

  • QMailMessageBody fromData ( const QByteArray & input, const QMailMessageContentType & type, TransferEncoding encoding, EncodingStatus status )
  • QMailMessageBody fromData ( const QString & input, const QMailMessageContentType & type, TransferEncoding encoding )
  • QMailMessageBody fromFile ( const QString & filename, const QMailMessageContentType & type, TransferEncoding encoding, EncodingStatus status )
  • QMailMessageBody fromStream ( QDataStream & in, const QMailMessageContentType & type, TransferEncoding encoding, EncodingStatus status )
  • QMailMessageBody fromStream ( QTextStream & in, const QMailMessageContentType & type, TransferEncoding encoding )

Detailed Description

The QMailMessageBody class contains the body element of a message or message part.

The body of a message or message part is treated as an atomic unit by the Qt Extended messaging library. It can only be inserted into a message part container or extracted from one. It can be inserted or extracted using either a QByteArray, a QDataStream or to/from a file. In the case of unicode text data, the insertion and extraction can operate on either a QString, a QTextStream or to/from a file.

The body data must be associated with a QMailMessageContentType describing that data. When extracting body data from a message or part to unicode text, the content type description must include a parameter named 'charset'; this parameter is used to locate a QTextCodec to be used to extract unicode data from the body data octet stream.

If the Content-Type of the data is a subtype of "text", then line-ending translation will be used to ensure that the text is transmitted with CR/LF line endings. The text data supplied to QMailMessageBody must conform to the RFC 2822 restrictions on maximum line lengths: "Each line of characters MUST be no more than 998 characters, and SHOULD be no more than 78 characters, excluding the CRLF." Textual message body data decoded from a QMailMessageBody object will have transmitted CR/LF line endings converted to \n on extraction.

The body data can also be encoded from 8-bit octets to 7-bit ASCII characters for safe transmission through obsolete email systems. When creating an instance of the QMailMessageBody class, the encoding to be used must be specified using the QMailMessageBody::TransferEncoding enum.

See also QMailMessagePart, QMailMessage, and QTextCodec.


Member Type Documentation

enum QMailMessageBody::EncodingFormat

This enum type is used to describe the format in which body data should be presented.

ConstantValueDescription
QMailMessageBody::Encoded1The body data should be presented in encoded form.
QMailMessageBody::Decoded2The body data should be presented in unencoded form.

enum QMailMessageBody::EncodingStatus

This enum type is used to describe the encoding status of body data.

ConstantValueDescription
QMailMessageBody::AlreadyEncoded1The body data is already encoded to the necessary encoding.
QMailMessageBody::RequiresEncoding2The body data is unencoded, and thus requires encoding for transmission.

enum QMailMessageBody::TransferEncoding

This enum type is used to describe a type of binary to text encoding. Encoding types used here are documented in RFC 2045 "Format of Internet Message Bodies"

ConstantValueDescription
QMailMessageBody::NoEncoding0The encoding is not specified.
QMailMessageBody::SevenBit1The data is not encoded, but contains only 7-bit ASCII data.
QMailMessageBody::EightBit2The data is not encoded, but contains data using only 8-bit characters which form a superset of ASCII.
QMailMessageBody::Base643A 65-character subset of US-ASCII is used, enabling 6 bits to be represented per printable character.
QMailMessageBody::QuotedPrintable4A method of encoding that tends to leave text similar to US-ASCII unmodified for readability.
QMailMessageBody::Binary5The data is not encoded to any limited subset of octet values.

See also QMailCodec.


Member Function Documentation

QMailMessageContentType QMailMessageBody::contentType () const

Returns the content type that the body was created with.

QByteArray QMailMessageBody::data ( EncodingFormat format ) const

Returns the data of the message body as a QByteArray. If format is QMailMessageBody::Encoded, then the data is written in the transfer encoding it was created with; otherwise, it is written in unencoded form.

See also QMailCodec.

QString QMailMessageBody::data () const

This is an overloaded member function, provided for convenience.

Returns the data of the message body as a QString, in unencoded form. Line-endings transmitted as CR/LF pairs are converted to \n on extraction.

The 'charset' parameter of the body's content type is used to locate the appropriate QTextCodec to convert the data from an octet stream to unicode, if necessary.

See also QMailCodec, QMailMessageContentType, and QTextCodec.

QMailMessageBody QMailMessageBody::fromData ( const QByteArray & input, const QMailMessageContentType & type, TransferEncoding encoding, EncodingStatus status )   [static]

Creates a message body from the data contained in input, having the content type type. If status is QMailMessageBody::RequiresEncoding, the data from the file will be encoded to encoding for transmission; otherwise it must already be in that encoding, which will be reported to recipients of the data.

If type is a subtype of "text", the data will be treated as text, and line-ending translation will be employed. Otherwise, the file will be treated as containing binary data.

If encoding is QMailMessageBody::QuotedPrintable, encoding will be performed assuming conformance to RFC 2045.

See also QMailCodec and QMailQuotedPrintableCodec.

QMailMessageBody QMailMessageBody::fromData ( const QString & input, const QMailMessageContentType & type, TransferEncoding encoding )   [static]

This is an overloaded member function, provided for convenience.

Creates a message body from the data contained in input, having the content type type. The data from input will be encoded to encoding for transmission, and line-ending translation will be employed. The unicode text data will be converted to an octet stream using a QTextCodec object identified by the 'charset' parameter of type.

If encoding is QMailMessageBody::QuotedPrintable, encoding will be performed assuming conformance to RFC 2045.

See also QMailCodec, QMailMessageContentType, and QTextCodec.

QMailMessageBody QMailMessageBody::fromFile ( const QString & filename, const QMailMessageContentType & type, TransferEncoding encoding, EncodingStatus status )   [static]

Creates a message body from the data contained in the file filename, having the content type type. If status is QMailMessageBody::RequiresEncoding, the data from the file will be encoded to encoding for transmission; otherwise it must already be in that encoding, which will be reported to recipients of the data.

If type is a subtype of "text", the data will be treated as text, and line-ending translation will be employed. Otherwise, the file will be treated as containing binary data. If the file contains unicode text data, it will be converted to an octet stream using a QTextCodec object identified by the 'charset' parameter of type.

If encoding is QMailMessageBody::QuotedPrintable, encoding will be performed assuming conformance to RFC 2045.

Note that the data is not actually read from the file until it is requested by another function.

See also QMailCodec, QMailQuotedPrintableCodec, QMailMessageContentType, and QTextCodec.

QMailMessageBody QMailMessageBody::fromStream ( QDataStream & in, const QMailMessageContentType & type, TransferEncoding encoding, EncodingStatus status )   [static]

Creates a message body from the data read from in, having the content type type. If status is QMailMessageBody::RequiresEncoding, the data from the file will be encoded to encoding for transmission; otherwise it must already be in that encoding, which will be reported to recipients of the data.

If type is a subtype of "text", the data will be treated as text, and line-ending translation will be employed. Otherwise, the file will be treated as containing binary data.

If encoding is QMailMessageBody::QuotedPrintable, encoding will be performed assuming conformance to RFC 2045.

See also QMailCodec and QMailQuotedPrintableCodec.

QMailMessageBody QMailMessageBody::fromStream ( QTextStream & in, const QMailMessageContentType & type, TransferEncoding encoding )   [static]

This is an overloaded member function, provided for convenience.

Creates a message body from the data read from in, having the content type type. The data read from in will be encoded to encoding for transmission, and line-ending translation will be employed. The unicode text data will be converted to an octet stream using a QTextCodec object identified by the 'charset' parameter of type.

If encoding is QMailMessageBody::QuotedPrintable, encoding will be performed assuming conformance to RFC 2045.

See also QMailCodec, QMailQuotedPrintableCodec, QMailMessageContentType, and QTextCodec.

bool QMailMessageBody::toFile ( const QString & filename, EncodingFormat format ) const

Writes the data of the message body to the file named filename. If format is QMailMessageBody::Encoded, then the data is written in the transfer encoding it was created with; otherwise, it is written in unencoded form.

If the body has a content type with a QMailMessageContentType::type() of "text", and the content type parameter 'charset' is not empty, then the unencoded data will be written as unicode text data, using the charset parameter to locate the appropriate QTextCodec.

Returns false if the operation causes an error; otherwise returns true.

See also QMailCodec, QMailMessageContentType, and QTextCodec.

bool QMailMessageBody::toStream ( QDataStream & out, EncodingFormat format ) const

Writes the data of the message body to the stream out. If format is QMailMessageBody::Encoded, then the data is written in the transfer encoding it was created with; otherwise, it is written in unencoded form.

Returns false if the operation causes an error; otherwise returns true.

See also QMailCodec.

bool QMailMessageBody::toStream ( QTextStream & out ) const

This is an overloaded member function, provided for convenience.

Writes the data of the message body to the stream out, in unencoded form. Line-endings transmitted as CR/LF pairs are converted to \n on extraction. Returns false if the operation causes an error; otherwise returns true.

The 'charset' parameter of the body's content type is used to locate the appropriate QTextCodec to convert the data from an octet stream to unicode, if necessary.

See also QMailCodec, QMailMessageContentType, and QTextCodec.

TransferEncoding QMailMessageBody::transferEncoding () const

Returns the transfer encoding type that the body was created with.

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 102
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 53
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 81
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 28
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 229
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 102
  7. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
Page suivante

Le Qt Labs au hasard

Logo

Construire l'avenir : (ré-)introduction aux composants de Qt Quick

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. 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 qtextended4.4
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