Changeset 7a6ba50 for irc_channel.c


Ignore:
Timestamp:
2010-06-29T23:44:17Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
217bf4e
Parents:
58646d9
Message:

Also allow selecting contacts for a channel by protocol instead of account.
If someone has two MSN accts and wants contacts from both in one channel,
this is now possible.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_channel.c

    r58646d9 r7a6ba50  
    474474static char *set_eval_fill_by( set_t *set, char *value );
    475475static char *set_eval_by_group( set_t *set, char *value );
     476static char *set_eval_by_protocol( set_t *set, char *value );
    476477
    477478static gboolean control_channel_init( irc_channel_t *ic )
     
    482483        set_add( &ic->set, "fill_by", "all", set_eval_fill_by, ic );
    483484        set_add( &ic->set, "group", NULL, set_eval_by_group, ic );
     485        set_add( &ic->set, "protocol", NULL, set_eval_by_protocol, ic );
    484486       
    485487        ic->data = icc = g_new0( struct irc_control_channel, 1 );
     
    515517        if( icc->type == IRC_CC_TYPE_ACCOUNT )
    516518                bee_irc_channel_update( ic->irc, ic, NULL );
     519       
    517520        return g_strdup_printf( "%s(%s)", acc->prpl->name, acc->user );
    518521}
     
    531534        else if( strcmp( value, "account" ) == 0 )
    532535                icc->type = IRC_CC_TYPE_ACCOUNT;
     536        else if( strcmp( value, "protocol" ) == 0 )
     537                icc->type = IRC_CC_TYPE_PROTOCOL;
    533538        else
    534539                return SET_INVALID;
     
    546551        if( icc->type == IRC_CC_TYPE_GROUP )
    547552                bee_irc_channel_update( ic->irc, ic, NULL );
     553       
    548554        return g_strdup( icc->group->name );
     555}
     556
     557static char *set_eval_by_protocol( set_t *set, char *value )
     558{
     559        struct irc_channel *ic = set->data;
     560        struct irc_control_channel *icc = ic->data;
     561        struct prpl *prpl;
     562       
     563        if( !( prpl = find_protocol( value ) ) )
     564                return SET_INVALID;
     565       
     566        icc->protocol = prpl;
     567        if( icc->type == IRC_CC_TYPE_PROTOCOL )
     568                bee_irc_channel_update( ic->irc, ic, NULL );
     569       
     570        return value;
    549571}
    550572
Note: See TracChangeset for help on using the changeset viewer.