| Home · All Classes · All Namespaces · Modules · Functions · Files

Public Member Functions
Tp::MessagePart Struct Reference
Mapping types

`#include <TelepathyQt/Types>`

Inherits QMap< QString, QDBusVariant >.

List of all members.

## Public Member Functions

- MessagePart ()
- MessagePart (const QMap< QString, QDBusVariant > &a)
- MessagePart & operator= (const QMap< QString, QDBusVariant > &a)

## Detailed Description

Mapping type generated from the specification. Convertible with QMap<QString, QDBusVariant>, but needed to have a discrete type in the Qt type system.

Part of a message's content. In practice, this mapping never appears in isolation: incoming messages are represented by a list of Message_Part mappings in the MessageReceived() signal, and outgoing messages are passed to SendMessage() as a list of these mappings.

The first part of the message contains "headers", which refer to the entire message. The second and subsequent parts contain the message's content, including plain text, formatted text and/or attached files. Well-known keys for the header and body parts are defined by the Message_Header_Key and Message_Body_Key types, respectively. It is an error for a connection manager to put keys referring to the message as a whole in the second or subsequent Message_Part, or keys intended for body parts in the first Message_Part; clients MUST recover from this error by ignoring these mis-placed keys.

Instead of representing messages as aa{sv} where the first dictionary is special (a dictionary of headers), we could have used a signature like (a{sv}aa{sv}) to separate out the headers and the body parts.

However, this would make access to the messages more awkward. In Python, the syntax for access to a header field would remain `message[0]['message-type']`, but access to a body field in the second body part would change from `message[2]['content'] to message[1][1]['content']`. In GLib, the message would change from being a `GPtrArray(GHashTable)` to being a `GValueArray(GHashTable, GPtrArray(GHashTable))` which is rather inconvenient to dereference.

In any group of parts with the same non-empty value for the `alternative` key (which represent alternative versions of the same content), more faithful versions of the intended message MUST come before less faithful versions (note that this order is the opposite of MIME `multipart/alternative` parts). Clients SHOULD display the first alternative that they understand.

Specifying the preference order means that if the underlying protocol doesn't support alternatives, the CM can safely delete everything apart from the first supported alternative when sending messages.

The order is the reverse of MIME because MIME's rationale for placing the "plainest" part first (legibility in pre-MIME UAs) does not apply to us, and placing the most preferred part first simplifies display (a client can iterate the message in order, display the first alternative that it understands, and skip displaying all subsequent parts with the same "alternative" key).

Clients SHOULD present all parts that are not redundant alternatives in the order they appear in this array, possibly excluding parts that are referenced by another displayed part. It is implementation-specific how the parts are presented to the user.

This allows CMs to assume that all parts are actually shown to the user, even if they are not explicitly referenced - we do not yet recommend formatted text, and there is no way for plain text to reference an attachment since it has no concept of markup or references. This also forces clients to do something sensible with messages that consist entirely of "attachments", with no "body" at all.

For instance, when displaying the above example, a client that understands the HTML part should display the JPEG image once, between the two lines "Here is a photo of my cat:" and "Isn't it cute?"; it may additionally present the image in some way for a second time, after "Isn't it cute?", or may choose not to.

A client that does not understand HTML, displaying the same message, should display the plain-text part, followed by the JPEG image.

Connection managers, clients and extensions to this specification SHOULD NOT include Handles as values in a Message_Part, except for `message-sender` in the header.

Reference-counting handles in clients becomes problematic if the channel proxy cannot know whether particular map values are handles or not.

#### Example messages

A rich-text message, with an embedded image, might be represented as:

     [
       {
         'message-token': '9de9546a-3400-4419-a505-3ea270cb834c',
         'message-sender': 42,
         'message-sent': 1210067943,
         'message-received': 1210067947,
         'message-type': 0,              # = Channel_Text_Message_Type_Normal
         'pending-message-id': 437,
       },
       { 'alternative': 'main',
         'content-type': 'text/html',
         'content': 'Here is a photo of my cat:<br />' +
                    '<img src="cid:catphoto" alt="lol!" />' +
                    '<br />Isn't it cute?',
       },
       { 'alternative': 'main',
         'content-type': 'text/plain',
         'content': 'Here is a photo of my cat:\\n[IMG: lol!]\\nIsn't it cute?',
       },
       { 'identifier': 'catphoto',
         'content-type': 'image/jpeg',
         'size': 101000,
         'needs-retrieval': True,
       },
     ]

