diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-12-13 15:49:36 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-12-13 18:12:43 +0000 |
commit | 72a436b2b953185ca6314fd34de87a2b32605aac (patch) | |
tree | b00a421db210c95c237575b3973bfd4b46cf2b71 /telepathy-glib/cm-message.c | |
parent | 54590e37f68e499aaab25cd0c2d7ebd0d7afeef0 (diff) | |
download | telepathy-glib-72a436b2b953185ca6314fd34de87a2b32605aac.tar.gz |
tp_cm_message_new_text: add
This is convenient for simple text-only CMs.
Diffstat (limited to 'telepathy-glib/cm-message.c')
-rw-r--r-- | telepathy-glib/cm-message.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/telepathy-glib/cm-message.c b/telepathy-glib/cm-message.c index b48e022f8..1291e82ac 100644 --- a/telepathy-glib/cm-message.c +++ b/telepathy-glib/cm-message.c @@ -254,3 +254,40 @@ tp_cm_message_get_sender (TpMessage *self) g_return_val_if_fail (TP_IS_CM_MESSAGE (self), 0); return tp_asv_get_uint32 (tp_message_peek (self, 0), "message-sender", NULL); } + +/** + * tp_cm_message_new_text: + * @conn: a connection + * @sender: the #TpHandle of the sender of the message + * @type: the type of message + * @text: content of the messsage + * + * A convenient function to create a new #TpCMMessage having + * 'text/plain' as 'content-type', @type as 'message-type', + * @text as 'content' and @sender as its sender. + * + * Returns: (transfer full): a newly allocated #TpCMMessage + * + * Since: 0.13.UNRELEASED + */ +TpMessage * +tp_cm_message_new_text (TpBaseConnection *conn, + TpHandle sender, + TpChannelTextMessageType type, + const gchar *text) +{ + TpMessage *msg; + + msg = tp_cm_message_new (conn, 2); + + if (sender != 0) + tp_cm_message_set_sender (msg, sender); + + if (type != TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL) + tp_message_set_uint32 (msg, 0, "message-type", type); + + tp_message_set_string (msg, 1, "content-type", "text/plain"); + tp_message_set_string (msg, 1, "content", text); + + return msg; +} |