[empathy: 1/22] message: store the TpMessage when created with one



commit ccc394aa7971cac1530931357dae7aaf14299ef2
Author: Jonny Lamb <jonnylamb gnome org>
Date:   Thu May 12 14:29:23 2011 +0100

    message: store the TpMessage when created with one
    
    Signed-off-by: Jonny Lamb <jonnylamb gnome org>

 libempathy/empathy-message.c |   34 ++++++++++++++++++++++++++++++++++
 libempathy/empathy-message.h |    2 ++
 2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index 076a100..64977e0 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 7508cb0..52e45b6 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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]