changeset 12604:71299d63801d

[gaim-migrate @ 14939] SF Patch #1383857 from Sadrul "This patch makes the display-msg signals to be emitted from gtkconv instead of conversation. The display-msg signals were not too useful before, especially because they were being emitted right after writing-msg signals, and not being emitted for messages being sent at all. This patch also makes necessary changes in the plugins, and in Changelog.API. With this change, the notify plugin can set the URGENT hint for a new received message which creates a conversation. marv and charkins seemed to think this was a good thing to do." committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Wed, 21 Dec 2005 21:48:38 +0000
parents e4e47871c373
children cd1d0131e07f
files plugins/ChangeLog.API plugins/gtk-signals-test.c plugins/musicmessaging/musicmessaging.c plugins/notify.c plugins/signals-test.c plugins/timestamp.c src/conversation.c src/gtkconv.c
diffstat 8 files changed, 123 insertions(+), 129 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ChangeLog.API	Wed Dec 21 21:18:25 2005 +0000
+++ b/plugins/ChangeLog.API	Wed Dec 21 21:48:38 2005 +0000
@@ -73,6 +73,13 @@
 	                             See the documentation for this function and
 	                             gaim_account_request_add.
 	* gaim_accounts_reorder: new_index is now a gint instead of a size_t
+	* displaying-message signals: displaying-[im|chat]-msg and
+	                              displayed-[im|chat]-msg signals are emitted
+								  for all messages (ie, for received messages,
+								  sent messages, system messages, error
+								  messages etc.), and the signals now have
+								  gaim_gtk_conversations_get_handle() for their
+								  handle.
 
 	Removed:
 	* gaim_gtk_sound_{get,set}_mute() (replaced by the /gaim/gtk/sound/mute
--- a/plugins/gtk-signals-test.c	Wed Dec 21 21:18:25 2005 +0000
+++ b/plugins/gtk-signals-test.c	Wed Dec 21 21:48:38 2005 +0000
@@ -60,6 +60,40 @@
 	gaim_debug_info("gtk-signal-test", "conversation dragging cb\n");
 }
 
+static gboolean
+displaying_im_msg_cb(GaimAccount *account, GaimConversation *conv,
+		     char **buffer, int flags, void *data)
+{
+	gaim_debug_misc("gtk-signals test", "displaying-im-msg (%s, %s)\n",
+					gaim_conversation_get_name(conv), *buffer);
+
+	return FALSE;
+}
+
+static void
+displayed_im_msg_cb(GaimAccount *account, GaimConversation *conv, const char *buffer, int flags, void *data)
+{
+	gaim_debug_misc("gtk-signals test", "displayed-im-msg (%s, %s)\n",
+					gaim_conversation_get_name(conv), buffer);
+}
+
+static gboolean
+displaying_chat_msg_cb(GaimAccount *account, GaimConversation *conv,
+		       char **buffer, int flags, void *data)
+{
+	gaim_debug_misc("gtk-signals test", "displaying-chat-msg (%s, %s)\n",
+					gaim_conversation_get_name(conv), *buffer);
+
+	return FALSE;
+}
+
+static void
+displayed_chat_msg_cb(GaimAccount *account, GaimConversation *conv, const char *buffer, int flags, void *data)
+{
+	gaim_debug_misc("gtk-signals test", "displayed-chat-msg (%s, %s)\n",
+					gaim_conversation_get_name(conv), buffer);
+}
+
 /**************************************************************************
  * Plugin stuff
  **************************************************************************/
@@ -83,6 +117,14 @@
 	/* Conversations subsystem signals */
 	gaim_signal_connect(conv_handle, "conversation-dragging",
 						plugin, GAIM_CALLBACK(conversation_dragging_cb), NULL);
