libpurple/protocols/jabber/si.c

Sun, 22 Jun 2008 18:59:33 +0000

author
Tobias Markmann <tfar@soc.pidgin.im>
date
Sun, 22 Jun 2008 18:59:33 +0000
branch
soc.2008.xmpp
changeset 23589
91775cc26843
parent 23434
3977bba2cc52
child 23497
d9fe9ecaabf1
permissions
-rw-r--r--

* defined JabberCapsIdentity as struct _JabberIdentity
* added jabber_caps_jabber_xdata_compare() which compares two x-data forms as required by XEP-0115

7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
2 * purple - Jabber Protocol Plugin
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 * GNU General Public License for more details.
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 *
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 *
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #include "debug.h"
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents: 8135
diff changeset
30 #include "network.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 #include "notify.h"
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33 #include "buddy.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
34 #include "disco.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 #include "jabber.h"
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36 #include "iq.h"
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 #include "si.h"
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
40
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
41 typedef struct _JabberSIXfer {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
42 JabberStream *js;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
43
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
44 PurpleProxyConnectData *connect_data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
48 gboolean accepted;
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
49
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
50 char *stream_id;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
51 char *iq_id;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
52
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
53 enum {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
54 STREAM_METHOD_UNKNOWN = 0,
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
55 STREAM_METHOD_BYTESTREAMS = 2 << 1,
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
56 STREAM_METHOD_IBB = 2 << 2,
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
57 STREAM_METHOD_UNSUPPORTED = 2 << 31
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
58 } stream_method;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
59
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
60 GList *streamhosts;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
61 PurpleProxyInfo *gpi;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
62
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
63 char *rxqueue;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
64 size_t rxlen;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
65 gsize rxmaxlen;
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
66 int local_streamhost_fd;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
67 } JabberSIXfer;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
68
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
69 static PurpleXfer*
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
70 jabber_si_xfer_find(JabberStream *js, const char *sid, const char *from)
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71 {
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
72 GList *xfers;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
73
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
74 if(!sid || !from)
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
75 return NULL;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
76
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
77 for(xfers = js->file_transfers; xfers; xfers = xfers->next) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
78 PurpleXfer *xfer = xfers->data;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79 JabberSIXfer *jsx = xfer->data;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
80 if(jsx->stream_id && xfer->who &&
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
81 !strcmp(jsx->stream_id, sid) && !strcmp(xfer->who, from))
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
82 return xfer;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
83 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
84
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
85 return NULL;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
86 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
103
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
104 static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
108 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
109 PurpleXfer *xfer = data;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110 JabberSIXfer *jsx = xfer->data;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
111 JabberIq *iq;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
114
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
130 jabber_si_bytestreams_attempt_connect(xfer);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
131 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
132 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
156
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
157 jabber_iq_send(iq);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
158
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
159 purple_xfer_start(xfer, source, NULL, -1);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
160 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
182 static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
183 {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
186 char *dstaddr, *p;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
187 int i;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
188 unsigned char hashval[20];
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
189 JabberID *dstjid;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
190
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
191 if(!jsx->streamhosts) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
192 JabberIq *iq = jabber_iq_new(jsx->js, JABBER_IQ_ERROR);
14740
7f7c3c8e14dd [gaim-migrate @ 17427]
Nathan Walp <nwalp@pidgin.im>
parents: 14561
diff changeset
193 xmlnode *error, *inf;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
194
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
195 if(jsx->iq_id)
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
196 jabber_iq_set_id(iq, jsx->iq_id);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
197
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
198 xmlnode_set_attrib(iq->node, "to", xfer->who);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
199 error = xmlnode_new_child(iq->node, "error");
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
200 xmlnode_set_attrib(error, "code", "404");
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
201 xmlnode_set_attrib(error, "type", "cancel");
14740
7f7c3c8e14dd [gaim-migrate @ 17427]
Nathan Walp <nwalp@pidgin.im>
parents: 14561
diff changeset
202 inf = xmlnode_new_child(error, "item-not-found");
7f7c3c8e14dd [gaim-migrate @ 17427]
Nathan Walp <nwalp@pidgin.im>
parents: 14561
diff changeset
203 xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas");
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
204
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
205 jabber_iq_send(iq);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
206
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
207 purple_xfer_cancel_local(xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
208
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
209 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
210 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
211
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
212 streamhost = jsx->streamhosts->data;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
219 dstjid = jabber_id_new(xfer->who);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
224 jsx->gpi = purple_proxy_info_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
225 purple_proxy_info_set_type(jsx->gpi, PURPLE_PROXY_SOCKS5);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
226 purple_proxy_info_set_host(jsx->gpi, streamhost->host);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
227 purple_proxy_info_set_port(jsx->gpi, streamhost->port);
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
237 purple_cipher_digest_region("sha1", (guchar *)dstaddr, strlen(dstaddr),
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
238 sizeof(hashval), hashval, NULL);
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
239 g_free(dstaddr);
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
240 dstaddr = g_malloc(41);
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
241 p = dstaddr;
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
242 for(i=0; i<20; i++, p+=2)
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
243 snprintf(p, 3, "%02x", hashval[i]);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
244
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
247 jabber_si_bytestreams_connect_cb, xfer);
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
248 g_free(dstaddr);
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
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
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
255 jabber_id_free(dstjid);
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
264 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
265
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
266 void jabber_bytestreams_parse(JabberStream *js, xmlnode *packet)
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
267 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
268 PurpleXfer *xfer;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
269 JabberSIXfer *jsx;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
270 xmlnode *query, *streamhost;
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14329
diff changeset
271 const char *sid, *from, *type;
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14329
diff changeset
272
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14329
diff changeset
273 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "set"))
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14329
diff changeset
274 return;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
275
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
276 if(!(from = xmlnode_get_attrib(packet, "from")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
277 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
278
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
279 if(!(query = xmlnode_get_child(packet, "query")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
280 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
281
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
282 if(!(sid = xmlnode_get_attrib(query, "sid")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
283 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
284
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
285 if(!(xfer = jabber_si_xfer_find(js, sid, from)))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
286 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
287
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
288 jsx = xfer->data;
10940
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
289
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
290 if(!jsx->accepted)
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
291 return;
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
292
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
293 if(jsx->iq_id)
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
294 g_free(jsx->iq_id);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
295 jsx->iq_id = g_strdup(xmlnode_get_attrib(packet, "id"));
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
296
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
297 for(streamhost = xmlnode_get_child(query, "streamhost"); streamhost;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
301
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
308 sh->jid = g_strdup(jid);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
309 sh->host = g_strdup(host);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
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
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
313 jsx->streamhosts = g_list_append(jsx->streamhosts, sh);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
314 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
315 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
316
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
317 jabber_si_bytestreams_attempt_connect(xfer);
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
318 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
323 PurpleInputCondition cond)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
324 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
338 purple_xfer_cancel_remote(xfer);
13441
aee36f1f8aa5 [gaim-migrate @ 15815]
Nathan Walp <nwalp@pidgin.im>
parents: 13201
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
351 /* Before actually starting sending the file, we need to wait until the
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
352 * recipient sends the IQ result with <streamhost-used/>
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
353 */
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
354 purple_debug_info("jabber", "SOCKS5 connection negotiation completed. "
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
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
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
358 static void
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
359 jabber_si_xfer_bytestreams_send_read_again_cb(gpointer data, gint source,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
360 PurpleInputCondition cond)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
361 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
362 PurpleXfer *xfer = data;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
363 JabberSIXfer *jsx = xfer->data;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
364 int i;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
365 char buffer[256];
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
366 int len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
367 char *dstaddr, *p;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
368 unsigned char hashval[20];
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
369 const char *host;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
370
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
371 purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_read_again_cb\n");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
372
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
373 if(jsx->rxlen < 5) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
379 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
380 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
381 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
382 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
383 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
384 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
385 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
386 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
387 jsx->rxlen += len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
388 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
389 } else if(jsx->rxqueue[0] != 0x05 || jsx->rxqueue[1] != 0x01 ||
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
390 jsx->rxqueue[3] != 0x03) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
391 purple_debug_info("jabber", "invalid socks5 stuff\n");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
392 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
393 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
394 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
395 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
396 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
397 } else if(jsx->rxlen - 5 < jsx->rxqueue[4] + 2) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
403 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
404 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
405 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
406 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
407 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
408 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
409 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
410 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
411 jsx->rxlen += len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
412 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
413
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
414 if(jsx->rxlen - 5 < jsx->rxqueue[4] + 2)
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
415 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
416
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
417 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
418 xfer->watcher = 0;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
419
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
420 dstaddr = g_strdup_printf("%s%s@%s/%s%s", jsx->stream_id,
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
421 jsx->js->user->node, jsx->js->user->domain,
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
422 jsx->js->user->resource, xfer->who);
10684
0325b164a7eb [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents: 10112
diff changeset
423
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
426 g_free(dstaddr);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
427 dstaddr = g_malloc(41);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
428 p = dstaddr;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
429 for(i=0; i<20; i++, p+=2)
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
430 snprintf(p, 3, "%02x", hashval[i]);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
431
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
432 if(jsx->rxqueue[4] != 40 || strncmp(dstaddr, jsx->rxqueue+5, 40) ||
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
433 jsx->rxqueue[45] != 0x00 || jsx->rxqueue[46] != 0x00) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
434 purple_debug_error("jabber", "someone connected with the wrong info!\n");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
435 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
438 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
439 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
444 host = purple_network_get_my_ip(jsx->js->fd);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
467 PurpleInputCondition cond)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
468 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
500 purple_xfer_cancel_remote(xfer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
501 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
502 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
503
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
504 static void
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
505 jabber_si_xfer_bytestreams_send_read_cb(gpointer data, gint source,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
506 PurpleInputCondition cond)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
507 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
508 PurpleXfer *xfer = data;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
509 JabberSIXfer *jsx = xfer->data;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
510 int i;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
511 int len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
512 char buffer[256];
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
513
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
514 purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_read_cb\n");
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
515
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
516 xfer->fd = source;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
517
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
518 if(jsx->rxlen < 2) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
524 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
525 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
526 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
527 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
528 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
529 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
530 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
531 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
532 jsx->rxlen += len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
533 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
534 } else if(jsx->rxlen - 2 < jsx->rxqueue[1]) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
540 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
541 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
542 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
543 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
544 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
545 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
546 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
547 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
548 jsx->rxlen += len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
549 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
550
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
551 if(jsx->rxlen -2 < jsx->rxqueue[1])
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
552 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
553
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
554 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
555 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
556
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
557 purple_debug_info("jabber", "checking to make sure we're socks FIVE\n");
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
558
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
559 if(jsx->rxqueue[0] != 0x05) {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
560 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
561 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
562 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
563 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
564
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
565 purple_debug_info("jabber", "going to test %hhu different methods\n", jsx->rxqueue[1]);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
566
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
567 for(i=0; i<jsx->rxqueue[1]; i++) {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
568
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
569 purple_debug_info("jabber", "testing %hhu\n", jsx->rxqueue[i+2]);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
570 if(jsx->rxqueue[i+2] == 0x00) {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
581 source, PURPLE_INPUT_WRITE);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
582 jsx->rxqueue = NULL;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
583 jsx->rxlen = 0;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
584 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
585 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
586 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
587
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
588 g_free(jsx->rxqueue);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
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
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
597 source, PURPLE_INPUT_WRITE);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
598 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
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
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
611 static void
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
612 jabber_si_xfer_bytestreams_send_connected_cb(gpointer data, gint source,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
613 PurpleInputCondition cond)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
614 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
615 PurpleXfer *xfer = data;
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
616 JabberSIXfer *jsx = xfer->data;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
617 int acceptfd;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
618
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
619 purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_connected_cb\n");
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
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));
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
626 /* TODO: This should cancel the ft */
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
627 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
628 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
629
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
630 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
631 close(source);
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
632 jsx->local_streamhost_fd = -1;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
633
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
634 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
635 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
636 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
637
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
638 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
639 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
640 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
641 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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 PurpleXfer *xfer = data;
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
643 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
644 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
645 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
646 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
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 /* 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
649
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
650 /* Make sure that the xfer is actually still valid and we're not just receiving an old iq response */
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
651 if (!g_list_find(js->file_transfers, xfer)) {
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
652 purple_debug_error("jabber", "Got bytestreams response for no longer existing xfer (%p)\n", xfer);
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
653 return;
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
654 }
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
655
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
656 /* In the case of a direct file transfer, this is expected to return */
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
657 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
658 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
659
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
660 jsx = xfer->data;
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
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 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result"))
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
663 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
664
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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 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
666 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
667
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
668 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
669 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
670
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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 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
672 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
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(!(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
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
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
677 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
678 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
679
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
680 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
681 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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 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
683 jsx->js->user->domain, jsx->js->user->resource);
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
684 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
685 purple_debug_info("jabber", "Got local SOCKS5 streamhost-used.\n");
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
686 purple_xfer_start(xfer, xfer->fd, NULL, -1);
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
687 } 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
688 purple_debug_info("jabber", "streamhost-used does not match any proxy that was offered to target\n");
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
689 purple_xfer_cancel_local(xfer);
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
690 }
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
691 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
692 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
693 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
695 /* Clean up the local streamhost - it isn't going to be used.*/
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
696 if (xfer->watcher > 0) {
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
697 purple_input_remove(xfer->watcher);
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
698 xfer->watcher = 0;
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
699 }
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
700 if (jsx->local_streamhost_fd >= 0) {
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
701 close(jsx->local_streamhost_fd);
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
702 jsx->local_streamhost_fd = -1;
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
703 }
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
704
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
705 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
706 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
707 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
708
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
709 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
710
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
711 jabber_si_bytestreams_attempt_connect(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
712 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
713
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
714 static void
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
715 jabber_si_xfer_bytestreams_listen_cb(int sock, gpointer data)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
716 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
717 PurpleXfer *xfer = data;
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
718 JabberSIXfer *jsx;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
719 JabberIq *iq;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
720 xmlnode *query, *streamhost;
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
721 char *jid, port[6];
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
722 const char *local_ip, *public_ip, *ft_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
723 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
724 JabberBytestreamsStreamhost *sh, *sh2;
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
725
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
726 jsx = xfer->data;
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
727 jsx->listen_data = NULL;
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
728
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
729 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
730 purple_xfer_unref(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
731 return;
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
732 }
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
733
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
734 purple_xfer_unref(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
735
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
736 if (sock < 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
737 purple_xfer_cancel_local(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
738 return;
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
739 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
740
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
741 jsx->local_streamhost_fd = sock;
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
742
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
743 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
744 "http://jabber.org/protocol/bytestreams");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
745 xmlnode_set_attrib(iq->node, "to", xfer->who);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
746 query = xmlnode_get_child(iq->node, "query");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
747
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
748 xmlnode_set_attrib(query, "sid", jsx->stream_id);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
749
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
750 jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node,
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
751 jsx->js->user->domain, jsx->js->user->resource);
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
752 xfer->local_port = purple_network_get_port_from_fd(sock);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
753 g_snprintf(port, sizeof(port), "%hu", xfer->local_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
754
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
755 /* TODO: Should there be an option to not use the local host as a ft proxy?
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
756 * (to prevent revealing IP address, etc.) */
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
757
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
758 /* Include the localhost's IP (for in-network transfers) */
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
759 local_ip = purple_network_get_local_system_ip(jsx->js->fd);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
760 if (strcmp(local_ip, "0.0.0.0") != 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
761 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
762 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
763 xmlnode_set_attrib(streamhost, "jid", 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
764 xmlnode_set_attrib(streamhost, "host", local_ip);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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 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
766 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
767
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
768 /* Include the public IP (assuming that there is a port mapped somehow) */
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
769 /* TODO: Check that it isn't the same as above and is a valid IP */
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
770 public_ip = purple_network_get_my_ip(jsx->js->fd);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
771 if (strcmp(public_ip, local_ip) != 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
772 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
773 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
774 xmlnode_set_attrib(streamhost, "jid", 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
775 xmlnode_set_attrib(streamhost, "host", public_ip);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
776 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
777 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
778
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
779 g_free(jid);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
780
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
781 /* The listener for the local proxy */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
782 xfer->watcher = purple_input_add(sock, PURPLE_INPUT_READ,
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
783 jabber_si_xfer_bytestreams_send_connected_cb, xfer);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
784
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
785 /* insert proxies here */
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
786 ft_proxies = purple_account_get_string(xfer->account, "ft_proxies", 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
787 if (ft_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
788 int i, portnum;
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
789 char *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
790 gchar **ft_proxy_list = g_strsplit(ft_proxies, ",", 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
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 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
793 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
794 jsx->streamhosts = 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
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 for(i = 0; ft_proxy_list[i]; i++) {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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 g_strstrip(ft_proxy_list[i]);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
798 if(!(*ft_proxy_list[i]))
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
799 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
800
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
801 if((tmp = strchr(ft_proxy_list[i], ':'))) {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
802 portnum = atoi(tmp + 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
803 *tmp = '\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
804 } 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
805 portnum = 7777;
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
806
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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 g_snprintf(port, sizeof(port), "%hu", portnum);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
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
809 purple_debug_info("jabber", "jabber_si_xfer_bytestreams_listen_cb() will be looking at jsx %p: jsx->streamhosts %p and ft_proxy_list[%i] %p",
68013573e6aa I've seen intermittent crashes on xmpp file transfers in this code, but I
Evan Schoenberg <evands@pidgin.im>
parents: 22328
diff changeset
810 jsx, jsx->streamhosts, i, ft_proxy_list[i]);
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
811 if(g_list_find_custom(jsx->streamhosts, ft_proxy_list[i], jabber_si_compare_jid) != NULL)
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
812 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
813
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
814 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
815 xmlnode_set_attrib(streamhost, "jid", ft_proxy_list[i]);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
816 xmlnode_set_attrib(streamhost, "host", ft_proxy_list[i]);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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 xmlnode_set_attrib(streamhost, "port", port);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
818
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
819 sh = g_new0(JabberBytestreamsStreamhost, 1);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
820 sh->jid = g_strdup(ft_proxy_list[i]);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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 sh->host = g_strdup(ft_proxy_list[i]);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
822 sh->port = portnum;
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
823
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
824 jsx->streamhosts = g_list_prepend(jsx->streamhosts, sh);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
825 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
826
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
827 g_strfreev(ft_proxy_list);
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
828 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
829
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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 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
831 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
832
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
833 /* 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
834
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
835 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
836 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
837
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
838 purple_debug_info("jabber", "jabber_si_xfer_bytestreams_listen_cb() will be looking at jsx %p: jsx->streamhosts %p and sh->jid %p",
68013573e6aa I've seen intermittent crashes on xmpp file transfers in this code, but I
Evan Schoenberg <evands@pidgin.im>
parents: 22328
diff changeset
839 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
840 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
841 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
842
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
843 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
844 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
845 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
846 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
847 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
848
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
849 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
850 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
851 sh2->host = g_strdup(sh->host);
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
852 /*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
853 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
854
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
855 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
856 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
857
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
858 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
859
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
860 jabber_iq_send(iq);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
861
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
862 }
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
863
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
864 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
865 jabber_si_xfer_bytestreams_send_init(PurpleXfer *xfer)
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
866 {
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
867 JabberSIXfer *jsx;
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
868
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
869 purple_xfer_ref(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
870
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
871 jsx = xfer->data;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
872 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
873 jabber_si_xfer_bytestreams_listen_cb, xfer);
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
874 if (jsx->listen_data == NULL) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
875 purple_xfer_unref(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
876 /* XXX: couldn't open a port, we're fscked */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
877 purple_xfer_cancel_local(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
878 return;
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
879 }
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
880
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
881 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
882
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
883 static void jabber_si_xfer_send_method_cb(JabberStream *js, xmlnode *packet,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
884 gpointer data)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
885 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
886 PurpleXfer *xfer = data;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
887 xmlnode *si, *feature, *x, *field, *value;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
888
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
889 if(!(si = xmlnode_get_child_with_namespace(packet, "si", "http://jabber.org/protocol/si"))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
890 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
891 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
892 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
893
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
894 if(!(feature = xmlnode_get_child_with_namespace(si, "feature", "http://jabber.org/protocol/feature-neg"))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
895 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
896 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
897 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
898
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
899 if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data"))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
900 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
901 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
902 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
903
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
904 for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
905 const char *var = xmlnode_get_attrib(field, "var");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
906
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
907 if(var && !strcmp(var, "stream-method")) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
908 if((value = xmlnode_get_child(field, "value"))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
909 char *val = xmlnode_get_data(value);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
910 if(val && !strcmp(val, "http://jabber.org/protocol/bytestreams")) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
911 jabber_si_xfer_bytestreams_send_init(xfer);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
912 g_free(val);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
913 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
914 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
915 g_free(val);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
916 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
917 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
918 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
919 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
920 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
921
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
922 static void jabber_si_xfer_send_request(PurpleXfer *xfer)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
923 {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
924 JabberSIXfer *jsx = xfer->data;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
925 JabberIq *iq;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
926 xmlnode *si, *file, *feature, *x, *field, *option, *value;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
927 char buf[32];
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
928
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
929 xfer->filename = g_path_get_basename(xfer->local_filename);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
930
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
931 iq = jabber_iq_new(jsx->js, JABBER_IQ_SET);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
932 xmlnode_set_attrib(iq->node, "to", xfer->who);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
933 si = xmlnode_new_child(iq->node, "si");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
934 xmlnode_set_namespace(si, "http://jabber.org/protocol/si");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
935 jsx->stream_id = jabber_get_next_id(jsx->js);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
936 xmlnode_set_attrib(si, "id", jsx->stream_id);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
937 xmlnode_set_attrib(si, "profile",
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
938 "http://jabber.org/protocol/si/profile/file-transfer");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
939
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
940 file = xmlnode_new_child(si, "file");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
941 xmlnode_set_namespace(file,
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
942 "http://jabber.org/protocol/si/profile/file-transfer");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
943 xmlnode_set_attrib(file, "name", xfer->filename);
11656
56f5e598dc6c [gaim-migrate @ 13940]
Richard Laager <rlaager@pidgin.im>
parents: 11183
diff changeset
944 g_snprintf(buf, sizeof(buf), "%" G_GSIZE_FORMAT, xfer->size);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
945 xmlnode_set_attrib(file, "size", buf);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
946 /* maybe later we'll do hash and date attribs */
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
947
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
948 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
949 xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
950 x = xmlnode_new_child(feature, "x");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
951 xmlnode_set_namespace(x, "jabber:x:data");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
952 xmlnode_set_attrib(x, "type", "form");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
953 field = xmlnode_new_child(x, "field");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
954 xmlnode_set_attrib(field, "var", "stream-method");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
955 xmlnode_set_attrib(field, "type", "list-single");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
956 option = xmlnode_new_child(field, "option");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
957 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
958 xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
959 /*
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
960 option = xmlnode_new_child(field, "option");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
961 value = xmlnode_new_child(option, "value");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
962 xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
963 */
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
964
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
965 jabber_iq_set_callback(iq, jabber_si_xfer_send_method_cb, xfer);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
966
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
967 /* 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
968 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
969 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
970
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
971 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
972 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
973
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
974 static void jabber_si_xfer_free(PurpleXfer *xfer)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
975 {
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
976 JabberSIXfer *jsx = xfer->data;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
977 JabberStream *js = jsx->js;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
978
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
979 js->file_transfers = g_list_remove(js->file_transfers, xfer);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
980
14324
8cbedd82b6ac [gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
981 if (jsx->connect_data != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
982 purple_proxy_connect_cancel(jsx->connect_data);
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
983 if (jsx->listen_data != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
984 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
985 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
986 jabber_iq_remove_callback_by_id(js, jsx->iq_id);
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
987 if (jsx->local_streamhost_fd >= 0)
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
988 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
989 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
990 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
991
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
992 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
993 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
994 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
995 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy 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
996
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
997 g_free(jsx->stream_id);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
998 g_free(jsx->iq_id);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
999 /* XXX: free other stuff */
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
1000 g_free(jsx->rxqueue);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1001 g_free(jsx);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1002 xfer->data = NULL;
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
1003
68013573e6aa I've seen intermittent crashes on xmpp file transfers in this code, but I
Evan Schoenberg <evands@pidgin.im>
parents: 22328
diff changeset
1004 purple_debug_info("jabber", "jabber_si_xfer_free(): freeing jsx %p", jsx);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1005 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1006
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1007 static void jabber_si_xfer_cancel_send(PurpleXfer *xfer)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1008 {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1009 jabber_si_xfer_free(xfer);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1010 purple_debug(PURPLE_DEBUG_INFO, "jabber", "in jabber_si_xfer_cancel_send\n");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1011 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1012
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1013
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1014 static void jabber_si_xfer_request_denied(PurpleXfer *xfer)
13146
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1015 {
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1016 jabber_si_xfer_free(xfer);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1017 purple_debug(PURPLE_DEBUG_INFO, "jabber", "in jabber_si_xfer_request_denied\n");
13146
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1018 }
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1019
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1020
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1021 static void jabber_si_xfer_cancel_recv(PurpleXfer *xfer)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1022 {
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1023 jabber_si_xfer_free(xfer);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1024 purple_debug(PURPLE_DEBUG_INFO, "jabber", "in jabber_si_xfer_cancel_recv\n");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1025 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1026
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1027
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1028 static void jabber_si_xfer_end(PurpleXfer *xfer)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1029 {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1030 jabber_si_xfer_free(xfer);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1031 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1032
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1033
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1034 static void jabber_si_xfer_send_disco_cb(JabberStream *js, const char *who,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1035 JabberCapabilities capabilities, gpointer data)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1036 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1037 PurpleXfer *xfer = data;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1038
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1039 if(capabilities & JABBER_CAP_SI_FILE_XFER) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1040 jabber_si_xfer_send_request(xfer);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1041 } else {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1042 char *msg = g_strdup_printf(_("Unable to send file to %s, user does not support file transfers"), who);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1043 purple_notify_error(js->gc, _("File Send Failed"),
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1044 _("File Send Failed"), msg);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1045 g_free(msg);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1046 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1047 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1048
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1049 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
1050 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1051 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
1052 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1053
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1054 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
1055 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1056 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
1057 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
1058 char *who;
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1059
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1060 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
1061 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
1062 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
1063 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
1064 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
1065 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
1066 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1067
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1068 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
1069 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1070 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
1071 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
1072 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
1073
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1074 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
1075
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1076 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
1077 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1078
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1079 static void jabber_si_xfer_init(PurpleXfer *xfer)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1080 {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1081 JabberSIXfer *jsx = xfer->data;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1082 JabberIq *iq;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1083 if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1084 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1085 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
1086 char *resource;
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1087
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1088 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
1089 /* 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
1090 * 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
1091
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1092 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
1093 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
1094 return;
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1095 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1096
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1097 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
1098
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1099 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
1100 /* 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
1101 * 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
1102 * 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
1103 char *msg;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1104
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1105 if(!jb) {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1106 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
1107 } 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
1108 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
1109 } else {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1110 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
1111 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1112
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1113 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
1114 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
1115 } 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
1116 /* 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
1117 * 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
1118 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
1119
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1120 do_transfer_send(xfer, jbr->name);
12935
b2d60d1890cc [gaim-migrate @ 15288]
Richard Laager <rlaager@pidgin.im>
parents: 12909
diff changeset
1121
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1122 } else {
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1123 /* 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
1124 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
1125 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
1126 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
1127 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
1128 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
1129
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1130 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
1131 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1132 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
1133
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1134 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
1135 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1136
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1137 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
1138
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1139 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
1140
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1141 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
1142 _("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
1143 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
1144
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1145 g_free(msg);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1146 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1147 } else {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1148 xmlnode *si, *feature, *x, *field, *value;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1149
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1150 iq = jabber_iq_new(jsx->js, JABBER_IQ_RESULT);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1151 xmlnode_set_attrib(iq->node, "to", xfer->who);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1152 if(jsx->iq_id)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1153 jabber_iq_set_id(iq, jsx->iq_id);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1154
10940
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
1155 jsx->accepted = TRUE;
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
1156
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1157 si = xmlnode_new_child(iq->node, "si");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
1158 xmlnode_set_namespace(si, "http://jabber.org/protocol/si");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1159
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1160 feature = xmlnode_new_child(si, "feature");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
1161 xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1162
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1163 x = xmlnode_new_child(feature, "x");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
1164 xmlnode_set_namespace(x, "jabber:x:data");
8343
842e3b8b1bd8 [gaim-migrate @ 9067]
Nathan Walp <nwalp@pidgin.im>
parents: 8316
diff changeset
1165 xmlnode_set_attrib(x, "type", "submit");
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1166
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1167 field = xmlnode_new_child(x, "field");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1168 xmlnode_set_attrib(field, "var", "stream-method");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1169
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1170 value = xmlnode_new_child(field, "value");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1171 if(jsx->stream_method & STREAM_METHOD_BYTESTREAMS)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1172 xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1173 /*
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1174 else if(jsx->stream_method & STREAM_METHOD_IBB)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1175 xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1176 */
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1177
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1178 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1179 }
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1180 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1181
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1182 PurpleXfer *jabber_si_new_xfer(PurpleConnection *gc, const char *who)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1183 {
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1184 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1185
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1186 PurpleXfer *xfer;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1187 JabberSIXfer *jsx;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1188
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1189 js = gc->proto_data;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1190
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1191 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who);
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1192 if (xfer)
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1193 {
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1194 xfer->data = jsx = g_new0(JabberSIXfer, 1);
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1195 jsx->js = js;
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
1196 jsx->local_streamhost_fd = -1;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1197
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1198 purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1199 purple_xfer_set_cancel_send_fnc(xfer, jabber_si_xfer_cancel_send);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1200 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1201
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1202 js->file_transfers = g_list_append(js->file_transfers, xfer);
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1203 }
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1204
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1205 return xfer;
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1206 }
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1207
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1208 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
1209 {
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1210 JabberStream *js;
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1211
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1212 PurpleXfer *xfer;
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1213
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1214 js = gc->proto_data;
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1215
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1216 if(!purple_find_buddy(gc->account, who) || !jabber_buddy_find(js, who, FALSE))
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1217 return;
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1218
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1219 xfer = jabber_si_new_xfer(gc, who);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1220
9466
b6425eab60ca [gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents: 9030
diff changeset
1221 if (file)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1222 purple_xfer_request_accepted(xfer, file);
9466
b6425eab60ca [gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents: 9030
diff changeset
1223 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1224 purple_xfer_request(xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1225 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1226
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1227 void jabber_si_parse(JabberStream *js, xmlnode *packet)
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1228 {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1229 JabberSIXfer *jsx;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1230 PurpleXfer *xfer;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1231 xmlnode *si, *file, *feature, *x, *field, *option, *value;
10939
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1232 const char *stream_id, *filename, *filesize_c, *profile, *from;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1233 size_t filesize = 0;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1234
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1235 if(!(si = xmlnode_get_child(packet, "si")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1236 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1237
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1238 if(!(profile = xmlnode_get_attrib(si, "profile")) ||
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1239 strcmp(profile, "http://jabber.org/protocol/si/profile/file-transfer"))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1240 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1241
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1242 if(!(stream_id = xmlnode_get_attrib(si, "id")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1243 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1244
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1245 if(!(file = xmlnode_get_child(si, "file")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1246 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1247
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1248 if(!(filename = xmlnode_get_attrib(file, "name")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1249 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1250
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1251 if((filesize_c = xmlnode_get_attrib(file, "size")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1252 filesize = atoi(filesize_c);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1253
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1254 if(!(feature = xmlnode_get_child(si, "feature")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1255 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1256
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1257 if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1258 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1259
10939
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1260 if(!(from = xmlnode_get_attrib(packet, "from")))
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1261 return;
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1262
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1263 /* if they've already sent us this file transfer with the same damn id
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1264 * then we're gonna ignore it, until I think of something better to do
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1265 * with it */
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1266 if((xfer = jabber_si_xfer_find(js, stream_id, from)))
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1267 return;
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1268
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1269 jsx = g_new0(JabberSIXfer, 1);
23434
3977bba2cc52 Don't start sending the local file until after recieving the <streamhost-used/>
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
1270 jsx->local_streamhost_fd = -1;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1271
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1272 for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1273 const char *var = xmlnode_get_attrib(field, "var");
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1274 if(var && !strcmp(var, "stream-method")) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1275 for(option = xmlnode_get_child(field, "option"); option;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1276 option = xmlnode_get_next_twin(option)) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1277 if((value = xmlnode_get_child(option, "value"))) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1278 char *val;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1279 if((val = xmlnode_get_data(value))) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1280 if(!strcmp(val, "http://jabber.org/protocol/bytestreams")) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1281 jsx->stream_method |= STREAM_METHOD_BYTESTREAMS;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1282 /*
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1283 } else if(!strcmp(val, "http://jabber.org/protocol/ibb")) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1284 jsx->stream_method |= STREAM_METHOD_IBB;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1285 */
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1286 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1287 g_free(val);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1288 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1289 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1290 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1291 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1292 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1293
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1294 if(jsx->stream_method == STREAM_METHOD_UNKNOWN) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1295 g_free(jsx);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1296 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1297 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1298
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1299 jsx->js = js;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1300 jsx->stream_id = g_strdup(stream_id);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1301 jsx->iq_id = g_strdup(xmlnode_get_attrib(packet, "id"));
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1302
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1303 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
1304 if (xfer)
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1305 {
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1306 xfer->data = jsx;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1307
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1308 purple_xfer_set_filename(xfer, filename);
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1309 if(filesize > 0)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1310 purple_xfer_set_size(xfer, filesize);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1311
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1312 purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1313 purple_xfer_set_request_denied_fnc(xfer, jabber_si_xfer_request_denied);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1314 purple_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1315 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1316
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1317 js->file_transfers = g_list_append(js->file_transfers, xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1318
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1319 purple_xfer_request(xfer);
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1320 }
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1321 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1322
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1323

mercurial