changeset 3596:bb966d68f9e3

[gaim-migrate @ 3698] I like typing notifcation. I think I'll marry it. Also, if I'm going to go around mentioning gaim on resumes, I can't very well tell people to look for "KingAnt"... :-) committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 06 Oct 2002 05:01:50 +0000
parents 1e60a05c7482
children bc87186a7478
files ChangeLog src/conversation.c src/gaim.h src/protocols/jabber/jabber.c src/protocols/oscar/oscar.c src/protocols/yahoo/yahoo.c src/ui.h
diffstat 7 files changed, 48 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Oct 06 03:08:47 2002 +0000
+++ b/ChangeLog	Sun Oct 06 05:01:50 2002 +0000
@@ -77,6 +77,10 @@
 	  KDE 3.1. (Thanks Robert McQueen, Ari Pollak, Patrick Aussems)
 	* Plugins dialog and perl script menu merged into preferences.
 	* use snprintf instead of sprintf (Thanks William T. Mahan).
+	* Non-direct connect typing notification for AIM over oscar 
+	  (Thanks Mark Doliner)
+	* Improved typing notification support for Jabber and 
+	  Yahoo! (Thanks Nathan Walp)
 
 version 0.59 (06/24/2002):
 	* Hungarian translation added (Thanks, Sutto Zoltan)
@@ -243,7 +247,7 @@
 	* Better selection in HTML widget (Thanks BMiller)
 	* New icons for ICQ (Thanks Kevin Miller)
 	* Editable buddy pounces (Thanks Jason Willis)
-	* Server side buddy lists in Oscar (Thanks KingAnt :-))
+	* Server side buddy lists in Oscar (Thanks Mark Doliner :-))
 	* Fix for the chatlist plugin
 	* Typing Notification (AIM Direct Connect, Yahoo, MSN)
 	* IM Images (Receive Only)
--- a/src/conversation.c	Sun Oct 06 03:08:47 2002 +0000
+++ b/src/conversation.c	Sun Oct 06 05:01:50 2002 +0000
@@ -284,6 +284,8 @@
 	g_list_free(c->send_history);
 	if (c->typing_timeout)
 		gtk_timeout_remove(c->typing_timeout);
+	if (c->type_again_timeout)
+		gtk_timeout_remove(c->type_again_timeout);
 	g_string_free(c->history, TRUE);
 	g_free(c);
 }
