Index: protocols/jabber/message.c
===================================================================
--- protocols/jabber/message.c	(revision 717e3bf045e5ebfb9b71e9260c8e573daefa7900)
+++ protocols/jabber/message.c	(revision 9624fdf0d6f170d8caa7948fb1b3a138b05e1d8c)
@@ -76,5 +76,5 @@
 		
 		if( fullmsg->len > 0 )
-			serv_got_im( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0, fullmsg->len );
+			imcb_buddy_msg( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0 );
 		
 		g_string_free( fullmsg, TRUE );
@@ -84,5 +84,5 @@
 		{
 			bud->flags |= JBFLAG_DOES_XEP85;
-			serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 1 );
+			imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_TYPING );
 		}
 		/* No need to send a "stopped typing" signal when there's a message. */
@@ -90,10 +90,10 @@
 		{
 			bud->flags |= JBFLAG_DOES_XEP85;
-			serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 0 );
+			imcb_buddy_typing( ic, bud ? bud->bare_jid : from, 0 );
 		}
 		else if( xt_find_node( node->children, "paused" ) )
 		{
 			bud->flags |= JBFLAG_DOES_XEP85;
-			serv_got_typing( ic, bud ? bud->bare_jid : from, 0, 2 );
+			imcb_buddy_typing( ic, bud ? bud->bare_jid : from, OPT_THINKING );
 		}
 		
Index: protocols/msn/sb.c
===================================================================
--- protocols/msn/sb.c	(revision 717e3bf045e5ebfb9b71e9260c8e573daefa7900)
+++ protocols/msn/sb.c	(revision 9624fdf0d6f170d8caa7948fb1b3a138b05e1d8c)
@@ -607,5 +607,5 @@
 			if( sb->who )
 			{
-				serv_got_im( ic, cmd[1], body, 0, 0, blen );
+				imcb_buddy_msg( ic, cmd[1], body, 0, 0 );
 			}
 			else if( sb->chat )
@@ -666,5 +666,5 @@
 			if( sb->who )
 			{
-				serv_got_im( ic, cmd[1], buf, 0, 0, strlen( buf ) );
+				imcb_buddy_msg( ic, cmd[1], buf, 0, 0 );
 			}
 			else if( sb->chat )
@@ -683,5 +683,5 @@
 			if( who )
 			{
-				serv_got_typing( ic, who, 5, 1 );
+				imcb_buddy_typing( ic, who, OPT_TYPING );
 				g_free( who );
 			}
Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision 717e3bf045e5ebfb9b71e9260c8e573daefa7900)
+++ protocols/nogaim.c	(revision 9624fdf0d6f170d8caa7948fb1b3a138b05e1d8c)
@@ -424,5 +424,5 @@
 	if( !u )
 		return( NULL );
-
+	
 	memset( b, 0, sizeof( b ) );
 	strncpy( b->name, handle, 80 );
@@ -575,9 +575,9 @@
 	{
 		irc_write( ic->irc, ":%s MODE %s %cv %s", ic->irc->myhost,
-		                                                ic->irc->channel, u->away?'-':'+', u->nick );
-	}
-}
-
-void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len )
+		                                          ic->irc->channel, u->away?'-':'+', u->nick );
+	}
+}
+
+void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at )
 {
 	irc_t *irc = ic->irc;
@@ -657,5 +657,5 @@
 }
 
-void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type )
+void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags )
 {
 	user_t *u;
@@ -664,15 +664,10 @@
 		return;
 	
-	if( ( u = user_findhandle( ic, handle ) ) ) {
-		/* If type is:
-		 * 0: user has stopped typing
-		 * 1: user is actively typing
-		 * 2: user has entered text, but is not actively typing
-		 */
-		if (type == 0 || type == 1 || type == 2) {
-			char buf[256]; 
-			g_snprintf(buf, 256, "\1TYPING %d\1", type); 
-			irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf );
-		}
+	if( ( u = user_findhandle( ic, handle ) ) )
+	{
+		char buf[256]; 
+		
+		g_snprintf( buf, 256, "\1TYPING %d\1", ( flags >> 8 ) & 3 );
+		irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf );
 	}
 }
Index: protocols/nogaim.h
===================================================================
--- protocols/nogaim.h	(revision 717e3bf045e5ebfb9b71e9260c8e573daefa7900)
+++ protocols/nogaim.h	(revision 9624fdf0d6f170d8caa7948fb1b3a138b05e1d8c)
@@ -50,5 +50,4 @@
 #define BUF_LEN MSG_LEN
 
-#define SELF_ALIAS_LEN 400
 #define BUDDY_ALIAS_MAXLEN 388   /* because MSN names can be 387 characters */
 
@@ -56,9 +55,12 @@
 #define GAIM_AWAY_CUSTOM "Custom"
 
