diff options
Diffstat (limited to 'protocols/jabber')
| -rw-r--r-- | protocols/jabber/jabber.c | 32 | ||||
| -rw-r--r-- | protocols/jabber/jabber.h | 4 | ||||
| -rw-r--r-- | protocols/jabber/jabber_util.c | 8 | ||||
| -rw-r--r-- | protocols/jabber/message.c | 17 | 
4 files changed, 50 insertions, 11 deletions
| diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 0e23b4d4..52a87d5d 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -36,11 +36,30 @@  GSList *jabber_connections; +/* First enty is the default */ +static const int jabber_port_list[] = { +	5222, +	5223, +	5220, +	5221, +	5224, +	5225, +	5226, +	5227, +	5228, +	5229, +	80, +	443, +	0 +}; +  static void jabber_init( account_t *acc )  {  	set_t *s; +	char str[16]; -	s = set_add( &acc->set, "port", JABBER_PORT_DEFAULT, set_eval_int, acc ); +	g_snprintf( str, sizeof( str ), "%d", jabber_port_list[0] ); +	s = set_add( &acc->set, "port", str, set_eval_int, acc );  	s->flags |= ACC_SET_OFFLINE_ONLY;  	s = set_add( &acc->set, "priority", "0", set_eval_priority, acc ); @@ -71,6 +90,7 @@ static void jabber_login( account_t *acc )  	struct jabber_data *jd = g_new0( struct jabber_data, 1 );  	struct ns_srv_reply *srv = NULL;  	char *connect_to, *s; +	int i;  	/* For now this is needed in the _connected() handlers if using  	   GLib event handling, to make sure we're not handling events @@ -176,11 +196,13 @@ static void jabber_login( account_t *acc )  	imcb_log( ic, "Connecting" ); -	if( set_getint( &acc->set, "port" ) < JABBER_PORT_MIN || -	    set_getint( &acc->set, "port" ) > JABBER_PORT_MAX ) +	for( i = 0; jabber_port_list[i] > 0; i ++ ) +		if( set_getint( &acc->set, "port" ) == jabber_port_list[i] ) +			break; + +	if( jabber_port_list[i] == 0 )  	{ -		imcb_log( ic, "Incorrect port number, must be in the %d-%d range", -		               JABBER_PORT_MIN, JABBER_PORT_MAX ); +		imcb_log( ic, "Illegal port number" );  		imc_logout( ic, FALSE );  		return;  	} diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 1ff0e8dd..023cf0f9 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -134,10 +134,6 @@ struct jabber_chat  #define JABBER_XMLCONSOLE_HANDLE "xmlconsole" -#define JABBER_PORT_DEFAULT "5222" -#define JABBER_PORT_MIN 5220 -#define JABBER_PORT_MAX 5229 -  /* Prefixes to use for packet IDs (mainly for IQ packets ATM). Usually the     first one should be used, but when storing a packet in the cache, a     "special" kind of ID is assigned to make it easier later to figure out diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 6e872040..518624f6 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -245,8 +245,10 @@ struct jabber_buddy_ask_data  	char *realname;  }; -static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla ) +static void jabber_buddy_ask_yes( void *data )  { +	struct jabber_buddy_ask_data *bla = data; +	  	presence_send_request( bla->ic, bla->handle, "subscribed" );  	if( imcb_find_buddy( bla->ic, bla->handle ) == NULL ) @@ -256,8 +258,10 @@ static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla  	g_free( bla );  } -static void jabber_buddy_ask_no( gpointer w, struct jabber_buddy_ask_data *bla ) +static void jabber_buddy_ask_no( void *data )  { +	struct jabber_buddy_ask_data *bla = data; +	  	presence_send_request( bla->ic, bla->handle, "subscribed" );  	g_free( bla->handle ); diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index fab62a91..6cb67d42 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -48,6 +48,23 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data )  	else /* "chat", "normal", "headline", no-type or whatever. Should all be pretty similar. */  	{  		GString *fullmsg = g_string_new( "" ); + +		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; +			 +			if( strcmp( ns, XMLNS_MUC_USER ) == 0 && +			    ( inv = xt_find_node( c->children, "invite" ) ) ) +			{ +				room = from; +				from = xt_find_attr( inv, "from" ) ? : from; + +				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( ( s = strchr( from, '/' ) ) )  		{ | 
