Index: protocols/jabber/presence.c
===================================================================
--- protocols/jabber/presence.c	(revision 8c1eb8025f493ce22b4cc58da1ecfd4afa416816)
+++ protocols/jabber/presence.c	(revision 434627083613f016d432462fce73f728dd77172e)
@@ -29,7 +29,7 @@
 	char *from = xt_find_attr( node, "from" );
 	char *type = xt_find_attr( node, "type" );	/* NULL should mean the person is online. */
-	struct xt_node *c, *cap;
-	struct jabber_buddy *bud, *send_presence = NULL;
-	int is_chat = 0;
+	struct xt_node *c;
+	struct jabber_buddy *bud;
+	int is_chat = 0, is_away = 0;
 	char *s;
 	
@@ -63,4 +63,6 @@
 		{
 			bud->away_state = (void*) jabber_away_state_by_code( c->text );
+			if( strcmp( c->text, "chat" ) != 0 )
+				is_away = OPT_AWAY;
 		}
 		else
@@ -77,28 +79,10 @@
 			bud->priority = 0;
 		
-		if( bud && ( cap = xt_find_node( node->children, "c" ) ) &&
-		    ( s = xt_find_attr( cap, "xmlns" ) ) && strcmp( s, XMLNS_CAPS ) == 0 )
-		{
-			/* This <presence> stanza includes an XEP-0115
-			   capabilities part. Not too interesting, but we can
-			   see if it has an ext= attribute. */
-			s = xt_find_attr( cap, "ext" );
-			if( s && ( strstr( s, "cstates" ) || strstr( s, "chatstate" ) ) )
-				bud->flags |= JBFLAG_DOES_XEP85;
-			
-			/* This field can contain more information like xhtml
-			   support, but we don't support that ourselves.
-			   Officially the ext= tag was deprecated, but enough
-			   clients do send it.
-			   
-			   (I'm aware that this is not the right way to use
-			   this field.) See for an explanation of ext=:
-			   http://www.xmpp.org/extensions/attic/xep-0115-1.3.html*/
-		}
-		
 		if( is_chat )
 			jabber_chat_pkt_presence( ic, bud, node );
-		else
-			send_presence = jabber_buddy_by_jid( ic, bud->bare_jid, 0 );
+		else if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) )
+			imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
+			                   ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
+			                   bud->away_message );
 	}
 	else if( strcmp( type, "unavailable" ) == 0 )
@@ -135,5 +119,15 @@
 			/* If another resource is still available, send its presence
 			   information. */
-			if( ( send_presence = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL )
+			if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) )
+			{
+				if( bud->away_state && ( *bud->away_state->code == 0 ||
+				    strcmp( bud->away_state->code, "chat" ) == 0 ) )
+					is_away = OPT_AWAY;
+				
+				imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away,
+				                   ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL,
+				                   bud->away_message );
+			}
+			else
 			{
 				/* Otherwise, count him/her as offline now. */
@@ -183,18 +177,4 @@
 		} */
 	}
-
-	if( send_presence )
-	{
-		int is_away = 0;
-
-		if( send_presence->away_state && !( *send_presence->away_state->code == 0 ||
-		    strcmp( send_presence->away_state->code, "chat" ) == 0 ) )
-			is_away = OPT_AWAY;
-
-		imcb_buddy_status( ic, send_presence->bare_jid, OPT_LOGGED_IN | is_away,
-		                   ( is_away && send_presence->away_state ) ?
-		                   send_presence->away_state->full_name : NULL,
-		                   send_presence->away_message );
-	}
 	
 	return XT_HANDLED;
@@ -206,5 +186,5 @@
 {
 	struct jabber_data *jd = ic->proto_data;
-	struct xt_node *node, *cap;
+	struct xt_node *node;
 	char *show = jd->away_state->code;
 	char *status = jd->away_message;
@@ -219,14 +199,4 @@
 		xt_add_child( node, xt_new_node( "status", status, NULL ) );
 	
-	/* This makes the packet slightly bigger, but clients interested in
-	   capabilities can now cache the discovery info. This reduces the
-	   usual post-login iq-flood. See XEP-0115. At least libpurple and
-	   Trillian seem to do this right. */
-	cap = xt_new_node( "c", NULL, NULL );
-	xt_add_attr( cap, "xmlns", XMLNS_CAPS );
-	xt_add_attr( cap, "node", "http://bitlbee.org/xmpp/caps" );
-	xt_add_attr( cap, "ver", BITLBEE_VERSION ); /* The XEP wants this hashed, but nobody's doing that. */
-	xt_add_child( node, cap );
-	
 	st = jabber_write_packet( ic, node );
 	
