libpurple/protocols/jabber/disco.c

Mon, 10 Sep 2007 13:57:15 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Mon, 10 Sep 2007 13:57:15 +0000
changeset 19897
8b5abbdebc87
parent 19896
b0586b3697e8
parent 19859
71d37b57eff2
child 21688
a16385b34219
permissions
-rw-r--r--

merge of 'b0586b3697e8044ccd62a369b0c0f9125b2ef732'
and 'dcb0081acd70c340b0592fcf855418558338af99'

8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15722
diff changeset
2 * purple - Jabber Protocol Plugin
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19832
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 #include "internal.h"
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "prefs.h"
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
24 #include "debug.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26 #include "buddy.h"
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
27 #include "google.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 #include "iq.h"
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29 #include "disco.h"
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
30 #include "jabber.h"
15344
34b7f4e55861 [gaim-migrate @ 18072]
Evan Schoenberg <evands@pidgin.im>
parents: 15323
diff changeset
31 #include "presence.h"
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
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"
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
34 #include "adhoccommands.h"
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
35
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 struct _jabber_disco_info_cb_data {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 gpointer data;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39 JabberDiscoInfoCallback *callback;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40 };
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41
17783
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17773
diff changeset
42 #define SUPPORT_FEATURE(x) { \
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43 feature = xmlnode_new_child(query, "feature"); \
17783
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17773
diff changeset
44 xmlnode_set_attrib(feature, "var", x); \
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17773
diff changeset
45 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 void jabber_disco_info_parse(JabberStream *js, xmlnode *packet) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49 const char *from = xmlnode_get_attrib(packet, "from");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 const char *type = xmlnode_get_attrib(packet, "type");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 if(!from || !type)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
53 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
54
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55 if(!strcmp(type, "get")) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
56 xmlnode *query, *identity, *feature;
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
57 JabberIq *iq;
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
58
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
59 xmlnode *in_query;
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
60 const char *node = NULL;
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
61
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
62 if((in_query = xmlnode_get_child(packet, "query"))) {
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
63 node = xmlnode_get_attrib(in_query, "node");
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
64 }
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
65
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
66
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
67 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT,
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68 "http://jabber.org/protocol/disco#info");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
69
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
70 jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id"));
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
72 xmlnode_set_attrib(iq->node, "to", from);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
73 query = xmlnode_get_child(iq->node, "query");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
74
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
75 if(node)
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
76 xmlnode_set_attrib(query, "node", node);
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
77
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
78 if(!node || !strcmp(node, CAPS0115_NODE "#" VERSION)) {
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
79 identity = xmlnode_new_child(query, "identity");
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
80 xmlnode_set_attrib(identity, "category", "client");
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
81 xmlnode_set_attrib(identity, "type", "pc"); /* XXX: bot, console,
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
82 * handheld, pc, phone,
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
83 * web */
13704
5800709f09f0 [gaim-migrate @ 16105]
Nathan Walp <nwalp@pidgin.im>
parents: 13703
diff changeset
84 xmlnode_set_attrib(identity, "name", PACKAGE);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
85
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
86 SUPPORT_FEATURE("jabber:iq:last")
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
87 SUPPORT_FEATURE("jabber:iq:oob")
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
88 SUPPORT_FEATURE("jabber:iq:time")
18317
6c814e134e56 support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents: 18235
diff changeset
89 SUPPORT_FEATURE("xmpp:urn:time")
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
90 SUPPORT_FEATURE("jabber:iq:version")
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
91 SUPPORT_FEATURE("jabber:x:conference")
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
92 SUPPORT_FEATURE("http://jabber.org/protocol/bytestreams")
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
93 SUPPORT_FEATURE("http://jabber.org/protocol/disco#info")
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
94 SUPPORT_FEATURE("http://jabber.org/protocol/disco#items")
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 #if 0
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
96 SUPPORT_FEATURE("http://jabber.org/protocol/ibb")
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
97 #endif
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
98 SUPPORT_FEATURE("http://jabber.org/protocol/muc")
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
99 SUPPORT_FEATURE("http://jabber.org/protocol/muc#user")
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
100 SUPPORT_FEATURE("http://jabber.org/protocol/si")
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
101 SUPPORT_FEATURE("http://jabber.org/protocol/si/profile/file-transfer")
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
102 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
103 SUPPORT_FEATURE("urn:xmpp:ping")
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
104 SUPPORT_FEATURE("http://www.xmpp.org/extensions/xep-0199.html#ns")
19894
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
105
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
106 if(!node) { /* non-caps disco#info, add all enabled extensions */
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
107 GList *features;
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
108 for(features = jabber_features; features; features = features->next) {
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
109 JabberFeature *feat = (JabberFeature*)features->data;
17783
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17773
diff changeset
110 if(feat->is_enabled == NULL || feat->is_enabled(js, feat->shortname, feat->namespace) == TRUE)
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17773
diff changeset
111 SUPPORT_FEATURE(feat->namespace);
19894
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
112 }
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
113 }
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
114 } else {
19894
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
115 const char *ext = NULL;
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
116 unsigned pos;
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
117 unsigned nodelen = strlen(node);
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
118 unsigned capslen = strlen(CAPS0115_NODE);
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
119 /* do a basic plausability check */
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
120 if(nodelen > capslen+1) {
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
121 /* verify that the string is CAPS0115#<ext> and get the pointer to the ext part */
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
122 for(pos = 0; pos < capslen+1; ++pos) {
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
123 if(pos == capslen) {
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
124 if(node[pos] == '#')
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
125 ext = &node[pos+1];
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
126 else
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
127 break;
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
128 } else if(node[pos] != CAPS0115_NODE[pos])
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
129 break;
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
130 }
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
131
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
132 if(ext != NULL) {
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
133 /* look for that ext */
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
134 GList *features;
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
135 for(features = jabber_features; features; features = features->next) {
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
136 JabberFeature *feat = (JabberFeature*)features->data;
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
137 if(!strcmp(feat->shortname, ext)) {
17783
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17773
diff changeset
138 SUPPORT_FEATURE(feat->namespace);
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17773
diff changeset
139 break;
19894
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
140 }
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
141 }
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
142 if(features == NULL)
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
143 ext = NULL;
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
144 }
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
145 }
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
146
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
147 if(ext == NULL) {
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
148 xmlnode *error, *inf;
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
149
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
150 /* XXX: gross hack, implement jabber_iq_set_type or something */
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
151 xmlnode_set_attrib(iq->node, "type", "error");
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
152 iq->type = JABBER_IQ_ERROR;
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
153
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
154 error = xmlnode_new_child(query, "error");
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
155 xmlnode_set_attrib(error, "code", "404");
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
156 xmlnode_set_attrib(error, "type", "cancel");
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
157 inf = xmlnode_new_child(error, "item-not-found");
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
158 xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas");
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
159 }
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
160 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
161
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
162 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 } else if(!strcmp(type, "result")) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164 xmlnode *query = xmlnode_get_child(packet, "query");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
165 xmlnode *child;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
166 JabberID *jid;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
167 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
168 JabberBuddyResource *jbr = NULL;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169 JabberCapabilities capabilities = JABBER_CAP_NONE;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
170 struct _jabber_disco_info_cb_data *jdicd;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
171
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
172 if((jid = jabber_id_new(from))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
173 if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE)))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 jbr = jabber_buddy_find_resource(jb, jid->resource);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
175 jabber_id_free(jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
176 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
177
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
178 if(jbr)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
179 capabilities = jbr->capabilities;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
180
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
181 for(child = query->child; child; child = child->next) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
182 if(child->type != XMLNODE_TYPE_TAG)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
183 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
184
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
185 if(!strcmp(child->name, "identity")) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
186 const char *category = xmlnode_get_attrib(child, "category");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
187 const char *type = xmlnode_get_attrib(child, "type");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
188 if(!category || !type)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
189 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
190
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
191 if(!strcmp(category, "conference") && !strcmp(type, "text")) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
192 /* we found a groupchat or MUC server, add it to the list */
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
193 /* XXX: actually check for protocol/muc or gc-1.0 support */
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
194 js->chat_servers = g_list_append(js->chat_servers, g_strdup(from));
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
195 } else if(!strcmp(category, "directory") && !strcmp(type, "user")) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
196 /* we found a JUD */
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
197 js->user_directories = g_list_append(js->user_directories, g_strdup(from));
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
198 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
199
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
200 } else if(!strcmp(child->name, "feature")) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
201 const char *var = xmlnode_get_attrib(child, "var");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
202 if(!var)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
203 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
204
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
205 if(!strcmp(var, "http://jabber.org/protocol/si"))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
206 capabilities |= JABBER_CAP_SI;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
207 else if(!strcmp(var, "http://jabber.org/protocol/si/profile/file-transfer"))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
208 capabilities |= JABBER_CAP_SI_FILE_XFER;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
209 else if(!strcmp(var, "http://jabber.org/protocol/bytestreams"))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
210 capabilities |= JABBER_CAP_BYTESTREAMS;
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
211 else if(!strcmp(var, "jabber:iq:search"))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
212 capabilities |= JABBER_CAP_IQ_SEARCH;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
213 else if(!strcmp(var, "jabber:iq:register"))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
214 capabilities |= JABBER_CAP_IQ_REGISTER;
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
215 else if(!strcmp(var, "http://www.xmpp.org/extensions/xep-0199.html#ns"))
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
216 capabilities |= JABBER_CAP_PING;
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
217 else if(!strcmp(var, "http://jabber.org/protocol/commands")) {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
218 capabilities |= JABBER_CAP_ADHOC;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
219 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
220 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
221 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
222
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
223 capabilities |= JABBER_CAP_RETRIEVED;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
224
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
225 if(jbr)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
226 jbr->capabilities = capabilities;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
227
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
228 if((jdicd = g_hash_table_lookup(js->disco_callbacks, from))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
229 jdicd->callback(js, from, capabilities, jdicd->data);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230 g_hash_table_remove(js->disco_callbacks, from);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
231 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
232 } else if(!strcmp(type, "error")) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
233 JabberID *jid;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
234 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
235 JabberBuddyResource *jbr = NULL;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
236 JabberCapabilities capabilities = JABBER_CAP_NONE;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237 struct _jabber_disco_info_cb_data *jdicd;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
239 if(!(jdicd = g_hash_table_lookup(js->disco_callbacks, from)))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
240 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
241
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242 if((jid = jabber_id_new(from))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
243 if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE)))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
244 jbr = jabber_buddy_find_resource(jb, jid->resource);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
245 jabber_id_free(jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
247
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
248 if(jbr)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
249 capabilities = jbr->capabilities;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
250
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
251 jdicd->callback(js, from, capabilities, jdicd->data);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
252 g_hash_table_remove(js->disco_callbacks, from);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
253 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
254 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
255
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
256 void jabber_disco_items_parse(JabberStream *js, xmlnode *packet) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
257 const char *from = xmlnode_get_attrib(packet, "from");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
258 const char *type = xmlnode_get_attrib(packet, "type");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
259
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
260 if(type && !strcmp(type, "get")) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
261 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_RESULT,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
262 "http://jabber.org/protocol/disco#items");
17826
8f31a68b1d70 Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents: 17817
diff changeset
263
8f31a68b1d70 Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents: 17817
diff changeset
264 /* preserve node */
8f31a68b1d70 Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents: 17817
diff changeset
265 xmlnode *iq_query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#items");
8f31a68b1d70 Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents: 17817
diff changeset
266 if(iq_query) {
8f31a68b1d70 Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents: 17817
diff changeset
267 xmlnode *query = xmlnode_get_child_with_namespace(packet,"query","http://jabber.org/protocol/disco#items");
8f31a68b1d70 Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents: 17817
diff changeset
268 if(query) {
8f31a68b1d70 Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents: 17817
diff changeset
269 const char *node = xmlnode_get_attrib(query,"node");
8f31a68b1d70 Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents: 17817
diff changeset
270 if(node)
8f31a68b1d70 Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents: 17817
diff changeset
271 xmlnode_set_attrib(iq_query,"node",node);
8f31a68b1d70 Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents: 17817
diff changeset
272 }
8f31a68b1d70 Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents: 17817
diff changeset
273 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
274
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
275 jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id"));
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
276
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
277 xmlnode_set_attrib(iq->node, "to", from);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
279 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
280 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
282 static void
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
283 jabber_disco_finish_server_info_result_cb(JabberStream *js)
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
284 {
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18225
diff changeset
285
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18225
diff changeset
286 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
287
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
288 if (!(js->server_caps & JABBER_CAP_GOOGLE_ROSTER)) {
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
289 /* 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
290 jabber_roster_request(js);
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
291 }
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
292
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
293 /* Send initial presence; this will trigger receipt of presence for contacts on the roster */
18719
7a0465381cea Fixed errors created by merge conflict resolve mistakes.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
294 jabber_presence_send(js->gc->account, NULL);
17817
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
295
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
296 if (js->server_caps & JABBER_CAP_ADHOC) {
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
297 /* The server supports ad-hoc commands, so let's request the list */
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
298 jabber_adhoc_server_get_list(js);
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
299 }
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
300 }
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
301
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
302 static void
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
303 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
304 {
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
305 xmlnode *query, *child;
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
306 const char *from = xmlnode_get_attrib(packet, "from");
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
307 const char *type = xmlnode_get_attrib(packet, "type");
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
308
15358
c8179e0a5483 [gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents: 15355
diff changeset
309 if((!from || !type) ||
c8179e0a5483 [gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents: 15355
diff changeset
310 (strcmp(from, js->user->domain))) {
c8179e0a5483 [gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents: 15355
diff changeset
311 jabber_disco_finish_server_info_result_cb(js);
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
312 return;
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
313 }
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
314
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
315 if(strcmp(type, "result")) {
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
316 /* 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
317 jabber_disco_finish_server_info_result_cb(js);
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
318 return;
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
319 }
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
320
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
321 query = xmlnode_get_child(packet, "query");
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
322
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
323 if (!query) {
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
324 jabber_disco_finish_server_info_result_cb(js);
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
325 return;
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
326 }
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
327
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
328 for (child = xmlnode_get_child(query, "identity"); child;
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
329 child = xmlnode_get_next_twin(child)) {
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
330 const char *category, *type, *name;
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
331 category = xmlnode_get_attrib(child, "category");
17768
7be011945a1b added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents: 17423
diff changeset
332 type = xmlnode_get_attrib(child, "type");
19894
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
333 if(category && type && !strcmp(category, "pubsub") && !strcmp(type,"pep"))
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
334 js->pep = TRUE;
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
335 if (!category || strcmp(category, "server"))
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
336 continue;
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
337 if (!type || strcmp(type, "im"))
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
338 continue;
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
339
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
340 name = xmlnode_get_attrib(child, "name");
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
341 if (!name)
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
342 continue;
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
343
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
344 g_free(js->server_name);
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
345 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
346 if (!strcmp(name, "Google Talk")) {
19832
84b69b21672b Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18317
diff changeset
347 purple_debug_info("jabber", "Google Talk!\n");
15587
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
348 js->googletalk = TRUE;
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
349 }
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
350 }
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
351
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
352 for (child = xmlnode_get_child(query, "feature"); child;
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
353 child = xmlnode_get_next_twin(child)) {
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
354 const char *var;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
355 var = xmlnode_get_attrib(child, "var");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
356 if (!var)
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
357 continue;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
358
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
359 if (!strcmp("google:mail:notify", var)) {
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
360 js->server_caps |= JABBER_CAP_GMAIL_NOTIFY;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
361 jabber_gmail_init(js);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
362 } else if (!strcmp("google:roster", var)) {
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
363 js->server_caps |= JABBER_CAP_GOOGLE_ROSTER;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
364 jabber_google_roster_init(js);
17817
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
365 } else if (!strcmp("http://jabber.org/protocol/commands", var)) {
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
366 js->server_caps |= JABBER_CAP_ADHOC;
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
367 }
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
368 }
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
369
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
370 jabber_disco_finish_server_info_result_cb(js);
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
371 }
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
372
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
373 static void
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
374 jabber_disco_server_items_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
375 {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
376 xmlnode *query, *child;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
377 const char *from = xmlnode_get_attrib(packet, "from");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
378 const char *type = xmlnode_get_attrib(packet, "type");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
379
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
380 if(!from || !type)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
381 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
382
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
383 if(strcmp(from, js->user->domain))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
384 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
385
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
386 if(strcmp(type, "result"))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
387 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
388
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
389 while(js->chat_servers) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
390 g_free(js->chat_servers->data);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
391 js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
392 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
393
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
394 query = xmlnode_get_child(packet, "query");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
395
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
396 for(child = xmlnode_get_child(query, "item"); child;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
397 child = xmlnode_get_next_twin(child)) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
398 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
399 const char *jid, *node;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
400
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
401 if(!(jid = xmlnode_get_attrib(child, "jid")))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
402 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
403
17423
1f3a88fda48e skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents: 17421
diff changeset
404 /* 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
405 * 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
406 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
407 continue;
1f3a88fda48e skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents: 17421
diff changeset
408
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
409 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
410 xmlnode_set_attrib(iq->node, "to", jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
411 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
412 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
413 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
414
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
415 void jabber_disco_items_server(JabberStream *js)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
416 {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
417 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
418 "http://jabber.org/protocol/disco#items");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
419
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
420 xmlnode_set_attrib(iq->node, "to", js->user->domain);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
421
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
422 jabber_iq_set_callback(iq, jabber_disco_server_items_result_cb, NULL);
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
423 jabber_iq_send(iq);
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
424
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
425 iq = jabber_iq_new_query(js, JABBER_IQ_GET,
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
426 "http://jabber.org/protocol/disco#info");
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
427 xmlnode_set_attrib(iq->node, "to", js->user->domain);
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
428 jabber_iq_set_callback(iq, jabber_disco_server_info_result_cb, NULL);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
429 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
430 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
431
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
432 void jabber_disco_info_do(JabberStream *js, const char *who, JabberDiscoInfoCallback *callback, gpointer data)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
433 {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
434 JabberID *jid;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
435 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
436 JabberBuddyResource *jbr = NULL;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
437 struct _jabber_disco_info_cb_data *jdicd;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
438 JabberIq *iq;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
439
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
440 if((jid = jabber_id_new(who))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
441 if(jid->resource && (jb = jabber_buddy_find(js, who, TRUE)))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
442 jbr = jabber_buddy_find_resource(jb, jid->resource);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
443 jabber_id_free(jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
444 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
445
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
446 if(jbr && jbr->capabilities & JABBER_CAP_RETRIEVED) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
447 callback(js, who, jbr->capabilities, data);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
448 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
449 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
450
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
451 jdicd = g_new0(struct _jabber_disco_info_cb_data, 1);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
452 jdicd->data = data;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
453 jdicd->callback = callback;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
454
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
455 g_hash_table_insert(js->disco_callbacks, g_strdup(who), jdicd);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
456
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
457 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
458 xmlnode_set_attrib(iq->node, "to", who);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
459
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
460 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
461 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
462
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
463

mercurial