libpurple/protocols/jabber/disco.c

Fri, 18 Oct 2019 23:30:32 +0300

author
qarkai <qarkai@gmail.com>
date
Fri, 18 Oct 2019 23:30:32 +0300
changeset 40062
d25228fc7b8e
parent 38363
876661dc1375
child 40064
467eecebfa70
permissions
-rw-r--r--

Use g_list_free_full instead of manual iterations

8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
2 * purple - Jabber Service Discovery
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28191
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28191
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28191
diff changeset
6 * source distribution.
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * 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
10 * the Free Software Foundation; either version 2 of the License, or
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 * 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
20 * 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
21 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 */
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24 #include "internal.h"
29247
ca703c2df180 jabber: Only make the SRV lookup for STUN based on the domain if no STUN
Marcus Lundblad <malu@pidgin.im>
parents: 29103
diff changeset
25 #include "network.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26 #include "prefs.h"
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
27 #include "debug.h"
27212
b458f88ab2d4 Fix merge.
Paul Aurich <darkrain42@pidgin.im>
parents: 27211
diff changeset
28 #include "request.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25290
diff changeset
30 #include "adhoccommands.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 #include "buddy.h"
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25290
diff changeset
32 #include "disco.h"
29913
58f5122fbcd3 First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents: 29814
diff changeset
33 #include "google/google.h"
58f5122fbcd3 First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents: 29814
diff changeset
34 #include "google/gmail.h"
58f5122fbcd3 First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents: 29814
diff changeset
35 #include "google/jingleinfo.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36 #include "iq.h"
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
37 #include "jabber.h"
26143
673b6665624d Restructure Jingle code to more easily support multiple application types.
Michael Ruprecht <maiku@pidgin.im>
parents: 26106
diff changeset
38 #include "jingle/jingle.h"
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25290
diff changeset
39 #include "pep.h"
15344
34b7f4e55861 [gaim-migrate @ 18072]
Evan Schoenberg <evands@pidgin.im>
parents: 15323
diff changeset
40 #include "presence.h"
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
41 #include "roster.h"
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25290
diff changeset
42 #include "useravatar.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44 struct _jabber_disco_info_cb_data {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45 gpointer data;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46 JabberDiscoInfoCallback *callback;
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
26594
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
49 struct _jabber_disco_items_cb_data {
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
50 gpointer data;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
51 JabberDiscoItemsCallback *callback;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
52 };
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
53
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
54 #define SUPPORT_FEATURE(x) { \
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
55 feature = purple_xmlnode_new_child(query, "feature"); \
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
56 purple_xmlnode_set_attrib(feature, "var", x); \
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
57 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
59 static void
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
60 jabber_disco_bytestream_server_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
61 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
62 PurpleXmlNode *packet, gpointer data)
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
63 {
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
64 JabberBytestreamsStreamhost *sh = data;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
65 PurpleXmlNode *query = purple_xmlnode_get_child_with_namespace(packet, "query",
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
66 NS_BYTESTREAMS);
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
67
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
68 if (from && purple_strequal(from, sh->jid) && query != NULL) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
69 PurpleXmlNode *sh_node = purple_xmlnode_get_child(query, "streamhost");
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
70 if (sh_node) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
71 const char *jid = purple_xmlnode_get_attrib(sh_node, "jid");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
72 const char *port = purple_xmlnode_get_attrib(sh_node, "port");
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
73
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
74
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
75 if (jid == NULL || !purple_strequal(jid, from))
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
76 purple_debug_error("jabber", "Invalid jid(%s) for bytestream.\n",
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
77 jid ? jid : "(null)");
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
78
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
79 sh->host = g_strdup(purple_xmlnode_get_attrib(sh_node, "host"));
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
80 sh->zeroconf = g_strdup(purple_xmlnode_get_attrib(sh_node, "zeroconf"));
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
81 if (port != NULL)
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
82 sh->port = atoi(port);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
83 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
84 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
85
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
86 purple_debug_info("jabber", "Discovered bytestream proxy server: "
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
87 "jid='%s' host='%s' port='%d' zeroconf='%s'\n",
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
88 from ? from : "", sh->host ? sh->host : "",
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
89 sh->port, sh->zeroconf ? sh->zeroconf : "");
23912
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
90
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
91 /* TODO: When we support zeroconf proxies, fix this to handle them */
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
92 if (!(sh->jid && sh->host && sh->port > 0)) {
28077
c2b493e058f1 Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 28047
diff changeset
93 js->bs_proxies = g_list_remove(js->bs_proxies, sh);
23912
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
94 g_free(sh->jid);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
95 g_free(sh->host);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
96 g_free(sh->zeroconf);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
97 g_free(sh);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
98 }
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
99 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
100
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
102 void jabber_disco_info_parse(JabberStream *js, const char *from,
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
103 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
104 PurpleXmlNode *in_query)
26707
a4f7c5d5e5ae propagate from branch 'im.pidgin.pidgin' (head beb862745aa7b61bf9942e731fdef09bf0bba641)
Paul Aurich <darkrain42@pidgin.im>
parents: 26668 26692
diff changeset
105 {
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
106 if(type == JABBER_IQ_GET) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
107 PurpleXmlNode *query, *identity, *feature;
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
108 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
109 const char *node = purple_xmlnode_get_attrib(in_query, "node");
26707
a4f7c5d5e5ae propagate from branch 'im.pidgin.pidgin' (head beb862745aa7b61bf9942e731fdef09bf0bba641)
Paul Aurich <darkrain42@pidgin.im>
parents: 26668 26692
diff changeset
110 char *node_uri = NULL;
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
111
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
112 /* create custom caps node URI */
24716
047f5075ca58 Entity Capabilities must be per-JabberStream
Paul Aurich <darkrain42@pidgin.im>
parents: 24715
diff changeset
113 node_uri = g_strconcat(CAPS0115_NODE, "#", jabber_caps_get_own_hash(js), NULL);
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
114
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
115 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, NS_DISCO_INFO);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
117 jabber_iq_set_id(iq, id);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
118
28047
0f280c9653d2 jabber: disco#info queries with no 'from' are from the server; valid.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
119 if (from)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
120 purple_xmlnode_set_attrib(iq->node, "to", from);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
121 query = purple_xmlnode_get_child(iq->node, "query");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
122
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
123 if(node)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
124 purple_xmlnode_set_attrib(query, "node", node);
26482
72d16a73cf12 Get rid of the rest of the extraneous changes.
Michael Ruprecht <maiku@pidgin.im>
parents: 26337
diff changeset
125
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31680
diff changeset
126 if(!node || purple_strequal(node, node_uri)) {
24715
69aaae59e205 Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 23954
diff changeset
127 GList *features, *identities;
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
128 for(identities = jabber_identities; identities; identities = identities->next) {
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
129 JabberIdentity *ident = (JabberIdentity*)identities->data;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
130 identity = purple_xmlnode_new_child(query, "identity");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
131 purple_xmlnode_set_attrib(identity, "category", ident->category);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
132 purple_xmlnode_set_attrib(identity, "type", ident->type);
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
133 if (ident->lang)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
134 purple_xmlnode_set_attrib(identity, "xml:lang", ident->lang);
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
135 if (ident->name)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
136 purple_xmlnode_set_attrib(identity, "name", ident->name);
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
137 }
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
138 for(features = jabber_features; features; features = features->next) {
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
139 JabberFeature *feat = (JabberFeature*)features->data;
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
140 if (!feat->is_enabled || feat->is_enabled(js, feat->namespace)) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
141 feature = purple_xmlnode_new_child(query, "feature");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
142 purple_xmlnode_set_attrib(feature, "var", 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
143 }
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
144 }
23714
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
145 #ifdef USE_VV
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31680
diff changeset
146 } else if (purple_strequal(node, CAPS0115_NODE "#" "voice-v1")) {
26668
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
147 /*
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
148 * HUGE HACK! We advertise this ext (see jabber_presence_create_js
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
149 * where we add <c/> to the <presence/>) for the Google Talk
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
150 * clients that don't actually check disco#info features.
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
151 *
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
152 * This specific feature is redundant but is what
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
153 * node='http://mail.google.com/xmpp/client/caps', ver='1.1'
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
154 * advertises as 'voice-v1'.
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
155 */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
156 PurpleXmlNode *feature = purple_xmlnode_new_child(query, "feature");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
157 purple_xmlnode_set_attrib(feature, "var", NS_GOOGLE_VOICE);
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31680
diff changeset
158 } else if (purple_strequal(node, CAPS0115_NODE "#" "video-v1")) {
27202
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 26991
diff changeset
159 /*
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 26991
diff changeset
160 * HUGE HACK! We advertise this ext (see jabber_presence_create_js
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 26991
diff changeset
161 * where we add <c/> to the <presence/>) for the Google Talk
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 26991
diff changeset
162 * clients that don't actually check disco#info features.
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 26991
diff changeset
163 *
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 26991
diff changeset
164 * This specific feature is redundant but is what
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 26991
diff changeset
165 * node='http://mail.google.com/xmpp/client/caps', ver='1.1'
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 26991
diff changeset
166 * advertises as 'video-v1'.
5244a5510e0e Add Gmail video support.
Michael Ruprecht <maiku@pidgin.im>
parents: 26991
diff changeset
167 */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
168 PurpleXmlNode *feature = purple_xmlnode_new_child(query, "feature");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
169 purple_xmlnode_set_attrib(feature, "var", NS_GOOGLE_VIDEO);
38256
035f00c4fd87 Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31680
diff changeset
170 } else if (purple_strequal(node, CAPS0115_NODE "#" "camera-v1")) {
28028
774400bac46f Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Michael Ruprecht <maiku@pidgin.im>
parents: 27790
diff changeset
171 /*
774400bac46f Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Michael Ruprecht <maiku@pidgin.im>
parents: 27790
diff changeset
172 * HUGE HACK! We advertise this ext (see jabber_presence_create_js
774400bac46f Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Michael Ruprecht <maiku@pidgin.im>
parents: 27790
diff changeset
173 * where we add <c/> to the <presence/>) for the Google Talk
774400bac46f Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Michael Ruprecht <maiku@pidgin.im>
parents: 27790
diff changeset
174 * clients that don't actually check disco#info features.
774400bac46f Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Michael Ruprecht <maiku@pidgin.im>
parents: 27790
diff changeset
175 *
774400bac46f Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Michael Ruprecht <maiku@pidgin.im>
parents: 27790
diff changeset
176 * This specific feature is redundant but is what
774400bac46f Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Michael Ruprecht <maiku@pidgin.im>
parents: 27790
diff changeset
177 * node='http://mail.google.com/xmpp/client/caps', ver='1.1'
774400bac46f Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Michael Ruprecht <maiku@pidgin.im>
parents: 27790
diff changeset
178 * advertises as 'camera-v1'.
774400bac46f Add the camera-v1 cap or else Gmail refuses to accept we're video enabled.
Michael Ruprecht <maiku@pidgin.im>
parents: 27790
diff changeset
179 */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
180 PurpleXmlNode *feature = purple_xmlnode_new_child(query, "feature");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
181 purple_xmlnode_set_attrib(feature, "var", NS_GOOGLE_CAMERA);
23714
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
182 #endif
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
183 } else {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
184 PurpleXmlNode *error, *inf;
27211
68a7be484fe1 propagate from branch 'im.pidgin.pidgin' (head feb6f844abcd8e7add3c986f3010f642838533e8)
Paul Aurich <darkrain42@pidgin.im>
parents: 26958 26928
diff changeset
185
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
186 /* XXX: gross hack, implement jabber_iq_set_type or something */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
187 purple_xmlnode_set_attrib(iq->node, "type", "error");
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
188 iq->type = JABBER_IQ_ERROR;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26026
diff changeset
189
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
190 error = purple_xmlnode_new_child(query, "error");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
191 purple_xmlnode_set_attrib(error, "code", "404");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
192 purple_xmlnode_set_attrib(error, "type", "cancel");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
193 inf = purple_xmlnode_new_child(error, "item-not-found");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
194 purple_xmlnode_set_namespace(inf, NS_XMPP_STANZAS);
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
195 }
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
196 g_free(node_uri);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
197 jabber_iq_send(iq);
26910
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
198 } else if (type == JABBER_IQ_SET) {
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
199 /* wtf? seriously. wtf‽ */
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
200 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
201 PurpleXmlNode *error, *bad_request;
26910
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
202
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
203 /* Free the <query/> */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
204 purple_xmlnode_free(purple_xmlnode_get_child(iq->node, "query"));
26910
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
205 /* Add an error */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
206 error = purple_xmlnode_new_child(iq->node, "error");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
207 purple_xmlnode_set_attrib(error, "type", "modify");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
208 bad_request = purple_xmlnode_new_child(error, "bad-request");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
209 purple_xmlnode_set_namespace(bad_request, NS_XMPP_STANZAS);
26910
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
210
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
211 jabber_iq_set_id(iq, id);
28047
0f280c9653d2 jabber: disco#info queries with no 'from' are from the server; valid.
Paul Aurich <darkrain42@pidgin.im>
parents: 28028
diff changeset
212 if (from)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
213 purple_xmlnode_set_attrib(iq->node, "to", from);
26910
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
214
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
215 jabber_iq_send(iq);
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
216 }
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
217 }
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
218
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
219 static void jabber_disco_info_cb(JabberStream *js, const char *from,
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
220 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
221 PurpleXmlNode *packet, gpointer data)
26910
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
222 {
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
223 struct _jabber_disco_info_cb_data *jdicd = data;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
224 PurpleXmlNode *query;
26910
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
225
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
226 query = purple_xmlnode_get_child_with_namespace(packet, "query", NS_DISCO_INFO);
26910
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
227
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
228 if (type == JABBER_IQ_RESULT && query) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
229 PurpleXmlNode *child;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230 JabberID *jid;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
231 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
232 JabberBuddyResource *jbr = NULL;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
233 JabberCapabilities capabilities = JABBER_CAP_NONE;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
234
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
235 if((jid = jabber_id_new(from))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
236 if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE)))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237 jbr = jabber_buddy_find_resource(jb, jid->resource);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238 jabber_id_free(jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
239 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
240
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
241 if(jbr)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242 capabilities = jbr->capabilities;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
243
26910
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
244 for(child = query->child; child; child = child->next) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
245 if(child->type != PURPLE_XMLNODE_TYPE_TAG)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
247
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
248 if(purple_strequal(child->name, "identity")) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
249 const char *category = purple_xmlnode_get_attrib(child, "category");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
250 const char *type = purple_xmlnode_get_attrib(child, "type");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
251 if(!category || !type)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
252 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
253
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
254 if(purple_strequal(category, "conference") && purple_strequal(type, "text")) {
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
255 /* 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
256 /* XXX: actually check for protocol/muc or gc-1.0 support */
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
257 js->chat_servers = g_list_prepend(js->chat_servers, g_strdup(from));
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
258 } else if(purple_strequal(category, "directory") && purple_strequal(type, "user")) {
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
259 /* we found a JUD */
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
260 js->user_directories = g_list_prepend(js->user_directories, g_strdup(from));
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
261 } else if(purple_strequal(category, "proxy") && purple_strequal(type, "bytestreams")) {
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
262 /* This is a bytestream proxy */
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
263 JabberIq *iq;
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
264 JabberBytestreamsStreamhost *sh;
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
265
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
266 purple_debug_info("jabber", "Found bytestream proxy server: %s\n", from);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
267
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
268 sh = g_new0(JabberBytestreamsStreamhost, 1);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
269 sh->jid = g_strdup(from);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
270 js->bs_proxies = g_list_prepend(js->bs_proxies, sh);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
271
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
272 iq = jabber_iq_new_query(js, JABBER_IQ_GET,
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
273 NS_BYTESTREAMS);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
274 purple_xmlnode_set_attrib(iq->node, "to", sh->jid);
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
275 jabber_iq_set_callback(iq, jabber_disco_bytestream_server_cb, sh);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
276 jabber_iq_send(iq);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
277 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
279 } else if(purple_strequal(child->name, "feature")) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
280 const char *var = purple_xmlnode_get_attrib(child, "var");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281 if(!var)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
282 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
284 if(purple_strequal(var, "http://jabber.org/protocol/si"))
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
285 capabilities |= JABBER_CAP_SI;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
286 else if(purple_strequal(var, "http://jabber.org/protocol/si/profile/file-transfer"))
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
287 capabilities |= JABBER_CAP_SI_FILE_XFER;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
288 else if(purple_strequal(var, NS_BYTESTREAMS))
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
289 capabilities |= JABBER_CAP_BYTESTREAMS;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
290 else if(purple_strequal(var, "jabber:iq:search"))
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
291 capabilities |= JABBER_CAP_IQ_SEARCH;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
292 else if(purple_strequal(var, "jabber:iq:register"))
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
293 capabilities |= JABBER_CAP_IQ_REGISTER;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
294 else if(purple_strequal(var, NS_PING))
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
295 capabilities |= JABBER_CAP_PING;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
296 else if(purple_strequal(var, NS_DISCO_ITEMS))
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
297 capabilities |= JABBER_CAP_ITEMS;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
298 else if(purple_strequal(var, "http://jabber.org/protocol/commands")) {
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
299 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
300 }
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
301 else if(purple_strequal(var, NS_IBB)) {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 23912
diff changeset
302 purple_debug_info("jabber", "remote supports IBB\n");
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 23912
diff changeset
303 capabilities |= JABBER_CAP_IBB;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 23912
diff changeset
304 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
305 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
306 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
307
28191
187bd9914401 Reverse the list of conference servers we find so that the first one in the
Etan Reisner <deryni@pidgin.im>
parents: 28077
diff changeset
308 js->chat_servers = g_list_reverse(js->chat_servers);
187bd9914401 Reverse the list of conference servers we find so that the first one in the
Etan Reisner <deryni@pidgin.im>
parents: 28077
diff changeset
309
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
310 capabilities |= JABBER_CAP_RETRIEVED;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
311
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
312 if(jbr)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
313 jbr->capabilities = capabilities;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
314
27790
b2f4880d4e96 Fix picking up SI streamhosts from login server and plug a leak.
Paul Aurich <darkrain42@pidgin.im>
parents: 27292
diff changeset
315 if (jdicd && jdicd->callback)
b2f4880d4e96 Fix picking up SI streamhosts from login server and plug a leak.
Paul Aurich <darkrain42@pidgin.im>
parents: 27292
diff changeset
316 jdicd->callback(js, from, capabilities, jdicd->data);
26910
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
317 } else { /* type == JABBER_IQ_ERROR or query == NULL */
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
318 JabberID *jid;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
319 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
320 JabberBuddyResource *jbr = NULL;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
321 JabberCapabilities capabilities = JABBER_CAP_NONE;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
322
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
323 if((jid = jabber_id_new(from))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
324 if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE)))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
325 jbr = jabber_buddy_find_resource(jb, jid->resource);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
326 jabber_id_free(jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
327 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
328
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
329 if(jbr)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
330 capabilities = jbr->capabilities;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
331
27790
b2f4880d4e96 Fix picking up SI streamhosts from login server and plug a leak.
Paul Aurich <darkrain42@pidgin.im>
parents: 27292
diff changeset
332 if (jdicd && jdicd->callback)
b2f4880d4e96 Fix picking up SI streamhosts from login server and plug a leak.
Paul Aurich <darkrain42@pidgin.im>
parents: 27292
diff changeset
333 jdicd->callback(js, from, capabilities, jdicd->data);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
334 }
27790
b2f4880d4e96 Fix picking up SI streamhosts from login server and plug a leak.
Paul Aurich <darkrain42@pidgin.im>
parents: 27292
diff changeset
335
b2f4880d4e96 Fix picking up SI streamhosts from login server and plug a leak.
Paul Aurich <darkrain42@pidgin.im>
parents: 27292
diff changeset
336 g_free(jdicd);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
337 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
338
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
339 void jabber_disco_items_parse(JabberStream *js, const char *from,
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
340 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
341 PurpleXmlNode *query)
26707
a4f7c5d5e5ae propagate from branch 'im.pidgin.pidgin' (head beb862745aa7b61bf9942e731fdef09bf0bba641)
Paul Aurich <darkrain42@pidgin.im>
parents: 26668 26692
diff changeset
342 {
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
343 if(type == JABBER_IQ_GET) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
344 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_RESULT,
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
345 NS_DISCO_ITEMS);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26026
diff changeset
346
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
347 /* preserve node */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
348 PurpleXmlNode *iq_query = purple_xmlnode_get_child(iq->node, "query");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
349 const char *node = purple_xmlnode_get_attrib(query, "node");
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
350 if(node)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
351 purple_xmlnode_set_attrib(iq_query,"node",node);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
352
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
353 jabber_iq_set_id(iq, id);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
354
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
355 if (from)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
356 purple_xmlnode_set_attrib(iq->node, "to", from);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
357 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
358 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
359 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
360
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
361 static void
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
362 jabber_disco_finish_server_info_result_cb(JabberStream *js)
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
363 {
23912
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
364 const char *ft_proxies;
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18225
diff changeset
365
25810
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25477
diff changeset
366 /*
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25477
diff changeset
367 * This *should* happen only if the server supports vcard-temp, but there
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25477
diff changeset
368 * are apparently some servers that don't advertise it even though they
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25477
diff changeset
369 * support it.
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25477
diff changeset
370 */
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18225
diff changeset
371 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
372
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25290
diff changeset
373 if (js->pep)
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25290
diff changeset
374 jabber_avatar_fetch_mine(js);
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18225
diff changeset
375
29103
aefa3f414775 jabber: The google roster request code was so lonely, so let's just drop-kick it and add the little custom logic to roster.c
Paul Aurich <darkrain42@pidgin.im>
parents: 28984
diff changeset
376 /* Yes, please! */
aefa3f414775 jabber: The google roster request code was so lonely, so let's just drop-kick it and add the little custom logic to roster.c
Paul Aurich <darkrain42@pidgin.im>
parents: 28984
diff changeset
377 jabber_roster_request(js);
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
378
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
379 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
380 /* 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
381 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
382 }
23912
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
383
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 23912
diff changeset
384 /* If the server supports blocking, request the block list */
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 23912
diff changeset
385 if (js->server_caps & JABBER_CAP_BLOCKING) {
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 23912
diff changeset
386 jabber_request_block_list(js);
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 23912
diff changeset
387 }
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 23912
diff changeset
388
23912
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
389 /* If there are manually specified bytestream proxies, query them */
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32300
diff changeset
390 ft_proxies = purple_account_get_string(purple_connection_get_account(js->gc), "ft_proxies", NULL);
23912
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
391 if (ft_proxies) {
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
392 JabberIq *iq;
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
393 JabberBytestreamsStreamhost *sh;
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
394 int i;
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
395 char *tmp;
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
396 gchar **ft_proxy_list = g_strsplit(ft_proxies, ",", 0);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
397
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
398 for(i = 0; ft_proxy_list[i]; i++) {
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
399 g_strstrip(ft_proxy_list[i]);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
400 if(!(*ft_proxy_list[i]))
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
401 continue;
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
402
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
403 /* We used to allow specifying a port directly here; get rid of it */
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
404 if((tmp = strchr(ft_proxy_list[i], ':')))
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
405 *tmp = '\0';
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
406
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
407 sh = g_new0(JabberBytestreamsStreamhost, 1);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
408 sh->jid = g_strdup(ft_proxy_list[i]);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
409 js->bs_proxies = g_list_prepend(js->bs_proxies, sh);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
410
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
411 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_BYTESTREAMS);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
412 purple_xmlnode_set_attrib(iq->node, "to", sh->jid);
23912
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
413 jabber_iq_set_callback(iq, jabber_disco_bytestream_server_cb, sh);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
414 jabber_iq_send(iq);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
415 }
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
416
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
417 g_strfreev(ft_proxy_list);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
418 }
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
419
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
420 }
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
421
28811
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
422 static void
37457
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
423 jabber_disco_stun_srv_resolve_cb(GObject *sender, GAsyncResult *result, gpointer data) {
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
424 GError *error = NULL;
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
425 GList *services = NULL;
28811
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
426 JabberStream *js = (JabberStream *) data;
37457
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
427 gint results = 0;
28811
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
428
37517
a67be31f9c7e Use the GResolver which was passed to g_resolver_lookup_*_async()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37466
diff changeset
429 services = g_resolver_lookup_service_finish(G_RESOLVER(sender),
a67be31f9c7e Use the GResolver which was passed to g_resolver_lookup_*_async()
Mike Ruprecht <cmaiku@gmail.com>
parents: 37466
diff changeset
430 result, &error);
37457
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
431
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
432 if(error != NULL) {
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
433 purple_debug_info("jabber", "Failed to look up a STUN record : %s\n", error->message);
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
434
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
435 g_error_free(error);
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
436
28811
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
437 return;
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
438 }
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
439
37457
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
440 results = g_list_length(services);
28811
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
441
37457
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
442 purple_debug_info("jabber", "got %d SRV responses for STUN.\n", results);
28811
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
443
37457
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
444 if (results > 0) {
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
445 GSrvTarget *target = (GSrvTarget *)services->data;
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
446 const gchar *hostname = g_srv_target_get_hostname(target);
28811
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
447
37457
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
448 js->stun_ip = g_strdup(hostname);
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
449 js->stun_port = g_srv_target_get_port(target);
28811
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
450
37457
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
451 purple_debug_info("jabber", "set stun address to %s:%d\n",
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
452 hostname, js->stun_port);
28811
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
453 }
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
454
37457
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
455 g_resolver_free_targets(services);
28811
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
456 }
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
457
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
458
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
459 static void
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
460 jabber_disco_server_info_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
461 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
462 PurpleXmlNode *packet, gpointer data)
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
463 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
464 PurpleXmlNode *query, *child;
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
465
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
466 if (!from || !purple_strequal(from, js->user->domain)) {
15358
c8179e0a5483 [gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents: 15355
diff changeset
467 jabber_disco_finish_server_info_result_cb(js);
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
468 return;
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
469 }
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
470
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
471 if (type == JABBER_IQ_ERROR) {
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
472 /* 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
473 jabber_disco_finish_server_info_result_cb(js);
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
474 return;
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
475 }
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
476
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
477 query = purple_xmlnode_get_child(packet, "query");
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
478
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
479 if (!query) {
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
480 jabber_disco_finish_server_info_result_cb(js);
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
481 return;
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
482 }
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
483
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
484 for (child = purple_xmlnode_get_child(query, "identity"); child;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
485 child = purple_xmlnode_get_next_twin(child)) {
38363
876661dc1375 Fix a bunch of stuff that was somehow broke in the last wave of pull requests
Gary Kramlich <grim@reaperworld.com>
parents: 38358
diff changeset
486 const char *category, *type, *name, *stun_ip;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
487 category = purple_xmlnode_get_attrib(child, "category");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
488 type = purple_xmlnode_get_attrib(child, "type");
38260
dcada91c0912 Remove redundant NULL checks
qarkai <qarkai@gmail.com>
parents: 38259
diff changeset
489 if(purple_strequal(category, "pubsub") && purple_strequal(type, "pep")) {
29814
ad92005bcdcf Added PurpleConnection flags to determine support for moods and mood messages.
Marcus Lundblad <malu@pidgin.im>
parents: 29247
diff changeset
490 PurpleConnection *gc = js->gc;
19894
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
491 js->pep = TRUE;
32678
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32300
diff changeset
492 purple_connection_set_flags(gc,
01f6312a4a7b On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents: 32300
diff changeset
493 purple_connection_get_flags(gc)
34746
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
494 | PURPLE_CONNECTION_FLAG_SUPPORT_MOODS
dc9c911dbd35 Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents: 32678
diff changeset
495 | PURPLE_CONNECTION_FLAG_SUPPORT_MOOD_MESSAGES);
29814
ad92005bcdcf Added PurpleConnection flags to determine support for moods and mood messages.
Marcus Lundblad <malu@pidgin.im>
parents: 29247
diff changeset
496 }
38260
dcada91c0912 Remove redundant NULL checks
qarkai <qarkai@gmail.com>
parents: 38259
diff changeset
497 if (!purple_strequal(category, "server"))
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
498 continue;
38260
dcada91c0912 Remove redundant NULL checks
qarkai <qarkai@gmail.com>
parents: 38259
diff changeset
499 if (!purple_strequal(type, "im"))
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
500 continue;
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
501
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
502 name = purple_xmlnode_get_attrib(child, "name");
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
503 if (!name)
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
504 continue;
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
505
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
506 g_free(js->server_name);
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
507 js->server_name = g_strdup(name);
38262
8c0b26d1d508 Replace empty string comparison with null character comparison
qarkai <qarkai@gmail.com>
parents: 38260
diff changeset
508 stun_ip = purple_network_get_stun_ip();
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
509 if (purple_strequal(name, "Google Talk")) {
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
510 purple_debug_info("jabber", "Google Talk!\n");
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 19897
diff changeset
511 js->googletalk = TRUE;
26286
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26186
diff changeset
512
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26186
diff changeset
513 /* autodiscover stun and relays */
38265
ee28d52fe2ca Use conventional style for empty string check
qarkai <qarkai@gmail.com>
parents: 38262
diff changeset
514 if (!stun_ip || !*stun_ip) {
29247
ca703c2df180 jabber: Only make the SRV lookup for STUN based on the domain if no STUN
Marcus Lundblad <malu@pidgin.im>
parents: 29103
diff changeset
515 jabber_google_send_jingle_info(js);
ca703c2df180 jabber: Only make the SRV lookup for STUN based on the domain if no STUN
Marcus Lundblad <malu@pidgin.im>
parents: 29103
diff changeset
516 }
38265
ee28d52fe2ca Use conventional style for empty string check
qarkai <qarkai@gmail.com>
parents: 38262
diff changeset
517 } else if (!stun_ip || !*stun_ip) {
37457
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
518
37518
53c9ebedf2b7 Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents: 37517
diff changeset
519 GResolver *resolver = g_resolver_get_default();
53c9ebedf2b7 Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents: 37517
diff changeset
520 g_resolver_lookup_service_async(resolver,
37457
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
521 "stun",
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
522 "udp",
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
523 js->user->domain,
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
524 NULL,
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
525 jabber_disco_stun_srv_resolve_cb,
0b957b80c46a This should do it for XMPP
Gary Kramlich <grim@reaperworld.com>
parents: 35676
diff changeset
526 js);
37518
53c9ebedf2b7 Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents: 37517
diff changeset
527 g_object_unref(resolver);
28811
a6b47f7de931 jabber: Automatically find a STUN server by SRV lookup on the account's domain
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
528 /* TODO: add TURN support later... */
26482
72d16a73cf12 Get rid of the rest of the extraneous changes.
Michael Ruprecht <maiku@pidgin.im>
parents: 26337
diff changeset
529 }
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
530 }
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
531
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
532 for (child = purple_xmlnode_get_child(query, "feature"); child;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
533 child = purple_xmlnode_get_next_twin(child)) {
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
534 const char *var;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
535 var = purple_xmlnode_get_attrib(child, "var");
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
536 if (!var)
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
537 continue;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
538
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
539 if (purple_strequal(NS_GOOGLE_MAIL_NOTIFY, var)) {
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
540 js->server_caps |= JABBER_CAP_GMAIL_NOTIFY;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
541 jabber_gmail_init(js);
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
542 } else if (purple_strequal(NS_GOOGLE_ROSTER, var)) {
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
543 js->server_caps |= JABBER_CAP_GOOGLE_ROSTER;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
544 } else if (purple_strequal("http://jabber.org/protocol/commands", var)) {
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
545 js->server_caps |= JABBER_CAP_ADHOC;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38256
diff changeset
546 } else if (purple_strequal(NS_SIMPLE_BLOCKING, var)) {
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 23912
diff changeset
547 js->server_caps |= JABBER_CAP_BLOCKING;
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
548 }
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
549 }
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
550
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
551 jabber_disco_finish_server_info_result_cb(js);
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
552 }
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
553
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
554 static void
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
555 jabber_disco_server_items_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
556 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
557 PurpleXmlNode *packet, gpointer data)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
558 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
559 PurpleXmlNode *query, *child;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
560
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
561 if (!from || !purple_strequal(from, js->user->domain))
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
562 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
563
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
564 if (type == JABBER_IQ_ERROR)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
565 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
566
40062
d25228fc7b8e Use g_list_free_full instead of manual iterations
qarkai <qarkai@gmail.com>
parents: 38363
diff changeset
567 g_list_free_full(js->chat_servers, g_free);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
568
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
569 query = purple_xmlnode_get_child(packet, "query");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
570
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
571 for(child = purple_xmlnode_get_child(query, "item"); child;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
572 child = purple_xmlnode_get_next_twin(child)) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
573 JabberIq *iq;
30784
35c4f2c99a81 Fix this inconsequential compile warning:
Mark Doliner <markdoliner@pidgin.im>
parents: 30744
diff changeset
574 const char *jid;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
575
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
576 if(!(jid = purple_xmlnode_get_attrib(child, "jid")))
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
577 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
578
17423
1f3a88fda48e skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents: 17421
diff changeset
579 /* 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
580 * so we won't query them */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
581 if(purple_xmlnode_get_attrib(child, "node") != NULL)
17423
1f3a88fda48e skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents: 17421
diff changeset
582 continue;
1f3a88fda48e skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents: 17421
diff changeset
583
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
584 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
585 purple_xmlnode_set_attrib(iq->node, "to", jid);
27790
b2f4880d4e96 Fix picking up SI streamhosts from login server and plug a leak.
Paul Aurich <darkrain42@pidgin.im>
parents: 27292
diff changeset
586 jabber_iq_set_callback(iq, jabber_disco_info_cb, NULL);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
587 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
588 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
589 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
590
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
591 void jabber_disco_items_server(JabberStream *js)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
592 {
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
593 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_ITEMS);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
594
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
595 purple_xmlnode_set_attrib(iq->node, "to", js->user->domain);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
596
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
597 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
598 jabber_iq_send(iq);
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
599
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
600 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
601 purple_xmlnode_set_attrib(iq->node, "to", js->user->domain);
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
602 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
603 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
604 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
605
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
606 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
607 {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
608 JabberID *jid;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
609 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
610 JabberBuddyResource *jbr = NULL;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
611 struct _jabber_disco_info_cb_data *jdicd;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
612 JabberIq *iq;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
613
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
614 if((jid = jabber_id_new(who))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
615 if(jid->resource && (jb = jabber_buddy_find(js, who, TRUE)))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
616 jbr = jabber_buddy_find_resource(jb, jid->resource);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
617 jabber_id_free(jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
618 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
619
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
620 if(jbr && jbr->capabilities & JABBER_CAP_RETRIEVED) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
621 callback(js, who, jbr->capabilities, data);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
622 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
623 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
624
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
625 jdicd = g_new0(struct _jabber_disco_info_cb_data, 1);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
626 jdicd->data = data;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
627 jdicd->callback = callback;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
628
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
629 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34746
diff changeset
630 purple_xmlnode_set_attrib(iq->node, "to", who);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
631
26910
7813befc9bf9 Split the jabber_disco_info_do IQ callback from the IQ handler and use the IQ callback semantics.
Paul Aurich <darkrain42@pidgin.im>
parents: 26908
diff changeset
632 jabber_iq_set_callback(iq, jabber_disco_info_cb, jdicd);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
633 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
634 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
635

mercurial