Changeset cc2cb2d


Ignore:
Timestamp:
2006-10-04T18:14:41Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
101d84f
Parents:
6266fca
Message:

Lack of TLS support is also detected now if the server doesn't support
XMPP 1.0 (properly), and restored immediate writes by splitting up the
jabber_write_callback() function.

Location:
protocols/jabber
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    r6266fca rcc2cb2d  
    2626
    2727static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond );
     28static gboolean jabber_write_queue( struct gaim_connection *gc );
    2829
    2930int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node )
     
    4243{
    4344        struct jabber_data *jd = gc->proto_data;
     45        gboolean ret;
    4446       
    4547        if( jd->tx_len == 0 )
     
    5254                   it via the event handler. If not, add the handler. (In
    5355                   most cases it probably won't be necessary.) */
    54                 /* Disabling this trick for now because there's really not
    55                    a good way to catch errors yet. :-(
    56                 if( jabber_write_callback( gc, jd->fd, GAIM_INPUT_WRITE ) )
    57                 */
     56                if( ( ret = jabber_write_queue( gc ) ) && jd->tx_len > 0 )
    5857                        jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, gc );
    5958        }
     
    6564                memcpy( jd->txq + jd->tx_len, buf, len );
    6665                jd->tx_len += len;
    67         }
    68        
    69         /* FIXME: write_callback could've generated a real error! Have to
    70            find a way to find out if we have to return 0 here. Looking for
    71            ourselves in the linked list of connections is a possibility,
    72            but it'd be too time-consuming... */
    73         return 1;
    74 }
    75 
     66               
     67                /* The return value for write() doesn't necessarily mean
     68                   that everything got sent, it mainly means that the
     69                   connection (officially) still exists and can still
     70                   be accessed without hitting SIGSEGV. IOW: */
     71                ret = TRUE;
     72        }
     73       
     74        return ret;
     75}
     76
     77/* Splitting up in two separate functions: One to use as a callback and one
     78   to use in the function above to escape from having to wait for the event
     79   handler to call us, if possible.
     80   
     81   Two different functions are necessary because of the return values: The
     82   callback should only return TRUE if the write was successful AND if the
     83   buffer is not empty yet (ie. if the handler has to be called again when
     84   the socket is ready for more data). */
    7685static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond )
    7786{
    78         struct gaim_connection *gc = data;
     87        struct jabber_data *jd = ((struct gaim_connection *)data)->proto_data;
     88       
     89        return jd->fd != -1 &&
     90               jabber_write_queue( data ) &&
     91               jd->tx_len > 0;
     92}
     93
     94static gboolean jabber_write_queue( struct gaim_connection *gc )
     95{
    7996        struct jabber_data *jd = gc->proto_data;
    8097        int st;
    81        
    82         if( jd->fd == -1 )
    83                 return FALSE;
    8498       
    8599        if( jd->ssl )
     
    97111                jd->tx_len = 0;
    98112               
    99                 return FALSE;
     113                return TRUE;
    100114        }
    101115        else if( st == 0 || ( st < 0 && !sockerr_again() ) )
     
    187201                                   authentication. */
    188202                                if( !sasl_supported( gc ) )
    189                                         return jabber_start_iq_auth( gc );
     203                                {
     204                                        /* If there's no version= tag, we suppose
     205                                           this server does NOT implement: XMPP 1.0,
     206                                           SASL and TLS. */
     207                                        if( set_getbool( &gc->acc->set, "tls" ) )
     208                                        {
     209                                                hide_login_progress( gc, "TLS is turned on for this "
     210                                                          "account, but is not supported by this server" );
     211                                                signoff( gc );
     212                                                return FALSE;
     213                                        }
     214                                        else
     215                                        {
     216                                                return jabber_start_iq_auth( gc );
     217                                        }
     218                                }
    190219                        }
    191220                        else
    192221                        {
    193                                 hide_login_progress_error( gc, "XML stream error" );
     222                                hide_login_progress( gc, "XML stream error" );
    194223                                signoff( gc );
    195224                                return FALSE;
  • protocols/jabber/jabber.c

    r6266fca rcc2cb2d  
    124124static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )
    125125{
    126         struct xt_node *node, *event;
     126        struct xt_node *node;
    127127        int st;
    128128       
Note: See TracChangeset for help on using the changeset viewer.