libpurple/protocols/jabber/si.c

Tue, 28 Feb 2023 03:23:06 -0600

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Tue, 28 Feb 2023 03:23:06 -0600
changeset 42105
e431d160e3a1
parent 41967
025eee9e6f1d
child 42127
18acb99a0fa6
permissions
-rw-r--r--

Fix leaks in requests

Fixes a leak for images in requests:
```
3,627 bytes in 1 blocks are definitely lost in loss record 35,636 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4995723: UnknownInlinedFun (gstrfuncs.c:426)
by 0x4995723: g_memdup2 (gstrfuncs.c:419)
by 0x4D3E534: purple_request_field_image_new (request.c:1677)
by 0x1CA970B1: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:553)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
by 0x581B132: g_action_activate (gaction.c:399)
by 0x51221B6: UnknownInlinedFun (gtkmenutrackeritem.c:842)
by 0x51221B6: gtk_popover_item_activate.lto_priv.0 (gtkmenusectionbox.c:200)
```
and leak of the GObject wrapper for request fields:
```
4 bytes in 1 blocks are possibly lost in loss record 713 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4995602: g_strdup (gstrfuncs.c:363)
by 0x488B324: create_list_field (gtkrequest.c:1504)
by 0x488D1D7: pidgin_request_fields (gtkrequest.c:2160)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
56 bytes in 1 blocks are possibly lost in loss record 19,209 of 36,499
at 0x48486AF: realloc (vg_replace_malloc.c:1451)
by 0x498071F: g_realloc (gmem.c:201)
by 0x49592C4: g_data_set_internal (gdataset.c:474)
by 0x488B347: create_list_field (gtkrequest.c:1504)
by 0x488D1D7: pidgin_request_fields (gtkrequest.c:2160)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
614 (192 direct, 422 indirect) bytes in 8 blocks are definitely lost in loss record 33,122 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4980168: g_malloc (gmem.c:130)
by 0x4997AB5: g_slice_alloc (gslice.c:1074)
by 0x49980EC: g_slice_alloc0 (gslice.c:1100)
by 0x4DDF04B: g_type_create_instance (gtype.c:1913)
by 0x4DC4C1F: g_object_new_internal (gobject.c:2228)
by 0x4DC6247: g_object_new_with_properties (gobject.c:2391)
by 0x4DC6FF0: g_object_new (gobject.c:2037)
by 0x488B2D5: create_list_field (gtkrequest.c:1499)
by 0x488D1D7: pidgin_request_fields (gtkrequest.c:2160)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
```
and a request label:
```
128 bytes in 1 blocks are definitely lost in loss record 27,735 of 36,499
at 0x484378A: malloc (vg_replace_malloc.c:392)
by 0x484870B: realloc (vg_replace_malloc.c:1451)
by 0x498071F: g_realloc (gmem.c:201)
by 0x499A343: g_string_maybe_expand (gstring.c:92)
by 0x499A3BF: g_string_sized_new (gstring.c:116)
by 0x4981BCB: g_markup_escape_text (gmarkup.c:2323)
by 0x4887D8A: pidgin_request_escape (gtkrequest.c:360)
by 0x488CED9: pidgin_request_fields (gtkrequest.c:2105)
by 0x4D3FFB8: purple_request_fields (request.c:2283)
by 0x1CA971D6: purple_demo_protocol_request_fields_activate (purpledemoprotocolactions.c:562)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
```
and one in the demo protocol:
```
40 bytes in 1 blocks are definitely lost in loss record 15,277 of 36,499
at 0x484386F: malloc (vg_replace_malloc.c:393)
by 0x4AE3017: __vasprintf_internal (vasprintf.c:71)
by 0x49C2E81: UnknownInlinedFun (stdio2.h:169)
by 0x49C2E81: g_vasprintf (gprintf.c:340)
by 0x4998EA0: g_strdup_vprintf (gstrfuncs.c:553)
by 0x4998F5C: g_strdup_printf (gstrfuncs.c:583)
by 0x1CA9584E: purple_demo_protocol_request_input_activate (purpledemoprotocolactions.c:203)
by 0x4DB5FBF: g_closure_invoke (gclosure.c:832)
by 0x4DE3D85: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
by 0x4DD3419: g_signal_emit_valist (gsignal.c:3549)
by 0x4DD3632: g_signal_emit (gsignal.c:3606)
by 0x581C784: g_simple_action_activate (gsimpleaction.c:227)
by 0x581B132: g_action_activate (gaction.c:399)
```

Testing Done:
Ran valgrind and confirmed above leaks were not there after opening Request Input and Request Fields.