telepathy-ring, Nokia's GSM connection manager, represents vCards sent via SMS as:

     [
       {
         'message-token': '9de9546a-3400-4419-a505-3ea270cb834c',
         'message-sender': 42,
         'message-sent': 1210067943,
         'message-received': 1210067947,
         'message-type': 0,              # = Channel_Text_Message_Type_Normal
         'pending-message-id': 437,
       },
       { 'content-type': 'text/x-vcard',
         'content': [ 0x66, 0x69, 0x71, ...], # vCard data as an array of bytes
       },
     ]

### Delivery reports

Delivery reports are also represented as messages with the `message-type` header mapping to Channel_Text_Message_Type Delivery_Report. Delivery reports SHOULD contain the `message-sender` header, mapping to the intended recipient of the original message, if possible; other headers specific to delivery reports are defined by the Delivery_Report_Header_Key type. The second and subsequent parts, if present, are a human-readable report from the IM service.

For backwards- and forwards-compatibility, whenever a delivery error report is signalled—that is, with `delivery-status` mapping to Delivery_Status Temporarily_Failed or Permanently_Failed— ChannelTypeTextInterface::SendError() SHOULD also be emitted; whenever ChannelTypeTextInterface::SendError() is emitted, a delivery report MUST also be signalled. Delivery report messages on this interface MUST be represented in emissions of ChannelTypeTextInterface::Received() as messages with the Non_Text_Content Channel_Text_Message_Flags; clients which understand this interface SHOULD ignore the SendError signal in favour of listening for delivery reports, as mentioned in the introduction.

The result of attempting to send delivery reports using SendMessage() is currently undefined.

#### Example delivery reports

A minimal delivery report indicating permanent failure of the sent message whose token was `b9a991bd-8845-4d7f-a704-215186f43bb4` for an unknown reason

       [{
       # header
       'message-sender': 123,
       'message-type': Channel_Text_Message_Type_Delivery_Report,
       'delivery-status': Delivery_Status_Permanently_Failed,
       'delivery-token': 'b9a991bd-8845-4d7f-a704-215186f43bb4',
       }
       # no body
       ]

A delivery report where the failed message is echoed back to the sender rather than being referenced by ID, and the failure reason is that this protocol cannot send messages to offline contacts such as the contact with handle 123

       [{ # header
       'message-sender': 123,
       'message-type': Channel_Text_Message_Type_Delivery_Report,
       'delivery-status': Delivery_Status_Temporarily_Failed,
       'delivery-error': Channel_Text_Send_Error_Offline,
       'delivery-echo':
           [{ # header of original message
           'message-sender': 1,
           'message-sent': 1210067943,
           },
           { # body of original message
           'content-type': 'text/plain',
           'content': 'Hello, world!',
           }]
         ],

       # no body
       ]

A maximally complex delivery report: the server reports a bilingual human-readable failure message because the user sent a message "Hello, world!" with token `b9a991bd-8845-4d7f-a704-215186f43bb4` to a contact with handle 123, but that handle represents a contact who does not actually exist

       [{ # header
       'message-sender': 123,
       'message-type': Channel_Text_Message_Type_Delivery_Report,
       'delivery-status': Delivery_Status_Permanently_Failed,
       'delivery-error': Channel_Text_Send_Error_Invalid_Contact,
       'delivery-token': 'b9a991bd-8845-4d7f-a704-215186f43bb4',
       'delivery-echo':
           [{ # header of original message
           'message-sender': 1,
           'message-sent': 1210067943,
           },
           { # body of original message
           'content-type': 'text/plain',
           'content': 'Hello, world!',
           }]
         ],
       },
       { # message from server (alternative in English)
       'alternative': '404',
       'content-type': 'text/plain',
       'lang': 'en',
       'content': 'I have no contact with that name',
       },
       { # message from server (alternative in German)
       'alternative': '404'.
       'content-type': 'text/plain',
       'lang': 'de',
       'content', 'Ich habe keinen Kontakt mit diesem Namen',
       }
       ]

A minimal delivery report indicating successful delivery of the sent message whose token was `b9a991bd-8845-4d7f-a704-215186f43bb4`

       [{
       # header
       'message-sender': 123,
       'message-type': Channel_Text_Message_Type_Delivery_Report,
       'delivery-status': Delivery_Status_Delivered,
       'delivery-token': 'b9a991bd-8845-4d7f-a704-215186f43bb4',
       }
       # no body
       ]

## Constructor & Destructor Documentation

Tp::MessagePart::MessagePart | ( |  | ) | `[inline]`

Tp::MessagePart::MessagePart | ( | const QMap< QString, QDBusVariant > & | a | ) | `[inline]`

## Member Function Documentation

MessagePart& Tp::MessagePart::operator= | ( | const QMap< QString, QDBusVariant > & | a | ) | `[inline]`