TpMessage

TpMessage — a message in the Telepathy message interface

Functions

Types and Values

Object Hierarchy

    GObject
    ╰── TpMessage
        ├── TpClientMessage
        ├── TpCMMessage
        ╰── TpSignalledMessage

Includes

#include <telepathy-glib/telepathy-glib.h>

Description

TpMessage represent a message send or received using the Message interface.

Functions

tp_message_count_parts ()

guint
tp_message_count_parts (TpMessage *self);

Parameters

self

a message

 

Returns

the number of parts in the message, including the headers in part 0

Since 0.7.21


tp_message_dup_part ()

GVariant *
tp_message_dup_part (TpMessage *self,
                     guint part);

Parameters

self

a message

 

part

a part number

 

Returns

the current contents of the given part, or NULL if the part number is out of range.

[transfer full]

Since 0.19.10


tp_message_to_text ()

gchar *
tp_message_to_text (TpMessage *message);

Concatene all the text parts contained in message .

Parameters

message

a TpMessage

 

Returns

a newly allocated string containing the text content of message.

[transfer full]

Since 0.13.9


tp_message_get_message_type ()

TpChannelTextMessageType
tp_message_get_message_type (TpMessage *self);

Parameters

self

a message

 

Returns

the type of this message

Since 0.13.10


tp_message_get_received_timestamp ()

gint64
tp_message_get_received_timestamp (TpMessage *self);

Return when this message was received locally, as a number of seconds since the beginning of 1970 in the UTC timezone (the same representation used by g_date_time_new_from_unix_utc(), for instance), or 0 if not known.

Parameters

self

a message

 

Returns

a Unix timestamp, or 0

Since 0.13.9


tp_message_get_sent_timestamp ()

gint64
tp_message_get_sent_timestamp (TpMessage *self);

Return when this message was sent, as a number of seconds since the beginning of 1970 in the UTC timezone (the same representation used by g_date_time_new_from_unix_utc(), for instance), or 0 if not known.

If this protocol does not track the time at which the message was initially sent, this timestamp might be approximated by using the time at which it arrived at a central server.

Parameters

self

a message

 

Returns

a Unix timestamp, or 0

Since 0.13.9


tp_message_dup_specific_to_interface ()

gchar *
tp_message_dup_specific_to_interface (TpMessage *self);

If this message is specific to a particular D-Bus interface and should be ignored by clients without knowledge of that interface, return the name of the interface.

If this message is an ordinary message or delivery report, return NULL.

Parameters

self

a message

 

Returns

a D-Bus interface name, or NULL for ordinary messages and delivery reports.

[transfer full]


tp_message_dup_supersedes ()

gchar *
tp_message_dup_supersedes (TpMessage *self);

If this message replaces a previous message, return the value of tp_message_dup_token() for that previous message. Otherwise, return NULL.

For instance, a user interface could replace the superseded message with this message, or grey out the superseded message.

Parameters

self

a message

 

Returns

a non-empty opaque identifier, or NULL if none.

[transfer full]


tp_message_dup_token ()

gchar *
tp_message_dup_token (TpMessage *self);

Return this message's identifier in the underlying protocol. This is not guaranteed to be unique, even within the scope of a single channel or contact: the only guarantee made is that two messages with different non-empty tokens are different messages.

If there is no suitable token, return NULL.

Parameters

self

a message

 

Returns

a non-empty opaque identifier, or NULL if none.

[transfer full]

Since 0.13.9


tp_message_is_delivery_report ()

gboolean
tp_message_is_delivery_report (TpMessage *self);

If this message is a delivery report indicating success or failure of delivering a message, return TRUE.

Parameters

self

a message

 

Returns

TRUE if this is a delivery report

Since 0.13.9


tp_message_is_rescued ()

gboolean
tp_message_is_rescued (TpMessage *self);

Returns TRUE if this incoming message has been seen in a previous channel during the lifetime of the Connection, but had not been acknowledged when that channel closed, causing an identical channel (in which the message now appears) to open.

Loggers should check this flag to avoid duplicating messages, for instance.

Parameters

self

a message

 

Returns

TRUE if this message was seen in a previous Channel on this Connection

Since 0.13.9


tp_message_is_scrollback ()

gboolean
tp_message_is_scrollback (TpMessage *self);

Parameters

self

a message

 

Returns

TRUE if this message is part of a replay of message history, for instance in an XMPP chatroom.

Since 0.13.9


tp_message_get_pending_message_id ()

guint32
tp_message_get_pending_message_id (TpMessage *self,
                                   gboolean *valid);

Return the incoming message ID of self . Only incoming messages have such ID, for outgoing ones this function returns 0 and set valid to FALSE.

Parameters

self

a message

 

valid

either NULL, or a location in which to store TRUE if self contains a pending message ID.

[out]

Returns

the incoming message ID.

Since 0.15.3


tp_message_is_mutable ()

gboolean
tp_message_is_mutable (TpMessage *self);

Check if self is mutable. Only mutable messages can be modified using functions such as tp_message_set_string().

Parameters

self

a TpMessage

 

Returns

TRUE if the message is mutable.

Since 0.13.9


tp_message_append_part ()

guint
tp_message_append_part (TpMessage *self);

Append a body part to the message.

Parameters

self

