Mercurial > pidgin
annotate libpurple/protocols/jabber/si.c @ 31525:db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
If we weren't string-frozen, I'd use a new separate account option for this.
Refs #13928
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 03 May 2011 02:26:35 +0000 |
parents | b671728e6ee9 |
children | 79ae7200a11a |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15822 | 2 * purple - Jabber Protocol Plugin |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
28048
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27879
diff
changeset
|
4 * Purple is the legal property of its developers, whose names are too numerous |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27879
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27879
diff
changeset
|
6 * source distribution. |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19676
diff
changeset
|
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
17532
diff
changeset
|
25 #include "internal.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
17532
diff
changeset
|
27 #include "blist.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "ft.h" |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
30 #include "request.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "network.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include "notify.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 #include "buddy.h" |
29787
7d8b074feda2
Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <ml@update.uu.se>
parents:
29783
diff
changeset
|
35 #include "data.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 #include "disco.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 #include "jabber.h" |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25752
diff
changeset
|
38 #include "ibb.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 #include "iq.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 #include "si.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
42 #define STREAMHOST_CONNECT_TIMEOUT 15 |
30169
0c8d1b152b16
woops, this should remain de-activated for a while yet... :)
Marcus Lundblad <ml@update.uu.se>
parents:
30168
diff
changeset
|
43 #define ENABLE_FT_THUMBNAILS 0 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 typedef struct _JabberSIXfer { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 JabberStream *js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 |
15822 | 48 PurpleProxyConnectData *connect_data; |
49 PurpleNetworkListenData *listen_data; | |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
50 guint connect_timeout; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 gboolean accepted; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 char *stream_id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 char *iq_id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 enum { |
27558
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
58 STREAM_METHOD_UNKNOWN = 0, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 STREAM_METHOD_BYTESTREAMS = 2 << 1, |
27558
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
60 STREAM_METHOD_IBB = 2 << 2, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 STREAM_METHOD_UNSUPPORTED = 2 << 31 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 } stream_method; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 GList *streamhosts; |
15822 | 65 PurpleProxyInfo *gpi; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 char *rxqueue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 size_t rxlen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 gsize rxmaxlen; |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
70 int local_streamhost_fd; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
71 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
72 JabberIBBSession *ibb_session; |
25752
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
73 guint ibb_timeout_handle; |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
74 PurpleCircBuffer *ibb_buffer; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 } JabberSIXfer; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
77 /* some forward declarations */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
78 static void jabber_si_xfer_ibb_send_init(JabberStream *js, PurpleXfer *xfer); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
79 |
15822 | 80 static PurpleXfer* |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 jabber_si_xfer_find(JabberStream *js, const char *sid, const char *from) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 GList *xfers; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 if(!sid || !from) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 for(xfers = js->file_transfers; xfers; xfers = xfers->next) { |
15822 | 89 PurpleXfer *xfer = xfers->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 JabberSIXfer *jsx = xfer->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 if(jsx->stream_id && xfer->who && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 !strcmp(jsx->stream_id, sid) && !strcmp(xfer->who, from)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 return xfer; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 |
22910
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
99 static void |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
100 jabber_si_free_streamhost(gpointer data, gpointer user_data) |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
101 { |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
102 JabberBytestreamsStreamhost *sh = data; |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
103 |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
104 if(!data) |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
105 return; |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
106 |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
107 g_free(sh->jid); |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
108 g_free(sh->host); |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
109 g_free(sh->zeroconf); |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
110 g_free(sh); |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
111 } |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
112 |
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
113 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 |
15822 | 115 static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 jabber_si_bytestreams_connect_cb(gpointer data, gint source, const gchar *error_message) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 { |
15822 | 120 PurpleXfer *xfer = data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 JabberSIXfer *jsx = xfer->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 xmlnode *query, *su; |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
124 JabberBytestreamsStreamhost *streamhost = jsx->streamhosts->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 |
15822 | 126 purple_proxy_info_destroy(jsx->gpi); |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
127 jsx->gpi = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 jsx->connect_data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
130 if (jsx->connect_timeout > 0) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
131 purple_timeout_remove(jsx->connect_timeout); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
132 jsx->connect_timeout = 0; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
133 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 if(source < 0) { |
17532
efb5d0fe4895
Better error message for when a Jabber connection fails
Mark Doliner <mark@kingant.net>
parents:
17365
diff
changeset
|
135 purple_debug_warning("jabber", |
efb5d0fe4895
Better error message for when a Jabber connection fails
Mark Doliner <mark@kingant.net>
parents:
17365
diff
changeset
|
136 "si connection failed, jid was %s, host was %s, error was %s\n", |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
137 streamhost->jid, streamhost->host, |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
138 error_message ? error_message : "(null)"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost); |
22910
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
140 jabber_si_free_streamhost(streamhost, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 jabber_si_bytestreams_attempt_connect(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
145 /* unknown file transfer type is assumed to be RECEIVE */ |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
146 if(xfer->type == PURPLE_XFER_SEND) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
147 { |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
148 xmlnode *activate; |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
149 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, NS_BYTESTREAMS); |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
150 xmlnode_set_attrib(iq->node, "to", streamhost->jid); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
151 query = xmlnode_get_child(iq->node, "query"); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
152 xmlnode_set_attrib(query, "sid", jsx->stream_id); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
153 activate = xmlnode_new_child(query, "activate"); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
154 xmlnode_insert_data(activate, xfer->who, -1); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
155 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
156 /* TODO: We need to wait for an activation result before starting */ |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
157 } |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
158 else |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
159 { |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
160 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_RESULT, NS_BYTESTREAMS); |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
161 xmlnode_set_attrib(iq->node, "to", xfer->who); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
162 jabber_iq_set_id(iq, jsx->iq_id); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
163 query = xmlnode_get_child(iq->node, "query"); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
164 su = xmlnode_new_child(query, "streamhost-used"); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
165 xmlnode_set_attrib(su, "jid", streamhost->jid); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
166 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 |
15822 | 170 purple_xfer_start(xfer, source, NULL, -1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
173 static gboolean |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
174 connect_timeout_cb(gpointer data) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
175 { |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
176 PurpleXfer *xfer = data; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
177 JabberSIXfer *jsx = xfer->data; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
178 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
179 purple_debug_info("jabber", "Streamhost connection timeout of %d seconds exceeded.\n", STREAMHOST_CONNECT_TIMEOUT); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
180 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
181 jsx->connect_timeout = 0; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
182 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
183 if (jsx->connect_data != NULL) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
184 purple_proxy_connect_cancel(jsx->connect_data); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
185 jsx->connect_data = NULL; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
186 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
187 /* Trigger the connect error manually */ |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
188 jabber_si_bytestreams_connect_cb(xfer, -1, "Timeout Exceeded."); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
189 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
190 return FALSE; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
191 } |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
192 |
25752
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
193 static void |
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
194 jabber_si_bytestreams_ibb_timeout_remove(JabberSIXfer *jsx) |
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
195 { |
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
196 if (jsx->ibb_timeout_handle) { |
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
197 purple_timeout_remove(jsx->ibb_timeout_handle); |
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
198 jsx->ibb_timeout_handle = 0; |
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
199 } |
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
200 } |
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
201 |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
202 static gboolean |
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
203 jabber_si_bytestreams_ibb_timeout_cb(gpointer data) |
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
204 { |
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
205 PurpleXfer *xfer = (PurpleXfer *) data; |
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
206 JabberSIXfer *jsx = xfer->data; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
207 |
25752
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
208 if (jsx && !jsx->ibb_session) { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
209 purple_debug_info("jabber", |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
210 "jabber_si_bytestreams_ibb_timeout called and IBB session not set " |
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
211 " up yet, cancel transfer"); |
25757
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
212 jabber_si_bytestreams_ibb_timeout_remove(jsx); |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
213 purple_xfer_cancel_local(xfer); |
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
214 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
215 |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
216 return FALSE; |
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
217 } |
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
218 |
15822 | 219 static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 JabberSIXfer *jsx = xfer->data; |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
222 JabberBytestreamsStreamhost *streamhost; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
223 JabberID *dstjid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 if(!jsx->streamhosts) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 JabberIq *iq = jabber_iq_new(jsx->js, JABBER_IQ_ERROR); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 xmlnode *error, *inf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 if(jsx->iq_id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 jabber_iq_set_id(iq, jsx->iq_id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 xmlnode_set_attrib(iq->node, "to", xfer->who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 error = xmlnode_new_child(iq->node, "error"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 xmlnode_set_attrib(error, "code", "404"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 xmlnode_set_attrib(error, "type", "cancel"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 inf = xmlnode_new_child(error, "item-not-found"); |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
237 xmlnode_set_namespace(inf, NS_XMPP_STANZAS); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
241 /* if IBB is available, revert to that before giving up... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
242 if (jsx->stream_method & STREAM_METHOD_IBB) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
243 /* if we are the initializer, init IBB */ |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
244 purple_debug_info("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
245 "jabber_si_bytestreams_attempt_connect: " |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
246 "no streamhosts found, trying IBB\n"); |
25757
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
247 /* if we are the sender, open an IBB session, but not if we already |
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
248 did it, since we could have received the error <iq/> from the |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
249 receiver already... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
250 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
251 && !jsx->ibb_session) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
252 jabber_si_xfer_ibb_send_init(jsx->js, xfer); |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
253 } else { |
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
254 /* setup a timeout to cancel waiting for IBB open */ |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
255 jsx->ibb_timeout_handle = purple_timeout_add_seconds(30, |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
256 jabber_si_bytestreams_ibb_timeout_cb, xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
257 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
258 /* if we are the receiver, just wait for IBB open, callback is |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
259 already set up... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
260 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
261 purple_xfer_cancel_local(xfer); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
262 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
263 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 streamhost = jsx->streamhosts->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
269 jsx->connect_data = NULL; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
270 if (jsx->gpi != NULL) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
271 purple_proxy_info_destroy(jsx->gpi); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
272 jsx->gpi = NULL; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
273 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 dstjid = jabber_id_new(xfer->who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
276 /* TODO: Deal with zeroconf */ |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
277 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
278 if(dstjid != NULL && streamhost->host && streamhost->port > 0) { |
24693
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24552
diff
changeset
|
279 char *dstaddr, *hash; |
31481
b671728e6ee9
Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31447
diff
changeset
|
280 PurpleAccount *account; |
15822 | 281 jsx->gpi = purple_proxy_info_new(); |
282 purple_proxy_info_set_type(jsx->gpi, PURPLE_PROXY_SOCKS5); | |
283 purple_proxy_info_set_host(jsx->gpi, streamhost->host); | |
284 purple_proxy_info_set_port(jsx->gpi, streamhost->port); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
286 /* unknown file transfer type is assumed to be RECEIVE */ |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
287 if(xfer->type == PURPLE_XFER_SEND) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
288 dstaddr = g_strdup_printf("%s%s@%s/%s%s@%s/%s", jsx->stream_id, jsx->js->user->node, jsx->js->user->domain, |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
289 jsx->js->user->resource, dstjid->node, dstjid->domain, dstjid->resource); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
290 else |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
291 dstaddr = g_strdup_printf("%s%s@%s/%s%s@%s/%s", jsx->stream_id, dstjid->node, dstjid->domain, dstjid->resource, |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
292 jsx->js->user->node, jsx->js->user->domain, jsx->js->user->resource); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 |
24693
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24552
diff
changeset
|
294 /* Per XEP-0065, the 'host' must be SHA1(SID + from JID + to JID) */ |
29630
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
29612
diff
changeset
|
295 hash = jabber_calculate_data_hash(dstaddr, strlen(dstaddr), "sha1"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 |
31481
b671728e6ee9
Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31447
diff
changeset
|
297 account = purple_connection_get_account(jsx->js->gc); |
b671728e6ee9
Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31447
diff
changeset
|
298 jsx->connect_data = purple_proxy_connect_socks5_account(NULL, account, |
b671728e6ee9
Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31447
diff
changeset
|
299 jsx->gpi, hash, 0, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 jabber_si_bytestreams_connect_cb, xfer); |
24693
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24552
diff
changeset
|
301 g_free(hash); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 g_free(dstaddr); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
304 /* When selecting a streamhost, timeout after STREAMHOST_CONNECT_TIMEOUT seconds, otherwise it takes forever */ |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
305 if (xfer->type != PURPLE_XFER_SEND && jsx->connect_data != NULL) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
306 jsx->connect_timeout = purple_timeout_add_seconds( |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
307 STREAMHOST_CONNECT_TIMEOUT, connect_timeout_cb, xfer); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
308 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 jabber_id_free(dstjid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 if (jsx->connect_data == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost); |
22910
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
315 jabber_si_free_streamhost(streamhost, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 jabber_si_bytestreams_attempt_connect(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
320 void jabber_bytestreams_parse(JabberStream *js, const char *from, |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
321 JabberIqType type, const char *id, xmlnode *query) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 { |
15822 | 323 PurpleXfer *xfer; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 JabberSIXfer *jsx; |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
325 xmlnode *streamhost; |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
326 const char *sid; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
328 if(type != JABBER_IQ_SET) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
331 if(!from) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 if(!(sid = xmlnode_get_attrib(query, "sid"))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 if(!(xfer = jabber_si_xfer_find(js, sid, from))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
340 jsx = xfer->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 if(!jsx->accepted) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 if(jsx->iq_id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 g_free(jsx->iq_id); |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
347 jsx->iq_id = g_strdup(id); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 for(streamhost = xmlnode_get_child(query, "streamhost"); streamhost; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 streamhost = xmlnode_get_next_twin(streamhost)) { |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
351 const char *jid, *host = NULL, *port, *zeroconf; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
352 int portnum = 0; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 if((jid = xmlnode_get_attrib(streamhost, "jid")) && |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
355 ((zeroconf = xmlnode_get_attrib(streamhost, "zeroconf")) || |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
356 ((host = xmlnode_get_attrib(streamhost, "host")) && |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 (port = xmlnode_get_attrib(streamhost, "port")) && |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
358 (portnum = atoi(port))))) { |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
359 JabberBytestreamsStreamhost *sh = g_new0(JabberBytestreamsStreamhost, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
360 sh->jid = g_strdup(jid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 sh->host = g_strdup(host); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 sh->port = portnum; |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
363 sh->zeroconf = g_strdup(zeroconf); |
22910
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
364 /* If there were a lot of these, it'd be worthwhile to prepend and reverse. */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 jsx->streamhosts = g_list_append(jsx->streamhosts, sh); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
366 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 jabber_si_bytestreams_attempt_connect(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 jabber_si_xfer_bytestreams_send_read_again_resp_cb(gpointer data, gint source, |
15822 | 375 PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 { |
15822 | 377 PurpleXfer *xfer = data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 JabberSIXfer *jsx = xfer->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 int len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 len = write(source, jsx->rxqueue + jsx->rxlen, jsx->rxmaxlen - jsx->rxlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 if (len < 0 && errno == EAGAIN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 else if (len < 0) { |
15822 | 385 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
387 g_free(jsx->rxqueue); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 jsx->rxqueue = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 close(source); |
15822 | 390 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 jsx->rxlen += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 if (jsx->rxlen < jsx->rxmaxlen) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 |
15822 | 398 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
399 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 g_free(jsx->rxqueue); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 jsx->rxqueue = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
403 /* Before actually starting sending the file, we need to wait until the |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
404 * recipient sends the IQ result with <streamhost-used/> |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
405 */ |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
406 purple_debug_info("jabber", "SOCKS5 connection negotiation completed. " |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
407 "Waiting for IQ result to start file transfer.\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 jabber_si_xfer_bytestreams_send_read_again_cb(gpointer data, gint source, |
15822 | 412 PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 { |
15822 | 414 PurpleXfer *xfer = data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 JabberSIXfer *jsx = xfer->data; |
25556
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
416 char buffer[42]; /* 40 for DST.ADDR + 2 bytes for port number*/ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 int len; |
24693
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24552
diff
changeset
|
418 char *dstaddr, *hash; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 const char *host; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 |
15822 | 421 purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_read_again_cb\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 if(jsx->rxlen < 5) { |
15822 | 424 purple_debug_info("jabber", "reading the first 5 bytes\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 len = read(source, buffer, 5 - jsx->rxlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 if(len < 0 && errno == EAGAIN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 else if(len <= 0) { |
15822 | 429 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 close(source); |
15822 | 432 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 jsx->rxlen += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 } else if(jsx->rxqueue[0] != 0x05 || jsx->rxqueue[1] != 0x01 || |
25556
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
440 jsx->rxqueue[3] != 0x03 || jsx->rxqueue[4] != 40) { |
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
441 purple_debug_info("jabber", "Invalid socks5 conn req. header[0x%x,0x%x,0x%x,0x%x,0x%x]\n", |
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
442 jsx->rxqueue[0], jsx->rxqueue[1], jsx->rxqueue[2], |
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
443 jsx->rxqueue[3], jsx->rxqueue[4]); |
15822 | 444 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
445 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 close(source); |
15822 | 447 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 } else if(jsx->rxlen - 5 < jsx->rxqueue[4] + 2) { |
26915
90e7220cf773
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <paul@darkrain42.org>
parents:
26877
diff
changeset
|
450 /* Upper-bound of 257 (jsx->rxlen = 5, jsx->rxqueue[4] = 0xFF) */ |
90e7220cf773
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <paul@darkrain42.org>
parents:
26877
diff
changeset
|
451 unsigned short to_read = jsx->rxqueue[4] + 2 - (jsx->rxlen - 5); |
90e7220cf773
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <paul@darkrain42.org>
parents:
26877
diff
changeset
|
452 purple_debug_info("jabber", "reading %u bytes for DST.ADDR + port num (trying to read %hu now)\n", |
90e7220cf773
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <paul@darkrain42.org>
parents:
26877
diff
changeset
|
453 jsx->rxqueue[4] + 2, to_read); |
90e7220cf773
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <paul@darkrain42.org>
parents:
26877
diff
changeset
|
454 len = read(source, buffer, to_read); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 if(len < 0 && errno == EAGAIN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 else if(len <= 0) { |
15822 | 458 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
459 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
460 close(source); |
15822 | 461 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
462 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
463 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
464 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 jsx->rxlen += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 |
25556
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
469 /* Have we not read all of DST.ADDR and the following 2-byte port number? */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 if(jsx->rxlen - 5 < jsx->rxqueue[4] + 2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
471 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 |
15822 | 473 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
474 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 dstaddr = g_strdup_printf("%s%s@%s/%s%s", jsx->stream_id, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 jsx->js->user->node, jsx->js->user->domain, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 jsx->js->user->resource, xfer->who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 |
24693
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24552
diff
changeset
|
480 /* Per XEP-0065, the 'host' must be SHA1(SID + from JID + to JID) */ |
29630
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
29612
diff
changeset
|
481 hash = jabber_calculate_data_hash(dstaddr, strlen(dstaddr), "sha1"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 |
25556
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
483 if(strncmp(hash, jsx->rxqueue + 5, 40) || |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 jsx->rxqueue[45] != 0x00 || jsx->rxqueue[46] != 0x00) { |
25556
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
485 if (jsx->rxqueue[45] != 0x00 || jsx->rxqueue[46] != 0x00) |
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
486 purple_debug_error("jabber", "Got SOCKS5 BS conn with the wrong DST.PORT" |
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
487 " (must be 0 - got[0x%x,0x%x]).\n", |
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
488 jsx->rxqueue[45], jsx->rxqueue[46]); |
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
489 else |
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
490 purple_debug_error("jabber", "Got SOCKS5 BS conn with the wrong DST.ADDR" |
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
491 " (expected '%s' - got '%.40s').\n", |
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
492 hash, jsx->rxqueue + 5); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 close(source); |
15822 | 494 purple_xfer_cancel_remote(xfer); |
24693
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24552
diff
changeset
|
495 g_free(hash); |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
496 g_free(dstaddr); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 |
24693
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24552
diff
changeset
|
500 g_free(hash); |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
501 g_free(dstaddr); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
502 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 g_free(jsx->rxqueue); |
15822 | 504 host = purple_network_get_my_ip(jsx->js->fd); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
505 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
506 jsx->rxmaxlen = 5 + strlen(host) + 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
507 jsx->rxqueue = g_malloc(jsx->rxmaxlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
508 jsx->rxlen = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
509 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 jsx->rxqueue[0] = 0x05; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 jsx->rxqueue[1] = 0x00; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 jsx->rxqueue[2] = 0x00; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 jsx->rxqueue[3] = 0x03; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
514 jsx->rxqueue[4] = strlen(host); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
515 memcpy(jsx->rxqueue + 5, host, strlen(host)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
516 jsx->rxqueue[5+strlen(host)] = 0x00; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
517 jsx->rxqueue[6+strlen(host)] = 0x00; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 |
15822 | 519 xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 jabber_si_xfer_bytestreams_send_read_again_resp_cb, xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 jabber_si_xfer_bytestreams_send_read_again_resp_cb(xfer, source, |
15822 | 522 PURPLE_INPUT_WRITE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
523 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
524 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 jabber_si_xfer_bytestreams_send_read_response_cb(gpointer data, gint source, |
15822 | 527 PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 { |
15822 | 529 PurpleXfer *xfer = data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 JabberSIXfer *jsx = xfer->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 int len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 len = write(source, jsx->rxqueue + jsx->rxlen, jsx->rxmaxlen - jsx->rxlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 if (len < 0 && errno == EAGAIN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
536 else if (len < 0) { |
15822 | 537 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 g_free(jsx->rxqueue); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 jsx->rxqueue = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 close(source); |
15822 | 542 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 jsx->rxlen += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
546 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 if (jsx->rxlen < jsx->rxmaxlen) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 |
15822 | 550 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 |
25556
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
553 /* If we sent a "Success", wait for a response, otherwise give up and cancel */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
554 if (jsx->rxqueue[1] == 0x00) { |
15822 | 555 xfer->watcher = purple_input_add(source, PURPLE_INPUT_READ, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
556 jabber_si_xfer_bytestreams_send_read_again_cb, xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 g_free(jsx->rxqueue); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 jsx->rxqueue = NULL; |
25556
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
559 jsx->rxlen = 0; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
560 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
561 close(source); |
15822 | 562 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
564 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 jabber_si_xfer_bytestreams_send_read_cb(gpointer data, gint source, |
15822 | 568 PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 { |
15822 | 570 PurpleXfer *xfer = data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 JabberSIXfer *jsx = xfer->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 int i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 int len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 char buffer[256]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 |
15822 | 576 purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_read_cb\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 xfer->fd = source; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 |
25556
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
580 /** Try to read the SOCKS5 header */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 if(jsx->rxlen < 2) { |
15822 | 582 purple_debug_info("jabber", "reading those first two bytes\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 len = read(source, buffer, 2 - jsx->rxlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 if(len < 0 && errno == EAGAIN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 else if(len <= 0) { |
15822 | 587 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
589 close(source); |
15822 | 590 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
594 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 jsx->rxlen += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
596 return; |
26915
90e7220cf773
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <paul@darkrain42.org>
parents:
26877
diff
changeset
|
597 } else if(jsx->rxlen - 2 < jsx->rxqueue[1]) { |
90e7220cf773
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <paul@darkrain42.org>
parents:
26877
diff
changeset
|
598 /* Has a maximum value of 255 (jsx->rxlen = 2, jsx->rxqueue[1] = 0xFF) */ |
90e7220cf773
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <paul@darkrain42.org>
parents:
26877
diff
changeset
|
599 unsigned short to_read = jsx->rxqueue[1] - (jsx->rxlen - 2); |
90e7220cf773
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <paul@darkrain42.org>
parents:
26877
diff
changeset
|
600 purple_debug_info("jabber", "reading %u bytes for auth methods (trying to read %hu now)\n", |
90e7220cf773
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <paul@darkrain42.org>
parents:
26877
diff
changeset
|
601 jsx->rxqueue[1], to_read); |
90e7220cf773
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
Paul Aurich <paul@darkrain42.org>
parents:
26877
diff
changeset
|
602 len = read(source, buffer, to_read); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 if(len < 0 && errno == EAGAIN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 else if(len <= 0) { |
15822 | 606 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 close(source); |
15822 | 609 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
613 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 jsx->rxlen += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 |
25556
0d7f02640e2b
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 <daniel.atallah@gmail.com>
parents:
24693
diff
changeset
|
617 /* Have we not read all the auth. method bytes? */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 if(jsx->rxlen -2 < jsx->rxqueue[1]) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 |
15822 | 621 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 xfer->watcher = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 |
15822 | 624 purple_debug_info("jabber", "checking to make sure we're socks FIVE\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 if(jsx->rxqueue[0] != 0x05) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 close(source); |
15822 | 628 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 |
15822 | 632 purple_debug_info("jabber", "going to test %hhu different methods\n", jsx->rxqueue[1]); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
634 for(i=0; i<jsx->rxqueue[1]; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
635 |
15822 | 636 purple_debug_info("jabber", "testing %hhu\n", jsx->rxqueue[i+2]); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 if(jsx->rxqueue[i+2] == 0x00) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
638 g_free(jsx->rxqueue); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
639 jsx->rxlen = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 jsx->rxmaxlen = 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
641 jsx->rxqueue = g_malloc(jsx->rxmaxlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 jsx->rxqueue[0] = 0x05; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 jsx->rxqueue[1] = 0x00; |
15822 | 644 xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
645 jabber_si_xfer_bytestreams_send_read_response_cb, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
646 xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 jabber_si_xfer_bytestreams_send_read_response_cb(xfer, |
15822 | 648 source, PURPLE_INPUT_WRITE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 jsx->rxqueue = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
650 jsx->rxlen = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 g_free(jsx->rxqueue); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 jsx->rxlen = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 jsx->rxmaxlen = 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 jsx->rxqueue = g_malloc(jsx->rxmaxlen); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
659 jsx->rxqueue[0] = 0x05; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 jsx->rxqueue[1] = 0xFF; |
15822 | 661 xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 jabber_si_xfer_bytestreams_send_read_response_cb, xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 jabber_si_xfer_bytestreams_send_read_response_cb(xfer, |
15822 | 664 source, PURPLE_INPUT_WRITE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
665 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
666 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
667 static gint |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
668 jabber_si_compare_jid(gconstpointer a, gconstpointer b) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
669 { |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
670 const JabberBytestreamsStreamhost *sh = a; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
671 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
672 if(!a) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
673 return -1; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
674 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
675 return strcmp(sh->jid, (char *)b); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
676 } |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
677 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
678 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
679 jabber_si_xfer_bytestreams_send_connected_cb(gpointer data, gint source, |
15822 | 680 PurpleInputCondition cond) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 { |
15822 | 682 PurpleXfer *xfer = data; |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
683 JabberSIXfer *jsx = xfer->data; |
23707
e21c79681c96
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23600
diff
changeset
|
684 int acceptfd, flags; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
685 |
15822 | 686 purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_connected_cb\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 acceptfd = accept(source, NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
689 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
690 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 else if(acceptfd == -1) { |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
19681
diff
changeset
|
692 purple_debug_warning("jabber", "accept: %s\n", g_strerror(errno)); |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
693 /* Don't cancel the ft - allow it to fall to the next streamhost.*/ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
696 |
15822 | 697 purple_input_remove(xfer->watcher); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 close(source); |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
699 jsx->local_streamhost_fd = -1; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
700 |
23707
e21c79681c96
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23600
diff
changeset
|
701 flags = fcntl(acceptfd, F_GETFL); |
e21c79681c96
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23600
diff
changeset
|
702 fcntl(acceptfd, F_SETFL, flags | O_NONBLOCK); |
e21c79681c96
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23600
diff
changeset
|
703 #ifndef _WIN32 |
e21c79681c96
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23600
diff
changeset
|
704 fcntl(acceptfd, F_SETFD, FD_CLOEXEC); |
e21c79681c96
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23600
diff
changeset
|
705 #endif |
e21c79681c96
Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23600
diff
changeset
|
706 |
15822 | 707 xfer->watcher = purple_input_add(acceptfd, PURPLE_INPUT_READ, |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
708 jabber_si_xfer_bytestreams_send_read_cb, xfer); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
709 } |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
710 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
711 static void |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
712 jabber_si_connect_proxy_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
713 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
714 xmlnode *packet, gpointer data) |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
715 { |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
716 PurpleXfer *xfer = data; |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
717 JabberSIXfer *jsx; |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
718 xmlnode *query, *streamhost_used; |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
719 const char *jid; |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
720 GList *matched; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
721 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
722 /* TODO: This need to send errors if we don't see what we're looking for */ |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
723 |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
724 /* Make sure that the xfer is actually still valid and we're not just receiving an old iq response */ |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
725 if (!g_list_find(js->file_transfers, xfer)) { |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
726 purple_debug_error("jabber", "Got bytestreams response for no longer existing xfer (%p)\n", xfer); |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
727 return; |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
728 } |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
729 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
730 /* In the case of a direct file transfer, this is expected to return */ |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
731 if(!xfer->data) |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
732 return; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
733 |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
734 jsx = xfer->data; |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
735 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
736 if(type != JABBER_IQ_RESULT) { |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
737 purple_debug_info("jabber", |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
738 "jabber_si_xfer_connect_proxy_cb: type = error\n"); |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
739 /* if IBB is available, open IBB session */ |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
740 purple_debug_info("jabber", |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
741 "jabber_si_xfer_connect_proxy_cb: got error, method: %d\n", |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
742 jsx->stream_method); |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
743 if (jsx->stream_method & STREAM_METHOD_IBB) { |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
744 purple_debug_info("jabber", "IBB is possible, try it\n"); |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
745 /* if we are the sender and haven't already opened an IBB |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
746 session, do so now (we might already have failed to open |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
747 the bytestream proxy ourselves when receiving this <iq/> */ |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
748 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
749 && !jsx->ibb_session) { |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
750 jabber_si_xfer_ibb_send_init(js, xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
751 } else { |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
752 jsx->ibb_timeout_handle = purple_timeout_add_seconds(30, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
753 jabber_si_bytestreams_ibb_timeout_cb, xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
754 } |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
755 /* if we are receiver, just wait for IBB open stanza, callback |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
756 is already set up */ |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
757 } else { |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
758 purple_xfer_cancel_remote(xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
759 } |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
760 return; |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
761 } |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
762 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
763 if (!from) |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
764 return; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
765 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
766 if(!(query = xmlnode_get_child(packet, "query"))) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
767 return; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
768 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
769 if(!(streamhost_used = xmlnode_get_child(query, "streamhost-used"))) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
770 return; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
771 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
772 if(!(jid = xmlnode_get_attrib(streamhost_used, "jid"))) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
773 return; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
774 |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
775 purple_debug_info("jabber", "jabber_si_connect_proxy_cb() will be looking at jsx %p: jsx->streamhosts is %p and jid is %s\n", |
22673
919074aa02ca
I've seen intermittent crashes on xmpp file transfers in this code, but I
Evan Schoenberg <evan.s@dreskin.net>
parents:
22206
diff
changeset
|
776 jsx, jsx->streamhosts, jid); |
919074aa02ca
I've seen intermittent crashes on xmpp file transfers in this code, but I
Evan Schoenberg <evan.s@dreskin.net>
parents:
22206
diff
changeset
|
777 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
778 if(!(matched = g_list_find_custom(jsx->streamhosts, jid, jabber_si_compare_jid))) |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
779 { |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
780 gchar *my_jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node, |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
781 jsx->js->user->domain, jsx->js->user->resource); |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
782 if (!strcmp(jid, my_jid)) { |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
783 purple_debug_info("jabber", "Got local SOCKS5 streamhost-used.\n"); |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
784 purple_xfer_start(xfer, xfer->fd, NULL, -1); |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
785 } else { |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
786 /* if available, try to revert to IBB... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
787 if (jsx->stream_method & STREAM_METHOD_IBB) { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
788 purple_debug_info("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
789 "jabber_si_connect_proxy_cb: trying to revert to IBB\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
790 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
791 jabber_si_xfer_ibb_send_init(jsx->js, xfer); |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
792 } else { |
25752
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
793 jsx->ibb_timeout_handle = purple_timeout_add_seconds(30, |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
794 jabber_si_bytestreams_ibb_timeout_cb, xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
795 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
796 /* if we are the receiver, we are already set up...*/ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
797 } else { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
798 purple_debug_info("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
799 "streamhost-used does not match any proxy that was offered to target\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
800 purple_xfer_cancel_local(xfer); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
801 } |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
802 } |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
803 g_free(my_jid); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
804 return; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
805 } |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
806 |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
807 /* Clean up the local streamhost - it isn't going to be used.*/ |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
808 if (xfer->watcher > 0) { |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
809 purple_input_remove(xfer->watcher); |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
810 xfer->watcher = 0; |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
811 } |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
812 if (jsx->local_streamhost_fd >= 0) { |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
813 close(jsx->local_streamhost_fd); |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
814 jsx->local_streamhost_fd = -1; |
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
815 } |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
816 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
817 jsx->streamhosts = g_list_remove_link(jsx->streamhosts, matched); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
818 g_list_foreach(jsx->streamhosts, jabber_si_free_streamhost, NULL); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
819 g_list_free(jsx->streamhosts); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
820 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
821 jsx->streamhosts = matched; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
822 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
823 jabber_si_bytestreams_attempt_connect(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
824 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
825 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
826 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
827 jabber_si_xfer_bytestreams_listen_cb(int sock, gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
828 { |
15822 | 829 PurpleXfer *xfer = data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
830 JabberSIXfer *jsx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
831 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
832 xmlnode *query, *streamhost; |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
833 char port[6]; |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
834 GList *tmp; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
835 JabberBytestreamsStreamhost *sh, *sh2; |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
836 int streamhost_count = 0; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
837 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
838 jsx = xfer->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
839 jsx->listen_data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
840 |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
841 /* I'm not sure under which conditions this can happen |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
842 * (it seems like it shouldn't be possible */ |
15822 | 843 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) { |
844 purple_xfer_unref(xfer); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
846 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
847 |
15822 | 848 purple_xfer_unref(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
849 |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
850 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, NS_BYTESTREAMS); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
851 xmlnode_set_attrib(iq->node, "to", xfer->who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
852 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
853 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
854 xmlnode_set_attrib(query, "sid", jsx->stream_id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
855 |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
856 /* If we successfully started listening locally */ |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
857 if (sock >= 0) { |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
858 gchar *jid; |
29101
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
859 GList *local_ips = |
29102
f1aa01ff26dd
Remove IPv6 support from _get_local_system_ips, since I couldn't get it to
Marcus Lundblad <ml@update.uu.se>
parents:
29101
diff
changeset
|
860 purple_network_get_all_local_system_ips(); |
29101
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
861 const char *public_ip; |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
862 gboolean has_public_ip = FALSE; |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30923
diff
changeset
|
863 |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
864 jsx->local_streamhost_fd = sock; |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
865 |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
866 jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
867 jsx->js->user->domain, jsx->js->user->resource); |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
868 xfer->local_port = purple_network_get_port_from_fd(sock); |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
869 g_snprintf(port, sizeof(port), "%hu", xfer->local_port); |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
870 |
29101
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
871 public_ip = purple_network_get_my_ip(jsx->js->fd); |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
872 |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
873 /* Include the localhost's IPs (for in-network transfers) */ |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
874 while (local_ips) { |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
875 gchar *local_ip = local_ips->data; |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
876 streamhost_count++; |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
877 streamhost = xmlnode_new_child(query, "streamhost"); |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
878 xmlnode_set_attrib(streamhost, "jid", jid); |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
879 xmlnode_set_attrib(streamhost, "host", local_ip); |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
880 xmlnode_set_attrib(streamhost, "port", port); |
29101
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
881 if (purple_strequal(local_ip, public_ip)) |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
882 has_public_ip = TRUE; |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
883 g_free(local_ip); |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
884 local_ips = g_list_delete_link(local_ips, local_ips); |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
885 } |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
886 |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
887 /* Include the public IP (assuming that there is a port mapped somehow) */ |
29101
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
28048
diff
changeset
|
888 if (!has_public_ip && strcmp(public_ip, "0.0.0.0") != 0) { |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
889 streamhost_count++; |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
890 streamhost = xmlnode_new_child(query, "streamhost"); |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
891 xmlnode_set_attrib(streamhost, "jid", jid); |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
892 xmlnode_set_attrib(streamhost, "host", public_ip); |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
893 xmlnode_set_attrib(streamhost, "port", port); |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
894 } |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
895 |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
896 g_free(jid); |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
897 |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
898 /* The listener for the local proxy */ |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
899 xfer->watcher = purple_input_add(sock, PURPLE_INPUT_READ, |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
900 jabber_si_xfer_bytestreams_send_connected_cb, xfer); |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
901 } |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
902 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
903 for (tmp = jsx->js->bs_proxies; tmp; tmp = tmp->next) { |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
904 sh = tmp->data; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
905 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
906 /* TODO: deal with zeroconf proxies */ |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
907 |
21637
844225b0c905
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 <daniel.atallah@gmail.com>
parents:
21603
diff
changeset
|
908 if (!(sh->jid && sh->host && sh->port > 0)) |
844225b0c905
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 <daniel.atallah@gmail.com>
parents:
21603
diff
changeset
|
909 continue; |
844225b0c905
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 <daniel.atallah@gmail.com>
parents:
21603
diff
changeset
|
910 |
24478
88955b918197
Add missing newline in debug message.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23707
diff
changeset
|
911 purple_debug_info("jabber", "jabber_si_xfer_bytestreams_listen_cb() will be looking at jsx %p: jsx->streamhosts %p and sh->jid %p\n", |
22673
919074aa02ca
I've seen intermittent crashes on xmpp file transfers in this code, but I
Evan Schoenberg <evan.s@dreskin.net>
parents:
22206
diff
changeset
|
912 jsx, jsx->streamhosts, sh->jid); |
21637
844225b0c905
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 <daniel.atallah@gmail.com>
parents:
21603
diff
changeset
|
913 if(g_list_find_custom(jsx->streamhosts, sh->jid, jabber_si_compare_jid) != NULL) |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
914 continue; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
915 |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
916 streamhost_count++; |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
917 streamhost = xmlnode_new_child(query, "streamhost"); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
918 xmlnode_set_attrib(streamhost, "jid", sh->jid); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
919 xmlnode_set_attrib(streamhost, "host", sh->host); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
920 g_snprintf(port, sizeof(port), "%hu", sh->port); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
921 xmlnode_set_attrib(streamhost, "port", port); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
922 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
923 sh2 = g_new0(JabberBytestreamsStreamhost, 1); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
924 sh2->jid = g_strdup(sh->jid); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
925 sh2->host = g_strdup(sh->host); |
22910
9004da91edd3
Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22673
diff
changeset
|
926 /*sh2->zeroconf = g_strdup(sh->zeroconf);*/ |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
927 sh2->port = sh->port; |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
928 |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
929 jsx->streamhosts = g_list_prepend(jsx->streamhosts, sh2); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
930 } |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
931 |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
932 /* We have no way of transferring, cancel the transfer */ |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
933 if (streamhost_count == 0) { |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
934 jabber_iq_free(iq); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
935 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
936 /* if available, revert to IBB */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
937 if (jsx->stream_method & STREAM_METHOD_IBB) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
938 purple_debug_info("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
939 "jabber_si_xfer_bytestreams_listen_cb: trying to revert to IBB\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
940 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
941 /* if we are the sender, init the IBB session... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
942 jabber_si_xfer_ibb_send_init(jsx->js, xfer); |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
943 } else { |
25752
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
944 jsx->ibb_timeout_handle = purple_timeout_add_seconds(30, |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
945 jabber_si_bytestreams_ibb_timeout_cb, xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
946 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
947 /* if we are the receiver, we should just wait... the IBB open |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
948 handler has already been set up... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
949 } else { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
950 /* We should probably notify the target, |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
951 but this really shouldn't ever happen */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
952 purple_xfer_cancel_local(xfer); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
953 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
954 |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
955 return; |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
956 } |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
957 |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
958 jabber_iq_set_callback(iq, jabber_si_connect_proxy_cb, xfer); |
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
959 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
960 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
962 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
963 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
964 static void |
15822 | 965 jabber_si_xfer_bytestreams_send_init(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
966 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
967 JabberSIXfer *jsx; |
31525
db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31481
diff
changeset
|
968 PurpleProxyType proxy_type; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
969 |
15822 | 970 purple_xfer_ref(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
971 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
972 jsx = xfer->data; |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
973 |
31525
db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31481
diff
changeset
|
974 /* TODO: This should probably be done with an account option instead of |
db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31481
diff
changeset
|
975 * piggy-backing on the TOR proxy type. */ |
db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31481
diff
changeset
|
976 proxy_type = purple_proxy_info_get_type( |
db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31481
diff
changeset
|
977 purple_proxy_get_setup(purple_connection_get_account(jsx->js->gc))); |
db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31481
diff
changeset
|
978 if (proxy_type == PURPLE_PROXY_TOR) { |
db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31481
diff
changeset
|
979 purple_debug_info("jabber", "Skipping attempting local streamhost.\n"); |
db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31481
diff
changeset
|
980 jsx->listen_data = NULL; |
db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31481
diff
changeset
|
981 } else |
db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31481
diff
changeset
|
982 jsx->listen_data = purple_network_listen_range(0, 0, SOCK_STREAM, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
983 jabber_si_xfer_bytestreams_listen_cb, xfer); |
31525
db082e0421f6
xmpp: Don't advertise our IPs as available streamhosts when using a TOR proxy.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31481
diff
changeset
|
984 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
985 if (jsx->listen_data == NULL) { |
23364
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
986 /* We couldn't open a local port. Perhaps we can use a proxy. */ |
05802d915c13
Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23363
diff
changeset
|
987 jabber_si_xfer_bytestreams_listen_cb(-1, xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
988 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
989 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
990 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
991 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
992 static void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
993 jabber_si_xfer_ibb_error_cb(JabberIBBSession *sess) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
994 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
995 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
996 |
27284
73c8e1964eef
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27108
diff
changeset
|
997 purple_debug_error("jabber", "an error occurred during IBB file transfer\n"); |
25757
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
998 purple_xfer_cancel_remote(xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
999 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1000 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1001 static void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1002 jabber_si_xfer_ibb_closed_cb(JabberIBBSession *sess) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1003 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1004 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1005 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1006 purple_debug_info("jabber", "the remote user closed the transfer\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1007 if (purple_xfer_get_bytes_remaining(xfer) > 0) { |
25757
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1008 purple_xfer_cancel_remote(xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1009 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1010 purple_xfer_set_completed(xfer, TRUE); |
25757
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1011 purple_xfer_end(xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1012 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1013 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1014 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1015 static void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1016 jabber_si_xfer_ibb_recv_data_cb(JabberIBBSession *sess, gpointer data, |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1017 gsize size) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1018 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1019 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1020 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1021 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1022 if (size <= purple_xfer_get_bytes_remaining(xfer)) { |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25752
diff
changeset
|
1023 purple_debug_info("jabber", "about to write %" G_GSIZE_FORMAT " bytes from IBB stream\n", |
25725
daaabfcf5c2b
Revert to using g_fopen (since we have a compatability define for old glibs)
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
1024 size); |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1025 purple_circ_buffer_append(jsx->ibb_buffer, data, size); |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1026 purple_xfer_prpl_ready(xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1027 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1028 /* trying to write past size of file transfers negotiated size, |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1029 reject transfer to protect against malicious behaviour */ |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1030 purple_debug_error("jabber", |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25752
diff
changeset
|
1031 "IBB file transfer send more data than expected\n"); |
25757
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1032 purple_xfer_cancel_remote(xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1033 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1034 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1035 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1036 |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1037 static gssize |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1038 jabber_si_xfer_ibb_read(guchar **out_buffer, PurpleXfer *xfer) |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1039 { |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1040 JabberSIXfer *jsx = xfer->data; |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1041 guchar *buffer; |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1042 gsize size; |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1043 gsize tmp; |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1044 |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1045 size = jsx->ibb_buffer->bufused; |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1046 *out_buffer = buffer = g_malloc(size); |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1047 while ((tmp = purple_circ_buffer_get_max_read(jsx->ibb_buffer))) { |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1048 memcpy(buffer, jsx->ibb_buffer->outptr, tmp); |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1049 buffer += tmp; |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1050 purple_circ_buffer_mark_read(jsx->ibb_buffer, tmp); |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1051 } |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1052 |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1053 return size; |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1054 } |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1055 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1056 static gboolean |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26469
diff
changeset
|
1057 jabber_si_xfer_ibb_open_cb(JabberStream *js, const char *who, const char *id, |
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26469
diff
changeset
|
1058 xmlnode *open) |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1059 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1060 const gchar *sid = xmlnode_get_attrib(open, "sid"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1061 PurpleXfer *xfer = jabber_si_xfer_find(js, sid, who); |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1062 if (xfer) { |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1063 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1064 JabberIBBSession *sess = |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26469
diff
changeset
|
1065 jabber_ibb_session_create_from_xmlnode(js, who, id, open, xfer); |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25752
diff
changeset
|
1066 |
25757
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1067 jabber_si_bytestreams_ibb_timeout_remove(jsx); |
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1068 |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1069 if (sess) { |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1070 /* setup callbacks here...*/ |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1071 jabber_ibb_session_set_data_received_callback(sess, |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1072 jabber_si_xfer_ibb_recv_data_cb); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1073 jabber_ibb_session_set_closed_callback(sess, |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1074 jabber_si_xfer_ibb_closed_cb); |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1075 jabber_ibb_session_set_error_callback(sess, |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1076 jabber_si_xfer_ibb_error_cb); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1077 |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1078 jsx->ibb_session = sess; |
29612
8f442c566ff2
jabber: Adjust amount of data to send in IBB packets so that at most block-size
Marcus Lundblad <ml@update.uu.se>
parents:
29339
diff
changeset
|
1079 /* we handle up to block-size bytes of decoded data, to handle |
8f442c566ff2
jabber: Adjust amount of data to send in IBB packets so that at most block-size
Marcus Lundblad <ml@update.uu.se>
parents:
29339
diff
changeset
|
1080 clients interpreting the block-size attribute as that |
8f442c566ff2
jabber: Adjust amount of data to send in IBB packets so that at most block-size
Marcus Lundblad <ml@update.uu.se>
parents:
29339
diff
changeset
|
1081 (see also remark in ibb.c) */ |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1082 jsx->ibb_buffer = |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1083 purple_circ_buffer_new(jabber_ibb_session_get_block_size(sess)); |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1084 |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1085 /* set up read function */ |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1086 purple_xfer_set_read_fnc(xfer, jabber_si_xfer_ibb_read); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1087 |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1088 /* start the transfer */ |
27874
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
27800
diff
changeset
|
1089 purple_xfer_start(xfer, -1, NULL, 0); |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1090 return TRUE; |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1091 } else { |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1092 /* failed to create IBB session */ |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1093 purple_debug_error("jabber", "failed to create IBB session\n"); |
25757
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1094 purple_xfer_cancel_remote(xfer); |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1095 return FALSE; |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1096 } |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1097 } else { |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1098 /* we got an IBB <open/> for an unknown file transfer, pass along... */ |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1099 purple_debug_info("jabber", |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1100 "IBB open did not match any SI file transfer\n"); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1101 return FALSE; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1102 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1103 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1104 |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1105 static gssize |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1106 jabber_si_xfer_ibb_write(const guchar *buffer, size_t len, PurpleXfer *xfer) |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1107 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1108 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1109 JabberIBBSession *sess = jsx->ibb_session; |
29612
8f442c566ff2
jabber: Adjust amount of data to send in IBB packets so that at most block-size
Marcus Lundblad <ml@update.uu.se>
parents:
29339
diff
changeset
|
1110 gsize packet_size = len < jabber_ibb_session_get_max_data_size(sess) ? |
8f442c566ff2
jabber: Adjust amount of data to send in IBB packets so that at most block-size
Marcus Lundblad <ml@update.uu.se>
parents:
29339
diff
changeset
|
1111 len : jabber_ibb_session_get_max_data_size(sess); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1112 |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1113 jabber_ibb_session_send_data(sess, buffer, packet_size); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1114 |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1115 return packet_size; |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1116 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1117 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1118 static void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1119 jabber_si_xfer_ibb_sent_cb(JabberIBBSession *sess) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1120 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1121 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1122 gsize remaining = purple_xfer_get_bytes_remaining(xfer); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1123 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1124 if (remaining == 0) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1125 /* close the session */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1126 jabber_ibb_session_close(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1127 purple_xfer_set_completed(xfer, TRUE); |
25731
d6351b105e42
Call purple_xfer_end when ending an IBB session.
Marcus Lundblad <ml@update.uu.se>
parents:
25730
diff
changeset
|
1128 purple_xfer_end(xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1129 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1130 /* send more... */ |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1131 purple_xfer_prpl_ready(xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1132 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1133 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1134 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1135 static void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1136 jabber_si_xfer_ibb_opened_cb(JabberIBBSession *sess) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1137 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1138 PurpleXfer *xfer = (PurpleXfer *) jabber_ibb_session_get_user_data(sess); |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25752
diff
changeset
|
1139 |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1140 if (jabber_ibb_session_get_state(sess) == JABBER_IBB_SESSION_OPENED) { |
27874
6adbdd4b2963
ft: Fix a bunch of uses of 0 as an 'invalid' fd.
Paul Aurich <paul@darkrain42.org>
parents:
27800
diff
changeset
|
1141 purple_xfer_start(xfer, -1, NULL, 0); |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1142 purple_xfer_prpl_ready(xfer); |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1143 } else { |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1144 /* error */ |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1145 purple_xfer_end(xfer); |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25731
diff
changeset
|
1146 } |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1147 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1148 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1149 static void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1150 jabber_si_xfer_ibb_send_init(JabberStream *js, PurpleXfer *xfer) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1151 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1152 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1153 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1154 jsx->ibb_session = jabber_ibb_session_create(js, jsx->stream_id, |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1155 purple_xfer_get_remote_user(xfer), xfer); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1156 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1157 if (jsx->ibb_session) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1158 /* should set callbacks here... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1159 jabber_ibb_session_set_opened_callback(jsx->ibb_session, |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1160 jabber_si_xfer_ibb_opened_cb); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1161 jabber_ibb_session_set_data_sent_callback(jsx->ibb_session, |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1162 jabber_si_xfer_ibb_sent_cb); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1163 jabber_ibb_session_set_closed_callback(jsx->ibb_session, |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1164 jabber_si_xfer_ibb_closed_cb); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1165 jabber_ibb_session_set_error_callback(jsx->ibb_session, |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1166 jabber_si_xfer_ibb_error_cb); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1167 |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1168 purple_xfer_set_write_fnc(xfer, jabber_si_xfer_ibb_write); |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1169 |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1170 jsx->ibb_buffer = |
29612
8f442c566ff2
jabber: Adjust amount of data to send in IBB packets so that at most block-size
Marcus Lundblad <ml@update.uu.se>
parents:
29339
diff
changeset
|
1171 purple_circ_buffer_new(jabber_ibb_session_get_max_data_size(jsx->ibb_session)); |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1172 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1173 /* open the IBB session */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1174 jabber_ibb_session_open(jsx->ibb_session); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1175 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1176 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1177 /* failed to create IBB session */ |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1178 purple_debug_error("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1179 "failed to initiate IBB session for file transfer\n"); |
25757
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1180 purple_xfer_cancel_local(xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1181 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1182 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1183 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
1184 static void jabber_si_xfer_send_method_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
1185 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25979
diff
changeset
|
1186 xmlnode *packet, gpointer data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1187 { |
15822 | 1188 PurpleXfer *xfer = data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1189 xmlnode *si, *feature, *x, *field, *value; |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1190 gboolean found_method = FALSE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1191 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1192 if(!(si = xmlnode_get_child_with_namespace(packet, "si", "http://jabber.org/protocol/si"))) { |
15822 | 1193 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1194 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1195 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1196 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1197 if(!(feature = xmlnode_get_child_with_namespace(si, "feature", "http://jabber.org/protocol/feature-neg"))) { |
15822 | 1198 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1199 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1200 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1201 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1202 if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data"))) { |
15822 | 1203 purple_xfer_cancel_remote(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1204 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1205 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1206 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1207 for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1208 const char *var = xmlnode_get_attrib(field, "var"); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1209 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1210 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1211 if(var && !strcmp(var, "stream-method")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1212 if((value = xmlnode_get_child(field, "value"))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1213 char *val = xmlnode_get_data(value); |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
1214 if(val && !strcmp(val, NS_BYTESTREAMS)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1215 jabber_si_xfer_bytestreams_send_init(xfer); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1216 jsx->stream_method |= STREAM_METHOD_BYTESTREAMS; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1217 found_method = TRUE; |
28645
7b4ade7c6d8a
jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents:
28513
diff
changeset
|
1218 } else if (val && !strcmp(val, NS_IBB)) { |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1219 jsx->stream_method |= STREAM_METHOD_IBB; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1220 if (!found_method) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1221 /* we haven't tried to init a bytestream session, yet |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1222 start IBB right away... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1223 jabber_si_xfer_ibb_send_init(js, xfer); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1224 found_method = TRUE; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1225 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1226 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1227 g_free(val); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1228 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1229 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1230 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1231 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1232 if (!found_method) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1233 purple_xfer_cancel_remote(xfer); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1234 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1235 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1236 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1237 |
15822 | 1238 static void jabber_si_xfer_send_request(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1239 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1240 JabberSIXfer *jsx = xfer->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1241 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1242 xmlnode *si, *file, *feature, *x, *field, *option, *value; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1243 char buf[32]; |
29841
f3a573191e43
Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <ml@update.uu.se>
parents:
29835
diff
changeset
|
1244 #if ENABLE_FT_THUMBNAILS |
29835
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29828
diff
changeset
|
1245 gconstpointer thumb; |
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29828
diff
changeset
|
1246 gsize thumb_size; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1247 |
29841
f3a573191e43
Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <ml@update.uu.se>
parents:
29835
diff
changeset
|
1248 purple_xfer_prepare_thumbnail(xfer, "jpeg,png"); |
f3a573191e43
Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <ml@update.uu.se>
parents:
29835
diff
changeset
|
1249 #endif |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1250 xfer->filename = g_path_get_basename(xfer->local_filename); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30923
diff
changeset
|
1251 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1252 iq = jabber_iq_new(jsx->js, JABBER_IQ_SET); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1253 xmlnode_set_attrib(iq->node, "to", xfer->who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1254 si = xmlnode_new_child(iq->node, "si"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1255 xmlnode_set_namespace(si, "http://jabber.org/protocol/si"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1256 jsx->stream_id = jabber_get_next_id(jsx->js); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1257 xmlnode_set_attrib(si, "id", jsx->stream_id); |
30225
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1258 xmlnode_set_attrib(si, "profile", NS_SI_FILE_TRANSFER); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1259 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1260 file = xmlnode_new_child(si, "file"); |
30225
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1261 xmlnode_set_namespace(file, NS_SI_FILE_TRANSFER); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1262 xmlnode_set_attrib(file, "name", xfer->filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1263 g_snprintf(buf, sizeof(buf), "%" G_GSIZE_FORMAT, xfer->size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1264 xmlnode_set_attrib(file, "size", buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1265 /* maybe later we'll do hash and date attribs */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1266 |
29841
f3a573191e43
Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <ml@update.uu.se>
parents:
29835
diff
changeset
|
1267 #if ENABLE_FT_THUMBNAILS |
29787
7d8b074feda2
Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <ml@update.uu.se>
parents:
29783
diff
changeset
|
1268 /* add thumbnail, if appropriate */ |
29835
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29828
diff
changeset
|
1269 if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) { |
29822
25a53c299713
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <ml@update.uu.se>
parents:
29817
diff
changeset
|
1270 const gchar *mimetype = purple_xfer_get_thumbnail_mimetype(xfer); |
25a53c299713
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <ml@update.uu.se>
parents:
29817
diff
changeset
|
1271 JabberData *thumbnail_data = |
29835
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29828
diff
changeset
|
1272 jabber_data_create_from_data(thumb, thumb_size, |
afc9cec164e4
Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29828
diff
changeset
|
1273 mimetype, TRUE, jsx->js); |
29787
7d8b074feda2
Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <ml@update.uu.se>
parents:
29783
diff
changeset
|
1274 xmlnode *thumbnail = xmlnode_new_child(file, "thumbnail"); |
29810
4cfa6d49bee5
Added the "thumbs" namespace to namespaces.h
Marcus Lundblad <ml@update.uu.se>
parents:
29809
diff
changeset
|
1275 xmlnode_set_namespace(thumbnail, NS_THUMBS); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30923
diff
changeset
|
1276 xmlnode_set_attrib(thumbnail, "cid", |
29787
7d8b074feda2
Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <ml@update.uu.se>
parents:
29783
diff
changeset
|
1277 jabber_data_get_cid(thumbnail_data)); |
29822
25a53c299713
Allow PRPLs to specify the image formats acceptable for thumbnails (in
Marcus Lundblad <ml@update.uu.se>
parents:
29817
diff
changeset
|
1278 xmlnode_set_attrib(thumbnail, "mime-type", mimetype); |
29787
7d8b074feda2
Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <ml@update.uu.se>
parents:
29783
diff
changeset
|
1279 /* cache data */ |
7d8b074feda2
Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <ml@update.uu.se>
parents:
29783
diff
changeset
|
1280 jabber_data_associate_local(thumbnail_data, NULL); |
7d8b074feda2
Create the thumbnail data and include the "thumbnail" element in the file
Marcus Lundblad <ml@update.uu.se>
parents:
29783
diff
changeset
|
1281 } |
29841
f3a573191e43
Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <ml@update.uu.se>
parents:
29835
diff
changeset
|
1282 #endif |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30923
diff
changeset
|
1283 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1284 feature = xmlnode_new_child(si, "feature"); |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
1285 xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1286 x = xmlnode_new_child(feature, "x"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1287 xmlnode_set_namespace(x, "jabber:x:data"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1288 xmlnode_set_attrib(x, "type", "form"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1289 field = xmlnode_new_child(x, "field"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1290 xmlnode_set_attrib(field, "var", "stream-method"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1291 xmlnode_set_attrib(field, "type", "list-single"); |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
1292 /* maybe we should add an option to always skip bytestreams for people |
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
1293 behind troublesome firewalls */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1294 option = xmlnode_new_child(field, "option"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1295 value = xmlnode_new_child(option, "value"); |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
1296 xmlnode_insert_data(value, NS_BYTESTREAMS, -1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1297 option = xmlnode_new_child(field, "option"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1298 value = xmlnode_new_child(option, "value"); |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
1299 xmlnode_insert_data(value, NS_IBB, -1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1300 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1301 jabber_iq_set_callback(iq, jabber_si_xfer_send_method_cb, xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1302 |
19676
a48681403103
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 <daniel.atallah@gmail.com>
parents:
18210
diff
changeset
|
1303 /* Store the IQ id so that we can cancel the callback */ |
a48681403103
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 <daniel.atallah@gmail.com>
parents:
18210
diff
changeset
|
1304 g_free(jsx->iq_id); |
a48681403103
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 <daniel.atallah@gmail.com>
parents:
18210
diff
changeset
|
1305 jsx->iq_id = g_strdup(iq->id); |
a48681403103
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 <daniel.atallah@gmail.com>
parents:
18210
diff
changeset
|
1306 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1307 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1308 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1309 |
15822 | 1310 static void jabber_si_xfer_free(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1311 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1312 JabberSIXfer *jsx = xfer->data; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1313 |
25730
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1314 if (jsx) { |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1315 JabberStream *js = jsx->js; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1316 |
25730
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1317 js->file_transfers = g_list_remove(js->file_transfers, xfer); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1318 |
25730
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1319 if (jsx->connect_data != NULL) |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1320 purple_proxy_connect_cancel(jsx->connect_data); |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1321 if (jsx->listen_data != NULL) |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1322 purple_network_listen_cancel(jsx->listen_data); |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1323 if (jsx->iq_id != NULL) |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1324 jabber_iq_remove_callback_by_id(js, jsx->iq_id); |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1325 if (jsx->local_streamhost_fd >= 0) |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1326 close(jsx->local_streamhost_fd); |
27108
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26932
diff
changeset
|
1327 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND && |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26932
diff
changeset
|
1328 xfer->fd >= 0) { |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26932
diff
changeset
|
1329 purple_debug_info("jabber", "remove port mapping\n"); |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26932
diff
changeset
|
1330 purple_network_remove_port_mapping(xfer->fd); |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26932
diff
changeset
|
1331 } |
25730
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1332 if (jsx->connect_timeout > 0) |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1333 purple_timeout_remove(jsx->connect_timeout); |
25752
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
1334 if (jsx->ibb_timeout_handle > 0) |
2faa374df334
Remove timeout for IBB when receiving an IBB session open from the initiator
Marcus Lundblad <ml@update.uu.se>
parents:
25751
diff
changeset
|
1335 purple_timeout_remove(jsx->ibb_timeout_handle); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1336 |
25730
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1337 if (jsx->streamhosts) { |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1338 g_list_foreach(jsx->streamhosts, jabber_si_free_streamhost, NULL); |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1339 g_list_free(jsx->streamhosts); |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1340 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1341 |
25730
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1342 if (jsx->ibb_session) { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1343 purple_debug_info("jabber", |
25730
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1344 "jabber_si_xfer_free: destroying IBB session\n"); |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1345 jabber_ibb_session_destroy(jsx->ibb_session); |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1346 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1347 |
27879
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1348 if (jsx->ibb_buffer) { |
b2dd32ce7353
jabber: Migrate IBB to the new code added in the previous commit.
Paul Aurich <paul@darkrain42.org>
parents:
27874
diff
changeset
|
1349 purple_circ_buffer_destroy(jsx->ibb_buffer); |
25730
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1350 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1351 |
27800
deecc1d663c4
Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <paul@darkrain42.org>
parents:
27559
diff
changeset
|
1352 purple_debug_info("jabber", "jabber_si_xfer_free(): freeing jsx %p\n", jsx); |
deecc1d663c4
Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <paul@darkrain42.org>
parents:
27559
diff
changeset
|
1353 |
25730
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1354 g_free(jsx->stream_id); |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1355 g_free(jsx->iq_id); |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1356 /* XXX: free other stuff */ |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1357 g_free(jsx->rxqueue); |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1358 g_free(jsx); |
6e0f1532eb3d
Check don't try to free the JabberSIXfer if it's already been freed.
Marcus Lundblad <ml@update.uu.se>
parents:
25729
diff
changeset
|
1359 xfer->data = NULL; |
21603
a4b6854737d5
Implement more of XEP-0065 to support sending files through a proxy. To avoid adding strings this close to a release, it only supports using a proxy that is discovered from the server, but we'll include an account option to manually specify a ft proxy in the next release. Lots of this is based on a patch from galt - Fixes #3730, #116, #1768
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21561
diff
changeset
|
1360 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1361 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1362 |
25757
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1363 /* |
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1364 * These four functions should only be called from the PurpleXfer functions |
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1365 * (typically purple_xfer_cancel_(remote|local), purple_xfer_end, or |
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1366 * purple_xfer_request_denied. |
4b51394fd834
Standardize all the IBB stream cleanup
Paul Aurich <paul@darkrain42.org>
parents:
25756
diff
changeset
|
1367 */ |
15822 | 1368 static void jabber_si_xfer_cancel_send(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1369 { |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1370 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1371 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1372 /* if there is an IBB session active, send close on that */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1373 if (jsx->ibb_session) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1374 jabber_ibb_session_close(jsx->ibb_session); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1375 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1376 jabber_si_xfer_free(xfer); |
28513
fa7f3426ed13
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
1377 purple_debug_info("jabber", "in jabber_si_xfer_cancel_send\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1378 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1379 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1380 |
15822 | 1381 static void jabber_si_xfer_request_denied(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1382 { |
27559
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1383 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1384 JabberStream *js = jsx->js; |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1385 |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1386 /* |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1387 * TODO: It's probably an error if jsx->iq_id == NULL. g_return_if_fail |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1388 * might be warranted. |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1389 */ |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1390 if (jsx->iq_id && !jsx->accepted) { |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1391 JabberIq *iq; |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1392 xmlnode *error, *child; |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1393 iq = jabber_iq_new(js, JABBER_IQ_ERROR); |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1394 xmlnode_set_attrib(iq->node, "to", xfer->who); |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1395 jabber_iq_set_id(iq, jsx->iq_id); |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1396 |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1397 error = xmlnode_new_child(iq->node, "error"); |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1398 xmlnode_set_attrib(error, "type", "cancel"); |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1399 child = xmlnode_new_child(error, "forbidden"); |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
1400 xmlnode_set_namespace(child, NS_XMPP_STANZAS); |
27559
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1401 child = xmlnode_new_child(error, "text"); |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
1402 xmlnode_set_namespace(child, NS_XMPP_STANZAS); |
27559
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1403 xmlnode_insert_data(child, "Offer Declined", -1); |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1404 |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1405 jabber_iq_send(iq); |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1406 } |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1407 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1408 jabber_si_xfer_free(xfer); |
28513
fa7f3426ed13
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
1409 purple_debug_info("jabber", "in jabber_si_xfer_request_denied\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1410 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1411 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1412 |
15822 | 1413 static void jabber_si_xfer_cancel_recv(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1414 { |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1415 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1416 /* if there is an IBB session active, send close */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1417 if (jsx->ibb_session) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1418 jabber_ibb_session_close(jsx->ibb_session); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1419 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1420 jabber_si_xfer_free(xfer); |
28513
fa7f3426ed13
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
1421 purple_debug_info("jabber", "in jabber_si_xfer_cancel_recv\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1422 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1423 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1424 |
15822 | 1425 static void jabber_si_xfer_end(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1426 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1427 jabber_si_xfer_free(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1428 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1429 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1430 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1431 static void jabber_si_xfer_send_disco_cb(JabberStream *js, const char *who, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1432 JabberCapabilities capabilities, gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1433 { |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1434 PurpleXfer *xfer = (PurpleXfer *) data; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1435 JabberSIXfer *jsx = (JabberSIXfer *) xfer->data; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1436 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1437 if (capabilities & JABBER_CAP_IBB) { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1438 purple_debug_info("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1439 "jabber_si_xfer_send_disco_cb: remote JID supports IBB\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1440 jsx->stream_method |= STREAM_METHOD_IBB; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1441 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1442 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1443 if (capabilities & JABBER_CAP_SI_FILE_XFER) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1444 jabber_si_xfer_send_request(xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1445 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1446 char *msg = g_strdup_printf(_("Unable to send file to %s, user does not support file transfers"), who); |
15822 | 1447 purple_notify_error(js->gc, _("File Send Failed"), |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1448 _("File Send Failed"), msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1449 g_free(msg); |
27558
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1450 purple_xfer_cancel_local(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1451 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1452 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1453 |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1454 static void resource_select_cancel_cb(PurpleXfer *xfer, PurpleRequestFields *fields) |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1455 { |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1456 purple_xfer_cancel_local(xfer); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1457 } |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1458 |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1459 static void do_transfer_send(PurpleXfer *xfer, const char *resource) |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1460 { |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1461 JabberSIXfer *jsx = xfer->data; |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1462 char **who_v = g_strsplit(xfer->who, "/", 2); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1463 char *who; |
27558
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1464 JabberBuddy *jb; |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1465 JabberBuddyResource *jbr = NULL; |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1466 |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1467 jb = jabber_buddy_find(jsx->js, who_v[0], FALSE); |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1468 if (jb) { |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1469 jbr = jabber_buddy_find_resource(jb, resource); |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1470 } |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1471 |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1472 who = g_strdup_printf("%s/%s", who_v[0], resource); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1473 g_strfreev(who_v); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1474 g_free(xfer->who); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1475 xfer->who = who; |
27558
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1476 |
28781
6921cc1e704b
Use the jabber_resource_know_capabilities function to determine if a buddy
Marcus Lundblad <ml@update.uu.se>
parents:
28779
diff
changeset
|
1477 if (jbr && jabber_resource_know_capabilities(jbr)) { |
27558
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1478 char *msg; |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1479 |
28645
7b4ade7c6d8a
jabber: Start putting all the namespaces in one location with consistent naming.
Paul Aurich <paul@darkrain42.org>
parents:
28513
diff
changeset
|
1480 if (jabber_resource_has_capability(jbr, NS_IBB)) |
27558
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1481 jsx->stream_method |= STREAM_METHOD_IBB; |
30225
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1482 if (jabber_resource_has_capability(jbr, NS_SI_FILE_TRANSFER)) { |
27558
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1483 jabber_si_xfer_send_request(xfer); |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1484 return; |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1485 } |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1486 |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1487 msg = g_strdup_printf(_("Unable to send file to %s, user does not support file transfers"), who); |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1488 purple_notify_error(jsx->js->gc, _("File Send Failed"), |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1489 _("File Send Failed"), msg); |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1490 g_free(msg); |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1491 purple_xfer_cancel_local(xfer); |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1492 } else { |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1493 jabber_disco_info_do(jsx->js, who, |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1494 jabber_si_xfer_send_disco_cb, xfer); |
636c3b6c9cc7
Use Entity Caps for determining file transfer abilities, if possible.
Paul Aurich <paul@darkrain42.org>
parents:
27284
diff
changeset
|
1495 } |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1496 } |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1497 |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1498 static void resource_select_ok_cb(PurpleXfer *xfer, PurpleRequestFields *fields) |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1499 { |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1500 PurpleRequestField *field = purple_request_fields_get_field(fields, "resource"); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1501 int selected_id = purple_request_field_choice_get_value(field); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1502 GList *labels = purple_request_field_choice_get_labels(field); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1503 |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1504 const char *selected_label = g_list_nth_data(labels, selected_id); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1505 |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1506 do_transfer_send(xfer, selected_label); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1507 } |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1508 |
15822 | 1509 static void jabber_si_xfer_init(PurpleXfer *xfer) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1510 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1511 JabberSIXfer *jsx = xfer->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1512 JabberIq *iq; |
15822 | 1513 if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1514 JabberBuddy *jb; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1515 JabberBuddyResource *jbr = NULL; |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1516 char *resource; |
30225
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1517 GList *resources = NULL; |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30923
diff
changeset
|
1518 |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1519 if(NULL != (resource = jabber_get_resource(xfer->who))) { |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1520 /* they've specified a resource, no need to ask or |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1521 * default or anything, just do it */ |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1522 |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1523 do_transfer_send(xfer, resource); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1524 g_free(resource); |
21556
4e98fb3661cc
Prevent multiple file offers from going out with a patch from galt. Fixes #3839.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21284
diff
changeset
|
1525 return; |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1526 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1527 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1528 jb = jabber_buddy_find(jsx->js, xfer->who, TRUE); |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1529 |
30225
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1530 if (jb) { |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1531 GList *l; |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1532 |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1533 for (l = jb->resources ; l ; l = g_list_next(l)) { |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1534 jbr = l->data; |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1535 |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1536 if (!jabber_resource_know_capabilities(jbr) || |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1537 (jabber_resource_has_capability(jbr, NS_SI_FILE_TRANSFER) |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1538 && (jabber_resource_has_capability(jbr, NS_BYTESTREAMS) |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1539 || jabber_resource_has_capability(jbr, NS_IBB)))) { |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1540 resources = g_list_append(resources, jbr); |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1541 } |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1542 } |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1543 } |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30923
diff
changeset
|
1544 |
30225
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1545 if (!resources) { |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1546 /* no resources online, we're trying to send to someone |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1547 * whose presence we're not subscribed to, or |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1548 * someone who is offline. Let's inform the user */ |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1549 char *msg; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1550 |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1551 if(!jb) { |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1552 msg = g_strdup_printf(_("Unable to send file to %s, invalid JID"), xfer->who); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1553 } else if(jb->subscription & JABBER_SUB_TO) { |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1554 msg = g_strdup_printf(_("Unable to send file to %s, user is not online"), xfer->who); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1555 } else { |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1556 msg = g_strdup_printf(_("Unable to send file to %s, not subscribed to user presence"), xfer->who); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1557 } |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1558 |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1559 purple_notify_error(jsx->js->gc, _("File Send Failed"), _("File Send Failed"), msg); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1560 g_free(msg); |
30225
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1561 } else if (g_list_length(resources) == 1) { |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1562 /* only 1 resource online (probably our most common case) |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1563 * so no need to ask who to send to */ |
30225
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1564 jbr = resources->data; |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1565 do_transfer_send(xfer, jbr->name); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1566 } else { |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1567 /* we've got multiple resources, we need to pick one to send to */ |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1568 GList *l; |
22204
a464d2bd6f01
I'm not sure how to disapprove a local change without it ever getting pushed... sorry for the double commit. I didn't intend to leave a trailing colon, since we didn't use punctuation at the end previously.
Evan Schoenberg <evan.s@dreskin.net>
parents:
22203
diff
changeset
|
1569 char *msg = g_strdup_printf(_("Please select the resource of %s to which you would like to send a file"), xfer->who); |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1570 PurpleRequestFields *fields = purple_request_fields_new(); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1571 PurpleRequestField *field = purple_request_field_choice_new("resource", _("Resource"), 0); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1572 PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30923
diff
changeset
|
1573 |
30225
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1574 for(l = resources; l; l = l->next) { |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1575 jbr = l->data; |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1576 purple_request_field_choice_add(field, jbr->name); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1577 } |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1578 |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1579 purple_request_field_group_add_field(group, field); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1580 |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1581 purple_request_fields_add_group(fields, group); |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1582 |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
1583 purple_request_fields(jsx->js->gc, _("Select a Resource"), msg, NULL, fields, |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1584 _("Send File"), G_CALLBACK(resource_select_ok_cb), _("Cancel"), G_CALLBACK(resource_select_cancel_cb), |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
1585 jsx->js->gc->account, xfer->who, NULL, xfer); |
17365
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1586 |
cc1b4d2e5a9b
if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents:
15822
diff
changeset
|
1587 g_free(msg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1588 } |
30225
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1589 |
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1590 g_list_free(resources); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1591 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1592 xmlnode *si, *feature, *x, *field, *value; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1593 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1594 iq = jabber_iq_new(jsx->js, JABBER_IQ_RESULT); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1595 xmlnode_set_attrib(iq->node, "to", xfer->who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1596 if(jsx->iq_id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1597 jabber_iq_set_id(iq, jsx->iq_id); |
27559
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1598 else |
97eb110550ad
Properly send rejection to initiator if we reject a transfer.
Paul Aurich <paul@darkrain42.org>
parents:
27558
diff
changeset
|
1599 purple_debug_error("jabber", "Sending SI result with new IQ id.\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1600 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1601 jsx->accepted = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1602 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1603 si = xmlnode_new_child(iq->node, "si"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1604 xmlnode_set_namespace(si, "http://jabber.org/protocol/si"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1605 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1606 feature = xmlnode_new_child(si, "feature"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1607 xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1608 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1609 x = xmlnode_new_child(feature, "x"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1610 xmlnode_set_namespace(x, "jabber:x:data"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1611 xmlnode_set_attrib(x, "type", "submit"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1612 field = xmlnode_new_child(x, "field"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1613 xmlnode_set_attrib(field, "var", "stream-method"); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1614 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1615 /* we should maybe "remember" if bytestreams has failed before (in the |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1616 same session) with this JID, and only present IBB as an option to |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1617 avoid unnessesary timeout */ |
25750
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
1618 /* maybe we should have an account option to always just try IBB |
5d65993761c1
Add timeout when receiver waits for initiator to open an IBB session
Marcus Lundblad <ml@update.uu.se>
parents:
25745
diff
changeset
|
1619 for people who know their firewalls are very restrictive */ |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1620 if (jsx->stream_method & STREAM_METHOD_BYTESTREAMS) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1621 value = xmlnode_new_child(field, "value"); |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
1622 xmlnode_insert_data(value, NS_BYTESTREAMS, -1); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1623 } else if(jsx->stream_method & STREAM_METHOD_IBB) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1624 value = xmlnode_new_child(field, "value"); |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
1625 xmlnode_insert_data(value, NS_IBB, -1); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1626 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1627 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1628 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1629 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1630 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1631 |
15822 | 1632 PurpleXfer *jabber_si_new_xfer(PurpleConnection *gc, const char *who) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1633 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1634 JabberStream *js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1635 |
15822 | 1636 PurpleXfer *xfer; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1637 JabberSIXfer *jsx; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1638 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1639 js = gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1640 |
15822 | 1641 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1642 if (xfer) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1643 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1644 xfer->data = jsx = g_new0(JabberSIXfer, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1645 jsx->js = js; |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
1646 jsx->local_streamhost_fd = -1; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1647 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1648 jsx->ibb_session = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1649 |
15822 | 1650 purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init); |
1651 purple_xfer_set_cancel_send_fnc(xfer, jabber_si_xfer_cancel_send); | |
1652 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1653 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1654 js->file_transfers = g_list_append(js->file_transfers, xfer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1655 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1656 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1657 return xfer; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1658 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1659 |
15822 | 1660 void jabber_si_xfer_send(PurpleConnection *gc, const char *who, const char *file) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1661 { |
15822 | 1662 PurpleXfer *xfer; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1663 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1664 xfer = jabber_si_new_xfer(gc, who); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1665 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1666 if (file) |
15822 | 1667 purple_xfer_request_accepted(xfer, file); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1668 else |
15822 | 1669 purple_xfer_request(xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1670 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1671 |
29841
f3a573191e43
Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <ml@update.uu.se>
parents:
29835
diff
changeset
|
1672 #if ENABLE_FT_THUMBNAILS |
29788
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1673 static void |
29827
93f6a5d48a46
Updated to use new BoB request functionallity
Marcus Lundblad <ml@update.uu.se>
parents:
29825
diff
changeset
|
1674 jabber_si_thumbnail_cb(JabberData *data, gchar *alt, gpointer userdata) |
29788
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1675 { |
29827
93f6a5d48a46
Updated to use new BoB request functionallity
Marcus Lundblad <ml@update.uu.se>
parents:
29825
diff
changeset
|
1676 PurpleXfer *xfer = (PurpleXfer *) userdata; |
29788
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1677 |
29827
93f6a5d48a46
Updated to use new BoB request functionallity
Marcus Lundblad <ml@update.uu.se>
parents:
29825
diff
changeset
|
1678 if (data) { |
93f6a5d48a46
Updated to use new BoB request functionallity
Marcus Lundblad <ml@update.uu.se>
parents:
29825
diff
changeset
|
1679 purple_xfer_set_thumbnail(xfer, jabber_data_get_data(data), |
93f6a5d48a46
Updated to use new BoB request functionallity
Marcus Lundblad <ml@update.uu.se>
parents:
29825
diff
changeset
|
1680 jabber_data_get_size(data), jabber_data_get_type(data)); |
93f6a5d48a46
Updated to use new BoB request functionallity
Marcus Lundblad <ml@update.uu.se>
parents:
29825
diff
changeset
|
1681 /* data is ephemeral, get rid of now (the xfer re-owned the thumbnail */ |
93f6a5d48a46
Updated to use new BoB request functionallity
Marcus Lundblad <ml@update.uu.se>
parents:
29825
diff
changeset
|
1682 jabber_data_destroy(data); |
29788
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1683 } |
29827
93f6a5d48a46
Updated to use new BoB request functionallity
Marcus Lundblad <ml@update.uu.se>
parents:
29825
diff
changeset
|
1684 |
29788
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1685 purple_xfer_request(xfer); |
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1686 } |
29841
f3a573191e43
Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <ml@update.uu.se>
parents:
29835
diff
changeset
|
1687 #endif |
29788
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1688 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
1689 void jabber_si_parse(JabberStream *js, const char *from, JabberIqType type, |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
1690 const char *id, xmlnode *si) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1691 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1692 JabberSIXfer *jsx; |
15822 | 1693 PurpleXfer *xfer; |
29788
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1694 xmlnode *file, *feature, *x, *field, *option, *value, *thumbnail; |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
1695 const char *stream_id, *filename, *filesize_c, *profile; |
31445
0123005d0fb8
jabber: Slightly better handling of large files (on receipt).
Paul Aurich <paul@darkrain42.org>
parents:
31321
diff
changeset
|
1696 guint64 filesize_64 = 0; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1697 size_t filesize = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1698 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1699 if(!(profile = xmlnode_get_attrib(si, "profile")) || |
30225
fa311a0e51c0
jabber: Don't show resources that we know for sure isn't supporting the file
Marcus Lundblad <ml@update.uu.se>
parents:
30169
diff
changeset
|
1700 strcmp(profile, NS_SI_FILE_TRANSFER)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1701 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1702 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1703 if(!(stream_id = xmlnode_get_attrib(si, "id"))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1704 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1705 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1706 if(!(file = xmlnode_get_child(si, "file"))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1707 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1708 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1709 if(!(filename = xmlnode_get_attrib(file, "name"))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1710 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1711 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1712 if((filesize_c = xmlnode_get_attrib(file, "size"))) |
31445
0123005d0fb8
jabber: Slightly better handling of large files (on receipt).
Paul Aurich <paul@darkrain42.org>
parents:
31321
diff
changeset
|
1713 filesize_64 = g_ascii_strtoull(filesize_c, NULL, 10); |
0123005d0fb8
jabber: Slightly better handling of large files (on receipt).
Paul Aurich <paul@darkrain42.org>
parents:
31321
diff
changeset
|
1714 /* TODO 3.0.0: When the core uses a guint64, this is redundant. |
0123005d0fb8
jabber: Slightly better handling of large files (on receipt).
Paul Aurich <paul@darkrain42.org>
parents:
31321
diff
changeset
|
1715 * See #8477. |
0123005d0fb8
jabber: Slightly better handling of large files (on receipt).
Paul Aurich <paul@darkrain42.org>
parents:
31321
diff
changeset
|
1716 */ |
0123005d0fb8
jabber: Slightly better handling of large files (on receipt).
Paul Aurich <paul@darkrain42.org>
parents:
31321
diff
changeset
|
1717 if (filesize_64 > G_MAXSIZE) { |
31447
a0b9ecdc98c4
Fix a typo in a comment (a very useful commit)
Paul Aurich <paul@darkrain42.org>
parents:
31445
diff
changeset
|
1718 /* Should this pop up a warning? */ |
31445
0123005d0fb8
jabber: Slightly better handling of large files (on receipt).
Paul Aurich <paul@darkrain42.org>
parents:
31321
diff
changeset
|
1719 purple_debug_warning("jabber", "Unable to transfer file (too large)" |
0123005d0fb8
jabber: Slightly better handling of large files (on receipt).
Paul Aurich <paul@darkrain42.org>
parents:
31321
diff
changeset
|
1720 " -- see #8477 for more details."); |
0123005d0fb8
jabber: Slightly better handling of large files (on receipt).
Paul Aurich <paul@darkrain42.org>
parents:
31321
diff
changeset
|
1721 return; |
0123005d0fb8
jabber: Slightly better handling of large files (on receipt).
Paul Aurich <paul@darkrain42.org>
parents:
31321
diff
changeset
|
1722 } |
0123005d0fb8
jabber: Slightly better handling of large files (on receipt).
Paul Aurich <paul@darkrain42.org>
parents:
31321
diff
changeset
|
1723 filesize = filesize_64; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1724 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1725 if(!(feature = xmlnode_get_child(si, "feature"))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1726 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1727 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1728 if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data"))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1729 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1730 |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
1731 if(!from) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1732 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1733 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1734 /* if they've already sent us this file transfer with the same damn id |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1735 * then we're gonna ignore it, until I think of something better to do |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1736 * with it */ |
30413
7c871249318b
Fix some "Dead nested assignment"s and then kill off some useless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30225
diff
changeset
|
1737 if(jabber_si_xfer_find(js, stream_id, from) != NULL) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1738 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1739 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1740 jsx = g_new0(JabberSIXfer, 1); |
23027
3c33405fd630
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22910
diff
changeset
|
1741 jsx->local_streamhost_fd = -1; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25773
diff
changeset
|
1742 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1743 jsx->ibb_session = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1744 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1745 for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1746 const char *var = xmlnode_get_attrib(field, "var"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1747 if(var && !strcmp(var, "stream-method")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1748 for(option = xmlnode_get_child(field, "option"); option; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1749 option = xmlnode_get_next_twin(option)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1750 if((value = xmlnode_get_child(option, "value"))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1751 char *val; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1752 if((val = xmlnode_get_data(value))) { |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
1753 if(!strcmp(val, NS_BYTESTREAMS)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1754 jsx->stream_method |= STREAM_METHOD_BYTESTREAMS; |
28650
9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <paul@darkrain42.org>
parents:
28645
diff
changeset
|
1755 } else if(!strcmp(val, NS_IBB)) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1756 jsx->stream_method |= STREAM_METHOD_IBB; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1757 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1758 g_free(val); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1759 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1760 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1761 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1762 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1763 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1764 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1765 if(jsx->stream_method == STREAM_METHOD_UNKNOWN) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1766 g_free(jsx); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1767 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1768 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1769 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1770 jsx->js = js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1771 jsx->stream_id = g_strdup(stream_id); |
25648
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25433
diff
changeset
|
1772 jsx->iq_id = g_strdup(id); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1773 |
15822 | 1774 xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE, from); |
26227
58daeb191c10
purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <mark@kingant.net>
parents:
25973
diff
changeset
|
1775 g_return_if_fail(xfer != NULL); |
58daeb191c10
purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <mark@kingant.net>
parents:
25973
diff
changeset
|
1776 |
58daeb191c10
purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <mark@kingant.net>
parents:
25973
diff
changeset
|
1777 xfer->data = jsx; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1778 |
26227
58daeb191c10
purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <mark@kingant.net>
parents:
25973
diff
changeset
|
1779 purple_xfer_set_filename(xfer, filename); |
58daeb191c10
purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <mark@kingant.net>
parents:
25973
diff
changeset
|
1780 if(filesize > 0) |
58daeb191c10
purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <mark@kingant.net>
parents:
25973
diff
changeset
|
1781 purple_xfer_set_size(xfer, filesize); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1782 |
26227
58daeb191c10
purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <mark@kingant.net>
parents:
25973
diff
changeset
|
1783 purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init); |
58daeb191c10
purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <mark@kingant.net>
parents:
25973
diff
changeset
|
1784 purple_xfer_set_request_denied_fnc(xfer, jabber_si_xfer_request_denied); |
58daeb191c10
purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <mark@kingant.net>
parents:
25973
diff
changeset
|
1785 purple_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv); |
58daeb191c10
purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <mark@kingant.net>
parents:
25973
diff
changeset
|
1786 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
30923
diff
changeset
|
1787 |
26227
58daeb191c10
purple_xfer_new only returns NULL if an assertion fails, so we should do
Mark Doliner <mark@kingant.net>
parents:
25973
diff
changeset
|
1788 js->file_transfers = g_list_append(js->file_transfers, xfer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1789 |
29841
f3a573191e43
Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <ml@update.uu.se>
parents:
29835
diff
changeset
|
1790 #if ENABLE_FT_THUMBNAILS |
29788
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1791 /* if there is a thumbnail, we should request it... */ |
29810
4cfa6d49bee5
Added the "thumbs" namespace to namespaces.h
Marcus Lundblad <ml@update.uu.se>
parents:
29809
diff
changeset
|
1792 if ((thumbnail = xmlnode_get_child_with_namespace(file, "thumbnail", |
4cfa6d49bee5
Added the "thumbs" namespace to namespaces.h
Marcus Lundblad <ml@update.uu.se>
parents:
29809
diff
changeset
|
1793 NS_THUMBS))) { |
29788
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1794 const char *cid = xmlnode_get_attrib(thumbnail, "cid"); |
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1795 if (cid) { |
29827
93f6a5d48a46
Updated to use new BoB request functionallity
Marcus Lundblad <ml@update.uu.se>
parents:
29825
diff
changeset
|
1796 jabber_data_request(js, cid, purple_xfer_get_remote_user(xfer), |
93f6a5d48a46
Updated to use new BoB request functionallity
Marcus Lundblad <ml@update.uu.se>
parents:
29825
diff
changeset
|
1797 NULL, TRUE, jabber_si_thumbnail_cb, xfer); |
29788
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1798 } else { |
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1799 purple_xfer_request(xfer); |
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1800 } |
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1801 } else { |
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1802 purple_xfer_request(xfer); |
259a331e4de7
Actually request the thumbnail when getting one in an offer.
Marcus Lundblad <ml@update.uu.se>
parents:
29787
diff
changeset
|
1803 } |
29841
f3a573191e43
Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <ml@update.uu.se>
parents:
29835
diff
changeset
|
1804 #else |
29848
1f5c86f79eeb
Silence a warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29841
diff
changeset
|
1805 thumbnail = NULL; /* Silence warning */ |
29841
f3a573191e43
Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <ml@update.uu.se>
parents:
29835
diff
changeset
|
1806 purple_xfer_request(xfer); |
f3a573191e43
Disable thumbnails for XMPP (in si.c) by using an #define
Marcus Lundblad <ml@update.uu.se>
parents:
29835
diff
changeset
|
1807 #endif |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1808 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1809 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1810 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1811 jabber_si_init(void) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1812 { |
26932
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26915
diff
changeset
|
1813 jabber_iq_register_handler("si", "http://jabber.org/protocol/si", jabber_si_parse); |
a8537bbcfb79
Remove trailing whitespace that has snuck in.
Paul Aurich <paul@darkrain42.org>
parents:
26915
diff
changeset
|
1814 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1815 jabber_ibb_register_open_handler(jabber_si_xfer_ibb_open_cb); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1816 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1817 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1818 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1819 jabber_si_uninit(void) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1820 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1821 jabber_ibb_unregister_open_handler(jabber_si_xfer_ibb_open_cb); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1822 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
23707
diff
changeset
|
1823 |