changeset 11706:bcc49c25ef90

[gaim-migrate @ 13997] Generalize the buddy-typing and buddy-typing-stopped signals. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Fri, 21 Oct 2005 19:03:51 +0000
parents 0906a3e9626c
children b7af9100af6c
files plugins/ChangeLog.API plugins/signals-test.c src/conversation.c src/pounce.c src/server.c
diffstat 5 files changed, 57 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ChangeLog.API	Fri Oct 21 19:03:34 2005 +0000
+++ b/plugins/ChangeLog.API	Fri Oct 21 19:03:51 2005 +0000
@@ -145,6 +145,11 @@
 	* Added:   "buddy-added" and "buddy-removed", which are self-explanatory
 	* Added:   "blist-node-aliased", an alias was set for a buddy, chat or
 	           contact.  See the Doxygen documentation for the details.
+	* Changed: "buddy-typing" and "buddy-typing-stopped", replaced the
+	           GaimConversation* 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.
 
 version 1.0.0 (09/17/2004):
 	* Added: get_chat_name to the GaimPluginProtocolInfo struct
--- a/plugins/signals-test.c	Fri Oct 21 19:03:34 2005 +0000
+++ b/plugins/signals-test.c	Fri Oct 21 19:03:51 2005 +0000
@@ -380,10 +380,17 @@
 }
 
 static void
-buddy_typing_cb(GaimConversation *conv, void *data)
+buddy_typing_cb(GaimAccount *account, const char *name, void *data)
 {
-	gaim_debug_misc("signals test", "buddy-typing (%s)\n",
-					gaim_conversation_get_name(conv));
+	gaim_debug_misc("signals test", "buddy-typing (%s, %s)\n",
+					gaim_account_get_username(account), name);
+}
+
+static void
+buddy_typing_stopped_cb(GaimAccount *account, const char *name, void *data)
+{
+	gaim_debug_misc("signals test", "buddy-typing-stopped (%s, %s)\n",
+					gaim_account_get_username(account), name);
 }
 
 static gboolean
@@ -652,6 +659,8 @@
 						plugin, GAIM_CALLBACK(deleting_conversation_cb), NULL);
 	gaim_signal_connect(conv_handle, "buddy-typing",
 						plugin, GAIM_CALLBACK(buddy_typing_cb), NULL);
+	gaim_signal_connect(conv_handle, "buddy-typing-stopped",
+						plugin, GAIM_CALLBACK(buddy_typing_stopped_cb), NULL);
 	gaim_signal_connect(conv_handle, "chat-buddy-joining",
 						plugin, GAIM_CALLBACK(chat_buddy_joining_cb), NULL);
 	gaim_signal_connect(conv_handle, "chat-buddy-joined",
--- a/src/conversation.c	Fri Oct 21 19:03:34 2005 +0000
+++ b/src/conversation.c	Fri Oct 21 19:03:51 2005 +0000
@@ -2166,12 +2166,14 @@
 	gaim_signal_register(handle, "buddy-typing",
 						 gaim_marshal_VOID__POINTER, NULL, 1,
 						 gaim_value_new(GAIM_TYPE_SUBTYPE,
-										GAIM_SUBTYPE_CONVERSATION));
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_STRING));
 
 	gaim_signal_register(handle, "buddy-typing-stopped",
 						 gaim_marshal_VOID__POINTER, NULL, 1,
 						 gaim_value_new(GAIM_TYPE_SUBTYPE,
-										GAIM_SUBTYPE_CONVERSATION));
+										GAIM_SUBTYPE_ACCOUNT),
+						 gaim_value_new(GAIM_TYPE_STRING));
 
 	gaim_signal_register(handle, "chat-buddy-joining",
 						 gaim_marshal_BOOLEAN__POINTER_POINTER_UINT,
--- a/src/pounce.c	Fri Oct 21 19:03:34 2005 +0000
+++ b/src/pounce.c	Fri Oct 21 19:03:51 2005 +0000
@@ -949,12 +949,12 @@
 }
 
 static void
