Index: protocols/jabber/iq.c
===================================================================
--- protocols/jabber/iq.c	(revision f920d9eb003541245e0fc32a381447cbba8fbea5)
+++ protocols/jabber/iq.c	(revision dfa41a405f0c80549f6dd5c0c111e3b62ce83b07)
@@ -45,9 +45,10 @@
 		struct jabber_cache_entry *entry;
 		
-		if( ( s = xt_find_attr( node, "id" ) ) == NULL )
-		{
-			/* Silently ignore it, without an ID we don't know
-			   how to handle the packet, but it doesn't have
-			   to be a serious problem. */
+		if( ( s = xt_find_attr( node, "id" ) ) == NULL ||
+		    strncmp( s, JABBER_CACHED_ID, strlen( JABBER_CACHED_ID ) ) != 0 )
+		{
+			/* Silently ignore it, without an ID (or an non-cache
+			   ID) we don't know how to handle the packet and we
+			   probably don't have to. */
 			return XT_HANDLED;
 		}
@@ -65,5 +66,5 @@
 		    !( s = xt_find_attr( c, "xmlns" ) ) )
 		{
-			serv_got_crap( gc, "WARNING: Received incomplete IQ-get packet" );
+			serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type );
 			return XT_HANDLED;
 		}
@@ -125,7 +126,24 @@
 	else if( strcmp( type, "set" ) == 0 )
 	{
-		xt_free_node( reply );
-		reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel" );
-		pack = 0;
+		if( !( c = xt_find_node( node->children, "query" ) ) ||
+		    !( s = xt_find_attr( c, "xmlns" ) ) )
+		{
+			serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type );
+			return XT_HANDLED;
+		}
+		
+		if( strcmp( s, "jabber:iq:roster" ) == 0 )
+		{
+			/* This is a roster push packet, probably. Here we
+			   should check if the packet is legitimate by
+			   checking if it really comes from the user's JID
+			   and, if so, process it. */
+		}
+		else
+		{
+			xt_free_node( reply );
+			reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel" );
+			pack = 0;
+		}
 	}
 	
Index: protocols/jabber/jabber.h
===================================================================
--- protocols/jabber/jabber.h	(revision f920d9eb003541245e0fc32a381447cbba8fbea5)
+++ protocols/jabber/jabber.h	(revision dfa41a405f0c80549f6dd5c0c111e3b62ce83b07)
@@ -102,8 +102,15 @@
 	
 	time_t last_act;
-	int flags;
+	jabber_buddy_flag_t flags;
 	
 	struct jabber_buddy *next;
 };
+
+/* Prefixes to use for packet IDs (mainly for IQ packets ATM). Usually the
+   first one should be used, but when storing a packet in the cache, a
+   "special" kind of ID is assigned to make it easier later to figure out
+   if we have to do call an event handler for the response packet. */
+#define JABBER_PACKET_ID "BeeP"
+#define JABBER_CACHED_ID "BeeC"
 
 /* iq.c */
Index: protocols/jabber/jabber_util.c
===================================================================
--- protocols/jabber/jabber_util.c	(revision f920d9eb003541245e0fc32a381447cbba8fbea5)
+++ protocols/jabber/jabber_util.c	(revision dfa41a405f0c80549f6dd5c0c111e3b62ce83b07)
@@ -24,5 +24,5 @@
 #include "jabber.h"
 
-static int next_id = 1;
+static unsigned int next_id = 1;
 
 char *set_eval_priority( set_t *set, char *value )
@@ -83,4 +83,15 @@
 		xt_add_attr( node, "to", to );
 	
+	/* IQ packets should always have an ID, so let's generate one. It
+	   might get overwritten by jabber_cache_add() if this packet has
+	   to be saved until we receive a response. Cached packets get
+	   slightly different IDs so we can recognize them. */
+	if( strcmp( name, "iq" ) == 0 )
+	{
+		char *id = g_strdup_printf( "%s%05x", JABBER_PACKET_ID, ( next_id++ ) & 0xfffff );
+		xt_add_attr( node, "id", id );
+		g_free( id );
+	}
+	
 	return node;
 }
@@ -116,11 +127,11 @@
 }
 
-/* Cache a node/epacket for later use. Mainly useful for IQ packets if you need
+/* Cache a node/packet for later use. Mainly useful for IQ packets if you need
    them when you receive the response. Use this BEFORE sending the packet so
-   it'll get an id= tag, and do NOT free() the packet after writing it! */
+   it'll get a new id= tag, and do NOT free() the packet after writing it! */
 void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func )
 {
 	struct jabber_data *jd = gc->proto_data;
-	char *id = g_strdup_printf( "BeeX%04x", next_id++ );
+	char *id = g_strdup_printf( "%s%05x", JABBER_CACHED_ID, ( next_id++ ) & 0xfffff );
 	struct jabber_cache_entry *entry = g_new0( struct jabber_cache_entry, 1 );
 	