-/* Sharing flags between buddies and connections. Or planning to, at least... */
+/* Sharing flags between all kinds of things. I just hope I won't hit any
+   limits before 32-bit machines become extinct. ;-) */
 #define OPT_LOGGED_IN   0x00000001
 #define OPT_LOGGING_OUT 0x00000002
 #define OPT_AWAY        0x00000004
 #define OPT_DOES_HTML   0x00000010
+#define OPT_TYPING      0x00000100
+#define OPT_THINKING    0x00000200
 
 /* ok. now the fun begins. first we create a connection structure */
@@ -136,5 +138,5 @@
 	void (* set_away)	(struct im_connection *, char *state, char *message);
 	void (* get_away)       (struct im_connection *, char *who);
-	int  (* send_typing)	(struct im_connection *, char *who, int typing);
+	int  (* send_typing)	(struct im_connection *, char *who, int flags);
 	
 	/* For now BitlBee doesn't really handle groups, just set it to NULL. */
@@ -171,6 +173,4 @@
 };
 
-#define UC_UNAVAILABLE  1
-
 /* im_api core stuff. */
 void nogaim_init();
@@ -208,6 +208,6 @@
 G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message );
 /* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle );
-G_MODULE_EXPORT void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len );
-G_MODULE_EXPORT void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type );
+G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at );
+G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags );
 
 /* Actions, or whatever. */
Index: protocols/oscar/oscar.c
===================================================================
--- protocols/oscar/oscar.c	(revision 717e3bf045e5ebfb9b71e9260c8e573daefa7900)
+++ protocols/oscar/oscar.c	(revision 9624fdf0d6f170d8caa7948fb1b3a138b05e1d8c)
@@ -1070,5 +1070,5 @@
 	
 	strip_linefeed(tmp);
-	serv_got_im(ic, userinfo->sn, tmp, flags, time(NULL), -1);
+	imcb_buddy_msg(ic, userinfo->sn, tmp, flags, 0);
 	g_free(tmp);
 	
@@ -1167,5 +1167,5 @@
 			message = g_strdup(args->msg);
 			strip_linefeed(message);
-			serv_got_im(ic, uin, message, 0, time(NULL), -1);
+			imcb_buddy_msg(ic, uin, message, 0, 0);
 			g_free(uin);
 			g_free(message);
@@ -1186,5 +1186,5 @@
 
 			strip_linefeed(message);
-			serv_got_im(ic, uin, message, 0, time(NULL), -1);
+			imcb_buddy_msg(ic, uin, message, 0, 0);
 			g_free(uin);
 			g_free(m);
@@ -1748,5 +1748,5 @@
 			g_snprintf(sender, sizeof(sender), "%u", msg->sender);
 			strip_linefeed(dialog_msg);
-			serv_got_im(ic, sender, dialog_msg, 0, t, -1);
+			imcb_buddy_msg(ic, sender, dialog_msg, 0, t);
 			g_free(dialog_msg);
 		} break;
@@ -1769,5 +1769,5 @@
 
 			strip_linefeed(dialog_msg);
-			serv_got_im(ic, sender, dialog_msg, 0, t, -1);
+			imcb_buddy_msg(ic, sender, dialog_msg, 0, t);
 			g_free(dialog_msg);
 			g_free(m);
@@ -2421,13 +2421,13 @@
 	if(type2 == 0x0002) {
 		/* User is typing */
-		serv_got_typing(ic, sn, 0, 1);
+		imcb_buddy_typing(ic, sn, OPT_TYPING);
 	} 
 	else if (type2 == 0x0001) {
 		/* User has typed something, but is not actively typing (stale) */
-		serv_got_typing(ic, sn, 0, 2);
+		imcb_buddy_typing(ic, sn, OPT_THINKING);
 	}
 	else {
 		/* User has stopped typing */
-		serv_got_typing(ic, sn, 0, 0);
+		imcb_buddy_typing(ic, sn, 0);
 	}        
 	
Index: protocols/yahoo/yahoo.c
===================================================================
--- protocols/yahoo/yahoo.c	(revision 717e3bf045e5ebfb9b71e9260c8e573daefa7900)
+++ protocols/yahoo/yahoo.c	(revision 9624fdf0d6f170d8caa7948fb1b3a138b05e1d8c)
@@ -618,5 +618,5 @@
 	char *m = byahoo_strip( msg );
 	
-	serv_got_im( ic, (char*) who, (char*) m, 0, 0, strlen( m ) );
+	imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 );
 	g_free( m );
 }
@@ -634,12 +634,9 @@
 {
 	struct im_connection *ic = byahoo_get_ic_by_id( id );
-	if (stat == 1) {
-		/* User is typing */
-		serv_got_typing( ic, (char*) who, 1, 1 );
-	}
-	else {
-		/* User stopped typing */
-		serv_got_typing( ic, (char*) who, 1, 0 );
-	}
+	
+	if( stat == 1 )
+		imcb_buddy_typing( ic, (char*) who, OPT_TYPING );
+	else
+		imcb_buddy_typing( ic, (char*) who, 0 );
 }
 
