Changeset dfa41a4 for protocols/jabber
- Timestamp:
- 2006-10-20T19:12:14Z (18 years ago)
- Branches:
- master
- Children:
- 3b3cd693
- Parents:
- f920d9e
- Location:
- protocols/jabber
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/iq.c
rf920d9e rdfa41a4 45 45 struct jabber_cache_entry *entry; 46 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. */ 47 if( ( s = xt_find_attr( node, "id" ) ) == NULL || 48 strncmp( s, JABBER_CACHED_ID, strlen( JABBER_CACHED_ID ) ) != 0 ) 49 { 50 /* Silently ignore it, without an ID (or an non-cache 51 ID) we don't know how to handle the packet and we 52 probably don't have to. */ 52 53 return XT_HANDLED; 53 54 } … … 65 66 !( s = xt_find_attr( c, "xmlns" ) ) ) 66 67 { 67 serv_got_crap( gc, "WARNING: Received incomplete IQ- get packet");68 serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type ); 68 69 return XT_HANDLED; 69 70 } … … 125 126 else if( strcmp( type, "set" ) == 0 ) 126 127 { 127 xt_free_node( reply ); 128 reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel" ); 129 pack = 0; 128 if( !( c = xt_find_node( node->children, "query" ) ) || 129 !( s = xt_find_attr( c, "xmlns" ) ) ) 130 { 131 serv_got_crap( gc, "WARNING: Received incomplete IQ-%s packet", type ); 132 return XT_HANDLED; 133 } 134 135 if( strcmp( s, "jabber:iq:roster" ) == 0 ) 136 { 137 /* This is a roster push packet, probably. Here we 138 should check if the packet is legitimate by 139 checking if it really comes from the user's JID 140 and, if so, process it. */ 141 } 142 else 143 { 144 xt_free_node( reply ); 145 reply = jabber_make_error_packet( node, "feature-not-implemented", "cancel" ); 146 pack = 0; 147 } 130 148 } 131 149 -
protocols/jabber/jabber.h
rf920d9e rdfa41a4 102 102 103 103 time_t last_act; 104 int flags;104 jabber_buddy_flag_t flags; 105 105 106 106 struct jabber_buddy *next; 107 107 }; 108 109 /* Prefixes to use for packet IDs (mainly for IQ packets ATM). Usually the 110 first one should be used, but when storing a packet in the cache, a 111 "special" kind of ID is assigned to make it easier later to figure out 112 if we have to do call an event handler for the response packet. */ 113 #define JABBER_PACKET_ID "BeeP" 114 #define JABBER_CACHED_ID "BeeC" 108 115 109 116 /* iq.c */ -
protocols/jabber/jabber_util.c
rf920d9e rdfa41a4 24 24 #include "jabber.h" 25 25 26 static int next_id = 1;26 static unsigned int next_id = 1; 27 27 28 28 char *set_eval_priority( set_t *set, char *value ) … … 83 83 xt_add_attr( node, "to", to ); 84 84 85 /* IQ packets should always have an ID, so let's generate one. It 86 might get overwritten by jabber_cache_add() if this packet has 87 to be saved until we receive a response. Cached packets get 88 slightly different IDs so we can recognize them. */ 89 if( strcmp( name, "iq" ) == 0 ) 90 { 91 char *id = g_strdup_printf( "%s%05x", JABBER_PACKET_ID, ( next_id++ ) & 0xfffff ); 92 xt_add_attr( node, "id", id ); 93 g_free( id ); 94 } 95 85 96 return node; 86 97 } … … 116 127 } 117 128 118 /* Cache a node/ epacket for later use. Mainly useful for IQ packets if you need129 /* Cache a node/packet for later use. Mainly useful for IQ packets if you need 119 130 them when you receive the response. Use this BEFORE sending the packet so 120 it'll get a nid= tag, and do NOT free() the packet after writing it! */131 it'll get a new id= tag, and do NOT free() the packet after writing it! */ 121 132 void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func ) 122 133 { 123 134 struct jabber_data *jd = gc->proto_data; 124 char *id = g_strdup_printf( " BeeX%04x", next_id++);135 char *id = g_strdup_printf( "%s%05x", JABBER_CACHED_ID, ( next_id++ ) & 0xfffff ); 125 136 struct jabber_cache_entry *entry = g_new0( struct jabber_cache_entry, 1 ); 126 137
Note: See TracChangeset
for help on using the changeset viewer.