Switch purple_conversation_write_message to PurpleMessage

Thu, 22 May 2014 20:20:19 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Thu, 22 May 2014 20:20:19 +0200
changeset 36088
4c386387f6f3
parent 36087
afa337c971e0
child 36089
c035b9a63457

Switch purple_conversation_write_message to PurpleMessage

finch/gntconv.c file | annotate | diff | comparison | revisions
libpurple/conversation.c file | annotate | diff | comparison | revisions
libpurple/conversation.h file | annotate | diff | comparison | revisions
libpurple/conversationtypes.c file | annotate | diff | comparison | revisions
libpurple/message.c file | annotate | diff | comparison | revisions
libpurple/message.h file | annotate | diff | comparison | revisions
libpurple/plugins/offlinemsg.c file | annotate | diff | comparison | revisions
libpurple/plugins/perl/common/Conversation.xs file | annotate | diff | comparison | revisions
libpurple/plugins/tcl/tcl_cmds.c file | annotate | diff | comparison | revisions
libpurple/protocols/irc/cmds.c file | annotate | diff | comparison | revisions
libpurple/protocols/irc/msgs.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/presence.c file | annotate | diff | comparison | revisions
libpurple/protocols/silc/ops.c file | annotate | diff | comparison | revisions
libpurple/protocols/silc/silc.c file | annotate | diff | comparison | revisions
libpurple/server.c file | annotate | diff | comparison | revisions
pidgin/gtkconv.c file | annotate | diff | comparison | revisions
--- a/finch/gntconv.c	Thu May 22 19:36:16 2014 +0200
+++ b/finch/gntconv.c	Thu May 22 20:20:19 2014 +0200
@@ -1083,18 +1083,23 @@
 }
 
 static void
-finch_write_chat(PurpleChatConversation *chat, const char *who, const char *message,
-		PurpleMessageFlags flags, time_t mtime)
+finch_write_chat(PurpleChatConversation *chat, PurpleMessage *msg)
 {
-	purple_conversation_write(PURPLE_CONVERSATION(chat), who, message, flags, mtime);
+	purple_conversation_write(PURPLE_CONVERSATION(chat),
+		purple_message_get_who(msg),
+		purple_message_get_contents(msg),
+		purple_message_get_flags(msg),
+		purple_message_get_time(msg));
 }
 
 static void
-finch_write_im(PurpleIMConversation *im, const char *who, const char *message,
-		PurpleMessageFlags flags, time_t mtime)
+finch_write_im(PurpleIMConversation *im, PurpleMessage *msg)
 {
 	PurpleConversation *conv = PURPLE_CONVERSATION(im);
 	PurpleAccount *account = purple_conversation_get_account(conv);
+	PurpleMessageFlags flags = purple_message_get_flags(msg);
+	const gchar *who = purple_message_get_who(msg);
+
 	if (flags & PURPLE_MESSAGE_SEND)
 	{
 		who = purple_connection_get_display_name(purple_account_get_connection(account));
@@ -1112,7 +1117,8 @@
 			who = purple_buddy_get_contact_alias(buddy);
 	}
 
-	purple_conversation_write(conv, who, message, flags, mtime);
+	purple_conversation_write(conv, who, purple_message_get_contents(msg),
+		flags, purple_message_get_time(msg));
 }
 
 static void
--- a/libpurple/conversation.c	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/conversation.c	Thu May 22 20:20:19 2014 +0200
@@ -144,8 +144,8 @@
 
 			err = purple_serv_send_im(gc, msg);
 
-			if ((err > 0) && (displayed != NULL)) /* TODO: use msg! */
-				purple_conversation_write_message(conv, NULL, displayed, msgflags, time(NULL));
+			if ((err > 0) && (displayed != NULL))
+				purple_conversation_write_message(conv, msg);
 
 			purple_signal_emit(purple_conversations_get_handle(),
 				"sent-im-msg", account, msg);
@@ -683,8 +683,7 @@
 }
 
 void
