diff options
| author | Wilmer van der Gaast <wilmer@google.com> | 2012-02-10 15:14:38 +0000 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@google.com> | 2012-02-10 15:14:38 +0000 | 
| commit | bb2d198251e2001591e0080ec9500e1078e1cd4f (patch) | |
| tree | b4ea73396a5bd15530051c7868267c3e8f585e09 /protocols/jabber/iq.c | |
| parent | e0a0a4277b51204743ffe7ece003602a50dc358c (diff) | |
Probing for Google Talk servers, based on iq-discovery responses. I'll need
this for automatically generating a sane name for groupchats.
Diffstat (limited to 'protocols/jabber/iq.c')
| -rw-r--r-- | protocols/jabber/iq.c | 44 | 
1 files changed, 44 insertions, 0 deletions
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index 2cdc681e..b5a37a30 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -26,6 +26,7 @@  static xt_status jabber_parse_roster( struct im_connection *ic, struct xt_node *node, struct xt_node *orig );  static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_node *node, struct xt_node *orig ); +static int jabber_iq_disco_server( struct im_connection *ic );  xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  { @@ -329,6 +330,8 @@ static xt_status jabber_finish_iq_auth( struct im_connection *ic, struct xt_node  		jd->flags |= JFLAG_AUTHENTICATED;  		if( !jabber_get_roster( ic ) )  			return XT_ABORT; +		if( !jabber_iq_disco_server( ic ) ) +			return XT_ABORT;  	}  	return XT_HANDLED; @@ -390,6 +393,8 @@ xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node,  	{  		if( !jabber_get_roster( ic ) )  			return XT_ABORT; +		if( !jabber_iq_disco_server( ic ) ) +			return XT_ABORT;  	}  	return XT_HANDLED; @@ -886,3 +891,42 @@ static xt_status jabber_iq_version_response( struct im_connection *ic,  	return XT_HANDLED;  } + +static xt_status jabber_iq_disco_server_response( struct im_connection *ic, +	struct xt_node *node, struct xt_node *orig ); + +static int jabber_iq_disco_server( struct im_connection *ic ) +{ +	struct xt_node *node, *iq; +	struct jabber_data *jd = ic->proto_data; +	 +	node = xt_new_node( "query", NULL, NULL ); +	xt_add_attr( node, "xmlns", XMLNS_DISCO_INFO ); +	iq = jabber_make_packet( "iq", "get", jd->server, node ); +	 +	jabber_cache_add( ic, iq, jabber_iq_disco_server_response ); +	return jabber_write_packet( ic, iq ); +} + +static xt_status jabber_iq_disco_server_response( struct im_connection *ic, +	struct xt_node *node, struct xt_node *orig ) +{ +	struct jabber_data *jd = ic->proto_data; +	struct xt_node *id; +	 +	if( ( id = xt_find_path( node, "query/identity" ) ) ) +	{ +		char *cat, *type, *name; +		 +		if( !( cat = xt_find_attr( id, "category" ) ) || +		    !( type = xt_find_attr( id, "type" ) ) || +		    !( name = xt_find_attr( id, "name" ) ) ) +			return XT_HANDLED; +		 +		if( strcmp( cat, "server" ) == 0 && strcmp( type, "im" ) == 0 && +		    strstr( name, "Google" ) != NULL ) +			jd->flags |= JFLAG_GTALK; +	} +	 +	return XT_HANDLED; +}  | 
