Sat, 22 Nov 2008 18:26:45 +0000
Sprinkle around more support for xml:lang on JabberIdentities
Change the IPC has_feature function to take a PurpleAccount and look up
the caps via the jbr
| 7395 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7395 | 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 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
14 | * |
| 7395 | 15 | * GNU General Public License for more details. |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * 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:
19853
diff
changeset
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7395 | 20 | * |
| 21 | */ | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8838
diff
changeset
|
22 | |
|
18273
e61c53184c52
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17643
diff
changeset
|
23 | #include "internal.h" |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8838
diff
changeset
|
24 | |
|
18273
e61c53184c52
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17643
diff
changeset
|
25 | #include "blist.h" |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10112
diff
changeset
|
26 | #include "cipher.h" |
| 7395 | 27 | #include "debug.h" |
| 28 | #include "ft.h" | |
|
17424
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
29 | #include "request.h" |
| 8231 | 30 | #include "network.h" |
| 7395 | 31 | #include "notify.h" |
| 32 | ||
| 33 | #include "buddy.h" | |
| 8312 | 34 | #include "disco.h" |
| 7395 | 35 | #include "jabber.h" |
| 36 | #include "iq.h" | |
| 37 | #include "si.h" | |
| 38 | ||
|
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:
21646
diff
changeset
|
39 | #define STREAMHOST_CONNECT_TIMEOUT 15 |
| 8262 | 40 | |
| 41 | typedef struct _JabberSIXfer { | |
| 42 | JabberStream *js; | |
| 43 | ||
| 15884 | 44 | PurpleProxyConnectData *connect_data; |
| 45 | PurpleNetworkListenData *listen_data; | |
|
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:
21646
diff
changeset
|
46 | guint connect_timeout; |
|
14175
2bc5a80c5071
[gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
47 | |
| 10940 | 48 | gboolean accepted; |
| 49 | ||
| 8262 | 50 | char *stream_id; |
| 51 | char *iq_id; | |
| 52 | ||
| 53 | enum { | |
| 54 | STREAM_METHOD_UNKNOWN = 0, | |
| 55 | STREAM_METHOD_BYTESTREAMS = 2 << 1, | |
| 56 | STREAM_METHOD_IBB = 2 << 2, | |
| 57 | STREAM_METHOD_UNSUPPORTED = 2 << 31 | |
| 58 | } stream_method; | |
| 59 | ||
| 60 | GList *streamhosts; | |
| 15884 | 61 | PurpleProxyInfo *gpi; |
| 8316 | 62 | |
| 63 | char *rxqueue; | |
| 64 | size_t rxlen; | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
65 | gsize rxmaxlen; |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
66 | int local_streamhost_fd; |
| 8262 | 67 | } JabberSIXfer; |
| 68 | ||
| 15884 | 69 | static PurpleXfer* |
| 8262 | 70 | jabber_si_xfer_find(JabberStream *js, const char *sid, const char *from) |
| 7395 | 71 | { |
| 72 | GList *xfers; | |
| 73 | ||
| 8262 | 74 | if(!sid || !from) |
| 7395 | 75 | return NULL; |
| 76 | ||
| 77 | for(xfers = js->file_transfers; xfers; xfers = xfers->next) { | |
| 15884 | 78 | PurpleXfer *xfer = xfers->data; |
| 7395 | 79 | JabberSIXfer *jsx = xfer->data; |
| 8316 | 80 | if(jsx->stream_id && xfer->who && |
| 81 | !strcmp(jsx->stream_id, sid) && !strcmp(xfer->who, from)) | |
| 7395 | 82 | return xfer; |
| 83 | } | |
| 84 | ||
| 85 | return NULL; | |
| 86 | } | |
| 87 | ||
|
23075
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
88 | static void |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
89 | jabber_si_free_streamhost(gpointer data, gpointer user_data) |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
90 | { |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
91 | JabberBytestreamsStreamhost *sh = data; |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
92 | |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
93 | if(!data) |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
94 | return; |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
95 | |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
96 | g_free(sh->jid); |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
97 | g_free(sh->host); |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
98 | g_free(sh->zeroconf); |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
99 | g_free(sh); |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
100 | } |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
101 | |
|
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
102 | |
| 8262 | 103 | |
| 15884 | 104 | static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer); |
| 8262 | 105 | |
|
14175
2bc5a80c5071
[gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
106 | static void |
|
2bc5a80c5071
[gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
107 | jabber_si_bytestreams_connect_cb(gpointer data, gint source, const gchar *error_message) |
| 8262 | 108 | { |
| 15884 | 109 | PurpleXfer *xfer = data; |
| 7395 | 110 | JabberSIXfer *jsx = xfer->data; |
| 8262 | 111 | JabberIq *iq; |
| 112 | xmlnode *query, *su; | |
|
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:
21646
diff
changeset
|
113 | JabberBytestreamsStreamhost *streamhost = jsx->streamhosts->data; |
| 7395 | 114 | |
| 15884 | 115 | purple_proxy_info_destroy(jsx->gpi); |
|
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:
21646
diff
changeset
|
116 | jsx->gpi = NULL; |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
117 | jsx->connect_data = NULL; |
| 8262 | 118 | |
|
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:
21646
diff
changeset
|
119 | if (jsx->connect_timeout > 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:
21646
diff
changeset
|
120 | purple_timeout_remove(jsx->connect_timeout); |
|
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:
21646
diff
changeset
|
121 | jsx->connect_timeout = 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:
21646
diff
changeset
|
122 | |
| 8262 | 123 | if(source < 0) { |
|
17643
870d08f93965
Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents:
17424
diff
changeset
|
124 | purple_debug_warning("jabber", |
|
870d08f93965
Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents:
17424
diff
changeset
|
125 | "si connection failed, jid was %s, host was %s, error was %s\n", |
|
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:
21646
diff
changeset
|
126 | streamhost->jid, streamhost->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:
21646
diff
changeset
|
127 | error_message ? error_message : "(null)"); |
| 8262 | 128 | jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost); |
|
23075
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
129 | jabber_si_free_streamhost(streamhost, NULL); |
| 8262 | 130 | jabber_si_bytestreams_attempt_connect(xfer); |
| 131 | return; | |
| 132 | } | |
| 133 | ||
|
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:
21646
diff
changeset
|
134 | /* unknown file transfer type is assumed to be RECEIVE */ |
|
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:
21646
diff
changeset
|
135 | if(xfer->type == PURPLE_XFER_SEND) |
|
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:
21646
diff
changeset
|
136 | { |
|
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:
21646
diff
changeset
|
137 | xmlnode *activate; |
|
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:
21646
diff
changeset
|
138 | iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, "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:
21646
diff
changeset
|
139 | xmlnode_set_attrib(iq->node, "to", streamhost->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:
21646
diff
changeset
|
140 | query = xmlnode_get_child(iq->node, "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:
21646
diff
changeset
|
141 | xmlnode_set_attrib(query, "sid", jsx->stream_id); |
|
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:
21646
diff
changeset
|
142 | activate = xmlnode_new_child(query, "activate"); |
|
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:
21646
diff
changeset
|
143 | xmlnode_insert_data(activate, xfer->who, -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:
21646
diff
changeset
|
144 | |
|
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:
21646
diff
changeset
|
145 | /* TODO: We need to wait for an activation result before starting */ |
|
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:
21646
diff
changeset
|
146 | } |
|
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:
21646
diff
changeset
|
147 | else |
|
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:
21646
diff
changeset
|
148 | { |
|
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:
21646
diff
changeset
|
149 | iq = jabber_iq_new_query(jsx->js, JABBER_IQ_RESULT, "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:
21646
diff
changeset
|
150 | xmlnode_set_attrib(iq->node, "to", xfer->who); |
|
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:
21646
diff
changeset
|
151 | jabber_iq_set_id(iq, jsx->iq_id); |
|
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:
21646
diff
changeset
|
152 | query = xmlnode_get_child(iq->node, "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:
21646
diff
changeset
|
153 | su = xmlnode_new_child(query, "streamhost-used"); |
|
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:
21646
diff
changeset
|
154 | xmlnode_set_attrib(su, "jid", streamhost->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:
21646
diff
changeset
|
155 | } |
| 8262 | 156 | |
| 157 | jabber_iq_send(iq); | |
| 158 | ||
| 15884 | 159 | purple_xfer_start(xfer, source, NULL, -1); |
| 8262 | 160 | } |
| 161 | ||
|
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:
21646
diff
changeset
|
162 | static gboolean |
|
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:
21646
diff
changeset
|
163 | connect_timeout_cb(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:
21646
diff
changeset
|
164 | { |
|
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:
21646
diff
changeset
|
165 | PurpleXfer *xfer = 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:
21646
diff
changeset
|
166 | JabberSIXfer *jsx = xfer->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:
21646
diff
changeset
|
167 | |
|
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:
21646
diff
changeset
|
168 | purple_debug_info("jabber", "Streamhost connection timeout of %d seconds exceeded.\n", STREAMHOST_CONNECT_TIMEOUT); |
|
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:
21646
diff
changeset
|
169 | |
|
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:
21646
diff
changeset
|
170 | jsx->connect_timeout = 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:
21646
diff
changeset
|
171 | |
|
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:
21646
diff
changeset
|
172 | if (jsx->connect_data != 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:
21646
diff
changeset
|
173 | purple_proxy_connect_cancel(jsx->connect_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:
21646
diff
changeset
|
174 | jsx->connect_data = 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:
21646
diff
changeset
|
175 | |
|
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:
21646
diff
changeset
|
176 | /* Trigger the connect error manually */ |
|
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:
21646
diff
changeset
|
177 | jabber_si_bytestreams_connect_cb(xfer, -1, "Timeout Exceeded."); |
|
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:
21646
diff
changeset
|
178 | |
|
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:
21646
diff
changeset
|
179 | return FALSE; |
|
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:
21646
diff
changeset
|
180 | } |
|
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:
21646
diff
changeset
|
181 | |
| 15884 | 182 | static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer) |
| 8262 | 183 | { |
| 184 | JabberSIXfer *jsx = xfer->data; | |
|
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:
21646
diff
changeset
|
185 | JabberBytestreamsStreamhost *streamhost; |
| 8262 | 186 | char *dstaddr, *p; |
| 187 | int i; | |
| 188 | unsigned char hashval[20]; | |
| 14561 | 189 | JabberID *dstjid; |
| 8262 | 190 | |
| 191 | if(!jsx->streamhosts) { | |
| 192 | JabberIq *iq = jabber_iq_new(jsx->js, JABBER_IQ_ERROR); | |
| 14740 | 193 | xmlnode *error, *inf; |
| 8262 | 194 | |
| 195 | if(jsx->iq_id) | |
| 196 | jabber_iq_set_id(iq, jsx->iq_id); | |
| 197 | ||
| 198 | xmlnode_set_attrib(iq->node, "to", xfer->who); | |
| 199 | error = xmlnode_new_child(iq->node, "error"); | |
| 200 | xmlnode_set_attrib(error, "code", "404"); | |
| 201 | xmlnode_set_attrib(error, "type", "cancel"); | |
| 14740 | 202 | inf = xmlnode_new_child(error, "item-not-found"); |
| 203 | xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas"); | |
| 8262 | 204 | |
| 205 | jabber_iq_send(iq); | |
| 206 | ||
| 15884 | 207 | purple_xfer_cancel_local(xfer); |
| 8262 | 208 | |
| 209 | return; | |
| 210 | } | |
| 211 | ||
| 212 | streamhost = jsx->streamhosts->data; | |
| 7395 | 213 | |
|
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:
21646
diff
changeset
|
214 | jsx->connect_data = 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:
21646
diff
changeset
|
215 | if (jsx->gpi != 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:
21646
diff
changeset
|
216 | purple_proxy_info_destroy(jsx->gpi); |
|
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:
21646
diff
changeset
|
217 | jsx->gpi = 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:
21646
diff
changeset
|
218 | |
| 14561 | 219 | dstjid = jabber_id_new(xfer->who); |
| 8262 | 220 | |
|
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:
21646
diff
changeset
|
221 | /* TODO: Deal with 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:
21646
diff
changeset
|
222 | |
|
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:
21646
diff
changeset
|
223 | if(dstjid != NULL && streamhost->host && streamhost->port > 0) { |
| 15884 | 224 | jsx->gpi = purple_proxy_info_new(); |
| 225 | purple_proxy_info_set_type(jsx->gpi, PURPLE_PROXY_SOCKS5); | |
| 226 | purple_proxy_info_set_host(jsx->gpi, streamhost->host); | |
| 227 | purple_proxy_info_set_port(jsx->gpi, streamhost->port); | |
| 14561 | 228 | |
|
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:
21646
diff
changeset
|
229 | /* unknown file transfer type is assumed to be RECEIVE */ |
|
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:
21646
diff
changeset
|
230 | if(xfer->type == PURPLE_XFER_SEND) |
|
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:
21646
diff
changeset
|
231 | dstaddr = g_strdup_printf("%s%s@%s/%s%s@%s/%s", jsx->stream_id, jsx->js->user->node, jsx->js->user->domain, |
|
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:
21646
diff
changeset
|
232 | jsx->js->user->resource, dstjid->node, dstjid->domain, dstjid->resource); |
|
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:
21646
diff
changeset
|
233 | else |
|
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:
21646
diff
changeset
|
234 | dstaddr = g_strdup_printf("%s%s@%s/%s%s@%s/%s", jsx->stream_id, dstjid->node, dstjid->domain, dstjid->resource, |
|
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:
21646
diff
changeset
|
235 | jsx->js->user->node, jsx->js->user->domain, jsx->js->user->resource); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10112
diff
changeset
|
236 | |
| 15884 | 237 | purple_cipher_digest_region("sha1", (guchar *)dstaddr, strlen(dstaddr), |
| 14561 | 238 | sizeof(hashval), hashval, NULL); |
| 239 | g_free(dstaddr); | |
| 240 | dstaddr = g_malloc(41); | |
| 241 | p = dstaddr; | |
| 242 | for(i=0; i<20; i++, p+=2) | |
| 243 | snprintf(p, 3, "%02x", hashval[i]); | |
| 8262 | 244 | |
| 15884 | 245 | jsx->connect_data = purple_proxy_connect_socks5(NULL, jsx->gpi, |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14740
diff
changeset
|
246 | dstaddr, 0, |
| 14561 | 247 | jabber_si_bytestreams_connect_cb, xfer); |
| 248 | g_free(dstaddr); | |
| 249 | ||
|
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:
21646
diff
changeset
|
250 | /* When selecting a streamhost, timeout after STREAMHOST_CONNECT_TIMEOUT seconds, otherwise it takes forever */ |
|
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:
21646
diff
changeset
|
251 | if (xfer->type != PURPLE_XFER_SEND && jsx->connect_data != 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:
21646
diff
changeset
|
252 | jsx->connect_timeout = purple_timeout_add_seconds( |
|
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:
21646
diff
changeset
|
253 | STREAMHOST_CONNECT_TIMEOUT, connect_timeout_cb, xfer); |
|
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:
21646
diff
changeset
|
254 | |
| 14561 | 255 | jabber_id_free(dstjid); |
| 256 | } | |
|
14175
2bc5a80c5071
[gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
257 | |
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
258 | if (jsx->connect_data == NULL) |
|
14175
2bc5a80c5071
[gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
259 | { |
|
2bc5a80c5071
[gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
260 | jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost); |
|
23075
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
261 | jabber_si_free_streamhost(streamhost, NULL); |
|
14175
2bc5a80c5071
[gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
262 | jabber_si_bytestreams_attempt_connect(xfer); |
|
2bc5a80c5071
[gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
263 | } |
| 8262 | 264 | } |
| 265 | ||
| 266 | void jabber_bytestreams_parse(JabberStream *js, xmlnode *packet) | |
| 267 | { | |
| 15884 | 268 | PurpleXfer *xfer; |
| 8262 | 269 | JabberSIXfer *jsx; |
| 270 | xmlnode *query, *streamhost; | |
| 14356 | 271 | const char *sid, *from, *type; |
| 272 | ||
| 273 | if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "set")) | |
| 274 | return; | |
| 8262 | 275 | |
| 276 | if(!(from = xmlnode_get_attrib(packet, "from"))) | |
| 277 | return; | |
| 278 | ||
| 279 | if(!(query = xmlnode_get_child(packet, "query"))) | |
| 280 | return; | |
| 281 | ||
| 282 | if(!(sid = xmlnode_get_attrib(query, "sid"))) | |
| 283 | return; | |
| 284 | ||
| 285 | if(!(xfer = jabber_si_xfer_find(js, sid, from))) | |
| 286 | return; | |
| 287 | ||
| 288 | jsx = xfer->data; | |
| 10940 | 289 | |
| 290 | if(!jsx->accepted) | |
| 291 | return; | |
| 292 | ||
| 8262 | 293 | if(jsx->iq_id) |
| 294 | g_free(jsx->iq_id); | |
| 295 | jsx->iq_id = g_strdup(xmlnode_get_attrib(packet, "id")); | |
| 296 | ||
| 297 | for(streamhost = xmlnode_get_child(query, "streamhost"); streamhost; | |
| 298 | streamhost = xmlnode_get_next_twin(streamhost)) { | |
|
21688
a16385b34219
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents:
21646
diff
changeset
|
299 | const char *jid, *host = NULL, *port, *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:
21646
diff
changeset
|
300 | int portnum = 0; |
| 8262 | 301 | |
| 302 | if((jid = xmlnode_get_attrib(streamhost, "jid")) && | |
|
21688
a16385b34219
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents:
21646
diff
changeset
|
303 | ((zeroconf = xmlnode_get_attrib(streamhost, "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:
21646
diff
changeset
|
304 | ((host = xmlnode_get_attrib(streamhost, "host")) && |
| 8262 | 305 | (port = xmlnode_get_attrib(streamhost, "port")) && |
|
21688
a16385b34219
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents:
21646
diff
changeset
|
306 | (portnum = 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:
21646
diff
changeset
|
307 | JabberBytestreamsStreamhost *sh = g_new0(JabberBytestreamsStreamhost, 1); |
| 8262 | 308 | sh->jid = g_strdup(jid); |
| 309 | sh->host = g_strdup(host); | |
| 310 | sh->port = portnum; | |
|
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:
21646
diff
changeset
|
311 | sh->zeroconf = g_strdup(zeroconf); |
|
23075
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
312 | /* If there were a lot of these, it'd be worthwhile to prepend and reverse. */ |
| 8262 | 313 | jsx->streamhosts = g_list_append(jsx->streamhosts, sh); |
| 314 | } | |
| 315 | } | |
| 316 | ||
| 317 | jabber_si_bytestreams_attempt_connect(xfer); | |
| 7395 | 318 | } |
| 319 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
320 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
321 | static void |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
322 | jabber_si_xfer_bytestreams_send_read_again_resp_cb(gpointer data, gint source, |
| 15884 | 323 | PurpleInputCondition cond) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
324 | { |
| 15884 | 325 | PurpleXfer *xfer = data; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
326 | JabberSIXfer *jsx = xfer->data; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
327 | int len; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
328 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
329 | len = write(source, jsx->rxqueue + jsx->rxlen, jsx->rxmaxlen - jsx->rxlen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
330 | if (len < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
331 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
332 | else if (len < 0) { |
| 15884 | 333 | purple_input_remove(xfer->watcher); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
334 | xfer->watcher = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
335 | g_free(jsx->rxqueue); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
336 | jsx->rxqueue = NULL; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
337 | close(source); |
| 15884 | 338 | purple_xfer_cancel_remote(xfer); |
| 13441 | 339 | return; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
340 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
341 | jsx->rxlen += len; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
342 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
343 | if (jsx->rxlen < jsx->rxmaxlen) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
344 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
345 | |
| 15884 | 346 | purple_input_remove(xfer->watcher); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
347 | xfer->watcher = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
348 | g_free(jsx->rxqueue); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
349 | jsx->rxqueue = NULL; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
350 | |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
351 | /* Before actually starting sending the file, we need to wait until the |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
352 | * recipient sends the IQ result with <streamhost-used/> |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
353 | */ |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
354 | purple_debug_info("jabber", "SOCKS5 connection negotiation completed. " |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
355 | "Waiting for IQ result to start file transfer.\n"); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
356 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
357 | |
| 8312 | 358 | static void |
| 8316 | 359 | jabber_si_xfer_bytestreams_send_read_again_cb(gpointer data, gint source, |
| 15884 | 360 | PurpleInputCondition cond) |
| 8312 | 361 | { |
| 15884 | 362 | PurpleXfer *xfer = data; |
| 8316 | 363 | JabberSIXfer *jsx = xfer->data; |
| 8312 | 364 | int i; |
| 8316 | 365 | char buffer[256]; |
| 366 | int len; | |
| 367 | char *dstaddr, *p; | |
| 368 | unsigned char hashval[20]; | |
| 369 | const char *host; | |
| 370 | ||
| 15884 | 371 | purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_read_again_cb\n"); |
| 8312 | 372 | |
| 8316 | 373 | if(jsx->rxlen < 5) { |
| 15884 | 374 | purple_debug_info("jabber", "reading the first 5 bytes\n"); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
375 | len = read(source, buffer, 5 - jsx->rxlen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
376 | if(len < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
377 | return; |
|
13788
019bc2080927
[gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents:
13493
diff
changeset
|
378 | else if(len <= 0) { |
| 15884 | 379 | purple_input_remove(xfer->watcher); |
| 8316 | 380 | xfer->watcher = 0; |
| 381 | close(source); | |
| 15884 | 382 | purple_xfer_cancel_remote(xfer); |
| 8316 | 383 | return; |
| 384 | } | |
| 385 | jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen); | |
| 386 | memcpy(jsx->rxqueue + jsx->rxlen, buffer, len); | |
| 387 | jsx->rxlen += len; | |
| 388 | return; | |
| 389 | } else if(jsx->rxqueue[0] != 0x05 || jsx->rxqueue[1] != 0x01 || | |
| 390 | jsx->rxqueue[3] != 0x03) { | |
| 15884 | 391 | purple_debug_info("jabber", "invalid socks5 stuff\n"); |
| 392 | purple_input_remove(xfer->watcher); | |
| 8316 | 393 | xfer->watcher = 0; |
| 394 | close(source); | |
| 15884 | 395 | purple_xfer_cancel_remote(xfer); |
| 8316 | 396 | return; |
| 397 | } else if(jsx->rxlen - 5 < jsx->rxqueue[4] + 2) { | |
| 15884 | 398 | purple_debug_info("jabber", "reading umpteen more bytes\n"); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
399 | len = read(source, buffer, jsx->rxqueue[4] + 5 + 2 - jsx->rxlen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
400 | if(len < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
401 | return; |
|
13788
019bc2080927
[gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents:
13493
diff
changeset
|
402 | else if(len <= 0) { |
| 15884 | 403 | purple_input_remove(xfer->watcher); |
| 8316 | 404 | xfer->watcher = 0; |
| 405 | close(source); | |
| 15884 | 406 | purple_xfer_cancel_remote(xfer); |
| 8316 | 407 | return; |
| 408 | } | |
| 409 | jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen); | |
| 410 | memcpy(jsx->rxqueue + jsx->rxlen, buffer, len); | |
| 411 | jsx->rxlen += len; | |
| 412 | } | |
| 8312 | 413 | |
| 8316 | 414 | if(jsx->rxlen - 5 < jsx->rxqueue[4] + 2) |
| 415 | return; | |
| 416 | ||
| 15884 | 417 | purple_input_remove(xfer->watcher); |
| 8316 | 418 | xfer->watcher = 0; |
| 8312 | 419 | |
| 8316 | 420 | dstaddr = g_strdup_printf("%s%s@%s/%s%s", jsx->stream_id, |
| 421 | jsx->js->user->node, jsx->js->user->domain, | |
| 422 | jsx->js->user->resource, xfer->who); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10112
diff
changeset
|
423 | |
| 15884 | 424 | purple_cipher_digest_region("sha1", (guchar *)dstaddr, strlen(dstaddr), |
|
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:
21646
diff
changeset
|
425 | sizeof(hashval), hashval, NULL); |
| 8316 | 426 | g_free(dstaddr); |
| 427 | dstaddr = g_malloc(41); | |
| 428 | p = dstaddr; | |
| 429 | for(i=0; i<20; i++, p+=2) | |
| 430 | snprintf(p, 3, "%02x", hashval[i]); | |
| 431 | ||
| 432 | if(jsx->rxqueue[4] != 40 || strncmp(dstaddr, jsx->rxqueue+5, 40) || | |
| 433 | jsx->rxqueue[45] != 0x00 || jsx->rxqueue[46] != 0x00) { | |
| 15884 | 434 | purple_debug_error("jabber", "someone connected with the wrong info!\n"); |
| 8312 | 435 | close(source); |
| 15884 | 436 | purple_xfer_cancel_remote(xfer); |
|
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:
21646
diff
changeset
|
437 | g_free(dstaddr); |
| 8312 | 438 | return; |
| 439 | } | |
| 440 | ||
|
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:
21646
diff
changeset
|
441 | g_free(dstaddr); |
|
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:
21646
diff
changeset
|
442 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
443 | g_free(jsx->rxqueue); |
| 15884 | 444 | host = purple_network_get_my_ip(jsx->js->fd); |
| 8316 | 445 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
446 | jsx->rxmaxlen = 5 + strlen(host) + 2; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
447 | jsx->rxqueue = g_malloc(jsx->rxmaxlen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
448 | jsx->rxlen = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
449 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
450 | jsx->rxqueue[0] = 0x05; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
451 | jsx->rxqueue[1] = 0x00; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
452 | jsx->rxqueue[2] = 0x00; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
453 | jsx->rxqueue[3] = 0x03; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
454 | jsx->rxqueue[4] = strlen(host); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
455 | memcpy(jsx->rxqueue + 5, host, strlen(host)); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
456 | jsx->rxqueue[5+strlen(host)] = 0x00; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
457 | jsx->rxqueue[6+strlen(host)] = 0x00; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
458 | |
| 15884 | 459 | xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
460 | jabber_si_xfer_bytestreams_send_read_again_resp_cb, xfer); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
461 | jabber_si_xfer_bytestreams_send_read_again_resp_cb(xfer, source, |
| 15884 | 462 | PURPLE_INPUT_WRITE); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
463 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
464 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
465 | static void |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
466 | jabber_si_xfer_bytestreams_send_read_response_cb(gpointer data, gint source, |
| 15884 | 467 | PurpleInputCondition cond) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
468 | { |
| 15884 | 469 | PurpleXfer *xfer = data; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
470 | JabberSIXfer *jsx = xfer->data; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
471 | int len; |
| 8316 | 472 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
473 | len = write(source, jsx->rxqueue + jsx->rxlen, jsx->rxmaxlen - jsx->rxlen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
474 | if (len < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
475 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
476 | else if (len < 0) { |
| 15884 | 477 | purple_input_remove(xfer->watcher); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
478 | xfer->watcher = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
479 | g_free(jsx->rxqueue); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
480 | jsx->rxqueue = NULL; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
481 | close(source); |
| 15884 | 482 | purple_xfer_cancel_remote(xfer); |
|
13493
598d8f618a31
[gaim-migrate @ 15868]
Richard Laager <rlaager@pidgin.im>
parents:
13441
diff
changeset
|
483 | return; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
484 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
485 | jsx->rxlen += len; |
| 8316 | 486 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
487 | if (jsx->rxlen < jsx->rxmaxlen) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
488 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
489 | |
| 15884 | 490 | purple_input_remove(xfer->watcher); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
491 | xfer->watcher = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
492 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
493 | if (jsx->rxqueue[1] == 0x00) { |
| 15884 | 494 | xfer->watcher = purple_input_add(source, PURPLE_INPUT_READ, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
495 | jabber_si_xfer_bytestreams_send_read_again_cb, xfer); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
496 | g_free(jsx->rxqueue); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
497 | jsx->rxqueue = NULL; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
498 | } else { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
499 | close(source); |
| 15884 | 500 | purple_xfer_cancel_remote(xfer); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
501 | } |
| 8316 | 502 | } |
| 503 | ||
| 504 | static void | |
| 505 | jabber_si_xfer_bytestreams_send_read_cb(gpointer data, gint source, | |
| 15884 | 506 | PurpleInputCondition cond) |
| 8316 | 507 | { |
| 15884 | 508 | PurpleXfer *xfer = data; |
| 8316 | 509 | JabberSIXfer *jsx = xfer->data; |
| 510 | int i; | |
| 511 | int len; | |
| 512 | char buffer[256]; | |
| 513 | ||
| 15884 | 514 | purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_read_cb\n"); |
| 8316 | 515 | |
| 516 | xfer->fd = source; | |
| 517 | ||
| 518 | if(jsx->rxlen < 2) { | |
| 15884 | 519 | purple_debug_info("jabber", "reading those first two bytes\n"); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
520 | len = read(source, buffer, 2 - jsx->rxlen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
521 | if(len < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
522 | return; |
|
13788
019bc2080927
[gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents:
13493
diff
changeset
|
523 | else if(len <= 0) { |
| 15884 | 524 | purple_input_remove(xfer->watcher); |
| 8316 | 525 | xfer->watcher = 0; |
| 526 | close(source); | |
| 15884 | 527 | purple_xfer_cancel_remote(xfer); |
| 8316 | 528 | return; |
| 529 | } | |
| 530 | jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen); | |
| 531 | memcpy(jsx->rxqueue + jsx->rxlen, buffer, len); | |
| 532 | jsx->rxlen += len; | |
| 533 | return; | |
| 534 | } else if(jsx->rxlen - 2 < jsx->rxqueue[1]) { | |
| 15884 | 535 | purple_debug_info("jabber", "reading the next umpteen bytes\n"); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
536 | len = read(source, buffer, jsx->rxqueue[1] + 2 - jsx->rxlen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
537 | if(len < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
538 | return; |
|
13788
019bc2080927
[gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents:
13493
diff
changeset
|
539 | else if(len <= 0) { |
| 15884 | 540 | purple_input_remove(xfer->watcher); |
| 8316 | 541 | xfer->watcher = 0; |
| 542 | close(source); | |
| 15884 | 543 | purple_xfer_cancel_remote(xfer); |
| 8316 | 544 | return; |
| 545 | } | |
| 546 | jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen); | |
| 547 | memcpy(jsx->rxqueue + jsx->rxlen, buffer, len); | |
| 548 | jsx->rxlen += len; | |
| 549 | } | |
| 550 | ||
| 551 | if(jsx->rxlen -2 < jsx->rxqueue[1]) | |
| 552 | return; | |
| 553 | ||
| 15884 | 554 | purple_input_remove(xfer->watcher); |
| 8316 | 555 | xfer->watcher = 0; |
| 556 | ||
| 15884 | 557 | purple_debug_info("jabber", "checking to make sure we're socks FIVE\n"); |
| 8316 | 558 | |
| 559 | if(jsx->rxqueue[0] != 0x05) { | |
| 560 | close(source); | |
| 15884 | 561 | purple_xfer_cancel_remote(xfer); |
| 8316 | 562 | return; |
| 563 | } | |
| 564 | ||
| 15884 | 565 | purple_debug_info("jabber", "going to test %hhu different methods\n", jsx->rxqueue[1]); |
| 8316 | 566 | |
| 567 | for(i=0; i<jsx->rxqueue[1]; i++) { | |
| 568 | ||
| 15884 | 569 | purple_debug_info("jabber", "testing %hhu\n", jsx->rxqueue[i+2]); |
| 8316 | 570 | if(jsx->rxqueue[i+2] == 0x00) { |
| 571 | g_free(jsx->rxqueue); | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
572 | jsx->rxlen = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
573 | jsx->rxmaxlen = 2; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
574 | jsx->rxqueue = g_malloc(jsx->rxmaxlen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
575 | jsx->rxqueue[0] = 0x05; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
576 | jsx->rxqueue[1] = 0x00; |
| 15884 | 577 | xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
578 | jabber_si_xfer_bytestreams_send_read_response_cb, |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
579 | xfer); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
580 | jabber_si_xfer_bytestreams_send_read_response_cb(xfer, |
| 15884 | 581 | source, PURPLE_INPUT_WRITE); |
| 8316 | 582 | jsx->rxqueue = NULL; |
| 583 | jsx->rxlen = 0; | |
| 8312 | 584 | return; |
| 585 | } | |
| 586 | } | |
| 587 | ||
| 8316 | 588 | g_free(jsx->rxqueue); |
| 589 | jsx->rxlen = 0; | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
590 | jsx->rxmaxlen = 2; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
591 | jsx->rxqueue = g_malloc(jsx->rxmaxlen); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
592 | jsx->rxqueue[0] = 0x05; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
593 | jsx->rxqueue[1] = 0xFF; |
| 15884 | 594 | xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
595 | jabber_si_xfer_bytestreams_send_read_response_cb, xfer); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
596 | jabber_si_xfer_bytestreams_send_read_response_cb(xfer, |
| 15884 | 597 | source, PURPLE_INPUT_WRITE); |
| 8312 | 598 | } |
| 599 | ||
|
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:
21646
diff
changeset
|
600 | static gint |
|
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:
21646
diff
changeset
|
601 | jabber_si_compare_jid(gconstpointer a, gconstpointer b) |
|
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:
21646
diff
changeset
|
602 | { |
|
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:
21646
diff
changeset
|
603 | const JabberBytestreamsStreamhost *sh = a; |
|
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:
21646
diff
changeset
|
604 | |
|
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:
21646
diff
changeset
|
605 | if(!a) |
|
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:
21646
diff
changeset
|
606 | return -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:
21646
diff
changeset
|
607 | |
|
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:
21646
diff
changeset
|
608 | return strcmp(sh->jid, (char *)b); |
|
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:
21646
diff
changeset
|
609 | } |
|
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:
21646
diff
changeset
|
610 | |
| 8312 | 611 | static void |
| 8316 | 612 | jabber_si_xfer_bytestreams_send_connected_cb(gpointer data, gint source, |
| 15884 | 613 | PurpleInputCondition cond) |
| 8316 | 614 | { |
| 15884 | 615 | PurpleXfer *xfer = data; |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
616 | JabberSIXfer *jsx = xfer->data; |
|
24038
5500af38bb9f
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents:
23912
diff
changeset
|
617 | int acceptfd, flags; |
| 8316 | 618 | |
| 15884 | 619 | purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_connected_cb\n"); |
| 8316 | 620 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
621 | acceptfd = accept(source, NULL, 0); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
622 | if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
623 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
624 | else if(acceptfd == -1) { |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
19859
diff
changeset
|
625 | purple_debug_warning("jabber", "accept: %s\n", g_strerror(errno)); |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
626 | /* Don't cancel the ft - allow it to fall to the next streamhost.*/ |
| 8316 | 627 | return; |
| 628 | } | |
| 629 | ||
| 15884 | 630 | purple_input_remove(xfer->watcher); |
| 8316 | 631 | close(source); |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
632 | jsx->local_streamhost_fd = -1; |
| 8316 | 633 | |
|
24038
5500af38bb9f
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents:
23912
diff
changeset
|
634 | flags = fcntl(acceptfd, F_GETFL); |
|
5500af38bb9f
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents:
23912
diff
changeset
|
635 | fcntl(acceptfd, F_SETFL, flags | O_NONBLOCK); |
|
5500af38bb9f
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents:
23912
diff
changeset
|
636 | #ifndef _WIN32 |
|
5500af38bb9f
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents:
23912
diff
changeset
|
637 | fcntl(acceptfd, F_SETFD, FD_CLOEXEC); |
|
5500af38bb9f
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents:
23912
diff
changeset
|
638 | #endif |
|
5500af38bb9f
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents:
23912
diff
changeset
|
639 | |
| 15884 | 640 | xfer->watcher = purple_input_add(acceptfd, PURPLE_INPUT_READ, |
|
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:
21646
diff
changeset
|
641 | jabber_si_xfer_bytestreams_send_read_cb, xfer); |
|
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:
21646
diff
changeset
|
642 | } |
|
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:
21646
diff
changeset
|
643 | |
|
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:
21646
diff
changeset
|
644 | 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:
21646
diff
changeset
|
645 | jabber_si_connect_proxy_cb(JabberStream *js, xmlnode *packet, |
|
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:
21646
diff
changeset
|
646 | 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:
21646
diff
changeset
|
647 | { |
|
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:
21646
diff
changeset
|
648 | PurpleXfer *xfer = data; |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
649 | JabberSIXfer *jsx; |
|
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:
21646
diff
changeset
|
650 | xmlnode *query, *streamhost_used; |
|
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:
21646
diff
changeset
|
651 | const char *from, *type, *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:
21646
diff
changeset
|
652 | GList *matched; |
|
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:
21646
diff
changeset
|
653 | |
|
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:
21646
diff
changeset
|
654 | /* TODO: This need to send errors if we don't see what we're looking for */ |
|
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:
21646
diff
changeset
|
655 | |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
656 | /* Make sure that the xfer is actually still valid and we're not just receiving an old iq response */ |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
657 | if (!g_list_find(js->file_transfers, xfer)) { |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
658 | purple_debug_error("jabber", "Got bytestreams response for no longer existing xfer (%p)\n", xfer); |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
659 | return; |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
660 | } |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
661 | |
|
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:
21646
diff
changeset
|
662 | /* In the case of a direct file transfer, this is expected to return */ |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
663 | if(!xfer->data) |
|
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:
21646
diff
changeset
|
664 | return; |
|
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:
21646
diff
changeset
|
665 | |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
666 | jsx = xfer->data; |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
667 | |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
668 | if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) { |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
669 | if (type && !strcmp(type, "error")) |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
670 | purple_xfer_cancel_remote(xfer); |
|
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:
21646
diff
changeset
|
671 | return; |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
672 | } |
|
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:
21646
diff
changeset
|
673 | |
|
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:
21646
diff
changeset
|
674 | if(!(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:
21646
diff
changeset
|
675 | return; |
|
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:
21646
diff
changeset
|
676 | |
|
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:
21646
diff
changeset
|
677 | if(!(query = xmlnode_get_child(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:
21646
diff
changeset
|
678 | return; |
|
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:
21646
diff
changeset
|
679 | |
|
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:
21646
diff
changeset
|
680 | if(!(streamhost_used = xmlnode_get_child(query, "streamhost-used"))) |
|
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:
21646
diff
changeset
|
681 | return; |
|
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:
21646
diff
changeset
|
682 | |
|
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:
21646
diff
changeset
|
683 | if(!(jid = xmlnode_get_attrib(streamhost_used, "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:
21646
diff
changeset
|
684 | return; |
|
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:
21646
diff
changeset
|
685 | |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
686 | purple_debug_info("jabber", "jabber_si_connect_proxy_cb() will be looking at jsx %p: jsx->streamhosts is %p and jid is %s\n", |
|
22816
68013573e6aa
I've seen intermittent crashes on xmpp file transfers in this code, but I
Evan Schoenberg <evands@pidgin.im>
parents:
22328
diff
changeset
|
687 | jsx, jsx->streamhosts, jid); |
|
68013573e6aa
I've seen intermittent crashes on xmpp file transfers in this code, but I
Evan Schoenberg <evands@pidgin.im>
parents:
22328
diff
changeset
|
688 | |
|
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:
21646
diff
changeset
|
689 | if(!(matched = g_list_find_custom(jsx->streamhosts, jid, jabber_si_compare_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:
21646
diff
changeset
|
690 | { |
|
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:
21646
diff
changeset
|
691 | gchar *my_jid = g_strdup_printf("%s@%s/%s", jsx->js->user->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:
21646
diff
changeset
|
692 | jsx->js->user->domain, jsx->js->user->resource); |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
693 | if (!strcmp(jid, my_jid)) { |
|
21688
a16385b34219
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents:
21646
diff
changeset
|
694 | purple_debug_info("jabber", "Got local SOCKS5 streamhost-used.\n"); |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
695 | purple_xfer_start(xfer, xfer->fd, NULL, -1); |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
696 | } else { |
|
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:
21646
diff
changeset
|
697 | purple_debug_info("jabber", "streamhost-used does not match any proxy that was offered to target\n"); |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
698 | purple_xfer_cancel_local(xfer); |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
699 | } |
|
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:
21646
diff
changeset
|
700 | g_free(my_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:
21646
diff
changeset
|
701 | return; |
|
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:
21646
diff
changeset
|
702 | } |
|
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:
21646
diff
changeset
|
703 | |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
704 | /* Clean up the local streamhost - it isn't going to be used.*/ |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
705 | if (xfer->watcher > 0) { |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
706 | purple_input_remove(xfer->watcher); |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
707 | xfer->watcher = 0; |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
708 | } |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
709 | if (jsx->local_streamhost_fd >= 0) { |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
710 | close(jsx->local_streamhost_fd); |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
711 | jsx->local_streamhost_fd = -1; |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
712 | } |
|
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:
21646
diff
changeset
|
713 | |
|
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:
21646
diff
changeset
|
714 | jsx->streamhosts = g_list_remove_link(jsx->streamhosts, matched); |
|
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:
21646
diff
changeset
|
715 | g_list_foreach(jsx->streamhosts, jabber_si_free_streamhost, 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:
21646
diff
changeset
|
716 | g_list_free(jsx->streamhosts); |
|
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:
21646
diff
changeset
|
717 | |
|
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:
21646
diff
changeset
|
718 | jsx->streamhosts = matched; |
|
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:
21646
diff
changeset
|
719 | |
|
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:
21646
diff
changeset
|
720 | jabber_si_bytestreams_attempt_connect(xfer); |
| 8316 | 721 | } |
| 722 | ||
| 723 | static void | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
724 | jabber_si_xfer_bytestreams_listen_cb(int sock, gpointer data) |
| 8312 | 725 | { |
| 15884 | 726 | PurpleXfer *xfer = data; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
727 | JabberSIXfer *jsx; |
| 8312 | 728 | JabberIq *iq; |
| 729 | xmlnode *query, *streamhost; | |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
730 | char port[6]; |
|
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:
21646
diff
changeset
|
731 | GList *tmp; |
|
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:
21646
diff
changeset
|
732 | JabberBytestreamsStreamhost *sh, *sh2; |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
733 | int streamhost_count = 0; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
734 | |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
735 | jsx = xfer->data; |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
736 | jsx->listen_data = NULL; |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
737 | |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
738 | /* I'm not sure under which conditions this can happen |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
739 | * (it seems like it shouldn't be possible */ |
| 15884 | 740 | if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) { |
| 741 | purple_xfer_unref(xfer); | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
742 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
743 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
744 | |
| 15884 | 745 | purple_xfer_unref(xfer); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
746 | |
| 8312 | 747 | iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, |
| 748 | "http://jabber.org/protocol/bytestreams"); | |
| 749 | xmlnode_set_attrib(iq->node, "to", xfer->who); | |
| 750 | query = xmlnode_get_child(iq->node, "query"); | |
| 751 | ||
| 752 | xmlnode_set_attrib(query, "sid", jsx->stream_id); | |
| 753 | ||
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
754 | /* If we successfully started listening locally */ |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
755 | if (sock >= 0) { |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
756 | gchar *jid; |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
757 | const char *local_ip, *public_ip; |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
758 | |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
759 | jsx->local_streamhost_fd = sock; |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
760 | |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
761 | jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node, |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
762 | jsx->js->user->domain, jsx->js->user->resource); |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
763 | xfer->local_port = purple_network_get_port_from_fd(sock); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
764 | g_snprintf(port, sizeof(port), "%hu", xfer->local_port); |
|
21688
a16385b34219
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents:
21646
diff
changeset
|
765 | |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
766 | /* Include the localhost's IP (for in-network transfers) */ |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
767 | local_ip = purple_network_get_local_system_ip(jsx->js->fd); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
768 | if (strcmp(local_ip, "0.0.0.0") != 0) { |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
769 | streamhost_count++; |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
770 | streamhost = xmlnode_new_child(query, "streamhost"); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
771 | xmlnode_set_attrib(streamhost, "jid", jid); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
772 | xmlnode_set_attrib(streamhost, "host", local_ip); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
773 | xmlnode_set_attrib(streamhost, "port", port); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
774 | } |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
775 | |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
776 | /* Include the public IP (assuming that there is a port mapped somehow) */ |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
777 | public_ip = purple_network_get_my_ip(jsx->js->fd); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
778 | if (strcmp(public_ip, local_ip) != 0 && strcmp(public_ip, "0.0.0.0") != 0) { |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
779 | streamhost_count++; |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
780 | streamhost = xmlnode_new_child(query, "streamhost"); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
781 | xmlnode_set_attrib(streamhost, "jid", jid); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
782 | xmlnode_set_attrib(streamhost, "host", public_ip); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
783 | xmlnode_set_attrib(streamhost, "port", port); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
784 | } |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
785 | |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
786 | g_free(jid); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
787 | |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
788 | /* The listener for the local proxy */ |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
789 | xfer->watcher = purple_input_add(sock, PURPLE_INPUT_READ, |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
790 | jabber_si_xfer_bytestreams_send_connected_cb, xfer); |
|
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:
21646
diff
changeset
|
791 | } |
|
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:
21646
diff
changeset
|
792 | |
|
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:
21646
diff
changeset
|
793 | for (tmp = jsx->js->bs_proxies; tmp; tmp = tmp->next) { |
|
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:
21646
diff
changeset
|
794 | sh = tmp->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:
21646
diff
changeset
|
795 | |
|
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:
21646
diff
changeset
|
796 | /* TODO: deal with zeroconf proxies */ |
|
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:
21646
diff
changeset
|
797 | |
|
21717
424d552a8435
Now that the release has been tagged and strings are unfrozen, enable the new ft proxy account setting for xmpp accounts. Also, prevent duplicate entries in the streamhost lists. I don't know if the default account proxy is acceptable, perhaps there shouldn't be a default value.
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
798 | if (!(sh->jid && sh->host && sh->port > 0)) |
|
424d552a8435
Now that the release has been tagged and strings are unfrozen, enable the new ft proxy account setting for xmpp accounts. Also, prevent duplicate entries in the streamhost lists. I don't know if the default account proxy is acceptable, perhaps there shouldn't be a default value.
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
799 | continue; |
|
424d552a8435
Now that the release has been tagged and strings are unfrozen, enable the new ft proxy account setting for xmpp accounts. Also, prevent duplicate entries in the streamhost lists. I don't know if the default account proxy is acceptable, perhaps there shouldn't be a default value.
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
800 | |
|
24712
134bd2024c88
Add missing newline in debug message.
Daniel Atallah <datallah@pidgin.im>
parents:
24038
diff
changeset
|
801 | purple_debug_info("jabber", "jabber_si_xfer_bytestreams_listen_cb() will be looking at jsx %p: jsx->streamhosts %p and sh->jid %p\n", |
|
22816
68013573e6aa
I've seen intermittent crashes on xmpp file transfers in this code, but I
Evan Schoenberg <evands@pidgin.im>
parents:
22328
diff
changeset
|
802 | jsx, jsx->streamhosts, sh->jid); |
|
21717
424d552a8435
Now that the release has been tagged and strings are unfrozen, enable the new ft proxy account setting for xmpp accounts. Also, prevent duplicate entries in the streamhost lists. I don't know if the default account proxy is acceptable, perhaps there shouldn't be a default value.
Daniel Atallah <datallah@pidgin.im>
parents:
21688
diff
changeset
|
803 | if(g_list_find_custom(jsx->streamhosts, sh->jid, jabber_si_compare_jid) != NULL) |
|
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:
21646
diff
changeset
|
804 | continue; |
|
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:
21646
diff
changeset
|
805 | |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
806 | streamhost_count++; |
|
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:
21646
diff
changeset
|
807 | streamhost = xmlnode_new_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:
21646
diff
changeset
|
808 | xmlnode_set_attrib(streamhost, "jid", 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:
21646
diff
changeset
|
809 | xmlnode_set_attrib(streamhost, "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:
21646
diff
changeset
|
810 | g_snprintf(port, sizeof(port), "%hu", sh->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:
21646
diff
changeset
|
811 | xmlnode_set_attrib(streamhost, "port", 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:
21646
diff
changeset
|
812 | |
|
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:
21646
diff
changeset
|
813 | sh2 = 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:
21646
diff
changeset
|
814 | sh2->jid = g_strdup(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:
21646
diff
changeset
|
815 | sh2->host = g_strdup(sh->host); |
|
23075
b25e0581e5a8
Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents:
22816
diff
changeset
|
816 | /*sh2->zeroconf = g_strdup(sh->zeroconf);*/ |
|
21688
a16385b34219
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents:
21646
diff
changeset
|
817 | sh2->port = sh->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:
21646
diff
changeset
|
818 | |
|
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:
21646
diff
changeset
|
819 | jsx->streamhosts = g_list_prepend(jsx->streamhosts, sh2); |
|
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:
21646
diff
changeset
|
820 | } |
|
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:
21646
diff
changeset
|
821 | |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
822 | /* We have no way of transferring, cancel the transfer */ |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
823 | if (streamhost_count == 0) { |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
824 | jabber_iq_free(iq); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
825 | /* We should probably notify the target, but this really shouldn't ever happen */ |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
826 | purple_xfer_cancel_local(xfer); |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
827 | return; |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
828 | } |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
829 | |
|
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:
21646
diff
changeset
|
830 | jabber_iq_set_callback(iq, jabber_si_connect_proxy_cb, xfer); |
|
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:
21646
diff
changeset
|
831 | |
| 8312 | 832 | jabber_iq_send(iq); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
833 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
834 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
835 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
836 | static void |
| 15884 | 837 | jabber_si_xfer_bytestreams_send_init(PurpleXfer *xfer) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
838 | { |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
839 | JabberSIXfer *jsx; |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
840 | |
| 15884 | 841 | purple_xfer_ref(xfer); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
842 | |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
843 | jsx = xfer->data; |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
844 | |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
845 | /* TODO: Should there be an option to not use the local host as a ft proxy? |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
846 | * (to prevent revealing IP address, etc.) */ |
| 15884 | 847 | jsx->listen_data = purple_network_listen_range(0, 0, SOCK_STREAM, |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
848 | jabber_si_xfer_bytestreams_listen_cb, xfer); |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
849 | if (jsx->listen_data == NULL) { |
|
23506
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
850 | /* We couldn't open a local port. Perhaps we can use a proxy. */ |
|
aeba2ae6a455
Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents:
23505
diff
changeset
|
851 | jabber_si_xfer_bytestreams_listen_cb(-1, xfer); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
852 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
853 | |
| 8312 | 854 | } |
| 855 | ||
| 856 | static void jabber_si_xfer_send_method_cb(JabberStream *js, xmlnode *packet, | |
| 857 | gpointer data) | |
| 858 | { | |
| 15884 | 859 | PurpleXfer *xfer = data; |
| 8312 | 860 | xmlnode *si, *feature, *x, *field, *value; |
| 861 | ||
| 862 | if(!(si = xmlnode_get_child_with_namespace(packet, "si", "http://jabber.org/protocol/si"))) { | |
| 15884 | 863 | purple_xfer_cancel_remote(xfer); |
| 8312 | 864 | return; |
| 865 | } | |
| 866 | ||
| 867 | if(!(feature = xmlnode_get_child_with_namespace(si, "feature", "http://jabber.org/protocol/feature-neg"))) { | |
| 15884 | 868 | purple_xfer_cancel_remote(xfer); |
| 8312 | 869 | return; |
| 870 | } | |
| 871 | ||
| 872 | if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data"))) { | |
| 15884 | 873 | purple_xfer_cancel_remote(xfer); |
| 8312 | 874 | return; |
| 875 | } | |
| 876 | ||
| 877 | for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) { | |
| 878 | const char *var = xmlnode_get_attrib(field, "var"); | |
| 879 | ||
| 880 | if(var && !strcmp(var, "stream-method")) { | |
| 881 | if((value = xmlnode_get_child(field, "value"))) { | |
| 882 | char *val = xmlnode_get_data(value); | |
| 883 | if(val && !strcmp(val, "http://jabber.org/protocol/bytestreams")) { | |
| 884 | jabber_si_xfer_bytestreams_send_init(xfer); | |
| 885 | g_free(val); | |
| 886 | return; | |
| 887 | } | |
| 888 | g_free(val); | |
| 889 | } | |
| 890 | } | |
| 891 | } | |
| 15884 | 892 | purple_xfer_cancel_remote(xfer); |
| 8312 | 893 | } |
| 894 | ||
| 15884 | 895 | static void jabber_si_xfer_send_request(PurpleXfer *xfer) |
| 8312 | 896 | { |
| 897 | JabberSIXfer *jsx = xfer->data; | |
| 898 | JabberIq *iq; | |
| 899 | xmlnode *si, *file, *feature, *x, *field, *option, *value; | |
| 900 | char buf[32]; | |
| 901 | ||
| 902 | xfer->filename = g_path_get_basename(xfer->local_filename); | |
| 903 | ||
| 904 | iq = jabber_iq_new(jsx->js, JABBER_IQ_SET); | |
| 905 | xmlnode_set_attrib(iq->node, "to", xfer->who); | |
| 906 | si = xmlnode_new_child(iq->node, "si"); | |
| 13808 | 907 | xmlnode_set_namespace(si, "http://jabber.org/protocol/si"); |
| 8312 | 908 | jsx->stream_id = jabber_get_next_id(jsx->js); |
| 909 | xmlnode_set_attrib(si, "id", jsx->stream_id); | |
| 910 | xmlnode_set_attrib(si, "profile", | |
| 911 | "http://jabber.org/protocol/si/profile/file-transfer"); | |
| 912 | ||
| 913 | file = xmlnode_new_child(si, "file"); | |
| 13808 | 914 | xmlnode_set_namespace(file, |
| 8312 | 915 | "http://jabber.org/protocol/si/profile/file-transfer"); |
| 916 | xmlnode_set_attrib(file, "name", xfer->filename); | |
|
11656
56f5e598dc6c
[gaim-migrate @ 13940]
Richard Laager <rlaager@pidgin.im>
parents:
11183
diff
changeset
|
917 | g_snprintf(buf, sizeof(buf), "%" G_GSIZE_FORMAT, xfer->size); |
| 8312 | 918 | xmlnode_set_attrib(file, "size", buf); |
| 919 | /* maybe later we'll do hash and date attribs */ | |
| 920 | ||
| 921 | feature = xmlnode_new_child(si, "feature"); | |
|
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:
21646
diff
changeset
|
922 | xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg"); |
| 8312 | 923 | x = xmlnode_new_child(feature, "x"); |
| 13808 | 924 | xmlnode_set_namespace(x, "jabber:x:data"); |
| 8312 | 925 | xmlnode_set_attrib(x, "type", "form"); |
| 926 | field = xmlnode_new_child(x, "field"); | |
| 927 | xmlnode_set_attrib(field, "var", "stream-method"); | |
| 928 | xmlnode_set_attrib(field, "type", "list-single"); | |
| 929 | option = xmlnode_new_child(field, "option"); | |
| 930 | value = xmlnode_new_child(option, "value"); | |
|
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:
21646
diff
changeset
|
931 | xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1); |
| 8312 | 932 | /* |
| 933 | option = xmlnode_new_child(field, "option"); | |
| 934 | value = xmlnode_new_child(option, "value"); | |
| 935 | xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1); | |
| 936 | */ | |
| 937 | ||
| 938 | jabber_iq_set_callback(iq, jabber_si_xfer_send_method_cb, xfer); | |
| 939 | ||
|
19853
389f6a0d4347
Unregister the iq callback listener when the transfer is freed. Fixes #1804. It doesn't seem correct to me that nothing is sent to the recipient when the sender cancels the ft request, but that is a different issue.
Daniel Atallah <datallah@pidgin.im>
parents:
18273
diff
changeset
|
940 | /* Store the IQ id so that we can cancel the callback */ |
|
389f6a0d4347
Unregister the iq callback listener when the transfer is freed. Fixes #1804. It doesn't seem correct to me that nothing is sent to the recipient when the sender cancels the ft request, but that is a different issue.
Daniel Atallah <datallah@pidgin.im>
parents:
18273
diff
changeset
|
941 | g_free(jsx->iq_id); |
|
389f6a0d4347
Unregister the iq callback listener when the transfer is freed. Fixes #1804. It doesn't seem correct to me that nothing is sent to the recipient when the sender cancels the ft request, but that is a different issue.
Daniel Atallah <datallah@pidgin.im>
parents:
18273
diff
changeset
|
942 | jsx->iq_id = g_strdup(iq->id); |
|
389f6a0d4347
Unregister the iq callback listener when the transfer is freed. Fixes #1804. It doesn't seem correct to me that nothing is sent to the recipient when the sender cancels the ft request, but that is a different issue.
Daniel Atallah <datallah@pidgin.im>
parents:
18273
diff
changeset
|
943 | |
| 8312 | 944 | jabber_iq_send(iq); |
| 945 | } | |
| 946 | ||
| 15884 | 947 | static void jabber_si_xfer_free(PurpleXfer *xfer) |
| 8312 | 948 | { |
| 8316 | 949 | JabberSIXfer *jsx = xfer->data; |
| 950 | JabberStream *js = jsx->js; | |
| 951 | ||
| 952 | js->file_transfers = g_list_remove(js->file_transfers, xfer); | |
| 953 | ||
|
14324
8cbedd82b6ac
[gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
954 | if (jsx->connect_data != NULL) |
| 15884 | 955 | purple_proxy_connect_cancel(jsx->connect_data); |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14324
diff
changeset
|
956 | if (jsx->listen_data != NULL) |
| 15884 | 957 | purple_network_listen_cancel(jsx->listen_data); |
|
19853
389f6a0d4347
Unregister the iq callback listener when the transfer is freed. Fixes #1804. It doesn't seem correct to me that nothing is sent to the recipient when the sender cancels the ft request, but that is a different issue.
Daniel Atallah <datallah@pidgin.im>
parents:
18273
diff
changeset
|
958 | if (jsx->iq_id != NULL) |
|
389f6a0d4347
Unregister the iq callback listener when the transfer is freed. Fixes #1804. It doesn't seem correct to me that nothing is sent to the recipient when the sender cancels the ft request, but that is a different issue.
Daniel Atallah <datallah@pidgin.im>
parents:
18273
diff
changeset
|
959 | jabber_iq_remove_callback_by_id(js, jsx->iq_id); |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
960 | if (jsx->local_streamhost_fd >= 0) |
|
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
961 | close(jsx->local_streamhost_fd); |
|
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:
21646
diff
changeset
|
962 | if (jsx->connect_timeout > 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:
21646
diff
changeset
|
963 | purple_timeout_remove(jsx->connect_timeout); |
|
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:
21646
diff
changeset
|
964 | |
|
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:
21646
diff
changeset
|
965 | if (jsx->streamhosts) { |
|
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:
21646
diff
changeset
|
966 | g_list_foreach(jsx->streamhosts, jabber_si_free_streamhost, 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:
21646
diff
changeset
|
967 | g_list_free(jsx->streamhosts); |
|
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:
21646
diff
changeset
|
968 | } |
|
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:
21646
diff
changeset
|
969 | |
| 8316 | 970 | g_free(jsx->stream_id); |
| 971 | g_free(jsx->iq_id); | |
| 972 | /* XXX: free other stuff */ | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
13146
diff
changeset
|
973 | g_free(jsx->rxqueue); |
| 8316 | 974 | g_free(jsx); |
| 975 | xfer->data = NULL; | |
|
24038
5500af38bb9f
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents:
23912
diff
changeset
|
976 | |
|
22816
68013573e6aa
I've seen intermittent crashes on xmpp file transfers in this code, but I
Evan Schoenberg <evands@pidgin.im>
parents:
22328
diff
changeset
|
977 | purple_debug_info("jabber", "jabber_si_xfer_free(): freeing jsx %p", jsx); |
| 8316 | 978 | } |
| 979 | ||
| 15884 | 980 | static void jabber_si_xfer_cancel_send(PurpleXfer *xfer) |
| 8316 | 981 | { |
| 982 | jabber_si_xfer_free(xfer); | |
| 15884 | 983 | purple_debug(PURPLE_DEBUG_INFO, "jabber", "in jabber_si_xfer_cancel_send\n"); |
| 8312 | 984 | } |
| 985 | ||
| 986 | ||
| 15884 | 987 | static void jabber_si_xfer_request_denied(PurpleXfer *xfer) |
| 13146 | 988 | { |
| 989 | jabber_si_xfer_free(xfer); | |
| 15884 | 990 | purple_debug(PURPLE_DEBUG_INFO, "jabber", "in jabber_si_xfer_request_denied\n"); |
| 13146 | 991 | } |
| 992 | ||
| 993 | ||
| 15884 | 994 | static void jabber_si_xfer_cancel_recv(PurpleXfer *xfer) |
| 8312 | 995 | { |
| 8316 | 996 | jabber_si_xfer_free(xfer); |
| 15884 | 997 | purple_debug(PURPLE_DEBUG_INFO, "jabber", "in jabber_si_xfer_cancel_recv\n"); |
| 8312 | 998 | } |
| 999 | ||
| 1000 | ||
| 15884 | 1001 | static void jabber_si_xfer_end(PurpleXfer *xfer) |
| 8316 | 1002 | { |
| 1003 | jabber_si_xfer_free(xfer); | |
| 1004 | } | |
| 1005 | ||
| 1006 | ||
| 8312 | 1007 | static void jabber_si_xfer_send_disco_cb(JabberStream *js, const char *who, |
| 1008 | JabberCapabilities capabilities, gpointer data) | |
| 1009 | { | |
| 15884 | 1010 | PurpleXfer *xfer = data; |
| 8312 | 1011 | |
| 1012 | if(capabilities & JABBER_CAP_SI_FILE_XFER) { | |
| 1013 | jabber_si_xfer_send_request(xfer); | |
| 1014 | } else { | |
| 1015 | char *msg = g_strdup_printf(_("Unable to send file to %s, user does not support file transfers"), who); | |
| 15884 | 1016 | purple_notify_error(js->gc, _("File Send Failed"), |
| 8312 | 1017 | _("File Send Failed"), msg); |
| 1018 | g_free(msg); | |
| 1019 | } | |
| 1020 | } | |
| 1021 | ||
|
17424
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1022 | static void resource_select_cancel_cb(PurpleXfer *xfer, PurpleRequestFields *fields) |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1023 | { |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1024 | purple_xfer_cancel_local(xfer); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1025 | } |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1026 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1027 | static void do_transfer_send(PurpleXfer *xfer, const char *resource) |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1028 | { |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1029 | JabberSIXfer *jsx = xfer->data; |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1030 | char **who_v = g_strsplit(xfer->who, "/", 2); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1031 | char *who; |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1032 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1033 | who = g_strdup_printf("%s/%s", who_v[0], resource); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1034 | g_strfreev(who_v); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1035 | g_free(xfer->who); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1036 | xfer->who = who; |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1037 | jabber_disco_info_do(jsx->js, who, |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1038 | jabber_si_xfer_send_disco_cb, xfer); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1039 | } |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1040 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1041 | static void resource_select_ok_cb(PurpleXfer *xfer, PurpleRequestFields *fields) |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1042 | { |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1043 | PurpleRequestField *field = purple_request_fields_get_field(fields, "resource"); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1044 | int selected_id = purple_request_field_choice_get_value(field); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1045 | GList *labels = purple_request_field_choice_get_labels(field); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1046 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1047 | const char *selected_label = g_list_nth_data(labels, selected_id); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1048 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1049 | do_transfer_send(xfer, selected_label); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1050 | } |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1051 | |
| 15884 | 1052 | static void jabber_si_xfer_init(PurpleXfer *xfer) |
| 8262 | 1053 | { |
| 1054 | JabberSIXfer *jsx = xfer->data; | |
| 1055 | JabberIq *iq; | |
| 15884 | 1056 | if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { |
| 8312 | 1057 | JabberBuddy *jb; |
| 1058 | JabberBuddyResource *jbr = NULL; | |
|
17424
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1059 | char *resource; |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1060 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1061 | if(NULL != (resource = jabber_get_resource(xfer->who))) { |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1062 | /* they've specified a resource, no need to ask or |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1063 | * default or anything, just do it */ |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1064 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1065 | do_transfer_send(xfer, resource); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1066 | g_free(resource); |
|
21642
172fe34cc2d9
Prevent multiple file offers from going out with a patch from galt. Fixes #3839.
Daniel Atallah <datallah@pidgin.im>
parents:
21453
diff
changeset
|
1067 | return; |
|
17424
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1068 | } |
| 8312 | 1069 | |
| 1070 | jb = jabber_buddy_find(jsx->js, xfer->who, TRUE); | |
|
17424
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1071 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1072 | if(!jb || !jb->resources) { |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1073 | /* no resources online, we're trying to send to someone |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1074 | * whose presence we're not subscribed to, or |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1075 | * someone who is offline. Let's inform the user */ |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1076 | char *msg; |
| 8262 | 1077 | |
|
17424
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1078 | if(!jb) { |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1079 | msg = g_strdup_printf(_("Unable to send file to %s, invalid JID"), xfer->who); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1080 | } else if(jb->subscription & JABBER_SUB_TO) { |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1081 | msg = g_strdup_printf(_("Unable to send file to %s, user is not online"), xfer->who); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1082 | } else { |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1083 | msg = g_strdup_printf(_("Unable to send file to %s, not subscribed to user presence"), xfer->who); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1084 | } |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1085 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1086 | purple_notify_error(jsx->js->gc, _("File Send Failed"), _("File Send Failed"), msg); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1087 | g_free(msg); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1088 | } else if(g_list_length(jb->resources) == 1) { |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1089 | /* only 1 resource online (probably our most common case) |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1090 | * so no need to ask who to send to */ |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1091 | jbr = jb->resources->data; |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1092 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1093 | do_transfer_send(xfer, jbr->name); |
|
12935
b2d60d1890cc
[gaim-migrate @ 15288]
Richard Laager <rlaager@pidgin.im>
parents:
12909
diff
changeset
|
1094 | |
| 8312 | 1095 | } else { |
|
17424
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1096 | /* we've got multiple resources, we need to pick one to send to */ |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1097 | GList *l; |
|
22326
f44a3c53256b
I'm not sure how to disapprove a local change without it ever getting pushed... sorry for the double commit. I didn't intend to leave a trailing colon, since we didn't use punctuation at the end previously.
Evan Schoenberg <evands@pidgin.im>
parents:
22325
diff
changeset
|
1098 | char *msg = g_strdup_printf(_("Please select the resource of %s to which you would like to send a file"), xfer->who); |
|
17424
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1099 | PurpleRequestFields *fields = purple_request_fields_new(); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1100 | PurpleRequestField *field = purple_request_field_choice_new("resource", _("Resource"), 0); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1101 | PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1102 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1103 | for(l = jb->resources; l; l = l->next) |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1104 | { |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1105 | jbr = l->data; |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1106 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1107 | purple_request_field_choice_add(field, jbr->name); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1108 | } |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1109 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1110 | purple_request_field_group_add_field(group, field); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1111 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1112 | purple_request_fields_add_group(fields, group); |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1113 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1114 | purple_request_fields(jsx->js->gc, _("Select a Resource"), msg, NULL, fields, |
|
17424
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1115 | _("Send File"), G_CALLBACK(resource_select_ok_cb), _("Cancel"), G_CALLBACK(resource_select_cancel_cb), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1116 | jsx->js->gc->account, xfer->who, NULL, xfer); |
|
17424
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1117 | |
|
3fd87c1c0320
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
1118 | g_free(msg); |
| 8312 | 1119 | } |
| 1120 | } else { | |
| 1121 | xmlnode *si, *feature, *x, *field, *value; | |
| 8262 | 1122 | |
| 8312 | 1123 | iq = jabber_iq_new(jsx->js, JABBER_IQ_RESULT); |
| 1124 | xmlnode_set_attrib(iq->node, "to", xfer->who); | |
| 1125 | if(jsx->iq_id) | |
| 1126 | jabber_iq_set_id(iq, jsx->iq_id); | |
| 1127 | ||
| 10940 | 1128 | jsx->accepted = TRUE; |
| 1129 | ||
| 8312 | 1130 | si = xmlnode_new_child(iq->node, "si"); |
| 13808 | 1131 | xmlnode_set_namespace(si, "http://jabber.org/protocol/si"); |
| 8312 | 1132 | |
| 1133 | feature = xmlnode_new_child(si, "feature"); | |
| 13808 | 1134 | xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg"); |
| 8262 | 1135 | |
| 8312 | 1136 | x = xmlnode_new_child(feature, "x"); |
| 13808 | 1137 | xmlnode_set_namespace(x, "jabber:x:data"); |
| 8343 | 1138 | xmlnode_set_attrib(x, "type", "submit"); |
| 8262 | 1139 | |
| 8312 | 1140 | field = xmlnode_new_child(x, "field"); |
| 1141 | xmlnode_set_attrib(field, "var", "stream-method"); | |
| 1142 | ||
| 1143 | value = xmlnode_new_child(field, "value"); | |
| 1144 | if(jsx->stream_method & STREAM_METHOD_BYTESTREAMS) | |
| 1145 | xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1); | |
| 1146 | /* | |
| 1147 | else if(jsx->stream_method & STREAM_METHOD_IBB) | |
| 8262 | 1148 | xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1); |
| 1149 | */ | |
| 1150 | ||
| 8312 | 1151 | jabber_iq_send(iq); |
| 1152 | } | |
| 8262 | 1153 | } |
| 1154 | ||
| 15884 | 1155 | PurpleXfer *jabber_si_new_xfer(PurpleConnection *gc, const char *who) |
| 8312 | 1156 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8838
diff
changeset
|
1157 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8838
diff
changeset
|
1158 | |
| 15884 | 1159 | PurpleXfer *xfer; |
| 8312 | 1160 | JabberSIXfer *jsx; |
| 1161 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8838
diff
changeset
|
1162 | js = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8838
diff
changeset
|
1163 | |
| 15884 | 1164 | xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1165 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1166 | { |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1167 | xfer->data = jsx = g_new0(JabberSIXfer, 1); |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1168 | jsx->js = js; |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
1169 | jsx->local_streamhost_fd = -1; |
| 8262 | 1170 | |
| 15884 | 1171 | purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init); |
| 1172 | purple_xfer_set_cancel_send_fnc(xfer, jabber_si_xfer_cancel_send); | |
| 1173 | purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end); | |
| 8312 | 1174 | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1175 | js->file_transfers = g_list_append(js->file_transfers, xfer); |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1176 | } |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11656
diff
changeset
|
1177 | |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11656
diff
changeset
|
1178 | return xfer; |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11656
diff
changeset
|
1179 | } |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11656
diff
changeset
|
1180 | |
| 15884 | 1181 | void jabber_si_xfer_send(PurpleConnection *gc, const char *who, const char *file) |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11656
diff
changeset
|
1182 | { |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11656
diff
changeset
|
1183 | JabberStream *js; |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11656
diff
changeset
|
1184 | |
| 15884 | 1185 | PurpleXfer *xfer; |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11656
diff
changeset
|
1186 | |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11656
diff
changeset
|
1187 | js = gc->proto_data; |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11656
diff
changeset
|
1188 | |
|
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
11656
diff
changeset
|
1189 | xfer = jabber_si_new_xfer(gc, who); |
| 8312 | 1190 | |
|
9466
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9030
diff
changeset
|
1191 | if (file) |
| 15884 | 1192 | purple_xfer_request_accepted(xfer, file); |
|
9466
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9030
diff
changeset
|
1193 | else |
| 15884 | 1194 | purple_xfer_request(xfer); |
| 8262 | 1195 | } |
| 1196 | ||
| 1197 | void jabber_si_parse(JabberStream *js, xmlnode *packet) | |
| 1198 | { | |
| 1199 | JabberSIXfer *jsx; | |
| 15884 | 1200 | PurpleXfer *xfer; |
| 8262 | 1201 | xmlnode *si, *file, *feature, *x, *field, *option, *value; |
| 10939 | 1202 | const char *stream_id, *filename, *filesize_c, *profile, *from; |
| 8262 | 1203 | size_t filesize = 0; |
| 1204 | ||
| 1205 | if(!(si = xmlnode_get_child(packet, "si"))) | |
| 1206 | return; | |
| 1207 | ||
| 1208 | if(!(profile = xmlnode_get_attrib(si, "profile")) || | |
| 1209 | strcmp(profile, "http://jabber.org/protocol/si/profile/file-transfer")) | |
| 1210 | return; | |
| 1211 | ||
| 1212 | if(!(stream_id = xmlnode_get_attrib(si, "id"))) | |
| 1213 | return; | |
| 1214 | ||
| 1215 | if(!(file = xmlnode_get_child(si, "file"))) | |
| 1216 | return; | |
| 1217 | ||
| 1218 | if(!(filename = xmlnode_get_attrib(file, "name"))) | |
| 1219 | return; | |
| 1220 | ||
| 1221 | if((filesize_c = xmlnode_get_attrib(file, "size"))) | |
| 1222 | filesize = atoi(filesize_c); | |
| 1223 | ||
| 1224 | if(!(feature = xmlnode_get_child(si, "feature"))) | |
| 1225 | return; | |
| 1226 | ||
| 1227 | if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data"))) | |
| 1228 | return; | |
| 1229 | ||
| 10939 | 1230 | if(!(from = xmlnode_get_attrib(packet, "from"))) |
| 1231 | return; | |
| 1232 | ||
| 1233 | /* if they've already sent us this file transfer with the same damn id | |
| 1234 | * then we're gonna ignore it, until I think of something better to do | |
| 1235 | * with it */ | |
| 1236 | if((xfer = jabber_si_xfer_find(js, stream_id, from))) | |
| 1237 | return; | |
| 1238 | ||
| 8262 | 1239 | jsx = g_new0(JabberSIXfer, 1); |
|
23169
dcdd90413703
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23075
diff
changeset
|
1240 | jsx->local_streamhost_fd = -1; |
| 8262 | 1241 | |
| 1242 | for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) { | |
| 1243 | const char *var = xmlnode_get_attrib(field, "var"); | |
| 1244 | if(var && !strcmp(var, "stream-method")) { | |
| 1245 | for(option = xmlnode_get_child(field, "option"); option; | |
| 1246 | option = xmlnode_get_next_twin(option)) { | |
| 1247 | if((value = xmlnode_get_child(option, "value"))) { | |
| 1248 | char *val; | |
| 1249 | if((val = xmlnode_get_data(value))) { | |
| 1250 | if(!strcmp(val, "http://jabber.org/protocol/bytestreams")) { | |
| 1251 | jsx->stream_method |= STREAM_METHOD_BYTESTREAMS; | |
| 1252 | /* | |
| 1253 | } else if(!strcmp(val, "http://jabber.org/protocol/ibb")) { | |
| 1254 | jsx->stream_method |= STREAM_METHOD_IBB; | |
| 1255 | */ | |
| 1256 | } | |
| 1257 | g_free(val); | |
| 1258 | } | |
| 1259 | } | |
| 1260 | } | |
| 1261 | } | |
| 1262 | } | |
| 1263 | ||
| 1264 | if(jsx->stream_method == STREAM_METHOD_UNKNOWN) { | |
| 1265 | g_free(jsx); | |
| 1266 | return; | |
| 1267 | } | |
| 1268 | ||
| 1269 | jsx->js = js; | |
| 1270 | jsx->stream_id = g_strdup(stream_id); | |
| 1271 | jsx->iq_id = g_strdup(xmlnode_get_attrib(packet, "id")); | |
| 1272 | ||
| 15884 | 1273 | xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE, from); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1274 | if (xfer) |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1275 | { |
|
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1276 | xfer->data = jsx; |
| 8262 | 1277 | |
| 15884 | 1278 | purple_xfer_set_filename(xfer, filename); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1279 | if(filesize > 0) |
| 15884 | 1280 | purple_xfer_set_size(xfer, filesize); |
| 8262 | 1281 | |
| 15884 | 1282 | purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init); |
| 1283 | purple_xfer_set_request_denied_fnc(xfer, jabber_si_xfer_request_denied); | |
| 1284 | purple_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv); | |
| 1285 | purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end); | |
| 8262 | 1286 | |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1287 | js->file_transfers = g_list_append(js->file_transfers, xfer); |
| 8262 | 1288 | |
| 15884 | 1289 | purple_xfer_request(xfer); |
|
15345
797936e968ff
[gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents:
14899
diff
changeset
|
1290 | } |
| 8262 | 1291 | } |
| 1292 | ||
| 7395 | 1293 |