# HG changeset patch
# Node ID df303b8515e5
# Parent  f3090252de57
diff --git a/libpurple/protocols/facebook/util.c b/libpurple/protocols/facebook/util.c
--- a/libpurple/protocols/facebook/util.c
+++ b/libpurple/protocols/facebook/util.c
@@ -459,7 +459,7 @@
 
 	me = purple_contact_info_get_name_for_display(info);
 	name = purple_contact_info_get_username(info);
-	msg = purple_message_new_outgoing(me, name, text, flags);
+	msg = purple_message_new_outgoing(acct, me, name, text, flags);
 
 	dt = g_date_time_new_from_unix_local((gint64)timestamp);
 	purple_message_set_timestamp(msg, dt);
@@ -498,7 +498,7 @@
 	me = purple_contact_info_get_name_for_display(info);
 	name = purple_contact_info_get_username(info);
 
-	msg = purple_message_new_outgoing(me, name, text, flags);
+	msg = purple_message_new_outgoing(acct, me, name, text, flags);
 
 	dt = g_date_time_new_from_unix_local((gint64)timestamp);
 	purple_message_set_timestamp(msg, dt);
diff --git a/libpurple/protocols/gg/chat.c b/libpurple/protocols/gg/chat.c
--- a/libpurple/protocols/gg/chat.c
+++ b/libpurple/protocols/gg/chat.c
@@ -562,8 +562,8 @@
 
 		username = purple_contact_info_get_name_for_display(info);
 
-		pmsg = purple_message_new_outgoing(username, ggp_uin_to_str(who),
-		                                   message, 0);
+		pmsg = purple_message_new_outgoing(account, username,
+		                                   ggp_uin_to_str(who), message, 0);
 
 		dt = g_date_time_new_from_unix_local((gint64)time);
 		purple_message_set_timestamp(pmsg, dt);
diff --git a/libpurple/protocols/gg/message-prpl.c b/libpurple/protocols/gg/message-prpl.c
--- a/libpurple/protocols/gg/message-prpl.c
+++ b/libpurple/protocols/gg/message-prpl.c
@@ -249,7 +249,7 @@
 		info = PURPLE_CONTACT_INFO(account);
 		me = purple_contact_info_get_name_for_display(info);
 
-		pmsg = purple_message_new_outgoing(me, NULL, msg->text, 0);
+		pmsg = purple_message_new_outgoing(account, me, NULL, msg->text, 0);
 
 		dt = g_date_time_new_from_unix_local((gint64)msg->time);
 		purple_message_set_timestamp(pmsg, dt);
diff --git a/libpurple/protocols/irc/cmds.c b/libpurple/protocols/irc/cmds.c
--- a/libpurple/protocols/irc/cmds.c
+++ b/libpurple/protocols/irc/cmds.c
@@ -116,12 +116,13 @@
 	/* XXX: we'd prefer to keep this in conversation.c */
 	if (PURPLE_IS_IM_CONVERSATION(convo)) {
 		const gchar *conv_name = purple_conversation_get_name(convo);
-		pmsg = purple_message_new_outgoing(me, conv_name, msg, 0);
+		pmsg = purple_message_new_outgoing(irc->account, me, conv_name, msg,
+		                                   0);
 
 		purple_signal_emit(purple_conversations_get_handle(),
 			"sending-im-msg", irc->account, pmsg);
 	} else {
-		pmsg = purple_message_new_outgoing(me, NULL, msg, 0);
+		pmsg = purple_message_new_outgoing(irc->account, me, NULL, msg, 0);
 
 		purple_signal_emit(purple_conversations_get_handle(),
 			"sending-chat-msg", irc->account, pmsg,
@@ -556,7 +557,8 @@
 
 		me = purple_contact_info_get_name_for_display(info);
 		recipient = purple_connection_get_display_name(gc);
-		message = purple_message_new_outgoing(me, recipient, args[1], 0);
+		message = purple_message_new_outgoing(irc->account, me, recipient,
+		                                      args[1], 0);
 
 		purple_conversation_write_message(im, message);
 
diff --git a/libpurple/protocols/ircv3/purpleircv3messagehandlers.c b/libpurple/protocols/ircv3/purpleircv3messagehandlers.c
--- a/libpurple/protocols/ircv3/purpleircv3messagehandlers.c
+++ b/libpurple/protocols/ircv3/purpleircv3messagehandlers.c
@@ -132,7 +132,8 @@
 		flags |= PURPLE_MESSAGE_NOTIFY;
 	}
 
-	message = purple_message_new_incoming(source, params[1], flags, 0);
+	message = purple_message_new_incoming(account, source, params[1], flags,
+	                                      0);
 
 	purple_conversation_write_message(conversation, message);
 
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -2618,7 +2618,7 @@
 	pc = purple_conversation_get_connection(conv);
 	prpl = purple_connection_get_protocol(pc);
 
-	msg = purple_message_new_outgoing(me, who, args[1], 0);
+	msg = purple_message_new_outgoing(account, me, who, args[1], 0);
 
 	jabber_message_send_im(PURPLE_PROTOCOL_IM(prpl), pc, msg);
 
diff --git a/libpurple/purpleconversation.c b/libpurple/purpleconversation.c
--- a/libpurple/purpleconversation.c
+++ b/libpurple/purpleconversation.c
@@ -121,7 +121,8 @@
 		PurpleMessage *msg = NULL;
 
 		name = purple_conversation_get_name(conv);
-		msg = purple_message_new_outgoing(me, name, sent, msgflags);
+		msg = purple_message_new_outgoing(priv->account, me, name, sent,
+		                                  msgflags);
 
 		purple_signal_emit(handle, "sending-im-msg", account, msg);
 
@@ -142,7 +143,8 @@
 		PurpleMessage *msg;
 		gint id = purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv));
 
