aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-message.c
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-05-20 09:34:31 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-06-12 14:56:47 +0800
commit44edc9fc835feaa279b5c20269a07aecff9e38cc (patch)
tree8c7675168b0fb6f9b30a1a0dc4f3738c19dd3715 /libempathy/empathy-message.c
parent29ab54db065d7753aebd5501680fb91049011fce (diff)
downloadgsoc2013-empathy-44edc9fc835feaa279b5c20269a07aecff9e38cc.tar
gsoc2013-empathy-44edc9fc835feaa279b5c20269a07aecff9e38cc.tar.gz
gsoc2013-empathy-44edc9fc835feaa279b5c20269a07aecff9e38cc.tar.bz2
gsoc2013-empathy-44edc9fc835feaa279b5c20269a07aecff9e38cc.tar.lz
gsoc2013-empathy-44edc9fc835feaa279b5c20269a07aecff9e38cc.tar.xz
gsoc2013-empathy-44edc9fc835feaa279b5c20269a07aecff9e38cc.tar.zst
gsoc2013-empathy-44edc9fc835feaa279b5c20269a07aecff9e38cc.zip
Add 'supersedes' property to EmpathyMessage
It would be nice to remove EmpathyMessage, because now that TpMessages are a GObject, EmpathyMessage is just an empty abstraction layer that we have to keep punching through.
Diffstat (limited to 'libempathy/empathy-message.c')
-rw-r--r--libempathy/empathy-message.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index 79625dd61..d68309bb3 100644
--- a/libempathy/empathy-message.c
+++ b/libempathy/empathy-message.c
@@ -50,6 +50,7 @@ typedef struct {
EmpathyContact *sender;
EmpathyContact *receiver;
gchar *token;
+ gchar *supersedes;
gchar *body;
gint64 timestamp;
gboolean is_backlog;
@@ -76,6 +77,7 @@ enum {
PROP_SENDER,
PROP_RECEIVER,
PROP_TOKEN,
+ PROP_SUPERSEDES,
PROP_BODY,
PROP_TIMESTAMP,
PROP_IS_BACKLOG,
@@ -126,6 +128,13 @@ empathy_message_class_init (EmpathyMessageClass *class)
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
+ PROP_SUPERSEDES,
+ g_param_spec_string ("supersedes",
+ "Supersedes Token",
+ "The message-token this message supersedes",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
PROP_BODY,
g_param_spec_string ("body",
"Message Body",
@@ -211,6 +220,7 @@ empathy_message_finalize (GObject *object)
}
g_free (priv->token);
+ g_free (priv->supersedes);
g_free (priv->body);
G_OBJECT_CLASS (empathy_message_parent_class)->finalize (object);
@@ -239,6 +249,9 @@ message_get_property (GObject *object,
case PROP_TOKEN:
g_value_set_string (value, priv->token);
break;
+ case PROP_SUPERSEDES:
+ g_value_set_string (value, priv->supersedes);
+ break;
case PROP_BODY:
g_value_set_string (value, priv->body);
break;
@@ -289,6 +302,10 @@ message_set_property (GObject *object,
g_assert (priv->token == NULL); /* construct only */
priv->token = g_value_dup_string (value);
break;
+ case PROP_SUPERSEDES:
+ g_assert (priv->supersedes == NULL); /* construct only */
+ priv->supersedes = g_value_dup_string (value);
+ break;
case PROP_BODY:
g_assert (priv->body == NULL); /* construct only */
priv->body = g_value_dup_string (value);
@@ -502,6 +519,30 @@ empathy_message_get_token (EmpathyMessage *message)
}
const gchar *
+empathy_message_get_supersedes (EmpathyMessage *message)
+{
+ EmpathyMessagePriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), NULL);
+
+ priv = GET_PRIV (message);
+
+ return priv->supersedes;
+}
+
+gboolean
+empathy_message_is_edit (EmpathyMessage *message)
+{
+ EmpathyMessagePriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), FALSE);
+
+ priv = GET_PRIV (message);
+
+ return !tp_str_empty (priv->supersedes);
+}
+
+const gchar *
empathy_message_get_body (EmpathyMessage *message)
{
EmpathyMessagePriv *priv;
@@ -698,6 +739,7 @@ empathy_message_new_from_tp_message (TpMessage *tp_msg,
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),
"flags", flags,