Changeset 8d74291 for protocols/jabber/io.c
- Timestamp:
- 2006-09-22T16:56:58Z (18 years ago)
- Branches:
- master
- Children:
- fe7a554
- Parents:
- 5997488
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/io.c
r5997488 r8d74291 73 73 int st; 74 74 75 if( jd->fd == -1 ) 76 return FALSE; 77 75 78 st = write( jd->fd, jd->txq, jd->tx_len ); 76 79 … … 86 89 else if( st == 0 || ( st < 0 && !sockerr_again() ) ) 87 90 { 91 /* Set fd to -1 to make sure we won't write to it anymore. */ 92 closesocket( jd->fd ); /* Shouldn't be necessary after errors? */ 93 jd->fd = -1; 94 88 95 hide_login_progress_error( gc, "Short write() to server" ); 89 96 signoff( gc ); … … 99 106 jd->txq = s; 100 107 101 return FALSE;108 return TRUE; 102 109 } 103 110 else … … 115 122 char buf[512]; 116 123 int st; 124 125 if( jd->fd == -1 ) 126 return FALSE; 117 127 118 128 st = read( fd, buf, sizeof( buf ) ); … … 139 149 { 140 150 jd->flags &= ~JFLAG_STREAM_RESTART; 141 xt_reset( jd->xt );142 151 jabber_start_stream( gc ); 143 152 } … … 156 165 { 157 166 jd->flags |= JFLAG_STREAM_STARTED; 158 return jabber_start_auth( gc ); 167 168 /* If there's no version attribute, assume 169 this is an old server that can't do SASL 170 authentication. */ 171 if( !sasl_supported( gc ) ) 172 return jabber_start_iq_auth( gc ); 159 173 } 160 174 else … … 168 182 else if( st == 0 || ( st < 0 && !sockerr_again() ) ) 169 183 { 184 closesocket( jd->fd ); 185 jd->fd = -1; 186 170 187 hide_login_progress_error( gc, "Error while reading from server" ); 171 188 signoff( gc ); … … 198 215 } 199 216 217 static xt_status jabber_pkt_features( struct xt_node *node, gpointer data ) 218 { 219 struct gaim_connection *gc = data; 220 struct jabber_data *jd = gc->proto_data; 221 struct xt_node *c; 222 223 c = xt_find_node( node->children, "starttls" ); 224 if( c ) 225 { 226 /* 227 jd->flags |= JFLAG_SUPPORTS_TLS; 228 if( xt_find_node( c->children, "required" ) ) 229 jd->flags |= JFLAG_REQUIRES_TLS; 230 */ 231 } 232 233 /* This flag is already set if we authenticated via SASL, so now 234 we can resume the session in the new stream. */ 235 if( jd->flags & JFLAG_AUTHENTICATED ) 236 { 237 if( !jabber_get_roster( gc ) ) 238 return XT_ABORT; 239 } 240 241 return XT_HANDLED; 242 } 243 200 244 static xt_status jabber_pkt_misc( struct xt_node *node, gpointer data ) 201 245 { … … 208 252 static const struct xt_handler_entry jabber_handlers[] = { 209 253 { "stream:stream", "<root>", jabber_end_of_stream }, 210 { "iq", "stream:stream", jabber_pkt_iq },211 254 { "message", "stream:stream", jabber_pkt_message }, 212 255 { "presence", "stream:stream", jabber_pkt_presence }, 256 { "iq", "stream:stream", jabber_pkt_iq }, 257 { "stream:features", "stream:stream", jabber_pkt_features }, 213 258 { "mechanisms", "stream:features", sasl_pkt_mechanisms }, 214 259 { "challenge", "stream:stream", sasl_pkt_challenge }, … … 231 276 jd->xt->handlers = (struct xt_handler_entry*) jabber_handlers; 232 277 233 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, gc ); 278 if( jd->r_inpa <= 0 ) 279 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, gc ); 234 280 235 281 greet = g_strdup_printf( "<?xml version='1.0' ?>" … … 254 300 char eos[] = "</stream:stream>"; 255 301 struct xt_node *node; 256 int st; 257 258 node = jabber_make_packet( "presence", "unavailable", NULL, NULL ); 259 st = jabber_write_packet( gc, node ); 260 xt_free_node( node ); 302 int st = 1; 303 304 if( gc->flags & OPT_LOGGED_IN ) 305 { 306 node = jabber_make_packet( "presence", "unavailable", NULL, NULL ); 307 st = jabber_write_packet( gc, node ); 308 xt_free_node( node ); 309 } 261 310 262 311 if( st )
Note: See TracChangeset
for help on using the changeset viewer.