diff options
| -rw-r--r-- | protocols/jabber/io.c | 2 | ||||
| -rw-r--r-- | protocols/jabber/iq.c | 152 | ||||
| -rw-r--r-- | protocols/jabber/jabber.c | 41 | ||||
| -rw-r--r-- | protocols/jabber/jabber.h | 10 | ||||
| -rw-r--r-- | protocols/jabber/xmltree.c | 24 | 
5 files changed, 23 insertions, 206 deletions
| diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c index 04b98626..73173dbc 100644 --- a/protocols/jabber/io.c +++ b/protocols/jabber/io.c @@ -385,7 +385,7 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data )  	   to bind/initialize the session. */  	if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )  	{ -		if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ) ) +		if( !jabber_get_roster( gc ) )  			return XT_ABORT;  	} diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index b77ee9ff..4739d6ab 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -108,42 +108,6 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  		account_online( gc );  	} -	if( strcmp( type, "result" ) == 0 && xmlns && strcmp( xmlns, "jabber:iq:privacy" ) == 0 ) -	{ -		struct xt_node *node; -		 -		/* When receiving a list of lists: */ -		if( ( node = xt_find_node( query->children, "active" ) ) ) -		{ -			if( ( s = xt_find_attr( node, "name" ) ) ) -			{ -				set_t *set; -				 -				g_free( jd->privacy_active ); -				jd->privacy_active = g_strdup( s ); -				 -				/* Save it so the user can see it. */ -				if( ( set = set_find( &gc->acc->set, "privacy_list" ) ) ) -				{ -					g_free( set->value ); -					set->value = g_strdup( s ); -				} -				 -				if( !jabber_get_privacy( gc ) ) -					return XT_ABORT; -			} -		} -		/* When receiving an actual list: */ -		else if( ( node = xt_find_node( query->children, "list" ) ) ) -		{ -			xt_free_node( jd->privacy_list ); -			jd->privacy_list = xt_dup( node ); -		} -		else if( query->children == NULL ) -		{ -			/* What to do here if there is no privacy list defined yet... */ -		} -	}  	else if( strcmp( type, "result" ) == 0 && orig )  	{  		struct xt_node *c; @@ -156,7 +120,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  			/* This happens when we just successfully authenticated  			   the old (non-SASL) way. */  			jd->flags |= JFLAG_AUTHENTICATED; -			if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ) ) +			if( !jabber_get_roster( gc ) )  				return XT_ABORT;  		}  		/* Tricky: Look for <bind> in the reply, because the server @@ -180,21 +144,10 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  			if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )  			{ -				if( !jabber_get_roster( gc ) || !jabber_get_privacy( gc ) ) +				if( !jabber_get_roster( gc ) )  					return XT_ABORT;  			}  		} -		else if( ( c = xt_find_node( orig->children, "query" ) ) && -		         ( c = xt_find_node( c->children, "active" ) ) ) -		{ -			/* We just successfully activated a (different) -			   privacy list. Fetch it now. */ -			g_free( jd->privacy_active ); -			jd->privacy_active = g_strdup( xt_find_attr( c, "name" ) ); -			 -			if( !jabber_get_privacy( gc ) ) -				return XT_ABORT; -		}  	}  	else if( strcmp( type, "error" ) == 0 )  	{ @@ -208,33 +161,6 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )  			signoff( gc );  			return XT_ABORT;  		} -		else if( ( xmlns && strcmp( xmlns, "jabber:iq:privacy" ) == 0 ) || -		         ( orig && -		           ( c = xt_find_node( orig->children, "query" ) ) && -		           ( s = xt_find_attr( c, "xmlns" ) ) && -		           strcmp( s, "jabber:iq:privacy" ) == 0 ) ) -		{ -			/* All errors related to privacy lists. */ -			if( ( c = xt_find_node( node->children, "error" ) ) == NULL ) -			{ -				hide_login_progress_error( gc, "Received malformed error packet" ); -				signoff( gc ); -				return XT_ABORT; -			} -			 -			if( xt_find_node( c->children, "item-not-found" ) ) -			{ -				serv_got_crap( gc, "Error while activating privacy list, maybe it doesn't exist" ); -				/* Should I do anything else here? */ -			} -			else if( xt_find_node( c->children, "feature-not-implemented" ) ) -			{ -				jd->flags |= JFLAG_PRIVACY_BROKEN; -				/* Probably there's no need to inform the user. -				   We can do that if the user ever tries to use -				   the block/allow commands. */ -			} -		}  	}  	return XT_HANDLED; @@ -315,77 +241,3 @@ int jabber_remove_from_roster( struct gaim_connection *gc, char *handle )  	xt_free_node( node );  	return st;  } - -/* Request the privacy list from the server. We need this, because every -   time we remove/add something we have to send the whole new list to the -   server again... If no privacy list is specified yet, this function will -   first ask for the list of lists (XMPP supports multiple "privacy lists", -   don't ask me why), later we can then fetch the list we want to use. */ -int jabber_get_privacy( struct gaim_connection *gc ) -{ -	struct jabber_data *jd = gc->proto_data; -	struct xt_node *node = NULL; -	char *name; -	int st; -	 -	if( jd->privacy_active ) -	{ -		/* If we know what is the active list right now, fetch it. */ -		node = xt_new_node( "list", NULL, NULL ); -		xt_add_attr( node, "name", jd->privacy_active ); -	} -	/* Okay, we don't know yet. If the user set a specific list, we'll -	   activate that one. Otherwise, we should figure out which list is -	   currently active. */ -	else if( ( name = set_getstr( &gc->acc->set, "privacy_list" ) ) ) -	{ -		return jabber_set_privacy( gc, name ); -	} -	/* else: sending this packet without a <list/> element will give -	   a list of available lists and information about the currently -	   active list. */ -	 -	node = xt_new_node( "query", NULL, node ); -	xt_add_attr( node, "xmlns", "jabber:iq:privacy" ); -	node = jabber_make_packet( "iq", "get", NULL, node ); -	 -	jabber_cache_packet( gc, node ); -	st = jabber_write_packet( gc, node ); -	 -	return st; -} - -int jabber_set_privacy( struct gaim_connection *gc, char *name ) -{ -	struct xt_node *node; -	 -	node = xt_new_node( "active", NULL, NULL ); -	xt_add_attr( node, "name", name ); -	node = xt_new_node( "query", NULL, node ); -	xt_add_attr( node, "xmlns", "jabber:iq:privacy" ); -	 -	node = jabber_make_packet( "iq", "set", NULL, node ); -	jabber_cache_packet( gc, node ); -	 -	return jabber_write_packet( gc, node ); -} - -char *set_eval_privacy_list( set_t *set, char *value ) -{ -	account_t *acc = set->data; -	struct jabber_data *jd = acc->gc->proto_data; -	 -	if( jd->flags & JFLAG_PRIVACY_BROKEN ) -	{ -		serv_got_crap( acc->gc, "Privacy lists not supported by this server" ); -		return NULL; -	} -	 -	/* If we're on-line, return NULL and let the server decide if the -	   chosen list is valid. If we're off-line, just accept it and we'll -	   see later (when we connect). */ -	if( acc->gc ) -		jabber_set_privacy( acc->gc, value ); -	 -	return acc->gc ? NULL : value; -} diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index fc415ca7..706d31c3 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -41,8 +41,6 @@ static void jabber_acc_init( account_t *acc )  	s = set_add( &acc->set, "priority", "0", set_eval_priority, acc ); -	s = set_add( &acc->set, "privacy_list", NULL, set_eval_privacy_list, acc ); -	  	s = set_add( &acc->set, "resource", "BitlBee", NULL, acc );  	s->flags |= ACC_SET_OFFLINE_ONLY; @@ -110,9 +108,6 @@ static void jabber_close( struct gaim_connection *gc )  	if( jd->tx_len )  		g_free( jd->txq ); -	xt_free_node( jd->privacy_list ); -	g_free( jd->privacy_active ); -	  	xt_free_node( jd->node_cache );  	xt_free( jd->xt ); @@ -228,38 +223,6 @@ static void jabber_keepalive( struct gaim_connection *gc )  	}  } -static void jabber_add_permit( struct gaim_connection *gc, char *who ) -{ -	struct jabber_data *jd = gc->proto_data; -	 -	if( jd->flags & JFLAG_PRIVACY_BROKEN ) -	{ -		serv_got_crap( gc, "Privacy lists not supported by this server" ); -		return; -	} -} - -static void jabber_rem_permit( struct gaim_connection *gc, char *who ) -{ -	struct jabber_data *jd = gc->proto_data; -	 -	if( jd->flags & JFLAG_PRIVACY_BROKEN ) -	{ -		serv_got_crap( gc, "Privacy lists not supported by this server" ); -		return; -	} -} - -/* XMPP doesn't have both a block- and and allow-list, so these two functions -   will be no-ops: */ -static void jabber_add_deny( struct gaim_connection *gc, char *who ) -{ -} - -static void jabber_rem_deny( struct gaim_connection *gc, char *who ) -{ -} -  void jabber_init()  {  	struct prpl *ret = g_new0( struct prpl, 1 ); @@ -281,10 +244,6 @@ void jabber_init()  //	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; diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 2c7cadd1..8ca7d545 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -36,7 +36,6 @@ typedef enum  	JFLAG_STREAM_RESTART = 4,	/* Set when we want to restart the stream (after SASL or TLS). */  	JFLAG_WAIT_SESSION = 8,		/* Set if we sent a <session> tag and need a reply before we continue. */  	JFLAG_WAIT_BIND = 16,		/* ... for <bind> tag. */ -	JFLAG_PRIVACY_BROKEN = 32,	/* Or just not supported, actually. */  } jabber_flags_t;  struct jabber_data @@ -60,10 +59,6 @@ struct jabber_data  	struct jabber_away_state *away_state;  	char *away_message; -	/* Updates to this one should be synchronized using jabber_privacy_update(). */ -	struct xt_node *privacy_list; -	char *privacy_active; -	  	struct xt_node *node_cache;  }; @@ -73,17 +68,12 @@ struct jabber_away_state  	char *full_name;  }; -#define DEFAULT_PRIVACY_LIST "simple_blocklist" -  /* iq.c */  xt_status jabber_pkt_iq( struct xt_node *node, gpointer data );  int jabber_start_iq_auth( struct gaim_connection *gc );  int jabber_get_roster( struct gaim_connection *gc );  int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name );  int jabber_remove_from_roster( struct gaim_connection *gc, char *handle ); -int jabber_get_privacy( struct gaim_connection *gc ); -int jabber_set_privacy( struct gaim_connection *gc, char *name ); -char *set_eval_privacy_list( set_t *set, char *value );  /* message.c */  xt_status jabber_pkt_message( struct xt_node *node, gpointer data ); diff --git a/protocols/jabber/xmltree.c b/protocols/jabber/xmltree.c index d4063476..af0c5832 100644 --- a/protocols/jabber/xmltree.c +++ b/protocols/jabber/xmltree.c @@ -527,9 +527,25 @@ void xt_add_attr( struct xt_node *node, char *key, char *value )  {  	int i; -	for( i = 0; node->attr[i].key; i ++ ); -	node->attr = g_renew( struct xt_attr, node->attr, i + 2 ); -	node->attr[i].key = g_strdup( key ); +	/* Now actually it'd be nice if we can also change existing attributes +	   (which actually means this function doesn't have the right name). +	   So let's find out if we have this attribute already... */ +	for( i = 0; node->attr[i].key; i ++ ) +		if( strcmp( node->attr[i].key, key ) == 0 ) +			break; +	 +	if( node->attr[i].key == NULL ) +	{ +		/* If not, allocate space for a new attribute. */ +		node->attr = g_renew( struct xt_attr, node->attr, i + 2 ); +		node->attr[i].key = g_strdup( key ); +		node->attr[i+1].key = NULL; +	} +	else +	{ +		/* Otherwise, free the old value before setting the new one. */ +		g_free( node->attr[i].value ); +	} +	  	node->attr[i].value = g_strdup( value ); -	node->attr[i+1].key = NULL;  } | 
