Index: protocols/bee.h
===================================================================
--- protocols/bee.h	(revision 9b1d2d6fa7edb911e3dbcd8785aaa797ebb20d0a)
+++ protocols/bee.h	(revision b78c4b9e3f3ec11b4ff560f579da764846793a00)
@@ -123,4 +123,5 @@
 	gboolean (*chat_topic)( bee_t *bee, struct groupchat *c, const char *new, bee_user_t *bu );
 	gboolean (*chat_name_hint)( bee_t *bee, struct groupchat *c, const char *name );
+	gboolean (*chat_invite)( bee_t *bee, bee_user_t *bu, const char *name, const char *msg );
 	
 	struct file_transfer* (*ft_in_start)( bee_t *bee, bee_user_t *bu, const char *file_name, size_t file_size );
@@ -176,4 +177,5 @@
 G_MODULE_EXPORT int bee_chat_msg( bee_t *bee, struct groupchat *c, const char *msg, int flags );
 G_MODULE_EXPORT struct groupchat *bee_chat_by_title( bee_t *bee, struct im_connection *ic, const char *title );
+G_MODULE_EXPORT void imcb_chat_invite( struct im_connection *ic, const char *name, const char *who, const char *msg );
 
 #endif /* __BEE_H__ */
Index: protocols/bee_chat.c
===================================================================
--- protocols/bee_chat.c	(revision 9b1d2d6fa7edb911e3dbcd8785aaa797ebb20d0a)
+++ protocols/bee_chat.c	(revision b78c4b9e3f3ec11b4ff560f579da764846793a00)
@@ -233,2 +233,10 @@
 	return NULL;
 }
+
+void imcb_chat_invite( struct im_connection *ic, const char *name, const char *who, const char *msg )
+{
+	bee_user_t *bu = bee_user_by_handle( ic->bee, ic, who );
+	
+	if( bu && ic->bee->ui->chat_invite )
+		ic->bee->ui->chat_invite( ic->bee, bu, name, msg );
+}
Index: protocols/jabber/message.c
===================================================================
--- protocols/jabber/message.c	(revision 9b1d2d6fa7edb911e3dbcd8785aaa797ebb20d0a)
+++ protocols/jabber/message.c	(revision b78c4b9e3f3ec11b4ff560f579da764846793a00)
@@ -31,5 +31,5 @@
 	struct xt_node *body = xt_find_node( node->children, "body" ), *c;
 	struct jabber_buddy *bud = NULL;
-	char *s;
+	char *s, *room = NULL, *reason = NULL;
 	
 	if( !from )
@@ -52,17 +52,17 @@
 		for( c = node->children; ( c = xt_find_node( c, "x" ) ); c = c->next )
 		{
-			char *ns = xt_find_attr( c, "xmlns" ), *room;
-			struct xt_node *inv, *reason;
+			char *ns = xt_find_attr( c, "xmlns" );
+			struct xt_node *inv;
 			
 			if( ns && strcmp( ns, XMLNS_MUC_USER ) == 0 &&
 			    ( inv = xt_find_node( c->children, "invite" ) ) )
 			{
+				/* This is an invitation. Set some vars which
+				   will be passed to imcb_chat_invite() below. */
 				room = from;
 				if( ( from = xt_find_attr( inv, "from" ) ) == NULL )
 					from = room;
-
-				g_string_append_printf( fullmsg, "<< \002BitlBee\002 - Invitation to chatroom %s >>\n", room );
-				if( ( reason = xt_find_node( inv->children, "reason" ) ) && reason->text_len > 0 )
-					g_string_append( fullmsg, reason->text );
+				if( ( inv = xt_find_node( inv->children, "reason" ) ) && inv->text_len > 0 )
+					reason = inv->text;
 			}
 		}
@@ -104,4 +104,6 @@
 			imcb_buddy_msg( ic, from, fullmsg->str,
 			                0, jabber_get_timestamp( node ) );
+		if( room )
+			imcb_chat_invite( ic, room, from, reason );
 		
 		g_string_free( fullmsg, TRUE );
Index: protocols/jabber/si.c
===================================================================
--- protocols/jabber/si.c	(revision 9b1d2d6fa7edb911e3dbcd8785aaa797ebb20d0a)
+++ protocols/jabber/si.c	(revision b78c4b9e3f3ec11b4ff560f579da764846793a00)
@@ -262,4 +262,8 @@
 				break;
 			}
+			else
+			{
+				c = c->next;
+			}
 
 		if ( !requestok )
@@ -373,5 +377,5 @@
 {
 	struct xt_node *c, *d;
-	char *ini_jid, *tgt_jid, *iq_id, *cmp;
+	char *ini_jid = NULL, *tgt_jid, *iq_id, *cmp;
 	GSList *tflist;
 	struct jabber_transfer *tf=NULL;
Index: protocols/twitter/twitter_lib.c
===================================================================
--- protocols/twitter/twitter_lib.c	(revision 9b1d2d6fa7edb911e3dbcd8785aaa797ebb20d0a)
+++ protocols/twitter/twitter_lib.c	(revision b78c4b9e3f3ec11b4ff560f579da764846793a00)
@@ -373,5 +373,5 @@
 static xt_status twitter_xt_get_status( struct xt_node *node, struct twitter_xml_status *txs )
 {
-	struct xt_node *child, *rt;
+	struct xt_node *child, *rt = NULL;
 	gboolean truncated = FALSE;
 
Index: protocols/yahoo/libyahoo2.c
===================================================================
--- protocols/yahoo/libyahoo2.c	(revision 9b1d2d6fa7edb911e3dbcd8785aaa797ebb20d0a)
+++ protocols/yahoo/libyahoo2.c	(revision b78c4b9e3f3ec11b4ff560f579da764846793a00)
@@ -2169,4 +2169,16 @@
 	yd->buddies = y_list_append(yd->buddies, bud);
 
+#if 0
+	/* BitlBee: This seems to be wrong in my experience. I think:
+	   status = 0: Success
+	   status = 2: Already on list
+	   status = 3: Doesn't exist
+	   status = 42: Invalid handle (possibly banned/reserved, I get it for
+	                handles like joe or jjjjjj)
+	   Haven't seen others yet. But whenever the add is successful, there
+	   will be a separate "went online" packet when the auth. request is
+	   accepted. Couldn't find any test account that doesn't require auth.
+	   unfortunately (if there is even such a thing?) */
+	   
 	/* A non-zero status (i've seen 2) seems to mean the buddy is already 
 	 * added and is online */
@@ -2176,4 +2188,11 @@
 		YAHOO_CALLBACK(ext_yahoo_status_changed) (yd->client_id, who,
 			YAHOO_STATUS_AVAILABLE, NULL, 0, 0, 0);
+	}
+#endif
+	/* BitlBee: Need ACK of added buddy, if it was successful. */
+	if (status == 0) {
+		YList *tmp = y_list_append(NULL, bud);
+		YAHOO_CALLBACK(ext_yahoo_got_buddies) (yd->client_id, tmp);
+		y_list_free(tmp);
 	}
 }
