Changeset 58b5f62 for protocols/jabber
- Timestamp:
- 2006-10-11T08:45:45Z (18 years ago)
- Branches:
- master
- Children:
- b56b220
- Parents:
- 8eb10c9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/iq.c
r8eb10c9 r58b5f62 28 28 struct gaim_connection *gc = data; 29 29 struct jabber_data *jd = gc->proto_data; 30 struct xt_node *c, *reply = NULL; 30 31 char *type, *s; 32 int st; 31 33 32 34 type = xt_find_attr( node, "type" ); … … 34 36 if( !type ) 35 37 { 36 hide_login_progress_error( gc, "Received IQ packet without type !" );38 hide_login_progress_error( gc, "Received IQ packet without type." ); 37 39 signoff( gc ); 38 40 return XT_ABORT; 39 41 } 40 42 41 if( ( s = xt_find_attr( node, "id" ) ) && 42 ( strcmp( type, "result" ) == 0 || strcmp( type, "error" ) == 0 ) ) 43 if( strcmp( type, "result" ) == 0 || strcmp( type, "error" ) == 0 ) 43 44 { 44 45 struct jabber_cache_entry *entry; 46 47 if( ( s = xt_find_attr( node, "id" ) ) == NULL ) 48 { 49 /* Silently ignore it, without an ID we don't know 50 how to handle the packet, but it doesn't have 51 to be a serious problem. */ 52 return XT_HANDLED; 53 } 45 54 46 55 entry = g_hash_table_lookup( jd->node_cache, s ); … … 50 59 else if( entry->func ) 51 60 return entry->func( gc, node, entry->node ); 61 } 62 else if( strcmp( type, "get" ) == 0 ) 63 { 64 if( !( c = xt_find_node( node->children, "query" ) ) || 65 !( s = xt_find_attr( c, "xmlns" ) ) ) 66 { 67 serv_got_crap( gc, "WARNING: Received incomplete IQ-get packet" ); 68 return XT_HANDLED; 69 } 70 71 reply = xt_new_node( "query", NULL, NULL ); 72 xt_add_attr( reply, "xmlns", s ); 73 74 /* Of course this is a very essential query to support. ;-) */ 75 if( strcmp( s, "jabber:iq:version" ) == 0 ) 76 { 77 xt_add_child( reply, xt_new_node( "name", "BitlBee", NULL ) ); 78 xt_add_child( reply, xt_new_node( "version", BITLBEE_VERSION, NULL ) ); 79 xt_add_child( reply, xt_new_node( "os", ARCH, NULL ) ); 80 } 81 else if( strcmp( s, "http://jabber.org/protocol/disco#info" ) == 0 ) 82 { 83 c = xt_new_node( "identity", NULL, NULL ); 84 xt_add_attr( c, "category", "client" ); 85 xt_add_attr( c, "type", "pc" ); 86 xt_add_attr( c, "name", "BitlBee" ); 87 xt_add_child( reply, c ); 88 89 c = xt_new_node( "feature", NULL, NULL ); 90 xt_add_attr( c, "var", "jabber:iq:version" ); 91 xt_add_child( reply, c ); 92 93 c = xt_new_node( "feature", NULL, NULL ); 94 xt_add_attr( c, "var", "http://jabber.org/protocol/chatstates" ); 95 xt_add_child( reply, c ); 96 97 /* Later this can be useful to announce things like 98 MUC support. */ 99 } 100 else 101 { 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 ) 109 { 110 reply = jabber_make_packet( "iq", "result", xt_find_attr( node, "from" ), reply ); 111 if( ( s = xt_find_attr( node, "id" ) ) ) 112 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 } 52 119 } 53 120
Note: See TracChangeset
for help on using the changeset viewer.