Ignore:
Timestamp:
2007-03-31T05:40:45Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
aef4828
Parents:
fa29d093
Message:

s/gaim_connection/im_connection/ and some other minor API changes. The rest
will come tomorrow. It compiles, I'll leave the real testing up to someone
else. ;-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/sasl.c

    rfa29d093 r0da65d5  
    2727xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )
    2828{
    29         struct gaim_connection *gc = data;
    30         struct jabber_data *jd = gc->proto_data;
     29        struct im_connection *ic = data;
     30        struct jabber_data *jd = ic->proto_data;
    3131        struct xt_node *c, *reply;
    3232        char *s;
    3333        int sup_plain = 0, sup_digest = 0;
    3434       
    35         if( !sasl_supported( gc ) )
     35        if( !sasl_supported( ic ) )
    3636        {
    3737                /* Should abort this now, since we should already be doing
    3838                   IQ authentication. Strange things happen when you try
    3939                   to do both... */
    40                 serv_got_crap( gc, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" );
     40                serv_got_crap( ic, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" );
    4141                return XT_HANDLED;
    4242        }
     
    4545        if( !s || strcmp( s, XMLNS_SASL ) != 0 )
    4646        {
    47                 signoff( gc );
     47                signoff( ic );
    4848                return XT_ABORT;
    4949        }
     
    6262        if( !sup_plain && !sup_digest )
    6363        {
    64                 hide_login_progress( gc, "No known SASL authentication schemes supported" );
    65                 signoff( gc );
     64                hide_login_progress( ic, "No known SASL authentication schemes supported" );
     65                signoff( ic );
    6666                return XT_ABORT;
    6767        }
     
    8383               
    8484                /* With SASL PLAIN in XMPP, the text should be b64(\0user\0pass) */
    85                 len = strlen( jd->username ) + strlen( gc->acc->pass ) + 2;
     85                len = strlen( jd->username ) + strlen( ic->acc->pass ) + 2;
    8686                s = g_malloc( len + 1 );
    8787                s[0] = 0;
    8888                strcpy( s + 1, jd->username );
    89                 strcpy( s + 2 + strlen( jd->username ), gc->acc->pass );
     89                strcpy( s + 2 + strlen( jd->username ), ic->acc->pass );
    9090                reply->text = base64_encode( s, len );
    9191                reply->text_len = strlen( reply->text );
     
    9393        }
    9494       
    95         if( !jabber_write_packet( gc, reply ) )
     95        if( !jabber_write_packet( ic, reply ) )
    9696        {
    9797                xt_free_node( reply );
     
    181181xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data )
    182182{
    183         struct gaim_connection *gc = data;
    184         struct jabber_data *jd = gc->proto_data;
     183        struct im_connection *ic = data;
     184        struct jabber_data *jd = ic->proto_data;
    185185        struct xt_node *reply = NULL;
    186186        char *nonce = NULL, *realm = NULL, *cnonce = NULL, cnonce_bin[30];
     
    222222                   I decided to call it H. */
    223223                md5_init( &H );
    224                 s = g_strdup_printf( "%s:%s:%s", jd->username, realm, gc->acc->pass );
     224                s = g_strdup_printf( "%s:%s:%s", jd->username, realm, ic->acc->pass );
    225225                md5_append( &H, (unsigned char *) s, strlen( s ) );
    226226                g_free( s );
     
    272272        xt_add_attr( reply, "xmlns", XMLNS_SASL );
    273273       
    274         if( !jabber_write_packet( gc, reply ) )
     274        if( !jabber_write_packet( ic, reply ) )
    275275                goto silent_error;
    276276       
     
    279279
    280280error:
    281         hide_login_progress( gc, "Incorrect SASL challenge received" );
    282         signoff( gc );
     281        hide_login_progress( ic, "Incorrect SASL challenge received" );
     282        signoff( ic );
    283283
    284284silent_error:
     
    296296xt_status sasl_pkt_result( struct xt_node *node, gpointer data )
    297297{
    298         struct gaim_connection *gc = data;
    299         struct jabber_data *jd = gc->proto_data;
     298        struct im_connection *ic = data;
     299        struct jabber_data *jd = ic->proto_data;
    300300        char *s;
    301301       
     
    303303        if( !s || strcmp( s, XMLNS_SASL ) != 0 )
    304304        {
    305                 signoff( gc );
     305                signoff( ic );
    306306                return XT_ABORT;
    307307        }
     
    309309        if( strcmp( node->name, "success" ) == 0 )
    310310        {
    311                 set_login_progress( gc, 1, "Authentication finished" );
     311                set_login_progress( ic, 1, "Authentication finished" );
    312312                jd->flags |= JFLAG_AUTHENTICATED | JFLAG_STREAM_RESTART;
    313313        }
    314314        else if( strcmp( node->name, "failure" ) == 0 )
    315315        {
    316                 hide_login_progress( gc, "Authentication failure" );
    317                 signoff( gc );
     316                hide_login_progress( ic, "Authentication failure" );
     317                signoff( ic );
    318318                return XT_ABORT;
    319319        }
     
    325325   It's done by checking if the <stream:stream> from the server has a
    326326   version attribute. I don't know if this is the right way though... */
    327 gboolean sasl_supported( struct gaim_connection *gc )
    328 {
    329         struct jabber_data *jd = gc->proto_data;
     327gboolean sasl_supported( struct im_connection *ic )
     328{
     329        struct jabber_data *jd = ic->proto_data;
    330330       
    331331        return ( (void*) ( jd->xt && jd->xt->root && xt_find_attr( jd->xt->root, "version" ) ) ) != NULL;
Note: See TracChangeset for help on using the changeset viewer.