Changeset badd148 for irc_im.c


Ignore:
Timestamp:
2010-07-12T23:22:53Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
db2cef1
Parents:
09dfb68
Message:

Reformat nicks whenever fullname/nick/group changes (but at least for now
still only for offline users).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_im.c

    r09dfb68 rbadd148  
    242242}
    243243
    244 static gboolean bee_irc_user_nick_hint( bee_t *bee, bee_user_t *bu, const char *hint );
     244static gboolean bee_irc_user_nick_update( irc_user_t *iu );
    245245
    246246static gboolean bee_irc_user_fullname( bee_t *bee, bee_user_t *bu )
     
    265265        }
    266266       
    267         s = set_getstr( &bu->ic->acc->set, "nick_source" );
    268         if( strcmp( s, "handle" ) != 0 )
    269         {
    270                 char *name = g_strdup( bu->fullname );
    271                
    272                 if( strcmp( s, "first_name" ) == 0 )
    273                 {
    274                         int i;
    275                         for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {}
    276                         name[i] = '\0';
    277                 }
    278                
    279                 bee_irc_user_nick_hint( bee, bu, name );
    280                
    281                 g_free( name );
    282         }
     267        bee_irc_user_nick_update( iu );
    283268       
    284269        return TRUE;
     
    287272static gboolean bee_irc_user_nick_hint( bee_t *bee, bee_user_t *bu, const char *hint )
    288273{
    289         irc_user_t *iu = bu->ui_data;
    290         char newnick[MAX_NICK_LENGTH+1], *translit;
     274        bee_irc_user_nick_update( (irc_user_t*) bu->ui_data );
     275       
     276        return TRUE;
     277}
     278
     279static gboolean bee_irc_user_group( bee_t *bee, bee_user_t *bu )
     280{
     281        irc_user_t *iu = (irc_user_t *) bu->ui_data;
     282        irc_t *irc = (irc_t *) bee->ui_data;
     283       
     284        bee_irc_channel_update( irc, NULL, iu );
     285        bee_irc_user_nick_update( iu );
     286       
     287        return TRUE;
     288}
     289
     290static gboolean bee_irc_user_nick_update( irc_user_t *iu )
     291{
     292        bee_user_t *bu = iu->bu;
     293        char *newnick;
    291294       
    292295        if( bu->flags & BEE_USER_ONLINE )
     
    298301                return TRUE;
    299302       
    300         /* Credits to Josay_ in #bitlbee for this idea. //TRANSLIT should
    301            do lossy/approximate conversions, so letters with accents don't
    302            just get stripped. Note that it depends on LC_CTYPE being set to
    303            something other than C/POSIX. */
    304         translit = g_convert( hint, -1, "ASCII//TRANSLIT//IGNORE", "UTF-8",
    305                               NULL, NULL, NULL );
    306        
    307         strncpy( newnick, translit ? : hint, MAX_NICK_LENGTH );
    308         newnick[MAX_NICK_LENGTH] = 0;
    309         g_free( translit );
    310        
    311         /* Some processing to make sure this string is a valid IRC nickname. */
    312         nick_strip( newnick );
    313         if( set_getbool( &bee->set, "lcnicks" ) )
    314                 nick_lc( newnick );
     303        newnick = nick_get( bu );
    315304       
    316305        if( strcmp( iu->nick, newnick ) != 0 )
    317306        {
    318                 /* Only do this if newnick is different from the current one.
    319                    If rejoining a channel, maybe we got this nick already
    320                    (and dedupe would only add an underscore. */
    321307                nick_dedupe( bu, newnick );
    322308                irc_user_set_nick( iu, newnick );
    323309        }
    324        
    325         return TRUE;
    326 }
    327 
    328 static gboolean bee_irc_user_group( bee_t *bee, bee_user_t *bu )
    329 {
    330         irc_user_t *iu = (irc_user_t *) bu->ui_data;
    331         irc_t *irc = (irc_t *) bee->ui_data;
    332        
    333         bee_irc_channel_update( irc, NULL, iu );
    334310       
    335311        return TRUE;
Note: See TracChangeset for help on using the changeset viewer.