Changeset 5f8ab6a9 for protocols/jabber


Ignore:
Timestamp:
2010-06-03T10:41:03Z (15 years ago)
Author:
Sven Moritz Hallberg <pesco@…>
Branches:
master
Children:
814aa52
Parents:
3f81999 (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:

merge in bitlbee 1.2.5

Location:
protocols/jabber
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    r3f81999 r5f8ab6a9  
    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

    r3f81999 r5f8ab6a9  
    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" );
     
    307307                    strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 )
    308308                        imcb_log( ic, "Server changed session resource string to `%s'", s + 1 );
    309                
    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 )
     309        }
     310       
     311        if( jd->flags & JFLAG_WANT_BIND )
     312        {
     313                reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) );
     314                xt_add_attr( reply, "xmlns", XMLNS_BIND );
     315                jd->flags &= ~JFLAG_WANT_BIND;
     316        }
     317        else if( jd->flags & JFLAG_WANT_SESSION )
     318        {
     319                reply = xt_new_node( "session", NULL, NULL );
     320                xt_add_attr( reply, "xmlns", XMLNS_SESSION );
     321                jd->flags &= ~JFLAG_WANT_SESSION;
     322        }
     323       
     324        if( reply != NULL )
     325        {
     326                reply = jabber_make_packet( "iq", "set", NULL, reply );
     327                jabber_cache_add( ic, reply, jabber_pkt_bind_sess );
     328               
     329                if( !jabber_write_packet( ic, reply ) )
     330                        return XT_ABORT;
     331        }
     332        else if( ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 )
    318333        {
    319334                if( !jabber_get_roster( ic ) )
  • protocols/jabber/jabber.c

    r3f81999 r5f8ab6a9  
    6767        s->flags |= ACC_SET_OFFLINE_ONLY;
    6868       
    69         s = set_add( &acc->set, "resource_select", "priority", NULL, acc );
     69        s = set_add( &acc->set, "resource_select", "activity", NULL, acc );
    7070       
    7171        s = set_add( &acc->set, "server", NULL, set_eval_account, acc );
     
    8080        s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc );
    8181        s->flags |= ACC_SET_OFFLINE_ONLY;
     82       
     83        acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE;
    8284}
    8385
     
    364366        while( bud )
    365367        {
    366                 imcb_log( ic, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s",
    367                                    bud->full_jid, bud->priority,
    368                                    bud->away_state ? bud->away_state->full_name : "(none)",
    369                                    bud->away_message ? : "(none)" );
     368                imcb_log( ic, "Buddy %s (%d) information:", bud->full_jid, bud->priority );
     369                if( bud->away_state )
     370                        imcb_log( ic, "Away state: %s", bud->away_state->full_name );
     371                imcb_log( ic, "Status message: %s", bud->away_message ? : "(none)" );
     372               
    370373                bud = bud->next;
    371374        }
     
    377380{
    378381        struct jabber_data *jd = ic->proto_data;
    379         struct jabber_away_state *state;
    380        
    381         /* Save all this info. We need it, for example, when changing the priority setting. */
    382         state = (void *) jabber_away_state_by_name( state_txt );
    383         jd->away_state = state ? state : (void *) jabber_away_state_list; /* Fall back to "Away" if necessary. */
     382       
     383        /* state_txt == NULL -> Not away.
     384           Unknown state -> fall back to the first defined away state. */
     385        jd->away_state = state_txt ? jabber_away_state_by_name( state_txt )
     386                         ? : jabber_away_state_list : NULL;
     387       
    384388        g_free( jd->away_message );
    385389        jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL;
  • protocols/jabber/jabber.h

    r3f81999 r5f8ab6a9  
    2727#include <glib.h>
    2828
     29#include "bitlbee.h"
     30#include "md5.h"
    2931#include "xmltree.h"
    30 #include "bitlbee.h"
    3132
    3233extern GSList *jabber_connections;
     
    3940        JFLAG_STREAM_RESTART = 4,       /* Set when we want to restart the stream (after
    4041                                           SASL or TLS). */
    41         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
    4243                                           before we continue. */
    43         JFLAG_WAIT_BIND = 16,           /* ... for <bind> tag. */
     44        JFLAG_WANT_BIND = 16,           /* ... for <bind> tag. */
    4445        JFLAG_WANT_TYPING = 32,         /* Set if we ever sent a typing notification, this
    4546                                           activates all XEP-85 related code. */
    4647        JFLAG_XMLCONSOLE = 64,          /* If the user added an xmlconsole buddy. */
     48        JFLAG_STARTTLS_DONE = 128,      /* If a plaintext session was converted to TLS. */
    4749} jabber_flags_t;
    4850
     
    8385        /* After changing one of these two (or the priority setting), call
    8486           presence_send_update() to inform the server about the changes. */
    85         struct jabber_away_state *away_state;
     87        const struct jabber_away_state *away_state;
    8688        char *away_message;
    8789       
  • protocols/jabber/jabber_util.c

    r3f81999 r5f8ab6a9  
    228228{
    229229        { "away",  "Away" },
    230         { "chat",  "Free for Chat" },
     230        { "chat",  "Free for Chat" },   /* WTF actually uses this? */
    231231        { "dnd",   "Do not Disturb" },
    232232        { "xa",    "Extended Away" },
    233         { "",      "Online" },
    234233        { "",      NULL }
    235234};
     
    238237{
    239238        int i;
     239       
     240        if( code == NULL )
     241                return NULL;
    240242       
    241243        for( i = 0; jabber_away_state_list[i].full_name; i ++ )
     
    249251{
    250252        int i;
     253       
     254        if( name == NULL )
     255                return NULL;
    251256       
    252257        for( i = 0; jabber_away_state_list[i].full_name; i ++ )
  • protocols/jabber/presence.c

    r3f81999 r5f8ab6a9  
    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.