diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-04-15 21:17:07 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-04-18 19:09:49 +0800 |
commit | 2af2286eb763f631624db953679c1cba28ff91d7 (patch) | |
tree | 2a3f12afce8baf3a662e19f5612edc5de261ae06 /libempathy/empathy-message.c | |
parent | 05ab1873675c5e2a6a04c85ef976fb1067a0d743 (diff) | |
download | gsoc2013-empathy-2af2286eb763f631624db953679c1cba28ff91d7.tar gsoc2013-empathy-2af2286eb763f631624db953679c1cba28ff91d7.tar.gz gsoc2013-empathy-2af2286eb763f631624db953679c1cba28ff91d7.tar.bz2 gsoc2013-empathy-2af2286eb763f631624db953679c1cba28ff91d7.tar.lz gsoc2013-empathy-2af2286eb763f631624db953679c1cba28ff91d7.tar.xz gsoc2013-empathy-2af2286eb763f631624db953679c1cba28ff91d7.tar.zst gsoc2013-empathy-2af2286eb763f631624db953679c1cba28ff91d7.zip |
factor out empathy_message_new_from_tp_message
Diffstat (limited to 'libempathy/empathy-message.c')
-rw-r--r-- | libempathy/empathy-message.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c index f98e955a0..520dbe650 100644 --- a/libempathy/empathy-message.c +++ b/libempathy/empathy-message.c @@ -721,3 +721,36 @@ empathy_message_set_flags (EmpathyMessage *self, g_object_notify (G_OBJECT (self), "flags"); } + +EmpathyMessage * +empathy_message_new_from_tp_message (TpMessage *tp_msg, + gboolean incoming) +{ + EmpathyMessage *message; + gchar *body; + TpChannelTextMessageFlags flags; + guint id; + + g_return_val_if_fail (TP_IS_MESSAGE (tp_msg), NULL); + + body = tp_message_to_text (tp_msg, &flags); + + message = g_object_new (EMPATHY_TYPE_MESSAGE, + "body", body, + "type", tp_message_get_message_type (tp_msg), + "timestamp", tp_message_get_received_timestamp (tp_msg), + "flags", flags, + "is-backlog", flags & TP_CHANNEL_TEXT_MESSAGE_FLAG_SCROLLBACK, + "incoming", incoming, + NULL); + + /* FIXME: this is pretty low level, ideally we shouldn't have to use the + * ID directly but we don't use TpTextChannel's ack API everywhere yet. */ + id = tp_asv_get_uint32 (tp_message_peek (tp_msg, 0), + "pending-message-id", NULL); + + empathy_message_set_id (message, id); + + g_free (body); + return message; +} |