Changeset f0cb961 for protocols/nogaim.c


Ignore:
Timestamp:
2007-04-19T06:03:43Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d323394c
Parents:
33dc261
Message:

More API changes: buddy list management. imcb_add_buddy() is now a *real*
callback, it's only called from inside IM-modules. This makes sure a buddy
only gets added to the BitlBee structures if the add was successful. This
gets rid of the weirdness described in #55. Unfortunately for now this
change breaks A) automatic renaming of ICQ contacts (if there are names
stored in the contact list) B) add -tmp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r33dc261 rf0cb961  
    352352/* list.c */
    353353
    354 void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname )
     354void imcb_add_buddy( struct im_connection *ic, char *handle, char *group )
    355355{
    356356        user_t *u;
    357         char nick[MAX_NICK_LENGTH+1];
    358         char *s;
     357        char nick[MAX_NICK_LENGTH+1], *s;
    359358        irc_t *irc = ic->irc;
    360        
    361         if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */
    362                 imcb_log( ic, "Receiving user add from handle: %s", handle );
    363359       
    364360        if( user_findhandle( ic, handle ) )
     
    369365                return;
    370366               
    371                 /* Buddy seems to exist already. Let's ignore this request then... */
     367                /* Buddy seems to exist already. Let's ignore this request then...
     368                   Eventually subsequent calls to this function *should* be possible
     369                   when a buddy is in multiple groups. But for now BitlBee doesn't
     370                   even support groups so let's silently ignore this for now. */
    372371        }
    373372       
    374373        memset( nick, 0, MAX_NICK_LENGTH + 1 );
    375         strcpy( nick, nick_get( ic->acc, handle, realname ) );
     374        strcpy( nick, nick_get( ic->acc, handle, NULL ) );
    376375       
    377376        u = user_add( ic->irc, nick );
    378377       
    379         if( !realname || !*realname ) realname = nick;
    380         u->realname = g_strdup( realname );
     378//      if( !realname || !*realname ) realname = nick;
     379//      u->realname = g_strdup( realname );
    381380       
    382381        if( ( s = strchr( handle, '@' ) ) )
     
    387386        else if( ic->acc->server )
    388387        {
    389                 char *colon;
    390                
    391                 if( ( colon = strchr( ic->acc->server, ':' ) ) )
    392                         u->host = g_strndup( ic->acc->server,
    393                                              colon - ic->acc->server );
    394                 else
    395                         u->host = g_strdup( ic->acc->server );
    396                
     388                u->host = g_strdup( ic->acc->server );
    397389                u->user = g_strdup( handle );
    398390               
     
    415407}
    416408
    417 struct buddy *find_buddy( struct im_connection *ic, char *handle )
     409struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle )
    418410{
    419411        static struct buddy b[1];
     
    435427
    436428
    437 void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname )
     429void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname )
    438430{
    439431        user_t *u = user_findhandle( ic, handle );
    440432       
    441         if( !u ) return;
     433        if( !u || !realname ) return;
    442434       
    443435        if( g_strcasecmp( u->realname, realname ) != 0 )
     
    470462{
    471463        data->ic->acc->prpl->add_buddy( data->ic, data->handle, NULL );
    472         add_buddy( data->ic, NULL, data->handle, data->handle );
     464        /* imcb_add_buddy( data->ic, NULL, data->handle, data->handle ); */
    473465       
    474466        return show_got_added_no( w, data );
     
    505497                if( g_strcasecmp( set_getstr( &ic->irc->set, "handle_unknown" ), "add" ) == 0 )
    506498                {
    507                         add_buddy( ic, NULL, (char*) handle, NULL );
     499                        imcb_add_buddy( ic, (char*) handle, NULL );
    508500                        u = user_findhandle( ic, (char*) handle );
    509501                }
     
    609601                        }
    610602                       
    611                         add_buddy( ic, NULL, handle, NULL );
     603                        imcb_add_buddy( ic, handle, NULL );
    612604                        u = user_findhandle( ic, handle );
    613605                        u->is_private = private;
     
    779771        if( !u )
    780772        {
    781                 add_buddy( b->ic, NULL, handle, NULL );
     773                imcb_add_buddy( b->ic, handle, NULL );
    782774                u = user_findhandle( b->ic, handle );
    783775        }
Note: See TracChangeset for help on using the changeset viewer.