libpurple/protocols/jabber/disco.c

Wed, 29 Apr 2009 23:20:51 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Wed, 29 Apr 2009 23:20:51 +0000
changeset 27211
68a7be484fe1
parent 26958
a955bd42f529
parent 26928
89d794256bfa
child 27212
b458f88ab2d4
permissions
-rw-r--r--

propagate from branch 'im.pidgin.pidgin' (head feb6f844abcd8e7add3c986f3010f642838533e8)
to branch 'im.pidgin.cpw.darkrain42.xmpp.disco' (head 89d794256bfae4cd7b60b635b786baf37e472a6a)

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 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19832
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 #include "internal.h"
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "prefs.h"
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
24 #include "debug.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25290
diff changeset
26 #include "adhoccommands.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #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
28 #include "disco.h"
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
29 #include "google.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include "iq.h"
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
31 #include "jabber.h"
26143
673b6665624d Restructure Jingle code to more easily support multiple application types.
Michael Ruprecht <maiku@pidgin.im>
parents: 26106
diff changeset
32 #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
33 #include "pep.h"
15344
34b7f4e55861 [gaim-migrate @ 18072]
Evan Schoenberg <evands@pidgin.im>
parents: 15323
diff changeset
34 #include "presence.h"
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
35 #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
36 #include "useravatar.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 struct _jabber_disco_info_cb_data {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39 gpointer data;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40 JabberDiscoInfoCallback *callback;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41 };
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42
26594
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
43 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
44 gpointer data;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
45 JabberDiscoItemsCallback *callback;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
46 };
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
47
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
48 #define SUPPORT_FEATURE(x) { \
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49 feature = xmlnode_new_child(query, "feature"); \
17783
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17773
diff changeset
50 xmlnode_set_attrib(feature, "var", x); \
2687df1ca202 PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents: 17773
diff changeset
51 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
53 struct jabber_disco_list_data {
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
54 JabberStream *js; /* TODO: Needed? */
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
55 PurpleDiscoList *list;
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
56 char *server;
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
57 int fetch_count;
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
58 };
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
59
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
60 struct jabber_disco_service_data {
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
61 char *jid;
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
62 char *node;
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
63 };
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
64
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
65 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
66 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
67 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
68 xmlnode *packet, gpointer data)
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
69 {
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 JabberBytestreamsStreamhost *sh = data;
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
71 xmlnode *query = xmlnode_get_child_with_namespace(packet, "query",
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
72 "http://jabber.org/protocol/bytestreams");
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 if (from && !strcmp(from, sh->jid) && query != 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
75 xmlnode *sh_node = xmlnode_get_child(query, "streamhost");
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 if (sh_node) {
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 const char *jid = xmlnode_get_attrib(sh_node, "jid");
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 const char *port = xmlnode_get_attrib(sh_node, "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
79
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
80
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 (jid == NULL || strcmp(jid, from) != 0)
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 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
83 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
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 sh->host = g_strdup(xmlnode_get_attrib(sh_node, "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
86 sh->zeroconf = g_strdup(xmlnode_get_attrib(sh_node, "zeroconf"));
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 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
88 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
89 }
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
90 }
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
91
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
92 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
93 "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
94 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
95 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
96
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
97 /* 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
98 if (!(sh->jid && sh->host && sh->port > 0)) {
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
99 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
100 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
101 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
102 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
103 js->bs_proxies = g_list_remove(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
104 }
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
105 }
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
106
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
108 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
109 JabberIqType type, const char *id,
26707
a4f7c5d5e5ae propagate from branch 'im.pidgin.pidgin' (head beb862745aa7b61bf9942e731fdef09bf0bba641)
Paul Aurich <darkrain42@pidgin.im>
parents: 26668 26692
diff changeset
110 xmlnode *in_query)
a4f7c5d5e5ae propagate from branch 'im.pidgin.pidgin' (head beb862745aa7b61bf9942e731fdef09bf0bba641)
Paul Aurich <darkrain42@pidgin.im>
parents: 26668 26692
diff changeset
111 {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
113 if(!from)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
114 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
115
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
116 if(type == JABBER_IQ_GET) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
117 xmlnode *query, *identity, *feature;
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
118 JabberIq *iq;
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
119 const char *node = 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
120 char *node_uri = NULL;
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
121
24734
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
122 /* create custom caps node URI */
24716
047f5075ca58 Entity Capabilities must be per-JabberStream
Paul Aurich <darkrain42@pidgin.im>
parents: 24715
diff changeset
123 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
124
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
125 iq = jabber_iq_new_query(js, JABBER_IQ_RESULT,
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
126 "http://jabber.org/protocol/disco#info");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
127
26593
338e4056ac4c Don't match in the disco callbacks hashtable on remote JID. Use IQ id instead.
Paul Aurich <darkrain42@pidgin.im>
parents: 26592
diff changeset
128 jabber_iq_set_id(iq, id);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
129
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
130 xmlnode_set_attrib(iq->node, "to", from);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
131 query = xmlnode_get_child(iq->node, "query");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
132
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
133 if(node)
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
134 xmlnode_set_attrib(query, "node", node);
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
135
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
136 if(!node || !strcmp(node, CAPS0115_NODE "#" VERSION)) {
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
137 identity = xmlnode_new_child(query, "identity");
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
138 xmlnode_set_attrib(identity, "category", "client");
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
139 xmlnode_set_attrib(identity, "type", "pc"); /* XXX: bot, console,
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
140 * handheld, pc, phone,
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
141 * web */
13704
5800709f09f0 [gaim-migrate @ 16105]
Nathan Walp <nwalp@pidgin.im>
parents: 13703
diff changeset
142 xmlnode_set_attrib(identity, "name", PACKAGE);
26073
62f7a54ea3a8 Fix up merge (why can't it simply make the changes to my WD first?)
Paul Aurich <darkrain42@pidgin.im>
parents: 26072
diff changeset
143 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
145 if(!node || !strcmp(node, node_uri)) {
24715
69aaae59e205 Fix compilation errors and many warnings
Paul Aurich <darkrain42@pidgin.im>
parents: 23954
diff changeset
146 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
147 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
148 JabberIdentity *ident = (JabberIdentity*)identities->data;
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
149 identity = xmlnode_new_child(query, "identity");
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
150 xmlnode_set_attrib(identity, "category", ident->category);
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
151 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
152 if (ident->lang)
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
153 xmlnode_set_attrib(identity, "xml:lang", ident->lang);
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
154 if (ident->name)
780b8ad67c22 Sprinkle around more support for xml:lang on JabberIdentities
Paul Aurich <darkrain42@pidgin.im>
parents: 24717
diff changeset
155 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
156 }
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
157 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
158 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
159 if (!feat->is_enabled || feat->is_enabled(js, feat->namespace)) {
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
160 feature = xmlnode_new_child(query, "feature");
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
161 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
162 }
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
163 }
23714
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
164 #ifdef USE_VV
26668
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
165 } else if (g_str_equal(node, CAPS0115_NODE "#" "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
166 /*
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
167 * 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
168 * 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
169 * 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
170 *
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
171 * 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
172 * 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
173 * 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
174 */
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
175 xmlnode *feature = xmlnode_new_child(query, "feature");
ef06285f3b64 Fix allowing gmail user to initiate voice call by advertising a specific ext
Paul Aurich <darkrain42@pidgin.im>
parents: 26659
diff changeset
176 xmlnode_set_attrib(feature, "var", "http://www.google.com/xmpp/protocol/voice/v1");
23714
a08cf0090382 Check remote JID's capabilities for audio and video XEP support.
Michael Ruprecht <maiku@pidgin.im>
parents: 22648
diff changeset
177 #endif
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
178 } else {
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
179 xmlnode *error, *inf;
27211
68a7be484fe1 propagate from branch 'im.pidgin.pidgin' (head feb6f844abcd8e7add3c986f3010f642838533e8)
Paul Aurich <darkrain42@pidgin.im>
parents: 26958 26928
diff changeset
180
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
181 /* XXX: gross hack, implement jabber_iq_set_type or something */
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
182 xmlnode_set_attrib(iq->node, "type", "error");
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
183 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
184
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
185 error = xmlnode_new_child(query, "error");
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
186 xmlnode_set_attrib(error, "code", "404");
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
187 xmlnode_set_attrib(error, "type", "cancel");
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
188 inf = xmlnode_new_child(error, "item-not-found");
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
189 xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas");
13385
6fb64ae23761 [gaim-migrate @ 15757]
Nathan Walp <nwalp@pidgin.im>
parents: 11675
diff changeset
190 }
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21688
diff changeset
191 g_free(node_uri);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
192 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
193 } 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
194 /* 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
195 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR);
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
196 xmlnode *error, *bad_request;
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
197
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 /* Free the <query/> */
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 xmlnode_free(xmlnode_get_child(iq->node, "query"));
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 /* Add an error */
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
201 error = xmlnode_new_child(iq->node, "error");
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 xmlnode_set_attrib(error, "type", "modify");
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 bad_request = xmlnode_new_child(error, "bad-request");
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
204 xmlnode_set_namespace(bad_request, "urn:ietf:params:xml:ns:xmpp-stanzas");
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
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
206 jabber_iq_set_id(iq, id);
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
207 xmlnode_set_attrib(iq->node, "to", 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
208
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
209 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
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 }
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
212
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
213 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
214 JabberIqType type, const char *id,
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 xmlnode *packet, gpointer data)
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 struct _jabber_disco_info_cb_data *jdicd = data;
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 xmlnode *query;
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
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 query = xmlnode_get_child_with_namespace(packet, "query",
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
221 "http://jabber.org/protocol/disco#info");
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 if (type == JABBER_IQ_RESULT && query) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
224 xmlnode *child;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
225 JabberID *jid;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
226 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
227 JabberBuddyResource *jbr = NULL;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
228 JabberCapabilities capabilities = JABBER_CAP_NONE;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
229 struct _jabber_disco_info_cb_data *jdicd;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
231 if((jid = jabber_id_new(from))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
232 if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE)))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
233 jbr = jabber_buddy_find_resource(jb, jid->resource);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
234 jabber_id_free(jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
235 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
236
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237 if(jbr)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238 capabilities = jbr->capabilities;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
239
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
240 for(child = query->child; child; child = child->next) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
241 if(child->type != XMLNODE_TYPE_TAG)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
243
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
244 if(!strcmp(child->name, "identity")) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
245 const char *category = xmlnode_get_attrib(child, "category");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246 const char *type = xmlnode_get_attrib(child, "type");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
247 if(!category || !type)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
248 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
249
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
250 if(!strcmp(category, "conference") && !strcmp(type, "text")) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
251 /* 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
252 /* 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
253 js->chat_servers = g_list_prepend(js->chat_servers, g_strdup(from));
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
254 } else if(!strcmp(category, "directory") && !strcmp(type, "user")) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
255 /* 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
256 js->user_directories = g_list_prepend(js->user_directories, 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
257 } else if(!strcmp(category, "proxy") && !strcmp(type, "bytestreams")) {
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
258 /* 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
259 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
260 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
261
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 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
263
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 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
265 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
266 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
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 iq = jabber_iq_new_query(js, JABBER_IQ_GET,
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 "http://jabber.org/protocol/bytestreams");
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 xmlnode_set_attrib(iq->node, "to", sh->jid);
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 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
272 jabber_iq_send(iq);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
273 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
274
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
275 } else if(!strcmp(child->name, "feature")) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
276 const char *var = xmlnode_get_attrib(child, "var");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
277 if(!var)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
279
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
280 if(!strcmp(var, "http://jabber.org/protocol/si"))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281 capabilities |= JABBER_CAP_SI;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
282 else if(!strcmp(var, "http://jabber.org/protocol/si/profile/file-transfer"))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283 capabilities |= JABBER_CAP_SI_FILE_XFER;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
284 else if(!strcmp(var, "http://jabber.org/protocol/bytestreams"))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
285 capabilities |= JABBER_CAP_BYTESTREAMS;
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
286 else if(!strcmp(var, "jabber:iq:search"))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
287 capabilities |= JABBER_CAP_IQ_SEARCH;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
288 else if(!strcmp(var, "jabber:iq:register"))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
289 capabilities |= JABBER_CAP_IQ_REGISTER;
26688
e036a4d105c1 Do not advertise support for old XEP-0199 (Ping) namespace
Paul Aurich <darkrain42@pidgin.im>
parents: 26687
diff changeset
290 else if(!strcmp(var, "urn:xmpp:ping"))
17769
69d98a4da006 applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents: 17768
diff changeset
291 capabilities |= JABBER_CAP_PING;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
292 else if(!strcmp(var, "http://jabber.org/protocol/disco#items"))
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
293 capabilities |= JABBER_CAP_ITEMS;
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
294 else if(!strcmp(var, "http://jabber.org/protocol/commands")) {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
295 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
296 }
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 23912
diff changeset
297 else if(!strcmp(var, "http://jabber.org/protocol/ibb")) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 23912
diff changeset
298 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
299 capabilities |= JABBER_CAP_IBB;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 23912
diff changeset
300 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
301 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
302 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
303
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
304 capabilities |= JABBER_CAP_RETRIEVED;
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 if(jbr)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
307 jbr->capabilities = capabilities;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
308
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
309 jdicd->callback(js, from, capabilities, jdicd->data);
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
310 } else { /* type == JABBER_IQ_ERROR or query == NULL */
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
311 JabberID *jid;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
312 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
313 JabberBuddyResource *jbr = NULL;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
314 JabberCapabilities capabilities = JABBER_CAP_NONE;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
315
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
316 if((jid = jabber_id_new(from))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
317 if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE)))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
318 jbr = jabber_buddy_find_resource(jb, jid->resource);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
319 jabber_id_free(jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
320 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
321
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
322 if(jbr)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
323 capabilities = jbr->capabilities;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
324
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
325 jdicd->callback(js, from, capabilities, jdicd->data);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
326 }
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
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
329 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
330 JabberIqType type, const char *id,
26707
a4f7c5d5e5ae propagate from branch 'im.pidgin.pidgin' (head beb862745aa7b61bf9942e731fdef09bf0bba641)
Paul Aurich <darkrain42@pidgin.im>
parents: 26668 26692
diff changeset
331 xmlnode *query)
a4f7c5d5e5ae propagate from branch 'im.pidgin.pidgin' (head beb862745aa7b61bf9942e731fdef09bf0bba641)
Paul Aurich <darkrain42@pidgin.im>
parents: 26668 26692
diff changeset
332 {
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
333 if(type == JABBER_IQ_GET) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
334 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_RESULT,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
335 "http://jabber.org/protocol/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
336
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
337 /* preserve node */
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
338 xmlnode *iq_query = xmlnode_get_child(iq->node, "query");
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
339 const char *node = xmlnode_get_attrib(query, "node");
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
340 if(node)
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
341 xmlnode_set_attrib(iq_query,"node",node);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
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 jabber_iq_set_id(iq, id);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
344
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
345 if (from)
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25553
diff changeset
346 xmlnode_set_attrib(iq->node, "to", from);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
347 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
348 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
349 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
350
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
351 static void
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
352 jabber_disco_finish_server_info_result_cb(JabberStream *js)
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
353 {
23912
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
354 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
355
25810
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25477
diff changeset
356 /*
5cf3c22e52df Always publish a <photo/> element, even if we have an empty buddy icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25477
diff changeset
357 * 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
358 * 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
359 * 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
360 */
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18225
diff changeset
361 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
362
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25290
diff changeset
363 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
364 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
365
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
366 if (!(js->server_caps & JABBER_CAP_GOOGLE_ROSTER)) {
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
367 /* If the server supports JABBER_CAP_GOOGLE_ROSTER; we will have already requested it */
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
368 jabber_roster_request(js);
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
369 }
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
370
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
371 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
372 /* 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
373 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
374 }
23912
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
375
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 23912
diff changeset
376 /* 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
377 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
378 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
379 }
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 23912
diff changeset
380
23912
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
381 /* If there are manually specified bytestream proxies, query them */
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
382 ft_proxies = purple_account_get_string(js->gc->account, "ft_proxies", NULL);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
383 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
384 JabberIq *iq;
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
385 JabberBytestreamsStreamhost *sh;
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
386 int i;
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
387 char *tmp;
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
388 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
389
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
390 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
391 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
392 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
393 continue;
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
394
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
395 /* 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
396 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
397 *tmp = '\0';
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
398
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
399 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
400 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
401 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
402
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
403 iq = jabber_iq_new_query(js, JABBER_IQ_GET,
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
404 "http://jabber.org/protocol/bytestreams");
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
405 xmlnode_set_attrib(iq->node, "to", sh->jid);
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
406 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
407 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
408 }
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
409
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
410 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
411 }
8169bfe82e47 Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents: 21688
diff changeset
412
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
413 }
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
414
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
415 struct _disco_data {
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
416 struct jabber_disco_list_data *list_data;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
417 PurpleDiscoService *parent;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
418 char *node;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
419 };
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
420
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
421 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
422 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
423 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
424 xmlnode *packet, gpointer data)
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
425 {
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
426 xmlnode *query, *child;
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
427
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
428 if (!from || strcmp(from, js->user->domain)) {
15358
c8179e0a5483 [gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents: 15355
diff changeset
429 jabber_disco_finish_server_info_result_cb(js);
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
430 return;
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
431 }
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
432
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
433 if (type == JABBER_IQ_ERROR) {
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
434 /* 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
435 jabber_disco_finish_server_info_result_cb(js);
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
436 return;
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
437 }
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
438
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
439 query = xmlnode_get_child(packet, "query");
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
440
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
441 if (!query) {
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
442 jabber_disco_finish_server_info_result_cb(js);
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
443 return;
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
444 }
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
445
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
446 for (child = xmlnode_get_child(query, "identity"); child;
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
447 child = xmlnode_get_next_twin(child)) {
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
448 const char *category, *type, *name;
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
449 category = xmlnode_get_attrib(child, "category");
17768
7be011945a1b added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents: 17423
diff changeset
450 type = xmlnode_get_attrib(child, "type");
19894
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
451 if(category && type && !strcmp(category, "pubsub") && !strcmp(type,"pep"))
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18719
diff changeset
452 js->pep = TRUE;
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
453 if (!category || strcmp(category, "server"))
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
454 continue;
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
455 if (!type || strcmp(type, "im"))
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
456 continue;
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
457
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
458 name = xmlnode_get_attrib(child, "name");
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
459 if (!name)
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
460 continue;
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
461
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
462 g_free(js->server_name);
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
463 js->server_name = g_strdup(name);
15587
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
464 if (!strcmp(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
465 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
466 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
467
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26186
diff changeset
468 /* autodiscover stun and relays */
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26186
diff changeset
469 jabber_google_send_jingle_info(js);
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26186
diff changeset
470 } else {
443041606e32 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <malu@pidgin.im>
parents: 26186
diff changeset
471 /* TODO: add external service discovery here... */
15587
cbedd543bfae Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
472 }
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
473 }
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
474
17421
9399db1f7bbd whitespace
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
475 for (child = xmlnode_get_child(query, "feature"); child;
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
476 child = xmlnode_get_next_twin(child)) {
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
477 const char *var;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
478 var = xmlnode_get_attrib(child, "var");
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
479 if (!var)
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
480 continue;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
481
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
482 if (!strcmp("google:mail:notify", var)) {
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
483 js->server_caps |= JABBER_CAP_GMAIL_NOTIFY;
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
484 jabber_gmail_init(js);
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
485 } else if (!strcmp("google:roster", var)) {
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
486 js->server_caps |= JABBER_CAP_GOOGLE_ROSTER;
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
487 jabber_google_roster_init(js);
17817
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
488 } else if (!strcmp("http://jabber.org/protocol/commands", var)) {
8e0f271aab78 The server's ad-hoc commands are now listed in the account's action menu. Note that this requires an additional field in the _PurplePluginAction struct. There's no other way, since there was no way to supply user_data, and dynamically created functions are not supported by C. This should be fine, since that struct is only malloced in purple_plugin_action_new, which is part of the core. Applications have to either pass the struct unmodified, or restore the user_data pointer if the action is recreated when necessary (as is the case in Adium).
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
489 js->server_caps |= JABBER_CAP_ADHOC;
25290
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 23912
diff changeset
490 } else if (!strcmp("urn:xmpp:blocking", var)) {
033942580f51 Commit patch #7670: Implement xep-0191 (simple blocking) for jabber protocols
Mark Doliner <markdoliner@pidgin.im>
parents: 23912
diff changeset
491 js->server_caps |= JABBER_CAP_BLOCKING;
15225
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
492 }
d04a059065dd [gaim-migrate @ 17949]
Sean Egan <seanegan@pidgin.im>
parents: 15197
diff changeset
493 }
15265
a5b0ab58b05d [gaim-migrate @ 17993]
Sean Egan <seanegan@pidgin.im>
parents: 15225
diff changeset
494
15355
1ce281d16071 [gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents: 15344
diff changeset
495 jabber_disco_finish_server_info_result_cb(js);
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
496 }
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
497
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
498 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
499 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
500 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
501 xmlnode *packet, gpointer data)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
502 {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
503 xmlnode *query, *child;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
504
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
505 if (!from || strcmp(from, js->user->domain) != 0)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
506 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
507
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
508 if (type == JABBER_IQ_ERROR)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
509 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
510
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
511 while(js->chat_servers) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
512 g_free(js->chat_servers->data);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
513 js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
514 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
515
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
516 query = xmlnode_get_child(packet, "query");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
517
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
518 for(child = xmlnode_get_child(query, "item"); child;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
519 child = xmlnode_get_next_twin(child)) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
520 JabberIq *iq;
17423
1f3a88fda48e skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents: 17421
diff changeset
521 const char *jid, *node;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
522
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
523 if(!(jid = xmlnode_get_attrib(child, "jid")))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
524 continue;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
525
17423
1f3a88fda48e skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents: 17421
diff changeset
526 /* 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
527 * so we won't query them */
1f3a88fda48e skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents: 17421
diff changeset
528 if((node = xmlnode_get_attrib(child, "node")))
1f3a88fda48e skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents: 17421
diff changeset
529 continue;
1f3a88fda48e skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents: 17421
diff changeset
530
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
531 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
532 xmlnode_set_attrib(iq->node, "to", jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
533 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
534 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
535 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
536
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
537 void jabber_disco_items_server(JabberStream *js)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
538 {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
539 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
540 "http://jabber.org/protocol/disco#items");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
541
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
542 xmlnode_set_attrib(iq->node, "to", js->user->domain);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
543
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
544 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
545 jabber_iq_send(iq);
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
546
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
547 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info");
15197
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
548 xmlnode_set_attrib(iq->node, "to", js->user->domain);
1d98528d4ee3 [gaim-migrate @ 17921]
Sean Egan <seanegan@pidgin.im>
parents: 14356
diff changeset
549 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
550 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
551 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
552
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
553 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
554 {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
555 JabberID *jid;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
556 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
557 JabberBuddyResource *jbr = NULL;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
558 struct _jabber_disco_info_cb_data *jdicd;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
559 JabberIq *iq;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
560
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
561 if((jid = jabber_id_new(who))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
562 if(jid->resource && (jb = jabber_buddy_find(js, who, TRUE)))
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
563 jbr = jabber_buddy_find_resource(jb, jid->resource);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
564 jabber_id_free(jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
565 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
566
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
567 if(jbr && jbr->capabilities & JABBER_CAP_RETRIEVED) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
568 callback(js, who, jbr->capabilities, data);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
569 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
570 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
571
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
572 jdicd = g_new0(struct _jabber_disco_info_cb_data, 1);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
573 jdicd->data = data;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
574 jdicd->callback = callback;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
575
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
576 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
577 xmlnode_set_attrib(iq->node, "to", who);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
578
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
579 jabber_iq_set_callback(iq, jabber_disco_info_cb, jdicd);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
580 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
581 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
582
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
583 static void
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
584 jabber_disco_list_data_destroy(struct jabber_disco_list_data *data)
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
585 {
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
586 g_free(data->server);
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
587 g_free(data);
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
588 }
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
589
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
590 static void
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
591 disco_proto_data_destroy_cb(PurpleDiscoList *list)
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
592 {
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
593 struct jabber_disco_list_data *data;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
594
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
595 data = purple_disco_list_get_protocol_data(list);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
596 jabber_disco_list_data_destroy(data);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
597 }
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
598
26596
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
599 static PurpleDiscoServiceType
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
600 jabber_disco_category_from_string(const gchar *str)
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
601 {
26596
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
602 if (!g_ascii_strcasecmp(str, "gateway"))
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
603 return PURPLE_DISCO_SERVICE_TYPE_GATEWAY;
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
604 else if (!g_ascii_strcasecmp(str, "directory"))
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
605 return PURPLE_DISCO_SERVICE_TYPE_DIRECTORY;
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
606 else if (!g_ascii_strcasecmp(str, "conference"))
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
607 return PURPLE_DISCO_SERVICE_TYPE_CHAT;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
608
26596
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
609 return PURPLE_DISCO_SERVICE_TYPE_OTHER;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
610 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
611
26928
89d794256bfa Constify the disco_type_mappings struct
Paul Aurich <darkrain42@pidgin.im>
parents: 26920
diff changeset
612 static const struct {
26915
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
613 const char *from;
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
614 const char *to;
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
615 } disco_type_mappings[] = {
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
616 { "gadu-gadu", "gg" },
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
617 { "sametime", "meanwhile" },
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
618 { "myspaceim", "myspace" },
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
619 { "xmpp", "jabber" },
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
620 { NULL, NULL }
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
621 };
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
622
26596
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
623 static const gchar *
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
624 jabber_disco_type_from_string(const gchar *str)
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
625 {
26915
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
626 int i = 0;
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
627
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
628 g_return_val_if_fail(str != NULL, "");
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
629
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
630 for ( ; disco_type_mappings[i].from; ++i) {
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
631 if (!strcasecmp(str, disco_type_mappings[i].from))
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
632 return disco_type_mappings[i].to;
f1ff4c059496 Remove most of the mappings, add in the ones necessary from our prpls, and
Paul Aurich <darkrain42@pidgin.im>
parents: 26914
diff changeset
633 }
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
634
26596
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
635 /* fallback to the string itself */
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
636 return str;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
637 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
638
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
639 static void
26907
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
640 jabber_disco_service_info_cb(JabberStream *js, const char *from,
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
641 JabberIqType type, const char *id,
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
642 xmlnode *packet, gpointer data);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
643
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
644 static void
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
645 jabber_disco_service_items_cb(JabberStream *js, const char *who, const char *node,
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
646 GSList *items, gpointer data)
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
647 {
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
648 GSList *l;
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
649 struct _disco_data *disco_data;
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
650 struct jabber_disco_list_data *list_data;
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
651 PurpleDiscoList *list;
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
652 PurpleDiscoService *parent;
26920
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
653 PurpleDiscoServiceType parent_type;
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
654 const char *parent_node;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
655
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
656 disco_data = data;
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
657 list_data = disco_data->list_data;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
658 list = list_data->list;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
659
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
660 --list_data->fetch_count;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
661
26592
2ffecd246bfb Clean up Jabber's references and protocol_data if the window is closed
Paul Aurich <darkrain42@pidgin.im>
parents: 26591
diff changeset
662 if (list_data->list == NULL) {
2ffecd246bfb Clean up Jabber's references and protocol_data if the window is closed
Paul Aurich <darkrain42@pidgin.im>
parents: 26591
diff changeset
663 if (list_data->fetch_count == 0)
2ffecd246bfb Clean up Jabber's references and protocol_data if the window is closed
Paul Aurich <darkrain42@pidgin.im>
parents: 26591
diff changeset
664 jabber_disco_list_data_destroy(list_data);
2ffecd246bfb Clean up Jabber's references and protocol_data if the window is closed
Paul Aurich <darkrain42@pidgin.im>
parents: 26591
diff changeset
665
2ffecd246bfb Clean up Jabber's references and protocol_data if the window is closed
Paul Aurich <darkrain42@pidgin.im>
parents: 26591
diff changeset
666 return;
2ffecd246bfb Clean up Jabber's references and protocol_data if the window is closed
Paul Aurich <darkrain42@pidgin.im>
parents: 26591
diff changeset
667 }
2ffecd246bfb Clean up Jabber's references and protocol_data if the window is closed
Paul Aurich <darkrain42@pidgin.im>
parents: 26591
diff changeset
668
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
669 if (items == NULL) {
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
670 if (list_data->fetch_count == 0)
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
671 purple_disco_list_set_in_progress(list, FALSE);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
672
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
673 purple_disco_list_unref(list);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
674 return;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
675 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
676
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
677 parent = disco_data->parent;
26920
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
678 parent_type = purple_disco_service_get_type(parent);
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
679 parent_node = disco_data->node;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
680
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
681 for (l = items; l; l = l->next) {
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
682 JabberDiscoItem *item = l->data;
26920
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
683
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
684 if (parent_type & PURPLE_DISCO_SERVICE_TYPE_CHAT) {
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
685 /* A chat server's items are chats. I promise. */
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
686 PurpleDiscoService *service;
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
687 struct jabber_disco_service_data *service_data;
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
688 JabberID *jid = jabber_id_new(item->jid);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
689
26920
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
690 if (jid) {
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
691 service_data = g_new0(struct jabber_disco_service_data, 1);
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
692 service_data->jid = g_strdup(item->jid);
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
693
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
694 service = purple_disco_list_service_new(PURPLE_DISCO_SERVICE_TYPE_CHAT,
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
695 jid->node, item->name, PURPLE_DISCO_ADD, service_data);
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
696
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
697 purple_disco_list_service_add(list, service, parent);
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
698
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
699 jabber_id_free(jid);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
700 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
701 } else {
26920
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
702 JabberIq *iq;
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
703 struct _disco_data *req_data;
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
704 char *full_node;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
705
26920
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
706 if (parent_node && !item->node)
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
707 continue;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
708
26920
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
709 if (parent_node)
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
710 full_node = g_strconcat(parent_node, "/", item->node, NULL);
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
711 else
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
712 full_node = g_strdup(item->node);
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
713
26920
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
714 req_data = g_new0(struct _disco_data, 1);
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
715 req_data->list_data = list_data;
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
716 req_data->parent = parent;
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
717 req_data->node = full_node;
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
718
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
719 ++list_data->fetch_count;
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
720 purple_disco_list_ref(list);
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
721
26920
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
722 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info");
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
723 xmlnode_set_attrib(iq->node, "to", item->jid);
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
724 if (full_node)
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
725 xmlnode_set_attrib(xmlnode_get_child(iq->node, "query"),
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
726 "node", full_node);
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
727 jabber_iq_set_callback(iq, jabber_disco_service_info_cb, req_data);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
728
26920
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
729 jabber_iq_send(iq);
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
730 }
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
731 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
732
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
733 g_slist_foreach(items, (GFunc)jabber_disco_item_free, NULL);
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
734 g_slist_free(items);
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
735
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
736 if (list_data->fetch_count == 0)
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
737 purple_disco_list_set_in_progress(list, FALSE);
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
738
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
739 purple_disco_list_unref(list);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
740
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
741 g_free(disco_data->node);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
742 g_free(disco_data);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
743 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
744
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
745 static void
26907
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
746 jabber_disco_service_info_cb(JabberStream *js, const char *from,
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
747 JabberIqType type, const char *id,
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
748 xmlnode *packet, gpointer data)
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
749 {
26911
579d7182a2fc Various minor nitpicky changes
Paul Aurich <darkrain42@pidgin.im>
parents: 26910
diff changeset
750 struct _disco_data *disco_data;
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
751 struct jabber_disco_list_data *list_data;
26913
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
752 xmlnode *query, *identity, *child;
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
753 const char *anode;
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
754 char *aname, *node;
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
755
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
756 PurpleDiscoList *list;
26913
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
757 PurpleDiscoService *parent, *service;
26907
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
758 PurpleDiscoServiceType service_type;
26911
579d7182a2fc Various minor nitpicky changes
Paul Aurich <darkrain42@pidgin.im>
parents: 26910
diff changeset
759 PurpleDiscoServiceFlags flags;
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
760 struct jabber_disco_service_data *service_data;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
761
26911
579d7182a2fc Various minor nitpicky changes
Paul Aurich <darkrain42@pidgin.im>
parents: 26910
diff changeset
762 disco_data = data;
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
763 list_data = disco_data->list_data;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
764 list = list_data->list;
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
765 parent = disco_data->parent;
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
766
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
767 node = disco_data->node;
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
768 disco_data->node = NULL;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
769 g_free(disco_data);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
770
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
771 --list_data->fetch_count;
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
772
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
773 if (!purple_disco_list_get_in_progress(list)) {
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
774 purple_disco_list_unref(list);
26592
2ffecd246bfb Clean up Jabber's references and protocol_data if the window is closed
Paul Aurich <darkrain42@pidgin.im>
parents: 26591
diff changeset
775 return;
2ffecd246bfb Clean up Jabber's references and protocol_data if the window is closed
Paul Aurich <darkrain42@pidgin.im>
parents: 26591
diff changeset
776 }
2ffecd246bfb Clean up Jabber's references and protocol_data if the window is closed
Paul Aurich <darkrain42@pidgin.im>
parents: 26591
diff changeset
777
26907
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
778 if (!from || type == JABBER_IQ_ERROR
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
779 || (!(query = xmlnode_get_child(packet, "query")))
26911
579d7182a2fc Various minor nitpicky changes
Paul Aurich <darkrain42@pidgin.im>
parents: 26910
diff changeset
780 || (!(identity = xmlnode_get_child(query, "identity")))) {
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
781 if (list_data->fetch_count == 0)
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
782 purple_disco_list_set_in_progress(list, FALSE);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
783
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
784 purple_disco_list_unref(list);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
785 return;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
786 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
787
26913
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
788 service_type = jabber_disco_category_from_string(
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
789 xmlnode_get_attrib(identity, "category"));
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
790
26911
579d7182a2fc Various minor nitpicky changes
Paul Aurich <darkrain42@pidgin.im>
parents: 26910
diff changeset
791 /* Default to allowing things to be add-able */
579d7182a2fc Various minor nitpicky changes
Paul Aurich <darkrain42@pidgin.im>
parents: 26910
diff changeset
792 flags = PURPLE_DISCO_ADD;
579d7182a2fc Various minor nitpicky changes
Paul Aurich <darkrain42@pidgin.im>
parents: 26910
diff changeset
793
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
794 for (child = xmlnode_get_child(query, "feature"); child;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
795 child = xmlnode_get_next_twin(child)) {
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
796 const char *var;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
797
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
798 if (!(var = xmlnode_get_attrib(child, "var")))
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
799 continue;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
800
26911
579d7182a2fc Various minor nitpicky changes
Paul Aurich <darkrain42@pidgin.im>
parents: 26910
diff changeset
801 if (g_str_equal(var, "jabber:iq:register"))
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
802 flags |= PURPLE_DISCO_REGISTER;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
803
26911
579d7182a2fc Various minor nitpicky changes
Paul Aurich <darkrain42@pidgin.im>
parents: 26910
diff changeset
804 if (g_str_equal(var, "http://jabber.org/protocol/disco#items"))
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
805 flags |= PURPLE_DISCO_BROWSE;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
806
26917
83f2abb0364d Discovered why that default assumption of PURPLE_DISCO_BROWSE was in there...
Paul Aurich <darkrain42@pidgin.im>
parents: 26916
diff changeset
807 if (g_str_equal(var, "http://jabber.org/protocol/muc")) {
83f2abb0364d Discovered why that default assumption of PURPLE_DISCO_BROWSE was in there...
Paul Aurich <darkrain42@pidgin.im>
parents: 26916
diff changeset
808 flags |= PURPLE_DISCO_BROWSE;
26907
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
809 service_type = PURPLE_DISCO_SERVICE_TYPE_CHAT;
26917
83f2abb0364d Discovered why that default assumption of PURPLE_DISCO_BROWSE was in there...
Paul Aurich <darkrain42@pidgin.im>
parents: 26916
diff changeset
810 }
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
811 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
812
26913
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
813 if ((anode = xmlnode_get_attrib(query, "node")))
26920
d460454d4241 Move the handling of chat rooms to jabber_disco_service_items_cb.
Paul Aurich <darkrain42@pidgin.im>
parents: 26917
diff changeset
814 aname = g_strconcat(from, anode, NULL);
26913
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
815 else
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
816 aname = g_strdup(from);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
817
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
818 service_data = g_new0(struct jabber_disco_service_data, 1);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
819 service_data->jid = g_strdup(from);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
820 if (anode)
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
821 service_data->node = g_strdup(anode);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
822
26913
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
823 service = purple_disco_list_service_new(service_type, aname,
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
824 xmlnode_get_attrib(identity, "name"), flags, service_data);
26913
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
825 g_free(aname);
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
826
26907
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
827 if (service_type == PURPLE_DISCO_SERVICE_TYPE_GATEWAY)
26913
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
828 purple_disco_service_set_gateway_type(service,
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
829 jabber_disco_type_from_string(xmlnode_get_attrib(identity,
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
830 "type")));
26596
d44a3a6a3046 s/category/type/ and s/muc/chat/ in the core and gateway type is a string.
Paul Aurich <darkrain42@pidgin.im>
parents: 26595
diff changeset
831
26913
ee9a3c5b3bdb More minor cleanup (no functional changes other than not printing a log msg)
Paul Aurich <darkrain42@pidgin.im>
parents: 26911
diff changeset
832 purple_disco_list_service_add(list, service, parent);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
833
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
834 if (list_data->fetch_count == 0)
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
835 purple_disco_list_set_in_progress(list, FALSE);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
836
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
837 purple_disco_list_unref(list);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
838
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
839 g_free(node);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
840 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
841
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
842 static void
26907
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
843 jabber_disco_server_items_cb(JabberStream *js, const char *from,
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
844 JabberIqType type, const char *id,
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
845 xmlnode *packet, gpointer data)
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
846 {
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
847 struct jabber_disco_list_data *list_data;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
848 xmlnode *query, *child;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
849 gboolean has_items = FALSE;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
850
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
851 list_data = data;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
852 --list_data->fetch_count;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
853
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
854 if (!from || type == JABBER_IQ_ERROR ||
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
855 !purple_disco_list_get_in_progress(list_data->list)) {
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
856 purple_disco_list_unref(list_data->list);
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
857 return;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
858 }
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
859
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
860 query = xmlnode_get_child(packet, "query");
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
861
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
862 for(child = xmlnode_get_child(query, "item"); child;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
863 child = xmlnode_get_next_twin(child)) {
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
864 JabberIq *iq;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
865 const char *jid;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
866 struct _disco_data *disco_data;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
867
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
868 if(!(jid = xmlnode_get_attrib(child, "jid")))
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
869 continue;
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
870
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
871 disco_data = g_new0(struct _disco_data, 1);
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
872 disco_data->list_data = list_data;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
873
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
874 has_items = TRUE;
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
875 ++list_data->fetch_count;
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
876 purple_disco_list_ref(list_data->list);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
877 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info");
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
878 xmlnode_set_attrib(iq->node, "to", jid);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
879 jabber_iq_set_callback(iq, jabber_disco_service_info_cb, disco_data);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
880
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
881 jabber_iq_send(iq);
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
882 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
883
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
884 if (!has_items)
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
885 purple_disco_list_set_in_progress(list_data->list, FALSE);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
886
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
887 purple_disco_list_unref(list_data->list);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
888 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
889
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
890 static void
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
891 jabber_disco_server_info_cb(JabberStream *js, const char *who, JabberCapabilities caps, gpointer data)
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
892 {
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
893 struct jabber_disco_list_data *list_data;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
894
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
895 list_data = data;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
896 --list_data->fetch_count;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
897
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
898 if (!list_data->list) {
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
899 purple_disco_list_unref(list_data->list);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
900
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
901 if (list_data->fetch_count == 0)
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
902 jabber_disco_list_data_destroy(list_data);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
903
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
904 return;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
905 }
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
906
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
907 if (caps & JABBER_CAP_ITEMS) {
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
908 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#items");
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
909 xmlnode_set_attrib(iq->node, "to", who);
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
910 jabber_iq_set_callback(iq, jabber_disco_server_items_cb, list_data);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
911
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
912 ++list_data->fetch_count;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
913 purple_disco_list_ref(list_data->list);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
914
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
915 jabber_iq_send(iq);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
916 } else {
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
917 purple_notify_error(NULL, _("Error"), _("Server doesn't support service discovery"), NULL);
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
918 purple_disco_list_set_in_progress(list_data->list, FALSE);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
919 }
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
920
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
921 purple_disco_list_unref(list_data->list);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
922 }
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
923
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
924 static void discolist_cancel_cb(struct jabber_disco_list_data *list_data, const char *server)
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
925 {
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
926 purple_disco_list_set_in_progress(list_data->list, FALSE);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
927 purple_disco_list_unref(list_data->list);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
928 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
929
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
930 static void discolist_ok_cb(struct jabber_disco_list_data *list_data, const char *server)
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
931 {
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
932 JabberStream *js;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
933
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
934 js = list_data->js;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
935
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
936 if (!server || !*server) {
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
937 purple_notify_error(js->gc, _("Invalid Server"), _("Invalid Server"), NULL);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
938
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
939 purple_disco_list_set_in_progress(list_data->list, FALSE);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
940 purple_disco_list_unref(list_data->list);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
941 return;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
942 }
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
943
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
944 list_data->server = g_strdup(server);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
945 if (js->last_disco_server)
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
946 g_free(js->last_disco_server);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
947 js->last_disco_server = g_strdup(server);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
948
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
949 purple_disco_list_set_in_progress(list_data->list, TRUE);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
950
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
951 ++list_data->fetch_count;
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
952 jabber_disco_info_do(js, list_data->server, jabber_disco_server_info_cb, list_data);
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
953 }
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
954
26908
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
955 static void
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
956 jabber_disco_service_close(PurpleDiscoService *service)
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
957 {
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
958 struct jabber_disco_service_data *data;
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
959
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
960 data = purple_disco_service_get_protocol_data(service);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
961 g_free(data->jid);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
962 g_free(data->node);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
963 g_free(data);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
964 }
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
965
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
966 #if 0
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
967 static void
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
968 jabber_disco_cancel(PurpleDiscoList *list)
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
969 {
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
970 /* This space intentionally letft blank */
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
971 }
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
972 #endif
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
973
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
974 static void
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
975 jabber_disco_list_expand(PurpleDiscoList *list, PurpleDiscoService *service)
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
976 {
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
977 PurpleAccount *account;
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
978 PurpleConnection *pc;
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
979 JabberStream *js;
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
980 struct jabber_disco_list_data *list_data;
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
981 struct jabber_disco_service_data *service_data;
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
982 struct _disco_data *disco_data;
26590
689f6f3b4d8a Make the prpl be in charge of creating the PurpleDiscoList; UI data is
Paul Aurich <darkrain42@pidgin.im>
parents: 26589
diff changeset
983
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
984 account = purple_disco_list_get_account(list);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
985 pc = purple_account_get_connection(account);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
986 js = purple_connection_get_protocol_data(pc);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
987
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
988 list_data = purple_disco_list_get_protocol_data(list);
26592
2ffecd246bfb Clean up Jabber's references and protocol_data if the window is closed
Paul Aurich <darkrain42@pidgin.im>
parents: 26591
diff changeset
989
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
990 ++list_data->fetch_count;
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
991 purple_disco_list_ref(list);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
992 disco_data = g_new0(struct _disco_data, 1);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
993 disco_data->list_data = list_data;
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
994 disco_data->parent = service;
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
995
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
996 service_data = purple_disco_service_get_protocol_data(service);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
997
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
998 jabber_disco_items_do(js, service_data->jid, service_data->node,
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
999 jabber_disco_service_items_cb, disco_data);
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
1000 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
1001
26908
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1002 static void
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
1003 jabber_disco_service_register(PurpleConnection *gc, PurpleDiscoService *service)
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
1004 {
26588
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
1005 JabberStream *js = purple_connection_get_protocol_data(gc);
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
1006
644d7d7ad292 Hide the structs, add accessors, and fix various smaller things:
Paul Aurich <darkrain42@pidgin.im>
parents: 26586
diff changeset
1007 jabber_register_gateway(js, purple_disco_service_get_name(service));
26908
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1008 }
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
1009
26908
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1010
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1011 PurpleDiscoList *
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1012 jabber_disco_get_list(PurpleConnection *gc)
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1013 {
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1014 PurpleAccount *account;
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1015 PurpleDiscoList *list;
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1016 JabberStream *js;
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1017 struct jabber_disco_list_data *disco_list_data;
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1018
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1019 account = purple_connection_get_account(gc);
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1020 js = purple_connection_get_protocol_data(gc);
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1021
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1022 /* We start with a ref */
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1023 list = purple_disco_list_new(account);
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1024
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1025 disco_list_data = g_new0(struct jabber_disco_list_data, 1);
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1026 disco_list_data->list = list;
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1027 disco_list_data->js = js;
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
1028 purple_disco_list_set_protocol_data(list, disco_list_data,
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
1029 disco_proto_data_destroy_cb);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
1030 purple_disco_list_set_service_close_func(list, jabber_disco_service_close);
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
1031 #if 0
26908
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1032 purple_disco_list_set_cancel_func(list, jabber_disco_cancel);
26916
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
1033 #endif
6cb5053eb433 Iteratively expand the disco tree as prompted by the UI.
Paul Aurich <darkrain42@pidgin.im>
parents: 26915
diff changeset
1034 purple_disco_list_set_expand_func(list, jabber_disco_list_expand);
26908
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1035 purple_disco_list_set_register_func(list, jabber_disco_service_register);
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1036
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1037 purple_request_input(gc, _("Server name request"), _("Enter an XMPP Server"),
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1038 _("Select an XMPP server to query"),
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1039 js->last_disco_server ? js->last_disco_server : js->user->domain,
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1040 FALSE, FALSE, NULL,
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1041 _("Find Services"), PURPLE_CALLBACK(discolist_ok_cb),
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1042 _("Cancel"), PURPLE_CALLBACK(discolist_cancel_cb),
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1043 account, NULL, NULL, disco_list_data);
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1044
e292ff5a9311 Use per-PurpleDiscoList ops for canceling a disco and registering.
Paul Aurich <darkrain42@pidgin.im>
parents: 26907
diff changeset
1045 return list;
26583
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
1046 }
e115c7ef2fcf Applied disco-2.patch from nops with some modifications:
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
1047
26594
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1048 static void
26907
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
1049 jabber_disco_items_cb(JabberStream *js, const char *from, JabberIqType type,
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
1050 const char *id, xmlnode *packet, gpointer data)
26594
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1051 {
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1052 struct _jabber_disco_items_cb_data *jdicd;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1053 xmlnode *query, *child;
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
1054 const char *node = NULL;
26594
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1055 GSList *items = NULL;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1056
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1057 jdicd = data;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1058
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1059 query = xmlnode_get_child(packet, "query");
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1060
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
1061 if (query)
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
1062 node = xmlnode_get_attrib(query, "node");
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
1063
26907
82a97da31ee2 Fix merge (convert to IQ-handlers syntax)
Paul Aurich <darkrain42@pidgin.im>
parents: 26741
diff changeset
1064 if (!from || !query || type == JABBER_IQ_ERROR) {
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
1065 jdicd->callback(js, from, node, NULL, jdicd->data);
26594
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1066 g_free(jdicd);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1067 return;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1068 }
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1069
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1070 for (child = xmlnode_get_child(query, "item"); child;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1071 child = xmlnode_get_next_twin(child)) {
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1072 JabberDiscoItem *item;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1073
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1074 item = g_new0(JabberDiscoItem, 1);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1075 item->jid = g_strdup(xmlnode_get_attrib(child, "jid"));
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1076 item->node = g_strdup(xmlnode_get_attrib(child, "node"));
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1077 item->name = g_strdup(xmlnode_get_attrib(child, "name"));
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1078
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1079 items = g_slist_prepend(items, item);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1080 }
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1081
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1082 items = g_slist_reverse(items);
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
1083 jdicd->callback(js, from, node, items, jdicd->data);
26594
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1084 g_free(jdicd);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1085 }
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1086
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
1087 void jabber_disco_items_do(JabberStream *js, const char *who, const char *node,
26594
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1088 JabberDiscoItemsCallback *callback, gpointer data)
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1089 {
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1090 struct _jabber_disco_items_cb_data *jdicd;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1091 JabberIq *iq;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1092
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1093 jdicd = g_new0(struct _jabber_disco_items_cb_data, 1);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1094 jdicd->data = data;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1095 jdicd->callback = callback;
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1096
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1097 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#items");
26595
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
1098 if (node)
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
1099 xmlnode_set_attrib(xmlnode_get_child(iq->node, "query"), "node", node);
f306ea83cb90 Add a node parameter to jabber_disco_items_do and use it in the new disco-listing code.
Paul Aurich <darkrain42@pidgin.im>
parents: 26594
diff changeset
1100
26594
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1101 xmlnode_set_attrib(iq->node, "to", who);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1102
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1103 jabber_iq_set_callback(iq, jabber_disco_items_cb, jdicd);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1104 jabber_iq_send(iq);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1105 }
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1106
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1107 void jabber_disco_item_free(JabberDiscoItem *item)
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1108 {
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1109 g_free((char *)item->jid);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1110 g_free((char *)item->node);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1111 g_free((char *)item->name);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1112 g_free(item);
73f09a0501f4 jabber_disco_items_do(), which functions like jabber_disco_info_do.
Paul Aurich <darkrain42@pidgin.im>
parents: 26593
diff changeset
1113 }

mercurial