Changeset 6d8cc05 for irc.c


Ignore:
Timestamp:
2010-07-18T23:50:27Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
5a61bf59
Parents:
94d5da9c
Message:

Adding easy migration from old show_offline/away_devoice settings, and
documentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    r94d5da9c r6d8cc05  
    3333static char *set_eval_charset( set_t *set, char *value );
    3434static char *set_eval_password( set_t *set, char *value );
     35static char *set_eval_bw_compat( set_t *set, char *value );
    3536
    3637irc_t *irc_new( int fd )
     
    101102       
    102103        s = set_add( &b->set, "allow_takeover", "true", set_eval_bool, irc );
    103         s = set_add( &b->set, "away_devoice", "true", set_eval_away_devoice, irc );
     104        s = set_add( &b->set, "away_devoice", "true", set_eval_bw_compat, irc );
    104105        s = set_add( &b->set, "away_reply_timeout", "3600", set_eval_int, irc );
    105106        s = set_add( &b->set, "charset", "utf-8", set_eval_charset, irc );
     
    121122        s = set_add( &b->set, "query_order", "lifo", NULL, irc );
    122123        s = set_add( &b->set, "root_nick", ROOT_NICK, set_eval_root_nick, irc );
     124        s = set_add( &b->set, "show_offline", "false", set_eval_bw_compat, irc );
    123125        s = set_add( &b->set, "simulate_netsplit", "true", set_eval_bool, irc );
    124126        s = set_add( &b->set, "timezone", "local", set_eval_timezone, irc );
     
    901903}
    902904
    903 char *set_eval_away_devoice( set_t *set, char *value )
     905/* Mostly meant for upgrades. If one of these is set to the non-default,
     906   set show_users of all channels to something with the same effect. */
     907static char *set_eval_bw_compat( set_t *set, char *value )
    904908{
    905909        irc_t *irc = set->data;
    906        
    907         if( !is_bool( value ) )
     910        char *val;
     911        GSList *l;
     912       
     913        irc_usermsg( irc, "Setting `%s' is obsolete, use the `show_users' "
     914                     "channel setting instead.", set->key );
     915       
     916        if( strcmp( set->key, "away_devoice" ) == 0 && !bool2int( value ) )
     917                val = "online,away";
     918        else if( strcmp( set->key, "show_offline" ) == 0 && bool2int( value ) )
     919                val = "online@,away+,offline";
     920        else
    908921                return SET_INVALID;
    909922       
    910         /* The usual problem: The setting isn't actually changed at this
    911            point and we need it to be, so do it by hand. */
    912         g_free( set->value );
    913         set->value = g_strdup( value );
    914        
    915         bee_irc_channel_update( irc, NULL, NULL );
    916        
    917         return value;
    918 }
     923        for( l = irc->channels; l; l = l->next )
     924        {
     925                irc_channel_t *ic = l->data;
     926                /* No need to check channel type, if the setting doesn't exist it
     927                   will just be ignored. */
     928                set_setstr( &ic->set, "show_users", val );
     929        }
     930       
     931        return SET_INVALID;
     932}
Note: See TracChangeset for help on using the changeset viewer.