-purple_conversation_write_message(PurpleConversation *conv, const char *who,
-		const char *message, PurpleMessageFlags flags, time_t mtime)
+purple_conversation_write_message(PurpleConversation *conv, PurpleMessage *msg)
 {
 	PurpleConversationClass *klass = NULL;
 
@@ -693,7 +692,7 @@
 	klass = PURPLE_CONVERSATION_GET_CLASS(conv);
 
 	if (klass && klass->write_message)
-		klass->write_message(conv, who, message, flags, mtime);
+		klass->write_message(conv, msg);
 }
 
 void purple_conversation_write_system_message(PurpleConversation *conv,
--- a/libpurple/conversation.h	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/conversation.h	Thu May 22 20:20:19 2014 +0200
@@ -142,6 +142,7 @@
 
 #include <glib.h>
 #include <glib-object.h>
+#include "message.h"
 
 /**************************************************************************/
 /** PurpleConversation                                                    */
@@ -179,8 +180,7 @@
 struct _PurpleConversationClass {
 	GObjectClass parent_class;
 
-	void (*write_message)(PurpleConversation *conv, const char *who,
-			const char *message, PurpleMessageFlags flags, time_t mtime);
+	void (*write_message)(PurpleConversation *conv, PurpleMessage *msg);
 
 	/*< private >*/
 	void (*_purple_reserved1)(void);
@@ -250,13 +250,8 @@
 	void (*create_conversation)(PurpleConversation *conv);
 	void (*destroy_conversation)(PurpleConversation *conv);
 
-	void (*write_chat)(PurpleChatConversation *chat, const char *who,
-	                  const char *message, PurpleMessageFlags flags,
-	                  time_t mtime);
-
-	void (*write_im)(PurpleIMConversation *im, const char *who,
-	                 const char *message, PurpleMessageFlags flags,
-	                 time_t mtime);
+	void (*write_chat)(PurpleChatConversation *chat, PurpleMessage *msg);
+	void (*write_im)(PurpleIMConversation *im, PurpleMessage *msg);
 
 	void (*write_conv)(PurpleConversation *conv,
 	                   const char *name,
@@ -512,8 +507,7 @@
  * Writes to a chat or an IM.
  */
 void purple_conversation_write_message(PurpleConversation *conv,
-		const char *who, const char *message,
-		PurpleMessageFlags flags, time_t mtime);
+	PurpleMessage *msg);
 
 /**
  * purple_conversation_write_system_message:
--- a/libpurple/conversationtypes.c	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/conversationtypes.c	Thu May 22 20:20:19 2014 +0200
@@ -353,25 +353,29 @@
 }
 
 static void
-im_conversation_write_message(PurpleConversation *conv, const char *who, const char *message,
-			  PurpleMessageFlags flags, time_t mtime)
+im_conversation_write_message(PurpleConversation *conv, PurpleMessage *msg)
 {
 	PurpleConversationUiOps *ops;
 	PurpleIMConversation *im = PURPLE_IM_CONVERSATION(conv);
 
 	g_return_if_fail(im != NULL);
-	g_return_if_fail(message != NULL);
+	g_return_if_fail(msg != NULL);
 
 	ops = purple_conversation_get_ui_ops(conv);
 
-	if ((flags & PURPLE_MESSAGE_RECV) == PURPLE_MESSAGE_RECV)
+	if (purple_message_get_flags(msg) & PURPLE_MESSAGE_RECV)
 		purple_im_conversation_set_typing_state(im, PURPLE_IM_NOT_TYPING);
 
 	/* Pass this on to either the ops structure or the default write func. */
 	if (ops != NULL && ops->write_im != NULL)
-		ops->write_im(im, who, message, flags, mtime);
-	else
-		purple_conversation_write(conv, who, message, flags, mtime);
+		ops->write_im(im, msg);
+	else {
+		purple_conversation_write(conv,
+			purple_message_get_who(msg),
+			purple_message_get_contents(msg),
+			purple_message_get_flags(msg),
+			purple_message_get_time(msg));
+	}
 }
 
 /**************************************************************************
@@ -797,43 +801,37 @@
 }
 
 static void
-chat_conversation_write_message(PurpleConversation *conv, const char *who, const char *message,
-				PurpleMessageFlags flags, time_t mtime)
+chat_conversation_write_message(PurpleConversation *conv, PurpleMessage *msg)
 {
 	PurpleAccount *account;
 	PurpleConversationUiOps *ops;
 	PurpleChatConversationPrivate *priv = PURPLE_CHAT_CONVERSATION_GET_PRIVATE(conv);
+	PurpleMessageFlags flags;
 
 	g_return_if_fail(priv != NULL);
-	g_return_if_fail(who != NULL);
-	g_return_if_fail(message != NULL);
+	g_return_if_fail(msg != NULL);
 
 	account = purple_conversation_get_account(conv);
 
 	/* Don't display this if the person who wrote it is ignored. */
-	if (purple_chat_conversation_is_ignored_user(PURPLE_CHAT_CONVERSATION(conv), who))
+	if (purple_chat_conversation_is_ignored_user(
+		PURPLE_CHAT_CONVERSATION(conv), purple_message_get_who(msg)))
+	{
 		return;
-
-	if (mtime < 0) {
-		purple_debug_error("conversation",
-				"purple_conv_chat_write ignoring negative timestamp\n");
-		/* TODO: Would be more appropriate to use a value that indicates
-		   that the timestamp is unknown, and surface that in the UI. */
-		mtime = time(NULL);
 	}
 
-	if (TRUE) {
-		const char *str;
-
-		str = purple_normalize(account, who);
+#if 0
+	/* XXX: this should not be necessary */
+	if (purple_strequal(purple_normalize(account, who), priv->nick)) {
+		flags |= PURPLE_MESSAGE_SEND;
+	}
+#endif
 
-		if (purple_strequal(str, priv->nick)) {
-			flags |= PURPLE_MESSAGE_SEND;
-		} else {
-			flags |= PURPLE_MESSAGE_RECV;
-
-			if (purple_utf8_has_word(message, priv->nick))
-				flags |= PURPLE_MESSAGE_NICK;
+	flags = purple_message_get_flags(msg);
+	if (flags & PURPLE_MESSAGE_RECV) {
+		if (purple_utf8_has_word(purple_message_get_contents(msg), priv->nick)) {
+			flags |= PURPLE_MESSAGE_NICK;
+			purple_message_set_flags(msg, flags);
 		}
 	}
 
@@ -841,9 +839,14 @@
 
 	/* Pass this on to either the ops structure or the default write func. */
 	if (ops != NULL && ops->write_chat != NULL)
-		ops->write_chat(PURPLE_CHAT_CONVERSATION(conv), who, message, flags, mtime);
-	else
-		purple_conversation_write(conv, who, message, flags, mtime);
+		ops->write_chat(PURPLE_CHAT_CONVERSATION(conv), msg);
+	else {
+		purple_conversation_write(conv,
+			purple_message_get_who(msg),
+			purple_message_get_contents(msg),
+			purple_message_get_flags(msg),
+			purple_message_get_time(msg));
+	}
 }
 
 void
--- a/libpurple/message.c	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/message.c	Thu May 22 20:20:19 2014 +0200
@@ -142,6 +142,16 @@
 	return priv->msgtime;
 }
 
+void
+purple_message_set_flags(PurpleMessage *msg, PurpleMessageFlags flags)
+{
+	PurpleMessagePrivate *priv = PURPLE_MESSAGE_GET_PRIVATE(msg);
+
+	g_return_if_fail(priv != NULL);
+
+	priv->flags = flags;
+}
+
 PurpleMessageFlags
 purple_message_get_flags(PurpleMessage *msg)
 {
--- a/libpurple/message.h	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/message.h	Thu May 22 20:20:19 2014 +0200
@@ -110,6 +110,9 @@
 guint64
 purple_message_get_time(PurpleMessage *msg);
 
+void
+purple_message_set_flags(PurpleMessage *msg, PurpleMessageFlags flags);
+
 PurpleMessageFlags
 purple_message_get_flags(PurpleMessage *msg);
 
--- a/libpurple/plugins/offlinemsg.c	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/plugins/offlinemsg.c	Thu May 22 20:20:19 2014 +0200
@@ -105,8 +105,9 @@
 	g_object_set_data(G_OBJECT(conv), "plugin_pack:offlinemsg",
 				GINT_TO_POINTER(OFFLINE_MSG_YES));
 
-	purple_conversation_write_message(conv, offline->who, offline->message,
-				PURPLE_MESSAGE_SEND, time(NULL));
+	/* TODO: use a reference to a PurpleMessage */
+	purple_conversation_write_message(conv, purple_message_new(offline->who,
+		offline->message, PURPLE_MESSAGE_SEND));
 
 	discard_data(offline);
 }
--- a/libpurple/plugins/perl/common/Conversation.xs	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/plugins/perl/common/Conversation.xs	Thu May 22 20:20:19 2014 +0200
@@ -47,7 +47,6 @@
 		const_iv(ACTIVE_ONLY),
 		const_iv(NICK),
 		const_iv(NO_LOG),
-		const_iv(WHISPER),
 		const_iv(ERROR),
 		const_iv(DELAYED),
 		const_iv(RAW),
@@ -209,14 +208,6 @@
 	time_t mtime
 
 void
-purple_conversation_write_message(conv, who, message, flags, mtime)
-	Purple::Conversation conv
-	const char *who
-	const char *message
-	Purple::MessageFlags flags
-	time_t mtime
-
-void
 purple_conversation_send(conv, message)
 	Purple::Conversation conv
 	const char *message
--- a/libpurple/plugins/tcl/tcl_cmds.c	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/plugins/tcl/tcl_cmds.c	Thu May 22 20:20:19 2014 +0200
@@ -874,7 +874,7 @@
 			flags = PURPLE_MESSAGE_SYSTEM;
 			break;
 		}
-		purple_conversation_write_message(convo, from, what, flags, time(NULL));
+		purple_conversation_write_message(convo, purple_message_new(from, what, flags));
 		break;
 	case CMD_CONV_NAME:
 		if (objc != 3) {
--- a/libpurple/protocols/irc/cmds.c	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/protocols/irc/cmds.c	Thu May 22 20:20:19 2014 +0200
@@ -189,8 +189,9 @@
 			                 purple_connection_get_display_name(gc),
 			                 PURPLE_MESSAGE_SEND, action, time(NULL));
 		else
-			purple_conversation_write_message(convo, purple_connection_get_display_name(gc),
-			                     action, PURPLE_MESSAGE_SEND, time(NULL));
+			purple_conversation_write_message(convo, purple_message_new(
+				purple_connection_get_display_name(gc), action,
+				PURPLE_MESSAGE_SEND));
 		g_free(action);
 	}
 