+	gaim_signal_connect(conv_handle, "displaying-im-msg",
+						plugin, GAIM_CALLBACK(displaying_im_msg_cb), NULL);
+	gaim_signal_connect(conv_handle, "displayed-im-msg",
+						plugin, GAIM_CALLBACK(displayed_im_msg_cb), NULL);
+	gaim_signal_connect(conv_handle, "displaying-chat-msg",
+						plugin, GAIM_CALLBACK(displaying_chat_msg_cb), NULL);
+	gaim_signal_connect(conv_handle, "displayed-chat-msg",
+						plugin, GAIM_CALLBACK(displayed_chat_msg_cb), NULL);
 
 	return TRUE;
 }
--- a/plugins/musicmessaging/musicmessaging.c	Wed Dec 21 21:18:25 2005 +0000
+++ b/plugins/musicmessaging/musicmessaging.c	Wed Dec 21 21:48:38 2005 +0000
@@ -281,7 +281,7 @@
 					plugin, GAIM_CALLBACK(conv_destroyed), NULL);
 					
 	/* Listen for sending/receiving messages to replace tags */
-	gaim_signal_connect(conv_list_handle, "displaying-im-msg",
+	gaim_signal_connect(conv_list_handle, "writing-im-msg",
 					plugin, GAIM_CALLBACK(intercept_sent), NULL);
 	gaim_signal_connect(conv_list_handle, "receiving-im-msg",
 					plugin, GAIM_CALLBACK(intercept_received), NULL);
--- a/plugins/notify.c	Wed Dec 21 21:18:25 2005 +0000
+++ b/plugins/notify.c	Wed Dec 21 21:48:38 2005 +0000
@@ -87,6 +87,7 @@
 #include "gtkgaim.h"
 #include "gtkprefs.h"
 
+#include "conversation.h"
 #include "prefs.h"
 #include "signals.h"
 #include "version.h"
@@ -238,22 +239,10 @@
 }
 
 static gboolean
-im_recv_im(GaimAccount *account, char *sender, char *message,
-           GaimConversation *conv, int *flags)
+message_displayed_cb(GaimAccount *account, GaimConversation *conv, const char *message, GaimMessageFlags flags)
 {
-	notify(conv, TRUE);
-
-	return FALSE;
-}
-
-static gboolean
-chat_recv_im(GaimAccount *account, char *sender, char *message,
-             GaimConversation *conv, int *flags)
-{
-	if (gaim_conv_chat_is_user_ignored(GAIM_CONV_CHAT(conv), sender))
-			return FALSE;
-
-	notify(conv, TRUE);
+	if ((flags & GAIM_MESSAGE_RECV) && !(flags & GAIM_MESSAGE_DELAYED))
+		notify(conv, TRUE);
 
 	return FALSE;
 }
