diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-09-20 22:09:19 +0200 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-09-20 22:09:19 +0200 | 
| commit | 70f6aab8f4b6a1bbd9991e800dde91a02cc363f0 (patch) | |
| tree | 5585d92a6bb79d64e38e9c74c29cb33e25c04fee | |
| parent | 21167d2d14c333d67445546bb69dd52dd295287d (diff) | |
It now requests a roster when logged in, no parsing for it yet.
| -rw-r--r-- | protocols/jabber/iq.c | 54 | ||||
| -rw-r--r-- | protocols/jabber/jabber.c | 2 | ||||
| -rw-r--r-- | protocols/jabber/jabber.h | 1 | 
3 files changed, 47 insertions, 10 deletions
| diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index 58e3f33c..0f1b1036 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -23,26 +23,23 @@  #include "jabber.h" -/* -<iq xmlns="jabber:client" id="BeeX00000001" type="result"><query -xmlns="jabber:iq:auth"><username>wilmer</username><resource/><password/><digest/> -<sequence>499</sequence><token>450D1FFD</token></query></iq> -*/ -  xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  {  	struct gaim_connection *gc = data;  	struct jabber_data *jd = gc->proto_data;  	struct xt_node *query, *reply = NULL; -	char *s; +	char *s, *type, *xmlns;  	int st;  	query = xt_find_node( node->children, "query" ); +	type = xt_find_attr( node, "type" ); -	if( !query ) +	if( !type )  		return XT_HANDLED;	/* Ignore it for now, don't know what's best... */ -	if( ( s = xt_find_attr( query, "xmlns" ) ) && strcmp( s, "jabber:iq:auth" ) == 0 ) +	xmlns = xt_find_attr( query, "xmlns" ); +	 +	if( strcmp( type, "result" ) == 0 && xmlns && strcmp( xmlns, "jabber:iq:auth" ) == 0 )  	{  		/* Time to authenticate ourselves! */  		reply = xt_new_node( "query", NULL, NULL ); @@ -78,7 +75,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  		{  			xt_free_node( reply ); -			hide_login_progress_error( gc, "Can't find suitable authentication method" ); +			hide_login_progress( gc, "Can't find suitable authentication method" );  			signoff( gc );  			return XT_ABORT;  		} @@ -89,6 +86,26 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  		return st ? XT_HANDLED : XT_ABORT;  	} +	else if( strcmp( type, "result" ) == 0 ) +	{ +		/* If we weren't authenticated yet, let's assume we are now. +		   There are cleaner ways to do this, probably, but well.. */ +		if( !( jd->flags & JFLAG_AUTHENTICATED ) ) +		{ +			jd->flags |= JFLAG_AUTHENTICATED; +			if( !jabber_get_roster( gc ) ) +				return XT_ABORT; +		} +	} +	else if( strcmp( type, "error" ) == 0 ) +	{ +		if( !( jd->flags & JFLAG_AUTHENTICATED ) ) +		{ +			hide_login_progress( gc, "Authentication failure" ); +			signoff( gc ); +			return XT_ABORT; +		} +	}  	return XT_HANDLED;  } @@ -108,3 +125,20 @@ int jabber_start_auth( struct gaim_connection *gc )  	xt_free_node( node );  	return st;  } + +int jabber_get_roster( struct gaim_connection *gc ) +{ +	struct xt_node *node; +	int st; +	 +	set_login_progress( gc, 1, "Authenticated, requesting buddy list" ); +	 +	node = xt_new_node( "query", NULL, NULL ); +	xt_add_attr( node, "xmlns", "jabber:iq:roster" ); +	node = jabber_make_packet( "iq", "get", NULL, node ); +	 +	st = jabber_write_packet( gc, node ); +	 +	xt_free_node( node ); +	return st; +} diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 9732d6eb..cc7bac3d 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -100,6 +100,8 @@ static void jabber_close( struct gaim_connection *gc )  	if( jd->fd >= 0 )  		closesocket( jd->fd ); +	xt_free( jd->xt ); +	  	g_free( jd->username );  	g_free( jd );  } diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index d812ec54..fcf8bbd3 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -38,6 +38,7 @@ typedef enum  /* iq.c */  xt_status jabber_pkt_iq( struct xt_node *node, gpointer data );  int jabber_start_auth( struct gaim_connection *gc ); +int jabber_get_roster( struct gaim_connection *gc );  xt_status jabber_pkt_message( struct xt_node *node, gpointer data );  xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ); | 
