aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy/empathy-message.c38
-rw-r--r--libempathy/empathy-message.h1
2 files changed, 36 insertions, 3 deletions
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index a1b7ae0e5..e1b168b1c 100644
--- a/libempathy/empathy-message.c
+++ b/libempathy/empathy-message.c
@@ -50,6 +50,7 @@ typedef struct {
gchar *supersedes;
gchar *body;
gint64 timestamp;
+ gint64 original_timestamp;
gboolean is_backlog;
guint id;
gboolean incoming;
@@ -77,6 +78,7 @@ enum {
PROP_SUPERSEDES,
PROP_BODY,
PROP_TIMESTAMP,
+ PROP_ORIGINAL_TIMESTAMP,
PROP_IS_BACKLOG,
PROP_INCOMING,
PROP_FLAGS,
@@ -147,6 +149,13 @@ empathy_message_class_init (EmpathyMessageClass *class)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
+ PROP_ORIGINAL_TIMESTAMP,
+ g_param_spec_int64 ("original-timestamp",
+ "Original Timestamp",
+ "Timestamp of the original message",
+ G_MININT64, G_MAXINT64, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
PROP_IS_BACKLOG,
g_param_spec_boolean ("is-backlog",
"History message",
@@ -241,6 +250,9 @@ message_get_property (GObject *object,
case PROP_TIMESTAMP:
g_value_set_int64 (value, priv->timestamp);
break;
+ case PROP_ORIGINAL_TIMESTAMP:
+ g_value_set_int64 (value, priv->original_timestamp);
+ break;
case PROP_IS_BACKLOG:
g_value_set_boolean (value, priv->is_backlog);
break;
@@ -295,6 +307,9 @@ message_set_property (GObject *object,
if (priv->timestamp <= 0)
priv->timestamp = empathy_time_get_current ();
break;
+ case PROP_ORIGINAL_TIMESTAMP:
+ priv->original_timestamp = g_value_get_int64 (value);
+ break;
case PROP_IS_BACKLOG:
priv->is_backlog = g_value_get_boolean (value);
break;
@@ -350,6 +365,7 @@ empathy_message_from_tpl_log_event (TplEvent *logevent)
"supersedes", tpl_text_event_get_supersedes_token (textevent),
"body", body,
"timestamp", tpl_event_get_timestamp (logevent),
+ "original-timestamp", tpl_text_event_get_original_timestamp (textevent),
"is-backlog", TRUE,
NULL);
@@ -532,6 +548,18 @@ empathy_message_get_timestamp (EmpathyMessage *message)
return priv->timestamp;
}
+gint64
+empathy_message_get_original_timestamp (EmpathyMessage *message)
+{
+ EmpathyMessagePriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), -1);
+
+ priv = GET_PRIV (message);
+
+ return priv->original_timestamp;
+}
+
gboolean
empathy_message_is_backlog (EmpathyMessage *message)
{
@@ -709,17 +737,23 @@ empathy_message_new_from_tp_message (TpMessage *tp_msg,
gchar *body;
TpChannelTextMessageFlags flags;
guint id;
+ gint64 original_timestamp;
+ const GHashTable *part = tp_message_peek (tp_msg, 0);
g_return_val_if_fail (TP_IS_MESSAGE (tp_msg), NULL);
body = tp_message_to_text (tp_msg, &flags);
+ original_timestamp = tp_asv_get_int64 (part,
+ "original-message-received", NULL);
+
message = g_object_new (EMPATHY_TYPE_MESSAGE,
"body", body,
"token", tp_message_get_token (tp_msg),
"supersedes", tp_message_get_supersedes (tp_msg),
"type", tp_message_get_message_type (tp_msg),
"timestamp", tp_message_get_received_timestamp (tp_msg),
+ "original-timestamp", original_timestamp,
"flags", flags,
"is-backlog", flags & TP_CHANNEL_TEXT_MESSAGE_FLAG_SCROLLBACK,
"incoming", incoming,
@@ -729,9 +763,7 @@ empathy_message_new_from_tp_message (TpMessage *tp_msg,
/* 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);
-
+ id = tp_asv_get_uint32 (part, "pending-message-id", NULL);
priv->id = id;
g_free (body);
diff --git a/libempathy/empathy-message.h b/libempathy/empathy-message.h
index 16c9e62e1..9c24f6365 100644
--- a/libempathy/empathy-message.h
+++ b/libempathy/empathy-message.h
@@ -71,6 +71,7 @@ const gchar * empathy_message_get_token (EmpathyMessage
const gchar * empathy_message_get_supersedes (EmpathyMessage *message);
gboolean empathy_message_is_edit (EmpathyMessage *message);
gint64 empathy_message_get_timestamp (EmpathyMessage *message);
+gint64 empathy_message_get_original_timestamp (EmpathyMessage *message);
gboolean empathy_message_is_backlog (EmpathyMessage *message);
gboolean empathy_message_is_incoming (EmpathyMessage *message);