Changeset 58adb7e


Ignore:
Timestamp:
2010-03-07T00:22:33Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
68198e9
Parents:
34fbbf9
Message:

Added global and per-account settings "away" and "status" so the user can
set these things individually.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • account.c

    r34fbbf9 r58adb7e  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2004 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2010 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    6969                prpl->init( a );
    7070       
    71         return( a );
     71        s = set_add( &a->set, "away", NULL, set_eval_account, a );
     72        s->flags |= SET_NULL_OK;
     73       
     74        if( a->flags & ACC_FLAG_STATUS_MESSAGE )
     75        {
     76                s = set_add( &a->set, "status", NULL, set_eval_account, a );
     77                s->flags |= SET_NULL_OK;
     78        }
     79       
     80        return a;
    7281}
    7382
     
    121130               
    122131                acc->auto_connect = bool2int( value );
     132                return value;
     133        }
     134        else if( strcmp( set->key, "away" ) == 0 ||
     135                 strcmp( set->key, "status" ) == 0 )
     136        {
     137                if( acc->ic && acc->ic->flags & OPT_LOGGED_IN )
     138                {
     139                        /* If we're currently on-line, set the var now already
     140                           (bit of a hack) and send an update. */
     141                        g_free( set->value );
     142                        set->value = g_strdup( value );
     143                       
     144                        imc_away_send_update( acc->ic );
     145                }
     146               
    123147                return value;
    124148        }
     
    267291        p->max = 86400;
    268292       
    269         /* Format: /[0-9]+([*+][0-9]+(<[0-9+]))/ */
     293        /* Format: /[0-9]+([*+][0-9]+(<[0-9+])?)?/ */
    270294        while( *value && isdigit( *value ) )
    271295                p->start = p->start * 10 + *value++ - '0';
  • irc.c

    r34fbbf9 r58adb7e  
    7878}
    7979
     80static char *set_eval_away_status( set_t *set, char *value )
     81{
     82        irc_t *irc = set->data;
     83        account_t *a;
     84       
     85        g_free( set->value );
     86        set->value = g_strdup( value );
     87       
     88        for( a = irc->accounts; a; a = a->next )
     89        {
     90                struct im_connection *ic = a->ic;
     91               
     92                if( ic && ic->flags & OPT_LOGGED_IN )
     93                        imc_away_send_update( ic );
     94        }
     95       
     96        return value;
     97}
     98
    8099irc_t *irc_new( int fd )
    81100{
     
    143162        irc_connection_list = g_slist_append( irc_connection_list, irc );
    144163       
     164        s = set_add( &irc->set, "away", NULL,  set_eval_away_status, irc );
     165        s->flags |= SET_NULL_OK;
    145166        s = set_add( &irc->set, "away_devoice", "true",  set_eval_away_devoice, irc );
    146167        s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc );
     
    163184        s = set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc );
    164185        s = set_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc );
     186        s = set_add( &irc->set, "status", NULL,  set_eval_away_status, irc );
     187        s->flags |= SET_NULL_OK;
    165188        s = set_add( &irc->set, "strip_html", "true", NULL, irc );
    166189        s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc );
  • irc_commands.c

    r34fbbf9 r58adb7e  
    475475        }
    476476       
    477         for( a = irc->accounts; a; a = a->next )
    478         {
    479                 struct im_connection *ic = a->ic;
    480                
    481                 if( ic && ic->flags & OPT_LOGGED_IN )
    482                         imc_set_away( ic, u->away );
    483         }
     477        set_setstr( &irc->set, "away", u->away );
    484478}
    485479
  • protocols/nogaim.c

    r34fbbf9 r58adb7e  
    22  * BitlBee -- An IRC to other IM-networks gateway                     *
    33  *                                                                    *
    4   * Copyright 2002-2006 Wilmer van der Gaast and others                *
     4  * Copyright 2002-2010 Wilmer van der Gaast and others                *
    55  \********************************************************************/
    66
     
    268268        ic->flags |= OPT_LOGGED_IN;
    269269       
    270         /* Also necessary when we're not away, at least for some of the
    271            protocols. */
    272         imc_set_away( ic, u->away );
     270        /* Necessary to send initial presence status, even if we're not away. */
     271        imc_away_send_update( ic );
    273272       
    274273        /* Apparently we're connected successfully, so reset the
     
    10721071static char *imc_away_state_find( GList *gcm, char *away, char **message );
    10731072
    1074 int imc_set_away( struct im_connection *ic, char *away )
    1075 {
    1076         char *s = NULL, *msg = away;
    1077        
     1073int imc_away_send_update( struct im_connection *ic )
     1074{
     1075        char *away, *msg;
     1076       
     1077        away = set_getstr( &ic->acc->set, "away" ) ?
     1078             : set_getstr( &ic->irc->set, "away" );
    10781079        if( away && *away )
    10791080        {
    10801081                GList *m = ic->acc->prpl->away_states( ic );
    1081                 s = imc_away_state_find( m, away, &msg ) ? : m->data;
    1082         }
    1083        
    1084         if( set_getbool( &ic->irc->set, "debug" ) )
    1085                 imcb_log( ic, "Setting away state to %s", s );
    1086        
    1087         ic->acc->prpl->set_away( ic, s, ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? msg : NULL );
     1082                msg = ic->acc->flags & ACC_FLAG_AWAY_MESSAGE ? away : NULL;
     1083                away = imc_away_state_find( m, away, &msg ) ? : m->data;
     1084        }
     1085        else if( ic->acc->flags & ACC_FLAG_STATUS_MESSAGE )
     1086        {
     1087                away = NULL;
     1088                msg = set_getstr( &ic->acc->set, "status" ) ?
     1089                    : set_getstr( &ic->irc->set, "status" );
     1090        }
     1091       
     1092        ic->acc->prpl->set_away( ic, away, msg );
    10881093       
    10891094        return 1;
  • protocols/nogaim.h

    r34fbbf9 r58adb7e  
    314314
    315315/* Actions, or whatever. */
    316 int imc_set_away( struct im_connection *ic, char *away );
     316int imc_away_send_update( struct im_connection *ic );
    317317int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags );
    318318int imc_chat_msg( struct groupchat *c, char *msg, int flags );
Note: See TracChangeset for help on using the changeset viewer.