/pidgin/main: f4d353818589: Add time property to PurpleMessage

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu May 22 13:37:36 EDT 2014


Changeset: f4d3538185897eb2df0c6b9c941e60673d5531c4
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-05-22 19:09 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/f4d353818589

Description:

Add time property to PurpleMessage

diffstat:

 libpurple/message.c |  32 ++++++++++++++++++++++++++++++++
 libpurple/message.h |   6 ++++++
 2 files changed, 38 insertions(+), 0 deletions(-)

diffs (100 lines):

diff --git a/libpurple/message.c b/libpurple/message.c
--- a/libpurple/message.c
+++ b/libpurple/message.c
@@ -33,6 +33,7 @@ typedef struct {
 	guint id;
 	gchar *who;
 	gchar *contents;
+	guint64 msgtime;
 	PurpleMessageFlags flags;
 } PurpleMessagePrivate;
 
@@ -42,6 +43,7 @@ enum
 	PROP_ID,
 	PROP_WHO,
 	PROP_CONTENTS,
+	PROP_TIME,
 	PROP_FLAGS,
 	PROP_LAST
 };
@@ -63,6 +65,7 @@ purple_message_new(const gchar *who, con
 		"who", who,
 		"contents", contents,
 		"flags", flags,
+		"time", (guint64)time(NULL),
 		NULL);
 }
 
@@ -118,6 +121,26 @@ purple_message_is_empty(PurpleMessage *m
 	return (cont == NULL || cont[0] == '\0');
 }
 
+void
+purple_message_set_time(PurpleMessage *msg, guint64 msgtime)
+{
+	PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(msg);
+
+	g_return_if_fail(priv != NULL);
+
+	priv->msgtime = msgtime;
+}
+
+guint64
+purple_message_get_time(PurpleMessage *msg)
+{
+	PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(msg);
+
+	g_return_val_if_fail(priv != NULL, 0);
+
+	return priv->msgtime;
+}
+
 PurpleMessageFlags
 purple_message_get_flags(PurpleMessage *msg)
 {
@@ -174,6 +197,9 @@ purple_message_get_property(GObject *obj
 		case PROP_CONTENTS:
 			g_value_set_string(value, priv->contents);
 			break;
+		case PROP_TIME:
+			g_value_set_uint64(value, priv->msgtime);
+			break;
 		case PROP_FLAGS:
 			g_value_set_uint(value, priv->flags);
 			break;
@@ -199,6 +225,9 @@ purple_message_set_property(GObject *obj
 			g_free(priv->contents);
 			priv->contents = g_strdup(g_value_get_string(value));
 			break;
+		case PROP_TIME:
+			priv->msgtime = g_value_get_uint64(value);
+			break;
 		case PROP_FLAGS:
 			priv->flags = g_value_get_uint(value);
 			break;
@@ -232,6 +261,9 @@ purple_message_class_init(PurpleMessageC
 	properties[PROP_CONTENTS] = g_param_spec_string("contents",
 		"Contents", "The message text",
 		NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+	properties[PROP_TIME] = g_param_spec_uint64("time",
+		"Time", "Message time",
+		0, G_MAXUINT64, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 	/* XXX: it should be spec_enum, but PurpleMessageFlags isn't
 	 * gobjectified (yet) */
 	properties[PROP_FLAGS] = g_param_spec_uint("flags",
diff --git a/libpurple/message.h b/libpurple/message.h
--- a/libpurple/message.h
+++ b/libpurple/message.h
@@ -104,6 +104,12 @@ purple_message_get_contents(PurpleMessag
 gboolean
 purple_message_is_empty(PurpleMessage *msg);
 
+void
+purple_message_set_time(PurpleMessage *msg, guint64 msgtime);
+
+guint64
+purple_message_get_time(PurpleMessage *msg);
+
 PurpleMessageFlags
 purple_message_get_flags(PurpleMessage *msg);
 



More information about the Commits mailing list