@@ -502,8 +503,8 @@
 		gc = purple_account_get_connection(irc->account);
 		irc_cmd_privmsg(irc, cmd, target, args);
 		purple_conversation_write_message(PURPLE_CONVERSATION(im),
-				purple_connection_get_display_name(gc), args[1],
-				PURPLE_MESSAGE_SEND, time(NULL));
+			purple_message_new(purple_connection_get_display_name(gc),
+				args[1], PURPLE_MESSAGE_SEND));
 	}
 
 	return 0;
@@ -582,8 +583,9 @@
 			g_free(tmp2);
 		} else
 			buf = g_strdup(_("No topic is set"));
-		purple_conversation_write_message(PURPLE_CONVERSATION(chat), target, buf,
-				PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+		purple_conversation_write_message(PURPLE_CONVERSATION(chat),
+			purple_message_new(target, buf,
+				PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG));
 		g_free(buf);
 
 		return 0;
--- a/libpurple/protocols/irc/msgs.c	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/protocols/irc/msgs.c	Thu May 22 20:20:19 2014 +0200
@@ -593,8 +593,8 @@
 				msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc);
 			g_free(nick_esc);
 			g_free(nick);
-			purple_conversation_write_message(PURPLE_CONVERSATION(chat), from,
-					msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
+			purple_conversation_write_system_message(
+				PURPLE_CONVERSATION(chat), msg, 0);
 			g_free(msg);
 		}
 	} else {
@@ -799,9 +799,9 @@
 
 	convo = purple_conversations_find_with_account(args[1], irc->account);
 	if (convo) {
-		purple_conversation_write_message(convo, args[1],
-				PURPLE_IS_IM_CONVERSATION(convo) ? _("User is not logged in") : _("no such channel"),
-				PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+		purple_conversation_write_system_message(convo,
+			PURPLE_IS_IM_CONVERSATION(convo) ? _("User is not logged in") : _("no such channel"),
+			PURPLE_MESSAGE_NO_LOG);
 
 	} else {
 		if ((gc = purple_account_get_connection(irc->account)) == NULL)
@@ -823,8 +823,8 @@
 
 	chat = purple_conversations_find_chat_with_account(args[1], irc->account);
 	if (chat) {
-		purple_conversation_write_message(PURPLE_CONVERSATION(chat), args[1], args[2],
-				PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+		purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), args[2],
+			PURPLE_MESSAGE_NO_LOG);
 	} else {
 		if ((gc = purple_account_get_connection(irc->account)) == NULL)
 			return;
@@ -841,8 +841,8 @@
 	if (chat) {
 		/*g_slist_remove(irc->gc->buddy_chats, chat);
 		  purple_conversation_set_account(chat, NULL);*/
-		purple_conversation_write_message(PURPLE_CONVERSATION(chat), args[1], args[2],
-				PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+		purple_conversation_write_system_message(PURPLE_CONVERSATION(chat),
+			args[2], PURPLE_MESSAGE_NO_LOG);
 	}
 }
 
@@ -1008,7 +1008,7 @@
 
 	if (!purple_utf8_strcasecmp(purple_connection_get_display_name(gc), args[1])) {
 		buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]);
-		purple_conversation_write_message(PURPLE_CONVERSATION(chat), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+		purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), buf, 0);
 		g_free(buf);
 		purple_serv_got_chat_left(gc, purple_chat_conversation_get_id(chat));
 	} else {
@@ -1036,7 +1036,7 @@
 		}
 		escaped = (args[2] != NULL) ? g_markup_escape_text(args[2], -1) : NULL;
 		buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick);