@@ -766,16 +755,14 @@
 {
 	GList *convs = gaim_get_conversations();
 	void *conv_handle = gaim_conversations_get_handle();
-	/*
 	void *gtk_conv_handle = gaim_gtk_conversations_get_handle();
-	*/
 
 	my_plugin = plugin;
 
-	gaim_signal_connect(conv_handle, "received-im-msg", plugin,
-	                    GAIM_CALLBACK(im_recv_im), NULL);
-	gaim_signal_connect(conv_handle, "received-chat-msg", plugin,
-	                    GAIM_CALLBACK(chat_recv_im), NULL);
+	gaim_signal_connect(gtk_conv_handle, "displayed-im-msg", plugin,
+						GAIM_CALLBACK(message_displayed_cb), NULL);
+	gaim_signal_connect(gtk_conv_handle, "displayed-chat-msg", plugin,
+						GAIM_CALLBACK(message_displayed_cb), NULL);
 	gaim_signal_connect(conv_handle, "sent-im-msg", plugin,
 	                    GAIM_CALLBACK(im_sent_im), NULL);
 	gaim_signal_connect(conv_handle, "sent-chat-msg", plugin,
--- a/plugins/signals-test.c	Wed Dec 21 21:18:25 2005 +0000
+++ b/plugins/signals-test.c	Wed Dec 21 21:48:38 2005 +0000
@@ -200,23 +200,6 @@
  * Conversation subsystem signal callbacks
  **************************************************************************/
 static gboolean
-displaying_im_msg_cb(GaimAccount *account, GaimConversation *conv,
-		     char **buffer, void *data)
-{
-	gaim_debug_misc("signals test", "displaying-im-msg (%s, %s)\n",
-					gaim_conversation_get_name(conv), *buffer);
-
-	return FALSE;
-}
-
-static void
-displayed_im_msg_cb(GaimAccount *account, GaimConversation *conv, const char *buffer, void *data)
-{
-	gaim_debug_misc("signals test", "displayed-im-msg (%s, %s)\n",
-					gaim_conversation_get_name(conv), buffer);
-}
-
-static gboolean
 writing_im_msg_cb(GaimAccount *account, GaimConversation  *conv, char **buffer, void *data)
 {
 	gaim_debug_misc("signals test", "writing-im-msg (%s, %s, %s)\n",
@@ -269,23 +252,6 @@
 }
 
 static gboolean
-displaying_chat_msg_cb(GaimAccount *account, GaimConversation *conv,
-		       char **buffer, void *data)
-{
-	gaim_debug_misc("signals test", "displaying-chat-msg (%s, %s)\n",
-					gaim_conversation_get_name(conv), *buffer);
-
-	return FALSE;
-}
-
-static void
-displayed_chat_msg_cb(GaimAccount *account, GaimConversation *conv, const char *buffer, void *data)
-{
-	gaim_debug_misc("signals test", "displayed-chat-msg (%s, %s)\n",
-					gaim_conversation_get_name(conv), buffer);
-}
-
-static gboolean
 writing_chat_msg_cb(GaimAccount *account, GaimConversation *conv,
 		       char **buffer, void *data)
 {
@@ -615,10 +581,6 @@
 						plugin, GAIM_CALLBACK(signed_off_cb), NULL);
 
 	/* Conversations subsystem signals */
-	gaim_signal_connect(conv_handle, "displaying-im-msg",
-						plugin, GAIM_CALLBACK(displaying_im_msg_cb), NULL);
-	gaim_signal_connect(conv_handle, "displayed-im-msg",
-						plugin, GAIM_CALLBACK(displayed_im_msg_cb), NULL);
 	gaim_signal_connect(conv_handle, "writing-im-msg",
 						plugin, GAIM_CALLBACK(writing_im_msg_cb), NULL);
 	gaim_signal_connect(conv_handle, "wrote-im-msg",
@@ -631,10 +593,6 @@
 						plugin, GAIM_CALLBACK(receiving_im_msg_cb), NULL);
 	gaim_signal_connect(conv_handle, "received-im-msg",
 						plugin, GAIM_CALLBACK(received_im_msg_cb), NULL);
-	gaim_signal_connect(conv_handle, "displaying-chat-msg",
-						plugin, GAIM_CALLBACK(displaying_chat_msg_cb), NULL);
-	gaim_signal_connect(conv_handle, "displayed-chat-msg",
-						plugin, GAIM_CALLBACK(displayed_chat_msg_cb), NULL);
 	gaim_signal_connect(conv_handle, "writing-chat-msg",
 						plugin, GAIM_CALLBACK(writing_chat_msg_cb), NULL);
 	gaim_signal_connect(conv_handle, "wrote-chat-msg",
--- a/plugins/timestamp.c	Wed Dec 21 21:18:25 2005 +0000
+++ b/plugins/timestamp.c	Wed Dec 21 21:48:38 2005 +0000
@@ -83,7 +83,7 @@
 
 static gboolean
 timestamp_displaying_conv_msg(GaimAccount *account, GaimConversation *conv,
-							  char **buffer, void *data)
+							  char **buffer, GaimMessageFlags flags, void *data)
 {
 	int is_timestamp_enabled;
 
@@ -103,16 +103,6 @@
 	return FALSE;
 }
 
-static gboolean
-timestamp_receiving_msg(GaimAccount *account, char **sender, char **buffer,
-						GaimConversation *conv, int *flags, void *data)
-{
-	g_return_val_if_fail(conv != NULL, FALSE);
-
-	return timestamp_displaying_conv_msg(account, conv, buffer, data);
-}
-
-
 static void timestamp_new_convo(GaimConversation *conv)
 {
 	GaimGtkConversation *c = GAIM_GTK_CONVERSATION(conv);
@@ -227,8 +217,6 @@
 					plugin, GAIM_CALLBACK(timestamp_new_convo), NULL);
 
 	/* record IM display events for each conversation */
-	gaim_signal_connect(conv_handle, "receiving-im-msg",
-					plugin, GAIM_CALLBACK(timestamp_receiving_msg), NULL);
 	gaim_signal_connect(conv_handle, "displaying-im-msg",
 					plugin, GAIM_CALLBACK(timestamp_displaying_conv_msg), NULL);
 
--- a/src/conversation.c	Wed Dec 21 21:18:25 2005 +0000
+++ b/src/conversation.c	Wed Dec 21 21:48:38 2005 +0000
@@ -135,21 +135,6 @@
 
 	sent = g_strdup(displayed);
 
-	plugin_return =
-		GPOINTER_TO_INT(gaim_signal_emit_return_1(
-			gaim_conversations_get_handle(), (type == GAIM_CONV_TYPE_IM ?
-			"displaying-im-msg" : "displaying-chat-msg"),
-			account, conv, &displayed));
-
-	if (plugin_return) {
-		g_free(displayed);
-		displayed = NULL;
-	} else {
-		gaim_signal_emit(gaim_conversations_get_handle(),
-			(type == GAIM_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"),
-			account, conv, displayed);
-	}
-
 	msgflags |= GAIM_MESSAGE_SEND;
 
 	if (type == GAIM_CONV_TYPE_IM) {
@@ -2015,24 +2000,6 @@
 										GAIM_SUBTYPE_CONVERSATION),
 						 gaim_value_new(GAIM_TYPE_STRING));
 
-	gaim_signal_register(handle, "displaying-im-msg",
-						 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER,
-						 gaim_value_new(GAIM_TYPE_BOOLEAN), 3,
-						 gaim_value_new(GAIM_TYPE_SUBTYPE,
-										GAIM_SUBTYPE_ACCOUNT),
-						 gaim_value_new(GAIM_TYPE_SUBTYPE,
-										GAIM_SUBTYPE_CONVERSATION),
-						 gaim_value_new_outgoing(GAIM_TYPE_STRING));
-
-	gaim_signal_register(handle, "displayed-im-msg",
-						 gaim_marshal_VOID__POINTER_POINTER_POINTER,
-						 NULL, 3,
-						 gaim_value_new(GAIM_TYPE_SUBTYPE,
-										GAIM_SUBTYPE_ACCOUNT),
-						 gaim_value_new(GAIM_TYPE_SUBTYPE,
-										GAIM_SUBTYPE_CONVERSATION),
-						 gaim_value_new(GAIM_TYPE_STRING));
-
 	gaim_signal_register(handle, "sending-im-msg",
 						 gaim_marshal_VOID__POINTER_POINTER_POINTER,
 						 NULL, 3,
@@ -2089,24 +2056,6 @@
 										GAIM_SUBTYPE_CONVERSATION),
 						 gaim_value_new(GAIM_TYPE_STRING));
 
-	gaim_signal_register(handle, "displaying-chat-msg",
-						 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER,
-						 gaim_value_new(GAIM_TYPE_BOOLEAN), 3,
-						 gaim_value_new(GAIM_TYPE_SUBTYPE,
-										GAIM_SUBTYPE_ACCOUNT),
-						 gaim_value_new(GAIM_TYPE_SUBTYPE,
-										GAIM_SUBTYPE_CONVERSATION),
-						 gaim_value_new_outgoing(GAIM_TYPE_STRING));
-
-	gaim_signal_register(handle, "displayed-chat-msg",
-						 gaim_marshal_VOID__POINTER_POINTER_POINTER,
-						 NULL, 3,
-						 gaim_value_new(GAIM_TYPE_SUBTYPE,
-										GAIM_SUBTYPE_ACCOUNT),
-						 gaim_value_new(GAIM_TYPE_SUBTYPE,
-										GAIM_SUBTYPE_CONVERSATION),
-						 gaim_value_new(GAIM_TYPE_STRING));
-
 	gaim_signal_register(handle, "sending-chat-msg",
 						 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3,
 						 gaim_value_new(GAIM_TYPE_SUBTYPE,
--- a/src/gtkconv.c	Wed Dec 21 21:18:25 2005 +0000
+++ b/src/gtkconv.c	Wed Dec 21 21:48:38 2005 +0000
@@ -4366,7 +4366,10 @@
 	char *str;
 	char *with_font_tag;
 	char *sml_attrib = NULL;
-	size_t length = strlen(message) + 1;
+	size_t length;
+	GaimConversationType type;
+	char *displaying;
+	gboolean plugin_return;
 
 	gtkconv = GAIM_GTK_CONVERSATION(conv);
 
@@ -4376,9 +4379,24 @@
 	/* Set the active conversation to the one that just messaged us. */
 	/* TODO: consider not doing this if the account is offline or something */
 	gaim_gtkconv_set_active_conversation(conv);
+	type = gaim_conversation_get_type(conv);
 
 	gc = gaim_conversation_get_gc(conv);
 	account = gaim_conversation_get_account(conv);
+
+	displaying = g_strdup(message);
+	plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1(
+							gaim_gtk_conversations_get_handle(), (type == GAIM_CONV_TYPE_IM ?
+							"displaying-im-msg" : "displaying-chat-msg"),
+							account, conv, &displaying, flags));
+	if (plugin_return)
+	{
+		g_free(displaying);
+		return;
+	}
+	message = displaying;
+	length = strlen(message) + 1;
+
 	win = gtkconv->win;
 	prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
 
@@ -4605,6 +4623,11 @@
 	if(sml_attrib)
 		g_free(sml_attrib);
 
+	gaim_signal_emit(gaim_gtk_conversations_get_handle(),
+		(type == GAIM_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"),
+		account, conv, message, flags);
+	g_free(displaying);
+
 	/* Tab highlighting stuff */
 	if (!gaim_gtkconv_has_focus(conv))
 	{
@@ -6037,6 +6060,46 @@
 	                     gaim_value_new(GAIM_TYPE_SUBTYPE,
 	                                    GAIM_SUBTYPE_CONV_WINDOW));
 
+	gaim_signal_register(handle, "displaying-im-msg",
+						 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT,
+						 gaim_value_new(GAIM_TYPE_BOOLEAN), 4,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING),
+						 gaim_value_new(G_TYPE_INT));
+
+	gaim_signal_register(handle, "displayed-im-msg",
+						 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT,
+						 NULL, 4,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new(G_TYPE_INT));
+
+	gaim_signal_register(handle, "displaying-chat-msg",
+						 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT,
+						 gaim_value_new(GAIM_TYPE_BOOLEAN), 4,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new_outgoing(GAIM_TYPE_STRING),
+						 gaim_value_new(G_TYPE_INT));
+
+	gaim_signal_register(handle, "displayed-chat-msg",
+						 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT,
+						 NULL, 4,
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_SUBTYPE,
+										GAIM_SUBTYPE_CONVERSATION),
+						 gaim_value_new(GAIM_TYPE_STRING),
+						 gaim_value_new(G_TYPE_INT));
+
 	/**********************************************************************
 	 * Register commands
 	 **********************************************************************/