/pidgin/main: cf0a11121049: Fix message flags

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu May 22 16:10:04 EDT 2014


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

Description:

Fix message flags

diffstat:

 libpurple/message.c                     |  18 ++++++++----------
 libpurple/plugins/tcl/tcl_cmds.c        |   2 +-
 libpurple/protocols/irc/cmds.c          |   5 ++---
 libpurple/protocols/irc/msgs.c          |   7 ++++---
 libpurple/protocols/jabber/jabber.c     |   2 +-
 libpurple/protocols/jabber/message.c    |   2 +-
 libpurple/protocols/msn/msg.c           |   4 ++--
 libpurple/protocols/msn/switchboard.c   |   4 ++--
 libpurple/protocols/novell/novell.c     |   4 ++--
 libpurple/protocols/oscar/oscar.c       |   3 ++-
 libpurple/protocols/sametime/sametime.c |   5 +++--
 libpurple/protocols/silc/ops.c          |   4 ++--
 libpurple/protocols/yahoo/yahoochat.c   |   9 ++++++---
 libpurple/protocols/yahoo/ycht.c        |   2 +-
 libpurple/protocols/zephyr/zephyr.c     |   3 ++-
 15 files changed, 39 insertions(+), 35 deletions(-)

diffs (266 lines):

diff --git a/libpurple/message.c b/libpurple/message.c
--- a/libpurple/message.c
+++ b/libpurple/message.c
@@ -62,6 +62,12 @@ PurpleMessage *
 purple_message_new(const gchar *who, const gchar *contents,
 	PurpleMessageFlags flags)
 {
+	if (!(flags & (PURPLE_MESSAGE_SEND |
+		PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM)))
+	{
+		purple_debug_warning("message", "Invalid flags %#x", flags);
+	}
+
 	return g_object_new(PURPLE_TYPE_MESSAGE,
 		"who", who,
 		"contents", contents,
@@ -125,11 +131,7 @@ purple_message_is_empty(PurpleMessage *m
 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;
+	g_object_set(msg, "time", msgtime, NULL);
 }
 
 guint64
@@ -145,11 +147,7 @@ purple_message_get_time(PurpleMessage *m
 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;
+	g_object_set(msg, "flags", flags, NULL);
 }
 
 PurpleMessageFlags
diff --git a/libpurple/plugins/tcl/tcl_cmds.c b/libpurple/plugins/tcl/tcl_cmds.c
--- a/libpurple/plugins/tcl/tcl_cmds.c
+++ b/libpurple/plugins/tcl/tcl_cmds.c
@@ -1411,7 +1411,7 @@ int tcl_cmd_send_im(ClientData unused, T
 	who = Tcl_GetString(objv[2]);
 	text = Tcl_GetString(objv[3]);
 
-	purple_serv_send_im(gc, purple_message_new(who, text, 0));
+	purple_serv_send_im(gc, purple_message_new(who, text, PURPLE_MESSAGE_SEND));
 
 	return TCL_OK;
 }
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
@@ -583,9 +583,8 @@ int irc_cmd_topic(struct irc_conn *irc, 
 			g_free(tmp2);
 		} else
 			buf = g_strdup(_("No topic is set"));
-		purple_conversation_write_message(PURPLE_CONVERSATION(chat),
-			purple_message_new(target, buf,
-				PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG));
+		purple_conversation_write_system_message(
+			PURPLE_CONVERSATION(chat), buf, PURPLE_MESSAGE_NO_LOG);
 		g_free(buf);
 
 		return 0;
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -1315,9 +1315,10 @@ static void irc_msg_handle_privmsg(struc
 		purple_serv_got_im(gc, nick, msg, 0, time(NULL));
 	} else {
 		chat = purple_conversations_find_chat_with_account(irc_nick_skip_mode(irc, to), irc->account);
-		if (chat)
-			purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(chat), nick, 0, msg, time(NULL));
-		else
+		if (chat) {
+			purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(chat),
+				nick, PURPLE_MESSAGE_RECV, msg, time(NULL));
+		} else
 			purple_debug_error("irc", "Got a %s on %s, which does not exist\n",
 			                   notice ? "NOTICE" : "PRIVMSG", to);
 	}
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
@@ -3072,7 +3072,7 @@ static PurpleCmdRet jabber_cmd_chat_msg(
 	who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]);
 
 	jabber_message_send_im(purple_conversation_get_connection(conv),
-		purple_message_new(who, args[1], 0));
+		purple_message_new(who, args[1], PURPLE_MESSAGE_SEND));
 
 	g_free(who);
 	return PURPLE_CMD_RET_OK;
