aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonny Lamb <jonnylamb@gnome.org>2011-05-12 21:29:23 +0800
committerJonny Lamb <jonnylamb@gnome.org>2011-05-12 21:29:23 +0800
commitccc394aa7971cac1530931357dae7aaf14299ef2 (patch)
tree791b72660eff9bb72647c52c61fa16173f01f604
parent0a6ce2b0c136c05fa5395d51517208c041bc392d (diff)
downloadgsoc2013-empathy-ccc394aa7971cac1530931357dae7aaf14299ef2.tar
gsoc2013-empathy-ccc394aa7971cac1530931357dae7aaf14299ef2.tar.gz
gsoc2013-empathy-ccc394aa7971cac1530931357dae7aaf14299ef2.tar.bz2
gsoc2013-empathy-ccc394aa7971cac1530931357dae7aaf14299ef2.tar.lz
gsoc2013-empathy-ccc394aa7971cac1530931357dae7aaf14299ef2.tar.xz
gsoc2013-empathy-ccc394aa7971cac1530931357dae7aaf14299ef2.tar.zst
gsoc2013-empathy-ccc394aa7971cac1530931357dae7aaf14299ef2.zip
message: store the TpMessage when created with one
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
-rw-r--r--libempathy/empathy-message.c34
-rw-r--r--libempathy/empathy-message.h2
2 files changed, 36 insertions, 0 deletions
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index 076a10053..64977e007 100644
--- a/libempathy/empathy-message.c
+++ b/libempathy/empathy-message.c
@@ -40,6 +40,7 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyMessage)
typedef struct {
+ TpMessage *tp_message;
TpChannelTextMessageType type;
EmpathyContact *sender;
EmpathyContact *receiver;
@@ -73,6 +74,7 @@ enum {
PROP_IS_BACKLOG,
PROP_INCOMING,
PROP_FLAGS,
+ PROP_TP_MESSAGE,
};
static void
@@ -153,6 +155,15 @@ 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_TP_MESSAGE,
+ g_param_spec_object ("tp-message",
+ "TpMessage",
+ "The TpMessage of this message",
+ TP_TYPE_MESSAGE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+ G_PARAM_CONSTRUCT_ONLY));
+
g_type_class_add_private (object_class, sizeof (EmpathyMessagePriv));
}
@@ -181,6 +192,10 @@ empathy_message_finalize (GObject *object)
g_object_unref (priv->receiver);
}
+ if (priv->tp_message) {
+ g_object_unref (priv->tp_message);
+ }
+
g_free (priv->body);
G_OBJECT_CLASS (empathy_message_parent_class)->finalize (object);
@@ -221,6 +236,9 @@ message_get_property (GObject *object,
case PROP_FLAGS:
g_value_set_uint (value, priv->flags);
break;
+ case PROP_TP_MESSAGE:
+ g_value_set_object (value, priv->tp_message);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -267,6 +285,9 @@ message_set_property (GObject *object,
case PROP_FLAGS:
priv->flags = g_value_get_uint (value);
break;
+ case PROP_TP_MESSAGE:
+ priv->tp_message = g_value_dup_object (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -342,6 +363,18 @@ empathy_message_from_tpl_log_event (TplEvent *logevent)
return retval;
}
+TpMessage *
+empathy_message_get_tp_message (EmpathyMessage *message)
+{
+ EmpathyMessagePriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), NULL);
+
+ priv = GET_PRIV (message);
+
+ return priv->tp_message;
+}
+
TpChannelTextMessageType
empathy_message_get_tptype (EmpathyMessage *message)
{
@@ -634,6 +667,7 @@ empathy_message_new_from_tp_message (TpMessage *tp_msg,
"flags", flags,
"is-backlog", flags & TP_CHANNEL_TEXT_MESSAGE_FLAG_SCROLLBACK,
"incoming", incoming,
+ "tp-message", tp_msg,
NULL);
priv = GET_PRIV (message);
diff --git a/libempathy/empathy-message.h b/libempathy/empathy-message.h
index 7508cb08e..52e45b6e2 100644
--- a/libempathy/empathy-message.h
+++ b/libempathy/empathy-message.h
@@ -59,6 +59,8 @@ EmpathyMessage * empathy_message_from_tpl_log_event (TplEvent
EmpathyMessage * empathy_message_new_from_tp_message (TpMessage *tp_msg,
gboolean incoming);
+TpMessage * empathy_message_get_tp_message (EmpathyMessage *message);
+
TpChannelTextMessageType empathy_message_get_tptype (EmpathyMessage *message);
EmpathyContact * empathy_message_get_sender (EmpathyMessage *message);
void empathy_message_set_sender (EmpathyMessage *message,