Sun, 24 Jun 2007 04:53:36 +0000
support replying to XEP-0202 queries
| 8312 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 8312 | 3 | * |
| 4 | * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> | |
| 5 | * | |
| 6 | * This program is free software; you can redistribute it and/or modify | |
| 7 | * it under the terms of the GNU General Public License as published by | |
| 8 | * the Free Software Foundation; either version 2 of the License, or | |
| 9 | * (at your option) any later version. | |
| 10 | * | |
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 | * | |
| 20 | */ | |
| 21 | ||
| 22 | #include "internal.h" | |
| 23 | #include "prefs.h" | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
24 | #include "debug.h" |
| 8312 | 25 | |
| 26 | #include "buddy.h" | |
| 15225 | 27 | #include "google.h" |
| 8312 | 28 | #include "iq.h" |
| 29 | #include "disco.h" | |
| 13385 | 30 | #include "jabber.h" |
|
15344
34b7f4e55861
[gaim-migrate @ 18072]
Evan Schoenberg <evands@pidgin.im>
parents:
15323
diff
changeset
|
31 | #include "presence.h" |
| 15265 | 32 | #include "roster.h" |
| 8312 | 33 | |
| 34 | struct _jabber_disco_info_cb_data { | |
| 35 | gpointer data; | |
| 36 | JabberDiscoInfoCallback *callback; | |
| 37 | }; | |
| 38 | ||
| 39 | #define SUPPORT_FEATURE(x) \ | |
| 40 | feature = xmlnode_new_child(query, "feature"); \ | |
| 41 | xmlnode_set_attrib(feature, "var", x); | |
| 42 | ||
| 43 | ||
| 44 | void jabber_disco_info_parse(JabberStream *js, xmlnode *packet) { | |
| 45 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 46 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 47 | ||
| 48 | if(!from || !type) | |
| 49 | return; | |
| 50 | ||
| 51 | if(!strcmp(type, "get")) { | |
| 52 | xmlnode *query, *identity, *feature; | |
| 13385 | 53 | JabberIq *iq; |
| 54 | ||
| 55 | xmlnode *in_query; | |
| 56 | const char *node = NULL; | |
| 57 | ||
| 58 | if((in_query = xmlnode_get_child(packet, "query"))) { | |
| 59 | node = xmlnode_get_attrib(in_query, "node"); | |
| 60 | } | |
| 61 | ||
| 62 | ||
| 63 | iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, | |
| 8312 | 64 | "http://jabber.org/protocol/disco#info"); |
| 65 | ||
| 66 | jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); | |
| 67 | ||
| 68 | xmlnode_set_attrib(iq->node, "to", from); | |
| 69 | query = xmlnode_get_child(iq->node, "query"); | |
| 70 | ||
| 13385 | 71 | if(node) |
| 72 | xmlnode_set_attrib(query, "node", node); | |
| 73 | ||
| 74 | if(!node || !strcmp(node, CAPS0115_NODE "#" VERSION)) { | |
| 75 | ||
| 76 | identity = xmlnode_new_child(query, "identity"); | |
| 77 | xmlnode_set_attrib(identity, "category", "client"); | |
| 78 | xmlnode_set_attrib(identity, "type", "pc"); /* XXX: bot, console, | |
| 79 | * handheld, pc, phone, | |
| 80 | * web */ | |
| 13704 | 81 | xmlnode_set_attrib(identity, "name", PACKAGE); |
| 8312 | 82 | |
| 13385 | 83 | SUPPORT_FEATURE("jabber:iq:last") |
| 84 | SUPPORT_FEATURE("jabber:iq:oob") | |
| 85 | SUPPORT_FEATURE("jabber:iq:time") | |
|
18317
6c814e134e56
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18235
diff
changeset
|
86 | SUPPORT_FEATURE("xmpp:urn:time") |
| 13385 | 87 | SUPPORT_FEATURE("jabber:iq:version") |
| 88 | SUPPORT_FEATURE("jabber:x:conference") | |
| 89 | SUPPORT_FEATURE("http://jabber.org/protocol/bytestreams") | |
| 90 | SUPPORT_FEATURE("http://jabber.org/protocol/disco#info") | |
| 91 | SUPPORT_FEATURE("http://jabber.org/protocol/disco#items") | |
| 8312 | 92 | #if 0 |
| 13385 | 93 | SUPPORT_FEATURE("http://jabber.org/protocol/ibb") |
| 8312 | 94 | #endif |
| 13385 | 95 | SUPPORT_FEATURE("http://jabber.org/protocol/muc") |
| 96 | SUPPORT_FEATURE("http://jabber.org/protocol/muc#user") | |
| 97 | SUPPORT_FEATURE("http://jabber.org/protocol/si") | |
| 98 | SUPPORT_FEATURE("http://jabber.org/protocol/si/profile/file-transfer") | |
| 99 | SUPPORT_FEATURE("http://jabber.org/protocol/xhtml-im") | |
|
18181
736c6abf62f4
respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents:
17423
diff
changeset
|
100 | SUPPORT_FEATURE("urn:xmpp:ping") |
| 13385 | 101 | } else { |
| 102 | xmlnode *error, *inf; | |
| 103 | ||
| 104 | /* XXX: gross hack, implement jabber_iq_set_type or something */ | |
| 105 | xmlnode_set_attrib(iq->node, "type", "error"); | |
| 106 | iq->type = JABBER_IQ_ERROR; | |
| 107 | ||
| 108 | error = xmlnode_new_child(query, "error"); | |
| 109 | xmlnode_set_attrib(error, "code", "404"); | |
| 110 | xmlnode_set_attrib(error, "type", "cancel"); | |
| 111 | inf = xmlnode_new_child(error, "item-not-found"); | |
| 13808 | 112 | xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas"); |
| 13385 | 113 | } |
| 8312 | 114 | |
| 115 | jabber_iq_send(iq); | |
| 116 | } else if(!strcmp(type, "result")) { | |
| 117 | xmlnode *query = xmlnode_get_child(packet, "query"); | |
| 118 | xmlnode *child; | |
| 119 | JabberID *jid; | |
| 120 | JabberBuddy *jb; | |
| 121 | JabberBuddyResource *jbr = NULL; | |
| 122 | JabberCapabilities capabilities = JABBER_CAP_NONE; | |
| 123 | struct _jabber_disco_info_cb_data *jdicd; | |
| 124 | ||
| 125 | if((jid = jabber_id_new(from))) { | |
| 126 | if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE))) | |
| 127 | jbr = jabber_buddy_find_resource(jb, jid->resource); | |
| 128 | jabber_id_free(jid); | |
| 129 | } | |
| 130 | ||
| 131 | if(jbr) | |
| 132 | capabilities = jbr->capabilities; | |
| 133 | ||
| 134 | for(child = query->child; child; child = child->next) { | |
| 135 | if(child->type != XMLNODE_TYPE_TAG) | |
| 136 | continue; | |
| 137 | ||
| 138 | if(!strcmp(child->name, "identity")) { | |
| 139 | const char *category = xmlnode_get_attrib(child, "category"); | |
| 140 | const char *type = xmlnode_get_attrib(child, "type"); | |
| 141 | if(!category || !type) | |
| 142 | continue; | |
| 143 | ||
| 11675 | 144 | if(!strcmp(category, "conference") && !strcmp(type, "text")) { |
| 145 | /* we found a groupchat or MUC server, add it to the list */ | |
| 146 | /* XXX: actually check for protocol/muc or gc-1.0 support */ | |
| 8312 | 147 | js->chat_servers = g_list_append(js->chat_servers, g_strdup(from)); |
| 11675 | 148 | } else if(!strcmp(category, "directory") && !strcmp(type, "user")) { |
| 149 | /* we found a JUD */ | |
| 150 | js->user_directories = g_list_append(js->user_directories, g_strdup(from)); | |
| 151 | } | |
| 8312 | 152 | |
| 153 | } else if(!strcmp(child->name, "feature")) { | |
| 154 | const char *var = xmlnode_get_attrib(child, "var"); | |
| 155 | if(!var) | |
| 156 | continue; | |
| 157 | ||
| 158 | if(!strcmp(var, "http://jabber.org/protocol/si")) | |
| 159 | capabilities |= JABBER_CAP_SI; | |
| 160 | else if(!strcmp(var, "http://jabber.org/protocol/si/profile/file-transfer")) | |
| 161 | capabilities |= JABBER_CAP_SI_FILE_XFER; | |
| 162 | else if(!strcmp(var, "http://jabber.org/protocol/bytestreams")) | |
| 163 | capabilities |= JABBER_CAP_BYTESTREAMS; | |
| 11675 | 164 | else if(!strcmp(var, "jabber:iq:search")) |
| 165 | capabilities |= JABBER_CAP_IQ_SEARCH; | |
| 166 | else if(!strcmp(var, "jabber:iq:register")) | |
| 167 | capabilities |= JABBER_CAP_IQ_REGISTER; | |
| 8312 | 168 | } |
| 169 | } | |
| 170 | ||
| 171 | capabilities |= JABBER_CAP_RETRIEVED; | |
| 172 | ||
| 173 | if(jbr) | |
| 174 | jbr->capabilities = capabilities; | |
| 175 | ||
| 176 | if((jdicd = g_hash_table_lookup(js->disco_callbacks, from))) { | |
| 177 | jdicd->callback(js, from, capabilities, jdicd->data); | |
| 178 | g_hash_table_remove(js->disco_callbacks, from); | |
| 179 | } | |
| 180 | } else if(!strcmp(type, "error")) { | |
| 181 | JabberID *jid; | |
| 182 | JabberBuddy *jb; | |
| 183 | JabberBuddyResource *jbr = NULL; | |
| 184 | JabberCapabilities capabilities = JABBER_CAP_NONE; | |
| 185 | struct _jabber_disco_info_cb_data *jdicd; | |
| 186 | ||
| 187 | if(!(jdicd = g_hash_table_lookup(js->disco_callbacks, from))) | |
| 188 | return; | |
| 189 | ||
| 190 | if((jid = jabber_id_new(from))) { | |
| 191 | if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE))) | |
| 192 | jbr = jabber_buddy_find_resource(jb, jid->resource); | |
| 193 | jabber_id_free(jid); | |
| 194 | } | |
| 195 | ||
| 196 | if(jbr) | |
| 197 | capabilities = jbr->capabilities; | |
| 198 | ||
| 199 | jdicd->callback(js, from, capabilities, jdicd->data); | |
| 200 | g_hash_table_remove(js->disco_callbacks, from); | |
| 201 | } | |
| 202 | } | |
| 203 | ||
| 204 | void jabber_disco_items_parse(JabberStream *js, xmlnode *packet) { | |
| 205 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 206 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 207 | ||
| 14356 | 208 | if(type && !strcmp(type, "get")) { |
| 8312 | 209 | JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, |
| 210 | "http://jabber.org/protocol/disco#items"); | |
| 211 | ||
| 212 | jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); | |
| 213 | ||
| 214 | xmlnode_set_attrib(iq->node, "to", from); | |
| 215 | jabber_iq_send(iq); | |
| 216 | } | |
| 217 | } | |
| 218 | ||
| 219 | static void | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
220 | jabber_disco_finish_server_info_result_cb(JabberStream *js) |
| 15197 | 221 | { |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18225
diff
changeset
|
222 | |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18225
diff
changeset
|
223 | jabber_vcard_fetch_mine(js); |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18225
diff
changeset
|
224 | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
225 | if (!(js->server_caps & JABBER_CAP_GOOGLE_ROSTER)) { |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
226 | /* If the server supports JABBER_CAP_GOOGLE_ROSTER; we will have already requested it */ |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
227 | jabber_roster_request(js); |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
228 | } |
| 17421 | 229 | |
|
18196
a7992a42dc3d
fix inital presence (fixes #1395)
Nathan Walp <nwalp@pidgin.im>
parents:
18181
diff
changeset
|
230 | /* when we get the roster back, we'll send our initial presence */ |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
231 | } |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
232 | |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
233 | static void |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
234 | jabber_disco_server_info_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
235 | { |
| 17421 | 236 | xmlnode *query, *child; |
| 15197 | 237 | const char *from = xmlnode_get_attrib(packet, "from"); |
| 238 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 239 | ||
|
15358
c8179e0a5483
[gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents:
15355
diff
changeset
|
240 | if((!from || !type) || |
|
c8179e0a5483
[gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents:
15355
diff
changeset
|
241 | (strcmp(from, js->user->domain))) { |
|
c8179e0a5483
[gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents:
15355
diff
changeset
|
242 | jabber_disco_finish_server_info_result_cb(js); |
| 15197 | 243 | return; |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
244 | } |
| 15197 | 245 | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
246 | if(strcmp(type, "result")) { |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
247 | /* A common way to get here is for the server not to support xmlns http://jabber.org/protocol/disco#info */ |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
248 | jabber_disco_finish_server_info_result_cb(js); |
| 15197 | 249 | return; |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
250 | } |
| 15197 | 251 | |
| 252 | query = xmlnode_get_child(packet, "query"); | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
253 | |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
254 | if (!query) { |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
255 | jabber_disco_finish_server_info_result_cb(js); |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
256 | return; |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
257 | } |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
258 | |
| 17421 | 259 | for (child = xmlnode_get_child(query, "identity"); child; |
| 15197 | 260 | child = xmlnode_get_next_twin(child)) { |
| 261 | const char *category, *type, *name; | |
| 262 | category = xmlnode_get_attrib(child, "category"); | |
| 263 | if (!category || strcmp(category, "server")) | |
| 264 | continue; | |
| 265 | type = xmlnode_get_attrib(child, "type"); | |
| 266 | if (!type || strcmp(type, "im")) | |
| 267 | continue; | |
| 17421 | 268 | |
| 15197 | 269 | name = xmlnode_get_attrib(child, "name"); |
| 270 | if (!name) | |
| 271 | continue; | |
| 272 | ||
| 273 | g_free(js->server_name); | |
| 274 | js->server_name = g_strdup(name); | |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
275 | if (!strcmp(name, "Google Talk")) { |
| 15884 | 276 | purple_debug_info("jabber", "Google Talk!"); |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
277 | js->googletalk = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
278 | } |
| 15197 | 279 | } |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
280 | |
| 17421 | 281 | for (child = xmlnode_get_child(query, "feature"); child; |
| 15225 | 282 | child = xmlnode_get_next_twin(child)) { |
| 283 | const char *var; | |
| 284 | var = xmlnode_get_attrib(child, "var"); | |
| 285 | if (!var) | |
| 286 | continue; | |
| 287 | ||
| 288 | if (!strcmp("google:mail:notify", var)) { | |
| 289 | js->server_caps |= JABBER_CAP_GMAIL_NOTIFY; | |
| 290 | jabber_gmail_init(js); | |
| 15265 | 291 | } else if (!strcmp("google:roster", var)) { |
| 292 | js->server_caps |= JABBER_CAP_GOOGLE_ROSTER; | |
| 293 | jabber_google_roster_init(js); | |
| 15225 | 294 | } |
| 295 | } | |
| 15265 | 296 | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
297 | jabber_disco_finish_server_info_result_cb(js); |
| 15197 | 298 | } |
| 299 | ||
| 300 | static void | |
| 301 | jabber_disco_server_items_result_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
| 8312 | 302 | { |
| 303 | xmlnode *query, *child; | |
| 304 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 305 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 306 | ||
| 307 | if(!from || !type) | |
| 308 | return; | |
| 309 | ||
| 310 | if(strcmp(from, js->user->domain)) | |
| 311 | return; | |
| 312 | ||
| 313 | if(strcmp(type, "result")) | |
| 314 | return; | |
| 315 | ||
| 316 | while(js->chat_servers) { | |
| 317 | g_free(js->chat_servers->data); | |
| 318 | js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers); | |
| 319 | } | |
| 320 | ||
| 321 | query = xmlnode_get_child(packet, "query"); | |
| 322 | ||
| 323 | for(child = xmlnode_get_child(query, "item"); child; | |
| 324 | child = xmlnode_get_next_twin(child)) { | |
| 325 | JabberIq *iq; | |
|
17423
1f3a88fda48e
skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents:
17421
diff
changeset
|
326 | const char *jid, *node; |
| 8312 | 327 | |
| 328 | if(!(jid = xmlnode_get_attrib(child, "jid"))) | |
| 329 | continue; | |
| 330 | ||
|
17423
1f3a88fda48e
skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents:
17421
diff
changeset
|
331 | /* we don't actually care about the specific nodes, |
|
1f3a88fda48e
skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents:
17421
diff
changeset
|
332 | * so we won't query them */ |
|
1f3a88fda48e
skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents:
17421
diff
changeset
|
333 | if((node = xmlnode_get_attrib(child, "node"))) |
|
1f3a88fda48e
skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents:
17421
diff
changeset
|
334 | continue; |
|
1f3a88fda48e
skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents:
17421
diff
changeset
|
335 | |
| 8312 | 336 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info"); |
| 337 | xmlnode_set_attrib(iq->node, "to", jid); | |
| 338 | jabber_iq_send(iq); | |
| 339 | } | |
| 340 | } | |
| 341 | ||
| 342 | void jabber_disco_items_server(JabberStream *js) | |
| 343 | { | |
| 344 | JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, | |
| 345 | "http://jabber.org/protocol/disco#items"); | |
| 346 | ||
| 347 | xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
| 348 | ||
| 15197 | 349 | jabber_iq_set_callback(iq, jabber_disco_server_items_result_cb, NULL); |
| 350 | jabber_iq_send(iq); | |
| 351 | ||
| 352 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, | |
| 353 | "http://jabber.org/protocol/disco#info"); | |
| 354 | xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
| 355 | jabber_iq_set_callback(iq, jabber_disco_server_info_result_cb, NULL); | |
| 8312 | 356 | jabber_iq_send(iq); |
| 357 | } | |
| 358 | ||
| 359 | void jabber_disco_info_do(JabberStream *js, const char *who, JabberDiscoInfoCallback *callback, gpointer data) | |
| 360 | { | |
| 361 | JabberID *jid; | |
| 362 | JabberBuddy *jb; | |
| 363 | JabberBuddyResource *jbr = NULL; | |
| 364 | struct _jabber_disco_info_cb_data *jdicd; | |
| 365 | JabberIq *iq; | |
| 366 | ||
| 367 | if((jid = jabber_id_new(who))) { | |
| 368 | if(jid->resource && (jb = jabber_buddy_find(js, who, TRUE))) | |
| 369 | jbr = jabber_buddy_find_resource(jb, jid->resource); | |
| 370 | jabber_id_free(jid); | |
| 371 | } | |
| 372 | ||
| 373 | if(jbr && jbr->capabilities & JABBER_CAP_RETRIEVED) { | |
| 374 | callback(js, who, jbr->capabilities, data); | |
| 375 | return; | |
| 376 | } | |
| 377 | ||
| 378 | jdicd = g_new0(struct _jabber_disco_info_cb_data, 1); | |
| 379 | jdicd->data = data; | |
| 380 | jdicd->callback = callback; | |
| 381 | ||
| 382 | g_hash_table_insert(js->disco_callbacks, g_strdup(who), jdicd); | |
| 383 | ||
| 384 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info"); | |
| 385 | xmlnode_set_attrib(iq->node, "to", who); | |
| 386 | ||
| 387 | jabber_iq_send(iq); | |
| 388 | } | |
| 389 | ||
| 390 |