@@ -535,7 +537,8 @@
 
 	if (!c->is_chat) {
 		GSList *cn = connections;
-		serv_send_typing(c->gc, c->name, FALSE);
+		if (!(misc_options & OPT_MISC_STEALTH_TYPING))
+			serv_send_typing(c->gc, c->name, NOT_TYPING);
 		while (cn) {
 			struct gaim_connection *gc = cn->data;
 			cn = cn->next;
@@ -820,6 +823,16 @@
 		gtk_notebook_next_page(notebook);
 }
 
+gboolean send_typed(gpointer data)
+{
+	struct conversation *c = (struct conversation*)data;
+	if (c && c->gc && c->name) {
+		c->type_again = 1;
+		serv_send_typing(c->gc, c->name, TYPED);
+	}
+	return FALSE;
+}
+
 gboolean keypress_callback(GtkWidget *entry, GdkEventKey * event, struct conversation *c)
 {
 	int pos;
@@ -1066,23 +1079,34 @@
 
 	if (c && (!(misc_options & OPT_MISC_STEALTH_TYPING)) && !c->is_chat) {
 		char *txt = gtk_editable_get_chars(GTK_EDITABLE(c->entry), 0, -1);
-		if (gdk_keyval_to_unicode(event->keyval) && 
+		if (gdk_keyval_to_unicode(event->keyval) &&
 			(strlen(txt) == 0 || (c->type_again != 0 && time(NULL) > c->type_again))) {
-			int timeout = serv_send_typing(c->gc, c->name, TRUE);
+			int timeout = serv_send_typing(c->gc, c->name, TYPING);
 			if (timeout)
 				c->type_again = time(NULL) + timeout;
 			else
 				c->type_again = 0;
+
+			if (c && c->type_again_timeout)
+				gtk_timeout_remove(c->type_again_timeout);
+			/* send TYPED after 5 seconds of not typing */
+			c->type_again_timeout = gtk_timeout_add(5000, send_typed, (gpointer)c);
 		}
 		else if (strlen(txt) == 1) {
 			if ((GTK_OLD_EDITABLE(c->entry)->current_pos == 1 && event->keyval == GDK_BackSpace) ||
-			    (GTK_OLD_EDITABLE(c->entry)->current_pos == 0 && event->keyval == GDK_Delete))
-				serv_send_typing(c->gc, c->name, FALSE);
+			    (GTK_OLD_EDITABLE(c->entry)->current_pos == 0 && event->keyval == GDK_Delete)) {
+				if (c && c->type_again_timeout)
+					gtk_timeout_remove(c->type_again_timeout);
+				serv_send_typing(c->gc, c->name, NOT_TYPING);
+			}
 		} else if (GTK_OLD_EDITABLE(c->entry)->selection_start_pos == 0) {
 			if (GTK_OLD_EDITABLE(c->entry)->selection_end_pos == strlen(txt) &&
 				strlen(txt) > 0 &&
-			    (event->keyval == GDK_BackSpace || event->keyval == GDK_Delete))
-				serv_send_typing(c->gc, c->name, FALSE);
+			    (event->keyval == GDK_BackSpace || event->keyval == GDK_Delete)) {
+				if (c && c->type_again_timeout)
+					gtk_timeout_remove(c->type_again_timeout);
+				serv_send_typing(c->gc, c->name, NOT_TYPING);
+			}
 		}
 		g_free(txt);
 	}
--- a/src/gaim.h	Sun Oct 06 03:08:47 2002 +0000
+++ b/src/gaim.h	Sun Oct 06 05:01:50 2002 +0000
@@ -117,6 +117,10 @@
 #define PERMIT_SOME	3
 #define DENY_SOME	4
 
+#define NOT_TYPING 0
+#define TYPING     1
+#define TYPED      2
+
 #define WFLAG_SEND	0x01
 #define WFLAG_RECV	0x02
 #define WFLAG_AUTO	0x04
--- a/src/protocols/jabber/jabber.c	Sun Oct 06 03:08:47 2002 +0000
+++ b/src/protocols/jabber/jabber.c	Sun Oct 06 05:01:50 2002 +0000
@@ -2209,7 +2209,7 @@
 
 	if((realwho = get_realwho(gjc, who, FALSE, NULL)) == NULL)
 		return 0;
-	
+
 	x = xmlnode_new_tag("message");
 	xmlnode_put_attrib(x, "to", realwho);
 	xmlnode_insert_tag(x, "gaim");
@@ -2217,9 +2217,9 @@
 	y = xmlnode_insert_tag(x, "x");
 	xmlnode_put_attrib(y, "xmlns", "jabber:x:event");
 
-	if(typing)
+	if(typing == TYPING)
 		xmlnode_insert_tag(y, "composing");
-	
+
 	gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x);
 	xmlnode_free(x);
 	g_free(realwho);
--- a/src/protocols/oscar/oscar.c	Sun Oct 06 03:08:47 2002 +0000
+++ b/src/protocols/oscar/oscar.c	Sun Oct 06 05:01:50 2002 +0000
@@ -2776,8 +2776,10 @@
 	else {
 		struct buddy *b = find_buddy(gc, name);
 		if (b && (b->uc & UC_TYPINGNOT)) {
-			if (typing)
+			if (typing == TYPING)
 				aim_mtn_send(odata->sess, 0x0001, name, 0x0002);
+			else if (typing == TYPED)
+				aim_mtn_send(odata->sess, 0x0001, name, 0x0001);
 			else
 				aim_mtn_send(odata->sess, 0x0001, name, 0x0000);
 		}
--- a/src/protocols/yahoo/yahoo.c	Sun Oct 06 03:08:47 2002 +0000
+++ b/src/protocols/yahoo/yahoo.c	Sun Oct 06 05:01:50 2002 +0000
@@ -1176,7 +1176,7 @@
 	yahoo_packet_hash(pkt, 49, "TYPING");
 	yahoo_packet_hash(pkt, 1, gc->displayname);
 	yahoo_packet_hash(pkt, 14, " ");
-	yahoo_packet_hash(pkt, 13, typ ? "1" : "0");
+	yahoo_packet_hash(pkt, 13, typ == TYPING ? "1" : "0");
 	yahoo_packet_hash(pkt, 5, who);
 	yahoo_packet_hash(pkt, 1002, "1");
 
--- a/src/ui.h	Sun Oct 06 03:08:47 2002 +0000
+++ b/src/ui.h	Sun Oct 06 05:01:50 2002 +0000
@@ -148,6 +148,7 @@
 	gint unseen;
 	guint typing_timeout;
 	time_t type_again;
+	guint type_again_timeout;
 
 	/* stuff used just for chat */
         GList *in_room;