changeset 31679:ba6a4a0f8f50

jabber: Treat the presence storm on joining a room as not new arrivals. This helps in Adium, where otherwise all of those joins end up printed out. Fixes #7501, #a14527 committer: Paul Aurich <paul@darkrain42.org>
author thijs@adium.im
date Sun, 20 Feb 2011 02:25:23 +0000
parents 05c45d8f2ce3
children b79dfdbb94e2
files ChangeLog libpurple/protocols/jabber/chat.c libpurple/protocols/jabber/chat.h libpurple/protocols/jabber/presence.c
diffstat 4 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Feb 20 02:22:03 2011 +0000
+++ b/ChangeLog	Sun Feb 20 02:25:23 2011 +0000
@@ -4,6 +4,11 @@
 	General:
 	* Our bundled libgadu should now build on HP-UX.
 
+	XMPP:
+	* Fix building on platforms with an older glib (inadvertantly broken in
+	  2.7.10).  (#13329)
+	* Don't treat the on-join status storms as 'new arrivals'.  (#a14527)
+
 version 2.7.10 (02/06/2011):
 	General:
 	* Force video sources to all have the same capabilities.  This reduces the
--- a/libpurple/protocols/jabber/chat.c	Sun Feb 20 02:22:03 2011 +0000
+++ b/libpurple/protocols/jabber/chat.c	Sun Feb 20 02:25:23 2011 +0000
@@ -237,6 +237,7 @@
 
 	chat = g_new0(JabberChat, 1);
 	chat->js = js;
+	chat->joined = 0;
 
 	chat->room = g_strdup(room);
 	chat->server = g_strdup(server);
--- a/libpurple/protocols/jabber/chat.h	Sun Feb 20 02:22:03 2011 +0000
+++ b/libpurple/protocols/jabber/chat.h	Sun Feb 20 02:25:23 2011 +0000
@@ -52,6 +52,7 @@
 	void *config_dialog_handle;
 	GHashTable *members;
 	gboolean left;
+	time_t joined;
 } JabberChat;
 
 GList *jabber_chat_info(PurpleConnection *gc);
--- a/libpurple/protocols/jabber/presence.c	Sun Feb 20 02:22:03 2011 +0000
+++ b/libpurple/protocols/jabber/presence.c	Sun Feb 20 02:25:23 2011 +0000
@@ -639,10 +639,14 @@
 
 		if(!jabber_chat_find_buddy(chat->conv, presence->jid_from->resource))
 			purple_conv_chat_add_user(PURPLE_CONV_CHAT(chat->conv), presence->jid_from->resource,
-					jid, flags, !presence->delayed);
+					jid, flags, chat->joined > 0 && ((!presence->delayed) || (presence->sent > chat->joined)));
 		else
 			purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(chat->conv), presence->jid_from->resource,
 					flags);
+
+		if (is_our_resource && chat->joined == 0)
+			chat->joined = time(NULL);
+
 	} else if (presence->type == JABBER_PRESENCE_UNAVAILABLE) {
 		gboolean nick_change = FALSE;
 		gboolean kick = FALSE;
@@ -669,8 +673,10 @@
 			jid = xmlnode_get_attrib(presence->chat_info.item, "jid");
 
 		if (chat->muc) {
-			if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(110)))
+			if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(110))) {
 				is_our_resource = TRUE;
+				chat->joined = 0;
+			}
 
 			if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(301))) {
 				/* XXX: We got banned.  YAY! (No GIR, that's bad) */
@@ -1159,9 +1165,6 @@
 static void
 parse_delay(JabberStream *js, JabberPresence *presence, xmlnode *delay)
 {
-	/* XXX: compare the time.  Can happen on presence stanzas that aren't
-	 * actually delayed.
-	 */
 	const char *stamp = xmlnode_get_attrib(delay, "stamp");
 	presence->delayed = TRUE;
 	presence->sent = purple_str_to_time(stamp, TRUE, NULL, NULL, NULL);