# HG changeset patch
# Node ID 7acd02e9bfbd
# Parent  7a4e48594a24
diff --git a/libpurple/protocols/zephyr/zephyr.c b/libpurple/protocols/zephyr/zephyr.c
--- a/libpurple/protocols/zephyr/zephyr.c
+++ b/libpurple/protocols/zephyr/zephyr.c
@@ -65,6 +65,7 @@
 typedef gssize (*PollableInputStreamReadFunc)(GPollableInputStream *stream, void *bufcur, GError **error);
 typedef gboolean (*ZephyrLoginFunc)(zephyr_account *zephyr);
 typedef Code_t (*ZephyrSubscribeToFunc)(zephyr_account *zephyr, char *class, char *instance, char *recipient);
+typedef unsigned int (*ZephyrSendTypingFunc)(zephyr_account *zephyr, const char *who);
 
 typedef enum {
 	PURPLE_ZEPHYR_NONE, /* Non-kerberized ZEPH0.2 */
@@ -95,6 +96,7 @@
 	GInputStream *tzc_stdout;
 	gchar *away;
 	ZephyrSubscribeToFunc subscribe_to;
+	ZephyrSendTypingFunc send_typing;
 };
 
 #define MAXCHILDREN 20
@@ -115,6 +117,8 @@
 static char *local_zephyr_normalize(const zephyr_account *zephyr, const char *);
 static void zephyr_chat_set_topic(PurpleConnection *gc, int id, const char *topic);
 static char *zephyr_tzc_deescape_str(const char *message);
+static unsigned int send_typing_tzc(zephyr_account *zephyr, const char *who);
+static unsigned int send_typing_zeph02(zephyr_account *zephyr, const char *who);
 
 static inline gboolean
 use_tzc(const zephyr_account *zephyr)
@@ -1444,11 +1448,13 @@
 		login = login_tzc;
 		check_notify = check_notify_tzc;
 		zephyr->subscribe_to = subscribe_to_tzc;
+		zephyr->send_typing = send_typing_tzc;
 	} else {
 		zephyr->connection_type = PURPLE_ZEPHYR_KRB4;
 		login = login_zeph02;
 		check_notify = check_notify_zeph02;
 		zephyr->subscribe_to = subscribe_to_zeph02;
+		zephyr->send_typing = send_typing_zeph02;
 	}
 
 	zephyr->encoding = (char *)purple_account_get_string(account, "encoding", ZEPHYR_FALLBACK_CHARSET);
@@ -2132,33 +2138,36 @@
 	return "zephyr";
 }
 
-static unsigned int zephyr_send_typing(PurpleProtocolIM *im, PurpleConnection *gc, const char *who, PurpleIMTypingState state) {
+static unsigned int
+send_typing_tzc(G_GNUC_UNUSED zephyr_account *zephyr, G_GNUC_UNUSED const char *who)
+{
+	return 0;
+}
+
+static unsigned int
+send_typing_zeph02(zephyr_account *zephyr, const char *who)
+{
 	gchar *recipient;
-	zephyr_account *zephyr = purple_connection_get_protocol_data(gc);
-	if (use_tzc(zephyr))
-		return 0;
-
-	if (state == PURPLE_IM_NOT_TYPING)
-		return 0;
 
 	/* XXX We probably should care if this fails. Or maybe we don't want to */
 	if (!who) {
 		purple_debug_info("zephyr", "who is null\n");
-		recipient = local_zephyr_normalize(zephyr,"");
+		recipient = local_zephyr_normalize(zephyr, "");
 	} else {
 		char *comma = strrchr(who, ',');
 		/* Don't ping broadcast (chat) recipients */
 		/* The strrchr case finds a realm-stripped broadcast subscription
 		   e.g. comma is the last character in the string */
-		if (comma && ( (*(comma+1) == '\0') || (*(comma+1) == '@')))
+		if (comma && ((*(comma+1) == '\0') || (*(comma+1) == '@'))) {
 			return 0;
-
-		recipient = local_zephyr_normalize(zephyr,who);
+		}
+
+		recipient = local_zephyr_normalize(zephyr, who);
 	}
 
-	purple_debug_info("zephyr","about to send typing notification to %s\n",recipient);
-	zephyr_send_message(zephyr,"MESSAGE","PERSONAL",recipient,"","","PING");
-	purple_debug_info("zephyr","sent typing notification\n");
+	purple_debug_info("zephyr", "about to send typing notification to %s\n", recipient);
+	zephyr_send_message(zephyr, "MESSAGE", "PERSONAL", recipient, "", "", "PING");
+	purple_debug_info("zephyr", "sent typing notification\n");
 
 	/*
 	 * TODO: Is this correct?  It means we will call
@@ -2168,6 +2177,19 @@
 	return ZEPHYR_TYPING_SEND_TIMEOUT;
 }
 
+static unsigned int
+zephyr_send_typing(G_GNUC_UNUSED PurpleProtocolIM *im, PurpleConnection *gc, const char *who, PurpleIMTypingState state)
+{
+	zephyr_account *zephyr;
+
+	if (state == PURPLE_IM_NOT_TYPING) {
+		return 0;
+	}
+
+	zephyr = purple_connection_get_protocol_data(gc);
+	return zephyr->send_typing(zephyr, who);
+}
+
 
 
 static void zephyr_chat_set_topic(PurpleConnection * gc, int id, const char *topic)
