diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-08-14 11:55:20 +0100 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-08-14 11:55:20 +0100 | 
| commit | ac2717b6a60900d31236b7696f150d0120bda3da (patch) | |
| tree | aea6f42167d75c9c41116491cbdb09cc9fbec735 | |
| parent | 4ffd757724a657d2dc5c536473523a86f2331d9e (diff) | |
blist should only show contacts that are (or would be if they were online)
in the current channel.
| -rw-r--r-- | doc/user-guide/commands.xml | 4 | ||||
| -rw-r--r-- | irc.h | 1 | ||||
| -rw-r--r-- | irc_channel.c | 25 | ||||
| -rw-r--r-- | irc_im.c | 16 | ||||
| -rw-r--r-- | root_commands.c | 12 | 
5 files changed, 39 insertions, 19 deletions
| diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 7cedffc3..8bbada95 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -1431,11 +1431,11 @@  	<bitlbee-command name="blist">  		<syntax>blist [all|online|offline|away]</syntax> -		<short-description>List all the buddies in your contact list</short-description> +		<short-description>List all the buddies in the current channel</short-description>  		<description>  			<para> -				You can get a better readable buddy list using the <emphasis>blist</emphasis> command. If you want a complete list (including the offline users) you can use the <emphasis>all</emphasis> argument. +				You can get a more readable buddy list using the <emphasis>blist</emphasis> command. If you want a complete list (including the offline users) you can use the <emphasis>all</emphasis> argument.  			</para>  		</description> @@ -257,6 +257,7 @@ void irc_channel_name_strip( char *name );  int irc_channel_name_cmp( const char *a_, const char *b_ );  void irc_channel_update_ops( irc_channel_t *ic, char *value );  char *set_eval_irc_channel_ops( struct set *set, char *value ); +gboolean irc_channel_wants_user( irc_channel_t *ic, irc_user_t *iu );  /* irc_commands.c */  void irc_exec( irc_t *irc, char **cmd ); diff --git a/irc_channel.c b/irc_channel.c index 0498cffa..118fef74 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -725,6 +725,31 @@ fail:  	return SET_INVALID;	  } +/* Figure out if a channel is supposed to have the user, assuming s/he is +   online or otherwise also selected by the show_users setting. Only works +   for control channels, but does *not* check if this channel is of that +   type. Beware! */ +gboolean irc_channel_wants_user( irc_channel_t *ic, irc_user_t *iu ) +{ +	struct irc_control_channel *icc = ic->data; +	 +	if( iu->bu == NULL ) +		return FALSE; +	 +	switch( icc->type ) +	{ +	case IRC_CC_TYPE_GROUP: +		return iu->bu->group == icc->group; +	case IRC_CC_TYPE_ACCOUNT: +		return iu->bu->ic->acc == icc->account; +	case IRC_CC_TYPE_PROTOCOL: +		return iu->bu->ic->acc->prpl == icc->protocol; +	case IRC_CC_TYPE_DEFAULT: +	default: +		return TRUE; +	} +} +  static gboolean control_channel_free( irc_channel_t *ic )  {  	struct irc_control_channel *icc = ic->data; @@ -140,9 +140,7 @@ static gboolean bee_irc_user_status( bee_t *bee, bee_user_t *bu, bee_user_t *old  void bee_irc_channel_update( irc_t *irc, irc_channel_t *ic, irc_user_t *iu )  { -	struct irc_control_channel *icc;  	GSList *l; -	gboolean match = FALSE;  	if( ic == NULL )  	{ @@ -167,23 +165,13 @@ void bee_irc_channel_update( irc_t *irc, irc_channel_t *ic, irc_user_t *iu )  		return;  	} -	icc = ic->data; -	 -	if( icc->type == IRC_CC_TYPE_DEFAULT ) -		match = TRUE; -	else if( icc->type == IRC_CC_TYPE_GROUP ) -		match = iu->bu->group == icc->group; -	else if( icc->type == IRC_CC_TYPE_ACCOUNT ) -		match = iu->bu->ic->acc == icc->account; -	else if( icc->type == IRC_CC_TYPE_PROTOCOL ) -		match = iu->bu->ic->acc->prpl == icc->protocol; -	 -	if( !match ) +	if( !irc_channel_wants_user( ic, iu ) )  	{  		irc_channel_del_user( ic, iu, IRC_CDU_PART, NULL );  	}  	else  	{ +		struct irc_control_channel *icc = ic->data;  		int mode = 0;  		if( !( iu->bu->flags & BEE_USER_ONLINE ) ) diff --git a/root_commands.c b/root_commands.c index 6bd953fc..2cd1a617 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1007,12 +1007,16 @@ static void cmd_blist( irc_t *irc, char **cmd )  	irc_usermsg( irc, format, "Nick", "Handle/Account", "Status" ); +	if( strcmp( set_getstr( &irc->root->last_channel->set, "type" ), "control" ) != 0 ) +		irc->root->last_channel = NULL; +	  	for( l = irc->users; l; l = l->next )  	{  		irc_user_t *iu = l->data;  		bee_user_t *bu = iu->bu; -		if( !bu || ( bu->flags & ( BEE_USER_ONLINE | BEE_USER_AWAY ) ) != BEE_USER_ONLINE ) +		if( !bu || ( irc->root->last_channel && !irc_channel_wants_user( irc->root->last_channel, iu ) ) || +		    ( bu->flags & ( BEE_USER_ONLINE | BEE_USER_AWAY ) ) != BEE_USER_ONLINE )  			continue;  		if( online == 1 ) @@ -1034,7 +1038,8 @@ static void cmd_blist( irc_t *irc, char **cmd )  		irc_user_t *iu = l->data;  		bee_user_t *bu = iu->bu; -		if( !bu || !( bu->flags & BEE_USER_ONLINE ) || !( bu->flags & BEE_USER_AWAY ) ) +		if( !bu || ( irc->root->last_channel && !irc_channel_wants_user( irc->root->last_channel, iu ) ) || +		    !( bu->flags & BEE_USER_ONLINE ) || !( bu->flags & BEE_USER_AWAY ) )  			continue;  		if( away == 1 ) @@ -1050,7 +1055,8 @@ static void cmd_blist( irc_t *irc, char **cmd )  		irc_user_t *iu = l->data;  		bee_user_t *bu = iu->bu; -		if( !bu || bu->flags & BEE_USER_ONLINE ) +		if( !bu || ( irc->root->last_channel && !irc_channel_wants_user( irc->root->last_channel, iu ) ) || +		    bu->flags & BEE_USER_ONLINE )  			continue;  		if( offline == 1 ) | 
