Changeset 0a3c243 for protocols/nogaim.c


Ignore:
Timestamp:
2006-06-30T23:18:56Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
5100caa
Parents:
5c9512f
Message:

Got rid of struct aim_user (now using account_t everywhere). Needs some more
testing though.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r5c9512f r0a3c243  
    145145/* multi.c */
    146146
    147 struct gaim_connection *new_gaim_conn( struct aim_user *user )
     147struct gaim_connection *new_gaim_conn( account_t *acc )
    148148{
    149149        struct gaim_connection *gc;
    150         account_t *a;
    151150       
    152151        gc = g_new0( struct gaim_connection, 1 );
    153152       
    154         gc->prpl = user->prpl;
    155         g_snprintf( gc->username, sizeof( gc->username ), "%s", user->username );
    156         g_snprintf( gc->password, sizeof( gc->password ), "%s", user->password );
    157         /* [MD] BUGFIX: don't set gc->irc to the global IRC, but use the one from the struct aim_user.
    158          * This fixes daemon mode breakage where IRC doesn't point to the currently active connection.
    159          */
    160         gc->irc = user->irc;
     153        /* Maybe we should get rid of this memory waste later. ;-) */
     154        g_snprintf( gc->username, sizeof( gc->username ), "%s", acc->user );
     155        g_snprintf( gc->password, sizeof( gc->password ), "%s", acc->pass );
     156       
     157        gc->irc = acc->irc;
     158        gc->acc = acc;
     159        acc->gc = gc;
    161160       
    162161        connections = g_slist_append( connections, gc );
    163        
    164         user->gc = gc;
    165         gc->user = user;
    166        
    167         // Find the account_t so we can set its gc pointer
    168         for( a = gc->irc->accounts; a; a = a->next )
    169                 if( ( struct aim_user * ) a->gc == user )
    170                 {
    171                         a->gc = gc;
    172                         break;
    173                 }
    174162       
    175163        return( gc );
     
    189177       
    190178        connections = g_slist_remove( connections, gc );
    191         g_free( gc->user );
    192179        g_free( gc );
    193180}
     
    226213        /* Try to find a different connection on the same protocol. */
    227214        for( a = gc->irc->accounts; a; a = a->next )
    228                 if( a->prpl == gc->prpl && a->gc != gc )
     215                if( a->prpl == gc->acc->prpl && a->gc != gc )
    229216                        break;
    230217       
    231218        /* If we found one, include the screenname in the message. */
    232219        if( a )
    233                 irc_usermsg( gc->irc, "%s(%s) - %s", gc->prpl->name, gc->username, text );
     220                irc_usermsg( gc->irc, "%s(%s) - %s", gc->acc->prpl->name, gc->username, text );
    234221        else
    235                 irc_usermsg( gc->irc, "%s - %s", gc->prpl->name, text );
     222                irc_usermsg( gc->irc, "%s - %s", gc->acc->prpl->name, text );
    236223       
    237224        g_free( text );
     
    242229        struct gaim_connection *gc = d;
    243230       
    244         if( gc->prpl && gc->prpl->keepalive )
    245                 gc->prpl->keepalive( gc );
     231        if( gc->acc->prpl->keepalive )
     232                gc->acc->prpl->keepalive( gc );
    246233       
    247234        return TRUE;
     
    299286       
    300287        gc->keepalive = 0;
    301         gc->prpl->close( gc );
     288        gc->acc->prpl->close( gc );
    302289        b_event_remove( gc->inpa );
    303290       
     
    379366       
    380367        memset( nick, 0, MAX_NICK_LENGTH + 1 );
    381         strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) );
     368        strcpy( nick, nick_get( gc->irc, handle, gc->acc->prpl, realname ) );
    382369       
    383370        u = user_add( gc->irc, nick );
     
    391378                u->user = g_strndup( handle, s - handle );
    392379        }
    393         else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0] )
     380        else if( *gc->acc->server )
    394381        {
    395382                char *colon;
    396383               
    397                 if( ( colon = strchr( gc->user->proto_opt[0], ':' ) ) )
    398                         u->host = g_strndup( gc->user->proto_opt[0],
    399                                              colon - gc->user->proto_opt[0] );
     384                if( ( colon = strchr( gc->acc->server, ':' ) ) )
     385                        u->host = g_strndup( gc->acc->server,
     386                                             colon - gc->acc->server );
    400387                else
    401                         u->host = g_strdup( gc->user->proto_opt[0] );
     388                        u->host = g_strdup( gc->acc->server );
    402389               
    403390                u->user = g_strdup( handle );
     
    410397        else
    411398        {
    412                 u->host = g_strdup( gc->user->prpl->name );
     399                u->host = g_strdup( gc->acc->prpl->name );
    413400                u->user = g_strdup( handle );
    414401        }
     
    480467void show_got_added_yes( gpointer w, struct show_got_added_data *data )
    481468{
    482         data->gc->prpl->add_buddy( data->gc, data->handle );
     469        data->gc->acc->prpl->add_buddy( data->gc, data->handle );
    483470        add_buddy( data->gc, NULL, data->handle, data->handle );
    484471       
     
    559546        }
    560547       
    561         if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) )
     548        if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "oscar" ) == 0 || strcmp( gc->acc->prpl->name, "icq" ) == 0 ) )
    562549        {
    563550                u->away = g_strdup( "Away" );
    564551        }
    565         else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) )
     552        else if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "jabber" ) == 0 ) )
    566553        {
    567554                if( type & UC_DND )
     
    572559                        u->away = g_strdup( "Away" );
    573560        }
    574         else if( ( type & UC_UNAVAILABLE ) && gc->prpl->get_status_string )
    575         {
    576                 u->away = g_strdup( gc->prpl->get_status_string( gc, type ) );
     561        else if( ( type & UC_UNAVAILABLE ) && gc->acc->prpl->get_status_string )
     562        {
     563                u->away = g_strdup( gc->acc->prpl->get_status_string( gc, type ) );
    577564        }
    578565        else
     
    733720       
    734721        /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */
    735         if( g_strcasecmp( who, gc->user->username ) == 0 )
     722        if( g_strcasecmp( who, gc->username ) == 0 )
    736723                return;
    737724       
     
    791778       
    792779        /* It might be yourself! */
    793         if( b->gc->prpl->cmp_buddynames( handle, b->gc->user->username ) == 0 )
     780        if( b->gc->acc->prpl->cmp_buddynames( handle, b->gc->username ) == 0 )
    794781        {
    795782                u = user_find( b->gc->irc, b->gc->irc->nick );
     
    825812       
    826813        /* It might be yourself! */
    827         if( g_strcasecmp( handle, b->gc->user->username ) == 0 )
     814        if( g_strcasecmp( handle, b->gc->username ) == 0 )
    828815        {
    829816                u = user_find( b->gc->irc, b->gc->irc->nick );
     
    959946        }
    960947       
    961         st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );
     948        st = gc->acc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );
    962949        g_free( buf );
    963950       
     
    976963        }
    977964       
    978         st = gc->prpl->chat_send( gc, id, msg );
     965        st = gc->acc->prpl->chat_send( gc, id, msg );
    979966        g_free( buf );
    980967       
     
    990977       
    991978        if( !away ) away = "";
    992         ms = m = gc->prpl->away_states( gc );
     979        ms = m = gc->acc->prpl->away_states( gc );
    993980       
    994981        while( m )
     
    1011998        if( m )
    1012999        {
    1013                 gc->prpl->set_away( gc, m->data, *away ? away : NULL );
     1000                gc->acc->prpl->set_away( gc, m->data, *away ? away : NULL );
    10141001        }
    10151002        else
     
    10181005                if( s )
    10191006                {
    1020                         gc->prpl->set_away( gc, s, away );
     1007                        gc->acc->prpl->set_away( gc, s, away );
    10211008                        if( set_getint( &gc->irc->set, "debug" ) )
    10221009                                serv_got_crap( gc, "Setting away state to %s", s );
    10231010                }
    10241011                else
    1025                         gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );
     1012                        gc->acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );
    10261013        }
    10271014       
     
    10751062void bim_add_allow( struct gaim_connection *gc, char *handle )
    10761063{
    1077         if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL )
     1064        if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) == NULL )
    10781065        {
    10791066                gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) );
    10801067        }
    10811068       
    1082         gc->prpl->add_permit( gc, handle );
     1069        gc->acc->prpl->add_permit( gc, handle );
    10831070}
    10841071
     
    10871074        GSList *l;
    10881075       
    1089         if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) )
     1076        if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) ) )
    10901077        {
    10911078                g_free( l->data );
     
    10931080        }
    10941081       
    1095         gc->prpl->rem_permit( gc, handle );
     1082        gc->acc->prpl->rem_permit( gc, handle );
    10961083}
    10971084
    10981085void bim_add_block( struct gaim_connection *gc, char *handle )
    10991086{
    1100         if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL )
     1087        if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) == NULL )
    11011088        {
    11021089                gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) );
    11031090        }
    11041091       
    1105         gc->prpl->add_deny( gc, handle );
     1092        gc->acc->prpl->add_deny( gc, handle );
    11061093}
    11071094
     
    11101097        GSList *l;
    11111098       
    1112         if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) )
     1099        if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->cmp_buddynames ) ) )
    11131100        {
    11141101                g_free( l->data );
     
    11161103        }
    11171104       
    1118         gc->prpl->rem_deny( gc, handle );
    1119 }
     1105        gc->acc->prpl->rem_deny( gc, handle );
     1106}
Note: See TracChangeset for help on using the changeset viewer.