-		purple_conversation_write_message(PURPLE_CONVERSATION(chat), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+		purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), buf, 0);
 		g_free(escaped);
 		g_free(buf);
 		if(args[2]) {
@@ -1221,7 +1221,7 @@
 		                      (args[1] && *args[1]) ? ": " : "",
 		                      (escaped && *escaped) ? escaped : "");
 		g_free(escaped);
-		purple_conversation_write_message(PURPLE_CONVERSATION(chat), channel, msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
+		purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), msg, 0);
 		g_free(msg);
 		purple_serv_got_chat_left(gc, purple_chat_conversation_get_id(chat));
 	} else {
--- a/libpurple/protocols/jabber/presence.c	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/protocols/jabber/presence.c	Thu May 22 20:20:19 2014 +0200
@@ -789,9 +789,12 @@
 
 		if(!nick_change) {
 			if (is_our_resource) {
-				if (kick)
-					purple_conversation_write_message(PURPLE_CONVERSATION(chat->conv), presence->jid_from->resource,
-							presence->status, PURPLE_MESSAGE_SYSTEM, time(NULL));
+				if (kick) {
+					gchar *msg = g_strdup_printf("%s: %s",
+						presence->jid_from->resource,
+						presence->status);
+					purple_conversation_write_system_message(PURPLE_CONVERSATION(chat->conv), msg, 0);
+				}
 
 				purple_serv_got_chat_left(js->gc, chat->id);
 				jabber_chat_destroy(chat);
--- a/libpurple/protocols/silc/ops.c	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/protocols/silc/ops.c	Thu May 22 20:20:19 2014 +0200
@@ -560,8 +560,8 @@
 				g_snprintf(buf, sizeof(buf),
 						_("%s has changed the topic of <I>%s</I> to: %s"),
 						client_entry->nickname, channel->channel_name, tmp2);
-				purple_conversation_write_message(PURPLE_CONVERSATION(chat), client_entry->nickname,
-						buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+				purple_conversation_write_system_message(
+					PURPLE_CONVERSATION(chat), buf, 0);
 				purple_chat_conversation_set_topic(chat,
 						client_entry->nickname, tmp);
 			} else if (idtype == SILC_ID_SERVER) {
@@ -569,8 +569,8 @@
 				g_snprintf(buf, sizeof(buf),
 						_("%s has changed the topic of <I>%s</I> to: %s"),
 						server_entry->server_name, channel->channel_name, tmp2);
-				purple_conversation_write_message(PURPLE_CONVERSATION(chat), server_entry->server_name,
-						buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+				purple_conversation_write_system_message(
+					PURPLE_CONVERSATION(chat), buf, 0);
 				purple_chat_conversation_set_topic(chat,
 						server_entry->server_name, tmp);
 			} else if (idtype == SILC_ID_CHANNEL) {
@@ -578,8 +578,8 @@
 				g_snprintf(buf, sizeof(buf),
 						_("%s has changed the topic of <I>%s</I> to: %s"),
 						channel->channel_name, channel->channel_name, tmp2);
-				purple_conversation_write_message(PURPLE_CONVERSATION(chat), channel->channel_name,
-						buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+				purple_conversation_write_system_message(
+					PURPLE_CONVERSATION(chat), buf, 0);
 				purple_chat_conversation_set_topic(chat,
 						channel->channel_name, tmp);
 			} else {
@@ -649,8 +649,7 @@
 				   _("<I>%s</I> removed all channel <I>%s</I> modes"), name,
 				   channel->channel_name);
 		}
-		purple_conversation_write_message(PURPLE_CONVERSATION(chat), channel->channel_name,
-				       buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+		purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), buf, 0);
 		break;
 
 	case SILC_NOTIFY_TYPE_CUMODE_CHANGE:
@@ -690,8 +689,7 @@
 					   _("<I>%s</I> removed all <I>%s's</I> modes"), name,
 					   client_entry2->nickname);
 			}
-			purple_conversation_write_message(PURPLE_CONVERSATION(chat), channel->channel_name,
-					       buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+			purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), buf, 0);
 			purple_chat_user_set_flags(purple_chat_conversation_find_user(
 					       chat, client_entry2->nickname), flags);
 			break;
