/pidgin/main: dc5d15df3a88: PurpleMessage: add author's alias

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu May 22 18:11:08 EDT 2014


Changeset: dc5d15df3a88eaa4d5f259d4eddb3a8f268e674b
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-05-23 00:11 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/dc5d15df3a88

Description:

PurpleMessage: add author's alias

diffstat:

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

diffs (98 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 *alias;
 	gchar *contents;
 	guint64 msgtime;
 	PurpleMessageFlags flags;
@@ -43,6 +44,7 @@ enum
 	PROP_0,
 	PROP_ID,
 	PROP_WHO,
+	PROP_ALIAS,
 	PROP_CONTENTS,
 	PROP_TIME,
 	PROP_FLAGS,
@@ -105,6 +107,22 @@ purple_message_get_who(PurpleMessage *ms
 }
 
 void
+purple_message_set_alias(PurpleMessage *msg, const gchar *alias)
+{
+	g_object_set(msg, "alias", alias, NULL);
+}
+
+const gchar *
+purple_message_get_alias(PurpleMessage *msg)
+{
+	PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(msg);
+
+	g_return_val_if_fail(priv != NULL, NULL);
+
+	return priv->alias;
+}
+
+void
 purple_message_set_contents(PurpleMessage *msg, const gchar *cont)
 {
 	g_object_set(msg, "contents", cont, NULL);
@@ -184,6 +202,7 @@ purple_message_finalize(GObject *obj)
 	PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(message);
 
 	g_free(priv->who);
+	g_free(priv->alias);
 	g_free(priv->contents);
 
 	G_OBJECT_CLASS(parent_class)->finalize(obj);
@@ -203,6 +222,9 @@ purple_message_get_property(GObject *obj
 		case PROP_WHO:
 			g_value_set_string(value, priv->who);
 			break;
+		case PROP_ALIAS:
+			g_value_set_string(value, priv->alias);
+			break;
 		case PROP_CONTENTS:
 			g_value_set_string(value, priv->contents);
 			break;
@@ -230,6 +252,10 @@ purple_message_set_property(GObject *obj
 			g_free(priv->who);
 			priv->who = g_strdup(g_value_get_string(value));
 			break;
+		case PROP_ALIAS:
+			g_free(priv->alias);
+			priv->alias = g_strdup(g_value_get_string(value));
+			break;
 		case PROP_CONTENTS:
 			g_free(priv->contents);
 			priv->contents = g_strdup(g_value_get_string(value));
@@ -267,6 +293,10 @@ purple_message_class_init(PurpleMessageC
 		"incoming messages) or the recipient (for outgoing). "
 		"Unused for outgoing chat messages.",
 		NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+	properties[PROP_ALIAS] = g_param_spec_string("alias",
+		"Author's alias", "The alias of the person, who sent the "
+		"message. For outgoing messages, it's your alias.",
+		NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 	properties[PROP_CONTENTS] = g_param_spec_string("contents",
 		"Contents", "The message text",
 		NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
diff --git a/libpurple/message.h b/libpurple/message.h
--- a/libpurple/message.h
+++ b/libpurple/message.h
@@ -96,6 +96,12 @@ const gchar *
 purple_message_get_who(PurpleMessage *msg);
 
 void
+purple_message_set_alias(PurpleMessage *msg, const gchar *alias);
+
+const gchar *
+purple_message_get_alias(PurpleMessage *msg);
+
+void
 purple_message_set_contents(PurpleMessage *msg, const gchar *cont);
 
 const gchar *



More information about the Commits mailing list