libpurple/protocols/jabber/si.c

Mon, 10 Feb 2014 16:22:00 +0530

author
Ankit Vani <a@nevitus.org>
date
Mon, 10 Feb 2014 16:22:00 +0530
branch
soc.2013.gobjectification.plugins
changeset 37108
73c5fb6d78b3
parent 37075
cf3f735b09b7
child 37144
8b63b9948107
permissions
-rw-r--r--

Merged default branch

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 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28157
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28157
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28157
diff changeset
6 * source distribution.
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 *
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * 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
10 * the Free Software Foundation; either version 2 of the License, or
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 *
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
16 *
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * GNU General Public License for more details.
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 *
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 * 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
21 * 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
22 *
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 */
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 "internal.h"
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
26
34706
02cb08146888 Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents: 34529
diff changeset
27 #include "buddylist.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 #include "debug.h"
34910
60502558e400 Replacements for the GObject Xfer API
Ankit Vani <a@nevitus.org>
parents: 34889
diff changeset
29 #include "xfer.h"
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
30 #include "request.h"
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents: 8135
diff changeset
31 #include "network.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #include "notify.h"
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34 #include "buddy.h"
27424
c19f67250659 Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <malu@pidgin.im>
parents: 27420
diff changeset
35 #include "data.h"
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
36 #include "disco.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 #include "jabber.h"
26020
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
38 #include "ibb.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39 #include "iq.h"
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40 #include "si.h"
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41
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
42 #define STREAMHOST_CONNECT_TIMEOUT 15
30422
a078ddc2e9e1 woops, this should remain de-activated for a while yet... :)
Marcus Lundblad <malu@pidgin.im>
parents: 30421
diff changeset
43 #define ENABLE_FT_THUMBNAILS 0
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
44
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
45 typedef struct _JabberSIXfer {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
46 JabberStream *js;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
47
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
48 PurpleProxyConnectData *connect_data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
49 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
50 guint connect_timeout;
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
51
10940
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
52 gboolean accepted;
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
53
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
54 char *stream_id;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
55 char *iq_id;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
56
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
57 enum {
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
58 STREAM_METHOD_UNKNOWN = 0,
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
59 STREAM_METHOD_BYTESTREAMS = 2 << 1,
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
60 STREAM_METHOD_IBB = 2 << 2,
34457
a9d3726c3a8f Clang warnings: clean up libpurple
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
61 STREAM_METHOD_UNSUPPORTED = 2 << 30
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
62 } stream_method;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
63
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
64 GList *streamhosts;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
65 PurpleProxyInfo *gpi;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
66
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
67 char *rxqueue;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
68 size_t rxlen;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
69 gsize rxmaxlen;
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
70 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
71
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
72 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
73 guint ibb_timeout_handle;
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
74 PurpleCircularBuffer *ibb_buffer;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
75 } JabberSIXfer;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
76
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
77 /* some forward declarations */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
78 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
79
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
80 static PurpleXfer*
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
81 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
82 {
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
83 GList *xfers;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
84
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
85 if(!sid || !from)
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
86 return NULL;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
87
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
88 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
89 PurpleXfer *xfer = xfers->data;
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
90 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
91 if(jsx->stream_id && purple_xfer_get_remote_user(xfer) &&
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
92 !strcmp(jsx->stream_id, sid) && !strcmp(purple_xfer_get_remote_user(xfer), from))
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 return xfer;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
96 return NULL;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
97 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
98
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
99 static void
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
100 jabber_si_free_streamhost(gpointer data, gpointer user_data)
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
101 {
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
102 JabberBytestreamsStreamhost *sh = data;
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
103
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
104 if(!data)
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
105 return;
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
106
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
107 g_free(sh->jid);
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
108 g_free(sh->host);
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
109 g_free(sh->zeroconf);
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
110 g_free(sh);
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
111 }
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
112
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
113
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
114
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
115 static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
116
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
117 static void
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
118 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
119 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
120 PurpleXfer *xfer = data;
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
121 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
122 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
123 PurpleXmlNode *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
124 JabberBytestreamsStreamhost *streamhost = jsx->streamhosts->data;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
125
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
126 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
127 jsx->gpi = NULL;
14324
8cbedd82b6ac [gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
128 jsx->connect_data = NULL;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
129
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
130 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
131 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
132 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
133
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
134 if(source < 0) {
17643
870d08f93965 Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents: 17424
diff changeset
135 purple_debug_warning("jabber",
870d08f93965 Better error message for when a Jabber connection fails
Mark Doliner <markdoliner@pidgin.im>
parents: 17424
diff changeset
136 "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
137 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
138 error_message ? error_message : "(null)");
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
139 jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost);
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
140 jabber_si_free_streamhost(streamhost, NULL);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
141 jabber_si_bytestreams_attempt_connect(xfer);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
142 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
143 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
144
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
145 /* unknown file transfer type is assumed to be RECEIVE */
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
146 if(purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND)
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
147 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
148 PurpleXmlNode *activate;
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
149 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, NS_BYTESTREAMS);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
150 purple_xmlnode_set_attrib(iq->node, "to", streamhost->jid);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
151 query = purple_xmlnode_get_child(iq->node, "query");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
152 purple_xmlnode_set_attrib(query, "sid", jsx->stream_id);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
153 activate = purple_xmlnode_new_child(query, "activate");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
154 purple_xmlnode_insert_data(activate, purple_xfer_get_remote_user(xfer), -1);
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
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 /* 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
157 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
159 {
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
160 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_RESULT, NS_BYTESTREAMS);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
161 purple_xmlnode_set_attrib(iq->node, "to", purple_xfer_get_remote_user(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
162 jabber_iq_set_id(iq, jsx->iq_id);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
163 query = purple_xmlnode_get_child(iq->node, "query");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
164 su = purple_xmlnode_new_child(query, "streamhost-used");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
165 purple_xmlnode_set_attrib(su, "jid", 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
166 }
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 jabber_iq_send(iq);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
169
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
170 purple_xfer_start(xfer, source, NULL, -1);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
171 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
172
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
173 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
174 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
175 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
176 PurpleXfer *xfer = data;
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
177 JabberSIXfer *jsx = purple_xfer_get_protocol_data(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
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 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
180
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
181 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
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 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
184 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
185 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
186
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 /* 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
188 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
189
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
190 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
191 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
192
26016
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
193 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
194 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
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 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
197 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
198 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
199 }
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
200 }
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
201
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
202 static gboolean
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
203 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
204 {
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
205 PurpleXfer *xfer = (PurpleXfer *) data;
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
206 JabberSIXfer *jsx = purple_xfer_get_protocol_data(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
207
26016
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
208 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
209 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
210 "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
211 " up yet, cancel transfer");
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
212 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
213 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
214 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
215
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
216 return FALSE;
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
217 }
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
218
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
219 static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
220 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
221 JabberSIXfer *jsx = purple_xfer_get_protocol_data(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
222 JabberBytestreamsStreamhost *streamhost;
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
223 JabberID *dstjid;
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->streamhosts) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
226 JabberIq *iq = jabber_iq_new(jsx->js, JABBER_IQ_ERROR);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
227 PurpleXmlNode *error, *inf;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
228
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
229 if(jsx->iq_id)
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
230 jabber_iq_set_id(iq, jsx->iq_id);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
231
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
232 purple_xmlnode_set_attrib(iq->node, "to", purple_xfer_get_remote_user(xfer));
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
233 error = purple_xmlnode_new_child(iq->node, "error");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
234 purple_xmlnode_set_attrib(error, "code", "404");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
235 purple_xmlnode_set_attrib(error, "type", "cancel");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
236 inf = purple_xmlnode_new_child(error, "item-not-found");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
237 purple_xmlnode_set_namespace(inf, NS_XMPP_STANZAS);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
238
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
239 jabber_iq_send(iq);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
240
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
241 /* 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
242 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
243 /* 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
244 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
245 "jabber_si_bytestreams_attempt_connect: "
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
246 "no streamhosts found, trying IBB\n");
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
247 /* 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
248 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
249 receiver already... */
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
250 if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
251 && !jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
252 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
253 } else {
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
254 /* 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
255 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
256 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
257 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
258 /* 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
259 already set up... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
260 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
261 purple_xfer_cancel_local(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
262 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
263
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
264 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
265 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
266
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
267 streamhost = jsx->streamhosts->data;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
268
33792
3f47965d439f Possibly fix the crash mentioned in #15067.
Mark Doliner <mark@kingant.net>
parents: 32703
diff changeset
269 if (jsx->connect_data) {
3f47965d439f Possibly fix the crash mentioned in #15067.
Mark Doliner <mark@kingant.net>
parents: 32703
diff changeset
270 purple_debug_info("jabber",
3f47965d439f Possibly fix the crash mentioned in #15067.
Mark Doliner <mark@kingant.net>
parents: 32703
diff changeset
271 "jabber_si_bytestreams_attempt_connect: "
3f47965d439f Possibly fix the crash mentioned in #15067.
Mark Doliner <mark@kingant.net>
parents: 32703
diff changeset
272 "cancelling existing connection attempt and restarting\n");
3f47965d439f Possibly fix the crash mentioned in #15067.
Mark Doliner <mark@kingant.net>
parents: 32703
diff changeset
273 purple_proxy_connect_cancel(jsx->connect_data);
3f47965d439f Possibly fix the crash mentioned in #15067.
Mark Doliner <mark@kingant.net>
parents: 32703
diff changeset
274 jsx->connect_data = NULL;
3f47965d439f Possibly fix the crash mentioned in #15067.
Mark Doliner <mark@kingant.net>
parents: 32703
diff changeset
275 if (jsx->connect_timeout > 0)
3f47965d439f Possibly fix the crash mentioned in #15067.
Mark Doliner <mark@kingant.net>
parents: 32703
diff changeset
276 purple_timeout_remove(jsx->connect_timeout);
3f47965d439f Possibly fix the crash mentioned in #15067.
Mark Doliner <mark@kingant.net>
parents: 32703
diff changeset
277 jsx->connect_timeout = 0;
3f47965d439f Possibly fix the crash mentioned in #15067.
Mark Doliner <mark@kingant.net>
parents: 32703
diff changeset
278 }
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
279 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
280 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
281 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
282
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
283 dstjid = jabber_id_new(purple_xfer_get_remote_user(xfer));
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
284
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
285 /* 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
286
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
288 char *dstaddr, *hash;
31680
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 31645
diff changeset
289 PurpleAccount *account;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
290 jsx->gpi = purple_proxy_info_new();
35378
5d9e2581005b gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents: 35115
diff changeset
291 purple_proxy_info_set_proxy_type(jsx->gpi, PURPLE_PROXY_SOCKS5);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
292 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
293 purple_proxy_info_set_port(jsx->gpi, streamhost->port);
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
294
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
295 /* unknown file transfer type is assumed to be RECEIVE */
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
296 if(purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND)
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
297 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
298 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
299 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
300 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
301 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
302
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
303 /* Per XEP-0065, the 'host' must be SHA1(SID + from JID + to JID) */
29910
f1c6e586e5c1 jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents: 29887
diff changeset
304 hash = jabber_calculate_data_hash(dstaddr, strlen(dstaddr), "sha1");
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
305
31680
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 31645
diff changeset
306 account = purple_connection_get_account(jsx->js->gc);
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 31645
diff changeset
307 jsx->connect_data = purple_proxy_connect_socks5_account(NULL, account,
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 31645
diff changeset
308 jsx->gpi, hash, 0,
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
309 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
310 g_free(hash);
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
311 g_free(dstaddr);
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
312
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
313 /* When selecting a streamhost, timeout after STREAMHOST_CONNECT_TIMEOUT seconds, otherwise it takes forever */
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
314 if (purple_xfer_get_xfer_type(xfer) != PURPLE_XFER_TYPE_SEND && jsx->connect_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
315 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
316 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
317
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
318 jabber_id_free(dstjid);
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
319 }
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
320
14324
8cbedd82b6ac [gaim-migrate @ 16944]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
321 if (jsx->connect_data == NULL)
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
322 {
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
323 jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost);
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
324 jabber_si_free_streamhost(streamhost, NULL);
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
325 jabber_si_bytestreams_attempt_connect(xfer);
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
326 }
8262
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
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
329 void jabber_bytestreams_parse(JabberStream *js, const char *from,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
330 JabberIqType type, const char *id, PurpleXmlNode *query)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
331 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
332 PurpleXfer *xfer;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
333 JabberSIXfer *jsx;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
334 PurpleXmlNode *streamhost;
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
335 const char *sid;
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14329
diff changeset
336
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
337 if(type != JABBER_IQ_SET)
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14329
diff changeset
338 return;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
339
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
340 if(!from)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
341 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
342
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
343 if(!(sid = purple_xmlnode_get_attrib(query, "sid")))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
344 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
345
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
346 if(!(xfer = jabber_si_xfer_find(js, sid, from)))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
347 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
348
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
349 jsx = purple_xfer_get_protocol_data(xfer);
10940
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
350
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
351 if(!jsx->accepted)
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
352 return;
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
353
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
354 if(jsx->iq_id)
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
355 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
356 jsx->iq_id = g_strdup(id);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
357
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
358 for(streamhost = purple_xmlnode_get_child(query, "streamhost"); streamhost;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
359 streamhost = purple_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
360 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
361 int portnum = 0;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
362
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
363 if((jid = purple_xmlnode_get_attrib(streamhost, "jid")) &&
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
364 ((zeroconf = purple_xmlnode_get_attrib(streamhost, "zeroconf")) ||
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
365 ((host = purple_xmlnode_get_attrib(streamhost, "host")) &&
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
366 (port = purple_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
367 (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
368 JabberBytestreamsStreamhost *sh = g_new0(JabberBytestreamsStreamhost, 1);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
369 sh->jid = g_strdup(jid);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
370 sh->host = g_strdup(host);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
371 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
372 sh->zeroconf = g_strdup(zeroconf);
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
373 /* 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
374 jsx->streamhosts = g_list_append(jsx->streamhosts, sh);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
375 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
376 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
377
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
378 jabber_si_bytestreams_attempt_connect(xfer);
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
379 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
380
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
381
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
382 static void
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
383 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
384 PurpleInputCondition cond)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
385 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
386 PurpleXfer *xfer = data;
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
387 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
388 int len;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
389
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
390 len = write(source, jsx->rxqueue + jsx->rxlen, jsx->rxmaxlen - jsx->rxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
391 if (len < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
392 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
393 else if (len < 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 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
397 purple_xfer_cancel_remote(xfer);
13441
aee36f1f8aa5 [gaim-migrate @ 15815]
Nathan Walp <nwalp@pidgin.im>
parents: 13201
diff changeset
398 return;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
399 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
400 jsx->rxlen += len;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
401
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
402 if (jsx->rxlen < jsx->rxmaxlen)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
403 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
404
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
405 purple_input_remove(purple_xfer_get_watcher(xfer));
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
406 purple_xfer_set_watcher(xfer, 0);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
407 g_free(jsx->rxqueue);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
408 jsx->rxqueue = NULL;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
409
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
410 /* 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
411 * recipient sends the IQ result with <streamhost-used/>
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
412 */
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
413 purple_debug_info("jabber", "SOCKS5 connection negotiation completed. "
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
414 "Waiting for IQ result to start file transfer.\n");
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
415 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
416
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
417 static void
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
418 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
419 PurpleInputCondition cond)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
420 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
421 PurpleXfer *xfer = data;
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
422 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
25695
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
423 char buffer[42]; /* 40 for DST.ADDR + 2 bytes for port number*/
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
424 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
425 char *dstaddr, *hash;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
426 const char *host;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
427
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
428 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
429
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
430 if(jsx->rxlen < 5) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
431 purple_debug_info("jabber", "reading the first 5 bytes\n");
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
432 len = read(source, buffer, 5 - jsx->rxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
433 if(len < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
434 return;
13788
019bc2080927 [gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents: 13493
diff changeset
435 else if(len <= 0) {
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
436 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
437 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
438 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
439 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
440 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
441 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
442 jsx->rxlen += len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
443 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
444 } else if(jsx->rxqueue[0] != 0x05 || jsx->rxqueue[1] != 0x01 ||
25695
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
445 jsx->rxqueue[3] != 0x03 || jsx->rxqueue[4] != 40) {
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
446 purple_debug_info("jabber", "Invalid socks5 conn req. header[0x%x,0x%x,0x%x,0x%x,0x%x]\n",
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
447 jsx->rxqueue[0], jsx->rxqueue[1], jsx->rxqueue[2],
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
448 jsx->rxqueue[3], jsx->rxqueue[4]);
8316
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;
34304
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33895
diff changeset
452 } else if(jsx->rxlen - 5 < (size_t)jsx->rxqueue[4] + 2) {
27140
eaa499df0786 Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <darkrain42@pidgin.im>
parents: 27112
diff changeset
453 /* Upper-bound of 257 (jsx->rxlen = 5, jsx->rxqueue[4] = 0xFF) */
eaa499df0786 Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <darkrain42@pidgin.im>
parents: 27112
diff changeset
454 unsigned short to_read = jsx->rxqueue[4] + 2 - (jsx->rxlen - 5);
eaa499df0786 Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <darkrain42@pidgin.im>
parents: 27112
diff changeset
455 purple_debug_info("jabber", "reading %u bytes for DST.ADDR + port num (trying to read %hu now)\n",
eaa499df0786 Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <darkrain42@pidgin.im>
parents: 27112
diff changeset
456 jsx->rxqueue[4] + 2, to_read);
eaa499df0786 Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <darkrain42@pidgin.im>
parents: 27112
diff changeset
457 len = read(source, buffer, to_read);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
458 if(len < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
459 return;
13788
019bc2080927 [gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents: 13493
diff changeset
460 else if(len <= 0) {
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
461 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
462 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
463 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
464 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
465 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
466 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
467 jsx->rxlen += len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
468 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
469
25695
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
470 /* Have we not read all of DST.ADDR and the following 2-byte port number? */
34304
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33895
diff changeset
471 if(jsx->rxlen - 5 < (size_t)jsx->rxqueue[4] + 2)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
472 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
473
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
474 purple_input_remove(purple_xfer_get_watcher(xfer));
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
475 purple_xfer_set_watcher(xfer, 0);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
476
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
477 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
478 jsx->js->user->node, jsx->js->user->domain,
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
479 jsx->js->user->resource, purple_xfer_get_remote_user(xfer));
10684
0325b164a7eb [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents: 10112
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 /* Per XEP-0065, the 'host' must be SHA1(SID + from JID + to JID) */
29910
f1c6e586e5c1 jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents: 29887
diff changeset
482 hash = jabber_calculate_data_hash(dstaddr, strlen(dstaddr), "sha1");
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
483
25695
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
484 if(strncmp(hash, jsx->rxqueue + 5, 40) ||
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
485 jsx->rxqueue[45] != 0x00 || jsx->rxqueue[46] != 0x00) {
25695
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
486 if (jsx->rxqueue[45] != 0x00 || jsx->rxqueue[46] != 0x00)
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
487 purple_debug_error("jabber", "Got SOCKS5 BS conn with the wrong DST.PORT"
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
488 " (must be 0 - got[0x%x,0x%x]).\n",
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
489 jsx->rxqueue[45], jsx->rxqueue[46]);
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
490 else
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
491 purple_debug_error("jabber", "Got SOCKS5 BS conn with the wrong DST.ADDR"
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
492 " (expected '%s' - got '%.40s').\n",
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
493 hash, jsx->rxqueue + 5);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
494 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
495 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
496 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
497 g_free(dstaddr);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
498 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
499 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
500
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
501 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
502 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
503
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
504 g_free(jsx->rxqueue);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
505 host = purple_network_get_my_ip(jsx->js->fd);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
506
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
507 jsx->rxmaxlen = 5 + strlen(host) + 2;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
508 jsx->rxqueue = g_malloc(jsx->rxmaxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
509 jsx->rxlen = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
510
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
511 jsx->rxqueue[0] = 0x05;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
512 jsx->rxqueue[1] = 0x00;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
513 jsx->rxqueue[2] = 0x00;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
514 jsx->rxqueue[3] = 0x03;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
515 jsx->rxqueue[4] = strlen(host);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
516 memcpy(jsx->rxqueue + 5, host, strlen(host));
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
517 jsx->rxqueue[5+strlen(host)] = 0x00;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
518 jsx->rxqueue[6+strlen(host)] = 0x00;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
519
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
520 purple_xfer_set_watcher(xfer, purple_input_add(source, PURPLE_INPUT_WRITE,
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
521 jabber_si_xfer_bytestreams_send_read_again_resp_cb, xfer));
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
522 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
523 PURPLE_INPUT_WRITE);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
524 }
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 static void
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
527 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
528 PurpleInputCondition cond)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
529 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
530 PurpleXfer *xfer = data;
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
531 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
532 int len;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
533
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
534 len = write(source, jsx->rxqueue + jsx->rxlen, jsx->rxmaxlen - jsx->rxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
535 if (len < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
536 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
537 else if (len < 0) {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
538 g_free(jsx->rxqueue);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
539 jsx->rxqueue = NULL;
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);
13493
598d8f618a31 [gaim-migrate @ 15868]
Richard Laager <rlaager@pidgin.im>
parents: 13441
diff changeset
542 return;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
543 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
544 jsx->rxlen += len;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
545
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
546 if (jsx->rxlen < jsx->rxmaxlen)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
547 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
548
25695
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
549 /* If we sent a "Success", wait for a response, otherwise give up and cancel */
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
550 if (jsx->rxqueue[1] == 0x00) {
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
551 purple_input_remove(purple_xfer_get_watcher(xfer));
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
552 purple_xfer_set_watcher(xfer, purple_input_add(source, PURPLE_INPUT_READ,
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
553 jabber_si_xfer_bytestreams_send_read_again_cb, xfer));
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
554 g_free(jsx->rxqueue);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
555 jsx->rxqueue = NULL;
25695
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
556 jsx->rxlen = 0;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
557 } else {
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
558 close(source);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
559 purple_xfer_cancel_remote(xfer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
560 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
561 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
562
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
563 static void
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
564 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
565 PurpleInputCondition cond)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
566 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
567 PurpleXfer *xfer = data;
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
568 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
569 int i;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
570 int len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
571 char buffer[256];
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
572
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
573 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
574
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
575 purple_xfer_set_fd(xfer, source);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
576
25695
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
577 /** Try to read the SOCKS5 header */
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
578 if(jsx->rxlen < 2) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
579 purple_debug_info("jabber", "reading those first two bytes\n");
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
580 len = read(source, buffer, 2 - jsx->rxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
581 if(len < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
582 return;
13788
019bc2080927 [gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents: 13493
diff changeset
583 else if(len <= 0) {
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 return;
34304
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33895
diff changeset
591 } else if(jsx->rxlen - 2 < (size_t)jsx->rxqueue[1]) {
27140
eaa499df0786 Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <darkrain42@pidgin.im>
parents: 27112
diff changeset
592 /* Has a maximum value of 255 (jsx->rxlen = 2, jsx->rxqueue[1] = 0xFF) */
eaa499df0786 Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <darkrain42@pidgin.im>
parents: 27112
diff changeset
593 unsigned short to_read = jsx->rxqueue[1] - (jsx->rxlen - 2);
eaa499df0786 Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <darkrain42@pidgin.im>
parents: 27112
diff changeset
594 purple_debug_info("jabber", "reading %u bytes for auth methods (trying to read %hu now)\n",
eaa499df0786 Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <darkrain42@pidgin.im>
parents: 27112
diff changeset
595 jsx->rxqueue[1], to_read);
eaa499df0786 Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <darkrain42@pidgin.im>
parents: 27112
diff changeset
596 len = read(source, buffer, to_read);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
597 if(len < 0 && errno == EAGAIN)
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
598 return;
13788
019bc2080927 [gaim-migrate @ 16198]
Daniel Atallah <datallah@pidgin.im>
parents: 13493
diff changeset
599 else if(len <= 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
600 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
601 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
602 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
603 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
604 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
605 jsx->rxlen += len;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
606 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
607
25695
2f903cd6bb2c Make sure that the buffer is large enough to fit DST.ADDR + DST.PORT. This was found in the analysis that Veracode performed on the pidgin codebase.
Daniel Atallah <datallah@pidgin.im>
parents: 25110
diff changeset
608 /* Have we not read all the auth. method bytes? */
34304
faf0414a8b51 Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33895
diff changeset
609 if(jsx->rxlen -2 < (size_t)jsx->rxqueue[1])
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
610 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
611
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
612 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
613
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
614 if(jsx->rxqueue[0] != 0x05) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
615 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
616 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
617 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
618
34457
a9d3726c3a8f Clang warnings: clean up libpurple
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
619 purple_debug_info("jabber", "going to test %u different methods\n", (guint)jsx->rxqueue[1]);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
620
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
621 for(i=0; i<jsx->rxqueue[1]; i++) {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
622
34457
a9d3726c3a8f Clang warnings: clean up libpurple
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
623 purple_debug_info("jabber", "testing %u\n", (guint)jsx->rxqueue[i+2]);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
624 if(jsx->rxqueue[i+2] == 0x00) {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
625 g_free(jsx->rxqueue);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
626 jsx->rxlen = 0;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
627 jsx->rxmaxlen = 2;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
628 jsx->rxqueue = g_malloc(jsx->rxmaxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
629 jsx->rxqueue[0] = 0x05;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
630 jsx->rxqueue[1] = 0x00;
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
631 purple_input_remove(purple_xfer_get_watcher(xfer));
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
632 purple_xfer_set_watcher(xfer, purple_input_add(source, PURPLE_INPUT_WRITE,
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
633 jabber_si_xfer_bytestreams_send_read_response_cb,
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
634 xfer));
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
635 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
636 source, PURPLE_INPUT_WRITE);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
637 jsx->rxqueue = NULL;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
638 jsx->rxlen = 0;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
639 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
640 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
641 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
642
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
643 g_free(jsx->rxqueue);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
644 jsx->rxlen = 0;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
645 jsx->rxmaxlen = 2;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
646 jsx->rxqueue = g_malloc(jsx->rxmaxlen);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
647 jsx->rxqueue[0] = 0x05;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
648 jsx->rxqueue[1] = 0xFF;
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
649 purple_input_remove(purple_xfer_get_watcher(xfer));
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
650 purple_xfer_set_watcher(xfer, purple_input_add(source, PURPLE_INPUT_WRITE,
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
651 jabber_si_xfer_bytestreams_send_read_response_cb, xfer));
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
652 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
653 source, PURPLE_INPUT_WRITE);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
654 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
655
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
656 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
657 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
658 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
659 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
660
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
661 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
662 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
663
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
664 return 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
665 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
666
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
667 static void
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
668 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
669 PurpleInputCondition cond)
8316
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 PurpleXfer *xfer = data;
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
672 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
24038
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
673 int acceptfd, flags;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
674
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
675 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
676
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
677 acceptfd = accept(source, NULL, 0);
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
678 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
679 return;
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
680 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
681 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
682 /* 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
683 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
684 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
685
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
686 purple_input_remove(purple_xfer_get_watcher(xfer));
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
687 close(source);
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
688 jsx->local_streamhost_fd = -1;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
689
24038
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
690 flags = fcntl(acceptfd, F_GETFL);
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
691 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
692 #ifndef _WIN32
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
693 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
694 #endif
5500af38bb9f Use non-blocking io for direct xmpp file transfers
Daniel Atallah <datallah@pidgin.im>
parents: 23912
diff changeset
695
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
696 purple_xfer_set_watcher(xfer, purple_input_add(acceptfd, PURPLE_INPUT_READ,
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
697 jabber_si_xfer_bytestreams_send_read_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
698 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
699
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
700 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
701 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
702 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
703 PurpleXmlNode *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
704 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
705 PurpleXfer *xfer = data;
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
706 JabberSIXfer *jsx;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
707 PurpleXmlNode *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
708 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
709 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
710
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
711 /* 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
712
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
713 /* 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
714 if (!g_list_find(js->file_transfers, xfer)) {
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
715 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
716 return;
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
717 }
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
718
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
719 jsx = purple_xfer_get_protocol_data(xfer);
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
720
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
721 /* In the case of a direct file transfer, this is expected to return */
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
722 if(!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
723 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
724
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
725 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
726 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
727 "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
728 /* 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
729 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
730 "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
731 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
732 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
733 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
734 /* 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
735 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
736 the bytestream proxy ourselves when receiving this <iq/> */
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
737 if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND
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
738 && !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
739 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
740 } 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
741 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
742 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
743 }
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
744 /* 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
745 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
746 } 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
747 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
748 }
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
749 return;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
750 }
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
751
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
752 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
753 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
754
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
755 if(!(query = purple_xmlnode_get_child(packet, "query")))
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
756 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
757
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
758 if(!(streamhost_used = purple_xmlnode_get_child(query, "streamhost-used")))
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
759 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
760
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
761 if(!(jid = purple_xmlnode_get_attrib(streamhost_used, "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
762 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
763
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
764 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
765 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
766
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
767 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
768 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
769 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
770 jsx->js->user->domain, jsx->js->user->resource);
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
771 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
772 purple_debug_info("jabber", "Got local SOCKS5 streamhost-used.\n");
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
773 purple_xfer_start(xfer, purple_xfer_get_fd(xfer), NULL, -1);
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
774 } else {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
775 /* 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
776 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
777 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
778 "jabber_si_connect_proxy_cb: trying to revert to IBB\n");
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
779 if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND) {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
780 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
781 } 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
782 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
783 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
784 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
785 /* 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
786 } 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
787 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
788 "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
789 purple_xfer_cancel_local(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
790 }
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
791 }
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
792 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
793 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
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
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
796 /* Clean up the local streamhost - it isn't going to be used.*/
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
797 if (purple_xfer_get_watcher(xfer) > 0) {
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
798 purple_input_remove(purple_xfer_get_watcher(xfer));
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
799 purple_xfer_set_watcher(xfer, 0);
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
800 }
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
801 if (jsx->local_streamhost_fd >= 0) {
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
802 close(jsx->local_streamhost_fd);
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
803 jsx->local_streamhost_fd = -1;
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
804 }
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
805
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
806 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
807 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
808 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
809
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
810 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
811
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
812 jabber_si_bytestreams_attempt_connect(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
813 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
814
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
815 static void
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
816 jabber_si_xfer_bytestreams_listen_cb(int sock, gpointer data)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
817 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
818 PurpleXfer *xfer = data;
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
819 JabberSIXfer *jsx;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
820 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
821 PurpleXmlNode *query, *streamhost;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
822 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
823 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
824 JabberBytestreamsStreamhost *sh, *sh2;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
825 int streamhost_count = 0;
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
826
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
827 jsx = purple_xfer_get_protocol_data(xfer);
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
828 jsx->listen_data = NULL;
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
829
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
830 /* 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
831 * (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
832 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) {
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
833 g_object_unref(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
834 return;
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
835 }
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
836
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
837 g_object_unref(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
838
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
839 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, NS_BYTESTREAMS);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
840 purple_xmlnode_set_attrib(iq->node, "to", purple_xfer_get_remote_user(xfer));
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
841 query = purple_xmlnode_get_child(iq->node, "query");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
842
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
843 purple_xmlnode_set_attrib(query, "sid", jsx->stream_id);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
844
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
845 /* If we successfully started listening locally */
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
846 if (sock >= 0) {
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
847 gchar *jid;
29510
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
848 GList *local_ips =
29511
7c4b1ba4f2aa Remove IPv6 support from _get_local_system_ips, since I couldn't get it to
Marcus Lundblad <malu@pidgin.im>
parents: 29510
diff changeset
849 purple_network_get_all_local_system_ips();
29510
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
850 const char *public_ip;
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
851 gboolean has_public_ip = FALSE;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31123
diff changeset
852
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
853 jsx->local_streamhost_fd = sock;
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
854
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
855 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
856 jsx->js->user->domain, jsx->js->user->resource);
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
857 purple_xfer_set_local_port(xfer, purple_network_get_port_from_fd(sock));
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
858 g_snprintf(port, sizeof(port), "%hu", purple_xfer_get_local_port(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
859
29510
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
860 public_ip = purple_network_get_my_ip(jsx->js->fd);
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
861
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
862 /* Include the localhost's IPs (for in-network transfers) */
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
863 while (local_ips) {
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
864 gchar *local_ip = local_ips->data;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
865 streamhost_count++;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
866 streamhost = purple_xmlnode_new_child(query, "streamhost");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
867 purple_xmlnode_set_attrib(streamhost, "jid", jid);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
868 purple_xmlnode_set_attrib(streamhost, "host", local_ip);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
869 purple_xmlnode_set_attrib(streamhost, "port", port);
29510
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
870 if (purple_strequal(local_ip, public_ip))
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
871 has_public_ip = TRUE;
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
872 g_free(local_ip);
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
873 local_ips = g_list_delete_link(local_ips, local_ips);
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
874 }
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
875
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
876 /* Include the public IP (assuming that there is a port mapped somehow) */
29510
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
877 if (!has_public_ip && strcmp(public_ip, "0.0.0.0") != 0) {
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
878 streamhost_count++;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
879 streamhost = purple_xmlnode_new_child(query, "streamhost");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
880 purple_xmlnode_set_attrib(streamhost, "jid", jid);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
881 purple_xmlnode_set_attrib(streamhost, "host", public_ip);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
882 purple_xmlnode_set_attrib(streamhost, "port", port);
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
883 }
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
884
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
885 g_free(jid);
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
886
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
887 /* The listener for the local proxy */
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
888 purple_xfer_set_watcher(xfer, purple_input_add(sock, PURPLE_INPUT_READ,
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
889 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
890 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
893 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
894
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 /* 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
896
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
897 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
898 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
899
24712
134bd2024c88 Add missing newline in debug message.
Daniel Atallah <datallah@pidgin.im>
parents: 24038
diff changeset
900 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
901 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
902 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
903 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
904
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
905 streamhost_count++;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
906 streamhost = purple_xmlnode_new_child(query, "streamhost");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
907 purple_xmlnode_set_attrib(streamhost, "jid", sh->jid);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
908 purple_xmlnode_set_attrib(streamhost, "host", sh->host);
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
909 g_snprintf(port, sizeof(port), "%hu", sh->port);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
910 purple_xmlnode_set_attrib(streamhost, "port", 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
911
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
912 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
913 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
914 sh2->host = g_strdup(sh->host);
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
915 /*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
916 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
917
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
918 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
919 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
920
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
921 /* 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
922 if (streamhost_count == 0) {
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
923 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
924
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
925 /* if available, revert to IBB */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
926 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
927 purple_debug_info("jabber",
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
928 "jabber_si_xfer_bytestreams_listen_cb: trying to revert to IBB\n");
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
929 if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND) {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
930 /* 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
931 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
932 } 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
933 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
934 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
935 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
936 /* 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
937 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
938 } 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
939 /* 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
940 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
941 purple_xfer_cancel_local(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
942 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
943
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
944 return;
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
945 }
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
946
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
947 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
948
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
949 jabber_iq_send(iq);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
950
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
951 }
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
952
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
953 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
954 jabber_si_xfer_bytestreams_send_init(PurpleXfer *xfer)
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
955 {
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
956 JabberSIXfer *jsx;
31735
6285e4a52844 xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <datallah@pidgin.im>
parents: 31680
diff changeset
957 PurpleProxyType proxy_type;
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
958
34912
539b7b4d1949 Replaced purple_xfer_{ref|unref} with g_object_{ref|unref}
Ankit Vani <a@nevitus.org>
parents: 34910
diff changeset
959 g_object_ref(xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
960
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
961 jsx = purple_xfer_get_protocol_data(xfer);
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
962
31735
6285e4a52844 xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <datallah@pidgin.im>
parents: 31680
diff changeset
963 /* TODO: This should probably be done with an account option instead of
6285e4a52844 xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <datallah@pidgin.im>
parents: 31680
diff changeset
964 * piggy-backing on the TOR proxy type. */
35378
5d9e2581005b gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents: 35115
diff changeset
965 proxy_type = purple_proxy_info_get_proxy_type(
31735
6285e4a52844 xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <datallah@pidgin.im>
parents: 31680
diff changeset
966 purple_proxy_get_setup(purple_connection_get_account(jsx->js->gc)));
6285e4a52844 xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <datallah@pidgin.im>
parents: 31680
diff changeset
967 if (proxy_type == PURPLE_PROXY_TOR) {
6285e4a52844 xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <datallah@pidgin.im>
parents: 31680
diff changeset
968 purple_debug_info("jabber", "Skipping attempting local streamhost.\n");
6285e4a52844 xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <datallah@pidgin.im>
parents: 31680
diff changeset
969 jsx->listen_data = NULL;
6285e4a52844 xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <datallah@pidgin.im>
parents: 31680
diff changeset
970 } else
32594
f2feea134fdb Remove deprecated purple_network_listen_map_external().
Andrew Victor <andrew.victor@mxit.com>
parents: 32593
diff changeset
971 jsx->listen_data = purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, TRUE,
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
972 jabber_si_xfer_bytestreams_listen_cb, xfer);
31735
6285e4a52844 xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <datallah@pidgin.im>
parents: 31680
diff changeset
973
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14324
diff changeset
974 if (jsx->listen_data == NULL) {
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
975 /* 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
976 jabber_si_xfer_bytestreams_listen_cb(-1, xfer);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
977 }
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
978
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
979 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
980
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
981 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
982 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
983 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
984 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(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
985
27525
579b9d64b364 A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27332
diff changeset
986 purple_debug_error("jabber", "an error occurred during IBB file transfer\n");
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
987 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
988 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
989
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
990 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
991 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
992 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
993 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(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
994
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
995 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
996 if (purple_xfer_get_bytes_remaining(xfer) > 0) {
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
997 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
998 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
999 purple_xfer_set_completed(xfer, TRUE);
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1000 purple_xfer_end(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1001 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1002 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1003
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1004 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1005 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
1006 gsize size)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1007 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1008 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1009 JabberSIXfer *jsx = purple_xfer_get_protocol_data(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
1010
35029
f9f672dcaadf Fixed warnings
Ankit Vani <a@nevitus.org>
parents: 35001
diff changeset
1011 if ((goffset)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
1012 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
1013 size);
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1014 purple_circular_buffer_append(jsx->ibb_buffer, data, size);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
1015 purple_xfer_protocol_ready(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1016 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1017 /* 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
1018 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
1019 purple_debug_error("jabber",
26020
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
1020 "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
1021 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
1022 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1023
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1024 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1025
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1026 static gssize
35115
ba7dbf5e91d3 PurpleXfer API: Added a buffer size parameter to the 'read' callback
Ankit Vani <a@nevitus.org>
parents: 35029
diff changeset
1027 jabber_si_xfer_ibb_read(guchar **out_buffer, size_t buf_size, PurpleXfer *xfer)
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1028 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1029 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1030 guchar *buffer;
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1031 gsize size = purple_circular_buffer_get_used(jsx->ibb_buffer);
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1032 gsize tmp;
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1033
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1034 *out_buffer = buffer = g_malloc(size);
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1035 while ((tmp = purple_circular_buffer_get_max_read(jsx->ibb_buffer))) {
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1036 const gchar *output = purple_circular_buffer_get_output(jsx->ibb_buffer);
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1037 memcpy(buffer, output, tmp);
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1038 buffer += tmp;
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1039 purple_circular_buffer_mark_read(jsx->ibb_buffer, tmp);
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1040 }
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1041
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1042 return size;
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1043 }
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1044
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1045 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
1046 jabber_si_xfer_ibb_open_cb(JabberStream *js, const char *who, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1047 PurpleXmlNode *open)
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1048 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1049 const gchar *sid = purple_xmlnode_get_attrib(open, "sid");
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1050 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
1051 if (xfer) {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1052 JabberSIXfer *jsx = purple_xfer_get_protocol_data(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
1053 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
1054 jabber_ibb_session_create_from_xmlnode(js, who, id, open, xfer);
26020
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
1055
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1056 jabber_si_bytestreams_ibb_timeout_remove(jsx);
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1057
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1058 if (sess) {
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1059 /* setup callbacks here...*/
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1060 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
1061 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
1062 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
1063 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
1064 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
1065 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
1066
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1067 jsx->ibb_session = sess;
29887
2556fe9b4875 jabber: Adjust amount of data to send in IBB packets so that at most block-size
Marcus Lundblad <malu@pidgin.im>
parents: 29675
diff changeset
1068 /* we handle up to block-size bytes of decoded data, to handle
2556fe9b4875 jabber: Adjust amount of data to send in IBB packets so that at most block-size
Marcus Lundblad <malu@pidgin.im>
parents: 29675
diff changeset
1069 clients interpreting the block-size attribute as that
2556fe9b4875 jabber: Adjust amount of data to send in IBB packets so that at most block-size
Marcus Lundblad <malu@pidgin.im>
parents: 29675
diff changeset
1070 (see also remark in ibb.c) */
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1071 jsx->ibb_buffer =
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1072 purple_circular_buffer_new(jabber_ibb_session_get_block_size(sess));
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1073
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1074 /* set up read function */
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1075 purple_xfer_set_read_fnc(xfer, jabber_si_xfer_ibb_read);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1076
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1077 /* start the transfer */
28152
e9800c07eb5b ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents: 28077
diff changeset
1078 purple_xfer_start(xfer, -1, NULL, 0);
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1079 return TRUE;
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1080 } else {
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1081 /* 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
1082 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
1083 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
1084 return FALSE;
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1085 }
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1086 } else {
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1087 /* 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
1088 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
1089 "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
1090 return FALSE;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1091 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1092 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1093
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1094 static gssize
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1095 jabber_si_xfer_ibb_write(const guchar *buffer, size_t len, PurpleXfer *xfer)
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1096 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1097 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1098 JabberIBBSession *sess = jsx->ibb_session;
29887
2556fe9b4875 jabber: Adjust amount of data to send in IBB packets so that at most block-size
Marcus Lundblad <malu@pidgin.im>
parents: 29675
diff changeset
1099 gsize packet_size = len < jabber_ibb_session_get_max_data_size(sess) ?
2556fe9b4875 jabber: Adjust amount of data to send in IBB packets so that at most block-size
Marcus Lundblad <malu@pidgin.im>
parents: 29675
diff changeset
1100 len : jabber_ibb_session_get_max_data_size(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
1101
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1102 jabber_ibb_session_send_data(sess, buffer, 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
1103
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1104 return packet_size;
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1105 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1106
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1107 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1108 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
1109 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1110 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
32665
1ddb514482cb Update XMPP for 64-bit transfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
1111 goffset 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
1112
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1113 if (remaining == 0) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1114 /* close the session */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1115 jabber_ibb_session_close(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1116 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
1117 purple_xfer_end(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1118 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1119 /* send more... */
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
1120 purple_xfer_protocol_ready(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1121 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1122 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1123
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1124 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1125 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
1126 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1127 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
26020
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
1128
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1129 if (jabber_ibb_session_get_state(sess) == JABBER_IBB_SESSION_OPENED) {
28152
e9800c07eb5b ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <darkrain42@pidgin.im>
parents: 28077
diff changeset
1130 purple_xfer_start(xfer, -1, NULL, 0);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
1131 purple_xfer_protocol_ready(xfer);
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1132 } else {
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1133 /* error */
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1134 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
1135 }
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1136 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1137
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1138 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1139 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
1140 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1141 JabberSIXfer *jsx = purple_xfer_get_protocol_data(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
1142
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1143 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
1144 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
1145
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1146 if (jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1147 /* should set callbacks here... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1148 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
1149 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
1150 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
1151 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
1152 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
1153 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
1154 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
1155 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
1156
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1157 purple_xfer_set_write_fnc(xfer, jabber_si_xfer_ibb_write);
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1158
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1159 jsx->ibb_buffer =
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1160 purple_circular_buffer_new(jabber_ibb_session_get_max_data_size(jsx->ibb_session));
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1161
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1162 /* open the IBB session */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1163 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
1164
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1165 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1166 /* 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
1167 purple_debug_error("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1168 "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
1169 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
1170 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1171 }
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
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
1173 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
1174 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1175 PurpleXmlNode *packet, gpointer data)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1176 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1177 PurpleXfer *xfer = data;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1178 PurpleXmlNode *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
1179 gboolean found_method = FALSE;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1180
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1181 if(!(si = purple_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
1182 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1183 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1184 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1185
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1186 if(!(feature = purple_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
1187 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1188 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1189 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1190
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1191 if(!(x = purple_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
1192 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1193 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1194 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1195
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1196 for(field = purple_xmlnode_get_child(x, "field"); field; field = purple_xmlnode_get_next_twin(field)) {
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1197 const char *var = purple_xmlnode_get_attrib(field, "var");
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1198 JabberSIXfer *jsx = purple_xfer_get_protocol_data(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
1199
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1200 if(var && !strcmp(var, "stream-method")) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1201 if((value = purple_xmlnode_get_child(field, "value"))) {
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1202 char *val = purple_xmlnode_get_data(value);
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
1203 if(val && !strcmp(val, NS_BYTESTREAMS)) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1204 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
1205 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
1206 found_method = TRUE;
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28828
diff changeset
1207 } else if (val && !strcmp(val, NS_IBB)) {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1208 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
1209 if (!found_method) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1210 /* 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
1211 start IBB right away... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1212 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
1213 found_method = TRUE;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1214 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1215 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1216 g_free(val);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1217 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1218 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1219 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1220
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1221 if (!found_method) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1222 purple_xfer_cancel_remote(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1223 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1224
8312
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
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1227 static void jabber_si_xfer_send_request(PurpleXfer *xfer)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1228 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1229 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1230 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1231 PurpleXmlNode *si, *file, *feature, *x, *field, *option, *value;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1232 char buf[32];
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1233 #if ENABLE_FT_THUMBNAILS
30126
f09ecb81212c Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30119
diff changeset
1234 gconstpointer thumb;
f09ecb81212c Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30119
diff changeset
1235 gsize thumb_size;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1236
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1237 purple_xfer_prepare_thumbnail(xfer, "jpeg,png");
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1238 #endif
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1239 purple_xfer_set_filename(xfer, g_path_get_basename(purple_xfer_get_local_filename(xfer)));
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31123
diff changeset
1240
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1241 iq = jabber_iq_new(jsx->js, JABBER_IQ_SET);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1242 purple_xmlnode_set_attrib(iq->node, "to", purple_xfer_get_remote_user(xfer));
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1243 si = purple_xmlnode_new_child(iq->node, "si");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1244 purple_xmlnode_set_namespace(si, "http://jabber.org/protocol/si");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1245 jsx->stream_id = jabber_get_next_id(jsx->js);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1246 purple_xmlnode_set_attrib(si, "id", jsx->stream_id);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1247 purple_xmlnode_set_attrib(si, "profile", NS_SI_FILE_TRANSFER);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1248
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1249 file = purple_xmlnode_new_child(si, "file");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1250 purple_xmlnode_set_namespace(file, NS_SI_FILE_TRANSFER);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1251 purple_xmlnode_set_attrib(file, "name", purple_xfer_get_filename(xfer));
32665
1ddb514482cb Update XMPP for 64-bit transfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
1252 g_snprintf(buf, sizeof(buf), "%" G_GOFFSET_FORMAT, purple_xfer_get_size(xfer));
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1253 purple_xmlnode_set_attrib(file, "size", buf);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1254 /* maybe later we'll do hash and date attribs */
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1255
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1256 #if ENABLE_FT_THUMBNAILS
27424
c19f67250659 Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <malu@pidgin.im>
parents: 27420
diff changeset
1257 /* add thumbnail, if appropriate */
30126
f09ecb81212c Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30119
diff changeset
1258 if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) {
30113
f60cbf3b3ca9 Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <malu@pidgin.im>
parents: 29778
diff changeset
1259 const gchar *mimetype = purple_xfer_get_thumbnail_mimetype(xfer);
f60cbf3b3ca9 Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <malu@pidgin.im>
parents: 29778
diff changeset
1260 JabberData *thumbnail_data =
30126
f09ecb81212c Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30119
diff changeset
1261 jabber_data_create_from_data(thumb, thumb_size,
f09ecb81212c Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30119
diff changeset
1262 mimetype, TRUE, jsx->js);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1263 PurpleXmlNode *thumbnail = purple_xmlnode_new_child(file, "thumbnail");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1264 purple_xmlnode_set_namespace(thumbnail, NS_THUMBS);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1265 purple_xmlnode_set_attrib(thumbnail, "cid",
27424
c19f67250659 Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <malu@pidgin.im>
parents: 27420
diff changeset
1266 jabber_data_get_cid(thumbnail_data));
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1267 purple_xmlnode_set_attrib(thumbnail, "mime-type", mimetype);
27424
c19f67250659 Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <malu@pidgin.im>
parents: 27420
diff changeset
1268 /* cache data */
c19f67250659 Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <malu@pidgin.im>
parents: 27420
diff changeset
1269 jabber_data_associate_local(thumbnail_data, NULL);
c19f67250659 Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <malu@pidgin.im>
parents: 27420
diff changeset
1270 }
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1271 #endif
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31123
diff changeset
1272
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1273 feature = purple_xmlnode_new_child(si, "feature");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1274 purple_xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1275 x = purple_xmlnode_new_child(feature, "x");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1276 purple_xmlnode_set_namespace(x, "jabber:x:data");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1277 purple_xmlnode_set_attrib(x, "type", "form");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1278 field = purple_xmlnode_new_child(x, "field");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1279 purple_xmlnode_set_attrib(field, "var", "stream-method");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1280 purple_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
1281 /* 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
1282 behind troublesome firewalls */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1283 option = purple_xmlnode_new_child(field, "option");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1284 value = purple_xmlnode_new_child(option, "value");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1285 purple_xmlnode_insert_data(value, NS_BYTESTREAMS, -1);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1286 option = purple_xmlnode_new_child(field, "option");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1287 value = purple_xmlnode_new_child(option, "value");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1288 purple_xmlnode_insert_data(value, NS_IBB, -1);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1289
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1290 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
1291
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
1292 /* 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
1293 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
1294 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
1295
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1296 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1297 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1298
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1299 static void jabber_si_xfer_free(PurpleXfer *xfer)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1300 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1301 JabberSIXfer *jsx = purple_xfer_get_protocol_data(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
1302
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
1303 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
1304 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
1305
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
1306 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
1307
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
1308 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
1309 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
1310 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
1311 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
1312 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
1313 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
1314 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
1315 close(jsx->local_streamhost_fd);
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
1316 if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND && purple_xfer_get_fd(xfer) >= 0) {
27332
8240ab259385 Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <malu@pidgin.im>
parents: 27155
diff changeset
1317 purple_debug_info("jabber", "remove port mapping\n");
32703
cd83cdab1b0f Jabber: Use file-transfer accessor functions
Andrew Victor <andrew.victor@mxit.com>
parents: 32678
diff changeset
1318 purple_network_remove_port_mapping(purple_xfer_get_fd(xfer));
27332
8240ab259385 Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <malu@pidgin.im>
parents: 27155
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->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
1321 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
1322 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
1323 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
1324
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
1325 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
1326 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
1327 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
1328 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1329
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
1330 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
1331 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
1332 "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
1333 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
1334 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1335
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1336 if (jsx->ibb_buffer) {
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1337 g_object_unref(G_OBJECT(jsx->ibb_buffer));
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
1338 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1339
28077
c2b493e058f1 Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27817
diff changeset
1340 purple_debug_info("jabber", "jabber_si_xfer_free(): freeing jsx %p\n", jsx);
c2b493e058f1 Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <darkrain42@pidgin.im>
parents: 27817
diff changeset
1341
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
1342 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
1343 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
1344 /* 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
1345 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
1346 g_free(jsx);
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1347 purple_xfer_set_protocol_data(xfer, 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
1348 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1349 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1350
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1351 /*
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1352 * 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
1353 * (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
1354 * purple_xfer_request_denied.
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1355 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1356 static void jabber_si_xfer_cancel_send(PurpleXfer *xfer)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1357 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1358 JabberSIXfer *jsx = purple_xfer_get_protocol_data(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
1359
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1360 /* 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
1361 if (jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1362 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
1363 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1364 jabber_si_xfer_free(xfer);
28828
7c1855f037e7 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
1365 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
1366 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1367
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1368
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1369 static void jabber_si_xfer_request_denied(PurpleXfer *xfer)
13146
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1370 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1371 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
27817
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1372 JabberStream *js = jsx->js;
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1373
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1374 /*
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1375 * TODO: It's probably an error if jsx->iq_id == NULL. g_return_if_fail
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1376 * might be warranted.
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1377 */
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1378 if (jsx->iq_id && !jsx->accepted) {
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1379 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1380 PurpleXmlNode *error, *child;
27817
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1381 iq = jabber_iq_new(js, JABBER_IQ_ERROR);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1382 purple_xmlnode_set_attrib(iq->node, "to", purple_xfer_get_remote_user(xfer));
27817
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1383 jabber_iq_set_id(iq, jsx->iq_id);
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1384
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1385 error = purple_xmlnode_new_child(iq->node, "error");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1386 purple_xmlnode_set_attrib(error, "type", "cancel");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1387 child = purple_xmlnode_new_child(error, "forbidden");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1388 purple_xmlnode_set_namespace(child, NS_XMPP_STANZAS);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1389 child = purple_xmlnode_new_child(error, "text");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1390 purple_xmlnode_set_namespace(child, NS_XMPP_STANZAS);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1391 purple_xmlnode_insert_data(child, "Offer Declined", -1);
27817
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1392
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1393 jabber_iq_send(iq);
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1394 }
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1395
13146
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1396 jabber_si_xfer_free(xfer);
28828
7c1855f037e7 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
1397 purple_debug_info("jabber", "in jabber_si_xfer_request_denied\n");
13146
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1398 }
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1399
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1400
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1401 static void jabber_si_xfer_cancel_recv(PurpleXfer *xfer)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1402 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1403 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1404 /* 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
1405 if (jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1406 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
1407 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1408 jabber_si_xfer_free(xfer);
28828
7c1855f037e7 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
1409 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
1410 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1411
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1412
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1413 static void jabber_si_xfer_end(PurpleXfer *xfer)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1414 {
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1415 jabber_si_xfer_free(xfer);
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1416 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1417
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1418
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1419 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
1420 JabberCapabilities capabilities, gpointer data)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1421 {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1422 PurpleXfer *xfer = (PurpleXfer *) data;
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1423 JabberSIXfer *jsx = purple_xfer_get_protocol_data(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
1424
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1425 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
1426 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1427 "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
1428 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
1429 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1430
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1431 if (capabilities & JABBER_CAP_SI_FILE_XFER) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1432 jabber_si_xfer_send_request(xfer);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1433 } else {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1434 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
1435 purple_notify_error(js->gc, _("File Send Failed"),
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1436 _("File Send Failed"), msg,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1437 purple_request_cpar_from_connection(js->gc));
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1438 g_free(msg);
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1439 purple_xfer_cancel_local(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1440 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1441 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1442
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1443 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
1444 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1445 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
1446 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1447
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1448 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
1449 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1450 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1451 char **who_v = g_strsplit(purple_xfer_get_remote_user(xfer), "/", 2);
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1452 char *who;
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1453 JabberBuddy *jb;
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1454 JabberBuddyResource *jbr = NULL;
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1455
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1456 jb = jabber_buddy_find(jsx->js, who_v[0], FALSE);
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1457 if (jb) {
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1458 jbr = jabber_buddy_find_resource(jb, resource);
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1459 }
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1460
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1461 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
1462 g_strfreev(who_v);
34913
21017b84a070 Refactored jabber to use the GObject xfer API.
Ankit Vani <a@nevitus.org>
parents: 34912
diff changeset
1463 purple_xfer_set_remote_user(xfer, who);
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1464
29118
8d6805679729 Use the jabber_resource_know_capabilities function to determine if a buddy
Marcus Lundblad <malu@pidgin.im>
parents: 29041
diff changeset
1465 if (jbr && jabber_resource_know_capabilities(jbr)) {
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1466 char *msg;
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1467
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28828
diff changeset
1468 if (jabber_resource_has_capability(jbr, NS_IBB))
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1469 jsx->stream_method |= STREAM_METHOD_IBB;
30474
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1470 if (jabber_resource_has_capability(jbr, NS_SI_FILE_TRANSFER)) {
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1471 jabber_si_xfer_send_request(xfer);
34921
ec60bc0b0be4 Freed a string
Ankit Vani <a@nevitus.org>
parents: 34920
diff changeset
1472 g_free(who);
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1473 return;
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1474 }
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1475
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1476 msg = g_strdup_printf(_("Unable to send file to %s, user does not support file transfers"), who);
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1477 purple_notify_error(jsx->js->gc, _("File Send Failed"),
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1478 _("File Send Failed"), msg,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1479 purple_request_cpar_from_connection(jsx->js->gc));
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1480 g_free(msg);
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1481 purple_xfer_cancel_local(xfer);
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1482 } else {
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1483 jabber_disco_info_do(jsx->js, who,
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1484 jabber_si_xfer_send_disco_cb, xfer);
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1485 }
34921
ec60bc0b0be4 Freed a string
Ankit Vani <a@nevitus.org>
parents: 34920
diff changeset
1486
ec60bc0b0be4 Freed a string
Ankit Vani <a@nevitus.org>
parents: 34920
diff changeset
1487 g_free(who);
17424
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 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
1491 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1492 PurpleRequestField *field = purple_request_fields_get_field(fields, "resource");
34338
c652670afac5 Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
1493 const char *selected_label = purple_request_field_choice_get_value(field);
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1494
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1495 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
1496 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1497
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1498 static void jabber_si_xfer_init(PurpleXfer *xfer)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1499 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1500 JabberSIXfer *jsx = purple_xfer_get_protocol_data(xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1501 JabberIq *iq;
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
1502 if(purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1503 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1504 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
1505 char *resource;
30474
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1506 GList *resources = NULL;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31123
diff changeset
1507
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1508 if(NULL != (resource = jabber_get_resource(purple_xfer_get_remote_user(xfer)))) {
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1509 /* 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
1510 * 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
1511
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1512 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
1513 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
1514 return;
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1515 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1516
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1517 jb = jabber_buddy_find(jsx->js, purple_xfer_get_remote_user(xfer), TRUE);
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1518
30474
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1519 if (jb) {
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1520 GList *l;
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1521
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1522 for (l = jb->resources ; l ; l = g_list_next(l)) {
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1523 jbr = l->data;
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1524
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1525 if (!jabber_resource_know_capabilities(jbr) ||
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1526 (jabber_resource_has_capability(jbr, NS_SI_FILE_TRANSFER)
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1527 && (jabber_resource_has_capability(jbr, NS_BYTESTREAMS)
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1528 || jabber_resource_has_capability(jbr, NS_IBB)))) {
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1529 resources = g_list_append(resources, jbr);
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1530 }
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1531 }
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1532 }
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31123
diff changeset
1533
30474
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1534 if (!resources) {
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1535 /* 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
1536 * 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
1537 * 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
1538 char *msg;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1539
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1540 if(!jb) {
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1541 msg = g_strdup_printf(_("Unable to send file to %s, invalid JID"), purple_xfer_get_remote_user(xfer));
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1542 } else if(jb->subscription & JABBER_SUB_TO) {
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1543 msg = g_strdup_printf(_("Unable to send file to %s, user is not online"), purple_xfer_get_remote_user(xfer));
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1544 } else {
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1545 msg = g_strdup_printf(_("Unable to send file to %s, not subscribed to user presence"), purple_xfer_get_remote_user(xfer));
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1546 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1547
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1548 purple_notify_error(jsx->js->gc, _("File Send Failed"),
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1549 _("File Send Failed"), msg,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1550 purple_request_cpar_from_connection(jsx->js->gc));
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1551 g_free(msg);
30474
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1552 } else if (g_list_length(resources) == 1) {
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1553 /* 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
1554 * so no need to ask who to send to */
30474
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1555 jbr = resources->data;
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1556 do_transfer_send(xfer, jbr->name);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1557 } else {
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1558 /* 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
1559 GList *l;
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1560 char *msg = g_strdup_printf(_("Please select the resource of %s to which you would like to send a file"), purple_xfer_get_remote_user(xfer));
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1561 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
1562 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
1563 PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL);
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31123
diff changeset
1564
34338
c652670afac5 Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
1565 purple_request_field_choice_set_data_destructor(field, g_free);
c652670afac5 Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
1566
30474
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1567 for(l = resources; l; l = l->next) {
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1568 jbr = l->data;
34338
c652670afac5 Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34332
diff changeset
1569 purple_request_field_choice_add(field, jbr->name, g_strdup(jbr->name));
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1570 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1571
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1572 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
1573
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1574 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
1575
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1576 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
1577 _("Send File"), G_CALLBACK(resource_select_ok_cb), _("Cancel"), G_CALLBACK(resource_select_cancel_cb),
34332
876483829700 Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34304
diff changeset
1578 purple_request_cpar_from_connection(jsx->js->gc), xfer);
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1579
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1580 g_free(msg);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1581 }
30474
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1582
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1583 g_list_free(resources);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1584 } else {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1585 PurpleXmlNode *si, *feature, *x, *field, *value;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1586
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1587 iq = jabber_iq_new(jsx->js, JABBER_IQ_RESULT);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1588 purple_xmlnode_set_attrib(iq->node, "to", purple_xfer_get_remote_user(xfer));
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1589 if(jsx->iq_id)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1590 jabber_iq_set_id(iq, jsx->iq_id);
27817
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1591 else
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1592 purple_debug_error("jabber", "Sending SI result with new IQ id.\n");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1593
10940
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
1594 jsx->accepted = TRUE;
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
1595
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1596 si = purple_xmlnode_new_child(iq->node, "si");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1597 purple_xmlnode_set_namespace(si, "http://jabber.org/protocol/si");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1598
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1599 feature = purple_xmlnode_new_child(si, "feature");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1600 purple_xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1601
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1602 x = purple_xmlnode_new_child(feature, "x");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1603 purple_xmlnode_set_namespace(x, "jabber:x:data");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1604 purple_xmlnode_set_attrib(x, "type", "submit");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1605 field = purple_xmlnode_new_child(x, "field");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1606 purple_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
1607
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1608 /* 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
1609 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
1610 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
1611 /* 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
1612 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
1613 if (jsx->stream_method & STREAM_METHOD_BYTESTREAMS) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1614 value = purple_xmlnode_new_child(field, "value");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1615 purple_xmlnode_insert_data(value, NS_BYTESTREAMS, -1);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1616 } else if(jsx->stream_method & STREAM_METHOD_IBB) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1617 value = purple_xmlnode_new_child(field, "value");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1618 purple_xmlnode_insert_data(value, NS_IBB, -1);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1619 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1620
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1621 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1622 }
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1623 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1624
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1625 PurpleXfer *jabber_si_new_xfer(PurpleConnection *gc, const char *who)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1626 {
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1627 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1628
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1629 PurpleXfer *xfer;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1630 JabberSIXfer *jsx;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1631
32277
97f16af01a05 Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents: 32270
diff changeset
1632 js = purple_connection_get_protocol_data(gc);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1633
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
1634 xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_TYPE_SEND, who);
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1635 if (xfer)
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1636 {
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1637 jsx = g_new0(JabberSIXfer, 1);
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1638 purple_xfer_set_protocol_data(xfer, jsx);
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1639 jsx->js = js;
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
1640 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
1641
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1642 jsx->ibb_session = NULL;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1643
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1644 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
1645 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
1646 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1647
15345
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1648 js->file_transfers = g_list_append(js->file_transfers, xfer);
797936e968ff [gaim-migrate @ 18073]
Evan Schoenberg <evands@pidgin.im>
parents: 14899
diff changeset
1649 }
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1650
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1651 return xfer;
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1652 }
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1653
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1654 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
1655 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1656 PurpleXfer *xfer;
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1657
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1658 xfer = jabber_si_new_xfer(gc, who);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1659
9466
b6425eab60ca [gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents: 9030
diff changeset
1660 if (file)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1661 purple_xfer_request_accepted(xfer, file);
9466
b6425eab60ca [gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents: 9030
diff changeset
1662 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1663 purple_xfer_request(xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1664 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1665
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1666 #if ENABLE_FT_THUMBNAILS
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1667 static void
30118
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1668 jabber_si_thumbnail_cb(JabberData *data, gchar *alt, gpointer userdata)
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1669 {
30118
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1670 PurpleXfer *xfer = (PurpleXfer *) userdata;
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1671
30118
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1672 if (data) {
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1673 purple_xfer_set_thumbnail(xfer, jabber_data_get_data(data),
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1674 jabber_data_get_size(data), jabber_data_get_type(data));
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1675 /* data is ephemeral, get rid of now (the xfer re-owned the thumbnail */
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1676 jabber_data_destroy(data);
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1677 }
30118
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1678
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1679 purple_xfer_request(xfer);
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1680 }
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1681 #endif
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1682
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
1683 void jabber_si_parse(JabberStream *js, const char *from, JabberIqType type,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1684 const char *id, PurpleXmlNode *si)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1685 {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1686 JabberSIXfer *jsx;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1687 PurpleXfer *xfer;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1688 PurpleXmlNode *file, *feature, *x, *field, *option, *value;
31739
88b0a203e2e0 Silence a swath of warnings regarding set-but-unused.
Paul Aurich <darkrain42@pidgin.im>
parents: 31735
diff changeset
1689 #if ENABLE_FT_THUMBNAILS
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1690 PurpleXmlNode *thumbnail;
31739
88b0a203e2e0 Silence a swath of warnings regarding set-but-unused.
Paul Aurich <darkrain42@pidgin.im>
parents: 31735
diff changeset
1691 #endif
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
1692 const char *stream_id, *filename, *filesize_c, *profile;
32665
1ddb514482cb Update XMPP for 64-bit transfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
1693 goffset filesize = 0;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1694
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1695 if(!(profile = purple_xmlnode_get_attrib(si, "profile")) ||
30474
3f649d2041db jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <malu@pidgin.im>
parents: 30422
diff changeset
1696 strcmp(profile, NS_SI_FILE_TRANSFER))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1697 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1698
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1699 if(!(stream_id = purple_xmlnode_get_attrib(si, "id")))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1700 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1701
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1702 if(!(file = purple_xmlnode_get_child(si, "file")))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1703 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1704
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1705 if(!(filename = purple_xmlnode_get_attrib(file, "name")))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1706 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1707
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1708 if((filesize_c = purple_xmlnode_get_attrib(file, "size")))
32665
1ddb514482cb Update XMPP for 64-bit transfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32594
diff changeset
1709 filesize = g_ascii_strtoull(filesize_c, NULL, 10);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1710
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1711 if(!(feature = purple_xmlnode_get_child(si, "feature")))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1712 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1713
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1714 if(!(x = purple_xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data")))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1715 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1716
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
1717 if(!from)
10939
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1718 return;
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1719
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1720 /* 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
1721 * 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
1722 * with it */
30626
bec413ce77c7 Fix some "Dead nested assignment"s and then kill off some useless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30474
diff changeset
1723 if(jabber_si_xfer_find(js, stream_id, from) != NULL)
10939
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1724 return;
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1725
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1726 jsx = g_new0(JabberSIXfer, 1);
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
1727 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
1728
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1729 jsx->ibb_session = NULL;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1730
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1731 for(field = purple_xmlnode_get_child(x, "field"); field; field = purple_xmlnode_get_next_twin(field)) {
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1732 const char *var = purple_xmlnode_get_attrib(field, "var");
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1733 if(var && !strcmp(var, "stream-method")) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1734 for(option = purple_xmlnode_get_child(field, "option"); option;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1735 option = purple_xmlnode_get_next_twin(option)) {
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1736 if((value = purple_xmlnode_get_child(option, "value"))) {
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1737 char *val;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1738 if((val = purple_xmlnode_get_data(value))) {
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
1739 if(!strcmp(val, NS_BYTESTREAMS)) {
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1740 jsx->stream_method |= STREAM_METHOD_BYTESTREAMS;
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
1741 } else if(!strcmp(val, NS_IBB)) {
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1742 jsx->stream_method |= STREAM_METHOD_IBB;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1743 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1744 g_free(val);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1745 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1746 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1747 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1748 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1749 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1750
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1751 if(jsx->stream_method == STREAM_METHOD_UNKNOWN) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1752 g_free(jsx);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1753 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1754 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1755
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1756 jsx->js = js;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1757 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
1758 jsx->iq_id = g_strdup(id);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1759
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
1760 xfer = purple_xfer_new(purple_connection_get_account(js->gc), PURPLE_XFER_TYPE_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
1761 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
1762
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
1763 purple_xfer_set_protocol_data(xfer, jsx);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1764
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
1765 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
1766 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
1767 purple_xfer_set_size(xfer, filesize);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1768
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
1769 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
1770 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
1771 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
1772 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31123
diff changeset
1773
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
1774 js->file_transfers = g_list_append(js->file_transfers, xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1775
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1776 #if ENABLE_FT_THUMBNAILS
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1777 /* if there is a thumbnail, we should request it... */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1778 if ((thumbnail = purple_xmlnode_get_child_with_namespace(file, "thumbnail",
29466
9263cce2f6b3 Added the "thumbs" namespace to namespaces.h
Marcus Lundblad <malu@pidgin.im>
parents: 29465
diff changeset
1779 NS_THUMBS))) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1780 const char *cid = purple_xmlnode_get_attrib(thumbnail, "cid");
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1781 if (cid) {
30118
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1782 jabber_data_request(js, cid, purple_xfer_get_remote_user(xfer),
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1783 NULL, TRUE, jabber_si_thumbnail_cb, xfer);
31740
6a4a29d1541f jabber: This seems slightly more straightforward to me.
Paul Aurich <darkrain42@pidgin.im>
parents: 31739
diff changeset
1784 return;
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1785 }
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1786 }
31740
6a4a29d1541f jabber: This seems slightly more straightforward to me.
Paul Aurich <darkrain42@pidgin.im>
parents: 31739
diff changeset
1787 #endif
6a4a29d1541f jabber: This seems slightly more straightforward to me.
Paul Aurich <darkrain42@pidgin.im>
parents: 31739
diff changeset
1788
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1789 purple_xfer_request(xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1790 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1791
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1792 void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1793 jabber_si_init(void)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1794 {
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27140
diff changeset
1795 jabber_iq_register_handler("si", "http://jabber.org/protocol/si", jabber_si_parse);
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27140
diff changeset
1796
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1797 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
1798 }
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1799
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1800 void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1801 jabber_si_uninit(void)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1802 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1803 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
1804 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1805

mercurial