Changeset a5c6ebd


Ignore:
Timestamp:
2013-02-21T18:09:19Z (11 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
03886fc
Parents:
06eef80
Message:

! modified for control channel fill_by setting to for example create a
separate control channel with all contacts *not* in a certain group/from
a certain IM account/network, etc.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • doc/user-guide/commands.xml

    r06eef80 ra5c6ebd  
    930930                       
    931931                        <para>
     932                                With a ! prefix an inverted channel can be created, for example with this setting set to <emphasis>!group</emphasis> you can create a channel with all users <emphasis>not</emphasis> in that group.
     933                        </para>
     934                       
     935                        <para>
    932936                                Note that, when creating a new channel, BitlBee will try to preconfigure the channel for you, based on the channel name. See <emphasis>help channels</emphasis>.
    933937                        </para>
  • irc.h

    r06eef80 ra5c6ebd  
    207207typedef enum
    208208{
    209         IRC_CC_TYPE_DEFAULT,
    210         IRC_CC_TYPE_REST,
    211         IRC_CC_TYPE_GROUP,
    212         IRC_CC_TYPE_ACCOUNT,
    213         IRC_CC_TYPE_PROTOCOL,
     209        IRC_CC_TYPE_DEFAULT  = 0x00001,
     210        IRC_CC_TYPE_REST     = 0x00002, /* Still not implemented. */
     211        IRC_CC_TYPE_GROUP    = 0x00004,
     212        IRC_CC_TYPE_ACCOUNT  = 0x00008,
     213        IRC_CC_TYPE_PROTOCOL = 0x00010,
     214        IRC_CC_TYPE_MASK     = 0x000ff,
     215        IRC_CC_TYPE_INVERT   = 0x00100,
    214216} irc_control_channel_type_t;
    215217
  • irc_channel.c

    r06eef80 ra5c6ebd  
    670670       
    671671        icc->account = acc;
    672         if( icc->type == IRC_CC_TYPE_ACCOUNT )
     672        if( ( icc->type & IRC_CC_TYPE_MASK ) == IRC_CC_TYPE_ACCOUNT )
    673673                bee_irc_channel_update( ic->irc, ic, NULL );
    674674       
     
    680680        struct irc_channel *ic = set->data;
    681681        struct irc_control_channel *icc = ic->data;
    682        
    683         if( strcmp( value, "all" ) == 0 )
    684                 icc->type = IRC_CC_TYPE_DEFAULT;
    685         else if( strcmp( value, "rest" ) == 0 )
    686                 icc->type = IRC_CC_TYPE_REST;
    687         else if( strcmp( value, "group" ) == 0 )
    688                 icc->type = IRC_CC_TYPE_GROUP;
    689         else if( strcmp( value, "account" ) == 0 )
    690                 icc->type = IRC_CC_TYPE_ACCOUNT;
    691         else if( strcmp( value, "protocol" ) == 0 )
    692                 icc->type = IRC_CC_TYPE_PROTOCOL;
     682        char *s;
     683       
     684        icc->type &= ~( IRC_CC_TYPE_MASK | IRC_CC_TYPE_INVERT );
     685       
     686        s = value;
     687        if( s[0] == '!' )
     688        {
     689                icc->type |= IRC_CC_TYPE_INVERT;
     690                s ++;
     691        }
     692       
     693        if( strcmp( s, "all" ) == 0 )
     694                icc->type |= IRC_CC_TYPE_DEFAULT;
     695        else if( strcmp( s, "rest" ) == 0 )
     696                icc->type |= IRC_CC_TYPE_REST;
     697        else if( strcmp( s, "group" ) == 0 )
     698                icc->type |= IRC_CC_TYPE_GROUP;
     699        else if( strcmp( s, "account" ) == 0 )
     700                icc->type |= IRC_CC_TYPE_ACCOUNT;
     701        else if( strcmp( s, "protocol" ) == 0 )
     702                icc->type |= IRC_CC_TYPE_PROTOCOL;
    693703        else
    694704                return SET_INVALID;
     
    704714       
    705715        icc->group = bee_group_by_name( ic->irc->b, value, TRUE );
    706         if( icc->type == IRC_CC_TYPE_GROUP )
     716        if( ( icc->type & IRC_CC_TYPE_MASK ) == IRC_CC_TYPE_GROUP )
    707717                bee_irc_channel_update( ic->irc, ic, NULL );
    708718       
     
    720730       
    721731        icc->protocol = prpl;
    722         if( icc->type == IRC_CC_TYPE_PROTOCOL )
     732        if( ( icc->type & IRC_CC_TYPE_MASK ) == IRC_CC_TYPE_PROTOCOL )
    723733                bee_irc_channel_update( ic->irc, ic, NULL );
    724734       
     
    776786{
    777787        struct irc_control_channel *icc = ic->data;
     788        gboolean ret = FALSE;
    778789       
    779790        if( iu->bu == NULL )
    780791                return FALSE;
    781792       
    782         switch( icc->type )
     793        switch( icc->type & IRC_CC_TYPE_MASK )
    783794        {
    784795        case IRC_CC_TYPE_GROUP:
    785                 return iu->bu->group == icc->group;
     796                ret = iu->bu->group == icc->group;
     797                break;
    786798        case IRC_CC_TYPE_ACCOUNT:
    787                 return iu->bu->ic->acc == icc->account;
     799                ret = iu->bu->ic->acc == icc->account;
     800                break;
    788801        case IRC_CC_TYPE_PROTOCOL:
    789                 return iu->bu->ic->acc->prpl == icc->protocol;
     802                ret = iu->bu->ic->acc->prpl == icc->protocol;
     803                break;
    790804        case IRC_CC_TYPE_DEFAULT:
    791805        default:
    792                 return TRUE;
    793         }
     806                ret = TRUE;
     807                break;
     808        }
     809       
     810        if( icc->type & IRC_CC_TYPE_INVERT )
     811                ret = !ret;
     812       
     813        return ret;
    794814}
    795815
Note: See TracChangeset for help on using the changeset viewer.