libpurple/protocols/jabber/si.c

Sat, 04 Apr 2009 07:05:23 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Sat, 04 Apr 2009 07:05:23 +0000
branch
cpw.darkrain42.xmpp.iq-handlers
changeset 26695
e0d0cc1eff29
parent 26691
208457630eae
child 26701
01ab22c2baa9
permissions
-rw-r--r--

Convert IBB parser (and everything that then stems from that) to new iq-handler

Apparently I completely missed this when propagating earlier

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"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26 #include "debug.h"
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #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
28 #include "request.h"
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents: 8135
diff changeset
29 #include "network.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include "notify.h"
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #include "buddy.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
33 #include "disco.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34 #include "jabber.h"
26020
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
35 #include "ibb.h"
7395
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;
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
66 int local_streamhost_fd;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
67
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
68 JabberIBBSession *ibb_session;
26016
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
69 guint ibb_timeout_handle;
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
70 FILE *fp;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
71 } JabberSIXfer;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
72
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
73 /* some forward declarations */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
74 static void jabber_si_xfer_ibb_send_init(JabberStream *js, PurpleXfer *xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
75
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
76 static PurpleXfer*
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
77 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
78 {
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79 GList *xfers;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
80
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
81 if(!sid || !from)
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
82 return NULL;
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 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
85 PurpleXfer *xfer = xfers->data;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
86 JabberSIXfer *jsx = xfer->data;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
87 if(jsx->stream_id && xfer->who &&
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
88 !strcmp(jsx->stream_id, sid) && !strcmp(xfer->who, from))
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
89 return xfer;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
91
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
92 return NULL;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
95 static void
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
96 jabber_si_free_streamhost(gpointer data, gpointer user_data)
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
97 {
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
98 JabberBytestreamsStreamhost *sh = data;
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
99
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
100 if(!data)
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
101 return;
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
102
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
103 g_free(sh->jid);
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
104 g_free(sh->host);
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
105 g_free(sh->zeroconf);
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
106 g_free(sh);
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
107 }
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
108
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
109
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
110
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
111 static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
112
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
113 static void
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
114 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
115 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
116 PurpleXfer *xfer = data;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
117 JabberSIXfer *jsx = xfer->data;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
118 JabberIq *iq;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
119 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
120 JabberBytestreamsStreamhost *streamhost = jsx->streamhosts->data;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
121
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
122 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
123 jsx->gpi = NULL;
14324
8cbedd82b6ac [gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
124 jsx->connect_data = NULL;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
125
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 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
127 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
128 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
129
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
130 if(source < 0) {
17643
870d08f93965 Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents: 17424
diff changeset
131 purple_debug_warning("jabber",
870d08f93965 Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents: 17424
diff changeset
132 "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
133 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
134 error_message ? error_message : "(null)");
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
135 jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost);
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
136 jabber_si_free_streamhost(streamhost, NULL);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
137 jabber_si_bytestreams_attempt_connect(xfer);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
138 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
139 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
140
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
141 /* 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
142 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
143 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
145 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
146 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
147 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
148 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
149 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
150 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
151
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 /* 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
153 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
155 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
156 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
157 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
158 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
159 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
160 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
161 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
162 }
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
163
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
164 jabber_iq_send(iq);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
165
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
166 purple_xfer_start(xfer, source, NULL, -1);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
167 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
168
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
169 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
170 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
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 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
173 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
174
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
176
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
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 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
180 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
181 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
182
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
183 /* 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
184 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
185
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
186 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
187 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
188
26016
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
189 static void
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
190 jabber_si_bytestreams_ibb_timeout_remove(JabberSIXfer *jsx)
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
191 {
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
192 if (jsx->ibb_timeout_handle) {
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
193 purple_timeout_remove(jsx->ibb_timeout_handle);
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
194 jsx->ibb_timeout_handle = 0;
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
195 }
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
196 }
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
197
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
198 static gboolean
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
199 jabber_si_bytestreams_ibb_timeout_cb(gpointer data)
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
200 {
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
201 PurpleXfer *xfer = (PurpleXfer *) data;
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
202 JabberSIXfer *jsx = xfer->data;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
203
26016
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
204 if (jsx && !jsx->ibb_session) {
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
205 purple_debug_info("jabber",
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
206 "jabber_si_bytestreams_ibb_timeout called and IBB session not set "
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
207 " up yet, cancel transfer");
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
208 jabber_si_bytestreams_ibb_timeout_remove(jsx);
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
209 purple_xfer_cancel_local(xfer);
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
210 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
211
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
212 return FALSE;
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
213 }
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
214
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
215 static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
216 {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
217 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
218 JabberBytestreamsStreamhost *streamhost;
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
219 JabberID *dstjid;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
220
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
221 if(!jsx->streamhosts) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
222 JabberIq *iq = jabber_iq_new(jsx->js, JABBER_IQ_ERROR);
14740
7f7c3c8e14dd [gaim-migrate @ 17427]
Nathan Walp <nwalp@pidgin.im>
parents: 14561
diff changeset
223 xmlnode *error, *inf;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
224
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
225 if(jsx->iq_id)
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
226 jabber_iq_set_id(iq, jsx->iq_id);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
227
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
228 xmlnode_set_attrib(iq->node, "to", xfer->who);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
229 error = xmlnode_new_child(iq->node, "error");
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
230 xmlnode_set_attrib(error, "code", "404");
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
231 xmlnode_set_attrib(error, "type", "cancel");
14740
7f7c3c8e14dd [gaim-migrate @ 17427]
Nathan Walp <nwalp@pidgin.im>
parents: 14561
diff changeset
232 inf = xmlnode_new_child(error, "item-not-found");
7f7c3c8e14dd [gaim-migrate @ 17427]
Nathan Walp <nwalp@pidgin.im>
parents: 14561
diff changeset
233 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
234
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
235 jabber_iq_send(iq);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
236
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
237 /* if IBB is available, revert to that before giving up... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
238 if (jsx->stream_method & STREAM_METHOD_IBB) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
239 /* if we are the initializer, init IBB */
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
240 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
241 "jabber_si_bytestreams_attempt_connect: "
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
242 "no streamhosts found, trying IBB\n");
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
243 /* if we are the sender, open an IBB session, but not if we already
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
244 did it, since we could have received the error <iq/> from the
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
245 receiver already... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
246 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
247 && !jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
248 jabber_si_xfer_ibb_send_init(jsx->js, xfer);
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
249 } else {
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
250 /* setup a timeout to cancel waiting for IBB open */
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
251 jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
252 jabber_si_bytestreams_ibb_timeout_cb, xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
253 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
254 /* if we are the receiver, just wait for IBB open, callback is
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
255 already set up... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
256 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
257 purple_xfer_cancel_local(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
258 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
259
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
260 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
261 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
263 streamhost = jsx->streamhosts->data;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
264
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
265 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
266 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
267 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
268 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
269
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
270 dstjid = jabber_id_new(xfer->who);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
271
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
272 /* 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
273
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
274 if(dstjid != NULL && streamhost->host && streamhost->port > 0) {
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
275 char *dstaddr, *hash;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
276 jsx->gpi = purple_proxy_info_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
277 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
278 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
279 purple_proxy_info_set_port(jsx->gpi, streamhost->port);
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
280
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
281 /* 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
282 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
283 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
284 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
285 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
286 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
287 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
288
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
289 /* Per XEP-0065, the 'host' must be SHA1(SID + from JID + to JID) */
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
290 hash = jabber_calculate_data_sha1sum(dstaddr, strlen(dstaddr));
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
291
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
292 jsx->connect_data = purple_proxy_connect_socks5(NULL, jsx->gpi,
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
293 hash, 0,
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
294 jabber_si_bytestreams_connect_cb, xfer);
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
295 g_free(hash);
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
296 g_free(dstaddr);
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
297
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
298 /* 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
299 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
300 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
301 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
302
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
303 jabber_id_free(dstjid);
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
304 }
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
305
14324
8cbedd82b6ac [gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
306 if (jsx->connect_data == NULL)
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
307 {
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
308 jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost);
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
309 jabber_si_free_streamhost(streamhost, NULL);
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
310 jabber_si_bytestreams_attempt_connect(xfer);
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
311 }
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
312 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
313
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
314 void jabber_bytestreams_parse(JabberStream *js, const char *from,
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
315 JabberIqType type, const char *id, xmlnode *query)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
316 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
317 PurpleXfer *xfer;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
318 JabberSIXfer *jsx;
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
319 xmlnode *streamhost;
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
320 const char *sid;
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14329
diff changeset
321
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
322 if(type != JABBER_IQ_SET)
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14329
diff changeset
323 return;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
324
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
325 if(!from)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
326 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
327
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
328 if(!(sid = xmlnode_get_attrib(query, "sid")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
329 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
330
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
331 if(!(xfer = jabber_si_xfer_find(js, sid, from)))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
332 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
333
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
334 jsx = xfer->data;
10940
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
335
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
336 if(!jsx->accepted)
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
337 return;
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
338
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
339 if(jsx->iq_id)
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
340 g_free(jsx->iq_id);
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
341 jsx->iq_id = g_strdup(id);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
342
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
343 for(streamhost = xmlnode_get_child(query, "streamhost"); streamhost;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
344 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
345 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
346 int portnum = 0;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
347
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
348 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
349 ((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
350 ((host = xmlnode_get_attrib(streamhost, "host")) &&
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
351 (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
352 (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
353 JabberBytestreamsStreamhost *sh = g_new0(JabberBytestreamsStreamhost, 1);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
354 sh->jid = g_strdup(jid);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
355 sh->host = g_strdup(host);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
356 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
357 sh->zeroconf = g_strdup(zeroconf);
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
358 /* 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
359 jsx->streamhosts = g_list_append(jsx->streamhosts, sh);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
360 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
361 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
362
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
363 jabber_si_bytestreams_attempt_connect(xfer);
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
364 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
365
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
366
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
367 static void
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
368 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
369 PurpleInputCondition cond)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
370 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
371 PurpleXfer *xfer = data;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
372 JabberSIXfer *jsx = xfer->data;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
373 int len;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
374
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
375 len = write(source, jsx->rxqueue + jsx->rxlen, jsx->rxmaxlen - 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;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
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);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
380 xfer->watcher = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
381 g_free(jsx->rxqueue);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
382 jsx->rxqueue = NULL;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
383 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
384 purple_xfer_cancel_remote(xfer);
13441
aee36f1f8aa5 [gaim-migrate @ 15815]
Nathan Walp <nwalp@pidgin.im>
parents: 13201
diff changeset
385 return;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
386 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
387 jsx->rxlen += len;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
388
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
389 if (jsx->rxlen < jsx->rxmaxlen)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
390 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
391
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
392 purple_input_remove(xfer->watcher);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
393 xfer->watcher = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
394 g_free(jsx->rxqueue);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
395 jsx->rxqueue = NULL;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
396
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
397 /* Before actually starting sending the file, we need to wait until the
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
398 * recipient sends the IQ result with <streamhost-used/>
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
399 */
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
400 purple_debug_info("jabber", "SOCKS5 connection negotiation completed. "
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
401 "Waiting for IQ result to start file transfer.\n");
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
402 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
403
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
404 static void
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
405 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
406 PurpleInputCondition cond)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
407 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
408 PurpleXfer *xfer = data;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
409 JabberSIXfer *jsx = xfer->data;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
410 char buffer[256];
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
411 int len;
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
412 char *dstaddr, *hash;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
413 const char *host;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
414
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
415 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
416
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
417 if(jsx->rxlen < 5) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
418 purple_debug_info("jabber", "reading the first 5 bytes\n");
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
419 len = read(source, buffer, 5 - jsx->rxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
420 if(len < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
421 return;
13788
019bc2080927 [gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents: 13493
diff changeset
422 else if(len <= 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
423 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
424 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
425 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
426 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
427 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
428 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
429 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
430 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
431 jsx->rxlen += len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
432 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
433 } else if(jsx->rxqueue[0] != 0x05 || jsx->rxqueue[1] != 0x01 ||
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
434 jsx->rxqueue[3] != 0x03) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
435 purple_debug_info("jabber", "invalid socks5 stuff\n");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
436 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
437 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
438 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
439 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
440 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
441 } 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
442 purple_debug_info("jabber", "reading umpteen more bytes\n");
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
443 len = read(source, buffer, jsx->rxqueue[4] + 5 + 2 - jsx->rxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
444 if(len < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
445 return;
13788
019bc2080927 [gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents: 13493
diff changeset
446 else if(len <= 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
447 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
448 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
449 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
450 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
451 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
452 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
453 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
454 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
455 jsx->rxlen += len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
456 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
457
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
458 if(jsx->rxlen - 5 < jsx->rxqueue[4] + 2)
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
459 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
460
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
461 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
462 xfer->watcher = 0;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
463
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
464 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
465 jsx->js->user->node, jsx->js->user->domain,
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
466 jsx->js->user->resource, xfer->who);
10684
0325b164a7eb [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents: 10112
diff changeset
467
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
468 /* Per XEP-0065, the 'host' must be SHA1(SID + from JID + to JID) */
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
469 hash = jabber_calculate_data_sha1sum(dstaddr, strlen(dstaddr));
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
470
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
471 if(jsx->rxqueue[4] != 40 || strncmp(hash, jsx->rxqueue+5, 40) ||
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
472 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
473 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
474 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
475 purple_xfer_cancel_remote(xfer);
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
476 g_free(hash);
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
477 g_free(dstaddr);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
478 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
479 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
480
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
481 g_free(hash);
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
482 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
483
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
484 g_free(jsx->rxqueue);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
485 host = purple_network_get_my_ip(jsx->js->fd);
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 jsx->rxmaxlen = 5 + strlen(host) + 2;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
488 jsx->rxqueue = g_malloc(jsx->rxmaxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
489 jsx->rxlen = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
490
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
491 jsx->rxqueue[0] = 0x05;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
492 jsx->rxqueue[1] = 0x00;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
493 jsx->rxqueue[2] = 0x00;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
494 jsx->rxqueue[3] = 0x03;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
495 jsx->rxqueue[4] = strlen(host);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
496 memcpy(jsx->rxqueue + 5, host, strlen(host));
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
497 jsx->rxqueue[5+strlen(host)] = 0x00;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
498 jsx->rxqueue[6+strlen(host)] = 0x00;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
499
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
500 xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
501 jabber_si_xfer_bytestreams_send_read_again_resp_cb, xfer);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
502 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
503 PURPLE_INPUT_WRITE);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
504 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
505
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
506 static void
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
507 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
508 PurpleInputCondition cond)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
509 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
510 PurpleXfer *xfer = data;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
511 JabberSIXfer *jsx = xfer->data;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
512 int len;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
513
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
514 len = write(source, jsx->rxqueue + jsx->rxlen, jsx->rxmaxlen - jsx->rxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
515 if (len < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
516 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
517 else if (len < 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
518 purple_input_remove(xfer->watcher);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
519 xfer->watcher = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
520 g_free(jsx->rxqueue);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
521 jsx->rxqueue = NULL;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
522 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
523 purple_xfer_cancel_remote(xfer);
13493
598d8f618a31 [gaim-migrate @ 15868]
Richard Laager <rlaager@pidgin.im>
parents: 13441
diff changeset
524 return;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
525 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
526 jsx->rxlen += len;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
527
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
528 if (jsx->rxlen < jsx->rxmaxlen)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
529 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
530
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
531 purple_input_remove(xfer->watcher);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
532 xfer->watcher = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
533
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
534 if (jsx->rxqueue[1] == 0x00) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
535 xfer->watcher = purple_input_add(source, PURPLE_INPUT_READ,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
536 jabber_si_xfer_bytestreams_send_read_again_cb, xfer);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
537 g_free(jsx->rxqueue);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
538 jsx->rxqueue = NULL;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
539 } else {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
540 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
541 purple_xfer_cancel_remote(xfer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
542 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
543 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
544
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
545 static void
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
546 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
547 PurpleInputCondition cond)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
548 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
549 PurpleXfer *xfer = data;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
550 JabberSIXfer *jsx = xfer->data;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
551 int i;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
552 int len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
553 char buffer[256];
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
554
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
555 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
556
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
557 xfer->fd = source;
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->rxlen < 2) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
560 purple_debug_info("jabber", "reading those first two bytes\n");
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
561 len = read(source, buffer, 2 - jsx->rxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
562 if(len < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
563 return;
13788
019bc2080927 [gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents: 13493
diff changeset
564 else if(len <= 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
565 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
566 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
567 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
568 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
569 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
570 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
571 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
572 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
573 jsx->rxlen += len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
574 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
575 } 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
576 purple_debug_info("jabber", "reading the next umpteen bytes\n");
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
577 len = read(source, buffer, jsx->rxqueue[1] + 2 - jsx->rxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
578 if(len < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
579 return;
13788
019bc2080927 [gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents: 13493
diff changeset
580 else if(len <= 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
581 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
582 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
583 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
584 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
585 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
586 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
587 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
588 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
589 jsx->rxlen += len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
590 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
591
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
592 if(jsx->rxlen -2 < jsx->rxqueue[1])
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
593 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
594
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
595 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
596 xfer->watcher = 0;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
597
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
598 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
599
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
600 if(jsx->rxqueue[0] != 0x05) {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
601 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
602 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
603 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
604 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
605
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
606 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
607
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
608 for(i=0; i<jsx->rxqueue[1]; i++) {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
609
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
610 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
611 if(jsx->rxqueue[i+2] == 0x00) {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
612 g_free(jsx->rxqueue);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
613 jsx->rxlen = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
614 jsx->rxmaxlen = 2;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
615 jsx->rxqueue = g_malloc(jsx->rxmaxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
616 jsx->rxqueue[0] = 0x05;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
617 jsx->rxqueue[1] = 0x00;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
618 xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
619 jabber_si_xfer_bytestreams_send_read_response_cb,
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
620 xfer);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
621 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
622 source, PURPLE_INPUT_WRITE);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
623 jsx->rxqueue = NULL;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
624 jsx->rxlen = 0;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
625 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
626 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
627 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
628
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
629 g_free(jsx->rxqueue);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
630 jsx->rxlen = 0;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
631 jsx->rxmaxlen = 2;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
632 jsx->rxqueue = g_malloc(jsx->rxmaxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
633 jsx->rxqueue[0] = 0x05;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
634 jsx->rxqueue[1] = 0xFF;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
635 xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
636 jabber_si_xfer_bytestreams_send_read_response_cb, xfer);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
637 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
638 source, PURPLE_INPUT_WRITE);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
639 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
640
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
641 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
642 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
643 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
644 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
645
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
647 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
648
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
650 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
651
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
652 static void
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
653 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
654 PurpleInputCondition cond)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
655 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
656 PurpleXfer *xfer = data;
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
657 JabberSIXfer *jsx = xfer->data;
24038
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
658 int acceptfd, flags;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
659
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
660 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
661
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
662 acceptfd = accept(source, NULL, 0);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
663 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
664 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
665 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
666 purple_debug_warning("jabber", "accept: %s\n", g_strerror(errno));
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
667 /* Don't cancel the ft - allow it to fall to the next streamhost.*/
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
668 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
669 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
670
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
671 purple_input_remove(xfer->watcher);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
672 close(source);
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
673 jsx->local_streamhost_fd = -1;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
674
24038
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
675 flags = fcntl(acceptfd, F_GETFL);
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
676 fcntl(acceptfd, F_SETFL, flags | O_NONBLOCK);
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
677 #ifndef _WIN32
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
678 fcntl(acceptfd, F_SETFD, FD_CLOEXEC);
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
679 #endif
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
680
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
681 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
682 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
683 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
684
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 static void
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
686 jabber_si_connect_proxy_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
687 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
688 xmlnode *packet, gpointer 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
689 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
690 PurpleXfer *xfer = data;
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
691 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
692 xmlnode *query, *streamhost_used;
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
693 const char *jid;
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
694 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
695
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
696 /* 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
697
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
698 /* Make sure that the xfer is actually still valid and we're not just receiving an old iq response */
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
699 if (!g_list_find(js->file_transfers, xfer)) {
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
700 purple_debug_error("jabber", "Got bytestreams response for no longer existing xfer (%p)\n", xfer);
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
701 return;
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
702 }
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
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 /* In the case of a direct file transfer, this is expected to return */
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
705 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
706 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
707
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
708 jsx = xfer->data;
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
709
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
710 if(type != JABBER_IQ_RESULT) {
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
711 purple_debug_info("jabber",
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
712 "jabber_si_xfer_connect_proxy_cb: type = error\n");
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
713 /* if IBB is available, open IBB session */
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
714 purple_debug_info("jabber",
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
715 "jabber_si_xfer_connect_proxy_cb: got error, method: %d\n",
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
716 jsx->stream_method);
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
717 if (jsx->stream_method & STREAM_METHOD_IBB) {
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
718 purple_debug_info("jabber", "IBB is possible, try it\n");
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
719 /* if we are the sender and haven't already opened an IBB
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
720 session, do so now (we might already have failed to open
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
721 the bytestream proxy ourselves when receiving this <iq/> */
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
722 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
723 && !jsx->ibb_session) {
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
724 jabber_si_xfer_ibb_send_init(js, xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
725 } else {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
726 jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
727 jabber_si_bytestreams_ibb_timeout_cb, xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
728 }
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
729 /* if we are receiver, just wait for IBB open stanza, callback
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
730 is already set up */
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
731 } else {
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
732 purple_xfer_cancel_remote(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
733 }
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
734 return;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
735 }
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
736
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
737 if (!from)
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
738 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
739
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
740 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
741 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
742
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
743 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
744 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
745
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
746 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
747 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
748
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
749 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
750 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
751
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 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
753 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
755 jsx->js->user->domain, jsx->js->user->resource);
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
756 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
757 purple_debug_info("jabber", "Got local SOCKS5 streamhost-used.\n");
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
758 purple_xfer_start(xfer, xfer->fd, NULL, -1);
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
759 } else {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
760 /* if available, try to revert to IBB... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
761 if (jsx->stream_method & STREAM_METHOD_IBB) {
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
762 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
763 "jabber_si_connect_proxy_cb: trying to revert to IBB\n");
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
764 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
765 jabber_si_xfer_ibb_send_init(jsx->js, xfer);
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
766 } else {
26016
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
767 jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
768 jabber_si_bytestreams_ibb_timeout_cb, xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
769 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
770 /* if we are the receiver, we are already set up...*/
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
771 } else {
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
772 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
773 "streamhost-used does not match any proxy that was offered to target\n");
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
774 purple_xfer_cancel_local(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
775 }
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
776 }
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
777 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
778 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
779 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
780
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
781 /* Clean up the local streamhost - it isn't going to be used.*/
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
782 if (xfer->watcher > 0) {
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
783 purple_input_remove(xfer->watcher);
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
784 xfer->watcher = 0;
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
785 }
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
786 if (jsx->local_streamhost_fd >= 0) {
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
787 close(jsx->local_streamhost_fd);
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
788 jsx->local_streamhost_fd = -1;
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
789 }
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
790
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
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
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
796
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 jabber_si_bytestreams_attempt_connect(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
798 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
799
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
800 static void
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
801 jabber_si_xfer_bytestreams_listen_cb(int sock, gpointer data)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
802 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
803 PurpleXfer *xfer = data;
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
804 JabberSIXfer *jsx;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
805 JabberIq *iq;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
806 xmlnode *query, *streamhost;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
807 char port[6];
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
808 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
809 JabberBytestreamsStreamhost *sh, *sh2;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
810 int streamhost_count = 0;
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
811
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
812 jsx = xfer->data;
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
813 jsx->listen_data = NULL;
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
814
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
815 /* I'm not sure under which conditions this can happen
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
816 * (it seems like it shouldn't be possible */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
817 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
818 purple_xfer_unref(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
819 return;
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
820 }
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
821
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
822 purple_xfer_unref(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
823
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
824 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET,
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
825 "http://jabber.org/protocol/bytestreams");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
826 xmlnode_set_attrib(iq->node, "to", xfer->who);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
827 query = xmlnode_get_child(iq->node, "query");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
828
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
829 xmlnode_set_attrib(query, "sid", jsx->stream_id);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
830
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
831 /* If we successfully started listening locally */
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
832 if (sock >= 0) {
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
833 gchar *jid;
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
834 const char *local_ip, *public_ip;
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
835
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
836 jsx->local_streamhost_fd = sock;
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
837
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
838 jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node,
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
839 jsx->js->user->domain, jsx->js->user->resource);
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
840 xfer->local_port = purple_network_get_port_from_fd(sock);
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
841 g_snprintf(port, sizeof(port), "%hu", xfer->local_port);
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
842
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
843 /* Include the localhost's IP (for in-network transfers) */
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
844 local_ip = purple_network_get_local_system_ip(jsx->js->fd);
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
845 if (strcmp(local_ip, "0.0.0.0") != 0) {
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
846 streamhost_count++;
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
847 streamhost = xmlnode_new_child(query, "streamhost");
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
848 xmlnode_set_attrib(streamhost, "jid", jid);
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
849 xmlnode_set_attrib(streamhost, "host", local_ip);
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
850 xmlnode_set_attrib(streamhost, "port", port);
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
851 }
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
852
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
853 /* Include the public IP (assuming that there is a port mapped somehow) */
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
854 public_ip = purple_network_get_my_ip(jsx->js->fd);
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
855 if (strcmp(public_ip, local_ip) != 0 && strcmp(public_ip, "0.0.0.0") != 0) {
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
856 streamhost_count++;
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
857 streamhost = xmlnode_new_child(query, "streamhost");
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
858 xmlnode_set_attrib(streamhost, "jid", jid);
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
859 xmlnode_set_attrib(streamhost, "host", public_ip);
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
860 xmlnode_set_attrib(streamhost, "port", port);
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
861 }
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
862
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
863 g_free(jid);
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
864
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
865 /* The listener for the local proxy */
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
866 xfer->watcher = purple_input_add(sock, PURPLE_INPUT_READ,
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
867 jabber_si_xfer_bytestreams_send_connected_cb, xfer);
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
868 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
869
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
870 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
871 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
872
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
873 /* 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
874
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
875 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
876 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
877
24712
134bd2024c88 Add missing newline in debug message.
Daniel Atallah <datallah@pidgin.im>
parents: 24038
diff changeset
878 purple_debug_info("jabber", "jabber_si_xfer_bytestreams_listen_cb() will be looking at jsx %p: jsx->streamhosts %p and sh->jid %p\n",
22816
68013573e6aa I've seen intermittent crashes on xmpp file transfers in this code, but I
Evan Schoenberg <evands@pidgin.im>
parents: 22328
diff changeset
879 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
880 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
881 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
882
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
883 streamhost_count++;
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
884 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
885 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
886 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
887 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
888 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
889
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
890 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
891 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
892 sh2->host = g_strdup(sh->host);
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
893 /*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
894 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
895
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
896 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
897 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
898
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
899 /* We have no way of transferring, cancel the transfer */
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
900 if (streamhost_count == 0) {
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
901 jabber_iq_free(iq);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
902
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
903 /* if available, revert to IBB */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
904 if (jsx->stream_method & STREAM_METHOD_IBB) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
905 purple_debug_info("jabber",
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
906 "jabber_si_xfer_bytestreams_listen_cb: trying to revert to IBB\n");
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
907 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
908 /* if we are the sender, init the IBB session... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
909 jabber_si_xfer_ibb_send_init(jsx->js, xfer);
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
910 } else {
26016
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
911 jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
912 jabber_si_bytestreams_ibb_timeout_cb, xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
913 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
914 /* if we are the receiver, we should just wait... the IBB open
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
915 handler has already been set up... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
916 } else {
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
917 /* We should probably notify the target,
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
918 but this really shouldn't ever happen */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
919 purple_xfer_cancel_local(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
920 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
921
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
922 return;
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
923 }
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
924
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
925 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
926
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
927 jabber_iq_send(iq);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
928
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
929 }
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
930
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
931 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
932 jabber_si_xfer_bytestreams_send_init(PurpleXfer *xfer)
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
933 {
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
934 JabberSIXfer *jsx;
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
935
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
936 purple_xfer_ref(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
937
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
938 jsx = xfer->data;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
939
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
940 /* TODO: Should there be an option to not use the local host as a ft proxy?
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
941 * (to prevent revealing IP address, etc.) */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
942 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
943 jabber_si_xfer_bytestreams_listen_cb, xfer);
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
944 if (jsx->listen_data == NULL) {
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
945 /* We couldn't open a local port. Perhaps we can use a proxy. */
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
946 jabber_si_xfer_bytestreams_listen_cb(-1, xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
947 }
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
948
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
949 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
950
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
951 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
952 jabber_si_xfer_ibb_error_cb(JabberIBBSession *sess)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
953 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
954 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
955 JabberStream *js = jabber_ibb_session_get_js(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
956 PurpleConnection *gc = js->gc;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
957 PurpleAccount *account = purple_connection_get_account(gc);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
958
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
959 purple_debug_error("jabber", "an error occured during IBB file transfer\n");
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
960 purple_xfer_error(purple_xfer_get_type(xfer), account,
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
961 jabber_ibb_session_get_who(sess),
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
962 _("An error occured on the in-band bytestream transfer\n"));
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
963 purple_xfer_cancel_remote(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
964 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
965
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
966 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
967 jabber_si_xfer_ibb_closed_cb(JabberIBBSession *sess)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
968 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
969 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
970 JabberStream *js = jabber_ibb_session_get_js(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
971 PurpleConnection *gc = js->gc;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
972 PurpleAccount *account = purple_connection_get_account(gc);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
973
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
974 purple_debug_info("jabber", "the remote user closed the transfer\n");
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
975 if (purple_xfer_get_bytes_remaining(xfer) > 0) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
976 purple_xfer_error(purple_xfer_get_type(xfer), account,
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
977 jabber_ibb_session_get_who(sess), _("Transfer was closed."));
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
978 purple_xfer_cancel_remote(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
979 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
980 purple_xfer_set_completed(xfer, TRUE);
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
981 purple_xfer_end(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
982 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
983 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
984
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
985 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
986 jabber_si_xfer_ibb_recv_data_cb(JabberIBBSession *sess, gpointer data,
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
987 gsize size)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
988 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
989 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
990 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
991
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
992 if (size <= purple_xfer_get_bytes_remaining(xfer)) {
26020
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
993 purple_debug_info("jabber", "about to write %" G_GSIZE_FORMAT " bytes from IBB stream\n",
25989
ff1398d7e183 Revert to using g_fopen (since we have a compatability define for old glibs)
Marcus Lundblad <malu@pidgin.im>
parents: 25986
diff changeset
994 size);
ff1398d7e183 Revert to using g_fopen (since we have a compatability define for old glibs)
Marcus Lundblad <malu@pidgin.im>
parents: 25986
diff changeset
995 if(!fwrite(data, size, 1, jsx->fp)) {
ff1398d7e183 Revert to using g_fopen (since we have a compatability define for old glibs)
Marcus Lundblad <malu@pidgin.im>
parents: 25986
diff changeset
996 purple_debug_error("jabber", "error writing to file\n");
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
997 purple_xfer_cancel_remote(xfer);
25989
ff1398d7e183 Revert to using g_fopen (since we have a compatability define for old glibs)
Marcus Lundblad <malu@pidgin.im>
parents: 25986
diff changeset
998 return;
ff1398d7e183 Revert to using g_fopen (since we have a compatability define for old glibs)
Marcus Lundblad <malu@pidgin.im>
parents: 25986
diff changeset
999 }
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1000 purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + size);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1001 purple_xfer_update_progress(xfer);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1002
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1003 if (purple_xfer_get_bytes_remaining(xfer) == 0) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1004 purple_xfer_set_completed(xfer, TRUE);
25995
11c38322f597 Call purple_xfer_end when ending an IBB session.
Marcus Lundblad <malu@pidgin.im>
parents: 25994
diff changeset
1005 purple_xfer_end(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1006 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1007 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1008 /* trying to write past size of file transfers negotiated size,
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1009 reject transfer to protect against malicious behaviour */
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1010 purple_debug_error("jabber",
26020
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
1011 "IBB file transfer send more data than expected\n");
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1012 purple_xfer_cancel_remote(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1013 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1014
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1015 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1016
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1017 static gboolean
26695
e0d0cc1eff29 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <darkrain42@pidgin.im>
parents: 26691
diff changeset
1018 jabber_si_xfer_ibb_open_cb(JabberStream *js, const char *who, const char *id,
e0d0cc1eff29 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <darkrain42@pidgin.im>
parents: 26691
diff changeset
1019 xmlnode *open)
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1020 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1021 const gchar *sid = xmlnode_get_attrib(open, "sid");
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1022 PurpleXfer *xfer = jabber_si_xfer_find(js, sid, who);
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1023 if (xfer) {
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1024 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1025 JabberIBBSession *sess =
26695
e0d0cc1eff29 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <darkrain42@pidgin.im>
parents: 26691
diff changeset
1026 jabber_ibb_session_create_from_xmlnode(js, who, id, open, xfer);
26033
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1027 const char *filename;
26020
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
1028
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1029 jabber_si_bytestreams_ibb_timeout_remove(jsx);
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1030
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1031 if (sess) {
26033
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1032 /* open the file to write to */
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1033 filename = purple_xfer_get_local_filename(xfer);
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1034 jsx->fp = g_fopen(filename, "wb");
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1035 if (jsx->fp == NULL) {
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1036 purple_debug_error("jabber", "failed to open file %s for writing: %s\n",
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1037 filename, g_strerror(errno));
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1038 purple_xfer_cancel_remote(xfer);
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1039 return FALSE;
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1040 }
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1041
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1042 /* setup callbacks here...*/
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1043 jabber_ibb_session_set_data_received_callback(sess,
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1044 jabber_si_xfer_ibb_recv_data_cb);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1045 jabber_ibb_session_set_closed_callback(sess,
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1046 jabber_si_xfer_ibb_closed_cb);
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1047 jabber_ibb_session_set_error_callback(sess,
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1048 jabber_si_xfer_ibb_error_cb);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1049
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1050 jsx->ibb_session = sess;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1051
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1052 /* start the transfer */
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1053 purple_xfer_start(xfer, 0, NULL, 0);
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1054 return TRUE;
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1055 } else {
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1056 /* failed to create IBB session */
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1057 purple_debug_error("jabber", "failed to create IBB session\n");
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1058 purple_xfer_cancel_remote(xfer);
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1059 return FALSE;
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1060 }
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1061 } else {
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1062 /* we got an IBB <open/> for an unknown file transfer, pass along... */
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1063 purple_debug_info("jabber",
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1064 "IBB open did not match any SI file transfer\n");
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1065 return FALSE;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1066 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1067 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1068
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1069 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1070 jabber_si_xfer_ibb_send_data(JabberIBBSession *sess)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1071 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1072 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1073 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1074 gsize remaining = purple_xfer_get_bytes_remaining(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1075 gsize packet_size = remaining < jabber_ibb_session_get_block_size(sess) ?
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1076 remaining : jabber_ibb_session_get_block_size(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1077 gpointer data = g_malloc(packet_size);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1078 int res;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1079
26020
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
1080 purple_debug_info("jabber", "IBB: about to read %" G_GSIZE_FORMAT " bytes from file %p\n",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1081 packet_size, jsx->fp);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1082 res = fread(data, packet_size, 1, jsx->fp);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1083
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1084 if (res == 1) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1085 jabber_ibb_session_send_data(sess, data, packet_size);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1086 purple_xfer_set_bytes_sent(xfer,
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1087 purple_xfer_get_bytes_sent(xfer) + packet_size);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1088 purple_xfer_update_progress(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1089 } else {
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1090 purple_debug_error("jabber",
25993
83dace21c08f Changed a debug message to refer to the correct function...
Marcus Lundblad <malu@pidgin.im>
parents: 25991
diff changeset
1091 "jabber_si_xfer_ibb_send_data: error reading from file\n");
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1092 purple_xfer_cancel_local(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1093 }
26066
Marcus Lundblad <malu@pidgin.im>
parents: 26042
diff changeset
1094 g_free(data);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1095 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1096
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1097 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1098 jabber_si_xfer_ibb_sent_cb(JabberIBBSession *sess)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1099 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1100 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1101 gsize remaining = purple_xfer_get_bytes_remaining(xfer);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1102
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1103 if (remaining == 0) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1104 /* close the session */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1105 jabber_ibb_session_close(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1106 purple_xfer_set_completed(xfer, TRUE);
25995
11c38322f597 Call purple_xfer_end when ending an IBB session.
Marcus Lundblad <malu@pidgin.im>
parents: 25994
diff changeset
1107 purple_xfer_end(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1108 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1109 /* send more... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1110 jabber_si_xfer_ibb_send_data(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1111 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1112 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1113
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1114 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1115 jabber_si_xfer_ibb_opened_cb(JabberIBBSession *sess)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1116 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1117 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1118 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
26020
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
1119 JabberStream *js = jabber_ibb_session_get_js(sess);
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
1120 PurpleConnection *gc = js->gc;
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
1121 PurpleAccount *account = purple_connection_get_account(gc);
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
1122
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1123 if (jabber_ibb_session_get_state(sess) == JABBER_IBB_SESSION_OPENED) {
26033
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1124 const char *filename = purple_xfer_get_local_filename(xfer);
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1125 jsx->fp = g_fopen(filename, "rb");
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1126 if (jsx->fp == NULL) {
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1127 purple_debug_error("jabber", "Failed to open file %s for reading: %s\n",
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1128 filename, g_strerror(errno));
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1129 purple_xfer_error(purple_xfer_get_type(xfer), account,
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1130 jabber_ibb_session_get_who(sess),
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1131 _("Failed to open the file"));
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1132 purple_xfer_cancel_local(xfer);
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1133 return;
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1134 }
b0d303e7f58c disapproval of revision '9f0db86565bf22de6f239c6dd97c42c136794681'
Marcus Lundblad <malu@pidgin.im>
parents: 26032
diff changeset
1135
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1136 purple_xfer_start(xfer, 0, NULL, 0);
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1137 purple_xfer_set_bytes_sent(xfer, 0);
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1138 purple_xfer_update_progress(xfer);
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1139 jabber_si_xfer_ibb_send_data(sess);
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1140 } else {
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1141 /* error */
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1142 purple_xfer_error(purple_xfer_get_type(xfer), account,
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1143 jabber_ibb_session_get_who(sess),
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1144 _("Failed to open in-band bytestream"));
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1145 purple_xfer_end(xfer);
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1146 }
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1147 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1148
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1149 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1150 jabber_si_xfer_ibb_send_init(JabberStream *js, PurpleXfer *xfer)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1151 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1152 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1153
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1154 purple_xfer_ref(xfer);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1155
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1156 jsx->ibb_session = jabber_ibb_session_create(js, jsx->stream_id,
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1157 purple_xfer_get_remote_user(xfer), xfer);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1158
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1159 if (jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1160 /* should set callbacks here... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1161 jabber_ibb_session_set_opened_callback(jsx->ibb_session,
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1162 jabber_si_xfer_ibb_opened_cb);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1163 jabber_ibb_session_set_data_sent_callback(jsx->ibb_session,
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1164 jabber_si_xfer_ibb_sent_cb);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1165 jabber_ibb_session_set_closed_callback(jsx->ibb_session,
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1166 jabber_si_xfer_ibb_closed_cb);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1167 jabber_ibb_session_set_error_callback(jsx->ibb_session,
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1168 jabber_si_xfer_ibb_error_cb);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1169
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1170 /* open the IBB session */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1171 jabber_ibb_session_open(jsx->ibb_session);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1172
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1173 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1174 /* failed to create IBB session */
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1175 purple_debug_error("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1176 "failed to initiate IBB session for file transfer\n");
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1177 purple_xfer_cancel_local(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1178 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1179 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1180
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1181 static void jabber_si_xfer_send_method_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1182 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1183 xmlnode *packet, gpointer data)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1184 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1185 PurpleXfer *xfer = data;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1186 xmlnode *si, *feature, *x, *field, *value;
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1187 gboolean found_method = FALSE;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1188
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1189 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
1190 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1191 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1192 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1193
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1194 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
1195 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1196 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1197 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1198
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1199 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
1200 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1201 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1202 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1203
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1204 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
1205 const char *var = xmlnode_get_attrib(field, "var");
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1206 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1207
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1208 if(var && !strcmp(var, "stream-method")) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1209 if((value = xmlnode_get_child(field, "value"))) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1210 char *val = xmlnode_get_data(value);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1211 if(val && !strcmp(val, "http://jabber.org/protocol/bytestreams")) {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1212 jabber_si_xfer_bytestreams_send_init(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1213 jsx->stream_method |= STREAM_METHOD_BYTESTREAMS;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1214 found_method = TRUE;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1215 } else if (val && !strcmp(val, XEP_0047_NAMESPACE)) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1216 jsx->stream_method |= STREAM_METHOD_IBB;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1217 if (!found_method) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1218 /* we haven't tried to init a bytestream session, yet
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1219 start IBB right away... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1220 jabber_si_xfer_ibb_send_init(js, xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1221 found_method = TRUE;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1222 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1223 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1224 g_free(val);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1225 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1226 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1227 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1228
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1229 if (!found_method) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1230 purple_xfer_cancel_remote(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1231 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1232
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1233 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1234
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1235 static void jabber_si_xfer_send_request(PurpleXfer *xfer)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1236 {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1237 JabberSIXfer *jsx = xfer->data;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1238 JabberIq *iq;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1239 xmlnode *si, *file, *feature, *x, *field, *option, *value;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1240 char buf[32];
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1241
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1242 xfer->filename = g_path_get_basename(xfer->local_filename);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1243
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1244 iq = jabber_iq_new(jsx->js, JABBER_IQ_SET);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1245 xmlnode_set_attrib(iq->node, "to", xfer->who);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1246 si = xmlnode_new_child(iq->node, "si");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
1247 xmlnode_set_namespace(si, "http://jabber.org/protocol/si");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1248 jsx->stream_id = jabber_get_next_id(jsx->js);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1249 xmlnode_set_attrib(si, "id", jsx->stream_id);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1250 xmlnode_set_attrib(si, "profile",
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1251 "http://jabber.org/protocol/si/profile/file-transfer");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1252
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1253 file = xmlnode_new_child(si, "file");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
1254 xmlnode_set_namespace(file,
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1255 "http://jabber.org/protocol/si/profile/file-transfer");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1256 xmlnode_set_attrib(file, "name", xfer->filename);
11656
56f5e598dc6c [gaim-migrate @ 13940]
Richard Laager <rlaager@pidgin.im>
parents: 11183
diff changeset
1257 g_snprintf(buf, sizeof(buf), "%" G_GSIZE_FORMAT, xfer->size);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1258 xmlnode_set_attrib(file, "size", buf);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1259 /* maybe later we'll do hash and date attribs */
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1260
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1261 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
1262 xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1263 x = xmlnode_new_child(feature, "x");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
1264 xmlnode_set_namespace(x, "jabber:x:data");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1265 xmlnode_set_attrib(x, "type", "form");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1266 field = xmlnode_new_child(x, "field");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1267 xmlnode_set_attrib(field, "var", "stream-method");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1268 xmlnode_set_attrib(field, "type", "list-single");
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
1269 /* maybe we should add an option to always skip bytestreams for people
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
1270 behind troublesome firewalls */
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1271 option = xmlnode_new_child(field, "option");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1272 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
1273 xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1274 option = xmlnode_new_child(field, "option");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1275 value = xmlnode_new_child(option, "value");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1276 xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1277
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1278 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
1279
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
1280 /* 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
1281 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
1282 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
1283
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1284 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1285 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1286
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1287 static void jabber_si_xfer_free(PurpleXfer *xfer)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1288 {
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1289 JabberSIXfer *jsx = xfer->data;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1290
25994
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1291 if (jsx) {
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1292 JabberStream *js = jsx->js;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1293
25994
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1294 js->file_transfers = g_list_remove(js->file_transfers, xfer);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1295
25994
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1296 if (jsx->connect_data != NULL)
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1297 purple_proxy_connect_cancel(jsx->connect_data);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1298 if (jsx->listen_data != NULL)
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1299 purple_network_listen_cancel(jsx->listen_data);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1300 if (jsx->iq_id != NULL)
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1301 jabber_iq_remove_callback_by_id(js, jsx->iq_id);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1302 if (jsx->local_streamhost_fd >= 0)
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1303 close(jsx->local_streamhost_fd);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1304 if (jsx->connect_timeout > 0)
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1305 purple_timeout_remove(jsx->connect_timeout);
26016
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
1306 if (jsx->ibb_timeout_handle > 0)
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
1307 purple_timeout_remove(jsx->ibb_timeout_handle);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1308
25994
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1309 if (jsx->streamhosts) {
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1310 g_list_foreach(jsx->streamhosts, jabber_si_free_streamhost, NULL);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1311 g_list_free(jsx->streamhosts);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1312 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1313
25994
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1314 if (jsx->ibb_session) {
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1315 purple_debug_info("jabber",
25994
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1316 "jabber_si_xfer_free: destroying IBB session\n");
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1317 jabber_ibb_session_destroy(jsx->ibb_session);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1318 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1319
25994
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1320 if (jsx->fp) {
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1321 purple_debug_info("jabber",
25994
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1322 "jabber_si_xfer_free: closing file for IBB transfer\n");
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1323 fclose(jsx->fp);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1324 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1325
25994
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1326 g_free(jsx->stream_id);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1327 g_free(jsx->iq_id);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1328 /* XXX: free other stuff */
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1329 g_free(jsx->rxqueue);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1330 g_free(jsx);
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1331 xfer->data = 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
1332
25994
0ddbd6b50f99 Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <malu@pidgin.im>
parents: 25993
diff changeset
1333 purple_debug_info("jabber", "jabber_si_xfer_free(): freeing jsx %p\n", 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
1334 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1335 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1336
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1337 /*
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1338 * These four functions should only be called from the PurpleXfer functions
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1339 * (typically purple_xfer_cancel_(remote|local), purple_xfer_end, or
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1340 * purple_xfer_request_denied.
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1341 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1342 static void jabber_si_xfer_cancel_send(PurpleXfer *xfer)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1343 {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1344 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1345
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1346 /* if there is an IBB session active, send close on that */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1347 if (jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1348 jabber_ibb_session_close(jsx->ibb_session);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1349 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1350 jabber_si_xfer_free(xfer);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1351 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
1352 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1353
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1354
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1355 static void jabber_si_xfer_request_denied(PurpleXfer *xfer)
13146
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1356 {
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1357 jabber_si_xfer_free(xfer);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1358 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
1359 }
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1360
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1361
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1362 static void jabber_si_xfer_cancel_recv(PurpleXfer *xfer)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1363 {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1364 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1365 /* if there is an IBB session active, send close */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1366 if (jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1367 jabber_ibb_session_close(jsx->ibb_session);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1368 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1369 jabber_si_xfer_free(xfer);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1370 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
1371 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1372
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1373
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1374 static void jabber_si_xfer_end(PurpleXfer *xfer)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1375 {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1376 jabber_si_xfer_free(xfer);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1377 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1378
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1379
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1380 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
1381 JabberCapabilities capabilities, gpointer data)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1382 {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1383 PurpleXfer *xfer = (PurpleXfer *) data;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1384 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1385
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1386 if (capabilities & JABBER_CAP_IBB) {
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1387 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1388 "jabber_si_xfer_send_disco_cb: remote JID supports IBB\n");
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1389 jsx->stream_method |= STREAM_METHOD_IBB;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1390 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1391
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1392 if (capabilities & JABBER_CAP_SI_FILE_XFER) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1393 jabber_si_xfer_send_request(xfer);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1394 } else {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1395 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
1396 purple_notify_error(js->gc, _("File Send Failed"),
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1397 _("File Send Failed"), msg);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1398 g_free(msg);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1399 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1400 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1401
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1402 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
1403 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1404 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
1405 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1406
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1407 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
1408 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1409 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
1410 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
1411 char *who;
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1412
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1413 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
1414 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
1415 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
1416 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
1417 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
1418 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
1419 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1420
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1421 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
1422 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1423 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
1424 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
1425 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
1426
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1427 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
1428
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1429 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
1430 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1431
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1432 static void jabber_si_xfer_init(PurpleXfer *xfer)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1433 {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1434 JabberSIXfer *jsx = xfer->data;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1435 JabberIq *iq;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1436 if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1437 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1438 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
1439 char *resource;
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1440
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1441 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
1442 /* 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
1443 * 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
1444
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1445 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
1446 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
1447 return;
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1448 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1449
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1450 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
1451
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1452 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
1453 /* 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
1454 * 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
1455 * 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
1456 char *msg;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1457
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1458 if(!jb) {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1459 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
1460 } 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
1461 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
1462 } else {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1463 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
1464 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1465
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1466 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
1467 g_free(msg);
24816
bd870d9ff0ab The other day while struct hiding, I noticed a for loop that was checking
Richard Laager <rlaager@pidgin.im>
parents: 24712
diff changeset
1468 } else if(!jb->resources->next) {
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1469 /* 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
1470 * 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
1471 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
1472
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1473 do_transfer_send(xfer, jbr->name);
12935
b2d60d1890cc [gaim-migrate @ 15288]
Richard Laager <rlaager@pidgin.im>
parents: 12909
diff changeset
1474
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1475 } else {
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1476 /* 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
1477 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
1478 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
1479 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
1480 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
1481 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
1482
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1483 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
1484 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1485 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
1486
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1487 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
1488 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1489
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1490 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
1491
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1492 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
1493
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1494 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
1495 _("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
1496 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
1497
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1498 g_free(msg);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1499 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1500 } else {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1501 xmlnode *si, *feature, *x, *field, *value;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1502
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1503 iq = jabber_iq_new(jsx->js, JABBER_IQ_RESULT);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1504 xmlnode_set_attrib(iq->node, "to", xfer->who);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1505 if(jsx->iq_id)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1506 jabber_iq_set_id(iq, jsx->iq_id);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1507
10940
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
1508 jsx->accepted = TRUE;
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
1509
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1510 si = xmlnode_new_child(iq->node, "si");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
1511 xmlnode_set_namespace(si, "http://jabber.org/protocol/si");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1512
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1513 feature = xmlnode_new_child(si, "feature");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
1514 xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1515
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1516 x = xmlnode_new_child(feature, "x");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13788
diff changeset
1517 xmlnode_set_namespace(x, "jabber:x:data");
8343
842e3b8b1bd8 [gaim-migrate @ 9067]
Nathan Walp <nwalp@pidgin.im>
parents: 8316
diff changeset
1518 xmlnode_set_attrib(x, "type", "submit");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1519 field = xmlnode_new_child(x, "field");
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1520 xmlnode_set_attrib(field, "var", "stream-method");
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1521
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1522 /* we should maybe "remember" if bytestreams has failed before (in the
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1523 same session) with this JID, and only present IBB as an option to
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1524 avoid unnessesary timeout */
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
1525 /* maybe we should have an account option to always just try IBB
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
1526 for people who know their firewalls are very restrictive */
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1527 if (jsx->stream_method & STREAM_METHOD_BYTESTREAMS) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1528 value = xmlnode_new_child(field, "value");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1529 xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1530 } else if(jsx->stream_method & STREAM_METHOD_IBB) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1531 value = xmlnode_new_child(field, "value");
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1532 xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1533 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1534
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1535 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1536 }
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1537 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1538
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1539 PurpleXfer *jabber_si_new_xfer(PurpleConnection *gc, const char *who)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1540 {
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1541 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1542
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1543 PurpleXfer *xfer;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1544 JabberSIXfer *jsx;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1545
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1546 js = gc->proto_data;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1547
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1548 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who);
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1549 if (xfer)
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1550 {
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1551 xfer->data = jsx = g_new0(JabberSIXfer, 1);
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1552 jsx->js = js;
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
1553 jsx->local_streamhost_fd = -1;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1554
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1555 jsx->ibb_session = NULL;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1556 jsx->fp = NULL;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1557
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1558 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
1559 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
1560 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1561
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1562 js->file_transfers = g_list_append(js->file_transfers, xfer);
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1563 }
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1564
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1565 return xfer;
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1566 }
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1567
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1568 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
1569 {
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1570 JabberStream *js;
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1571
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1572 PurpleXfer *xfer;
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1573
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1574 js = gc->proto_data;
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1575
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1576 xfer = jabber_si_new_xfer(gc, who);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1577
9466
b6425eab60ca [gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents: 9030
diff changeset
1578 if (file)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1579 purple_xfer_request_accepted(xfer, file);
9466
b6425eab60ca [gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents: 9030
diff changeset
1580 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1581 purple_xfer_request(xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1582 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1583
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
1584 void jabber_si_parse(JabberStream *js, const char *from, JabberIqType type,
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
1585 const char *id, xmlnode *si)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1586 {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1587 JabberSIXfer *jsx;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1588 PurpleXfer *xfer;
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
1589 xmlnode *file, *feature, *x, *field, *option, *value;
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
1590 const char *stream_id, *filename, *filesize_c, *profile;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1591 size_t filesize = 0;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1592
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1593 if(!(profile = xmlnode_get_attrib(si, "profile")) ||
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1594 strcmp(profile, "http://jabber.org/protocol/si/profile/file-transfer"))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1595 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1596
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1597 if(!(stream_id = xmlnode_get_attrib(si, "id")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1598 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1599
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1600 if(!(file = xmlnode_get_child(si, "file")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1601 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1602
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1603 if(!(filename = xmlnode_get_attrib(file, "name")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1604 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1605
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1606 if((filesize_c = xmlnode_get_attrib(file, "size")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1607 filesize = atoi(filesize_c);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1608
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1609 if(!(feature = xmlnode_get_child(si, "feature")))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1610 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1611
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1612 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
1613 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1614
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
1615 if(!from)
10939
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1616 return;
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1617
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1618 /* 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
1619 * 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
1620 * with it */
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1621 if((xfer = jabber_si_xfer_find(js, stream_id, from)))
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1622 return;
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1623
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1624 jsx = g_new0(JabberSIXfer, 1);
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
1625 jsx->local_streamhost_fd = -1;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1626
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1627 jsx->ibb_session = NULL;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1628
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1629 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
1630 const char *var = xmlnode_get_attrib(field, "var");
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1631 if(var && !strcmp(var, "stream-method")) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1632 for(option = xmlnode_get_child(field, "option"); option;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1633 option = xmlnode_get_next_twin(option)) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1634 if((value = xmlnode_get_child(option, "value"))) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1635 char *val;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1636 if((val = xmlnode_get_data(value))) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1637 if(!strcmp(val, "http://jabber.org/protocol/bytestreams")) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1638 jsx->stream_method |= STREAM_METHOD_BYTESTREAMS;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1639 } else if(!strcmp(val, "http://jabber.org/protocol/ibb")) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1640 jsx->stream_method |= STREAM_METHOD_IBB;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1641 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1642 g_free(val);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1643 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1644 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1645 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1646 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1647 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1648
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1649 if(jsx->stream_method == STREAM_METHOD_UNKNOWN) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1650 g_free(jsx);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1651 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1652 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1653
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1654 jsx->js = js;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1655 jsx->stream_id = g_strdup(stream_id);
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
1656 jsx->iq_id = g_strdup(id);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1657
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1658 xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE, from);
26564
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1659 g_return_if_fail(xfer != NULL);
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1660
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1661 xfer->data = jsx;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1662
26564
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1663 purple_xfer_set_filename(xfer, filename);
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1664 if(filesize > 0)
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1665 purple_xfer_set_size(xfer, filesize);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1666
26564
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1667 purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init);
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1668 purple_xfer_set_request_denied_fnc(xfer, jabber_si_xfer_request_denied);
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1669 purple_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv);
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1670 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1671
26564
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1672 js->file_transfers = g_list_append(js->file_transfers, xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1673
26564
aa5fe0a2ce4a purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <markdoliner@pidgin.im>
parents: 26066
diff changeset
1674 purple_xfer_request(xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1675 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1676
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1677 void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1678 jabber_si_init(void)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1679 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1680 jabber_ibb_register_open_handler(jabber_si_xfer_ibb_open_cb);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1681 }
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1682
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1683 void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1684 jabber_si_uninit(void)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1685 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1686 jabber_ibb_unregister_open_handler(jabber_si_xfer_ibb_open_cb);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1687 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1688

mercurial