Reviewed at https://reviews.imfreedom.org/r/2300/

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
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
25 #include <config.h>
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
26
40462
24ed25d87550 Fix some issues on macos that resulted from the internal.h cleanup
Gary Kramlich <grim@reaperworld.com>
parents: 40443
diff changeset
27 #include <errno.h>
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
28 #include <sys/types.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
29
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
30 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
31
40358
e6fe6fc1f516 move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents: 40158
diff changeset
32 #include <purple.h>
7395
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
40155
8f9d5d0acbbf Less delay for XMPP file transfer using streamhosts. Ignore 0.0.0.0.
Evert Mouw <post@evert.net>
parents: 39670
diff changeset
42 #define STREAMHOST_CONNECT_TIMEOUT 5
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
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
45 struct _JabberSIXfer {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
46 PurpleXfer parent;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
47
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
48 JabberStream *js;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
49
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
50 GCancellable *cancellable;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
51 GSocketClient *client;
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
52 GSocketService *service;
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
53 guint connect_timeout;
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
54
10940
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
55 gboolean accepted;
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
56
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
57 char *stream_id;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
58 char *iq_id;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
59
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
60 enum {
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
61 STREAM_METHOD_UNKNOWN = 0,
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
62 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
63 STREAM_METHOD_IBB = 2 << 2,
35977
9b7b48f446f4 Backport warning fixes from default
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31740
diff changeset
64 STREAM_METHOD_UNSUPPORTED = 2 << 30
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
65 } stream_method;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
66
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
67 GList *streamhosts;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
68
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
69 gchar *socks_buf;
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
70 GSocketConnection *local_streamhost_conn;
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;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
75 };
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
76
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
77 G_DEFINE_DYNAMIC_TYPE(JabberSIXfer, jabber_si_xfer, PURPLE_TYPE_XFER);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
78
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
79 /* some forward declarations */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
80 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
81
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
82 static PurpleXfer*
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
83 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
84 {
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
85 GList *xfers;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
86
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
87 if(!sid || !from)
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
88 return NULL;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
89
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90 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
91 PurpleXfer *xfer = xfers->data;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
92 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
93 if(jsx->stream_id && purple_xfer_get_remote_user(xfer) &&
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38327 38260
diff changeset
94 purple_strequal(jsx->stream_id, sid) && purple_strequal(purple_xfer_get_remote_user(xfer), from))
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 return xfer;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
96 }
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 return NULL;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
101
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
102
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
103 static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
104
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
105 static void
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
106 jabber_si_bytestreams_try_next_streamhost(PurpleXfer *xfer,
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
107 const gchar *error_message)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
108 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
109 JabberSIXfer *jsx = JABBER_SI_XFER(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
110 JabberBytestreamsStreamhost *streamhost = jsx->streamhosts->data;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
112 purple_debug_warning(
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
113 "jabber",
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
114 "si connection failed, jid was %s, host was %s, error was %s",
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
115 streamhost->jid, streamhost->host, error_message);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
116 jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
117 jabber_bytestreams_streamhost_free(streamhost);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
118 g_clear_object(&jsx->client);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
119 jabber_si_bytestreams_attempt_connect(xfer);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
120 }
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
121
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
122 static void
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
123 jabber_si_bytestreams_connect_cb(GObject *source, GAsyncResult *result,
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
124 gpointer user_data)
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
125 {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
126 PurpleXfer *xfer = PURPLE_XFER(user_data);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
127 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
128 GIOStream *stream = NULL;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
129 GError *error = NULL;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
130 GSocket *socket = NULL;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
131 JabberIq *iq = NULL;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
132 JabberBytestreamsStreamhost *streamhost = jsx->streamhosts->data;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
133
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
134 stream = g_proxy_connect_finish(G_PROXY(source), result, &error);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
135 if (stream == NULL) {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
136 if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
40588
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
137 purple_debug_error("jabber",
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
138 "Unable to connect to destination host: %s",
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
139 error->message);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
140 jabber_si_bytestreams_try_next_streamhost(
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
141 xfer, "Unable to connect to destination host.");
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
142 }
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
143
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
144 g_clear_error(&error);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
145 return;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
146 }
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
147
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
148 if (!G_IS_SOCKET_CONNECTION(stream)) {
40588
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
149 purple_debug_error("jabber",
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
150 "GProxy didn't return a GSocketConnection.");
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
151 jabber_si_bytestreams_try_next_streamhost(
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
152 xfer, "GProxy didn't return a GSocketConnection.");
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
153 g_object_unref(stream);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
154 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
155 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
156
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
157 /* unknown file transfer type is assumed to be RECEIVE */
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
158 if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND) {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
159 PurpleXmlNode *query, *activate;
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_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
161 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
162 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
163 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
164 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
165 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
166
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
167 /* TODO: We need to wait for an activation result before starting */
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
168 } else {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
169 PurpleXmlNode *query, *su;
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
170 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
171 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
172 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
173 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
174 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
175 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
176 }
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
177
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
178 jabber_iq_send(iq);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
179
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
180 jsx->local_streamhost_conn = G_SOCKET_CONNECTION(stream);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
181 socket = g_socket_connection_get_socket(jsx->local_streamhost_conn);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
182 purple_xfer_start(xfer, g_socket_get_fd(socket), NULL, -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
183 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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
26016
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
185 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
186 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
187 {
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
188 if (jsx->ibb_timeout_handle) {
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
189 g_source_remove(jsx->ibb_timeout_handle);
26016
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
190 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
191 }
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
192 }
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
193
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
194 static gboolean
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
195 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
196 {
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
197 PurpleXfer *xfer = (PurpleXfer *) data;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
198 JabberSIXfer *jsx = JABBER_SI_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
199
26016
9e3b8bdeed61 Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <malu@pidgin.im>
parents: 26015
diff changeset
200 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
201 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
202 "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
203 " up yet, cancel transfer");
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
204 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
205 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
206 }
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
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
208 return FALSE;
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
209 }
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
210
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
211 /* This is called when we connect to the SOCKS5 proxy server (through any
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
212 * relevant account proxy)
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
213 */
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
214 static void
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
215 jabber_si_bytestreams_socks5_connect_to_host_cb(GObject *source,
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
216 GAsyncResult *result,
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
217 gpointer user_data)
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
218 {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
219 PurpleXfer *xfer = PURPLE_XFER(user_data);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
220 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
221 JabberID *dstjid;
40588
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
222 const JabberID *from_jid, *to_jid;
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
223 GSocketConnection *conn;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
224 GProxy *proxy;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
225 GSocketAddress *addr;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
226 GInetSocketAddress *inet_addr;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
227 GSocketAddress *proxy_addr;
40588
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
228 gchar *dstaddr, *hash_input;
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
229 GError *error = NULL;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
230
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
231 conn = g_socket_client_connect_to_host_finish(G_SOCKET_CLIENT(source),
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
232 result, &error);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
233 if (conn == NULL) {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
234 if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
235 purple_debug_error("jabber", "Unable to connect to SOCKS5 host: %s",
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
236 error->message);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
237 jabber_si_bytestreams_try_next_streamhost(
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
238 xfer, "Unable to connect to SOCKS5 host.");
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
239 }
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
240
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
241 g_clear_error(&error);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
242 return;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
243 }
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
244
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
245 proxy = g_proxy_get_default_for_protocol("socks5");
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
246 if (proxy == NULL) {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
247 purple_debug_error("jabber", "SOCKS5 proxy backend missing.");
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
248 jabber_si_bytestreams_try_next_streamhost(
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
249 xfer, "SOCKS5 proxy backend missing.");
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
250 g_object_unref(conn);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
251 return;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
252 }
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
253
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
254 addr = g_socket_connection_get_remote_address(conn, &error);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
255 if (addr == NULL) {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
256 purple_debug_error(
40588
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
257 "jabber",
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
258 "Unable to retrieve SOCKS5 host address from connection: %s",
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
259 error->message);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
260 jabber_si_bytestreams_try_next_streamhost(
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
261 xfer, "Unable to retrieve SOCKS5 host address from connection");
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
262 g_object_unref(conn);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
263 g_object_unref(proxy);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
264 g_clear_error(&error);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
265 return;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
266 }
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
267
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
268 dstjid = jabber_id_new(purple_xfer_get_remote_user(xfer));
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
269
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
270 /* unknown file transfer type is assumed to be RECEIVE */
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
271 if (purple_xfer_get_xfer_type(xfer) == PURPLE_XFER_TYPE_SEND) {
40588
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
272 from_jid = jsx->js->user;
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
273 to_jid = dstjid;
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
274 } else {
40588
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
275 from_jid = dstjid;
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
276 to_jid = jsx->js->user;
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
277 }
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
278
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
279 /* Per XEP-0065, the 'host' must be SHA1(SID + from JID + to JID) */
40588
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
280 hash_input = g_strdup_printf("%s%s@%s/%s%s@%s/%s", jsx->stream_id,
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
281 from_jid->node, from_jid->domain,
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
282 from_jid->resource, to_jid->node,
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
283 to_jid->domain, to_jid->resource);
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
284 dstaddr = g_compute_checksum_for_string(G_CHECKSUM_SHA1, hash_input, -1);
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
285 g_free(hash_input);
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
286 jabber_id_free(dstjid);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
287
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
288 inet_addr = G_INET_SOCKET_ADDRESS(addr);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
289
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
290 proxy_addr =
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
291 g_proxy_address_new(g_inet_socket_address_get_address(inet_addr),
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
292 g_inet_socket_address_get_port(inet_addr),
40588
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
293 "socks5", dstaddr, 0, NULL, NULL);
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
294 g_object_unref(inet_addr);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
295
40588
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
296 purple_debug_info("jabber", "Connecting to %s using SOCKS5 proxy", dstaddr);
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
297
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
298 g_proxy_connect_async(proxy, G_IO_STREAM(conn), G_PROXY_ADDRESS(proxy_addr),
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
299 jsx->cancellable, jabber_si_bytestreams_connect_cb,
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
300 user_data);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
301
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
302 g_object_unref(proxy_addr);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
303 g_object_unref(conn);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
304 g_object_unref(proxy);
40588
abf38be27d21 Rename a few things in Jabber SI xfer to be clearer.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40587
diff changeset
305 g_free(dstaddr);
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
306 }
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
307
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
308 static void
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
309 jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
310 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
311 JabberSIXfer *jsx = JABBER_SI_XFER(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
312 JabberBytestreamsStreamhost *streamhost;
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
313 JabberID *dstjid;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
314
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
315 if(!jsx->streamhosts) {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
316 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
317 PurpleXmlNode *error, *inf;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
318
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
319 if(jsx->iq_id)
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
320 jabber_iq_set_id(iq, jsx->iq_id);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
321
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
322 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
323 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
324 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
325 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
326 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
327 purple_xmlnode_set_namespace(inf, NS_XMPP_STANZAS);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
328
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
329 jabber_iq_send(iq);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
330
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
331 /* 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
332 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
333 /* 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
334 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
335 "jabber_si_bytestreams_attempt_connect: "
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
336 "no streamhosts found, trying IBB\n");
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
337 if(jsx->stream_method & STREAM_METHOD_BYTESTREAMS) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
338 jsx->stream_method &= ~STREAM_METHOD_BYTESTREAMS;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
339 }
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
340 /* 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
341 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
342 receiver already... */
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
343 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
344 && !jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
345 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
346 } else {
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
347 /* setup a timeout to cancel waiting for IBB open */
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
348 jsx->ibb_timeout_handle = g_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
349 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
350 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
351 /* 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
352 already set up... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
353 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
354 purple_xfer_cancel_local(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
355 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
356
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
357 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
358 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
359
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
360 streamhost = jsx->streamhosts->data;
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
361 dstjid = jabber_id_new(purple_xfer_get_remote_user(xfer));
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
362
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
363 /* 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
364
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
365 if(dstjid != NULL && streamhost->host && streamhost->port > 0) {
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
366 GError *error = NULL;
31680
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 31645
diff changeset
367 PurpleAccount *account;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
368
31680
d3902c687705 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <datallah@pidgin.im>
parents: 31645
diff changeset
369 account = purple_connection_get_account(jsx->js->gc);
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
370 jsx->client = purple_gio_socket_client_new(account, &error);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
371 if (jsx->client != NULL) {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
372 if (purple_xfer_get_xfer_type(xfer) != PURPLE_XFER_TYPE_SEND) {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
373 /* When selecting a streamhost, timeout after
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
374 * STREAMHOST_CONNECT_TIMEOUT seconds, otherwise it takes
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
375 * forever
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
376 */
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
377 g_socket_client_set_timeout(jsx->client,
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
378 STREAMHOST_CONNECT_TIMEOUT);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
379 }
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
380
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
381 purple_debug_info("jabber",
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
382 "Connecting to SOCKS5 streamhost proxy %s:%d",
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
383 streamhost->host, streamhost->port);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
384
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
385 g_socket_client_connect_to_host_async(
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
386 jsx->client, streamhost->host, streamhost->port,
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
387 jsx->cancellable,
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
388 jabber_si_bytestreams_socks5_connect_to_host_cb, xfer);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
389 } else {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
390 purple_debug_error(
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
391 "jabber",
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
392 "Failed to connect to SOCKS5 streamhost proxy: %s",
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
393 error->message);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
394 g_clear_error(&error);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
395 }
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
396
14561
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
397 jabber_id_free(dstjid);
a8cd3be8821d [gaim-migrate @ 17218]
Nathan Walp <nwalp@pidgin.im>
parents: 14356
diff changeset
398 }
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
399
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
400 if (jsx->client == NULL) {
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
401 jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost);
40137
016690872c6c Add new and free functions for structs to reduce duplication
qarkai <qarkai@gmail.com>
parents: 39670
diff changeset
402 jabber_bytestreams_streamhost_free(streamhost);
14175
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
403 jabber_si_bytestreams_attempt_connect(xfer);
2bc5a80c5071 [gaim-migrate @ 16747]
Mark Doliner <markdoliner@pidgin.im>
parents: 14170
diff changeset
404 }
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
405 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
406
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
407 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
408 JabberIqType type, const char *id, PurpleXmlNode *query)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
409 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
410 PurpleXfer *xfer;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
411 JabberSIXfer *jsx;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
412 PurpleXmlNode *streamhost;
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
413 const char *sid;
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14329
diff changeset
414
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
415 if(type != JABBER_IQ_SET)
14356
7f4abf922cfa [gaim-migrate @ 16984]
Nathan Walp <nwalp@pidgin.im>
parents: 14329
diff changeset
416 return;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
417
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
418 if(!from)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
419 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
420
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
421 if(!(sid = purple_xmlnode_get_attrib(query, "sid")))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
422 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
423
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
424 if(!(xfer = jabber_si_xfer_find(js, sid, from)))
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
425 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
426
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
427 jsx = JABBER_SI_XFER(xfer);
10940
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
428
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
429 if(!jsx->accepted)
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
430 return;
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
431
37423
d2f0259aa43f Remove NULL-checks before free(). No functional change.
Michael McConville <mmcco@mykolab.com>
parents: 37158
diff changeset
432 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
433 jsx->iq_id = g_strdup(id);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
434
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
435 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
436 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
437 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
438 int portnum = 0;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
439
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
440 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
441 ((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
442 ((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
443 (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
444 (portnum = atoi(port))))) {
40155
8f9d5d0acbbf Less delay for XMPP file transfer using streamhosts. Ignore 0.0.0.0.
Evert Mouw <post@evert.net>
parents: 39670
diff changeset
445 /* ignore 0.0.0.0 */
40157
e74e34093dfa Fix an error caused by misreading purple_strequal()
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 40155
diff changeset
446 if(purple_strequal(host, "0.0.0.0") == FALSE) {
40155
8f9d5d0acbbf Less delay for XMPP file transfer using streamhosts. Ignore 0.0.0.0.
Evert Mouw <post@evert.net>
parents: 39670
diff changeset
447 JabberBytestreamsStreamhost *sh = g_new0(JabberBytestreamsStreamhost, 1);
8f9d5d0acbbf Less delay for XMPP file transfer using streamhosts. Ignore 0.0.0.0.
Evert Mouw <post@evert.net>
parents: 39670
diff changeset
448 sh->jid = g_strdup(jid);
8f9d5d0acbbf Less delay for XMPP file transfer using streamhosts. Ignore 0.0.0.0.
Evert Mouw <post@evert.net>
parents: 39670
diff changeset
449 sh->host = g_strdup(host);
8f9d5d0acbbf Less delay for XMPP file transfer using streamhosts. Ignore 0.0.0.0.
Evert Mouw <post@evert.net>
parents: 39670
diff changeset
450 sh->port = portnum;
8f9d5d0acbbf Less delay for XMPP file transfer using streamhosts. Ignore 0.0.0.0.
Evert Mouw <post@evert.net>
parents: 39670
diff changeset
451 sh->zeroconf = g_strdup(zeroconf);
8f9d5d0acbbf Less delay for XMPP file transfer using streamhosts. Ignore 0.0.0.0.
Evert Mouw <post@evert.net>
parents: 39670
diff changeset
452
8f9d5d0acbbf Less delay for XMPP file transfer using streamhosts. Ignore 0.0.0.0.
Evert Mouw <post@evert.net>
parents: 39670
diff changeset
453 /* If there were a lot of these, it'd be worthwhile to prepend and reverse. */
8f9d5d0acbbf Less delay for XMPP file transfer using streamhosts. Ignore 0.0.0.0.
Evert Mouw <post@evert.net>
parents: 39670
diff changeset
454 jsx->streamhosts = g_list_append(jsx->streamhosts, sh);
8f9d5d0acbbf Less delay for XMPP file transfer using streamhosts. Ignore 0.0.0.0.
Evert Mouw <post@evert.net>
parents: 39670
diff changeset
455 }
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
456 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
457 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
458
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
459 jabber_si_bytestreams_attempt_connect(xfer);
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
460 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
461
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
462 static void
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
463 jabber_si_xfer_bytestreams_send_write_response_cb(GObject *source,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
464 GAsyncResult *result,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
465 gpointer user_data)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
466 {
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
467 PurpleXfer *xfer = PURPLE_XFER(user_data);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
468 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
469 gsize bytes_written = 0;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
470 GError *error = NULL;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
471
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
472 if (!g_output_stream_write_all_finish(G_OUTPUT_STREAM(source), result,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
473 &bytes_written, &error)) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
474 if (error->code != G_IO_ERROR_CANCELLED) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
475 purple_xfer_cancel_remote(xfer);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
476 }
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
477 g_clear_error(&error);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
478 } else {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
479 /* Before actually starting sending the file, we need to wait until the
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
480 * recipient sends the IQ result with <streamhost-used/>
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
481 */
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
482 purple_debug_info("jabber",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
483 "SOCKS5 connection negotiation completed. Waiting "
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
484 "for IQ result to start file transfer.");
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
485 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
486
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
487 g_clear_pointer(&jsx->socks_buf, g_free);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
488 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
489
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
490 static void
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
491 jabber_si_xfer_bytestreams_send_read_request_cb(GObject *source,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
492 GAsyncResult *result,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
493 gpointer user_data)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
494 {
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
495 PurpleXfer *xfer = PURPLE_XFER(user_data);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
496 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
497 gsize bytes_read = 0;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
498 GError *error = NULL;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
499 GOutputStream *output = NULL;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
500 gsize bufsize;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
501 gchar *dstaddr, *hash;
40110
bc2b94f2595a Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40107
diff changeset
502 gchar *host;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
503
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
504 purple_debug_info("jabber",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
505 "in jabber_si_xfer_bytestreams_send_read_request_cb");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
506
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
507 if (!g_input_stream_read_all_finish(G_INPUT_STREAM(source), result,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
508 &bytes_read, &error)) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
509 if (error->code != G_IO_ERROR_CANCELLED) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
510 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
511 }
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
512 g_clear_error(&error);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
513 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
514 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
515
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
516 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
517 jsx->js->user->node, jsx->js->user->domain,
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
518 jsx->js->user->resource, purple_xfer_get_remote_user(xfer));
10684
0325b164a7eb [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents: 10112
diff changeset
519
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
520 /* Per XEP-0065, the 'host' must be SHA1(SID + from JID + to JID) */
38327
c842a56b9967 jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents: 37423
diff changeset
521 hash = g_compute_checksum_for_string(G_CHECKSUM_SHA1, dstaddr, -1);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
522
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
523 if (strncmp(hash, jsx->socks_buf + 5, 40) || jsx->socks_buf[45] != 0x00 ||
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
524 jsx->socks_buf[46] != 0x00) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
525 if (jsx->socks_buf[45] != 0x00 || jsx->socks_buf[46] != 0x00) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
526 purple_debug_error("jabber",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
527 "Got SOCKS5 BS conn with the wrong DST.PORT "
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
528 "(must be 0 - got[0x%x,0x%x]).",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
529 jsx->socks_buf[45], jsx->socks_buf[46]);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
530 } else {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
531 purple_debug_error("jabber",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
532 "Got SOCKS5 BS conn with the wrong DST.ADDR "
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
533 "(expected '%s' - got '%.40s').",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
534 hash, jsx->socks_buf + 5);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
535 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
536 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
537 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
538 g_free(dstaddr);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
539 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
540 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
541
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
542 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
543 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
544
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
545 g_free(jsx->socks_buf);
40107
6320c272e8b2 xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39670
diff changeset
546 host = purple_network_get_my_ip_from_gio(
6320c272e8b2 xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39670
diff changeset
547 G_SOCKET_CONNECTION(jsx->js->stream));
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
548
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
549 bufsize = 5 + strlen(host) + 2;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
550 jsx->socks_buf = g_malloc(bufsize);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
551
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
552 jsx->socks_buf[0] = 0x05;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
553 jsx->socks_buf[1] = 0x00;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
554 jsx->socks_buf[2] = 0x00;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
555 jsx->socks_buf[3] = 0x03;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
556 jsx->socks_buf[4] = strlen(host);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
557 memcpy(jsx->socks_buf + 5, host, strlen(host));
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
558 jsx->socks_buf[5 + strlen(host)] = 0x00;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
559 jsx->socks_buf[6 + strlen(host)] = 0x00;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
560
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
561 output = g_io_stream_get_output_stream(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
562 G_IO_STREAM(jsx->local_streamhost_conn));
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
563 g_output_stream_write_all_async(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
564 output, jsx->socks_buf, bufsize, G_PRIORITY_DEFAULT,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
565 jsx->cancellable, jabber_si_xfer_bytestreams_send_write_response_cb,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
566 xfer);
40110
bc2b94f2595a Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40107
diff changeset
567
bc2b94f2595a Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40107
diff changeset
568 g_free(host);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
569 }
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
570
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
571 static void
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
572 jabber_si_xfer_bytestreams_send_read_request_header_cb(GObject *source,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
573 GAsyncResult *result,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
574 gpointer user_data)
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
575 {
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
576 GInputStream *input = G_INPUT_STREAM(source);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
577 PurpleXfer *xfer = PURPLE_XFER(user_data);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
578 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
579 gsize bytes_read = 0;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
580 GError *error = NULL;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
581
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
582 purple_debug_info(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
583 "jabber",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
584 "in jabber_si_xfer_bytestreams_send_read_request_header_cb");
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
585
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
586 if (!g_input_stream_read_all_finish(input, result, &bytes_read, &error)) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
587 if (error->code != G_IO_ERROR_CANCELLED) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
588 purple_xfer_cancel_remote(xfer);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
589 }
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
590 g_clear_error(&error);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
591 return;
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
592 }
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
593
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
594 if (jsx->socks_buf[0] != 0x05 || jsx->socks_buf[1] != 0x01 ||
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
595 jsx->socks_buf[3] != 0x03 || jsx->socks_buf[4] != 40) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
596 purple_debug_info(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
597 "jabber",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
598 "Invalid socks5 conn req. header[0x%x,0x%x,0x%x,0x%x,0x%x]",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
599 jsx->socks_buf[0], jsx->socks_buf[1], jsx->socks_buf[2],
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
600 jsx->socks_buf[3], jsx->socks_buf[4]);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
601 purple_xfer_cancel_remote(xfer);
13493
598d8f618a31 [gaim-migrate @ 15868]
Richard Laager <rlaager@pidgin.im>
parents: 13441
diff changeset
602 return;
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
603 }
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
604
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
605 /* Read DST.ADDR and the following 2-byte port number. */
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
606 purple_debug_info("jabber", "reading %u bytes for DST.ADDR + port num",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
607 jsx->socks_buf[4] + 2);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
608 g_input_stream_read_all_async(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
609 input, jsx->socks_buf + 5, jsx->socks_buf[4] + 2,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
610 G_PRIORITY_DEFAULT, jsx->cancellable,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
611 jabber_si_xfer_bytestreams_send_read_request_cb, xfer);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
612 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
613
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
614 static void
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
615 jabber_si_xfer_bytestreams_send_write_method_cb(GObject *source,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
616 GAsyncResult *result,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
617 gpointer user_data)
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
618 {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
619 PurpleXfer *xfer = PURPLE_XFER(user_data);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
620 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
621 gsize bytes_written = 0;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
622 GError *error = NULL;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
623
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
624 if (!g_output_stream_write_all_finish(G_OUTPUT_STREAM(source), result,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
625 &bytes_written, &error)) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
626 if (error->code != G_IO_ERROR_CANCELLED) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
627 purple_xfer_cancel_remote(xfer);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
628 }
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
629 g_clear_pointer(&jsx->socks_buf, g_free);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
630 g_clear_error(&error);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
631 return;
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
632 }
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
633
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
634 /* If we sent a "Success", wait for a response, otherwise give up and cancel */
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
635 if (jsx->socks_buf[1] == 0x00) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
636 GInputStream *input = g_io_stream_get_input_stream(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
637 G_IO_STREAM(jsx->local_streamhost_conn));
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
638
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
639 g_free(jsx->socks_buf);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
640 /* Request is: Version, Command, Reserved, Address type, Address length,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
641 * Address (up to 255), 2-byte port */
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
642 jsx->socks_buf = g_malloc(5 + 255 + 2);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
643 g_input_stream_read_all_async(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
644 input, jsx->socks_buf, 5, G_PRIORITY_DEFAULT, jsx->cancellable,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
645 jabber_si_xfer_bytestreams_send_read_request_header_cb, xfer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
646 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
647 purple_xfer_cancel_remote(xfer);
13201
8c224ef70efa [gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents: 13146
diff changeset
648 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
649 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
650
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
651 static void
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
652 jabber_si_xfer_bytestreams_send_read_methods_cb(GObject *source,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
653 GAsyncResult *result,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
654 gpointer user_data)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
655 {
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
656 PurpleXfer *xfer = PURPLE_XFER(user_data);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
657 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
658 gsize bytes_read = 0;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
659 GError *error = NULL;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
660 GOutputStream *output;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
661 gboolean valid_method_found = FALSE;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
662 gint i;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
663
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
664 purple_debug_info("jabber",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
665 "in jabber_si_xfer_bytestreams_send_read_methods_cb");
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
666
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
667 if (!g_input_stream_read_all_finish(G_INPUT_STREAM(source), result,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
668 &bytes_read, &error)) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
669 if (error->code != G_IO_ERROR_CANCELLED) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
670 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
671 }
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
672 g_clear_error(&error);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
673 return;
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
674 }
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
675
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
676 purple_debug_info("jabber", "going to test %u different methods",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
677 jsx->socks_buf[1]);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
678
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
679 for (i = 0; i < jsx->socks_buf[1]; i++) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
680 purple_debug_info("jabber", "testing %u", jsx->socks_buf[i + 2]);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
681 if (jsx->socks_buf[i + 2] == 0x00) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
682 valid_method_found = TRUE;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
683 break;
8316
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 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
686
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
687 g_free(jsx->socks_buf);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
688 jsx->socks_buf = g_malloc(2);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
689 jsx->socks_buf[0] = 0x05;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
690 jsx->socks_buf[1] = valid_method_found ? 0x00 : 0xFF;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
691 output = g_io_stream_get_output_stream(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
692 G_IO_STREAM(jsx->local_streamhost_conn));
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
693 g_output_stream_write_all_async(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
694 output, jsx->socks_buf, 2, G_PRIORITY_DEFAULT, jsx->cancellable,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
695 jabber_si_xfer_bytestreams_send_write_method_cb, xfer);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
696 }
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
697
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
698 static void
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
699 jabber_si_xfer_bytestreams_send_read_version_cb(GObject *source,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
700 GAsyncResult *result,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
701 gpointer user_data)
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
702 {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
703 GInputStream *input = G_INPUT_STREAM(source);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
704 PurpleXfer *xfer = PURPLE_XFER(user_data);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
705 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
706 gsize bytes_read = 0;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
707 GError *error = NULL;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
708
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
709 purple_debug_info("jabber",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
710 "in jabber_si_xfer_bytestreams_send_read_version_cb");
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
711
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
712 /* Try to read the SOCKS5 header */
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
713 if (!g_input_stream_read_all_finish(input, result, &bytes_read, &error)) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
714 if (error->code != G_IO_ERROR_CANCELLED) {
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
715 purple_xfer_cancel_remote(xfer);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
716 }
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
717 g_clear_error(&error);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
718 return;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
719 }
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
720
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
721 purple_debug_info("jabber", "checking to make sure we're socks FIVE");
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
722 if (jsx->socks_buf[0] != 0x05) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
723 purple_xfer_cancel_remote(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
724 return;
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
725 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
726
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
727 /* Number of methods is given in second byte. */
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
728 purple_debug_info("jabber", "reading %u bytes for auth methods",
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
729 jsx->socks_buf[1]);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
730 g_input_stream_read_all_async(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
731 input, jsx->socks_buf + 2, jsx->socks_buf[1], G_PRIORITY_DEFAULT,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
732 jsx->cancellable, jabber_si_xfer_bytestreams_send_read_methods_cb,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
733 xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
734 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
735
21688
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
736 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
737 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
738 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
739 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
740
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
741 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
742 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
743
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
744 return 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
745 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
746
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
747 static void
41967
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
748 jabber_si_xfer_bytestreams_send_connected_cb(G_GNUC_UNUSED GSocketService *service,
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
749 GSocketConnection *connection,
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
750 GObject *source_object,
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
751 G_GNUC_UNUSED gpointer data)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
752 {
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
753 PurpleXfer *xfer = PURPLE_XFER(source_object);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
754 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
755 GInputStream *input = NULL;
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
756
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
757 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
758
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
759 jsx->local_streamhost_conn = g_object_ref(connection);
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
760 g_socket_service_stop(jsx->service);
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
761 g_clear_object(&jsx->service);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
762
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
763 /* Initial message is: Version, Method count, up to 255 methods. */
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
764 jsx->socks_buf = g_malloc(2 + 255);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
765 input = g_io_stream_get_input_stream(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
766 G_IO_STREAM(jsx->local_streamhost_conn));
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
767 g_input_stream_read_all_async(
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
768 input, jsx->socks_buf, 2, G_PRIORITY_DEFAULT, jsx->cancellable,
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
769 jabber_si_xfer_bytestreams_send_read_version_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
770 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
771
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 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
773 jabber_si_connect_proxy_cb(JabberStream *js, const char *from,
41967
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
774 JabberIqType type, G_GNUC_UNUSED 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
775 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
776 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
777 PurpleXfer *xfer = data;
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
778 JabberSIXfer *jsx;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
779 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
780 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
781 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
782
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
783 /* 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
784
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
785 /* 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
786 if (!g_list_find(js->file_transfers, xfer)) {
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
787 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
788 return;
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
789 }
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
790
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
791 jsx = JABBER_SI_XFER(xfer);
32245
6e7b93c200fe Convert the jabber prpl to use the new API.
Andrew Victor <andrew.victor@mxit.com>
parents: 31740
diff changeset
792
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
793 /* 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
794 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
795 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
796
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
797 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
798 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
799 "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
800 /* 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
801 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
802 "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
803 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
804 if (jsx->stream_method & STREAM_METHOD_IBB) {
41084
72d6941bfa2e Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40817
diff changeset
805 /* if we previously tried bytestreams, we need to disable it. */
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
806 if(jsx->stream_method & STREAM_METHOD_BYTESTREAMS) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
807 jsx->stream_method &= ~STREAM_METHOD_BYTESTREAMS;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
808 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
809
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
810 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
811 /* 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
812 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
813 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
814 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
815 && !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
816 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
817 } else {
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
818 jsx->ibb_timeout_handle = g_timeout_add_seconds(30,
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
819 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
820 }
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
821 /* 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
822 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
823 } 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
824 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
825 }
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
826 return;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
827 }
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
828
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
829 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
830 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
831
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
832 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
833 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
834
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
835 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
836 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
837
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
838 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
839 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
840
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
841 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
842 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
843
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
844 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
845 {
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
846 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
847 jsx->js->user->domain, jsx->js->user->resource);
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 36256
diff changeset
848 if (purple_strequal(jid, my_jid)) {
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
849 GSocket *sock = NULL;
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
850 gint fd = -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
851 purple_debug_info("jabber", "Got local SOCKS5 streamhost-used.\n");
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
852 sock = g_socket_connection_get_socket(jsx->local_streamhost_conn);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
853 fd = g_socket_get_fd(sock);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
854 _purple_network_set_common_socket_flags(fd);
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
855 purple_xfer_start(xfer, fd, NULL, -1);
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
856 } else {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
857 /* 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
858 if (jsx->stream_method & STREAM_METHOD_IBB) {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
859 if(jsx->stream_method & STREAM_METHOD_BYTESTREAMS) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
860 jsx->stream_method &= ~STREAM_METHOD_BYTESTREAMS;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
861 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
862
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
863 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
864 "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
865 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
866 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
867 } else {
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
868 jsx->ibb_timeout_handle = g_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
869 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
870 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
871 /* 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
872 } 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
873 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
874 "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
875 purple_xfer_cancel_local(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
876 }
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
877 }
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
878 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
879 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
880 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
881
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
882 /* Clean up the local streamhost - it isn't going to be used.*/
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
883 g_clear_object(&jsx->local_streamhost_conn);
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
884 if (jsx->service) {
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
885 g_socket_service_stop(jsx->service);
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
886 g_clear_object(&jsx->service);
23169
dcdd90413703 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents: 23075
diff changeset
887 }
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
888
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
889 jsx->streamhosts = g_list_remove_link(jsx->streamhosts, matched);
40137
016690872c6c Add new and free functions for structs to reduce duplication
qarkai <qarkai@gmail.com>
parents: 39670
diff changeset
890 g_list_free_full(jsx->streamhosts, (GDestroyNotify)jabber_bytestreams_streamhost_free);
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
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 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
893
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next 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 jabber_si_bytestreams_attempt_connect(xfer);
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
895 }
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
896
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
897 static void
40403
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
898 jabber_si_xfer_bytestreams_send_local_info(PurpleXfer *xfer, GList *local_ips)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
899 {
40403
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
900 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
901 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
902 PurpleXmlNode *query, *streamhost;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
903 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
904 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
905 JabberBytestreamsStreamhost *sh, *sh2;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
906 int streamhost_count = 0;
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
907
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28979
diff changeset
908 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
909 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
910 query = purple_xmlnode_get_child(iq->node, "query");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
911
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
912 purple_xmlnode_set_attrib(query, "sid", jsx->stream_id);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
913
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
914 /* If we successfully started listening locally */
40403
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
915 if (local_ips) {
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
916 gchar *jid;
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
917
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
918 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
919 jsx->js->user->domain, jsx->js->user->resource);
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
920 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
921
29510
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
922 /* 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
923 while (local_ips) {
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
924 gchar *local_ip = local_ips->data;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
925 streamhost_count++;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
926 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
927 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
928 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
929 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
930 g_free(local_ip);
9c636f4b965c Add a function to enumerate all local IPs
Marcus Lundblad <malu@pidgin.im>
parents: 28322
diff changeset
931 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
932 }
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
933
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
934 g_free(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
935 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
936
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
937 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
938 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
939
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
940 /* 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
941
40405
dc115c3b7694 Cleanup some list iteration.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40404
diff changeset
942 if (!sh->jid) {
dc115c3b7694 Cleanup some list iteration.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40404
diff changeset
943 continue;
dc115c3b7694 Cleanup some list iteration.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40404
diff changeset
944 } else if (!sh->host) {
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
945 continue;
40405
dc115c3b7694 Cleanup some list iteration.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40404
diff changeset
946 } else if (sh->port <= 0) {
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 continue;
40405
dc115c3b7694 Cleanup some list iteration.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40404
diff changeset
948 } else if (g_list_find_custom(jsx->streamhosts, sh->jid,
dc115c3b7694 Cleanup some list iteration.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40404
diff changeset
949 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
950 continue;
40403
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
951 }
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
952
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
953 streamhost_count++;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
954 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
955 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
956 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
957 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
958 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
959
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
960 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
961 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
962 sh2->host = g_strdup(sh->host);
23075
b25e0581e5a8 Reuse cleanup function.
Daniel Atallah <datallah@pidgin.im>
parents: 22816
diff changeset
963 /*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
964 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
965
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
966 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
967 }
a16385b34219 Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <datallah@pidgin.im>
parents: 21646
diff changeset
968
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
969 /* 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
970 if (streamhost_count == 0) {
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
971 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
972
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
973 /* if available, revert to IBB */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
974 if (jsx->stream_method & STREAM_METHOD_IBB) {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
975 if(jsx->stream_method & STREAM_METHOD_BYTESTREAMS) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
976 jsx->stream_method &= ~STREAM_METHOD_BYTESTREAMS;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
977 }
40403
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
978 purple_debug_info("jabber", "jabber_si_xfer_bytestreams_send_local_"
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
979 "info: 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
980 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
981 /* 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
982 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
983 } else {
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
984 jsx->ibb_timeout_handle = g_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
985 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
986 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
987 /* 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
988 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
989 } 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
990 /* 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
991 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
992 purple_xfer_cancel_local(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
993 }
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
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
995 return;
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
996 }
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
997
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
998 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
999
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1000 jabber_iq_send(iq);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
1001 }
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
1002
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
1003 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1004 jabber_si_xfer_bytestreams_send_init(PurpleXfer *xfer)
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
1005 {
40403
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
1006 JabberSIXfer *jsx = JABBER_SI_XFER(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
1007 PurpleProxyType proxy_type;
40403
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
1008 GList *local_ips = NULL;
23506
aeba2ae6a455 Improve error handling for xmpp file transfers.
Daniel Atallah <datallah@pidgin.im>
parents: 23505
diff changeset
1009
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
1010 /* 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
1011 * 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
1012 proxy_type = purple_proxy_info_get_proxy_type(
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1013 purple_proxy_get_setup(purple_connection_get_account(jsx->js->gc)));
41318
56092ffeae95 Move PurpleProxyInfo from a boxed type to a GObject
Gary Kramlich <grim@reaperworld.com>
parents: 41084
diff changeset
1014 if (proxy_type == PURPLE_PROXY_TYPE_TOR) {
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
1015 purple_debug_info("jabber", "Skipping attempting local streamhost.\n");
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1016 jsx->service = NULL;
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1017 } else {
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1018 guint16 port = 0;
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1019 GError *error = NULL;
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1020 jsx->service = g_socket_service_new();
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1021 port = purple_socket_listener_add_any_inet_port(
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1022 G_SOCKET_LISTENER(jsx->service), G_OBJECT(xfer), &error);
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1023 if (port != 0) {
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1024 purple_xfer_set_local_port(xfer, port);
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1025 } else {
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1026 purple_debug_error("jabber",
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1027 "Unable to create streamhost socket listener: "
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1028 "%s. Trying proxy instead.",
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1029 error->message);
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1030 g_error_free(error);
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1031 g_clear_object(&jsx->service);
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1032 }
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
1033 }
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
1034
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1035 if (jsx->service) {
40403
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
1036 gchar *public_ip;
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
1037
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
1038 /* Include the public IP (assuming there is a port mapped somehow) */
40405
dc115c3b7694 Cleanup some list iteration.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40404
diff changeset
1039 public_ip = purple_network_get_my_ip_from_gio(
dc115c3b7694 Cleanup some list iteration.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40404
diff changeset
1040 G_SOCKET_CONNECTION(jsx->js->stream));
41826
0c1829dae5b6 Remove the libnice dependency
Gary Kramlich <grim@reaperworld.com>
parents: 41791
diff changeset
1041 if (!purple_strequal(public_ip, "0.0.0.0")) {
40403
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
1042 local_ips = g_list_append(local_ips, public_ip);
40405
dc115c3b7694 Cleanup some list iteration.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40404
diff changeset
1043 } else {
dc115c3b7694 Cleanup some list iteration.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40404
diff changeset
1044 g_free(public_ip);
40403
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
1045 }
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
1046
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1047 g_signal_connect(
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1048 G_OBJECT(jsx->service), "incoming",
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1049 G_CALLBACK(jabber_si_xfer_bytestreams_send_connected_cb), NULL);
40403
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
1050 }
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
1051
5529108bd66e Split jabber_si_xfer_bytestreams_listen_cb in half.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40358
diff changeset
1052 jabber_si_xfer_bytestreams_send_local_info(xfer, local_ips);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1053 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1054
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1055 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1056 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
1057 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1058 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
1059
27525
579b9d64b364 A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27332
diff changeset
1060 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
1061 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
1062 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1063
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1064 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1065 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
1066 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1067 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
1068
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1069 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
1070 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
1071 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
1072 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1073 purple_xfer_set_completed(xfer, TRUE);
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1074 purple_xfer_end(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1075 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1076 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1077
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1078 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1079 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
1080 gsize size)
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1081 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1082 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1083 JabberSIXfer *jsx = JABBER_SI_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
1084
35029
f9f672dcaadf Fixed warnings
Ankit Vani <a@nevitus.org>
parents: 35001
diff changeset
1085 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
1086 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
1087 size);
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1088 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
1089 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
1090 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1091 /* 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
1092 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
1093 purple_debug_error("jabber",
26020
0e7f4920e969 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <darkrain42@pidgin.im>
parents: 26016
diff changeset
1094 "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
1095 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
1096 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1097
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1098 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1099
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1100 static gssize
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1101 jabber_si_xfer_ibb_read(PurpleXfer *xfer, guchar **out_buffer, size_t buf_size)
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1102 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1103 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1104 guchar *buffer;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1105 gsize size;
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1106 gsize tmp;
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1107
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1108 if(jsx->stream_method & STREAM_METHOD_BYTESTREAMS) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1109 return PURPLE_XFER_CLASS(jabber_si_xfer_parent_class)->read(xfer, out_buffer, buf_size);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1110 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1111
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1112 size = purple_circular_buffer_get_used(jsx->ibb_buffer);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1113
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1114 *out_buffer = buffer = g_malloc(size);
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1115 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
1116 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
1117 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
1118 buffer += tmp;
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1119 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
1120 }
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1121
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1122 return size;
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1123 }
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1124
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1125 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
1126 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
1127 PurpleXmlNode *open)
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1128 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1129 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
1130 PurpleXfer *xfer = jabber_si_xfer_find(js, sid, who);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1131
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1132 if (xfer) {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1133 JabberSIXfer *jsx = JABBER_SI_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
1134 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
1135 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
1136
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1137 jabber_si_bytestreams_ibb_timeout_remove(jsx);
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1138
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1139 if (sess) {
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1140 /* setup callbacks here...*/
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1141 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
1142 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
1143 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
1144 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
1145 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
1146 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
1147
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1148 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
1149 /* 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
1150 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
1151 (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
1152 jsx->ibb_buffer =
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1153 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
1154
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1155 /* 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
1156 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
1157 return TRUE;
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1158 } else {
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1159 /* 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
1160 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
1161 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
1162 return FALSE;
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1163 }
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1164 } else {
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1165 /* 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
1166 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
1167 "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
1168 return FALSE;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1169 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1170 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1171
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1172 static gssize
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1173 jabber_si_xfer_ibb_write(PurpleXfer *xfer, const guchar *buffer, size_t len)
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1174 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1175 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1176 JabberIBBSession *sess = jsx->ibb_session;
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1177 gsize packet_size;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1178
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1179 if(jsx->stream_method & STREAM_METHOD_BYTESTREAMS) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1180 purple_debug_error("jabber", "falling back to raw socket\n");
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1181 return PURPLE_XFER_CLASS(jabber_si_xfer_parent_class)->write(xfer, buffer, len);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1182 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1183
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1184 packet_size = MIN(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
1185
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1186 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
1187
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1188 return packet_size;
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1189 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1190
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1191 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1192 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
1193 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1194 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
1195 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
1196
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1197 if (remaining == 0) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1198 /* close the session */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1199 jabber_ibb_session_close(sess);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1200 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
1201 purple_xfer_end(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1202 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1203 /* send more... */
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
1204 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
1205 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1206 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1207
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1208 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1209 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
1210 {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1211 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
1212
25997
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1213 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
1214 purple_xfer_start(xfer, -1, NULL, 0);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
1215 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
1216 } else {
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1217 /* error */
e871edaa1835 Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <malu@pidgin.im>
parents: 25995
diff changeset
1218 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
1219 }
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1220 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1221
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1222 static void
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1223 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
1224 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1225 JabberSIXfer *jsx = JABBER_SI_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
1226
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1227 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
1228 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
1229
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1230 if (jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1231 /* should set callbacks here... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1232 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
1233 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
1234 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
1235 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
1236 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
1237 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
1238 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
1239 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
1240
28157
03df7915ebb4 jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <darkrain42@pidgin.im>
parents: 28152
diff changeset
1241 jsx->ibb_buffer =
34529
68cf25486001 GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents: 33895
diff changeset
1242 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
1243
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1244 /* open the IBB session */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1245 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
1246
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1247 } else {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1248 /* 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
1249 purple_debug_error("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1250 "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
1251 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
1252 }
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1253 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1254
41967
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1255 static void
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1256 jabber_si_xfer_send_method_cb(JabberStream *js, G_GNUC_UNUSED const char *from,
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1257 G_GNUC_UNUSED JabberIqType type,
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1258 G_GNUC_UNUSED const char *id,
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1259 PurpleXmlNode *packet, gpointer data)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1260 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1261 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
1262 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
1263 gboolean found_method = FALSE;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1264
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1265 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
1266 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1267 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1268 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1269
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1270 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
1271 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1272 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1273 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1274
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1275 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
1276 purple_xfer_cancel_remote(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1277 return;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1278 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1279
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1280 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
1281 const char *var = purple_xmlnode_get_attrib(field, "var");
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1282 JabberSIXfer *jsx = JABBER_SI_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
1283
38260
dcada91c0912 Remove redundant NULL checks
qarkai <qarkai@gmail.com>
parents: 38259
diff changeset
1284 if(purple_strequal(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
1285 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
1286 char *val = purple_xmlnode_get_data(value);
38260
dcada91c0912 Remove redundant NULL checks
qarkai <qarkai@gmail.com>
parents: 38259
diff changeset
1287 if(purple_strequal(val, NS_BYTESTREAMS)) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1288 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
1289 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
1290 found_method = TRUE;
38260
dcada91c0912 Remove redundant NULL checks
qarkai <qarkai@gmail.com>
parents: 38259
diff changeset
1291 } else if (purple_strequal(val, NS_IBB)) {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1292 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
1293 if (!found_method) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1294 /* 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
1295 start IBB right away... */
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1296 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
1297 found_method = TRUE;
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1298 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1299 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1300 g_free(val);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1301 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1302 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1303 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1304
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1305 if (!found_method) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1306 purple_xfer_cancel_remote(xfer);
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1307 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1308
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1309 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1310
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1311 static void jabber_si_xfer_send_request(PurpleXfer *xfer)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1312 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1313 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1314 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1315 PurpleXmlNode *si, *file, *feature, *x, *field, *option, *value;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1316 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
1317 #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
1318 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
1319 gsize thumb_size;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1320
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1321 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
1322 #endif
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1323 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
1324
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1325 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
1326 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
1327 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
1328 purple_xmlnode_set_namespace(si, "http://jabber.org/protocol/si");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1329 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
1330 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
1331 purple_xmlnode_set_attrib(si, "profile", NS_SI_FILE_TRANSFER);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1332
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1333 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
1334 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
1335 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
1336 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
1337 purple_xmlnode_set_attrib(file, "size", buf);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1338 /* maybe later we'll do hash and date attribs */
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1339
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1340 #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
1341 /* 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
1342 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
1343 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
1344 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
1345 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
1346 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
1347 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
1348 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
1349 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
1350 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
1351 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
1352 /* cache data */
c19f67250659 Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <malu@pidgin.im>
parents: 27420
diff changeset
1353 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
1354 }
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1355 #endif
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31123
diff changeset
1356
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1357 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
1358 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
1359 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
1360 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
1361 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
1362 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
1363 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
1364 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
1365 /* 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
1366 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
1367 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
1368 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
1369 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
1370 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
1371 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
1372 purple_xmlnode_insert_data(value, NS_IBB, -1);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1373
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1374 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
1375
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
1376 /* 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
1377 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
1378 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
1379
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1380 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1381 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1382
26021
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1383 /*
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1384 * 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
1385 * (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
1386 * purple_xfer_request_denied.
d566a418eeee Standardize all the IBB stream cleanup
Paul Aurich <darkrain42@pidgin.im>
parents: 26020
diff changeset
1387 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1388 static void jabber_si_xfer_cancel_send(PurpleXfer *xfer)
8316
7de7b31679a2 [gaim-migrate @ 9040]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
1389 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1390 JabberSIXfer *jsx = JABBER_SI_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
1391
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1392 /* 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
1393 if (jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1394 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
1395 }
28828
7c1855f037e7 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
1396 purple_debug_info("jabber", "in jabber_si_xfer_cancel_send\n");
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
1397
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
1398 g_cancellable_cancel(jsx->cancellable);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1399 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1400
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1401
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1402 static void jabber_si_xfer_request_denied(PurpleXfer *xfer)
13146
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1403 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1404 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
27817
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1405 JabberStream *js = jsx->js;
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1406
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1407 /*
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1408 * 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
1409 * might be warranted.
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1410 */
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1411 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
1412 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1413 PurpleXmlNode *error, *child;
27817
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1414 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
1415 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
1416 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
1417
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1418 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
1419 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
1420 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
1421 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
1422 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
1423 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
1424 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
1425
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1426 jabber_iq_send(iq);
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1427 }
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1428
28828
7c1855f037e7 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
1429 purple_debug_info("jabber", "in jabber_si_xfer_request_denied\n");
13146
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1430 }
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1431
e151cc4c0f7e [gaim-migrate @ 15508]
<eschman@users.sourceforge.net>
parents: 12936
diff changeset
1432
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1433 static void jabber_si_xfer_cancel_recv(PurpleXfer *xfer)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1434 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1435 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1436 /* 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
1437 if (jsx->ibb_session) {
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1438 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
1439 }
28828
7c1855f037e7 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
1440 purple_debug_info("jabber", "in jabber_si_xfer_cancel_recv\n");
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
1441
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
1442 g_cancellable_cancel(jsx->cancellable);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1443 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1444
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1445
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1446 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
1447 JabberCapabilities capabilities, gpointer data)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1448 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1449 PurpleXfer *xfer = PURPLE_XFER(data);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1450 JabberSIXfer *jsx = JABBER_SI_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
1451
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1452 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
1453 purple_debug_info("jabber",
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1454 "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
1455 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
1456 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1457
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1458 if (capabilities & JABBER_CAP_SI_FILE_XFER) {
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1459 jabber_si_xfer_send_request(xfer);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1460 } else {
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1461 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
1462 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
1463 _("File Send Failed"), msg,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1464 purple_request_cpar_from_connection(js->gc));
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1465 g_free(msg);
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1466 purple_xfer_cancel_local(xfer);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1467 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1468 }
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1469
41967
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1470 static void
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1471 resource_select_cancel_cb(PurpleXfer *xfer,
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1472 G_GNUC_UNUSED PurpleRequestFields *fields)
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1473 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1474 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
1475 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1476
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1477 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
1478 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1479 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1480 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
1481 char *who;
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1482 JabberBuddy *jb;
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1483 JabberBuddyResource *jbr = NULL;
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1484
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1485 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
1486 if (jb) {
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1487 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
1488 }
17424
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 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
1491 g_strfreev(who_v);
34913
21017b84a070 Refactored jabber to use the GObject xfer API.
Ankit Vani <a@nevitus.org>
parents: 34912
diff changeset
1492 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
1493
29118
8d6805679729 Use the jabber_resource_know_capabilities function to determine if a buddy
Marcus Lundblad <malu@pidgin.im>
parents: 29041
diff changeset
1494 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
1495 char *msg;
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1496
28979
191942cc7747 jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <darkrain42@pidgin.im>
parents: 28828
diff changeset
1497 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
1498 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
1499 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
1500 jabber_si_xfer_send_request(xfer);
34921
ec60bc0b0be4 Freed a string
Ankit Vani <a@nevitus.org>
parents: 34920
diff changeset
1501 g_free(who);
27816
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1502 return;
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1503 }
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1504
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1505 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
1506 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
1507 _("File Send Failed"), msg,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1508 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
1509 g_free(msg);
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1510 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
1511 } else {
2771743d6fdc Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <darkrain42@pidgin.im>
parents: 27525
diff changeset
1512 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
1513 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
1514 }
34921
ec60bc0b0be4 Freed a string
Ankit Vani <a@nevitus.org>
parents: 34920
diff changeset
1515
ec60bc0b0be4 Freed a string
Ankit Vani <a@nevitus.org>
parents: 34920
diff changeset
1516 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
1517 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1518
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1519 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
1520 {
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1521 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
1522 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
1523
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1524 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
1525 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1526
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1527 static void jabber_si_xfer_xfer_init(PurpleXfer *xfer)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1528 {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1529 JabberSIXfer *jsx = JABBER_SI_XFER(xfer);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1530 JabberIq *iq;
34926
c5b444d1447d Changed prefix of PurpleXferType enums to PURPLE_XFER_TYPE_*
Ankit Vani <a@nevitus.org>
parents: 34921
diff changeset
1531 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
1532 JabberBuddy *jb;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1533 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
1534 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
1535 GList *resources = NULL;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31123
diff changeset
1536
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1537 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
1538 /* 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
1539 * 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
1540
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1541 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
1542 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
1543 return;
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1544 }
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1545
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1546 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
1547
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
1548 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
1549 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
1550
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
1551 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
1552 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
1553
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
1554 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
1555 (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
1556 && (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
1557 || 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
1558 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
1559 }
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
1560 }
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
1561 }
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31123
diff changeset
1562
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
1563 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
1564 /* 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
1565 * 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
1566 * 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
1567 char *msg;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1568
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1569 if(!jb) {
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1570 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
1571 } else if(jb->subscription & JABBER_SUB_TO) {
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1572 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
1573 } else {
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1574 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
1575 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1576
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1577 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
1578 _("File Send Failed"), msg,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1579 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
1580 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
1581 } 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
1582 /* 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
1583 * 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
1584 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
1585 do_transfer_send(xfer, jbr->name);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1586 } else {
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1587 /* 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
1588 GList *l;
32270
028a4b3c0402 Steps toward hiding PurpleXfer.
Daniel Atallah <datallah@pidgin.im>
parents: 32245
diff changeset
1589 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
1590 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
1591 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
1592 PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL);
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 31123
diff changeset
1593
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
1594 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
1595 jbr = l->data;
40817
7f0cde300360 Add purple_request_field_choice_add_full
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40668
diff changeset
1596 purple_request_field_choice_add_full(field, jbr->name, g_strdup(jbr->name), g_free);
17424
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1597 }
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1598
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1599 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
1600
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1601 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
1602
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
1603 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
1604 _("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
1605 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
1606
3fd87c1c0320 if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
1607 g_free(msg);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1608 }
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
1609
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
1610 g_list_free(resources);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1611 } else {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1612 PurpleXmlNode *si, *feature, *x, *field, *value;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1613
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1614 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
1615 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
1616 if(jsx->iq_id)
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1617 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
1618 else
1192c3f37355 Properly send rejection to initiator if we reject a transfer.
Paul Aurich <darkrain42@pidgin.im>
parents: 27816
diff changeset
1619 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
1620
10940
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
1621 jsx->accepted = TRUE;
3a7fc8684d13 [gaim-migrate @ 12730]
Nathan Walp <nwalp@pidgin.im>
parents: 10939
diff changeset
1622
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1623 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
1624 purple_xmlnode_set_namespace(si, "http://jabber.org/protocol/si");
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1625
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1626 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
1627 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
1628
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1629 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
1630 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
1631 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
1632 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
1633 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
1634
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1635 /* 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
1636 same session) with this JID, and only present IBB as an option to
41084
72d6941bfa2e Fix typos in protocol plugins
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40817
diff changeset
1637 avoid unnecessary timeout */
26014
884c77a43f5a Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <malu@pidgin.im>
parents: 26009
diff changeset
1638 /* 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
1639 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
1640 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
1641 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
1642 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
1643 } 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
1644 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
1645 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
1646 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1647
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1648 jabber_iq_send(iq);
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1649 }
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1650 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1651
41967
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1652 PurpleXfer *
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1653 jabber_si_new_xfer(G_GNUC_UNUSED PurpleProtocolXfer *prplxfer,
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1654 PurpleConnection *gc, const char *who)
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1655 {
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1656 JabberStream *js;
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1657 JabberSIXfer *jsx;
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1658
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
1659 js = purple_connection_get_protocol_data(gc);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 8838
diff changeset
1660
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1661 jsx = g_object_new(
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1662 JABBER_TYPE_SI_XFER,
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1663 "account", purple_connection_get_account(gc),
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1664 "type", PURPLE_XFER_TYPE_SEND,
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1665 "remote-user", who,
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1666 NULL
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1667 );
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26037
diff changeset
1668
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1669 jsx->js = js;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1670 js->file_transfers = g_list_append(js->file_transfers, jsx);
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1671
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1672 return PURPLE_XFER(jsx);
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1673 }
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1674
38841
518362268798 make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents: 38838
diff changeset
1675 void jabber_si_xfer_send(PurpleProtocolXfer *prplxfer, PurpleConnection *gc, const char *who, const char *file)
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1676 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1677 PurpleXfer *xfer;
12143
09f216663302 [gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents: 11656
diff changeset
1678
38841
518362268798 make sure all the PurpleProtocolXfer parameters are named prplxfer
Gary Kramlich <grim@reaperworld.com>
parents: 38838
diff changeset
1679 xfer = jabber_si_new_xfer(prplxfer, gc, who);
8312
3cb6d9d94694 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8262
diff changeset
1680
9466
b6425eab60ca [gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents: 9030
diff changeset
1681 if (file)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1682 purple_xfer_request_accepted(xfer, file);
9466
b6425eab60ca [gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents: 9030
diff changeset
1683 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15847
diff changeset
1684 purple_xfer_request(xfer);
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
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1687 #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
1688 static void
30118
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1689 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
1690 {
30118
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1691 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
1692
30118
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1693 if (data) {
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1694 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
1695 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
1696 /* 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
1697 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
1698 }
30118
cee45670f6ef Updated to use new BoB request functionallity
Marcus Lundblad <malu@pidgin.im>
parents: 30116
diff changeset
1699
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1700 purple_xfer_request(xfer);
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1701 }
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1702 #endif
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1703
41791
3bf884522663 xmpp: Remove unused prototypes and code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41741
diff changeset
1704 static void
41967
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1705 jabber_si_parse(JabberStream *js, const char *from,
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1706 G_GNUC_UNUSED JabberIqType type, const char *id,
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1707 PurpleXmlNode *si)
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1708 {
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1709 JabberSIXfer *jsx;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1710 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
1711 #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
1712 PurpleXmlNode *thumbnail;
31739
88b0a203e2e0 Silence a swath of warnings regarding set-but-unused.
Paul Aurich <darkrain42@pidgin.im>
parents: 31735
diff changeset
1713 #endif
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
1714 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
1715 goffset filesize = 0;
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1716
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1717 if(!(profile = purple_xmlnode_get_attrib(si, "profile")) ||
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
1718 !purple_strequal(profile, NS_SI_FILE_TRANSFER))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1719 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1720
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1721 if(!(stream_id = purple_xmlnode_get_attrib(si, "id")))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1722 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1723
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1724 if(!(file = purple_xmlnode_get_child(si, "file")))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1725 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1726
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1727 if(!(filename = purple_xmlnode_get_attrib(file, "name")))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1728 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1729
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1730 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
1731 filesize = g_ascii_strtoull(filesize_c, NULL, 10);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1732
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1733 if(!(feature = purple_xmlnode_get_child(si, "feature")))
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1734 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1735
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1736 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
1737 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1738
25817
09d6a40a341d Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents: 25566
diff changeset
1739 if(!from)
10939
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1740 return;
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1741
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1742 /* 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
1743 * 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
1744 * 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
1745 if(jabber_si_xfer_find(js, stream_id, from) != NULL)
10939
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1746 return;
91cca1a726ce [gaim-migrate @ 12729]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1747
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1748 jsx = g_object_new(
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1749 JABBER_TYPE_SI_XFER,
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1750 "account", purple_connection_get_account(js->gc),
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1751 "type", PURPLE_XFER_TYPE_RECEIVE,
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1752 "remote-user", from,
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1753 NULL
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1754 );
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1755
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1756 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
1757 const char *var = purple_xmlnode_get_attrib(field, "var");
38260
dcada91c0912 Remove redundant NULL checks
qarkai <qarkai@gmail.com>
parents: 38259
diff changeset
1758 if(purple_strequal(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
1759 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
1760 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
1761 if((value = purple_xmlnode_get_child(option, "value"))) {
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1762 char *val;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1763 if((val = purple_xmlnode_get_data(value))) {
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 36256
diff changeset
1764 if(purple_strequal(val, NS_BYTESTREAMS)) {
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1765 jsx->stream_method |= STREAM_METHOD_BYTESTREAMS;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 36256
diff changeset
1766 } else if(purple_strequal(val, NS_IBB)) {
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1767 jsx->stream_method |= STREAM_METHOD_IBB;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1768 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1769 g_free(val);
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1770 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1771 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1772 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1773 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1774 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1775
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1776 if(jsx->stream_method == STREAM_METHOD_UNKNOWN) {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1777 g_object_unref(G_OBJECT(jsx));
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1778 return;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1779 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1780
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1781 jsx->js = js;
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1782 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
1783 jsx->iq_id = g_strdup(id);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1784
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1785 purple_xfer_set_filename(PURPLE_XFER(jsx), filename);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1786 if(filesize > 0) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1787 purple_xfer_set_size(PURPLE_XFER(jsx), filesize);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1788 }
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1789
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1790 js->file_transfers = g_list_append(js->file_transfers, jsx);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1791
30132
064f5dc73a6f Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <malu@pidgin.im>
parents: 30126
diff changeset
1792 #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
1793 /* 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
1794 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
1795 NS_THUMBS))) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34926
diff changeset
1796 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
1797 if (cid) {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1798 jabber_data_request(js, cid, purple_xfer_get_remote_user(PURPLE_XFER(jsx)),
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1799 NULL, TRUE, jabber_si_thumbnail_cb, jsx);
31740
6a4a29d1541f jabber: This seems slightly more straightforward to me.
Paul Aurich <darkrain42@pidgin.im>
parents: 31739
diff changeset
1800 return;
27425
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1801 }
c16aa3c94fb4 Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <malu@pidgin.im>
parents: 27424
diff changeset
1802 }
31740
6a4a29d1541f jabber: This seems slightly more straightforward to me.
Paul Aurich <darkrain42@pidgin.im>
parents: 31739
diff changeset
1803 #endif
6a4a29d1541f jabber: This seems slightly more straightforward to me.
Paul Aurich <darkrain42@pidgin.im>
parents: 31739
diff changeset
1804
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1805 purple_xfer_request(PURPLE_XFER(jsx));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1806 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1807
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1808 /******************************************************************************
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1809 * GObject Implementation
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1810 *****************************************************************************/
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1811 static void
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
1812 jabber_si_xfer_init(JabberSIXfer *jsx)
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
1813 {
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
1814 jsx->ibb_session = NULL;
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
1815 jsx->cancellable = g_cancellable_new();
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1816 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1817
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1818 static void
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1819 jabber_si_xfer_finalize(GObject *obj) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1820 JabberSIXfer *jsx = JABBER_SI_XFER(obj);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1821 JabberStream *js = jsx->js;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1822
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1823 js->file_transfers = g_list_remove(js->file_transfers, jsx);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1824
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
1825 g_cancellable_cancel(jsx->cancellable);
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
1826 g_clear_object(&jsx->cancellable);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1827
40587
f2d29265494b Embed SOCKS5 proxying in Jabber SI xfer code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40474
diff changeset
1828 g_clear_object(&jsx->client);
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1829 g_clear_object(&jsx->local_streamhost_conn);
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1830 if (jsx->service) {
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1831 g_socket_service_stop(jsx->service);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1832 }
40404
d85e4d3f17be xmpp: Convert si xfer to gio socket server.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40403
diff changeset
1833 g_clear_object(&jsx->service);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1834
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1835 if (jsx->iq_id != NULL) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1836 jabber_iq_remove_callback_by_id(js, jsx->iq_id);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1837 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1838
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1839 if (jsx->connect_timeout > 0) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1840 g_source_remove(jsx->connect_timeout);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1841 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1842
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1843 if (jsx->ibb_timeout_handle > 0) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1844 g_source_remove(jsx->ibb_timeout_handle);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1845 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1846
40137
016690872c6c Add new and free functions for structs to reduce duplication
qarkai <qarkai@gmail.com>
parents: 39670
diff changeset
1847 g_list_free_full(jsx->streamhosts, (GDestroyNotify)jabber_bytestreams_streamhost_free);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1848
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1849 if (jsx->ibb_session) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1850 purple_debug_info("jabber",
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1851 "jabber_si_xfer_free: destroying IBB session\n");
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1852 jabber_ibb_session_destroy(jsx->ibb_session);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1853 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1854
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1855 if (jsx->ibb_buffer) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1856 g_object_unref(G_OBJECT(jsx->ibb_buffer));
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1857 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1858
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1859 purple_debug_info("jabber", "jabber_si_xfer_free(): freeing jsx %p\n", jsx);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1860
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1861 g_free(jsx->stream_id);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1862 g_free(jsx->iq_id);
40603
46f9691e2ac7 Rewrite XMPP SOCKS5 communication using Gio.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40588
diff changeset
1863 g_free(jsx->socks_buf);
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1864
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1865 G_OBJECT_CLASS(jabber_si_xfer_parent_class)->finalize(obj);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1866 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1867
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1868 static void
41967
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41826
diff changeset
1869 jabber_si_xfer_class_finalize(G_GNUC_UNUSED JabberSIXferClass *klass) {
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1870 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1871
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1872 static void
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1873 jabber_si_xfer_class_init(JabberSIXferClass *klass) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1874 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1875 PurpleXferClass *xfer_class = PURPLE_XFER_CLASS(klass);
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1876
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1877 obj_class->finalize = jabber_si_xfer_finalize;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1878
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1879 xfer_class->init = jabber_si_xfer_xfer_init;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1880 xfer_class->request_denied = jabber_si_xfer_request_denied;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1881 xfer_class->cancel_send = jabber_si_xfer_cancel_send;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1882 xfer_class->cancel_recv = jabber_si_xfer_cancel_recv;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1883 xfer_class->read = jabber_si_xfer_ibb_read;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1884 xfer_class->write = jabber_si_xfer_ibb_write;
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1885 }
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1886
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1887 /******************************************************************************
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1888 * Public API
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1889 *****************************************************************************/
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1890 void
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1891 jabber_si_xfer_register(GTypeModule *module) {
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1892 jabber_si_xfer_register_type(module);
8262
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1893 }
fa907a654af9 [gaim-migrate @ 8985]
Nathan Walp <nwalp@pidgin.im>
parents: 8231
diff changeset
1894
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1895 void
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1896 jabber_si_init(void) {
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27140
diff changeset
1897 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
1898
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1899 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
1900 }
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1901
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1902 void
39669
bab07ecb9330 Make PurpleXfer a derivable type and create subclasses in all the protocols that support file transfers
Gary Kramlich <grim@reaperworld.com>
parents: 39556
diff changeset
1903 jabber_si_uninit(void) {
24372
830701cec96f Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <malu@pidgin.im>
parents: 24038
diff changeset
1904 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
1905 }

mercurial