Index: protocols/jabber/Makefile
===================================================================
--- protocols/jabber/Makefile	(revision 8f243add8b64f9936c49bbeafac77aa9961cf264)
+++ protocols/jabber/Makefile	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
@@ -10,5 +10,5 @@
 
 # [SH] Program variables
-objects = jabber.o xmltree.o
+objects = iq.o jabber.o jabber_util.o message.o presence.o xmltree.o
 
 CFLAGS += -Wall
Index: protocols/jabber/iq.c
===================================================================
--- protocols/jabber/iq.c	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
+++ protocols/jabber/iq.c	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
@@ -0,0 +1,35 @@
+/***************************************************************************\
+*                                                                           *
+*  BitlBee - An IRC to IM gateway                                           *
+*  Jabber module - IQ packets                                               *
+*                                                                           *
+*  Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net>                   *
+*                                                                           *
+*  This program is free software; you can redistribute it and/or modify     *
+*  it under the terms of the GNU General Public License as published by     *
+*  the Free Software Foundation; either version 2 of the License, or        *
+*  (at your option) any later version.                                      *
+*                                                                           *
+*  This program is distributed in the hope that it will be useful,          *
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
+*  GNU General Public License for more details.                             *
+*                                                                           *
+*  You should have received a copy of the GNU General Public License along  *
+*  with this program; if not, write to the Free Software Foundation, Inc.,  *
+*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.              *
+*                                                                           *
+\***************************************************************************/
+
+#include "jabber.h"
+
+xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
+{
+	char *from = xt_find_attr( node, "from" );
+	
+	printf( "Received IQ from %s:\n", from );
+	xt_print( node );
+	
+	return XT_HANDLED;
+}
+
Index: protocols/jabber/jabber.c
===================================================================
--- protocols/jabber/jabber.c	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
+++ protocols/jabber/jabber.c	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
@@ -0,0 +1,147 @@
+/***************************************************************************\
+*                                                                           *
+*  BitlBee - An IRC to IM gateway                                           *
+*  Jabber module - Main file                                                *
+*                                                                           *
+*  Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net>                   *
+*                                                                           *
+*  This program is free software; you can redistribute it and/or modify     *
+*  it under the terms of the GNU General Public License as published by     *
+*  the Free Software Foundation; either version 2 of the License, or        *
+*  (at your option) any later version.                                      *
+*                                                                           *
+*  This program is distributed in the hope that it will be useful,          *
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
+*  GNU General Public License for more details.                             *
+*                                                                           *
+*  You should have received a copy of the GNU General Public License along  *
+*  with this program; if not, write to the Free Software Foundation, Inc.,  *
+*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.              *
+*                                                                           *
+\***************************************************************************/
+
+#include <glib.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <stdio.h>
+
+#include "xmltree.h"
+#include "bitlbee.h"
+#include "jabber.h"
+
+static void jabber_acc_init( account_t *acc )
+{
+	set_t *s;
+	
+	s = set_add( &acc->set, "port", "5222", set_eval_int, acc );
+	s->flags |= ACC_SET_OFFLINE_ONLY;
+	
+	s = set_add( &acc->set, "priority", "0", set_eval_resprio, acc );
+	
+	s = set_add( &acc->set, "resource", "BitlBee", set_eval_resprio, acc );
+	
+	s = set_add( &acc->set, "server", NULL, set_eval_account, acc );
+	s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY;
+	
+	s = set_add( &acc->set, "ssl", "false", set_eval_bool, acc );
+	s->flags |= ACC_SET_OFFLINE_ONLY;
+	
+	s = set_add( &acc->set, "tls", "try", set_eval_tls, acc );
+	s->flags |= ACC_SET_OFFLINE_ONLY;
+}
+
+static void jabber_login( account_t *acc )
+{
+}
+
+static void jabber_close( struct gaim_connection *gc )
+{
+}
+
+static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )
+{
+}
+
+void jabber_init()
+{
+	struct prpl *ret = g_new0(struct prpl, 1);
+	
+	ret->name = "jabber";
+	ret->login = jabber_login;
+	ret->acc_init = jabber_acc_init;
+	ret->close = jabber_close;
+	ret->send_im = jabber_send_im;
+//	ret->away_states = jabber_away_states;
+//	ret->get_status_string = jabber_get_status_string;
+//	ret->set_away = jabber_set_away;
+//	ret->set_info = jabber_set_info;
+//	ret->get_info = jabber_get_info;
+//	ret->add_buddy = jabber_add_buddy;
+//	ret->remove_buddy = jabber_remove_buddy;
+//	ret->chat_send = jabber_chat_send;
+//	ret->chat_invite = jabber_chat_invite;
+//	ret->chat_leave = jabber_chat_leave;
+//	ret->chat_open = jabber_chat_open;
+//	ret->keepalive = jabber_keepalive;
+//	ret->add_permit = jabber_add_permit;
+//	ret->rem_permit = jabber_rem_permit;
+//	ret->add_deny = jabber_add_deny;
+//	ret->rem_deny = jabber_rem_deny;
+//	ret->send_typing = jabber_send_typing;
+	ret->handle_cmp = g_strcasecmp;
+
+	register_protocol(ret);
+}
+
+static xt_status jabber_end_of_stream( struct xt_node *node, gpointer data )
+{
+	return XT_ABORT;
+}
+
+static xt_status jabber_pkt_misc( struct xt_node *node, gpointer data )
+{
+	printf( "Received unknown packet:\n" );
+	xt_print( node );
+	
+	return XT_HANDLED;
+}
+
+static const struct xt_handler_entry jabber_handlers[] = {
+	{ "stream:stream",      "<root>",               jabber_end_of_stream },
+	{ "iq",                 "stream:stream",        jabber_pkt_iq },
+	{ "message",            "stream:stream",        jabber_pkt_message },
+	{ "presence",           "stream:stream",        jabber_pkt_presence },
+	{ NULL,                 "stream:stream",        jabber_pkt_misc },
+	{ NULL,                 NULL,                   NULL }
+};
+
+#if 0
+int main( int argc, char *argv[] )
+{
+	struct xt_parser *xt = xt_new( NULL );
+	struct xt_node *msg;
+	int i;
+	char buf[512];
+	
+	msg = xt_new_node( "message", NULL, xt_new_node( "body", "blaataap-test", NULL ) );
+	xt_add_child( msg, xt_new_node( "html", NULL, xt_new_node( "body", "<b>blaataap in html</b>", NULL ) ) );
+	xt_add_attr( msg, "xmlns", "jabber:client" );
+	xt_add_attr( xt_find_node( msg->children, "html" ), "xmlns", "html rotte zooi" );
+	printf( "%s\n", xt_to_string( msg ) );
+	
+	while( ( i = read( 0, buf, 512 ) ) > 0 )
+	{
+		if( xt_feed( xt, buf, i ) < 1 )
+			break;
+	}
+	xt->handlers = jabber_handlers;
+	xt_handle( xt, NULL );
+	
+	xt_cleanup( xt, NULL );
+	printf( "%d\n", xt->root );
+	
+	xt_free( xt );
+}
+#endif
Index: protocols/jabber/jabber.h
===================================================================
--- protocols/jabber/jabber.h	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
+++ protocols/jabber/jabber.h	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
@@ -0,0 +1,39 @@
+/***************************************************************************\
+*                                                                           *
+*  BitlBee - An IRC to IM gateway                                           *
+*  Jabber module - Main file                                                *
+*                                                                           *
+*  Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net>                   *
+*                                                                           *
+*  This program is free software; you can redistribute it and/or modify     *
+*  it under the terms of the GNU General Public License as published by     *
+*  the Free Software Foundation; either version 2 of the License, or        *
+*  (at your option) any later version.                                      *
+*                                                                           *
+*  This program is distributed in the hope that it will be useful,          *
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
+*  GNU General Public License for more details.                             *
+*                                                                           *
+*  You should have received a copy of the GNU General Public License along  *
+*  with this program; if not, write to the Free Software Foundation, Inc.,  *
+*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.              *
+*                                                                           *
+\***************************************************************************/
+
+#ifndef _JABBER_H
+#define _JABBER_H
+
+#include <glib.h>
+
+#include "xmltree.h"
+#include "bitlbee.h"
+
+xt_status jabber_pkt_iq( struct xt_node *node, gpointer data );
+xt_status jabber_pkt_message( struct xt_node *node, gpointer data );
+xt_status jabber_pkt_presence( struct xt_node *node, gpointer data );
+
+char *set_eval_resprio( set_t *set, char *value );
+char *set_eval_tls( set_t *set, char *value );
+
+#endif
Index: protocols/jabber/jabber_util.c
===================================================================
--- protocols/jabber/jabber_util.c	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
+++ protocols/jabber/jabber_util.c	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
@@ -0,0 +1,48 @@
+/***************************************************************************\
+*                                                                           *
+*  BitlBee - An IRC to IM gateway                                           *
+*  Jabber module - Main file                                                *
+*                                                                           *
+*  Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net>                   *
+*                                                                           *
+*  This program is free software; you can redistribute it and/or modify     *
+*  it under the terms of the GNU General Public License as published by     *
+*  the Free Software Foundation; either version 2 of the License, or        *
+*  (at your option) any later version.                                      *
+*                                                                           *
+*  This program is distributed in the hope that it will be useful,          *
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
+*  GNU General Public License for more details.                             *
+*                                                                           *
+*  You should have received a copy of the GNU General Public License along  *
+*  with this program; if not, write to the Free Software Foundation, Inc.,  *
+*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.              *
+*                                                                           *
+\***************************************************************************/
+
+#include "jabber.h"
+
+char *set_eval_resprio( set_t *set, char *value )
+{
+	account_t *acc = set->data;
+	
+	/* Only run this stuff if the account is online ATM. */
+	if( acc->gc )
+	{
+		/* ... */
+	}
+	
+	if( g_strcasecmp( set->key, "priority" ) == 0 )
+		return set_eval_int( set, value );
+	else
+		return value;
+}
+
+char *set_eval_tls( set_t *set, char *value )
+{
+	if( g_strcasecmp( value, "try" ) == 0 )
+		return value;
+	else
+		return set_eval_bool( set, value );
+}
Index: protocols/jabber/message.c
===================================================================
--- protocols/jabber/message.c	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
+++ protocols/jabber/message.c	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
@@ -0,0 +1,36 @@
+/***************************************************************************\
+*                                                                           *
+*  BitlBee - An IRC to IM gateway                                           *
+*  Jabber module - Main file                                                *
+*                                                                           *
+*  Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net>                   *
+*                                                                           *
+*  This program is free software; you can redistribute it and/or modify     *
+*  it under the terms of the GNU General Public License as published by     *
+*  the Free Software Foundation; either version 2 of the License, or        *
+*  (at your option) any later version.                                      *
+*                                                                           *
+*  This program is distributed in the hope that it will be useful,          *
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
+*  GNU General Public License for more details.                             *
+*                                                                           *
+*  You should have received a copy of the GNU General Public License along  *
+*  with this program; if not, write to the Free Software Foundation, Inc.,  *
+*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.              *
+*                                                                           *
+\***************************************************************************/
+
+#include "jabber.h"
+
+xt_status jabber_pkt_message( struct xt_node *node, gpointer data )
+{
+	char *from = xt_find_attr( node, "from" );
+	struct xt_node *msg = xt_find_node( node->children, "body" );
+	
+	printf( "Received MSG from %s: %s\n", from, msg ? msg->text : "<null>" );
+	xt_print( node );
+	
+	return XT_HANDLED;
+}
+
Index: protocols/jabber/presence.c
===================================================================
--- protocols/jabber/presence.c	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
+++ protocols/jabber/presence.c	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
@@ -0,0 +1,35 @@
+/***************************************************************************\
+*                                                                           *
+*  BitlBee - An IRC to IM gateway                                           *
+*  Jabber module - Main file                                                *
+*                                                                           *
+*  Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net>                   *
+*                                                                           *
+*  This program is free software; you can redistribute it and/or modify     *
+*  it under the terms of the GNU General Public License as published by     *
+*  the Free Software Foundation; either version 2 of the License, or        *
+*  (at your option) any later version.                                      *
+*                                                                           *
+*  This program is distributed in the hope that it will be useful,          *
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
+*  GNU General Public License for more details.                             *
+*                                                                           *
+*  You should have received a copy of the GNU General Public License along  *
+*  with this program; if not, write to the Free Software Foundation, Inc.,  *
+*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.              *
+*                                                                           *
+\***************************************************************************/
+
+#include "jabber.h"
+
+xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
+{
+	char *from = xt_find_attr( node, "from" );
+	
+	printf( "Received PRES from %s:\n", from );
+	xt_print( node );
+	
+	return XT_HANDLED;
+}
+
Index: protocols/jabber/xmltree.h
===================================================================
--- protocols/jabber/xmltree.h	(revision 8f243add8b64f9936c49bbeafac77aa9961cf264)
+++ protocols/jabber/xmltree.h	(revision f06894d8f55b50b632c1d81ad878f8581273ba66)
@@ -21,4 +21,7 @@
 *                                                                           *
 ****************************************************************************/
+
+#ifndef _XMLTREE_H
+#define _XMLTREE_H
 
 typedef enum
@@ -89,2 +92,4 @@
 void xt_add_child( struct xt_node *parent, struct xt_node *child );
 void xt_add_attr( struct xt_node *node, char *key, char *value );
+
+#endif
