Changeset 69cb623 for protocols/nogaim.c


Ignore:
Timestamp:
2006-10-15T09:41:12Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
2529faf
Parents:
695e392 (diff), e97827b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging with storage-xml. It seems to be working pretty well, so maybe
this way more people will test it. :-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r695e392 r69cb623  
    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}
     
    220207        va_end( params );
    221208
    222         if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) ||
    223             ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) )
     209        if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
     210            ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
    224211                strip_html( text );
    225212       
    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;
     
    297284        b_event_remove( gc->keepalive );
    298285        gc->flags |= OPT_LOGGING_OUT;
     286       
    299287        gc->keepalive = 0;
    300         gc->prpl->close( gc );
     288        gc->acc->prpl->close( gc );
    301289        b_event_remove( gc->inpa );
    302290       
     
    323311                /* Uhm... This is very sick. */
    324312        }
    325         else if( !gc->wants_to_die && set_getint( irc, "auto_reconnect" ) )
    326         {
    327                 int delay = set_getint( irc, "auto_reconnect_delay" );
     313        else if( !gc->wants_to_die && set_getbool( &irc->set, "auto_reconnect" ) &&
     314                 set_getbool( &a->set, "auto_reconnect" ) )
     315        {
     316                int delay = set_getint( &irc->set, "auto_reconnect_delay" );
    328317               
    329318                serv_got_crap( gc, "Reconnecting in %d seconds..", delay );
     
    364353        irc_t *irc = gc->irc;
    365354       
    366         if( set_getint( irc, "debug" ) && 0 ) /* This message is too useless */
     355        if( set_getbool( &irc->set, "debug" ) && 0 ) /* This message is too useless */
    367356                serv_got_crap( gc, "Receiving user add from handle: %s", handle );
    368357       
    369358        if( user_findhandle( gc, handle ) )
    370359        {
    371                 if( set_getint( irc, "debug" ) )
     360                if( set_getbool( &irc->set, "debug" ) )
    372361                        serv_got_crap( gc, "User already exists, ignoring add request: %s", handle );
    373362               
     
    378367       
    379368        memset( nick, 0, MAX_NICK_LENGTH + 1 );
    380         strcpy( nick, nick_get( gc->irc, handle, gc->prpl, realname ) );
     369        strcpy( nick, nick_get( gc->acc, handle, realname ) );
    381370       
    382371        u = user_add( gc->irc, nick );
     
    390379                u->user = g_strndup( handle, s - handle );
    391380        }
    392         else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0] )
     381        else if( gc->acc->server )
    393382        {
    394383                char *colon;
    395384               
    396                 if( ( colon = strchr( gc->user->proto_opt[0], ':' ) ) )
    397                         u->host = g_strndup( gc->user->proto_opt[0],
    398                                              colon - gc->user->proto_opt[0] );
     385                if( ( colon = strchr( gc->acc->server, ':' ) ) )
     386                        u->host = g_strndup( gc->acc->server,
     387                                             colon - gc->acc->server );
    399388                else
    400                         u->host = g_strdup( gc->user->proto_opt[0] );
     389                        u->host = g_strdup( gc->acc->server );
    401390               
    402391                u->user = g_strdup( handle );
     
    409398        else
    410399        {
    411                 u->host = g_strdup( gc->user->prpl->name );
     400                u->host = g_strdup( gc->acc->prpl->name );
    412401                u->user = g_strdup( handle );
    413402        }
     
    457446                u->realname = g_strdup( realname );
    458447               
    459                 if( ( gc->flags & OPT_LOGGED_IN ) && set_getint( gc->irc, "display_namechanges" ) )
     448                if( ( gc->flags & OPT_LOGGED_IN ) && set_getbool( &gc->irc->set, "display_namechanges" ) )
    460449                        serv_got_crap( gc, "User `%s' changed name to `%s'", u->nick, u->realname );
    461450        }
     
    479468void show_got_added_yes( gpointer w, struct show_got_added_data *data )
    480469{
    481         data->gc->prpl->add_buddy( data->gc, data->handle );
     470        data->gc->acc->prpl->add_buddy( data->gc, data->handle );
    482471        add_buddy( data->gc, NULL, data->handle, data->handle );
    483472       
     
    513502        if( !u )
    514503        {
    515                 if( g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "add" ) == 0 )
     504                if( g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "add" ) == 0 )
    516505                {
    517506                        add_buddy( gc, NULL, handle, NULL );
     
    520509                else
    521510                {
    522                         if( set_getint( gc->irc, "debug" ) || g_strcasecmp( set_getstr( gc->irc, "handle_unknown" ), "ignore" ) != 0 )
     511                        if( set_getbool( &gc->irc->set, "debug" ) || g_strcasecmp( set_getstr( &gc->irc->set, "handle_unknown" ), "ignore" ) != 0 )
    523512                        {
    524513                                serv_got_crap( gc, "serv_got_update() for handle %s:", handle );
     
    558547        }
    559548       
    560         if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "oscar") || !strcmp(gc->prpl->name, "icq")) )
     549        if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "oscar" ) == 0 || strcmp( gc->acc->prpl->name, "icq" ) == 0 ) )
    561550        {
    562551                u->away = g_strdup( "Away" );
    563552        }
    564         else if( ( type & UC_UNAVAILABLE ) && ( !strcmp(gc->prpl->name, "jabber") ) )
     553        else if( ( type & UC_UNAVAILABLE ) && ( strcmp( gc->acc->prpl->name, "jabber" ) == 0 ) )
    565554        {
    566555                if( type & UC_DND )
     
    571560                        u->away = g_strdup( "Away" );
    572561        }
    573         else if( ( type & UC_UNAVAILABLE ) && gc->prpl->get_status_string )
    574         {
    575                 u->away = g_strdup( gc->prpl->get_status_string( gc, type ) );
     562        else if( ( type & UC_UNAVAILABLE ) && gc->acc->prpl->get_status_string )
     563        {
     564                u->away = g_strdup( gc->acc->prpl->get_status_string( gc, type ) );
    576565        }
    577566        else
     
    579568       
    580569        /* LISPy... */
    581         if( ( set_getint( gc->irc, "away_devoice" ) ) &&                /* Don't do a thing when user doesn't want it */
     570        if( ( set_getbool( &gc->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
    582571            ( u->online ) &&                                            /* Don't touch offline people */
    583572            ( ( ( u->online != oo ) && !u->away ) ||                    /* Voice joining people */
     
    598587        if( !u )
    599588        {
    600                 char *h = set_getstr( irc, "handle_unknown" );
     589                char *h = set_getstr( &irc->set, "handle_unknown" );
    601590               
    602591                if( g_strcasecmp( h, "ignore" ) == 0 )
    603592                {
    604                         if( set_getint( irc, "debug" ) )
     593                        if( set_getbool( &irc->set, "debug" ) )
    605594                                serv_got_crap( gc, "Ignoring message from unknown handle %s", handle );
    606595                       
     
    609598                else if( g_strncasecmp( h, "add", 3 ) == 0 )
    610599                {
    611                         int private = set_getint( irc, "private" );
     600                        int private = set_getbool( &irc->set, "private" );
    612601                       
    613602                        if( h[3] )
     
    630619        }
    631620       
    632         if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) ||
    633             ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) )
     621        if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
     622            ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
    634623                strip_html( msg );
    635624
     
    671660        user_t *u;
    672661       
    673         if( !set_getint( gc->irc, "typing_notice" ) )
     662        if( !set_getbool( &gc->irc->set, "typing_notice" ) )
    674663                return;
    675664       
     
    693682        GList *ir;
    694683       
    695         if( set_getint( gc->irc, "debug" ) )
     684        if( set_getbool( &gc->irc->set, "debug" ) )
    696685                serv_got_crap( gc, "You were removed from conversation %d", (int) id );
    697686       
     
    732721       
    733722        /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */
    734         if( g_strcasecmp( who, gc->user->username ) == 0 )
     723        if( g_strcasecmp( who, gc->username ) == 0 )
    735724                return;
    736725       
     
    738727        for( c = gc->conversations; c && c->id != id; c = c->next );
    739728       
    740         if( ( g_strcasecmp( set_getstr( gc->irc, "strip_html" ), "always" ) == 0 ) ||
    741             ( ( gc->flags & OPT_CONN_HTML ) && set_getint( gc->irc, "strip_html" ) ) )
     729        if( ( g_strcasecmp( set_getstr( &gc->irc->set, "strip_html" ), "always" ) == 0 ) ||
     730            ( ( gc->flags & OPT_CONN_HTML ) && set_getbool( &gc->irc->set, "strip_html" ) ) )
    742731                strip_html( msg );
    743732       
     
    772761        g_free( s );
    773762       
    774         if( set_getint( gc->irc, "debug" ) )
     763        if( set_getbool( &gc->irc->set, "debug" ) )
    775764                serv_got_crap( gc, "Creating new conversation: (id=%d,handle=%s)", id, handle );
    776765       
     
    786775        int me = 0;
    787776       
    788         if( set_getint( b->gc->irc, "debug" ) )
     777        if( set_getbool( &b->gc->irc->set, "debug" ) )
    789778                serv_got_crap( b->gc, "User %s added to conversation %d", handle, b->id );
    790779       
    791780        /* It might be yourself! */
    792         if( b->gc->prpl->cmp_buddynames( handle, b->gc->user->username ) == 0 )
     781        if( b->gc->acc->prpl->handle_cmp( handle, b->gc->username ) == 0 )
    793782        {
    794783                u = user_find( b->gc->irc, b->gc->irc->nick );
     
    820809        int me = 0;
    821810       
    822         if( set_getint( b->gc->irc, "debug" ) )
     811        if( set_getbool( &b->gc->irc->set, "debug" ) )
    823812                serv_got_crap( b->gc, "User %s removed from conversation %d (%s)", handle, b->id, reason ? reason : "" );
    824813       
    825814        /* It might be yourself! */
    826         if( g_strcasecmp( handle, b->gc->user->username ) == 0 )
     815        if( g_strcasecmp( handle, b->gc->username ) == 0 )
    827816        {
    828817                u = user_find( b->gc->irc, b->gc->irc->nick );
     
    882871}
    883872
    884 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value )
    885 {
     873char *set_eval_away_devoice( set_t *set, char *value )
     874{
     875        irc_t *irc = set->data;
    886876        int st;
    887877       
     
    897887        /* Horror.... */
    898888       
    899         if( st != set_getint( irc, "away_devoice" ) )
     889        if( st != set_getbool( &irc->set, "away_devoice" ) )
    900890        {
    901891                char list[80] = "";
     
    937927        }
    938928       
    939         return( set_eval_bool( irc, set, value ) );
     929        return( set_eval_bool( set, value ) );
    940930}
    941931
     
    957947        }
    958948       
    959         st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );
     949        st = gc->acc->prpl->send_im( gc, handle, msg, strlen( msg ), flags );
    960950        g_free( buf );
    961951       
     
    974964        }
    975965       
    976         st = gc->prpl->chat_send( gc, id, msg );
     966        st = gc->acc->prpl->chat_send( gc, id, msg );
    977967        g_free( buf );
    978968       
     
    988978       
    989979        if( !away ) away = "";
    990         ms = m = gc->prpl->away_states( gc );
     980        ms = m = gc->acc->prpl->away_states( gc );
    991981       
    992982        while( m )
     
    1009999        if( m )
    10101000        {
    1011                 gc->prpl->set_away( gc, m->data, *away ? away : NULL );
     1001                gc->acc->prpl->set_away( gc, m->data, *away ? away : NULL );
    10121002        }
    10131003        else
     
    10161006                if( s )
    10171007                {
    1018                         gc->prpl->set_away( gc, s, away );
    1019                         if( set_getint( gc->irc, "debug" ) )
     1008                        gc->acc->prpl->set_away( gc, s, away );
     1009                        if( set_getbool( &gc->irc->set, "debug" ) )
    10201010                                serv_got_crap( gc, "Setting away state to %s", s );
    10211011                }
    10221012                else
    1023                         gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );
     1013                        gc->acc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );
    10241014        }
    10251015       
     
    10731063void bim_add_allow( struct gaim_connection *gc, char *handle )
    10741064{
    1075         if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL )
     1065        if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL )
    10761066        {
    10771067                gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) );
    10781068        }
    10791069       
    1080         gc->prpl->add_permit( gc, handle );
     1070        gc->acc->prpl->add_permit( gc, handle );
    10811071}
    10821072
     
    10851075        GSList *l;
    10861076       
    1087         if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) )
     1077        if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) )
    10881078        {
    10891079                g_free( l->data );
     
    10911081        }
    10921082       
    1093         gc->prpl->rem_permit( gc, handle );
     1083        gc->acc->prpl->rem_permit( gc, handle );
    10941084}
    10951085
    10961086void bim_add_block( struct gaim_connection *gc, char *handle )
    10971087{
    1098         if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL )
     1088        if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) == NULL )
    10991089        {
    11001090                gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) );
    11011091        }
    11021092       
    1103         gc->prpl->add_deny( gc, handle );
     1093        gc->acc->prpl->add_deny( gc, handle );
    11041094}
    11051095
     
    11081098        GSList *l;
    11091099       
    1110         if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) )
     1100        if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->acc->prpl->handle_cmp ) ) )
    11111101        {
    11121102                g_free( l->data );
     
    11141104        }
    11151105       
    1116         gc->prpl->rem_deny( gc, handle );
    1117 }
     1106        gc->acc->prpl->rem_deny( gc, handle );
     1107}
Note: See TracChangeset for help on using the changeset viewer.