| 83 js->bs_proxies = g_list_remove(js->bs_proxies, sh); |
83 js->bs_proxies = g_list_remove(js->bs_proxies, sh); |
| 84 } |
84 } |
| 85 } |
85 } |
| 86 |
86 |
| 87 |
87 |
| 88 void jabber_disco_info_parse(JabberStream *js, xmlnode *packet) { |
88 void jabber_disco_info_parse(JabberStream *js, const char *from, |
| 89 const char *from = xmlnode_get_attrib(packet, "from"); |
89 JabberIqType type, const char *id, |
| 90 const char *type = xmlnode_get_attrib(packet, "type"); |
90 xmlnode *in_query) { |
| 91 |
91 |
| 92 if(!from || !type) |
92 if(!from) |
| 93 return; |
93 return; |
| 94 |
94 |
| 95 if(!strcmp(type, "get")) { |
95 if(type == JABBER_IQ_GET) { |
| 96 xmlnode *query, *identity, *feature; |
96 xmlnode *query, *identity, *feature; |
| 97 JabberIq *iq; |
97 JabberIq *iq; |
| 98 |
98 const char *node = xmlnode_get_attrib(in_query, "node"); |
| 99 xmlnode *in_query; |
|
| 100 const char *node = NULL; |
|
| 101 |
|
| 102 if((in_query = xmlnode_get_child(packet, "query"))) { |
|
| 103 node = xmlnode_get_attrib(in_query, "node"); |
|
| 104 } |
|
| 105 |
|
| 106 |
99 |
| 107 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, |
100 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, |
| 108 "http://jabber.org/protocol/disco#info"); |
101 "http://jabber.org/protocol/disco#info"); |
| 109 |
102 |
| 110 jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); |
103 jabber_iq_set_id(iq, id); |
| 111 |
104 |
| 112 xmlnode_set_attrib(iq->node, "to", from); |
105 xmlnode_set_attrib(iq->node, "to", from); |
| 113 query = xmlnode_get_child(iq->node, "query"); |
106 query = xmlnode_get_child(iq->node, "query"); |
| 114 |
107 |
| 115 if(node) |
108 if(node) |
| 124 xmlnode_set_attrib(identity, "name", PACKAGE); |
117 xmlnode_set_attrib(identity, "name", PACKAGE); |
| 125 |
118 |
| 126 SUPPORT_FEATURE("jabber:iq:last") |
119 SUPPORT_FEATURE("jabber:iq:last") |
| 127 SUPPORT_FEATURE("jabber:iq:oob") |
120 SUPPORT_FEATURE("jabber:iq:oob") |
| 128 SUPPORT_FEATURE("jabber:iq:time") |
121 SUPPORT_FEATURE("jabber:iq:time") |
| 129 SUPPORT_FEATURE("xmpp:urn:time") |
122 SUPPORT_FEATURE("urn:xmpp:time") |
| 130 SUPPORT_FEATURE("jabber:iq:version") |
123 SUPPORT_FEATURE("jabber:iq:version") |
| 131 SUPPORT_FEATURE("jabber:x:conference") |
124 SUPPORT_FEATURE("jabber:x:conference") |
| 132 SUPPORT_FEATURE("http://jabber.org/protocol/bytestreams") |
125 SUPPORT_FEATURE("http://jabber.org/protocol/bytestreams") |
| 133 SUPPORT_FEATURE("http://jabber.org/protocol/disco#info") |
126 SUPPORT_FEATURE("http://jabber.org/protocol/disco#info") |
| 134 SUPPORT_FEATURE("http://jabber.org/protocol/disco#items") |
127 SUPPORT_FEATURE("http://jabber.org/protocol/disco#items") |
| 196 xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas"); |
189 xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas"); |
| 197 } |
190 } |
| 198 } |
191 } |
| 199 |
192 |
| 200 jabber_iq_send(iq); |
193 jabber_iq_send(iq); |
| 201 } else if(!strcmp(type, "result")) { |
194 } else if(type == JABBER_IQ_RESULT) { |
| 202 xmlnode *query = xmlnode_get_child(packet, "query"); |
|
| 203 xmlnode *child; |
195 xmlnode *child; |
| 204 JabberID *jid; |
196 JabberID *jid; |
| 205 JabberBuddy *jb; |
197 JabberBuddy *jb; |
| 206 JabberBuddyResource *jbr = NULL; |
198 JabberBuddyResource *jbr = NULL; |
| 207 JabberCapabilities capabilities = JABBER_CAP_NONE; |
199 JabberCapabilities capabilities = JABBER_CAP_NONE; |
| 214 } |
206 } |
| 215 |
207 |
| 216 if(jbr) |
208 if(jbr) |
| 217 capabilities = jbr->capabilities; |
209 capabilities = jbr->capabilities; |
| 218 |
210 |
| 219 for(child = query->child; child; child = child->next) { |
211 for(child = in_query->child; child; child = child->next) { |
| 220 if(child->type != XMLNODE_TYPE_TAG) |
212 if(child->type != XMLNODE_TYPE_TAG) |
| 221 continue; |
213 continue; |
| 222 |
214 |
| 223 if(!strcmp(child->name, "identity")) { |
215 if(!strcmp(child->name, "identity")) { |
| 224 const char *category = xmlnode_get_attrib(child, "category"); |
216 const char *category = xmlnode_get_attrib(child, "category"); |
| 285 |
277 |
| 286 if((jdicd = g_hash_table_lookup(js->disco_callbacks, from))) { |
278 if((jdicd = g_hash_table_lookup(js->disco_callbacks, from))) { |
| 287 jdicd->callback(js, from, capabilities, jdicd->data); |
279 jdicd->callback(js, from, capabilities, jdicd->data); |
| 288 g_hash_table_remove(js->disco_callbacks, from); |
280 g_hash_table_remove(js->disco_callbacks, from); |
| 289 } |
281 } |
| 290 } else if(!strcmp(type, "error")) { |
282 } else if(type == JABBER_IQ_ERROR) { |
| 291 JabberID *jid; |
283 JabberID *jid; |
| 292 JabberBuddy *jb; |
284 JabberBuddy *jb; |
| 293 JabberBuddyResource *jbr = NULL; |
285 JabberBuddyResource *jbr = NULL; |
| 294 JabberCapabilities capabilities = JABBER_CAP_NONE; |
286 JabberCapabilities capabilities = JABBER_CAP_NONE; |
| 295 struct _jabber_disco_info_cb_data *jdicd; |
287 struct _jabber_disco_info_cb_data *jdicd; |
| 309 jdicd->callback(js, from, capabilities, jdicd->data); |
301 jdicd->callback(js, from, capabilities, jdicd->data); |
| 310 g_hash_table_remove(js->disco_callbacks, from); |
302 g_hash_table_remove(js->disco_callbacks, from); |
| 311 } |
303 } |
| 312 } |
304 } |
| 313 |
305 |
| 314 void jabber_disco_items_parse(JabberStream *js, xmlnode *packet) { |
306 void jabber_disco_items_parse(JabberStream *js, const char *from, |
| 315 const char *from = xmlnode_get_attrib(packet, "from"); |
307 JabberIqType type, const char *id, |
| 316 const char *type = xmlnode_get_attrib(packet, "type"); |
308 xmlnode *query) { |
| 317 |
309 if(type == JABBER_IQ_GET) { |
| 318 if(type && !strcmp(type, "get")) { |
|
| 319 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, |
310 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, |
| 320 "http://jabber.org/protocol/disco#items"); |
311 "http://jabber.org/protocol/disco#items"); |
| 321 |
312 |
| 322 /* preserve node */ |
313 /* preserve node */ |
| 323 xmlnode *iq_query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#items"); |
314 xmlnode *iq_query = xmlnode_get_child(iq->node, "query"); |
| 324 if(iq_query) { |
315 const char *node = xmlnode_get_attrib(query, "node"); |
| 325 xmlnode *query = xmlnode_get_child_with_namespace(packet,"query","http://jabber.org/protocol/disco#items"); |
316 if(node) |
| 326 if(query) { |
317 xmlnode_set_attrib(iq_query,"node",node); |
| 327 const char *node = xmlnode_get_attrib(query,"node"); |
318 |
| 328 if(node) |
319 jabber_iq_set_id(iq, id); |
| 329 xmlnode_set_attrib(iq_query,"node",node); |
320 |
| 330 } |
321 if (from) |
| 331 } |
322 xmlnode_set_attrib(iq->node, "to", from); |
| 332 |
|
| 333 jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); |
|
| 334 |
|
| 335 xmlnode_set_attrib(iq->node, "to", from); |
|
| 336 jabber_iq_send(iq); |
323 jabber_iq_send(iq); |
| 337 } |
324 } |
| 338 } |
325 } |
| 339 |
326 |
| 340 static void |
327 static void |