-		msg = purple_message_new_outgoing(me, NULL, sent, msgflags);
+		msg = purple_message_new_outgoing(priv->account, me, NULL, sent,
+		                                  msgflags);
 
 		purple_signal_emit(handle, "sending-chat-msg", account, msg, id);
 
@@ -717,8 +719,16 @@
                                          const gchar *message,
                                          PurpleMessageFlags flags)
 {
+	PurpleConversationPrivate *priv = NULL;
+
+	g_return_if_fail(PURPLE_IS_CONVERSATION(conv));
+
+	priv = purple_conversation_get_instance_private(conv);
+
 	_purple_conversation_write_common(conv,
-	                                  purple_message_new_system(message, flags));
+	                                  purple_message_new_system(priv->account,
+	                                                            message,
+	                                                            flags));
 }
 
 void
diff --git a/libpurple/purplemessage.h b/libpurple/purplemessage.h
--- a/libpurple/purplemessage.h
+++ b/libpurple/purplemessage.h
@@ -108,8 +108,11 @@
 
 G_DECLARE_FINAL_TYPE(PurpleMessage, purple_message, PURPLE, MESSAGE, GObject)
 
+#include "account.h"
+
 /**
  * purple_message_new_outgoing:
+ * @account: The account for this message.
  * @author: The author.
  * @recipient: The recipient.
  * @contents: The contents.
@@ -124,10 +127,11 @@
  *
  * Since: 3.0.0
  */
-PurpleMessage *purple_message_new_outgoing(const gchar *author, const gchar *recipient, const gchar *contents, PurpleMessageFlags flags);
+PurpleMessage *purple_message_new_outgoing(PurpleAccount *account, const gchar *author, const gchar *recipient, const gchar *contents, PurpleMessageFlags flags);
 
 /**
  * purple_message_new_incoming:
+ * @account: The account for this message.
  * @who: Message's author.
  * @contents: The contents of a message.
  * @flags: The message flags.
@@ -141,10 +145,11 @@
  *
  * Since: 3.0.0
  */
-PurpleMessage *purple_message_new_incoming(const gchar *who, const gchar *contents, PurpleMessageFlags flags, guint64 timestamp);
+PurpleMessage *purple_message_new_incoming(PurpleAccount *account, const gchar *who, const gchar *contents, PurpleMessageFlags flags, guint64 timestamp);
 
 /**
  * purple_message_new_system:
+ * @account: The account for this message.
  * @contents: The contents of a message.
  * @flags: The message flags.
  *
@@ -156,7 +161,7 @@
  *
  * Since: 3.0.0
  */
-PurpleMessage *purple_message_new_system(const gchar *contents, PurpleMessageFlags flags);
+PurpleMessage *purple_message_new_system(PurpleAccount *account, const gchar *contents, PurpleMessageFlags flags);
 
 /**
  * purple_message_get_id:
diff --git a/libpurple/purplemessage.c b/libpurple/purplemessage.c
--- a/libpurple/purplemessage.c
+++ b/libpurple/purplemessage.c
@@ -323,7 +323,8 @@
  * Public API
  *****************************************************************************/
 PurpleMessage *
-purple_message_new_outgoing(const gchar *author, const gchar *recipient,
+purple_message_new_outgoing(G_GNUC_UNUSED PurpleAccount *account,
+                            const gchar *author, const gchar *recipient,
                             const gchar *contents, PurpleMessageFlags flags)
 {
 	PurpleMessage *message = NULL;
@@ -350,7 +351,8 @@
 }
 
 PurpleMessage *
-purple_message_new_incoming(const gchar *who, const gchar *contents,
+purple_message_new_incoming(G_GNUC_UNUSED PurpleAccount *account,
+                            const gchar *who, const gchar *contents,
                             PurpleMessageFlags flags, guint64 timestamp)
 {
 	PurpleMessage *message = NULL;
@@ -381,7 +383,9 @@
 }
 
 PurpleMessage *
-purple_message_new_system(const gchar *contents, PurpleMessageFlags flags) {
+purple_message_new_system(G_GNUC_UNUSED PurpleAccount *account,
+                          const gchar *contents, PurpleMessageFlags flags)
+{
 	PurpleMessage *message = NULL;
 	GDateTime *dt = NULL;
 
diff --git a/libpurple/server.c b/libpurple/server.c
--- a/libpurple/server.c
+++ b/libpurple/server.c
@@ -377,7 +377,7 @@
 		im = purple_im_conversation_new(account, name);
 	}
 
-	pmsg = purple_message_new_incoming(name, message, flags, mtime);
+	pmsg = purple_message_new_incoming(account, name, message, flags, mtime);
 	purple_conversation_write_message(im, pmsg);
 	g_free(message);
 	g_object_unref(G_OBJECT(pmsg));
@@ -653,14 +653,15 @@
 					 who, message, chat, flags);
 
 	if (flags & PURPLE_MESSAGE_RECV) {
-		pmsg = purple_message_new_incoming(who, message, flags, mtime);
+		pmsg = purple_message_new_incoming(purple_connection_get_account(g),
+		                                   who, message, flags, mtime);
 	} else {
 		PurpleAccount *account = purple_connection_get_account(g);
 		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 		GDateTime *dt = g_date_time_new_from_unix_local((gint64)mtime);
 		const gchar *me = purple_contact_info_get_name_for_display(info);
 
-		pmsg = purple_message_new_outgoing(me, who, message, flags);
+		pmsg = purple_message_new_outgoing(account, me, who, message, flags);
 		purple_message_set_timestamp(pmsg, dt);
 		g_date_time_unref(dt);
 	}
