Changeset d06eabf


Ignore:
Timestamp:
2007-06-04T13:22:05Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
e0e2a71
Parents:
54f2f55
Message:

Added imcb_buddy_nick_hint so the Jabber conference module can suggest sane
nicknames for chatroom participants. There'll probably be a lot of
underscores now, but this is by far the cleanest way to implement this, I
think. At least now whispers will work properly. Also using this function
call to set names for ICQ contacts in a slightly saner way.

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • nick.c

    r54f2f55 rd06eabf  
    5757        static char nick[MAX_NICK_LENGTH+1];
    5858        char *store_handle, *found_nick;
    59         int inf_protection = 256;
    6059       
    6160        memset( nick, 0, MAX_NICK_LENGTH + 1 );
     
    8281        }
    8382        g_free( store_handle );
     83       
     84        /* Make sure the nick doesn't collide with an existing one by adding
     85           underscores and that kind of stuff, if necessary. */
     86        nick_dedupe( acc, handle, nick );
     87       
     88        return nick;
     89}
     90
     91void nick_dedupe( account_t *acc, const char *handle, char nick[MAX_NICK_LENGTH+1] )
     92{
     93        int inf_protection = 256;
    8494       
    8595        /* Now, find out if the nick is already in use at the moment, and make
     
    120130                }
    121131        }
    122        
    123         return nick;
    124132}
    125133
  • nick.h

    r54f2f55 rd06eabf  
    2626void nick_set( account_t *acc, const char *handle, const char *nick );
    2727char *nick_get( account_t *acc, const char *handle );
     28void nick_dedupe( account_t *acc, const char *handle, char nick[MAX_NICK_LENGTH+1] );
    2829int nick_saved( account_t *acc, const char *handle );
    2930void nick_del( account_t *acc, const char *handle );
  • protocols/jabber/conference.c

    r54f2f55 rd06eabf  
    160160                imcb_chat_add_buddy( chat, bud->ext_jid );
    161161                if( s ) *s = '/';
     162               
     163                if( bud != jc->me )
     164                        imcb_buddy_nick_hint( ic, bud->ext_jid, bud->resource );
    162165        }
    163166        else if( type ) /* This only gets called if type is NULL or "unavailable" */
  • protocols/jabber/iq.c

    r54f2f55 rd06eabf  
    373373                                                                   group->text : NULL );
    374374                               
    375                                 imcb_rename_buddy( ic, jid, name );
     375                                if( name )
     376                                {
     377                                        imcb_rename_buddy( ic, jid, name );
     378                                        imcb_buddy_nick_hint( ic, jid, name );
     379                                }
    376380                        }
    377381                        else if( strcmp( sub, "remove" ) == 0 )
  • protocols/nogaim.c

    r54f2f55 rd06eabf  
    428428{
    429429        user_t *u = user_findhandle( ic, handle );
    430         char *s, newnick[MAX_NICK_LENGTH+1];
    431430       
    432431        if( !u || !realname ) return;
     
    440439                if( ( ic->flags & OPT_LOGGED_IN ) && set_getbool( &ic->irc->set, "display_namechanges" ) )
    441440                        imcb_log( ic, "User `%s' changed name to `%s'", u->nick, u->realname );
    442                
    443                 if( !u->online && !nick_saved( ic->acc, handle ) )
    444                 {
    445                         /* Detect numeric handles: */
    446                         for( s = u->user; isdigit( *s ); s++ );
    447                        
    448                         if( *s == 0 )
    449                         {
    450                                 /* If we reached the end of the string, it only contained numbers.
    451                                    Seems to be an ICQ# then, so hopefully realname contains
    452                                    something more useful. */
    453                                 strcpy( newnick, realname );
    454                                
    455                                 /* Some processing to make sure this string is a valid IRC nickname. */
    456                                 nick_strip( newnick );
    457                                 if( set_getbool( &ic->irc->set, "lcnicks" ) )
    458                                         nick_lc( newnick );
    459                                
    460                                 u->nick = g_strdup( newnick );
    461                         }
    462                 }
    463         }
    464 }
    465 
     441        }
     442}
     443
     444/* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM
     445   modules to suggest a nickname for a handle. */
     446void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick )
     447{
     448        user_t *u = user_findhandle( ic, handle );
     449        char newnick[MAX_NICK_LENGTH+1];
     450       
     451        if( !u->online && !nick_saved( ic->acc, handle ) )
     452        {
     453                /* Only do this if the person isn't online yet (which should
     454                   be the case if we just added it) and if the user hasn't
     455                   assigned a nickname to this buddy already. */
     456               
     457                strcpy( newnick, nick );
     458               
     459                /* Some processing to make sure this string is a valid IRC nickname. */
     460                nick_strip( newnick );
     461                if( set_getbool( &ic->irc->set, "lcnicks" ) )
     462                        nick_lc( newnick );
     463               
     464                nick_dedupe( ic->acc, handle, newnick );
     465               
     466                u->nick = g_strdup( newnick );
     467        }
     468}
    466469
    467470/* prpl.c */
  • protocols/nogaim.h

    r54f2f55 rd06eabf  
    194194G_MODULE_EXPORT struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle );
    195195G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname );
     196G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, char *handle, char *nick );
    196197
    197198/* Buddy activity */
  • protocols/oscar/oscar.c

    r54f2f55 rd06eabf  
    20222022                                       
    20232023                                        if (realname) {
     2024                                                imcb_buddy_nick_hint(ic, curitem->name, realname);
    20242025                                                imcb_rename_buddy(ic, curitem->name, realname);
    20252026                                                g_free(realname);
Note: See TracChangeset for help on using the changeset viewer.