Wed, 06 Jun 2007 00:01:15 +0000
added preliminary frame for pep-support
| 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" |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17423
diff
changeset
|
33 | #include "pep.h" |
| 8312 | 34 | |
| 35 | struct _jabber_disco_info_cb_data { | |
| 36 | gpointer data; | |
| 37 | JabberDiscoInfoCallback *callback; | |
| 38 | }; | |
| 39 | ||
| 40 | #define SUPPORT_FEATURE(x) \ | |
| 41 | feature = xmlnode_new_child(query, "feature"); \ | |
| 42 | xmlnode_set_attrib(feature, "var", x); | |
| 43 | ||
| 44 | ||
| 45 | void jabber_disco_info_parse(JabberStream *js, xmlnode *packet) { | |
| 46 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 47 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 48 | ||
| 49 | if(!from || !type) | |
| 50 | return; | |
| 51 | ||
| 52 | if(!strcmp(type, "get")) { | |
| 53 | xmlnode *query, *identity, *feature; | |
| 13385 | 54 | JabberIq *iq; |
| 55 | ||
| 56 | xmlnode *in_query; | |
| 57 | const char *node = NULL; | |
| 58 | ||
| 59 | if((in_query = xmlnode_get_child(packet, "query"))) { | |
| 60 | node = xmlnode_get_attrib(in_query, "node"); | |
| 61 | } | |
| 62 | ||
| 63 | ||
| 64 | iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, | |
| 8312 | 65 | "http://jabber.org/protocol/disco#info"); |
| 66 | ||
| 67 | jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); | |
| 68 | ||
| 69 | xmlnode_set_attrib(iq->node, "to", from); | |
| 70 | query = xmlnode_get_child(iq->node, "query"); | |
| 71 | ||
| 13385 | 72 | if(node) |
| 73 | xmlnode_set_attrib(query, "node", node); | |
| 74 | ||
| 75 | if(!node || !strcmp(node, CAPS0115_NODE "#" VERSION)) { | |
| 76 | ||
| 77 | identity = xmlnode_new_child(query, "identity"); | |
| 78 | xmlnode_set_attrib(identity, "category", "client"); | |
| 79 | xmlnode_set_attrib(identity, "type", "pc"); /* XXX: bot, console, | |
| 80 | * handheld, pc, phone, | |
| 81 | * web */ | |
| 13704 | 82 | xmlnode_set_attrib(identity, "name", PACKAGE); |
| 8312 | 83 | |
| 13385 | 84 | SUPPORT_FEATURE("jabber:iq:last") |
| 85 | SUPPORT_FEATURE("jabber:iq:oob") | |
| 86 | SUPPORT_FEATURE("jabber:iq:time") | |
| 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") | |
| 100 | } else { | |
| 101 | xmlnode *error, *inf; | |
| 102 | ||
| 103 | /* XXX: gross hack, implement jabber_iq_set_type or something */ | |
| 104 | xmlnode_set_attrib(iq->node, "type", "error"); | |
| 105 | iq->type = JABBER_IQ_ERROR; | |
| 106 | ||
| 107 | error = xmlnode_new_child(query, "error"); | |
| 108 | xmlnode_set_attrib(error, "code", "404"); | |
| 109 | xmlnode_set_attrib(error, "type", "cancel"); | |
| 110 | inf = xmlnode_new_child(error, "item-not-found"); | |
| 13808 | 111 | xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas"); |
| 13385 | 112 | } |
| 8312 | 113 | |
| 114 | jabber_iq_send(iq); | |
| 115 | } else if(!strcmp(type, "result")) { | |
| 116 | xmlnode *query = xmlnode_get_child(packet, "query"); | |
| 117 | xmlnode *child; | |
| 118 | JabberID *jid; | |
| 119 | JabberBuddy *jb; | |
| 120 | JabberBuddyResource *jbr = NULL; | |
| 121 | JabberCapabilities capabilities = JABBER_CAP_NONE; | |
| 122 | struct _jabber_disco_info_cb_data *jdicd; | |
| 123 | ||
| 124 | if((jid = jabber_id_new(from))) { | |
| 125 | if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE))) | |
| 126 | jbr = jabber_buddy_find_resource(jb, jid->resource); | |
| 127 | jabber_id_free(jid); | |
| 128 | } | |
| 129 | ||
| 130 | if(jbr) | |
| 131 | capabilities = jbr->capabilities; | |
| 132 | ||
| 133 | for(child = query->child; child; child = child->next) { | |
| 134 | if(child->type != XMLNODE_TYPE_TAG) | |
| 135 | continue; | |
| 136 | ||
| 137 | if(!strcmp(child->name, "identity")) { | |
| 138 | const char *category = xmlnode_get_attrib(child, "category"); | |
| 139 | const char *type = xmlnode_get_attrib(child, "type"); | |
| 140 | if(!category || !type) | |
| 141 | continue; | |
| 142 | ||
| 11675 | 143 | if(!strcmp(category, "conference") && !strcmp(type, "text")) { |
| 144 | /* we found a groupchat or MUC server, add it to the list */ | |
| 145 | /* XXX: actually check for protocol/muc or gc-1.0 support */ | |
| 8312 | 146 | js->chat_servers = g_list_append(js->chat_servers, g_strdup(from)); |
| 11675 | 147 | } else if(!strcmp(category, "directory") && !strcmp(type, "user")) { |
| 148 | /* we found a JUD */ | |
| 149 | js->user_directories = g_list_append(js->user_directories, g_strdup(from)); | |
| 150 | } | |
| 8312 | 151 | |
| 152 | } else if(!strcmp(child->name, "feature")) { | |
| 153 | const char *var = xmlnode_get_attrib(child, "var"); | |
| 154 | if(!var) | |
| 155 | continue; | |
| 156 | ||
| 157 | if(!strcmp(var, "http://jabber.org/protocol/si")) | |
| 158 | capabilities |= JABBER_CAP_SI; | |
| 159 | else if(!strcmp(var, "http://jabber.org/protocol/si/profile/file-transfer")) | |
| 160 | capabilities |= JABBER_CAP_SI_FILE_XFER; | |
| 161 | else if(!strcmp(var, "http://jabber.org/protocol/bytestreams")) | |
| 162 | capabilities |= JABBER_CAP_BYTESTREAMS; | |
| 11675 | 163 | else if(!strcmp(var, "jabber:iq:search")) |
| 164 | capabilities |= JABBER_CAP_IQ_SEARCH; | |
| 165 | else if(!strcmp(var, "jabber:iq:register")) | |
| 166 | capabilities |= JABBER_CAP_IQ_REGISTER; | |
| 8312 | 167 | } |
| 168 | } | |
| 169 | ||
| 170 | capabilities |= JABBER_CAP_RETRIEVED; | |
| 171 | ||
| 172 | if(jbr) | |
| 173 | jbr->capabilities = capabilities; | |
| 174 | ||
| 175 | if((jdicd = g_hash_table_lookup(js->disco_callbacks, from))) { | |
| 176 | jdicd->callback(js, from, capabilities, jdicd->data); | |
| 177 | g_hash_table_remove(js->disco_callbacks, from); | |
| 178 | } | |
| 179 | } else if(!strcmp(type, "error")) { | |
| 180 | JabberID *jid; | |
| 181 | JabberBuddy *jb; | |
| 182 | JabberBuddyResource *jbr = NULL; | |
| 183 | JabberCapabilities capabilities = JABBER_CAP_NONE; | |
| 184 | struct _jabber_disco_info_cb_data *jdicd; | |
| 185 | ||
| 186 | if(!(jdicd = g_hash_table_lookup(js->disco_callbacks, from))) | |
| 187 | return; | |
| 188 | ||
| 189 | if((jid = jabber_id_new(from))) { | |
| 190 | if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE))) | |
| 191 | jbr = jabber_buddy_find_resource(jb, jid->resource); | |
| 192 | jabber_id_free(jid); | |
| 193 | } | |
| 194 | ||
| 195 | if(jbr) | |
| 196 | capabilities = jbr->capabilities; | |
| 197 | ||
| 198 | jdicd->callback(js, from, capabilities, jdicd->data); | |
| 199 | g_hash_table_remove(js->disco_callbacks, from); | |
| 200 | } | |
| 201 | } | |
| 202 | ||
| 203 | void jabber_disco_items_parse(JabberStream *js, xmlnode *packet) { | |
| 204 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 205 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 206 | ||
| 14356 | 207 | if(type && !strcmp(type, "get")) { |
| 8312 | 208 | JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, |
| 209 | "http://jabber.org/protocol/disco#items"); | |
| 210 | ||
| 211 | jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); | |
| 212 | ||
| 213 | xmlnode_set_attrib(iq->node, "to", from); | |
| 214 | jabber_iq_send(iq); | |
| 215 | } | |
| 216 | } | |
| 217 | ||
| 218 | static void | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
219 | jabber_disco_finish_server_info_result_cb(JabberStream *js) |
| 15197 | 220 | { |
| 15884 | 221 | PurplePresence *gpresence; |
| 222 | PurpleStatus *status; | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
223 | |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
224 | if (!(js->server_caps & JABBER_CAP_GOOGLE_ROSTER)) { |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
225 | /* 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
|
226 | jabber_roster_request(js); |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
227 | } |
| 17421 | 228 | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
229 | /* Send initial presence; this will trigger receipt of presence for contacts on the roster */ |
| 15884 | 230 | gpresence = purple_account_get_presence(js->gc->account); |
| 231 | status = purple_presence_get_active_status(gpresence); | |
| 17421 | 232 | jabber_presence_send(js->gc->account, status); |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
233 | } |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
234 | |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
235 | static void |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
236 | 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
|
237 | { |
| 17421 | 238 | xmlnode *query, *child; |
| 15197 | 239 | const char *from = xmlnode_get_attrib(packet, "from"); |
| 240 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 241 | ||
|
15358
c8179e0a5483
[gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents:
15355
diff
changeset
|
242 | if((!from || !type) || |
|
c8179e0a5483
[gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents:
15355
diff
changeset
|
243 | (strcmp(from, js->user->domain))) { |
|
c8179e0a5483
[gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents:
15355
diff
changeset
|
244 | jabber_disco_finish_server_info_result_cb(js); |
| 15197 | 245 | return; |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
246 | } |
| 15197 | 247 | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
248 | if(strcmp(type, "result")) { |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
249 | /* 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
|
250 | jabber_disco_finish_server_info_result_cb(js); |
| 15197 | 251 | return; |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
252 | } |
| 15197 | 253 | |
| 254 | query = xmlnode_get_child(packet, "query"); | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
255 | |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
256 | if (!query) { |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
257 | jabber_disco_finish_server_info_result_cb(js); |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
258 | return; |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
259 | } |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
260 | |
| 17421 | 261 | for (child = xmlnode_get_child(query, "identity"); child; |
| 15197 | 262 | child = xmlnode_get_next_twin(child)) { |
| 263 | const char *category, *type, *name; | |
| 264 | category = xmlnode_get_attrib(child, "category"); | |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17423
diff
changeset
|
265 | type = xmlnode_get_attrib(child, "type"); |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17423
diff
changeset
|
266 | if(category && type && !strcmp(category, "pubsub") && !strcmp(type,"pep")) { |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17423
diff
changeset
|
267 | /* server supports pep, initialize it */ |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17423
diff
changeset
|
268 | jabber_pep_init(js); |
|
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17423
diff
changeset
|
269 | } |
| 15197 | 270 | if (!category || strcmp(category, "server")) |
| 271 | continue; | |
| 272 | if (!type || strcmp(type, "im")) | |
| 273 | continue; | |
| 17421 | 274 | |
| 15197 | 275 | name = xmlnode_get_attrib(child, "name"); |
| 276 | if (!name) | |
| 277 | continue; | |
| 278 | ||
| 279 | g_free(js->server_name); | |
| 280 | 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
|
281 | if (!strcmp(name, "Google Talk")) { |
| 15884 | 282 | 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
|
283 | js->googletalk = TRUE; |
|
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
284 | } |
| 15197 | 285 | } |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
286 | |
| 17421 | 287 | for (child = xmlnode_get_child(query, "feature"); child; |
| 15225 | 288 | child = xmlnode_get_next_twin(child)) { |
| 289 | const char *var; | |
| 290 | var = xmlnode_get_attrib(child, "var"); | |
| 291 | if (!var) | |
| 292 | continue; | |
| 293 | ||
| 294 | if (!strcmp("google:mail:notify", var)) { | |
| 295 | js->server_caps |= JABBER_CAP_GMAIL_NOTIFY; | |
| 296 | jabber_gmail_init(js); | |
| 15265 | 297 | } else if (!strcmp("google:roster", var)) { |
| 298 | js->server_caps |= JABBER_CAP_GOOGLE_ROSTER; | |
| 299 | jabber_google_roster_init(js); | |
| 15225 | 300 | } |
| 301 | } | |
| 15265 | 302 | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
303 | jabber_disco_finish_server_info_result_cb(js); |
| 15197 | 304 | } |
| 305 | ||
| 306 | static void | |
| 307 | jabber_disco_server_items_result_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
| 8312 | 308 | { |
| 309 | xmlnode *query, *child; | |
| 310 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 311 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 312 | ||
| 313 | if(!from || !type) | |
| 314 | return; | |
| 315 | ||
| 316 | if(strcmp(from, js->user->domain)) | |
| 317 | return; | |
| 318 | ||
| 319 | if(strcmp(type, "result")) | |
| 320 | return; | |
| 321 | ||
| 322 | while(js->chat_servers) { | |
| 323 | g_free(js->chat_servers->data); | |
| 324 | js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers); | |
| 325 | } | |
| 326 | ||
| 327 | query = xmlnode_get_child(packet, "query"); | |
| 328 | ||
| 329 | for(child = xmlnode_get_child(query, "item"); child; | |
| 330 | child = xmlnode_get_next_twin(child)) { | |
| 331 | 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
|
332 | const char *jid, *node; |
| 8312 | 333 | |
| 334 | if(!(jid = xmlnode_get_attrib(child, "jid"))) | |
| 335 | continue; | |
| 336 | ||
|
17423
1f3a88fda48e
skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents:
17421
diff
changeset
|
337 | /* 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
|
338 | * 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
|
339 | 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
|
340 | continue; |
|
1f3a88fda48e
skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents:
17421
diff
changeset
|
341 | |
| 8312 | 342 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info"); |
| 343 | xmlnode_set_attrib(iq->node, "to", jid); | |
| 344 | jabber_iq_send(iq); | |
| 345 | } | |
| 346 | } | |
| 347 | ||
| 348 | void jabber_disco_items_server(JabberStream *js) | |
| 349 | { | |
| 350 | JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, | |
| 351 | "http://jabber.org/protocol/disco#items"); | |
| 352 | ||
| 353 | xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
| 354 | ||
| 15197 | 355 | jabber_iq_set_callback(iq, jabber_disco_server_items_result_cb, NULL); |
| 356 | jabber_iq_send(iq); | |
| 357 | ||
| 358 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, | |
| 359 | "http://jabber.org/protocol/disco#info"); | |
| 360 | xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
| 361 | jabber_iq_set_callback(iq, jabber_disco_server_info_result_cb, NULL); | |
| 8312 | 362 | jabber_iq_send(iq); |
| 363 | } | |
| 364 | ||
| 365 | void jabber_disco_info_do(JabberStream *js, const char *who, JabberDiscoInfoCallback *callback, gpointer data) | |
| 366 | { | |
| 367 | JabberID *jid; | |
| 368 | JabberBuddy *jb; | |
| 369 | JabberBuddyResource *jbr = NULL; | |
| 370 | struct _jabber_disco_info_cb_data *jdicd; | |
| 371 | JabberIq *iq; | |
| 372 | ||
| 373 | if((jid = jabber_id_new(who))) { | |
| 374 | if(jid->resource && (jb = jabber_buddy_find(js, who, TRUE))) | |
| 375 | jbr = jabber_buddy_find_resource(jb, jid->resource); | |
| 376 | jabber_id_free(jid); | |
| 377 | } | |
| 378 | ||
| 379 | if(jbr && jbr->capabilities & JABBER_CAP_RETRIEVED) { | |
| 380 | callback(js, who, jbr->capabilities, data); | |
| 381 | return; | |
| 382 | } | |
| 383 | ||
| 384 | jdicd = g_new0(struct _jabber_disco_info_cb_data, 1); | |
| 385 | jdicd->data = data; | |
| 386 | jdicd->callback = callback; | |
| 387 | ||
| 388 | g_hash_table_insert(js->disco_callbacks, g_strdup(who), jdicd); | |
| 389 | ||
| 390 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info"); | |
| 391 | xmlnode_set_attrib(iq->node, "to", who); | |
| 392 | ||
| 393 | jabber_iq_send(iq); | |
| 394 | } | |
| 395 | ||
| 396 |