Changeset 259edd4
- Timestamp:
- 2006-10-12T17:48:58Z (18 years ago)
- Branches:
- master
- Children:
- a4effbf
- Parents:
- b56b220
- Location:
- protocols/jabber
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/io.c
rb56b220 r259edd4 465 465 infinite loop! */ 466 466 if( strcmp( type, "conflict" ) == 0 ) 467 { 468 hide_login_progress( gc, "Account and resource used from a different location" ); 467 469 gc->wants_to_die = TRUE; 468 469 s = g_strdup_printf( "Stream error: %s%s%s", type, text ? ": " : "", text ? text : "" ); 470 hide_login_progress_error( gc, s ); 471 g_free( s ); 470 } 471 else 472 { 473 s = g_strdup_printf( "Stream error: %s%s%s", type, text ? ": " : "", text ? text : "" ); 474 hide_login_progress_error( gc, s ); 475 g_free( s ); 476 } 477 472 478 signoff( gc ); 473 479 -
protocols/jabber/iq.c
rb56b220 r259edd4 30 30 struct xt_node *c, *reply = NULL; 31 31 char *type, *s; 32 int st ;32 int st, pack = 1; 33 33 34 34 type = xt_find_attr( node, "type" ); … … 101 101 { 102 102 xt_free_node( reply ); 103 reply = NULL; 104 } 105 106 /* If we recognized the xmlns and managed to generate a reply, 107 finish and send it. */ 108 if( reply ) 103 reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel" ); 104 pack = 0; 105 } 106 } 107 else if( strcmp( type, "set" ) == 0 ) 108 { 109 xt_free_node( reply ); 110 reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel" ); 111 pack = 0; 112 } 113 114 /* If we recognized the xmlns and managed to generate a reply, 115 finish and send it. */ 116 if( reply ) 117 { 118 /* Normally we still have to pack it into an iq-result 119 packet, but for errors, for example, we don't. */ 120 if( pack ) 109 121 { 110 122 reply = jabber_make_packet( "iq", "result", xt_find_attr( node, "from" ), reply ); 111 123 if( ( s = xt_find_attr( node, "id" ) ) ) 112 124 xt_add_attr( reply, "id", s ); 113 114 st = jabber_write_packet( gc, reply );115 xt_free_node(reply );116 if( !st )117 return XT_ABORT;118 }125 } 126 127 st = jabber_write_packet( gc, reply ); 128 xt_free_node( reply ); 129 if( !st ) 130 return XT_ABORT; 119 131 } 120 132 -
protocols/jabber/jabber.h
rb56b220 r259edd4 127 127 char *set_eval_tls( set_t *set, char *value ); 128 128 struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_node *children ); 129 struct xt_node *jabber_make_error_packet( struct xt_node *orig, char *err_cond, char *err_type ); 129 130 void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func ); 130 131 struct xt_node *jabber_cache_get( struct gaim_connection *gc, char *id ); -
protocols/jabber/jabber_util.c
rb56b220 r259edd4 79 79 } 80 80 81 /* Cache a node/packet for later use. Mainly useful for IQ packets if you need 81 struct xt_node *jabber_make_error_packet( struct xt_node *orig, char *err_cond, char *err_type ) 82 { 83 struct xt_node *node, *c; 84 char *to; 85 86 /* Create the "defined-condition" tag. */ 87 c = xt_new_node( err_cond, NULL, NULL ); 88 xt_add_attr( c, "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas" ); 89 90 /* Put it in an <error> tag. */ 91 c = xt_new_node( "error", NULL, c ); 92 xt_add_attr( c, "type", err_type ); 93 94 /* To make the actual error packet, we copy the original packet and 95 add our <error>/type="error" tag. Including the original packet 96 is recommended, so let's just do it. */ 97 node = xt_dup( orig ); 98 xt_add_child( node, c ); 99 xt_add_attr( node, "type", "error" ); 100 101 /* Return to sender. */ 102 if( ( to = xt_find_attr( node, "from" ) ) ) 103 { 104 xt_add_attr( node, "to", to ); 105 xt_remove_attr( node, "from" ); 106 } 107 108 return node; 109 } 110 111 /* Cache a node/epacket for later use. Mainly useful for IQ packets if you need 82 112 them when you receive the response. Use this BEFORE sending the packet so 83 113 it'll get an id= tag, and do NOT free() the packet after writing it! */ -
protocols/jabber/xmltree.c
rb56b220 r259edd4 550 550 node->attr[i].value = g_strdup( value ); 551 551 } 552 553 int xt_remove_attr( struct xt_node *node, char *key ) 554 { 555 int i, last; 556 557 for( i = 0; node->attr[i].key; i ++ ) 558 if( strcmp( node->attr[i].key, key ) == 0 ) 559 break; 560 561 /* If we didn't find the attribute... */ 562 if( node->attr[i].key == NULL ) 563 return 0; 564 565 g_free( node->attr[i].key ); 566 g_free( node->attr[i].value ); 567 568 /* If it's the last, this is easy: */ 569 if( node->attr[i+1].key == NULL ) 570 { 571 node->attr[i].key = node->attr[i].value = NULL; 572 } 573 else /* It's also pretty easy, actually. */ 574 { 575 /* Find the last item. */ 576 for( last = i + 1; node->attr[last+1].key; last ++ ); 577 578 node->attr[i] = node->attr[last]; 579 node->attr[last].key = NULL; 580 node->attr[last].value = NULL; 581 } 582 583 /* Let's not bother with reallocating memory here. It takes time and 584 most packets don't stay in memory for long anyway. */ 585 586 return 1; 587 } -
protocols/jabber/xmltree.h
rb56b220 r259edd4 93 93 void xt_add_child( struct xt_node *parent, struct xt_node *child ); 94 94 void xt_add_attr( struct xt_node *node, char *key, char *value ); 95 int xt_remove_attr( struct xt_node *node, char *key ); 95 96 96 97 #endif
Note: See TracChangeset
for help on using the changeset viewer.