@@ -720,8 +718,8 @@
 				   _("You have been kicked off <I>%s</I> by <I>%s</I> (%s)"),
 				   channel->channel_name, client_entry2->nickname,
 				   tmp ? tmp : "");
-			purple_conversation_write_message(PURPLE_CONVERSATION(chat), client_entry->nickname,
-					       buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+			purple_conversation_write_system_message(PURPLE_CONVERSATION(chat),
+				buf, 0);
 			purple_serv_got_chat_left(gc, purple_chat_conversation_get_id(chat));
 		} else {
 			/* Remove user from channel */
@@ -765,8 +763,8 @@
 										chu->channel->channel_name, sg->account);
 				if (!chat)
 					continue;
-				purple_conversation_write_message(PURPLE_CONVERSATION(chat), client_entry->nickname,
-						       buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
+				purple_conversation_write_system_message(
+					PURPLE_CONVERSATION(chat), buf, 0);
 				purple_serv_got_chat_left(gc, purple_chat_conversation_get_id(chat));
 			}
 			silc_hash_table_list_reset(&htl);
--- a/libpurple/protocols/silc/silc.c	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/protocols/silc/silc.c	Thu May 22 20:20:19 2014 +0200
@@ -1412,8 +1412,9 @@
 								 buf->data,
 								 silc_buffer_len(buf));
 			silc_mime_partial_free(list);
