Changeset 1baaef8
- Timestamp:
- 2007-07-30T19:12:06Z (17 years ago)
- Branches:
- master
- Children:
- 82135c7
- Parents:
- 85023c6
- Location:
- protocols/jabber
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/io.c
r85023c6 r1baaef8 436 436 { 437 437 struct im_connection *ic = data; 438 struct xt_node *c;439 char *s, *type = NULL, *text = NULL;440 438 int allow_reconnect = TRUE; 441 442 for( c = node->children; c; c = c->next ) 443 { 444 if( !( s = xt_find_attr( c, "xmlns" ) ) || 445 strcmp( s, XMLNS_STREAM_ERROR ) != 0 ) 446 continue; 447 448 if( strcmp( c->name, "text" ) != 0 ) 449 { 450 type = c->name; 451 } 452 /* Only use the text if it doesn't have an xml:lang attribute, 453 if it's empty or if it's set to something English. */ 454 else if( !( s = xt_find_attr( c, "xml:lang" ) ) || 455 !*s || strncmp( s, "en", 2 ) == 0 ) 456 { 457 text = c->text; 458 } 459 } 439 struct jabber_error *err; 440 441 err = jabber_error_parse( node, XMLNS_STREAM_ERROR ); 460 442 461 443 /* Tssk... */ 462 if( type == NULL )444 if( err->code == NULL ) 463 445 { 464 446 imcb_error( ic, "Unknown stream error reported by server" ); 465 447 imc_logout( ic, allow_reconnect ); 448 jabber_error_free( err ); 466 449 return XT_ABORT; 467 450 } … … 470 453 should turn off auto-reconnect to make sure we won't get some nasty 471 454 infinite loop! */ 472 if( strcmp( type, "conflict" ) == 0 )455 if( strcmp( err->code, "conflict" ) == 0 ) 473 456 { 474 457 imcb_error( ic, "Account and resource used from a different location" ); … … 477 460 else 478 461 { 479 imcb_error( ic, "Stream error: %s%s%s", type, text ? ": " : "", text ? text : "" ); 480 } 481 462 imcb_error( ic, "Stream error: %s%s%s", err->code, err->text ? ": " : "", 463 err->text ? err->text : "" ); 464 } 465 466 jabber_error_free( err ); 482 467 imc_logout( ic, allow_reconnect ); 483 468 -
protocols/jabber/jabber.h
r85023c6 r1baaef8 194 194 } get_buddy_flags_t; 195 195 196 struct jabber_error 197 { 198 char *code, *text, *type; 199 }; 200 196 201 struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid ); 197 202 struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid, get_buddy_flags_t flags ); … … 201 206 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name ); 202 207 time_t jabber_get_timestamp( struct xt_node *xt ); 208 struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns ); 209 void jabber_error_free( struct jabber_error *err ); 203 210 204 211 extern const struct jabber_away_state jabber_away_state_list[]; -
protocols/jabber/jabber_util.c
r85023c6 r1baaef8 648 648 return res; 649 649 } 650 651 struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns ) 652 { 653 struct jabber_error *err = g_new0( struct jabber_error, 1 ); 654 struct xt_node *c; 655 char *s; 656 657 err->type = xt_find_attr( node, "type" ); 658 659 for( c = node->children; c; c = c->next ) 660 { 661 if( !( s = xt_find_attr( c, "xmlns" ) ) || 662 strcmp( s, xmlns ) != 0 ) 663 continue; 664 665 if( strcmp( c->name, "text" ) != 0 ) 666 { 667 err->code = c->name; 668 } 669 /* Only use the text if it doesn't have an xml:lang attribute, 670 if it's empty or if it's set to something English. */ 671 else if( !( s = xt_find_attr( c, "xml:lang" ) ) || 672 !*s || strncmp( s, "en", 2 ) == 0 ) 673 { 674 err->text = c->text; 675 } 676 } 677 678 return err; 679 } 680 681 void jabber_error_free( struct jabber_error *err ) 682 { 683 g_free( err ); 684 } -
protocols/jabber/presence.c
r85023c6 r1baaef8 158 158 else if( strcmp( type, "error" ) == 0 ) 159 159 { 160 /* What to do with it? */ 160 struct jabber_error *err; 161 162 if( ( c = xt_find_node( node->children, "error" ) ) ) 163 { 164 err = jabber_error_parse( c, XMLNS_STANZA_ERROR ); 165 imcb_error( ic, "Stanza (%s) error: %s%s%s", node->name, 166 err->code, err->text ? ": " : "", 167 err->text ? err->text : "" ); 168 jabber_error_free( err ); 169 } 170 /* What else to do with it? */ 161 171 } 162 172 else
Note: See TracChangeset
for help on using the changeset viewer.