Changeset e8c8d00 for protocols/jabber


Ignore:
Timestamp:
2010-03-17T15:15:19Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
60e4df3
Parents:
1c3008a (diff), f9928cb (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 mainline.

Location:
protocols/jabber
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    r1c3008a re8c8d00  
    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         }
    401        
    402         /* This flag is already set if we authenticated via SASL, so now
    403            we can resume the session in the new stream, if we don't have
    404            to bind/initialize the session. */
    405         if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
    406         {
    407                 if( !jabber_get_roster( ic ) )
    408                         return XT_ABORT;
    409         }
     380                jd->flags |= JFLAG_WANT_SESSION;
     381       
     382        if( jd->flags & JFLAG_AUTHENTICATED )
     383                return jabber_pkt_bind_sess( ic, NULL, NULL );
    410384       
    411385        return XT_HANDLED;
     
    441415        imcb_log( ic, "Converting stream to TLS" );
    442416       
     417        jd->flags |= JFLAG_STARTTLS_DONE;
    443418        jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, ic );
    444419       
     
    531506                jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, ic );
    532507       
    533         greet = g_strdup_printf( "<?xml version='1.0' ?>"
    534                                  "<stream:stream to=\"%s\" xmlns=\"jabber:client\" "
    535                                   "xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">", jd->server );
     508        greet = g_strdup_printf( "%s<stream:stream to=\"%s\" xmlns=\"jabber:client\" "
     509                                  "xmlns:stream=\"http://etherx.jabber.org/streams\" version=\"1.0\">",
     510                                  ( jd->flags & JFLAG_STARTTLS_DONE ) ? "" : "<?xml version='1.0' ?>",
     511                                  jd->server );
    536512       
    537513        st = jabber_write( ic, greet, strlen( greet ) );
  • protocols/jabber/iq.c

    r1c3008a re8c8d00  
    310310{
    311311        struct jabber_data *jd = ic->proto_data;
    312         struct xt_node *c;
     312        struct xt_node *c, *reply = NULL;
    313313        char *s;
    314314       
    315         if( ( c = xt_find_node( node->children, "bind" ) ) )
     315        if( node && ( c = xt_find_node( node->children, "bind" ) ) )
    316316        {
    317317                c = xt_find_node( c->children, "jid" );
     
    319319                    strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 )
    320320                        imcb_log( ic, "Server changed session resource string to `%s'", s + 1 );
    321                
    322                 jd->flags &= ~JFLAG_WAIT_BIND;
    323         }
    324         else
    325         {
    326                 jd->flags &= ~JFLAG_WAIT_SESSION;
    327         }
    328        
    329         if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
     321        }
     322       
     323        if( jd->flags & JFLAG_WANT_BIND )
     324        {
     325                reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) );
     326                xt_add_attr( reply, "xmlns", XMLNS_BIND );
     327                jd->flags &= ~JFLAG_WANT_BIND;
     328        }
     329        else if( jd->flags & JFLAG_WANT_SESSION )
     330        {
     331                reply = xt_new_node( "session", NULL, NULL );
     332                xt_add_attr( reply, "xmlns", XMLNS_SESSION );
     333                jd->flags &= ~JFLAG_WANT_SESSION;
     334        }
     335       
     336        if( reply != NULL )
     337        {
     338                reply = jabber_make_packet( "iq", "set", NULL, reply );
     339                jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
     340               
     341                if( !jabber_write_packet( ic, reply ) )
     342                        return XT_ABORT;
     343        }
     344        else if( ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 )
    330345        {
    331346                if( !jabber_get_roster( ic ) )
  • protocols/jabber/jabber.c

    r1c3008a re8c8d00  
    6969        s->flags |= ACC_SET_OFFLINE_ONLY;
    7070       
    71         s = set_add( &acc->set, "resource_select", "priority", NULL, acc );
     71        s = set_add( &acc->set, "resource_select", "activity", NULL, acc );
    7272       
    7373        s = set_add( &acc->set, "server", NULL, set_eval_account, acc );
     
    8282        s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc );
    8383        s->flags |= ACC_SET_OFFLINE_ONLY;
     84       
     85        acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE;
    8486}
    8587
     
    378380        while( bud )
    379381        {
    380                 imcb_log( ic, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s",
    381                                    bud->full_jid, bud->priority,
    382                                    bud->away_state ? bud->away_state->full_name : "(none)",
    383                                    bud->away_message ? : "(none)" );
     382                imcb_log( ic, "Buddy %s (%d) information:", bud->full_jid, bud->priority );
     383                if( bud->away_state )
     384                        imcb_log( ic, "Away state: %s", bud->away_state->full_name );
     385                imcb_log( ic, "Status message: %s", bud->away_message ? : "(none)" );
     386               
    384387                bud = bud->next;
    385388        }
     
    391394{
    392395        struct jabber_data *jd = ic->proto_data;
    393         struct jabber_away_state *state;
    394        
    395         /* Save all this info. We need it, for example, when changing the priority setting. */
    396         state = (void *) jabber_away_state_by_name( state_txt );
    397         jd->away_state = state ? state : (void *) jabber_away_state_list; /* Fall back to "Away" if necessary. */
     396       
     397        /* state_txt == NULL -> Not away.
     398           Unknown state -> fall back to the first defined away state. */
     399        jd->away_state = state_txt ? jabber_away_state_by_name( state_txt )
     400                         ? : jabber_away_state_list : NULL;
     401       
    398402        g_free( jd->away_message );
    399403        jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL;
  • protocols/jabber/jabber.h

    r1c3008a re8c8d00  
    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. */
    4747        JFLAG_XMLCONSOLE = 64,          /* If the user added an xmlconsole buddy. */
     48        JFLAG_STARTTLS_DONE = 128,      /* If a plaintext session was converted to TLS. */
    4849} jabber_flags_t;
    4950
     
    9293        /* After changing one of these two (or the priority setting), call
    9394           presence_send_update() to inform the server about the changes. */
    94         struct jabber_away_state *away_state;
     95        const struct jabber_away_state *away_state;
    9596        char *away_message;
    9697       
  • protocols/jabber/jabber_util.c

    r1c3008a re8c8d00  
    232232{
    233233        { "away",  "Away" },
    234         { "chat",  "Free for Chat" },
     234        { "chat",  "Free for Chat" },   /* WTF actually uses this? */
    235235        { "dnd",   "Do not Disturb" },
    236236        { "xa",    "Extended Away" },
    237         { "",      "Online" },
    238237        { "",      NULL }
    239238};
     
    242241{
    243242        int i;
     243       
     244        if( code == NULL )
     245                return NULL;
    244246       
    245247        for( i = 0; jabber_away_state_list[i].full_name; i ++ )
     
    253255{
    254256        int i;
     257       
     258        if( name == NULL )
     259                return NULL;
    255260       
    256261        for( i = 0; jabber_away_state_list[i].full_name; i ++ )
  • protocols/jabber/presence.c

    r1c3008a re8c8d00  
    190190                int is_away = 0;
    191191
    192                 if( send_presence->away_state && !( *send_presence->away_state->code == 0 ||
    193                     strcmp( send_presence->away_state->code, "chat" ) == 0 ) )
     192                if( send_presence->away_state &&
     193                    strcmp( send_presence->away_state->code, "chat" ) != 0 )
    194194                        is_away = OPT_AWAY;
    195195
    196196                imcb_buddy_status( ic, send_presence->bare_jid, OPT_LOGGED_IN | is_away,
    197                                    ( is_away && send_presence->away_state ) ?
    198                                    send_presence->away_state->full_name : NULL,
     197                                   is_away ? send_presence->away_state->full_name : NULL,
    199198                                   send_presence->away_message );
    200199        }
     
    209208        struct jabber_data *jd = ic->proto_data;
    210209        struct xt_node *node, *cap;
    211         char *show = jd->away_state->code;
    212         char *status = jd->away_message;
    213210        struct groupchat *c;
    214211        int st;
     
    216213        node = jabber_make_packet( "presence", NULL, NULL, NULL );
    217214        xt_add_child( node, xt_new_node( "priority", set_getstr( &ic->acc->set, "priority" ), NULL ) );
    218         if( show && *show )
    219                 xt_add_child( node, xt_new_node( "show", show, NULL ) );
    220         if( status )
    221                 xt_add_child( node, xt_new_node( "status", status, NULL ) );
     215        if( jd->away_state )
     216                xt_add_child( node, xt_new_node( "show", jd->away_state->code, NULL ) );
     217        if( jd->away_message )
     218                xt_add_child( node, xt_new_node( "status", jd->away_message, NULL ) );
    222219       
    223220        /* This makes the packet slightly bigger, but clients interested in
Note: See TracChangeset for help on using the changeset viewer.