diff --git a/libpurple/protocols/jabber/message.c b/libpurple/protocols/jabber/message.c
--- a/libpurple/protocols/jabber/message.c
+++ b/libpurple/protocols/jabber/message.c
@@ -220,7 +220,7 @@ static void handle_groupchat(JabberMessa
 {
 	JabberID *jid = jabber_id_new(jm->from);
 	JabberChat *chat;
-	PurpleMessageFlags messageFlags = 0;
+	PurpleMessageFlags messageFlags = PURPLE_MESSAGE_RECV;
 
 	if(!jid)
 		return;
diff --git a/libpurple/protocols/msn/msg.c b/libpurple/protocols/msn/msg.c
--- a/libpurple/protocols/msn/msg.c
+++ b/libpurple/protocols/msn/msg.c
@@ -702,8 +702,8 @@ msn_plain_msg(MsnCmdProc *cmdproc, MsnMe
 				purple_debug_misc("msn", "plain_msg: current_users(%d)\n",
 								swboard->current_users);
 
-			purple_serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final,
-							 time(NULL));
+			purple_serv_got_chat_in(gc, swboard->chat_id, passport,
+				PURPLE_MESSAGE_RECV, body_final, time(NULL));
 			if (swboard->conv == NULL)
 			{
 				swboard->conv = PURPLE_CONVERSATION(purple_conversations_find_chat(gc, swboard->chat_id));
diff --git a/libpurple/protocols/msn/switchboard.c b/libpurple/protocols/msn/switchboard.c
--- a/libpurple/protocols/msn/switchboard.c
+++ b/libpurple/protocols/msn/switchboard.c
@@ -838,8 +838,8 @@ msn_switchboard_show_ink(MsnSwitchBoard 
 	if (swboard->current_users > 1 ||
 		((swboard->conv != NULL) &&
 		 PURPLE_IS_CHAT_CONVERSATION(swboard->conv)))
-		purple_serv_got_chat_in(gc, swboard->chat_id, passport, 0, image_msg,
-						 time(NULL));
+		purple_serv_got_chat_in(gc, swboard->chat_id, passport,
+			PURPLE_MESSAGE_RECV, image_msg, time(NULL));
 	else
 		purple_serv_got_im(gc, passport, image_msg, 0, time(NULL));
 
diff --git a/libpurple/protocols/novell/novell.c b/libpurple/protocols/novell/novell.c
--- a/libpurple/protocols/novell/novell.c
+++ b/libpurple/protocols/novell/novell.c
@@ -1869,8 +1869,8 @@ static void
 				}
 
 				purple_serv_got_chat_in(purple_account_get_connection(user->client_data),
-								 purple_chat_conversation_get_id(chat),
-								 name, 0, text, nm_event_get_gmt(event));
+					purple_chat_conversation_get_id(chat),
+					name, PURPLE_MESSAGE_RECV, text, nm_event_get_gmt(event));
 			}
 		}
 	}
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -2409,7 +2409,8 @@ static int purple_chat_conversation_inco
 	va_end(ap);
 
 	utf8 = oscar_encoding_to_utf8(charset, msg, len);
-	purple_serv_got_chat_in(gc, ccon->id, info->bn, 0, utf8, time(NULL));
+	purple_serv_got_chat_in(gc, ccon->id, info->bn,
+		PURPLE_MESSAGE_RECV, utf8, time(NULL));
 	g_free(utf8);
 
 	return 1;
diff --git a/libpurple/protocols/sametime/sametime.c b/libpurple/protocols/sametime/sametime.c
--- a/libpurple/protocols/sametime/sametime.c
+++ b/libpurple/protocols/sametime/sametime.c
@@ -2085,7 +2085,7 @@ static void mw_conf_text(struct mwConfer
   gc = pd->gc;
 
   esc = g_markup_escape_text(text, -1);
-  purple_serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, 0, esc, time(NULL));
+  purple_serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, PURPLE_MESSAGE_RECV, esc, time(NULL));
   g_free(esc);
 }
 
@@ -3079,7 +3079,8 @@ static void mw_place_message(struct mwPl
   gc = pd->gc;
 
   esc = g_markup_escape_text(msg, -1);
-  purple_serv_got_chat_in(gc, PLACE_TO_ID(place), who->user, 0, esc, time(NULL));
+  purple_serv_got_chat_in(gc, PLACE_TO_ID(place), who->user,
+	PURPLE_MESSAGE_RECV, esc, time(NULL));
   g_free(esc);
 }
 