a message

 

Returns

the part number

Since 0.7.21


tp_message_delete_key ()

gboolean
tp_message_delete_key (TpMessage *self,
                       guint part,
                       const gchar *key);

Remove the given key and its value from the given part.

Parameters

self

a message

 

part

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

key

a key in the mapping representing the part

 

Returns

TRUE if the key previously existed

Since 0.7.21


tp_message_delete_part ()

void
tp_message_delete_part (TpMessage *self,
                        guint part);

Delete the given body part from the message.

Parameters

self

a message

 

part

a part number, which must be strictly greater than 0, and strictly less than the number returned by tp_message_count_parts()

 

Since 0.7.21


tp_message_set_variant ()

void
tp_message_set_variant (TpMessage *self,
                        guint part,
                        const gchar *key,
                        GVariant *value);

Set key in part part of self to have value as its value.

If value is a floating reference (see g_variant_ref_sink()), then this function will take ownership of it.

Parameters

self

a message

 

part

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

key

a key in the mapping representing the part

 

value

a value

 

Since 0.19.10


tp_message_set_boolean ()

void
tp_message_set_boolean (TpMessage *self,
                        guint part,
                        const gchar *key,
                        gboolean b);

Set key in part part of self to have b as a boolean value.

Parameters

self

a message

 

part

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

key

a key in the mapping representing the part

 

b

a boolean value

 

Since 0.7.21


tp_message_set_bytes ()

void
tp_message_set_bytes (TpMessage *self,
                      guint part,
                      const gchar *key,
                      guint len,
                      gconstpointer bytes);

Set key in part part of self to have bytes as a byte-array value.

Parameters

self

a message

 

part

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

key

a key in the mapping representing the part

 

len

a number of bytes

 

bytes

an array of len bytes

 

Since 0.7.21


tp_message_set_int16()

#define             tp_message_set_int16(s, p, k, i)

Set key in part part of self to have i as a signed integer value.

Parameters

s

a message

 

p

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

k

a key in the mapping representing the part

 

i

an integer value

 

Since 0.7.21


tp_message_set_int32 ()

void
tp_message_set_int32 (TpMessage *self,
                      guint part,
                      const gchar *key,
                      gint32 i);

Set key in part part of self to have i as a signed integer value.

Parameters

self

a message

 

part

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

key

a key in the mapping representing the part

 

i

an integer value

 

Since 0.7.21


tp_message_set_int64 ()

void
tp_message_set_int64 (TpMessage *self,
                      guint part,
                      const gchar *key,
                      gint64 i);

Set key in part part of self to have i as a signed integer value.

Parameters

self

a message

 

part

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

key

a key in the mapping representing the part

 

i

an integer value

 

Since 0.7.21


tp_message_set_string ()

void
tp_message_set_string (TpMessage *self,
                       guint part,
                       const gchar *key,
                       const gchar *s);

Set key in part part of self to have s as a string value.

Parameters

self

a message

 

part

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

key

a key in the mapping representing the part

 

s

a string value

 

Since 0.7.21


tp_message_set_string_printf ()

void
tp_message_set_string_printf (TpMessage *self,
                              guint part,
                              const gchar *key,
                              const gchar *fmt,
                              ...);

Set key in part part of self to have a string value constructed from a printf-style format string.

Parameters

self

a message

 

part

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

key

a key in the mapping representing the part

 

fmt

a printf-style format string for the string value

 

...

arguments for the format string

 

Since 0.7.21


tp_message_set_uint16()

#define             tp_message_set_uint16(s, p, k, u)

Set key in part part of self to have u as an unsigned integer value.

Parameters

s

a message

 

p

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

k

a key in the mapping representing the part

 

u

an unsigned integer value

 

Since 0.7.21


tp_message_set_uint32 ()

void
tp_message_set_uint32 (TpMessage *self,
                       guint part,
                       const gchar *key,
                       guint32 u);

Set key in part part of self to have u as an unsigned integer value.

Parameters

self

a message

 

part

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

key

a key in the mapping representing the part

 

u

an unsigned integer value

 

Since 0.7.21


tp_message_set_uint64 ()

void
tp_message_set_uint64 (TpMessage *self,
                       guint part,
                       const gchar *key,
                       guint64 u);

Set key in part part of self to have u as an unsigned integer value.

Parameters

self

a message

 

part

a part number, which must be strictly less than the number returned by tp_message_count_parts()

 

key

a key in the mapping representing the part

 

u

an unsigned integer value

 

Since 0.7.21

Types and Values

TpMessage

typedef struct _TpMessage TpMessage;

Opaque structure representing a message in the Telepathy messages interface (an array of at least one mapping from string to variant, where the first mapping contains message headers and subsequent mappings contain the message body).

This base class provides convenience API for most of the common keys that can appear in the header. One notable exception is the sender of the message. Inside a connection manager, messages are represented by the TpCMMessage subclass, and you should use tp_cm_message_get_sender(). When composing a message in a client using TpClientMessage, messages do not have an explicit sender (the sender is automatically the local user). When a client sees a sent or received message signalled by the connection manager (represented by TpSignalledMessage), the message's sender (if any) can be accessed with tp_signalled_message_get_sender().

See Also

TpCMMessage, TpClientMessage, TpSignalledMessage