diff src/server.c @ 13842:a9ff4499d9ce

[gaim-migrate @ 16295] Hopefully improve the typing notification code so it's a lot easier to understand. This also creates a distinction between the signals emitted when receiving GAIM_TYPED and GAIM_NOT_TYPING messages (by adding a gaim-typed signal). And the gaim-not-typing signal should work in all cases. Most of this is stuff I changed last week during work, thanks to Meebo committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 20 Jun 2006 08:17:49 +0000
parents 99688ab310c8
children 7d513e44201b
line wrap: on
line diff
--- a/src/server.c	Tue Jun 20 04:05:56 2006 +0000
+++ b/src/server.c	Tue Jun 20 08:17:49 2006 +0000
@@ -38,18 +38,16 @@
 #define SECS_BEFORE_RESENDING_AUTORESPONSE 600
 #define SEX_BEFORE_RESENDING_AUTORESPONSE "Only after you're married"
 
-/* This should return the elapsed time in seconds in which Gaim will not send
- * typing notifications.
- * if it returns zero, it will not send any more typing notifications
- * typing is a flag - TRUE for typing, FALSE for stopped typing */
-int serv_send_typing(GaimConnection *g, const char *name, int typing) {
+unsigned int
+serv_send_typing(GaimConnection *gc, const char *name, GaimTypingState state)
+{
 	GaimPluginProtocolInfo *prpl_info = NULL;
 
-	if (g != NULL && g->prpl != NULL)
-		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl);
+	if (gc != NULL && gc->prpl != NULL)
+		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
 
-	if (g && prpl_info && prpl_info->send_typing)
-		return prpl_info->send_typing(g, name, typing);
+	if (prpl_info && prpl_info->send_typing)
+		return prpl_info->send_typing(gc, name, state);
 
 	return 0;
 }
@@ -150,8 +148,8 @@
 		lar->sent = time(NULL);
 	}
 
-	if (conv && gaim_conv_im_get_type_again_timeout(GAIM_CONV_IM(conv)))
-		gaim_conv_im_stop_type_again_timeout(GAIM_CONV_IM(conv));
+	if (conv && gaim_conv_im_get_send_typed_timeout(GAIM_CONV_IM(conv)))
+		gaim_conv_im_stop_send_typed_timeout(GAIM_CONV_IM(conv));
 
 	return val;
 }
@@ -593,7 +591,7 @@
 		else
 		{
 			gaim_signal_emit(gaim_conversations_get_handle(),
-							 "buddy-typing-stopped", gc->account, name);
+							 "buddy-typed", gc->account, name);
 		}
 	}
 
@@ -618,6 +616,11 @@
 		gaim_conv_im_set_typing_state(im, GAIM_NOT_TYPING);
 		gaim_conv_im_update_typing(im);
 	}
+	else
+	{
+		gaim_signal_emit(gaim_conversations_get_handle(),
+						 "buddy-typing-stopped", gc->account, name);
+	}
 
 	gaim_signal_emit(gaim_conversations_get_handle(),
 					 "buddy-typing-stopped", gc->account, name);