Changeset 8d74291
- Timestamp:
- 2006-09-22T16:56:58Z (18 years ago)
- Branches:
- master
- Children:
- fe7a554
- Parents:
- 5997488
- Location:
- protocols
- Files:
-
- 5 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 ) -
protocols/jabber/iq.c
r5997488 r8d74291 130 130 } 131 131 132 int jabber_start_ auth( struct gaim_connection *gc )132 int jabber_start_iq_auth( struct gaim_connection *gc ) 133 133 { 134 134 struct jabber_data *jd = gc->proto_data; -
protocols/jabber/jabber.h
r5997488 r8d74291 35 35 JFLAG_AUTHENTICATED = 2, /* Set when we're successfully authenticatd. */ 36 36 JFLAG_STREAM_RESTART = 4, /* Set when we want to restart the stream (after SASL or TLS). */ 37 JFLAG_SUPPORTS_TLS = 8, /* Set when there's <starttls/> in <stream:features>. */38 37 } jabber_flags_t; 39 38 40 39 /* iq.c */ 41 40 xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ); 42 int jabber_start_ auth( struct gaim_connection *gc );41 int jabber_start_iq_auth( struct gaim_connection *gc ); 43 42 int jabber_get_roster( struct gaim_connection *gc ); 44 43 … … 66 65 xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data ); 67 66 xt_status sasl_pkt_result( struct xt_node *node, gpointer data ); 67 gboolean sasl_supported( struct gaim_connection *gc ); 68 68 69 69 struct jabber_data -
protocols/jabber/sasl.c
r5997488 r8d74291 34 34 char *s; 35 35 int sup_plain = 0, sup_digest = 0; 36 37 if( !sasl_supported( gc ) ) 38 { 39 /* Should abort this now, since we should already be doing 40 IQ authentication. Strange things happen when you try 41 to do both... */ 42 serv_got_crap( gc, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" ); 43 return XT_HANDLED; 44 } 36 45 37 46 s = xt_find_attr( node, "xmlns" ); … … 94 103 xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data ) 95 104 { 105 return XT_HANDLED; 96 106 } 97 107 … … 123 133 return XT_HANDLED; 124 134 } 135 136 /* This one is needed to judge if we'll do authentication using IQ or SASL. 137 It's done by checking if the <stream:stream> from the server has a 138 version attribute. I don't know if this is the right way though... */ 139 gboolean sasl_supported( struct gaim_connection *gc ) 140 { 141 struct jabber_data *jd = gc->proto_data; 142 143 return ( jd->xt && jd->xt->root && xt_find_attr( jd->xt->root, "version" ) ) != NULL; 144 } -
protocols/nogaim.c
r5997488 r8d74291 279 279 user_t *t, *u = irc->users; 280 280 account_t *a; 281 282 /* Nested calls might happen sometimes, this is probably the best 283 place to catch them. */ 284 if( gc->flags & OPT_LOGGING_OUT ) 285 return; 281 286 282 287 serv_got_crap( gc, "Signing off.." );
Note: See TracChangeset
for help on using the changeset viewer.