Changeset 8fb1263


Ignore:
Timestamp:
2010-03-14T17:45:33Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
fb00989
Parents:
af7f046
Message:

Don't send bind and session requests at the same time when logging in
because some very picky jabberd's don't like it. (Fixes Bug #569)

Location:
protocols/jabber
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    raf7f046 r8fb1263  
    375375       
    376376        if( ( c = xt_find_node( node->children, "bind" ) ) )
    377         {
    378                 reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) );
    379                 xt_add_attr( reply, "xmlns", XMLNS_BIND );
    380                 reply = jabber_make_packet( "iq", "set", NULL, reply );
    381                 jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
    382                
    383                 if( !jabber_write_packet( ic, reply ) )
    384                         return XT_ABORT;
    385                
    386                 jd->flags |= JFLAG_WAIT_BIND;
    387         }
     377                jd->flags |= JFLAG_WANT_BIND;
    388378       
    389379        if( ( c = xt_find_node( node->children, "session" ) ) )
    390         {
    391                 reply = xt_new_node( "session", NULL, NULL );
    392                 xt_add_attr( reply, "xmlns", XMLNS_SESSION );
    393                 reply = jabber_make_packet( "iq", "set", NULL, reply );
    394                 jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
    395                
    396                 if( !jabber_write_packet( ic, reply ) )
    397                         return XT_ABORT;
    398                
    399                 jd->flags |= JFLAG_WAIT_SESSION;
    400         }
     380                jd->flags |= JFLAG_WANT_SESSION;
    401381       
    402382        /* This flag is already set if we authenticated via SASL, so now
    403383           we can resume the session in the new stream, if we don't have
    404384           to bind/initialize the session. */
    405         if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
     385        if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 )
    406386        {
    407387                if( !jabber_get_roster( ic ) )
    408388                        return XT_ABORT;
     389        }
     390        else if( jd->flags & JFLAG_AUTHENTICATED )
     391        {
     392                return jabber_pkt_bind_sess( ic, NULL, NULL );
    409393        }
    410394       
  • protocols/jabber/iq.c

    raf7f046 r8fb1263  
    298298{
    299299        struct jabber_data *jd = ic->proto_data;
    300         struct xt_node *c;
     300        struct xt_node *c, *reply = NULL;
    301301        char *s;
    302302       
    303         if( ( c = xt_find_node( node->children, "bind" ) ) )
     303        if( node && ( c = xt_find_node( node->children, "bind" ) ) )
    304304        {
    305305                c = xt_find_node( c->children, "jid" );
     
    308308                        imcb_log( ic, "Server changed session resource string to `%s'", s + 1 );
    309309               
    310                 jd->flags &= ~JFLAG_WAIT_BIND;
    311         }
    312         else
    313         {
    314                 jd->flags &= ~JFLAG_WAIT_SESSION;
    315         }
    316        
    317         if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
     310                jd->flags &= ~JFLAG_WANT_BIND;
     311        }
     312        else if( node && ( c = xt_find_node( node->children, "session" ) ) )
     313        {
     314                jd->flags &= ~JFLAG_WANT_SESSION;
     315        }
     316       
     317        if( jd->flags & JFLAG_WANT_BIND )
     318        {
     319                reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) );
     320                xt_add_attr( reply, "xmlns", XMLNS_BIND );
     321        }
     322        else if( jd->flags & JFLAG_WANT_SESSION )
     323        {
     324                reply = xt_new_node( "session", NULL, NULL );
     325                xt_add_attr( reply, "xmlns", XMLNS_SESSION );
     326        }
     327       
     328        if( reply != NULL )
     329        {
     330                reply = jabber_make_packet( "iq", "set", NULL, reply );
     331                jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
     332               
     333                if( !jabber_write_packet( ic, reply ) )
     334                        return XT_ABORT;
     335        }
     336        else if( ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 )
    318337        {
    319338                if( !jabber_get_roster( ic ) )
  • protocols/jabber/jabber.h

    raf7f046 r8fb1263  
    4040        JFLAG_STREAM_RESTART = 4,       /* Set when we want to restart the stream (after
    4141                                           SASL or TLS). */
    42         JFLAG_WAIT_SESSION = 8,         /* Set if we sent a <session> tag and need a reply
     42        JFLAG_WANT_SESSION = 8,         /* Set if the server wants a <session/> tag
    4343                                           before we continue. */
    44         JFLAG_WAIT_BIND = 16,           /* ... for <bind> tag. */
     44        JFLAG_WANT_BIND = 16,           /* ... for <bind> tag. */
    4545        JFLAG_WANT_TYPING = 32,         /* Set if we ever sent a typing notification, this
    4646                                           activates all XEP-85 related code. */
Note: See TracChangeset for help on using the changeset viewer.