comparison libpurple/protocols/jabber/data.c @ 26487:bc7fac8e2f79

propagate from branch 'im.pidgin.pidgin' (head f144c6bda9daf701aa891c875fce7a4dedd611ae) to branch 'im.pidgin.cpw.darkrain42.xmpp.bosh' (head 8b60514f2b44295e87ee3587669aec5059556149)
author Paul Aurich <paul@darkrain42.org>
date Sun, 05 Apr 2009 21:13:10 +0000
parents c4fd9222dda1 457dca546b23
children a8537bbcfb79
comparison
equal deleted inserted replaced
26463:b01e8e76c59d 26487:bc7fac8e2f79
198 g_hash_table_insert(remote_data_by_cid, g_strdup(jabber_data_get_cid(data)), 198 g_hash_table_insert(remote_data_by_cid, g_strdup(jabber_data_get_cid(data)),
199 data); 199 data);
200 } 200 }
201 201
202 void 202 void
203 jabber_data_parse(JabberStream *js, xmlnode *packet) 203 jabber_data_parse(JabberStream *js, const char *who, JabberIqType type,
204 const char *id, xmlnode *data_node)
204 { 205 {
205 JabberIq *result = NULL; 206 JabberIq *result = NULL;
206 const char *who = xmlnode_get_attrib(packet, "from"); 207 const char *cid = xmlnode_get_attrib(data_node, "cid");
207 xmlnode *data_node = xmlnode_get_child(packet, "data"); 208 const JabberData *data = cid ? jabber_data_find_local_by_cid(cid) : NULL;
208 const JabberData *data =
209 jabber_data_find_local_by_cid(xmlnode_get_attrib(data_node, "cid"));
210 209
211 if (!data) { 210 if (!data) {
212 xmlnode *item_not_found = xmlnode_new("item-not-found"); 211 xmlnode *item_not_found = xmlnode_new("item-not-found");
213 212
214 result = jabber_iq_new(js, JABBER_IQ_ERROR); 213 result = jabber_iq_new(js, JABBER_IQ_ERROR);
215 xmlnode_set_attrib(result->node, "to", who); 214 if (who)
216 xmlnode_set_attrib(result->node, "id", xmlnode_get_attrib(packet, "id")); 215 xmlnode_set_attrib(result->node, "to", who);
216 xmlnode_set_attrib(result->node, "id", id);
217 xmlnode_insert_child(result->node, item_not_found); 217 xmlnode_insert_child(result->node, item_not_found);
218 } else { 218 } else {
219 result = jabber_iq_new(js, JABBER_IQ_RESULT); 219 result = jabber_iq_new(js, JABBER_IQ_RESULT);
220 xmlnode_set_attrib(result->node, "to", who); 220 if (who)
221 xmlnode_set_attrib(result->node, "id", xmlnode_get_attrib(packet, "id")); 221 xmlnode_set_attrib(result->node, "to", who);
222 xmlnode_set_attrib(result->node, "id", id);
222 xmlnode_insert_child(result->node, 223 xmlnode_insert_child(result->node,
223 jabber_data_get_xml_definition(data)); 224 jabber_data_get_xml_definition(data));
224 } 225 }
225 jabber_iq_send(result); 226 jabber_iq_send(result);
226 } 227 }
233 g_free, NULL); 234 g_free, NULL);
234 local_data_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, 235 local_data_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal,
235 g_free, jabber_data_delete); 236 g_free, jabber_data_delete);
236 remote_data_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, 237 remote_data_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal,
237 g_free, jabber_data_delete); 238 g_free, jabber_data_delete);
239
240 jabber_iq_register_handler("data", XEP_0231_NAMESPACE, jabber_data_parse);
238 } 241 }
239 242
240 void 243 void
241 jabber_data_uninit(void) 244 jabber_data_uninit(void)
242 { 245 {