-buddy_typing_cb(GaimConversation *conv, void *data)
+buddy_typing_cb(GaimAccount *account, const char *name, void *data)
 {
-	GaimAccount *account = gaim_conversation_get_account(conv);
-	const char *name     = gaim_conversation_get_name(conv);
+	GaimConversation *conv;
 
-	if (gaim_find_buddy(account, name) != NULL)
+	conv == gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, account);
+	if (conv != NULL)
 	{
 		GaimPounceEvent event;
 
--- a/src/server.c	Fri Oct 21 19:03:34 2005 +0000
+++ b/src/server.c	Fri Oct 21 19:03:51 2005 +0000
@@ -787,67 +787,53 @@
 
 void serv_got_typing(GaimConnection *gc, const char *name, int timeout,
 					 GaimTypingState state) {
-
-	GaimBuddy *b;
-	GaimConversation *cnv;
+	GaimConversation *conv;
 	GaimConvIm *im;
 
-	cnv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, gc->account);
-	if (!cnv)
-		return;
-
-	im = GAIM_CONV_IM(cnv);
-
-	gaim_conversation_set_account(cnv, gc->account);
-	gaim_conv_im_set_typing_state(im, state);
-	gaim_conv_im_update_typing(im);
-
-	b = gaim_find_buddy(gc->account, name);
+	conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, gc->account);
+	if (conv != NULL) {
+		im = GAIM_CONV_IM(conv);
 
-	if (b != NULL)
-	{
-		if (state == GAIM_TYPING)
-		{
-			gaim_signal_emit(gaim_conversations_get_handle(),
-							 "buddy-typing", cnv);
-		}
-		else
-		{
-			gaim_signal_emit(gaim_conversations_get_handle(),
-							 "buddy-typing-stopped", cnv);
-		}
+		gaim_conversation_set_account(conv, gc->account);
+		gaim_conv_im_set_typing_state(im, state);
+		gaim_conv_im_update_typing(im);
 	}
 
-	if (timeout > 0)
+	if (state == GAIM_TYPING)
+	{
+		gaim_signal_emit(gaim_conversations_get_handle(),
+						 "buddy-typing", gc->account, name);
+	}
+	else
+	{
+		gaim_signal_emit(gaim_conversations_get_handle(),
+						 "buddy-typing-stopped", gc->account, name);
+	}
+
+	if (conv != NULL && timeout > 0)
 		gaim_conv_im_start_typing_timeout(im, timeout);
 }
 
 void serv_got_typing_stopped(GaimConnection *gc, const char *name) {
 
-	GaimConversation *c;
+	GaimConversation *conv;
 	GaimConvIm *im;
-	GaimBuddy *b;
 
-	c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, gc->account);
-	if (!c)
-		return;
-
-	im = GAIM_CONV_IM(c);
+	conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, gc->account);
+	if (conv != NULL)
+	{
+		im = GAIM_CONV_IM(conv);
 
-	if (im->typing_state == GAIM_NOT_TYPING)
-		return;
-
-	gaim_conv_im_stop_typing_timeout(im);
-	gaim_conv_im_set_typing_state(im, GAIM_NOT_TYPING);
-	gaim_conv_im_update_typing(im);
+		if (im->typing_state == GAIM_NOT_TYPING)
+			return;
 
-	b = gaim_find_buddy(gc->account, name);
+		gaim_conv_im_stop_typing_timeout(im);
+		gaim_conv_im_set_typing_state(im, GAIM_NOT_TYPING);
+		gaim_conv_im_update_typing(im);
+	}
 
-	if (b != NULL)
-	{
-		gaim_signal_emit(gaim_conversations_get_handle(),
-						 "buddy-typing-stopped", c);
-	}
+	gaim_signal_emit(gaim_conversations_get_handle(),
+					 "buddy-typing-stopped", gc->account, name);
 }
 
 struct chat_invite_data {