diff --git a/libpurple/protocols/silc/ops.c b/libpurple/protocols/silc/ops.c
--- a/libpurple/protocols/silc/ops.c
+++ b/libpurple/protocols/silc/ops.c
@@ -311,7 +311,7 @@ silc_channel_message(SilcClient client, 
 		tmp = g_markup_escape_text(msg, -1);
 		/* Send to Purple */
 		purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(chat),
-				 sender->nickname, 0, tmp, time(NULL));
+			sender->nickname, PURPLE_MESSAGE_RECV, tmp, time(NULL));
 		g_free(tmp);
 		g_free(msg);
 		return;
@@ -340,7 +340,7 @@ silc_channel_message(SilcClient client, 
 		tmp = g_markup_escape_text(msg, -1);
 		/* Send to Purple */
 		purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(chat),
-				 sender->nickname, 0, tmp, time(NULL));
+			sender->nickname, PURPLE_MESSAGE_RECV, tmp, time(NULL));
 		g_free(salvaged);
 		g_free(tmp);
 	}
diff --git a/libpurple/protocols/yahoo/yahoochat.c b/libpurple/protocols/yahoo/yahoochat.c
--- a/libpurple/protocols/yahoo/yahoochat.c
+++ b/libpurple/protocols/yahoo/yahoochat.c
@@ -261,7 +261,8 @@ void yahoo_process_conference_decline(Pu
 			{
 				msg_tmp = yahoo_string_decode(gc, msg, utf8);
 				msg = yahoo_codes_to_html(msg_tmp);
-				purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(c), who, 0, msg, time(NULL));
+				purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(c),
+					who, PURPLE_MESSAGE_RECV, msg, time(NULL));
 				g_free(msg_tmp);
 				g_free(msg);
 			}
@@ -393,7 +394,8 @@ void yahoo_process_conference_message(Pu
 
 		msg2 = yahoo_string_decode(gc, msg, utf8);
 		msg = yahoo_codes_to_html(msg2);
-		purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(c), who, 0, msg, time(NULL));
+		purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(c), who,
+			PURPLE_MESSAGE_RECV, msg, time(NULL));
 		g_free(msg);
 		g_free(msg2);
 	}
@@ -747,7 +749,8 @@ void yahoo_process_chat_message(PurpleCo
 		msg = tmp;
 	}
 
-	purple_serv_got_chat_in(gc, YAHOO_CHAT_ID, who, 0, msg, time(NULL));
+	purple_serv_got_chat_in(gc, YAHOO_CHAT_ID, who,
+		PURPLE_MESSAGE_RECV, msg, time(NULL));
 	g_free(msg);
 	g_free(room);
 }
diff --git a/libpurple/protocols/yahoo/ycht.c b/libpurple/protocols/yahoo/ycht.c
--- a/libpurple/protocols/yahoo/ycht.c
+++ b/libpurple/protocols/yahoo/ycht.c
@@ -165,7 +165,7 @@ static void ycht_progress_chatmsg(YchtCo
 		what = tmp;
 	}
 
-	purple_serv_got_chat_in(gc, YAHOO_CHAT_ID, who, 0, what, time(NULL));
+	purple_serv_got_chat_in(gc, YAHOO_CHAT_ID, who, PURPLE_MESSAGE_RECV, what, time(NULL));
 	g_free(what);
 }
 
diff --git a/libpurple/protocols/zephyr/zephyr.c b/libpurple/protocols/zephyr/zephyr.c
--- a/libpurple/protocols/zephyr/zephyr.c
+++ b/libpurple/protocols/zephyr/zephyr.c
@@ -918,7 +918,8 @@ static void handle_message(PurpleConnect
 #endif
 				purple_chat_conversation_add_user(gcc, stripped_sender, ipaddr, PURPLE_CHAT_USER_NONE, TRUE);
 			}
-			purple_serv_got_chat_in(gc, zt2->id, send_inst_utf8, 0, buf3, time(NULL));
+			purple_serv_got_chat_in(gc, zt2->id, send_inst_utf8,
+				PURPLE_MESSAGE_RECV, buf3, time(NULL));
 			g_free(send_inst_utf8);
 
 			free_triple(zt1);



More information about the Commits mailing list