Changeset cc2cb2d for protocols/jabber
- Timestamp:
- 2006-10-04T18:14:41Z (18 years ago)
- Branches:
- master
- Children:
- 101d84f
- Parents:
- 6266fca
- Location:
- protocols/jabber
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/io.c
r6266fca rcc2cb2d 26 26 27 27 static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond ); 28 static gboolean jabber_write_queue( struct gaim_connection *gc ); 28 29 29 30 int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node ) … … 42 43 { 43 44 struct jabber_data *jd = gc->proto_data; 45 gboolean ret; 44 46 45 47 if( jd->tx_len == 0 ) … … 52 54 it via the event handler. If not, add the handler. (In 53 55 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 ) 58 57 jd->w_inpa = b_input_add( jd->fd, GAIM_INPUT_WRITE, jabber_write_callback, gc ); 59 58 } … … 65 64 memcpy( jd->txq + jd->tx_len, buf, len ); 66 65 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). */ 76 85 static gboolean jabber_write_callback( gpointer data, gint fd, b_input_condition cond ) 77 86 { 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 94 static gboolean jabber_write_queue( struct gaim_connection *gc ) 95 { 79 96 struct jabber_data *jd = gc->proto_data; 80 97 int st; 81 82 if( jd->fd == -1 )83 return FALSE;84 98 85 99 if( jd->ssl ) … … 97 111 jd->tx_len = 0; 98 112 99 return FALSE;113 return TRUE; 100 114 } 101 115 else if( st == 0 || ( st < 0 && !sockerr_again() ) ) … … 187 201 authentication. */ 188 202 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 } 190 219 } 191 220 else 192 221 { 193 hide_login_progress _error( gc, "XML stream error" );222 hide_login_progress( gc, "XML stream error" ); 194 223 signoff( gc ); 195 224 return FALSE; -
protocols/jabber/jabber.c
r6266fca rcc2cb2d 124 124 static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away ) 125 125 { 126 struct xt_node *node , *event;126 struct xt_node *node; 127 127 int st; 128 128
Note: See TracChangeset
for help on using the changeset viewer.