This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
This interface extends the Text interface to support more general messages, including:
It also provides a hook for improved sent message status notification, to be used by the DeliveryReporting interface.
Although this specification supports formatted (rich-text) messages with unformatted alternatives, implementations SHOULD NOT attempt to send formatted messages until the Telepathy specification has also been extended to cover capability discovery for message formatting.
If this interface is present, clients that support it SHOULD listen for the MessageSent and MessageReceived signals, and ignore the Sent and Received signal on the Text interface (which are guaranteed to duplicate signals from this interface).
Flags indicating the level of support for message parts on this channel. They are designed such that setting more flags always implies that the channel has more capabilities.
It is assumed that messages containing a textual message body (only), like the messages the Text interface was designed for, are always supported.
There is no flag indicating support for alternatives. This is because the SendMessage implementation can always accept messages containing alternatives, even if the underlying protocol does not, by deleting all alternatives except the first (most preferred) that is supported.
Part of a message's content. In practice, this mapping never
appears in isolation - messages are represented by a list of
An example of how a message might look, in a Python-like syntax:
[ { 'message-sender': 42, 'message-sent': 1210067943, 'message-received': 1210067947, 'message-type': 0, 'pending-message-id': 437, }, { 'alternative': 'main', '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', 'type': 'text/plain', 'content': 'Here is a photo of my cat:\n[IMG: lol!]\nIsn't it cute?', }, { 'identifier': 'catphoto', 'type': 'image/jpeg', 'size': 101000, 'needs-retrieval': True, }, ]
The first part of the message contains "headers" which refer to the entire message.
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, but clients MUST recover from this error by ignoring these keys in the second and subsequent parts.
Well-known keys for the message as a whole, and the corresponding value types, include:
The second and subsequent parts contain the message's content, including plain text, formatted text and/or attached files.
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.
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.
Well-known keys for the second and subsequent parts, and the corresponding value types, include:
If present, this part of the message is an alternative for all other parts with the same value for "alternative". Clients SHOULD only display one of them (this is expected to be used for XHTML messages in a future version of this specification).
If omitted, this part is not an alternative for any other part.
Parts of a message MAY reference the group of alternatives as a whole (i.e. a reference to whichever of them is chosen) by treating this identifier as if it were the MIME Content-ID of a multipart/alternative part, and using the cid: URI scheme.
The MIME type of this part. See the documentation for ReceivedMessage for notes on the special status of "text/plain" parts.
Connection managers MUST NOT signal parts without a 'type' key; if a protocol provides no way to determine the MIME type, the connection manager is responsible for guessing it, but MAY fall back to "text/plain" for text and "application/octet-stream" for non-text.
Clients MUST ignore parts without a 'type' key, which are reserved for future expansion.
It is an error for a connection manager to put these keys
in the first
An opaque token used to identify sent messages. As a special case, the empty string indicates that there is no particular identification for a message.
CM implementations SHOULD use an identifier expected to be unique, such as a UUID, if possible.
Some protocols can only track a limited number of sent messages in a small message-ID space. As a result, clients MUST NOT assume that message tokens will not be re-used, and SHOULD use some reasonable heuristic to assign delivery reports to messages, such as matching on message content or timestamp (if available), or assuming that the delivery report refers to the most recent message with that ID.
This is a hook for the DeliveryReporting interface, to avoid having to introduce a SendMultiPartMessageAndReturnToken method in that interface.
Submit a message to the server for sending. If this method returns successfully, the message has been submitted to the server and the MessageSent signal is emitted. A corresponding Sent signal on the Text interface MUST also be emitted.
If this method fails, message submission to the server has failed and no signal on this interface (or the Text interface) is emitted.
The content of the requested parts. The keys in this mapping
are positions in the array of message parts; the values are
either of type 's' or 'ay' (UTF-8 text string, or byte array),
following the same rules as for the value of the 'content' key in
the
If the one of the requested part numbers was greater than zero but referred to a part that had no content (i.e. it had no 'type' key or no 'content' key), it is simply omitted from this mapping; this is not considered to be an error condition.