changeset 12850:49b2347863b2

[gaim-migrate @ 15200] SF Patch #1403151 from charkins "This patch prevents two cases for "sonic avalanche" in the sound code. The first is to only play sounds in response to the chat-buddy-joined signal when the new_arrival flag is set." "The second case has to do with jabber pre-filling chat history when a chat is joined. The GAIM_MESSAGE_DELAYED flag is used on these messages, so sound are not played when this flag is set on received messages." "I also fixed sound_playing_event_cb() in signals-test.c which was assuming account!=NULL, which in turn was throwing an assertion error when gaim_account_get_username() was called." committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 12 Jan 2006 06:59:39 +0000
parents c0fbdea8828b
children c1317074fce3
files doc/conversation-signals.dox plugins/ChangeLog.API plugins/signals-test.c src/conversation.c src/gtksound.c
diffstat 5 files changed, 25 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/doc/conversation-signals.dox	Thu Jan 12 06:44:23 2006 +0000
+++ b/doc/conversation-signals.dox	Thu Jan 12 06:59:39 2006 +0000
@@ -279,13 +279,15 @@
  @signaldef chat-buddy-joined
   @signalproto
 void (*chat_buddy_joined)(GaimConversation *conv, const char *name,
-                          GaimConvChatBuddyFlags flags);
+                          GaimConvChatBuddyFlags flags,
+                          gboolean new_arrival);
   @endsignalproto
   @signaldesc
    Emitted when a buddy joined a chat, after the users list is updated.
   @param conv The chat conversation.
   @param name The name of the user that has joined the conversation.
   @param flags The flags of the user that has joined the conversation.
+  @param new_arrival If the buddy is a new arrival.
  @endsignaldef
 
  @signaldef chat-buddy-flags
--- a/plugins/ChangeLog.API	Thu Jan 12 06:44:23 2006 +0000
+++ b/plugins/ChangeLog.API	Thu Jan 12 06:59:39 2006 +0000
@@ -240,6 +240,7 @@
 	  with GaimAccount*, const char *name.  Also, the signal is now emitted
 	  regardless of whether a conversation exists and regardless of whether
 	  the user is on the buddy list.
+	* "chat-buddy-joined": added the new_arrival argument
 	* "chat-invited" handlers can now return a value to control what happens
 	  to the invite (accept, reject, prompt the user).
 	* "chat-left": Emitted *after* setting chat->left to TRUE.
--- a/plugins/signals-test.c	Thu Jan 12 06:44:23 2006 +0000
+++ b/plugins/signals-test.c	Thu Jan 12 06:59:39 2006 +0000
@@ -346,10 +346,10 @@
 
 static void
 chat_buddy_joined_cb(GaimConversation *conv, const char *user,
-					 GaimConvChatBuddyFlags flags, void *data)
+					 GaimConvChatBuddyFlags flags, gboolean new_arrival, void *data)
 {
-	gaim_debug_misc("signals test", "chat-buddy-joined (%s, %s, %d)\n",
-					gaim_conversation_get_name(conv), user, flags);
+	gaim_debug_misc("signals test", "chat-buddy-joined (%s, %s, %d, %d)\n",
+					gaim_conversation_get_name(conv), user, flags, new_arrival);
 }
 
 static void
@@ -501,8 +501,11 @@
  **************************************************************************/
 static int
 sound_playing_event_cb(GaimSoundEventID event, const GaimAccount *account) {
-	gaim_debug_misc("signals test", "sound playing event: %d for account: %s\n",
-	                event, gaim_account_get_username(account));
+	if (account != NULL)
+		gaim_debug_misc("signals test", "sound playing event: %d for account: %s\n",
+	    	            event, gaim_account_get_username(account));
+	else
+		gaim_debug_misc("signals test", "sound playing event: %d\n", event);
 
 	return 0;
 }
--- a/src/conversation.c	Thu Jan 12 06:44:23 2006 +0000
+++ b/src/conversation.c	Thu Jan 12 06:59:39 2006 +0000
@@ -1520,7 +1520,7 @@
 		}
 
 		gaim_signal_emit(gaim_conversations_get_handle(),
-						 "chat-buddy-joined", conv, user, flags);
+						 "chat-buddy-joined", conv, user, flags, new_arrivals);
 		ul = ul->next;
 		fl = fl->next;
 		if (extra_msgs != NULL)
@@ -2154,11 +2154,12 @@
 						 gaim_value_new(GAIM_TYPE_UINT));
 
 	gaim_signal_register(handle, "chat-buddy-joined",
-						 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3,
+						 gaim_marshal_VOID__POINTER_POINTER_UINT_UINT, NULL, 4,
 						 gaim_value_new(GAIM_TYPE_SUBTYPE,
 										GAIM_SUBTYPE_CONVERSATION),
 						 gaim_value_new(GAIM_TYPE_STRING),
-						 gaim_value_new(GAIM_TYPE_UINT));
+						 gaim_value_new(GAIM_TYPE_UINT),
+						 gaim_value_new(GAIM_TYPE_BOOLEAN));
 
 	gaim_signal_register(handle, "chat-buddy-flags",
 						 gaim_marshal_VOID__POINTER_POINTER_UINT_UINT, NULL, 4,
--- a/src/gtksound.c	Thu Jan 12 06:44:23 2006 +0000
+++ b/src/gtksound.c	Thu Jan 12 06:59:39 2006 +0000
@@ -148,6 +148,9 @@
 				   char *message, GaimConversation *conv,
 				   int flags, GaimSoundEventID event)
 {
+	if (flags & GAIM_MESSAGE_DELAYED)
+		return;
+
 	if (conv==NULL)
 		gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE, account);
 	else
@@ -165,9 +168,10 @@
 
 static void
 chat_buddy_join_cb(GaimConversation *conv, const char *name,
-				   GaimConvChatBuddyFlags flags, GaimSoundEventID event)
+				   GaimConvChatBuddyFlags flags, gboolean new_arrival,
+				   GaimSoundEventID event)
 {
-	if (!chat_nick_matches_name(conv, name))
+	if (new_arrival && !chat_nick_matches_name(conv, name))
 		play_conv_event(conv, event);
 }
 
@@ -199,6 +203,9 @@
 {
 	GaimConvChat *chat;
 
+	if (flags & GAIM_MESSAGE_DELAYED)
+		return;
+
 	chat = gaim_conversation_get_chat_data(conv);
 
 	if (chat!=NULL && gaim_conv_chat_is_user_ignored(chat, sender))