-			purple_conversation_write_message(PURPLE_CONVERSATION(convo), conn->local_entry->nickname,
-					     im->message, 0, time(NULL));
+			purple_conversation_write_message(PURPLE_CONVERSATION(convo),
+				purple_message_new(conn->local_entry->nickname,
+					im->message, PURPLE_MESSAGE_SEND));
 			goto out;
 		}
 	}
@@ -1421,8 +1422,8 @@
 	/* Send the message */
 	silc_client_send_private_message(client, conn, client_entry, im->flags,
 					 sg->sha1hash, (unsigned char *)im->message, im->message_len);
-	purple_conversation_write_message(PURPLE_CONVERSATION(convo), conn->local_entry->nickname,
-			     im->message, 0, time(NULL));
+	purple_conversation_write_message(PURPLE_CONVERSATION(convo), purple_message_new(
+		conn->local_entry->nickname, im->message, PURPLE_MESSAGE_SEND));
 	goto out;
 
  err:
@@ -1605,8 +1606,8 @@
 			g_free(tmp2);
 		} else
 			buf = g_strdup(_("No topic is set"));
-		purple_conversation_write_message(conv, purple_account_get_username(purple_connection_get_account(gc)), buf,
-							 PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
+		purple_conversation_write_system_message(conv,
+			buf, PURPLE_MESSAGE_NO_LOG);
 		g_free(buf);
 
 	}
