Sat, 06 Sep 2008 07:49:05 +0000
Implements file transfers using in-band bytestreams for XMPP
using XEP-0047
Refs #6183
| 8312 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 8312 | 3 | * |
| 4 | * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> | |
| 5 | * | |
| 6 | * This program is free software; you can redistribute it and/or modify | |
| 7 | * it under the terms of the GNU General Public License as published by | |
| 8 | * the Free Software Foundation; either version 2 of the License, or | |
| 9 | * (at your option) any later version. | |
| 10 | * | |
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
|
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 | 19 | * |
| 20 | */ | |
| 21 | ||
| 22 | #include "internal.h" | |
| 23 | #include "prefs.h" | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
24 | #include "debug.h" |
| 8312 | 25 | |
| 26 | #include "buddy.h" | |
| 15225 | 27 | #include "google.h" |
| 8312 | 28 | #include "iq.h" |
| 29 | #include "disco.h" | |
| 13385 | 30 | #include "jabber.h" |
|
15344
34b7f4e55861
[gaim-migrate @ 18072]
Evan Schoenberg <evands@pidgin.im>
parents:
15323
diff
changeset
|
31 | #include "presence.h" |
| 15265 | 32 | #include "roster.h" |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17423
diff
changeset
|
33 | #include "pep.h" |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
34 | #include "adhoccommands.h" |
|
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
35 | |
| 8312 | 36 | |
| 37 | struct _jabber_disco_info_cb_data { | |
| 38 | gpointer data; | |
| 39 | JabberDiscoInfoCallback *callback; | |
| 40 | }; | |
| 41 | ||
|
17783
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
42 | #define SUPPORT_FEATURE(x) { \ |
| 8312 | 43 | feature = xmlnode_new_child(query, "feature"); \ |
|
17783
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
44 | xmlnode_set_attrib(feature, "var", x); \ |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
45 | } |
| 8312 | 46 | |
|
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
|
47 | static void |
|
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
|
48 | jabber_disco_bytestream_server_cb(JabberStream *js, xmlnode *packet, gpointer 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
|
49 | 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
|
50 | const char *from = xmlnode_get_attrib(packet, "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
|
51 | 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
|
52 | "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
|
53 | |
|
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
|
54 | 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
|
55 | 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
|
56 | 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
|
57 | 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
|
58 | 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
|
59 | |
|
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
|
60 | |
|
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
|
61 | 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
|
62 | 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
|
63 | 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
|
64 | |
|
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 | 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
|
66 | 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
|
67 | 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
|
68 | 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
|
69 | } |
|
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 | } |
|
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 | |
|
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 | 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
|
73 | "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
|
74 | 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
|
75 | 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
|
76 | |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
77 | /* 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
|
78 | 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
|
79 | 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
|
80 | 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
|
81 | 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
|
82 | 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
|
83 | 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
|
84 | } |
|
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
|
85 | } |
|
a16385b34219
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents:
19897
diff
changeset
|
86 | |
| 8312 | 87 | |
| 88 | void jabber_disco_info_parse(JabberStream *js, xmlnode *packet) { | |
| 89 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 90 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 91 | ||
| 92 | if(!from || !type) | |
| 93 | return; | |
| 94 | ||
| 95 | if(!strcmp(type, "get")) { | |
| 96 | xmlnode *query, *identity, *feature; | |
| 13385 | 97 | JabberIq *iq; |
| 98 | ||
| 99 | xmlnode *in_query; | |
| 100 | const char *node = NULL; | |
| 101 | ||
| 102 | if((in_query = xmlnode_get_child(packet, "query"))) { | |
| 103 | node = xmlnode_get_attrib(in_query, "node"); | |
| 104 | } | |
| 105 | ||
| 106 | ||
| 107 | iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, | |
| 8312 | 108 | "http://jabber.org/protocol/disco#info"); |
| 109 | ||
| 110 | jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); | |
| 111 | ||
| 112 | xmlnode_set_attrib(iq->node, "to", from); | |
| 113 | query = xmlnode_get_child(iq->node, "query"); | |
| 114 | ||
| 13385 | 115 | if(node) |
| 116 | xmlnode_set_attrib(query, "node", node); | |
| 117 | ||
| 118 | if(!node || !strcmp(node, CAPS0115_NODE "#" VERSION)) { | |
| 119 | identity = xmlnode_new_child(query, "identity"); | |
| 120 | xmlnode_set_attrib(identity, "category", "client"); | |
| 121 | xmlnode_set_attrib(identity, "type", "pc"); /* XXX: bot, console, | |
| 122 | * handheld, pc, phone, | |
| 123 | * web */ | |
| 13704 | 124 | xmlnode_set_attrib(identity, "name", PACKAGE); |
| 8312 | 125 | |
| 13385 | 126 | SUPPORT_FEATURE("jabber:iq:last") |
| 127 | SUPPORT_FEATURE("jabber:iq:oob") | |
| 128 | SUPPORT_FEATURE("jabber:iq:time") | |
|
18317
6c814e134e56
support replying to XEP-0202 queries
Nathan Walp <nwalp@pidgin.im>
parents:
18235
diff
changeset
|
129 | SUPPORT_FEATURE("xmpp:urn:time") |
| 13385 | 130 | SUPPORT_FEATURE("jabber:iq:version") |
| 131 | SUPPORT_FEATURE("jabber:x:conference") | |
| 132 | SUPPORT_FEATURE("http://jabber.org/protocol/bytestreams") | |
| 133 | SUPPORT_FEATURE("http://jabber.org/protocol/disco#info") | |
| 134 | SUPPORT_FEATURE("http://jabber.org/protocol/disco#items") | |
|
24372
830701cec96f
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents:
23912
diff
changeset
|
135 | SUPPORT_FEATURE("http://jabber.org/protocol/ibb"); |
| 13385 | 136 | SUPPORT_FEATURE("http://jabber.org/protocol/muc") |
| 137 | SUPPORT_FEATURE("http://jabber.org/protocol/muc#user") | |
| 138 | SUPPORT_FEATURE("http://jabber.org/protocol/si") | |
| 139 | SUPPORT_FEATURE("http://jabber.org/protocol/si/profile/file-transfer") | |
| 140 | SUPPORT_FEATURE("http://jabber.org/protocol/xhtml-im") | |
|
18181
736c6abf62f4
respond to XEP-0199 queries (XMPP ping)
Nathan Walp <nwalp@pidgin.im>
parents:
17423
diff
changeset
|
141 | SUPPORT_FEATURE("urn:xmpp:ping") |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
142 | SUPPORT_FEATURE("http://www.xmpp.org/extensions/xep-0199.html#ns") |
|
19894
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
143 | |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
144 | if(!node) { /* non-caps disco#info, add all enabled extensions */ |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
145 | GList *features; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
146 | for(features = jabber_features; features; features = features->next) { |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
147 | JabberFeature *feat = (JabberFeature*)features->data; |
|
17783
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
148 | if(feat->is_enabled == NULL || feat->is_enabled(js, feat->shortname, feat->namespace) == TRUE) |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
149 | SUPPORT_FEATURE(feat->namespace); |
|
19894
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
150 | } |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
151 | } |
| 13385 | 152 | } else { |
|
19894
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
153 | const char *ext = NULL; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
154 | unsigned pos; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
155 | unsigned nodelen = strlen(node); |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
156 | unsigned capslen = strlen(CAPS0115_NODE); |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
157 | /* do a basic plausability check */ |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
158 | if(nodelen > capslen+1) { |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
159 | /* verify that the string is CAPS0115#<ext> and get the pointer to the ext part */ |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
160 | for(pos = 0; pos < capslen+1; ++pos) { |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
161 | if(pos == capslen) { |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
162 | if(node[pos] == '#') |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
163 | ext = &node[pos+1]; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
164 | else |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
165 | break; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
166 | } else if(node[pos] != CAPS0115_NODE[pos]) |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
167 | break; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
168 | } |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
169 | |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
170 | if(ext != NULL) { |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
171 | /* look for that ext */ |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
172 | GList *features; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
173 | for(features = jabber_features; features; features = features->next) { |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
174 | JabberFeature *feat = (JabberFeature*)features->data; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
175 | if(!strcmp(feat->shortname, ext)) { |
|
17783
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
176 | SUPPORT_FEATURE(feat->namespace); |
|
2687df1ca202
PEP publishing features are now only announced in disco#info when PEP is supported by the server.
Andreas Monitzer <am@adiumx.com>
parents:
17773
diff
changeset
|
177 | break; |
|
19894
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
178 | } |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
179 | } |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
180 | if(features == NULL) |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
181 | ext = NULL; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
182 | } |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
183 | } |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
184 | |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
185 | if(ext == NULL) { |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
186 | xmlnode *error, *inf; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
187 | |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
188 | /* XXX: gross hack, implement jabber_iq_set_type or something */ |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
189 | xmlnode_set_attrib(iq->node, "type", "error"); |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
190 | iq->type = JABBER_IQ_ERROR; |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
191 | |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
192 | error = xmlnode_new_child(query, "error"); |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
193 | xmlnode_set_attrib(error, "code", "404"); |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
194 | xmlnode_set_attrib(error, "type", "cancel"); |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
195 | inf = xmlnode_new_child(error, "item-not-found"); |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
196 | xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas"); |
|
b273d0db2bdd
Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents:
18719
diff
changeset
|
197 | } |
| 13385 | 198 | } |
| 8312 | 199 | |
| 200 | jabber_iq_send(iq); | |
| 201 | } else if(!strcmp(type, "result")) { | |
| 202 | xmlnode *query = xmlnode_get_child(packet, "query"); | |
| 203 | xmlnode *child; | |
| 204 | JabberID *jid; | |
| 205 | JabberBuddy *jb; | |
| 206 | JabberBuddyResource *jbr = NULL; | |
| 207 | JabberCapabilities capabilities = JABBER_CAP_NONE; | |
| 208 | struct _jabber_disco_info_cb_data *jdicd; | |
| 209 | ||
| 210 | if((jid = jabber_id_new(from))) { | |
| 211 | if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE))) | |
| 212 | jbr = jabber_buddy_find_resource(jb, jid->resource); | |
| 213 | jabber_id_free(jid); | |
| 214 | } | |
| 215 | ||
| 216 | if(jbr) | |
| 217 | capabilities = jbr->capabilities; | |
| 218 | ||
| 219 | for(child = query->child; child; child = child->next) { | |
| 220 | if(child->type != XMLNODE_TYPE_TAG) | |
| 221 | continue; | |
| 222 | ||
| 223 | if(!strcmp(child->name, "identity")) { | |
| 224 | const char *category = xmlnode_get_attrib(child, "category"); | |
| 225 | const char *type = xmlnode_get_attrib(child, "type"); | |
| 226 | if(!category || !type) | |
| 227 | continue; | |
| 228 | ||
| 11675 | 229 | if(!strcmp(category, "conference") && !strcmp(type, "text")) { |
| 230 | /* we found a groupchat or MUC server, add it to the list */ | |
| 231 | /* 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
|
232 | js->chat_servers = g_list_prepend(js->chat_servers, g_strdup(from)); |
| 11675 | 233 | } else if(!strcmp(category, "directory") && !strcmp(type, "user")) { |
| 234 | /* 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
|
235 | 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
|
236 | } 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
|
237 | /* 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
|
238 | 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
|
239 | 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
|
240 | |
|
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
|
241 | 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
|
242 | |
|
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
|
243 | 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
|
244 | 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
|
245 | 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
|
246 | |
|
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
|
247 | 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
|
248 | "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
|
249 | 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
|
250 | 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
|
251 | jabber_iq_send(iq); |
| 11675 | 252 | } |
| 8312 | 253 | |
| 254 | } else if(!strcmp(child->name, "feature")) { | |
| 255 | const char *var = xmlnode_get_attrib(child, "var"); | |
| 256 | if(!var) | |
| 257 | continue; | |
| 258 | ||
| 259 | if(!strcmp(var, "http://jabber.org/protocol/si")) | |
| 260 | capabilities |= JABBER_CAP_SI; | |
| 261 | else if(!strcmp(var, "http://jabber.org/protocol/si/profile/file-transfer")) | |
| 262 | capabilities |= JABBER_CAP_SI_FILE_XFER; | |
| 263 | else if(!strcmp(var, "http://jabber.org/protocol/bytestreams")) | |
| 264 | capabilities |= JABBER_CAP_BYTESTREAMS; | |
| 11675 | 265 | else if(!strcmp(var, "jabber:iq:search")) |
| 266 | capabilities |= JABBER_CAP_IQ_SEARCH; | |
| 267 | else if(!strcmp(var, "jabber:iq:register")) | |
| 268 | capabilities |= JABBER_CAP_IQ_REGISTER; | |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
269 | else if(!strcmp(var, "http://www.xmpp.org/extensions/xep-0199.html#ns")) |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
17768
diff
changeset
|
270 | capabilities |= JABBER_CAP_PING; |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17783
diff
changeset
|
271 | 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
|
272 | 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
|
273 | } |
|
24372
830701cec96f
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents:
23912
diff
changeset
|
274 | 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
|
275 | 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
|
276 | capabilities |= JABBER_CAP_IBB; |
|
830701cec96f
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents:
23912
diff
changeset
|
277 | } |
| 8312 | 278 | } |
| 279 | } | |
| 280 | ||
| 281 | capabilities |= JABBER_CAP_RETRIEVED; | |
| 282 | ||
| 283 | if(jbr) | |
| 284 | jbr->capabilities = capabilities; | |
| 285 | ||
| 286 | if((jdicd = g_hash_table_lookup(js->disco_callbacks, from))) { | |
| 287 | jdicd->callback(js, from, capabilities, jdicd->data); | |
| 288 | g_hash_table_remove(js->disco_callbacks, from); | |
| 289 | } | |
| 290 | } else if(!strcmp(type, "error")) { | |
| 291 | JabberID *jid; | |
| 292 | JabberBuddy *jb; | |
| 293 | JabberBuddyResource *jbr = NULL; | |
| 294 | JabberCapabilities capabilities = JABBER_CAP_NONE; | |
| 295 | struct _jabber_disco_info_cb_data *jdicd; | |
| 296 | ||
| 297 | if(!(jdicd = g_hash_table_lookup(js->disco_callbacks, from))) | |
| 298 | return; | |
| 299 | ||
| 300 | if((jid = jabber_id_new(from))) { | |
| 301 | if(jid->resource && (jb = jabber_buddy_find(js, from, TRUE))) | |
| 302 | jbr = jabber_buddy_find_resource(jb, jid->resource); | |
| 303 | jabber_id_free(jid); | |
| 304 | } | |
| 305 | ||
| 306 | if(jbr) | |
| 307 | capabilities = jbr->capabilities; | |
| 308 | ||
| 309 | jdicd->callback(js, from, capabilities, jdicd->data); | |
| 310 | g_hash_table_remove(js->disco_callbacks, from); | |
| 311 | } | |
| 312 | } | |
| 313 | ||
| 314 | void jabber_disco_items_parse(JabberStream *js, xmlnode *packet) { | |
| 315 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 316 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 317 | ||
| 14356 | 318 | if(type && !strcmp(type, "get")) { |
| 8312 | 319 | JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, |
| 320 | "http://jabber.org/protocol/disco#items"); | |
|
17826
8f31a68b1d70
Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents:
17817
diff
changeset
|
321 | |
|
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
|
322 | /* preserve node */ |
|
8f31a68b1d70
Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents:
17817
diff
changeset
|
323 | xmlnode *iq_query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#items"); |
|
8f31a68b1d70
Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents:
17817
diff
changeset
|
324 | if(iq_query) { |
|
8f31a68b1d70
Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents:
17817
diff
changeset
|
325 | xmlnode *query = xmlnode_get_child_with_namespace(packet,"query","http://jabber.org/protocol/disco#items"); |
|
8f31a68b1d70
Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents:
17817
diff
changeset
|
326 | if(query) { |
|
8f31a68b1d70
Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents:
17817
diff
changeset
|
327 | const char *node = xmlnode_get_attrib(query,"node"); |
|
8f31a68b1d70
Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents:
17817
diff
changeset
|
328 | if(node) |
|
8f31a68b1d70
Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents:
17817
diff
changeset
|
329 | xmlnode_set_attrib(iq_query,"node",node); |
|
8f31a68b1d70
Now preserving the node on the (empty) disco#items replies. This is required for apps to add items on the correct nodes using signals.
Andreas Monitzer <am@adiumx.com>
parents:
17817
diff
changeset
|
330 | } |
|
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
|
331 | } |
| 8312 | 332 | |
| 333 | jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); | |
| 334 | ||
| 335 | xmlnode_set_attrib(iq->node, "to", from); | |
| 336 | jabber_iq_send(iq); | |
| 337 | } | |
| 338 | } | |
| 339 | ||
| 340 | static void | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
341 | jabber_disco_finish_server_info_result_cb(JabberStream *js) |
| 15197 | 342 | { |
|
23912
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
343 | 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
|
344 | |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18225
diff
changeset
|
345 | 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
|
346 | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
347 | if (!(js->server_caps & JABBER_CAP_GOOGLE_ROSTER)) { |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
348 | /* 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
|
349 | jabber_roster_request(js); |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
350 | } |
| 17421 | 351 | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
352 | /* Send initial presence; this will trigger receipt of presence for contacts on the roster */ |
|
18719
7a0465381cea
Fixed errors created by merge conflict resolve mistakes.
Andreas Monitzer <am@adiumx.com>
parents:
18718
diff
changeset
|
353 | jabber_presence_send(js->gc->account, NULL); |
|
23912
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
354 | |
|
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
|
355 | 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
|
356 | /* 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
|
357 | 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
|
358 | } |
|
23912
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
359 | |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
360 | /* 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
|
361 | 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
|
362 | 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
|
363 | JabberIq *iq; |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
364 | JabberBytestreamsStreamhost *sh; |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
365 | int i; |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
366 | char *tmp; |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
367 | 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
|
368 | |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
369 | 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
|
370 | 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
|
371 | 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
|
372 | continue; |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
373 | |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
374 | /* 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
|
375 | 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
|
376 | *tmp = '\0'; |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
377 | |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
378 | 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
|
379 | 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
|
380 | 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
|
381 | |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
382 | 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
|
383 | "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
|
384 | 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
|
385 | 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
|
386 | 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
|
387 | } |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
388 | |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
389 | 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
|
390 | } |
|
8169bfe82e47
Use Service Discovery to look up information about the manually specified FT
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
391 | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
392 | } |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
393 | |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
394 | static void |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
395 | jabber_disco_server_info_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
396 | { |
| 17421 | 397 | xmlnode *query, *child; |
| 15197 | 398 | const char *from = xmlnode_get_attrib(packet, "from"); |
| 399 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 400 | ||
|
15358
c8179e0a5483
[gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents:
15355
diff
changeset
|
401 | if((!from || !type) || |
|
c8179e0a5483
[gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents:
15355
diff
changeset
|
402 | (strcmp(from, js->user->domain))) { |
|
c8179e0a5483
[gaim-migrate @ 18087]
Evan Schoenberg <evands@pidgin.im>
parents:
15355
diff
changeset
|
403 | jabber_disco_finish_server_info_result_cb(js); |
| 15197 | 404 | return; |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
405 | } |
| 15197 | 406 | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
407 | if(strcmp(type, "result")) { |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
408 | /* 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
|
409 | jabber_disco_finish_server_info_result_cb(js); |
| 15197 | 410 | return; |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
411 | } |
| 15197 | 412 | |
| 413 | query = xmlnode_get_child(packet, "query"); | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
414 | |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
415 | if (!query) { |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
416 | jabber_disco_finish_server_info_result_cb(js); |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
417 | return; |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
418 | } |
|
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
419 | |
| 17421 | 420 | for (child = xmlnode_get_child(query, "identity"); child; |
| 15197 | 421 | child = xmlnode_get_next_twin(child)) { |
| 422 | const char *category, *type, *name; | |
| 423 | category = xmlnode_get_attrib(child, "category"); | |
|
17768
7be011945a1b
added preliminary frame for pep-support
Andreas Monitzer <am@adiumx.com>
parents:
17423
diff
changeset
|
424 | 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
|
425 | 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
|
426 | js->pep = TRUE; |
| 15197 | 427 | if (!category || strcmp(category, "server")) |
| 428 | continue; | |
| 429 | if (!type || strcmp(type, "im")) | |
| 430 | continue; | |
| 17421 | 431 | |
| 15197 | 432 | name = xmlnode_get_attrib(child, "name"); |
| 433 | if (!name) | |
| 434 | continue; | |
| 435 | ||
| 436 | g_free(js->server_name); | |
| 437 | 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
|
438 | 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
|
439 | 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
|
440 | js->googletalk = TRUE; |
|
15587
cbedd543bfae
Google Talk uses structured text formatting where *this* is bold
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
441 | } |
| 15197 | 442 | } |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
443 | |
| 17421 | 444 | for (child = xmlnode_get_child(query, "feature"); child; |
| 15225 | 445 | child = xmlnode_get_next_twin(child)) { |
| 446 | const char *var; | |
| 447 | var = xmlnode_get_attrib(child, "var"); | |
| 448 | if (!var) | |
| 449 | continue; | |
| 450 | ||
| 451 | if (!strcmp("google:mail:notify", var)) { | |
| 452 | js->server_caps |= JABBER_CAP_GMAIL_NOTIFY; | |
| 453 | jabber_gmail_init(js); | |
| 15265 | 454 | } else if (!strcmp("google:roster", var)) { |
| 455 | js->server_caps |= JABBER_CAP_GOOGLE_ROSTER; | |
| 456 | 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
|
457 | } 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
|
458 | js->server_caps |= JABBER_CAP_ADHOC; |
| 15225 | 459 | } |
| 460 | } | |
| 15265 | 461 | |
|
15355
1ce281d16071
[gaim-migrate @ 18084]
Evan Schoenberg <evands@pidgin.im>
parents:
15344
diff
changeset
|
462 | jabber_disco_finish_server_info_result_cb(js); |
| 15197 | 463 | } |
| 464 | ||
| 465 | static void | |
| 466 | jabber_disco_server_items_result_cb(JabberStream *js, xmlnode *packet, gpointer data) | |
| 8312 | 467 | { |
| 468 | xmlnode *query, *child; | |
| 469 | const char *from = xmlnode_get_attrib(packet, "from"); | |
| 470 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 471 | ||
| 472 | if(!from || !type) | |
| 473 | return; | |
| 474 | ||
| 475 | if(strcmp(from, js->user->domain)) | |
| 476 | return; | |
| 477 | ||
| 478 | if(strcmp(type, "result")) | |
| 479 | return; | |
| 480 | ||
| 481 | while(js->chat_servers) { | |
| 482 | g_free(js->chat_servers->data); | |
| 483 | js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers); | |
| 484 | } | |
| 485 | ||
| 486 | query = xmlnode_get_child(packet, "query"); | |
| 487 | ||
| 488 | for(child = xmlnode_get_child(query, "item"); child; | |
| 489 | child = xmlnode_get_next_twin(child)) { | |
| 490 | 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
|
491 | const char *jid, *node; |
| 8312 | 492 | |
| 493 | if(!(jid = xmlnode_get_attrib(child, "jid"))) | |
| 494 | continue; | |
| 495 | ||
|
17423
1f3a88fda48e
skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents:
17421
diff
changeset
|
496 | /* 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
|
497 | * 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
|
498 | 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
|
499 | continue; |
|
1f3a88fda48e
skip some unneeded queries that we don't particularly need or want
Nathan Walp <nwalp@pidgin.im>
parents:
17421
diff
changeset
|
500 | |
| 8312 | 501 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info"); |
| 502 | xmlnode_set_attrib(iq->node, "to", jid); | |
| 503 | jabber_iq_send(iq); | |
| 504 | } | |
| 505 | } | |
| 506 | ||
| 507 | void jabber_disco_items_server(JabberStream *js) | |
| 508 | { | |
| 509 | JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, | |
| 510 | "http://jabber.org/protocol/disco#items"); | |
| 511 | ||
| 512 | xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
| 513 | ||
| 15197 | 514 | jabber_iq_set_callback(iq, jabber_disco_server_items_result_cb, NULL); |
| 515 | jabber_iq_send(iq); | |
| 516 | ||
|
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
|
517 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info"); |
| 15197 | 518 | xmlnode_set_attrib(iq->node, "to", js->user->domain); |
| 519 | jabber_iq_set_callback(iq, jabber_disco_server_info_result_cb, NULL); | |
| 8312 | 520 | jabber_iq_send(iq); |
| 521 | } | |
| 522 | ||
| 523 | void jabber_disco_info_do(JabberStream *js, const char *who, JabberDiscoInfoCallback *callback, gpointer data) | |
| 524 | { | |
| 525 | JabberID *jid; | |
| 526 | JabberBuddy *jb; | |
| 527 | JabberBuddyResource *jbr = NULL; | |
| 528 | struct _jabber_disco_info_cb_data *jdicd; | |
| 529 | JabberIq *iq; | |
| 530 | ||
| 531 | if((jid = jabber_id_new(who))) { | |
| 532 | if(jid->resource && (jb = jabber_buddy_find(js, who, TRUE))) | |
| 533 | jbr = jabber_buddy_find_resource(jb, jid->resource); | |
| 534 | jabber_id_free(jid); | |
| 535 | } | |
| 536 | ||
| 537 | if(jbr && jbr->capabilities & JABBER_CAP_RETRIEVED) { | |
| 538 | callback(js, who, jbr->capabilities, data); | |
| 539 | return; | |
| 540 | } | |
| 541 | ||
| 542 | jdicd = g_new0(struct _jabber_disco_info_cb_data, 1); | |
| 543 | jdicd->data = data; | |
| 544 | jdicd->callback = callback; | |
| 545 | ||
| 546 | g_hash_table_insert(js->disco_callbacks, g_strdup(who), jdicd); | |
| 547 | ||
| 548 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#info"); | |
| 549 | xmlnode_set_attrib(iq->node, "to", who); | |
| 550 | ||
| 551 | jabber_iq_send(iq); | |
| 552 | } | |
| 553 | ||
| 554 |