Changeset 6ef9065


Ignore:
Timestamp:
2010-06-07T21:09:33Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
f1cea66
Parents:
619dd18
Message:

Restored nick_hint/nick_source functionality.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • irc_im.c

    r619dd18 r6ef9065  
    220220}
    221221
     222static gboolean bee_irc_user_nick_hint( bee_t *bee, bee_user_t *bu, const char *hint );
     223
    222224static gboolean bee_irc_user_fullname( bee_t *bee, bee_user_t *bu )
    223225{
     
    253255                }
    254256               
    255                 imcb_buddy_nick_hint( bu->ic, bu->handle, name );
     257                bee_irc_user_nick_hint( bee, bu, name );
    256258               
    257259                g_free( name );
     260        }
     261       
     262        return TRUE;
     263}
     264
     265static gboolean bee_irc_user_nick_hint( bee_t *bee, bee_user_t *bu, const char *hint )
     266{
     267        irc_user_t *iu = bu->ui_data;
     268        char newnick[MAX_NICK_LENGTH+1], *translit;
     269       
     270        if( bu->flags & BEE_USER_ONLINE )
     271                /* Ignore if the user is visible already. */
     272                return TRUE;
     273       
     274        if( nick_saved( bu->ic->acc, bu->handle ) )
     275                /* The user already assigned a nickname to this person. */
     276                return TRUE;
     277       
     278        /* Credits to Josay_ in #bitlbee for this idea. //TRANSLIT should
     279           do lossy/approximate conversions, so letters with accents don't
     280           just get stripped. Note that it depends on LC_CTYPE being set to
     281           something other than C/POSIX. */
     282        translit = g_convert( hint, -1, "ASCII//TRANSLIT//IGNORE", "UTF-8",
     283                              NULL, NULL, NULL );
     284       
     285        strncpy( newnick, translit ? : hint, MAX_NICK_LENGTH );
     286        newnick[MAX_NICK_LENGTH] = 0;
     287        g_free( translit );
     288       
     289        /* Some processing to make sure this string is a valid IRC nickname. */
     290        nick_strip( newnick );
     291        if( set_getbool( &bee->set, "lcnicks" ) )
     292                nick_lc( newnick );
     293       
     294        if( strcmp( iu->nick, newnick ) != 0 )
     295        {
     296                /* Only do this if newnick is different from the current one.
     297                   If rejoining a channel, maybe we got this nick already
     298                   (and dedupe would only add an underscore. */
     299                nick_dedupe( bu->ic->acc, bu->handle, newnick );
     300                irc_user_set_nick( iu, newnick );
    258301        }
    259302       
     
    722765        bee_irc_user_free,
    723766        bee_irc_user_fullname,
     767        bee_irc_user_nick_hint,
    724768        bee_irc_user_group,
    725769        bee_irc_user_status,
  • protocols/bee.h

    r619dd18 r6ef9065  
    8585        gboolean (*user_free)( bee_t *bee, struct bee_user *bu );
    8686        gboolean (*user_fullname)( bee_t *bee, bee_user_t *bu );
     87        gboolean (*user_nick_hint)( bee_t *bee, bee_user_t *bu, const char *hint );
    8788        gboolean (*user_group)( bee_t *bee, bee_user_t *bu );
    8889        gboolean (*user_status)( bee_t *bee, struct bee_user *bu, struct bee_user *old );
  • protocols/nogaim.c

    r619dd18 r6ef9065  
    418418void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick )
    419419{
    420 #if 0
    421         user_t *u = user_findhandle( ic, handle );
    422         char newnick[MAX_NICK_LENGTH+1], *orig_nick;
    423        
    424         if( u && !u->online && !nick_saved( ic->acc, handle ) )
    425         {
    426                 /* Only do this if the person isn't online yet (which should
    427                    be the case if we just added it) and if the user hasn't
    428                    assigned a nickname to this buddy already. */
    429                
    430                 strncpy( newnick, nick, MAX_NICK_LENGTH );
    431                 newnick[MAX_NICK_LENGTH] = 0;
    432                
    433                 /* Some processing to make sure this string is a valid IRC nickname. */
    434                 nick_strip( newnick );
    435                 if( set_getbool( &ic->bee->set, "lcnicks" ) )
    436                         nick_lc( newnick );
    437                
    438                 if( strcmp( u->nick, newnick ) != 0 )
    439                 {
    440                         /* Only do this if newnick is different from the current one.
    441                            If rejoining a channel, maybe we got this nick already
    442                            (and dedupe would only add an underscore. */
    443                         nick_dedupe( ic->acc, handle, newnick );
    444                        
    445                         /* u->nick will be freed halfway the process, so it can't be
    446                            passed as an argument. */
    447                         orig_nick = g_strdup( u->nick );
    448                         user_rename( ic->irc, orig_nick, newnick );
    449                         g_free( orig_nick );
    450                 }
    451         }
    452 #endif
     420        bee_t *bee = ic->bee;
     421        bee_user_t *bu = bee_user_by_handle( bee, ic, handle );
     422       
     423        if( !bu || !nick ) return;
     424       
     425        if( bee->ui->user_nick_hint )
     426                bee->ui->user_nick_hint( bee, bu, nick );
    453427}
    454428
Note: See TracChangeset for help on using the changeset viewer.