@@ -1712,8 +1713,9 @@
 			args[1], PURPLE_MESSAGE_SEND);
 
 		ret = silcpurple_send_im(gc, msg);
-		purple_conversation_write_message(PURPLE_CONVERSATION(im), purple_connection_get_display_name(gc),
-				args[1], PURPLE_MESSAGE_SEND, time(NULL));
+		purple_conversation_write_message(PURPLE_CONVERSATION(im),
+			purple_message_new(purple_connection_get_display_name(gc),
+				args[1], PURPLE_MESSAGE_SEND));
 	}
 
 	if (ret)
--- a/libpurple/server.c	Thu May 22 19:36:16 2014 +0200
+++ b/libpurple/server.c	Thu May 22 20:20:19 2014 +0200
@@ -538,6 +538,7 @@
 	char *message, *name;
 	char *angel, *buffy;
 	int plugin_return;
+	PurpleMessage *pmsg;
 
 	g_return_if_fail(msg != NULL);
 
@@ -599,7 +600,10 @@
 	if (im == NULL)
 		im = purple_im_conversation_new(account, name);
 
-	purple_conversation_write_message(PURPLE_CONVERSATION(im), name, message, flags, mtime);
+	pmsg = purple_message_new(name, message, flags);
+	purple_message_set_time(pmsg, mtime);
+
+	purple_conversation_write_message(PURPLE_CONVERSATION(im), pmsg);
 	g_free(message);
 
 	/*
@@ -672,10 +676,7 @@
 						PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_AUTO_RESP);
 
 					purple_serv_send_im(gc, msg);
-
-					purple_conversation_write_message(PURPLE_CONVERSATION(im), NULL, away_msg,
-									   PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_AUTO_RESP,
-									   mtime);
+					purple_conversation_write_message(PURPLE_CONVERSATION(im), msg);
 				}
 			}
 		}
@@ -878,6 +879,7 @@
 	PurpleChatConversation *chat = NULL;
 	char *buffy, *angel;
 	int plugin_return;
+	PurpleMessage *pmsg;
 
 	g_return_if_fail(who != NULL);
 	g_return_if_fail(message != NULL);
@@ -935,7 +937,9 @@
 	purple_signal_emit(purple_conversations_get_handle(), "received-chat-msg", purple_connection_get_account(g),
 					 who, message, chat, flags);
 
-	purple_conversation_write_message(PURPLE_CONVERSATION(chat), who, message, flags, mtime);
+	pmsg = purple_message_new(who, message, flags);
+	purple_message_set_time(pmsg, mtime);
+	purple_conversation_write_message(PURPLE_CONVERSATION(chat), pmsg);
 
 	g_free(angel);
 	g_free(buffy);
--- a/pidgin/gtkconv.c	Thu May 22 19:36:16 2014 +0200
+++ b/pidgin/gtkconv.c	Thu May 22 20:20:19 2014 +0200
@@ -6198,12 +6198,11 @@
 
 
 static void
-pidgin_conv_write_im(PurpleIMConversation *im, const char *who,
-					  const char *message, PurpleMessageFlags flags,
-					  time_t mtime)
+pidgin_conv_write_im(PurpleIMConversation *im, PurpleMessage *msg)
 {
 	PidginConversation *gtkconv;
 	PurpleConversation *conv = PURPLE_CONVERSATION(im);
+	PurpleMessageFlags flags = purple_message_get_flags(msg);
 
 	gtkconv = PIDGIN_CONVERSATION(conv);
 
@@ -6218,7 +6217,9 @@
 		return;
 	}
 
-	purple_conversation_write(conv, who, message, flags, mtime);
+	purple_conversation_write(conv, purple_message_get_who(msg),
+		purple_message_get_contents(msg), flags,
+		purple_message_get_time(msg));
 }
 
 #if 0

mercurial