Changeset e8c8d00 for protocols/jabber
- Timestamp:
- 2010-03-17T15:15:19Z (15 years ago)
- Branches:
- master
- Children:
- 60e4df3
- Parents:
- 1c3008a (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. - Location:
- protocols/jabber
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/io.c
r1c3008a re8c8d00 375 375 376 376 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; 388 378 389 379 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 ); 410 384 411 385 return XT_HANDLED; … … 441 415 imcb_log( ic, "Converting stream to TLS" ); 442 416 417 jd->flags |= JFLAG_STARTTLS_DONE; 443 418 jd->ssl = ssl_starttls( jd->fd, jabber_connected_ssl, ic ); 444 419 … … 531 506 jd->r_inpa = b_input_add( jd->fd, GAIM_INPUT_READ, jabber_read_callback, ic ); 532 507 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 ); 536 512 537 513 st = jabber_write( ic, greet, strlen( greet ) ); -
protocols/jabber/iq.c
r1c3008a re8c8d00 310 310 { 311 311 struct jabber_data *jd = ic->proto_data; 312 struct xt_node *c ;312 struct xt_node *c, *reply = NULL; 313 313 char *s; 314 314 315 if( ( c = xt_find_node( node->children, "bind" ) ) )315 if( node && ( c = xt_find_node( node->children, "bind" ) ) ) 316 316 { 317 317 c = xt_find_node( c->children, "jid" ); … … 319 319 strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 ) 320 320 imcb_log( ic, "Server changed session resource string to `%s'", s + 1 ); 321 322 jd->flags &= ~JFLAG_WAIT_BIND; 323 } 324 else 325 { 326 jd->flags &= ~JFLAG_WAIT_SESSION; 327 } 328 329 if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 ) 321 } 322 323 if( jd->flags & JFLAG_WANT_BIND ) 324 { 325 reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); 326 xt_add_attr( reply, "xmlns", XMLNS_BIND ); 327 jd->flags &= ~JFLAG_WANT_BIND; 328 } 329 else if( jd->flags & JFLAG_WANT_SESSION ) 330 { 331 reply = xt_new_node( "session", NULL, NULL ); 332 xt_add_attr( reply, "xmlns", XMLNS_SESSION ); 333 jd->flags &= ~JFLAG_WANT_SESSION; 334 } 335 336 if( reply != NULL ) 337 { 338 reply = jabber_make_packet( "iq", "set", NULL, reply ); 339 jabber_cache_add( ic, reply, jabber_pkt_bind_sess ); 340 341 if( !jabber_write_packet( ic, reply ) ) 342 return XT_ABORT; 343 } 344 else if( ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 ) 330 345 { 331 346 if( !jabber_get_roster( ic ) ) -
protocols/jabber/jabber.c
r1c3008a re8c8d00 69 69 s->flags |= ACC_SET_OFFLINE_ONLY; 70 70 71 s = set_add( &acc->set, "resource_select", " priority", NULL, acc );71 s = set_add( &acc->set, "resource_select", "activity", NULL, acc ); 72 72 73 73 s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); … … 82 82 s = set_add( &acc->set, "xmlconsole", "false", set_eval_bool, acc ); 83 83 s->flags |= ACC_SET_OFFLINE_ONLY; 84 85 acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE; 84 86 } 85 87 … … 378 380 while( bud ) 379 381 { 380 imcb_log( ic, "Buddy %s (%d) information:\nAway state: %s\nAway message: %s", 381 bud->full_jid, bud->priority, 382 bud->away_state ? bud->away_state->full_name : "(none)", 383 bud->away_message ? : "(none)" ); 382 imcb_log( ic, "Buddy %s (%d) information:", bud->full_jid, bud->priority ); 383 if( bud->away_state ) 384 imcb_log( ic, "Away state: %s", bud->away_state->full_name ); 385 imcb_log( ic, "Status message: %s", bud->away_message ? : "(none)" ); 386 384 387 bud = bud->next; 385 388 } … … 391 394 { 392 395 struct jabber_data *jd = ic->proto_data; 393 struct jabber_away_state *state; 394 395 /* Save all this info. We need it, for example, when changing the priority setting. */ 396 state = (void *) jabber_away_state_by_name( state_txt ); 397 jd->away_state = state ? state : (void *) jabber_away_state_list; /* Fall back to "Away" if necessary. */ 396 397 /* state_txt == NULL -> Not away. 398 Unknown state -> fall back to the first defined away state. */ 399 jd->away_state = state_txt ? jabber_away_state_by_name( state_txt ) 400 ? : jabber_away_state_list : NULL; 401 398 402 g_free( jd->away_message ); 399 403 jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL; -
protocols/jabber/jabber.h
r1c3008a re8c8d00 40 40 JFLAG_STREAM_RESTART = 4, /* Set when we want to restart the stream (after 41 41 SASL or TLS). */ 42 JFLAG_WA IT_SESSION = 8, /* Set if we sent a <session> tag and need a reply42 JFLAG_WANT_SESSION = 8, /* Set if the server wants a <session/> tag 43 43 before we continue. */ 44 JFLAG_WA IT_BIND = 16, /* ... for <bind> tag. */44 JFLAG_WANT_BIND = 16, /* ... for <bind> tag. */ 45 45 JFLAG_WANT_TYPING = 32, /* Set if we ever sent a typing notification, this 46 46 activates all XEP-85 related code. */ 47 47 JFLAG_XMLCONSOLE = 64, /* If the user added an xmlconsole buddy. */ 48 JFLAG_STARTTLS_DONE = 128, /* If a plaintext session was converted to TLS. */ 48 49 } jabber_flags_t; 49 50 … … 92 93 /* After changing one of these two (or the priority setting), call 93 94 presence_send_update() to inform the server about the changes. */ 94 struct jabber_away_state *away_state;95 const struct jabber_away_state *away_state; 95 96 char *away_message; 96 97 -
protocols/jabber/jabber_util.c
r1c3008a re8c8d00 232 232 { 233 233 { "away", "Away" }, 234 { "chat", "Free for Chat" }, 234 { "chat", "Free for Chat" }, /* WTF actually uses this? */ 235 235 { "dnd", "Do not Disturb" }, 236 236 { "xa", "Extended Away" }, 237 { "", "Online" },238 237 { "", NULL } 239 238 }; … … 242 241 { 243 242 int i; 243 244 if( code == NULL ) 245 return NULL; 244 246 245 247 for( i = 0; jabber_away_state_list[i].full_name; i ++ ) … … 253 255 { 254 256 int i; 257 258 if( name == NULL ) 259 return NULL; 255 260 256 261 for( i = 0; jabber_away_state_list[i].full_name; i ++ ) -
protocols/jabber/presence.c
r1c3008a re8c8d00 190 190 int is_away = 0; 191 191 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 ) 194 194 is_away = OPT_AWAY; 195 195 196 196 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, 199 198 send_presence->away_message ); 200 199 } … … 209 208 struct jabber_data *jd = ic->proto_data; 210 209 struct xt_node *node, *cap; 211 char *show = jd->away_state->code;212 char *status = jd->away_message;213 210 struct groupchat *c; 214 211 int st; … … 216 213 node = jabber_make_packet( "presence", NULL, NULL, NULL ); 217 214 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 ) ); 222 219 223 220 /* This makes the packet slightly bigger, but clients interested in
Note: See TracChangeset
for help on using the changeset viewer.