diff options
Diffstat (limited to 'protocols/jabber')
| -rw-r--r-- | protocols/jabber/io.c | 10 | ||||
| -rw-r--r-- | protocols/jabber/iq.c | 26 | ||||
| -rw-r--r-- | protocols/jabber/jabber.c | 4 | ||||
| -rw-r--r-- | protocols/jabber/jabber.h | 17 | ||||
| -rw-r--r-- | protocols/jabber/jabber_util.c | 2 | ||||
| -rw-r--r-- | protocols/jabber/sasl.c | 10 | 
6 files changed, 42 insertions, 27 deletions
| diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c index bc08a977..1039bb87 100644 --- a/protocols/jabber/io.c +++ b/protocols/jabber/io.c @@ -306,7 +306,7 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )  		if( ( trytls || set_getbool( &gc->acc->set, "tls" ) ) )  		{  			reply = xt_new_node( "starttls", NULL, NULL ); -			xt_add_attr( reply, "xmlns", "urn:ietf:params:xml:ns:xmpp-tls" ); +			xt_add_attr( reply, "xmlns", XMLNS_TLS );  			if( !jabber_write_packet( gc, reply ) )  			{  				xt_free_node( reply ); @@ -354,7 +354,7 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )  	if( ( c = xt_find_node( node->children, "bind" ) ) )  	{  		reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &gc->acc->set, "resource" ), NULL ) ); -		xt_add_attr( reply, "xmlns", "urn:ietf:params:xml:ns:xmpp-bind" ); +		xt_add_attr( reply, "xmlns", XMLNS_BIND );  		reply = jabber_make_packet( "iq", "set", NULL, reply );  		jabber_cache_add( gc, reply, jabber_pkt_bind_sess ); @@ -367,7 +367,7 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )  	if( ( c = xt_find_node( node->children, "session" ) ) )  	{  		reply = xt_new_node( "session", NULL, NULL ); -		xt_add_attr( reply, "xmlns", "urn:ietf:params:xml:ns:xmpp-session" ); +		xt_add_attr( reply, "xmlns", XMLNS_SESSION );  		reply = jabber_make_packet( "iq", "set", NULL, reply );  		jabber_cache_add( gc, reply, jabber_pkt_bind_sess ); @@ -399,7 +399,7 @@ static xt_status jabber_pkt_proceed_tls( struct xt_node *node, gpointer data )  	/* Just ignore it when it doesn't seem to be TLS-related (is that at  	   all possible??). */ -	if( !xmlns || strcmp( xmlns, "urn:ietf:params:xml:ns:xmpp-tls" ) != 0 ) +	if( !xmlns || strcmp( xmlns, XMLNS_TLS ) != 0 )  		return XT_HANDLED;  	/* We don't want event handlers to touch our TLS session while it's @@ -432,7 +432,7 @@ static xt_status jabber_pkt_stream_error( struct xt_node *node, gpointer data )  	for( c = node->children; c; c = c->next )  	{  		if( !( s = xt_find_attr( c, "xmlns" ) ) || -		    strcmp( s, "urn:ietf:params:xml:ns:xmpp-streams" ) != 0 ) +		    strcmp( s, XMLNS_STREAM_ERROR ) != 0 )  			continue;  		if( strcmp( c->name, "text" ) != 0 ) diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index c5263572..c46a7c52 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -76,13 +76,13 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  		xt_add_attr( reply, "xmlns", s );  		/* Of course this is a very essential query to support. ;-) */ -		if( strcmp( s, "jabber:iq:version" ) == 0 ) +		if( strcmp( s, XMLNS_VERSION ) == 0 )  		{  			xt_add_child( reply, xt_new_node( "name", "BitlBee", NULL ) );  			xt_add_child( reply, xt_new_node( "version", BITLBEE_VERSION, NULL ) );  			xt_add_child( reply, xt_new_node( "os", ARCH, NULL ) );  		} -		else if( strcmp( s, "jabber:iq:time" ) == 0 ) +		else if( strcmp( s, XMLNS_TIME ) == 0 )  		{  			time_t time_ep;  			char buf[1024]; @@ -96,7 +96,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  			strftime( buf, sizeof( buf ) - 1, "%Z", localtime( &time_ep ) );  			xt_add_child( reply, xt_new_node( "tz", buf, NULL ) );  		} -		else if( strcmp( s, "http://jabber.org/protocol/disco#info" ) == 0 ) +		else if( strcmp( s, XMLNS_DISCOVER ) == 0 )  		{  			c = xt_new_node( "identity", NULL, NULL );  			xt_add_attr( c, "category", "client" ); @@ -105,15 +105,15 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  			xt_add_child( reply, c );  			c = xt_new_node( "feature", NULL, NULL ); -			xt_add_attr( c, "var", "jabber:iq:version" ); +			xt_add_attr( c, "var", XMLNS_VERSION );  			xt_add_child( reply, c );  			c = xt_new_node( "feature", NULL, NULL ); -			xt_add_attr( c, "var", "jabber:iq:time" ); +			xt_add_attr( c, "var", XMLNS_TIME );  			xt_add_child( reply, c );  			c = xt_new_node( "feature", NULL, NULL ); -			xt_add_attr( c, "var", "http://jabber.org/protocol/chatstates" ); +			xt_add_attr( c, "var", XMLNS_CHATSTATES );  			xt_add_child( reply, c );  			/* Later this can be useful to announce things like @@ -135,7 +135,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  			return XT_HANDLED;  		} -		if( strcmp( s, "jabber:iq:roster" ) == 0 ) +		if( strcmp( s, XMLNS_ROSTER ) == 0 )  		{  			int bare_len = strlen( gc->acc->user ); @@ -197,7 +197,7 @@ int jabber_init_iq_auth( struct gaim_connection *gc )  	int st;  	node = xt_new_node( "query", NULL, xt_new_node( "username", jd->username, NULL ) ); -	xt_add_attr( node, "xmlns", "jabber:iq:auth" ); +	xt_add_attr( node, "xmlns", XMLNS_AUTH );  	node = jabber_make_packet( "iq", "get", NULL, node );  	jabber_cache_add( gc, node, jabber_do_iq_auth ); @@ -217,7 +217,7 @@ static xt_status jabber_do_iq_auth( struct gaim_connection *gc, struct xt_node *  	/* Time to authenticate ourselves! */  	reply = xt_new_node( "query", NULL, NULL ); -	xt_add_attr( reply, "xmlns", "jabber:iq:auth" ); +	xt_add_attr( reply, "xmlns", XMLNS_AUTH );  	xt_add_child( reply, xt_new_node( "username", jd->username, NULL ) );  	xt_add_child( reply, xt_new_node( "resource", set_getstr( &gc->acc->set, "resource" ), NULL ) ); @@ -321,7 +321,7 @@ int jabber_get_roster( struct gaim_connection *gc )  	set_login_progress( gc, 1, "Authenticated, requesting buddy list" );  	node = xt_new_node( "query", NULL, NULL ); -	xt_add_attr( node, "xmlns", "jabber:iq:roster" ); +	xt_add_attr( node, "xmlns", XMLNS_ROSTER );  	node = jabber_make_packet( "iq", "get", NULL, node );  	jabber_cache_add( gc, node, jabber_parse_roster ); @@ -390,7 +390,7 @@ int jabber_get_vcard( struct gaim_connection *gc, char *bare_jid )  		return 1;	/* This was an error, but return 0 should only be done if the connection died... */  	node = xt_new_node( "vCard", NULL, NULL ); -	xt_add_attr( node, "xmlns", "vcard-temp" ); +	xt_add_attr( node, "xmlns", XMLNS_VCARD );  	node = jabber_make_packet( "iq", "get", bare_jid, node );  	jabber_cache_add( gc, node, jabber_iq_display_vcard ); @@ -535,7 +535,7 @@ int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name )  	/* And pack it into a roster-add packet */  	node = xt_new_node( "query", NULL, node ); -	xt_add_attr( node, "xmlns", "jabber:iq:roster" ); +	xt_add_attr( node, "xmlns", XMLNS_ROSTER );  	node = jabber_make_packet( "iq", "set", NULL, node );  	st = jabber_write_packet( gc, node ); @@ -556,7 +556,7 @@ int jabber_remove_from_roster( struct gaim_connection *gc, char *handle )  	/* And pack it into a roster-add packet */  	node = xt_new_node( "query", NULL, node ); -	xt_add_attr( node, "xmlns", "jabber:iq:roster" ); +	xt_add_attr( node, "xmlns", XMLNS_ROSTER );  	node = jabber_make_packet( "iq", "set", NULL, node );  	st = jabber_write_packet( gc, node ); diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 855a6a3b..2ef76444 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -234,7 +234,7 @@ static int jabber_send_im( struct gaim_connection *gc, char *who, char *message,  		   tag to tell that the user stopped typing (well, that's what  		   we guess when s/he pressed Enter...). */  		act = xt_new_node( "active", NULL, NULL ); -		xt_add_attr( act, "xmlns", "http://jabber.org/protocol/chatstates" ); +		xt_add_attr( act, "xmlns", XMLNS_CHATSTATES );  		xt_add_child( node, act );  		/* Just make sure we do this only once. */ @@ -352,7 +352,7 @@ static int jabber_send_typing( struct gaim_connection *gc, char *who, int typing  			type = "composing";  		node = xt_new_node( type, NULL, NULL ); -		xt_add_attr( node, "xmlns", "http://jabber.org/protocol/chatstates" ); +		xt_add_attr( node, "xmlns", XMLNS_CHATSTATES );  		node = jabber_make_packet( "message", "chat", bud->full_jid, node );  		st = jabber_write_packet( gc, node ); diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 4bccd5ed..da9bfd52 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -113,6 +113,23 @@ struct jabber_buddy  #define JABBER_PACKET_ID "BeeP"  #define JABBER_CACHED_ID "BeeC" +/* RFC 392[01] stuff */ +#define XMLNS_TLS          "urn:ietf:params:xml:ns:xmpp-tls" +#define XMLNS_SASL         "urn:ietf:params:xml:ns:xmpp-sasl" +#define XMLNS_BIND         "urn:ietf:params:xml:ns:xmpp-bind" +#define XMLNS_SESSION      "urn:ietf:params:xml:ns:xmpp-session" +#define XMLNS_STANZA_ERROR "urn:ietf:params:xml:ns:xmpp-stanzas" +#define XMLNS_STREAM_ERROR "urn:ietf:params:xml:ns:xmpp-streams" +#define XMLNS_ROSTER       "jabber:iq:roster" + +/* Some supported extensions/legacy stuff */ +#define XMLNS_AUTH         "jabber:iq:auth"                     /* XEP-0078 */ +#define XMLNS_VERSION      "jabber:iq:version"                  /* XEP-0092 */ +#define XMLNS_TIME         "jabber:iq:time"                     /* XEP-0090 */ +#define XMLNS_VCARD        "vcard-temp"                         /* XEP-0054 */ +#define XMLNS_CHATSTATES   "http://jabber.org/protocol/chatstates"  /* 0085 */ +#define XMLNS_DISCOVER     "http://jabber.org/protocol/disco#info"  /* 0030 */ +  /* iq.c */  xt_status jabber_pkt_iq( struct xt_node *node, gpointer data );  int jabber_init_iq_auth( struct gaim_connection *gc ); diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 3f189300..07d7a2fd 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -103,7 +103,7 @@ struct xt_node *jabber_make_error_packet( struct xt_node *orig, char *err_cond,  	/* Create the "defined-condition" tag. */  	c = xt_new_node( err_cond, NULL, NULL ); -	xt_add_attr( c, "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas" ); +	xt_add_attr( c, "xmlns", XMLNS_STANZA_ERROR );  	/* Put it in an <error> tag. */  	c = xt_new_node( "error", NULL, c ); diff --git a/protocols/jabber/sasl.c b/protocols/jabber/sasl.c index a9676338..68953ced 100644 --- a/protocols/jabber/sasl.c +++ b/protocols/jabber/sasl.c @@ -24,8 +24,6 @@  #include "jabber.h"  #include "base64.h" -#define SASL_NS "urn:ietf:params:xml:ns:xmpp-sasl" -  xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )  {  	struct gaim_connection *gc = data; @@ -44,7 +42,7 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )  	}  	s = xt_find_attr( node, "xmlns" ); -	if( !s || strcmp( s, SASL_NS ) != 0 ) +	if( !s || strcmp( s, XMLNS_SASL ) != 0 )  	{  		signoff( gc );  		return XT_ABORT; @@ -69,7 +67,7 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )  	}  	reply = xt_new_node( "auth", NULL, NULL ); -	xt_add_attr( reply, "xmlns", SASL_NS ); +	xt_add_attr( reply, "xmlns", XMLNS_SASL );  	if( sup_digest )  	{ @@ -271,7 +269,7 @@ xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data )  	}  	reply = xt_new_node( "response", s, NULL ); -	xt_add_attr( reply, "xmlns", SASL_NS ); +	xt_add_attr( reply, "xmlns", XMLNS_SASL );  	if( !jabber_write_packet( gc, reply ) )  		goto silent_error; @@ -302,7 +300,7 @@ xt_status sasl_pkt_result( struct xt_node *node, gpointer data )  	char *s;  	s = xt_find_attr( node, "xmlns" ); -	if( !s || strcmp( s, SASL_NS ) != 0 ) +	if( !s || strcmp( s, XMLNS_SASL ) != 0 )  	{  		signoff( gc );  		return XT_ABORT; | 
