[empathy: 2/19] Add 'supersedes' property to EmpathyMessage
- From: Danielle Madeley <daniellem src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy: 2/19] Add 'supersedes' property to EmpathyMessage
- Date: Mon, 20 Jun 2011 10:08:05 +0000 (UTC)
commit 44edc9fc835feaa279b5c20269a07aecff9e38cc
Author: Danielle Madeley <danielle madeley collabora co uk>
Date: Fri May 20 11:34:31 2011 +1000
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.
libempathy/empathy-message.c | 42 ++++++++++++++++++++++++++++++++++++++++++
libempathy/empathy-message.h | 2 ++
2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index 79625dd..d68309b 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,
diff --git a/libempathy/empathy-message.h b/libempathy/empathy-message.h
index f6c57ed..cb05967 100644
--- a/libempathy/empathy-message.h
+++ b/libempathy/empathy-message.h
@@ -70,6 +70,8 @@ void empathy_message_set_receiver (EmpathyMessage
EmpathyContact *contact);
const gchar * empathy_message_get_body (EmpathyMessage *message);
const gchar * empathy_message_get_token (EmpathyMessage *message);
+const gchar * empathy_message_get_supersedes (EmpathyMessage *message);
+gboolean empathy_message_is_edit (EmpathyMessage *message);
gint64 empathy_message_get_timestamp (EmpathyMessage *message);
gboolean empathy_message_is_backlog (EmpathyMessage *message);
gboolean empathy_message_is_incoming (EmpathyMessage *message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]