aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-chat.c
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-05-25 15:10:12 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-06-14 00:04:04 +0800
commit2d91c5513fce276eb8a65a463119a80609a4eeb7 (patch)
tree899ef02c932db94661f169fb36d5f88257fd2df1 /libempathy-gtk/empathy-chat.c
parent3884ef55323a4060d043d37d565af3a8c2e9a293 (diff)
downloadgsoc2013-empathy-2d91c5513fce276eb8a65a463119a80609a4eeb7.tar
gsoc2013-empathy-2d91c5513fce276eb8a65a463119a80609a4eeb7.tar.gz
gsoc2013-empathy-2d91c5513fce276eb8a65a463119a80609a4eeb7.tar.bz2
gsoc2013-empathy-2d91c5513fce276eb8a65a463119a80609a4eeb7.tar.lz
gsoc2013-empathy-2d91c5513fce276eb8a65a463119a80609a4eeb7.tar.xz
gsoc2013-empathy-2d91c5513fce276eb8a65a463119a80609a4eeb7.tar.zst
gsoc2013-empathy-2d91c5513fce276eb8a65a463119a80609a4eeb7.zip
Replace tpl_text_event_dup_supersedes() with synthetic message
This allows us to handle the case where we get b-supersedes-a, but we've lost the original message a.
Diffstat (limited to 'libempathy-gtk/empathy-chat.c')
-rw-r--r--libempathy-gtk/empathy-chat.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 85a0b7793..dd4bdf0f8 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -2332,31 +2332,37 @@ got_filtered_messages_cb (GObject *manager,
for (l = messages; l; l = g_list_next (l)) {
EmpathyMessage *message;
- GList *supersedes;
- g_assert (TPL_IS_EVENT (l->data));
-
- /* we need the last message this one supersedes, which is the
- * the original */
- supersedes = tpl_text_event_dup_supersedes (l->data);
-
- if (supersedes != NULL) {
- message = empathy_message_from_tpl_log_event (
- g_list_last (supersedes)->data);
- empathy_chat_view_append_message (chat->view, message);
-
- g_object_unref (message);
- }
- g_list_free_full (supersedes, g_object_unref);
+ g_assert (TPL_IS_EVENT (l->data));
- /* append the latest message */
message = empathy_message_from_tpl_log_event (l->data);
g_object_unref (l->data);
- if (empathy_message_is_edit (message))
+ if (empathy_message_is_edit (message)) {
+ /* this is an edited message, create a synthetic event
+ * using the supersedes token and
+ * original-message-sent timestamp, that we can then
+ * replace */
+ EmpathyMessage *syn_msg = g_object_new (
+ EMPATHY_TYPE_MESSAGE,
+ "body", "",
+ "token", empathy_message_get_supersedes (message),
+ "type", empathy_message_get_tptype (message),
+ "timestamp", empathy_message_get_original_timestamp (message),
+ "incoming", empathy_message_is_incoming (message),
+ "is-backlog", TRUE,
+ "receiver", empathy_message_get_receiver (message),
+ "sender", empathy_message_get_sender (message),
+ NULL);
+
+ empathy_chat_view_append_message (chat->view, syn_msg);
empathy_chat_view_edit_message (chat->view, message);
- else
+
+ g_object_unref (syn_msg);
+ } else {
+ /* append the latest message */
empathy_chat_view_append_message (chat->view, message);
+ }
g_object_unref (message);
}