annotate libpurple/protocols/jabber/si.c @ 27907:a64685485775

propagate from branch 'im.pidgin.pidgin' (head a4222a6a8081e1e41a29c5b01c09a31ed212eb60) to branch 'im.pidgin.pidgin.yaz' (head f037145e58bf0c248f0bfb71758c04c604be896b)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sun, 23 Nov 2008 09:40:48 +0000
parents 88955b918197 e4fa83bb82e0
children a063901a5499
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
2 * purple - Jabber Protocol Plugin
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * 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
7 * 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
8 * 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
9 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * 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
12 * 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
13 * 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
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * GNU General Public License for more details.
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 * 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
18 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19675
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22
18210
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 17770
diff changeset
23 #include "internal.h"
15374
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: 17770
diff changeset
25 #include "blist.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "cipher.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "ft.h"
17441
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
29 #include "request.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "network.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "notify.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "buddy.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "disco.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "jabber.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "iq.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #include "si.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
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
39 #define STREAMHOST_CONNECT_TIMEOUT 15
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
25540
d892a9275d0d make use of utf8 filename in jabber.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 18210
diff changeset
41 #include "util.h"
d892a9275d0d make use of utf8 filename in jabber.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 18210
diff changeset
42
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 typedef struct _JabberSIXfer {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 JabberStream *js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
46 PurpleProxyConnectData *connect_data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
47 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
48 guint connect_timeout;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 gboolean accepted;
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 char *stream_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 char *iq_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 enum {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 STREAM_METHOD_UNKNOWN = 0,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 STREAM_METHOD_BYTESTREAMS = 2 << 1,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 STREAM_METHOD_IBB = 2 << 2,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 STREAM_METHOD_UNSUPPORTED = 2 << 31
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 } stream_method;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 GList *streamhosts;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
63 PurpleProxyInfo *gpi;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 char *rxqueue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 size_t rxlen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 gsize rxmaxlen;
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
68 int local_streamhost_fd;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 } JabberSIXfer;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
71 static PurpleXfer*
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 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
73 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 GList *xfers;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 if(!sid || !from)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 for(xfers = js->file_transfers; xfers; xfers = xfers->next) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
80 PurpleXfer *xfer = xfers->data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 JabberSIXfer *jsx = xfer->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 if(jsx->stream_id && xfer->who &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 !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
84 return xfer;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89
22912
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
90 static void
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
91 jabber_si_free_streamhost(gpointer data, gpointer user_data)
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
92 {
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
93 JabberBytestreamsStreamhost *sh = data;
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
94
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
95 if(!data)
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
96 return;
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
97
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
98 g_free(sh->jid);
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
99 g_free(sh->host);
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
100 g_free(sh->zeroconf);
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
101 g_free(sh);
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
102 }
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
103
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
104
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
106 static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 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
110 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
111 PurpleXfer *xfer = data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 JabberSIXfer *jsx = xfer->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 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
115 JabberBytestreamsStreamhost *streamhost = jsx->streamhosts->data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
117 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
118 jsx->gpi = NULL;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 jsx->connect_data = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120
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
121 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
122 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
123 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
124
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 if(source < 0) {
17770
efb5d0fe4895 Better error message for when a Jabber connection fails
Mark Doliner <mark@kingant.net>
parents: 17441
diff changeset
126 purple_debug_warning("jabber",
efb5d0fe4895 Better error message for when a Jabber connection fails
Mark Doliner <mark@kingant.net>
parents: 17441
diff changeset
127 "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
128 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
129 error_message ? error_message : "(null)");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost);
22912
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
131 jabber_si_free_streamhost(streamhost, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 jabber_si_bytestreams_attempt_connect(xfer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135
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
136 /* 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
137 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
138 {
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
139 xmlnode *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
140 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET, "http://jabber.org/protocol/bytestreams");
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
141 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
142 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
143 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
144 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
145 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
146
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 /* 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
148 }
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
149 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
150 {
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 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_RESULT, "http://jabber.org/protocol/bytestreams");
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(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
153 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
154 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
155 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
156 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
157 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
161 purple_xfer_start(xfer, source, NULL, -1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
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
164 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
165 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
166 {
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
167 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
168 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
169
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
170 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
171
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
172 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
173
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 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
175 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
176 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
177
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 /* 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
179 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
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 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
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
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
184 static void jabber_si_bytestreams_attempt_connect(PurpleXfer *xfer)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 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
187 JabberBytestreamsStreamhost *streamhost;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 char *dstaddr, *p;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 int i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 unsigned char hashval[20];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 JabberID *dstjid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 if(!jsx->streamhosts) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 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
195 xmlnode *error, *inf;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 if(jsx->iq_id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 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
199
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 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
201 error = xmlnode_new_child(iq->node, "error");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 xmlnode_set_attrib(error, "code", "404");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 xmlnode_set_attrib(error, "type", "cancel");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 inf = xmlnode_new_child(error, "item-not-found");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 xmlnode_set_namespace(inf, "urn:ietf:params:xml:ns:xmpp-stanzas");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
209 purple_xfer_cancel_local(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 streamhost = jsx->streamhosts->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215
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
216 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
217 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
218 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
219 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
220
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 dstjid = jabber_id_new(xfer->who);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222
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
223 /* 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
224
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
225 if(dstjid != NULL && streamhost->host && streamhost->port > 0) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
226 jsx->gpi = purple_proxy_info_new();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
227 purple_proxy_info_set_type(jsx->gpi, PURPLE_PROXY_SOCKS5);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
228 purple_proxy_info_set_host(jsx->gpi, streamhost->host);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
229 purple_proxy_info_set_port(jsx->gpi, streamhost->port);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230
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
231 /* 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
232 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
233 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
234 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
235 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
236 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
237 jsx->js->user->node, jsx->js->user->domain, jsx->js->user->resource);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
239 purple_cipher_digest_region("sha1", (guchar *)dstaddr, strlen(dstaddr),
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 sizeof(hashval), hashval, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 g_free(dstaddr);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 dstaddr = g_malloc(41);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 p = dstaddr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 for(i=0; i<20; i++, p+=2)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 snprintf(p, 3, "%02x", hashval[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
247 jsx->connect_data = purple_proxy_connect_socks5(NULL, jsx->gpi,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 dstaddr, 0,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 jabber_si_bytestreams_connect_cb, xfer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 g_free(dstaddr);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251
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
252 /* 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
253 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
254 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
255 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
256
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 jabber_id_free(dstjid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 if (jsx->connect_data == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost);
22912
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
263 jabber_si_free_streamhost(streamhost, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 jabber_si_bytestreams_attempt_connect(xfer);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 void jabber_bytestreams_parse(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
270 PurpleXfer *xfer;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 JabberSIXfer *jsx;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 xmlnode *query, *streamhost;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 const char *sid, *from, *type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "set"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 if(!(from = xmlnode_get_attrib(packet, "from")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 if(!(query = xmlnode_get_child(packet, "query")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 if(!(sid = xmlnode_get_attrib(query, "sid")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 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
288 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 jsx = xfer->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 if(!jsx->accepted)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 if(jsx->iq_id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 g_free(jsx->iq_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 jsx->iq_id = g_strdup(xmlnode_get_attrib(packet, "id"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 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
300 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
301 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
302 int portnum = 0;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 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
305 ((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
306 ((host = xmlnode_get_attrib(streamhost, "host")) &&
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 (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
308 (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
309 JabberBytestreamsStreamhost *sh = g_new0(JabberBytestreamsStreamhost, 1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 sh->jid = g_strdup(jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 sh->host = g_strdup(host);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 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
313 sh->zeroconf = g_strdup(zeroconf);
22912
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
314 /* If there were a lot of these, it'd be worthwhile to prepend and reverse. */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 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
316 }
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 jabber_si_bytestreams_attempt_connect(xfer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 jabber_si_xfer_bytestreams_send_read_again_resp_cb(gpointer data, gint source,
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
325 PurpleInputCondition cond)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
327 PurpleXfer *xfer = data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 JabberSIXfer *jsx = xfer->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 int len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 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
332 if (len < 0 && errno == EAGAIN)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 else if (len < 0) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
335 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 xfer->watcher = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 g_free(jsx->rxqueue);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 jsx->rxqueue = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 close(source);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
340 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 jsx->rxlen += len;
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->rxlen < jsx->rxmaxlen)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
348 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 xfer->watcher = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 g_free(jsx->rxqueue);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 jsx->rxqueue = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
353 /* Before actually starting sending the file, we need to wait until the
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
354 * recipient sends the IQ result with <streamhost-used/>
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
355 */
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
356 purple_debug_info("jabber", "SOCKS5 connection negotiation completed. "
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
357 "Waiting for IQ result to start file transfer.\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 jabber_si_xfer_bytestreams_send_read_again_cb(gpointer data, gint source,
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
362 PurpleInputCondition cond)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
364 PurpleXfer *xfer = data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 JabberSIXfer *jsx = xfer->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 int i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 char buffer[256];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 int len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 char *dstaddr, *p;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 unsigned char hashval[20];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 const char *host;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
373 purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_read_again_cb\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 if(jsx->rxlen < 5) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
376 purple_debug_info("jabber", "reading the first 5 bytes\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 len = read(source, buffer, 5 - jsx->rxlen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 if(len < 0 && errno == EAGAIN)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 else if(len <= 0) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
381 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 xfer->watcher = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 close(source);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
384 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 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
388 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 jsx->rxlen += len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 } else if(jsx->rxqueue[0] != 0x05 || jsx->rxqueue[1] != 0x01 ||
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 jsx->rxqueue[3] != 0x03) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
393 purple_debug_info("jabber", "invalid socks5 stuff\n");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
394 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 xfer->watcher = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 close(source);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
397 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 } else if(jsx->rxlen - 5 < jsx->rxqueue[4] + 2) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
400 purple_debug_info("jabber", "reading umpteen more bytes\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 len = read(source, buffer, jsx->rxqueue[4] + 5 + 2 - jsx->rxlen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 if(len < 0 && errno == EAGAIN)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 else if(len <= 0) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
405 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 xfer->watcher = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 close(source);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
408 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 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
412 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 jsx->rxlen += len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 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
417 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
419 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 xfer->watcher = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 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
423 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
424 jsx->js->user->resource, xfer->who);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
426 purple_cipher_digest_region("sha1", (guchar *)dstaddr, strlen(dstaddr),
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
427 sizeof(hashval), hashval, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 g_free(dstaddr);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 dstaddr = g_malloc(41);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 p = dstaddr;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 for(i=0; i<20; i++, p+=2)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 snprintf(p, 3, "%02x", hashval[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 if(jsx->rxqueue[4] != 40 || strncmp(dstaddr, jsx->rxqueue+5, 40) ||
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 jsx->rxqueue[45] != 0x00 || jsx->rxqueue[46] != 0x00) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
436 purple_debug_error("jabber", "someone connected with the wrong info!\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 close(source);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
438 purple_xfer_cancel_remote(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
439 g_free(dstaddr);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442
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
443 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
444
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 g_free(jsx->rxqueue);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
446 host = purple_network_get_my_ip(jsx->js->fd);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 jsx->rxmaxlen = 5 + strlen(host) + 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 jsx->rxqueue = g_malloc(jsx->rxmaxlen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 jsx->rxlen = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 jsx->rxqueue[0] = 0x05;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 jsx->rxqueue[1] = 0x00;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 jsx->rxqueue[2] = 0x00;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 jsx->rxqueue[3] = 0x03;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 jsx->rxqueue[4] = strlen(host);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 memcpy(jsx->rxqueue + 5, host, strlen(host));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 jsx->rxqueue[5+strlen(host)] = 0x00;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 jsx->rxqueue[6+strlen(host)] = 0x00;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
461 xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 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
463 jabber_si_xfer_bytestreams_send_read_again_resp_cb(xfer, source,
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
464 PURPLE_INPUT_WRITE);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 jabber_si_xfer_bytestreams_send_read_response_cb(gpointer data, gint source,
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
469 PurpleInputCondition cond)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
471 PurpleXfer *xfer = data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 JabberSIXfer *jsx = xfer->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 int len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 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
476 if (len < 0 && errno == EAGAIN)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 else if (len < 0) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
479 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 xfer->watcher = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 g_free(jsx->rxqueue);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 jsx->rxqueue = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 close(source);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
484 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 jsx->rxlen += len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 if (jsx->rxlen < jsx->rxmaxlen)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
492 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 xfer->watcher = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 if (jsx->rxqueue[1] == 0x00) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
496 xfer->watcher = purple_input_add(source, PURPLE_INPUT_READ,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 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
498 g_free(jsx->rxqueue);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 jsx->rxqueue = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 close(source);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
502 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 }
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 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 jabber_si_xfer_bytestreams_send_read_cb(gpointer data, gint source,
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
508 PurpleInputCondition cond)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
510 PurpleXfer *xfer = data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 JabberSIXfer *jsx = xfer->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 int i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 int len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 char buffer[256];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
516 purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_read_cb\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 xfer->fd = source;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 if(jsx->rxlen < 2) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
521 purple_debug_info("jabber", "reading those first two bytes\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 len = read(source, buffer, 2 - jsx->rxlen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 if(len < 0 && errno == EAGAIN)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 else if(len <= 0) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
526 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 xfer->watcher = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 close(source);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
529 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 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
533 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534 jsx->rxlen += len;
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(jsx->rxlen - 2 < jsx->rxqueue[1]) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
537 purple_debug_info("jabber", "reading the next umpteen bytes\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 len = read(source, buffer, jsx->rxqueue[1] + 2 - jsx->rxlen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 if(len < 0 && errno == EAGAIN)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541 else if(len <= 0) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
542 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 xfer->watcher = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 close(source);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
545 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 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
549 memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 jsx->rxlen += len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 if(jsx->rxlen -2 < jsx->rxqueue[1])
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
556 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 xfer->watcher = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
559 purple_debug_info("jabber", "checking to make sure we're socks FIVE\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 if(jsx->rxqueue[0] != 0x05) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 close(source);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
563 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 return;
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
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
567 purple_debug_info("jabber", "going to test %hhu different methods\n", jsx->rxqueue[1]);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569 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
570
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
571 purple_debug_info("jabber", "testing %hhu\n", jsx->rxqueue[i+2]);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 if(jsx->rxqueue[i+2] == 0x00) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 g_free(jsx->rxqueue);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 jsx->rxlen = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 jsx->rxmaxlen = 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 jsx->rxqueue = g_malloc(jsx->rxmaxlen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 jsx->rxqueue[0] = 0x05;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 jsx->rxqueue[1] = 0x00;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
579 xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 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
581 xfer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 jabber_si_xfer_bytestreams_send_read_response_cb(xfer,
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
583 source, PURPLE_INPUT_WRITE);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 jsx->rxqueue = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 jsx->rxlen = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 g_free(jsx->rxqueue);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 jsx->rxlen = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 jsx->rxmaxlen = 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 jsx->rxqueue = g_malloc(jsx->rxmaxlen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 jsx->rxqueue[0] = 0x05;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 jsx->rxqueue[1] = 0xFF;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
596 xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597 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
598 jabber_si_xfer_bytestreams_send_read_response_cb(xfer,
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
599 source, PURPLE_INPUT_WRITE);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601
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
602 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
603 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
604 {
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
605 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
606
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
607 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
608 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
609
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
610 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
611 }
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
612
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 jabber_si_xfer_bytestreams_send_connected_cb(gpointer data, gint source,
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
615 PurpleInputCondition cond)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
617 PurpleXfer *xfer = data;
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
618 JabberSIXfer *jsx = xfer->data;
23769
e21c79681c96 Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23645
diff changeset
619 int acceptfd, flags;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
621 purple_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_connected_cb\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 acceptfd = accept(source, NULL, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 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: 19680
diff changeset
627 purple_debug_warning("jabber", "accept: %s\n", g_strerror(errno));
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
628 /* Don't cancel the ft - allow it to fall to the next streamhost.*/
15374
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
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
632 purple_input_remove(xfer->watcher);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 close(source);
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
634 jsx->local_streamhost_fd = -1;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635
23769
e21c79681c96 Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23645
diff changeset
636 flags = fcntl(acceptfd, F_GETFL);
e21c79681c96 Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23645
diff changeset
637 fcntl(acceptfd, F_SETFL, flags | O_NONBLOCK);
e21c79681c96 Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23645
diff changeset
638 #ifndef _WIN32
e21c79681c96 Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23645
diff changeset
639 fcntl(acceptfd, F_SETFD, FD_CLOEXEC);
e21c79681c96 Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23645
diff changeset
640 #endif
e21c79681c96 Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23645
diff changeset
641
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
642 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
643 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
644 }
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
645
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
646 static void
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
647 jabber_si_connect_proxy_cb(JabberStream *js, xmlnode *packet,
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
648 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
649 {
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
650 PurpleXfer *xfer = data;
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
651 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
652 xmlnode *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
653 const char *from, *type, *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
654 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
655
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
656 /* 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
657
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
658 /* 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: 22912
diff changeset
659 if (!g_list_find(js->file_transfers, xfer)) {
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
660 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: 22912
diff changeset
661 return;
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
662 }
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
663
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
664 /* In the case of a direct file transfer, this is expected to return */
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
665 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
666 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
667
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
668 jsx = xfer->data;
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
669
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
670 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) {
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
671 if (type && !strcmp(type, "error"))
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
672 purple_xfer_cancel_remote(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
673 return;
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
674 }
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
675
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 if(!(from = xmlnode_get_attrib(packet, "from")))
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 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
678
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
679 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
680 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
681
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
682 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
683 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
684
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
685 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
686 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
687
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
688 purple_debug_info("jabber", "jabber_si_connect_proxy_cb() will be looking at jsx %p: jsx->streamhosts is %p and jid is %s\n",
22656
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
689 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
690
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
691 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
692 {
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
693 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
694 jsx->js->user->domain, jsx->js->user->resource);
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
695 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
696 purple_debug_info("jabber", "Got local SOCKS5 streamhost-used.\n");
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
697 purple_xfer_start(xfer, xfer->fd, NULL, -1);
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
698 } else {
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
699 purple_debug_info("jabber", "streamhost-used does not match any proxy that was offered to target\n");
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
700 purple_xfer_cancel_local(xfer);
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
701 }
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
702 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
703 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
704 }
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
705
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
706 /* Clean up the local streamhost - it isn't going to be used.*/
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
707 if (xfer->watcher > 0) {
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
708 purple_input_remove(xfer->watcher);
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
709 xfer->watcher = 0;
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
710 }
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
711 if (jsx->local_streamhost_fd >= 0) {
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
712 close(jsx->local_streamhost_fd);
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
713 jsx->local_streamhost_fd = -1;
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
714 }
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 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
717 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
718 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
719
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 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
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 jabber_si_bytestreams_attempt_connect(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
724
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 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
727 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
728 PurpleXfer *xfer = data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729 JabberSIXfer *jsx;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
730 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731 xmlnode *query, *streamhost;
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
732 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
733 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
734 JabberBytestreamsStreamhost *sh, *sh2;
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
735 int streamhost_count = 0;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 jsx = xfer->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738 jsx->listen_data = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
740 /* 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: 23365
diff changeset
741 * (it seems like it shouldn't be possible */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
742 if (purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_CANCEL_LOCAL) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
743 purple_xfer_unref(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
745 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
747 purple_xfer_unref(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749 iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750 "http://jabber.org/protocol/bytestreams");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751 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
752 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
753
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
754 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
755
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
756 /* If we successfully started listening locally */
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
757 if (sock >= 0) {
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
758 gchar *jid;
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
759 const char *local_ip, *public_ip;
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
760
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
761 jsx->local_streamhost_fd = sock;
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
762
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
763 jid = g_strdup_printf("%s@%s/%s", jsx->js->user->node,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
764 jsx->js->user->domain, jsx->js->user->resource);
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
765 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: 23365
diff changeset
766 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
767
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
768 /* Include the localhost's IP (for in-network transfers) */
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
769 local_ip = purple_network_get_local_system_ip(jsx->js->fd);
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
770 if (strcmp(local_ip, "0.0.0.0") != 0) {
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
771 streamhost_count++;
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
772 streamhost = xmlnode_new_child(query, "streamhost");
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
773 xmlnode_set_attrib(streamhost, "jid", jid);
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
774 xmlnode_set_attrib(streamhost, "host", local_ip);
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
775 xmlnode_set_attrib(streamhost, "port", port);
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
776 }
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
777
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
778 /* Include the public IP (assuming that there is a port mapped somehow) */
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
779 public_ip = purple_network_get_my_ip(jsx->js->fd);
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
780 if (strcmp(public_ip, local_ip) != 0 && strcmp(public_ip, "0.0.0.0") != 0) {
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
781 streamhost_count++;
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
782 streamhost = xmlnode_new_child(query, "streamhost");
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
783 xmlnode_set_attrib(streamhost, "jid", jid);
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
784 xmlnode_set_attrib(streamhost, "host", public_ip);
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
785 xmlnode_set_attrib(streamhost, "port", port);
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
786 }
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
787
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
788 g_free(jid);
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
789
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
790 /* The listener for the local proxy */
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
791 xfer->watcher = purple_input_add(sock, PURPLE_INPUT_READ,
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
792 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
793 }
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
794
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
795 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
796 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
797
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
798 /* 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
799
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
800 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
801 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
802
24423
88955b918197 Add missing newline in debug message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23769
diff changeset
803 purple_debug_info("jabber", "jabber_si_xfer_bytestreams_listen_cb() will be looking at jsx %p: jsx->streamhosts %p and sh->jid %p\n",
22656
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
804 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
805 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
806 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
807
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
808 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
809 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
810 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
811 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
812 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
813 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
814
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
815 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
816 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
817 sh2->host = g_strdup(sh->host);
22912
9004da91edd3 Reuse cleanup function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22656
diff changeset
818 /*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
819 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
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 = 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
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
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
824 /* We have no way of transferring, cancel the transfer */
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
825 if (streamhost_count == 0) {
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
826 jabber_iq_free(iq);
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
827 /* We should probably notify the target, but this really shouldn't ever happen */
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
828 purple_xfer_cancel_local(xfer);
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
829 return;
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
830 }
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
831
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
832 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
833
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
834 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836 }
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 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
839 jabber_si_xfer_bytestreams_send_init(PurpleXfer *xfer)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
841 JabberSIXfer *jsx;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
842
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
843 purple_xfer_ref(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
844
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845 jsx = xfer->data;
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
846
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
847 /* TODO: Should there be an option to not use the local host as a ft proxy?
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
848 * (to prevent revealing IP address, etc.) */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
849 jsx->listen_data = purple_network_listen_range(0, 0, SOCK_STREAM,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
850 jabber_si_xfer_bytestreams_listen_cb, xfer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 if (jsx->listen_data == NULL) {
23366
05802d915c13 Improve error handling for xmpp file transfers.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23365
diff changeset
852 /* 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: 23365
diff changeset
853 jabber_si_xfer_bytestreams_listen_cb(-1, xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858 static void jabber_si_xfer_send_method_cb(JabberStream *js, xmlnode *packet,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
859 gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
861 PurpleXfer *xfer = data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 xmlnode *si, *feature, *x, *field, *value;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 if(!(si = xmlnode_get_child_with_namespace(packet, "si", "http://jabber.org/protocol/si"))) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
865 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
869 if(!(feature = xmlnode_get_child_with_namespace(si, "feature", "http://jabber.org/protocol/feature-neg"))) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
870 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
872 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
873
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
874 if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data"))) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
875 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
876 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
879 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
880 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
881
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
882 if(var && !strcmp(var, "stream-method")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
883 if((value = xmlnode_get_child(field, "value"))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884 char *val = xmlnode_get_data(value);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
885 if(val && !strcmp(val, "http://jabber.org/protocol/bytestreams")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
886 jabber_si_xfer_bytestreams_send_init(xfer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 g_free(val);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
888 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890 g_free(val);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893 }
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
894 purple_xfer_cancel_remote(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
897 static void jabber_si_xfer_send_request(PurpleXfer *xfer)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899 JabberSIXfer *jsx = xfer->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901 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
902 char buf[32];
27773
0f3a131d23da - import nosuke's hash 244 patch and others to yahoo plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27760
diff changeset
903 gchar *f1 = NULL, *f2 = NULL;
0f3a131d23da - import nosuke's hash 244 patch and others to yahoo plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27760
diff changeset
904 gsize dummy;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905
27773
0f3a131d23da - import nosuke's hash 244 patch and others to yahoo plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27760
diff changeset
906 /* yaz */
0f3a131d23da - import nosuke's hash 244 patch and others to yahoo plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27760
diff changeset
907 f1 = g_filename_display_basename(xfer->local_filename);
0f3a131d23da - import nosuke's hash 244 patch and others to yahoo plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27760
diff changeset
908 f2 = botch_utf(f1, strlen(f1), &dummy);
0f3a131d23da - import nosuke's hash 244 patch and others to yahoo plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27760
diff changeset
909 if(f2){
0f3a131d23da - import nosuke's hash 244 patch and others to yahoo plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27760
diff changeset
910 purple_xfer_set_filename(xfer, (char *)f2);
0f3a131d23da - import nosuke's hash 244 patch and others to yahoo plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27760
diff changeset
911 }
0f3a131d23da - import nosuke's hash 244 patch and others to yahoo plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27760
diff changeset
912 g_free(f1); f1 = NULL;
0f3a131d23da - import nosuke's hash 244 patch and others to yahoo plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27760
diff changeset
913 g_free(f2); f2 = NULL;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915 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
916 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
917 si = xmlnode_new_child(iq->node, "si");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918 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
919 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
920 xmlnode_set_attrib(si, "id", jsx->stream_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
921 xmlnode_set_attrib(si, "profile",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922 "http://jabber.org/protocol/si/profile/file-transfer");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
923
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 file = xmlnode_new_child(si, "file");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925 xmlnode_set_namespace(file,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926 "http://jabber.org/protocol/si/profile/file-transfer");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927 xmlnode_set_attrib(file, "name", xfer->filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 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
929 xmlnode_set_attrib(file, "size", buf);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 /* 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
931
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 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
933 xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
934 x = xmlnode_new_child(feature, "x");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935 xmlnode_set_namespace(x, "jabber:x:data");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 xmlnode_set_attrib(x, "type", "form");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937 field = xmlnode_new_child(x, "field");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938 xmlnode_set_attrib(field, "var", "stream-method");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 xmlnode_set_attrib(field, "type", "list-single");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940 option = xmlnode_new_child(field, "option");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941 value = xmlnode_new_child(option, "value");
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
942 xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944 option = xmlnode_new_child(field, "option");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 value = xmlnode_new_child(option, "value");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 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
950
19675
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
951 /* 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
952 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
953 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
954
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
958 static void jabber_si_xfer_free(PurpleXfer *xfer)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960 JabberSIXfer *jsx = xfer->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
961 JabberStream *js = jsx->js;
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 js->file_transfers = g_list_remove(js->file_transfers, xfer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
965 if (jsx->connect_data != NULL)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
966 purple_proxy_connect_cancel(jsx->connect_data);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
967 if (jsx->listen_data != NULL)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
968 purple_network_listen_cancel(jsx->listen_data);
19675
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
969 if (jsx->iq_id != NULL)
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
970 jabber_iq_remove_callback_by_id(js, jsx->iq_id);
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
971 if (jsx->local_streamhost_fd >= 0)
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
972 close(jsx->local_streamhost_fd);
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
973 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
974 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
975
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
976 if (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
977 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
978 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
979 }
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
980
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981 g_free(jsx->stream_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 g_free(jsx->iq_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983 /* XXX: free other stuff */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 g_free(jsx->rxqueue);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 g_free(jsx);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 xfer->data = NULL;
23769
e21c79681c96 Use non-blocking io for direct xmpp file transfers
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23645
diff changeset
987
22656
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
988 purple_debug_info("jabber", "jabber_si_xfer_free(): freeing jsx %p", jsx);
15374
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
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
991 static void jabber_si_xfer_cancel_send(PurpleXfer *xfer)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 jabber_si_xfer_free(xfer);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
994 purple_debug(PURPLE_DEBUG_INFO, "jabber", "in jabber_si_xfer_cancel_send\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
998 static void jabber_si_xfer_request_denied(PurpleXfer *xfer)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 jabber_si_xfer_free(xfer);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1001 purple_debug(PURPLE_DEBUG_INFO, "jabber", "in jabber_si_xfer_request_denied\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1005 static void jabber_si_xfer_cancel_recv(PurpleXfer *xfer)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007 jabber_si_xfer_free(xfer);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1008 purple_debug(PURPLE_DEBUG_INFO, "jabber", "in jabber_si_xfer_cancel_recv\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1012 static void jabber_si_xfer_end(PurpleXfer *xfer)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 jabber_si_xfer_free(xfer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1017
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 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
1019 JabberCapabilities capabilities, gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1021 PurpleXfer *xfer = data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 if(capabilities & JABBER_CAP_SI_FILE_XFER) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 jabber_si_xfer_send_request(xfer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 char *msg = g_strdup_printf(_("Unable to send file to %s, user does not support file transfers"), who);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1027 purple_notify_error(js->gc, _("File Send Failed"),
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 _("File Send Failed"), msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032
17441
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1033 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: 15823
diff changeset
1034 {
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1035 purple_xfer_cancel_local(xfer);
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1036 }
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1037
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1038 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: 15823
diff changeset
1039 {
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1040 JabberSIXfer *jsx = xfer->data;
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1041 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: 15823
diff changeset
1042 char *who;
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1043
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1044 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: 15823
diff changeset
1045 g_strfreev(who_v);
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1046 g_free(xfer->who);
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1047 xfer->who = who;
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1048 jabber_disco_info_do(jsx->js, who,
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1049 jabber_si_xfer_send_disco_cb, xfer);
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1050 }
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1051
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1052 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: 15823
diff changeset
1053 {
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1054 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: 15823
diff changeset
1055 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: 15823
diff changeset
1056 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: 15823
diff changeset
1057
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1058 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: 15823
diff changeset
1059
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1060 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: 15823
diff changeset
1061 }
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1062
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1063 static void jabber_si_xfer_init(PurpleXfer *xfer)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1064 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065 JabberSIXfer *jsx = xfer->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 JabberIq *iq;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1067 if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068 JabberBuddy *jb;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1069 JabberBuddyResource *jbr = NULL;
17441
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1070 char *resource;
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1071
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1072 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: 15823
diff changeset
1073 /* 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: 15823
diff changeset
1074 * 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: 15823
diff changeset
1075
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1076 do_transfer_send(xfer, resource);
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1077 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
1078 return;
17441
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1079 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1080
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1081 jb = jabber_buddy_find(jsx->js, xfer->who, TRUE);
17441
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1082
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1083 if(!jb || !jb->resources) {
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1084 /* 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: 15823
diff changeset
1085 * 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: 15823
diff changeset
1086 * 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: 15823
diff changeset
1087 char *msg;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1088
17441
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1089 if(!jb) {
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1090 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: 15823
diff changeset
1091 } 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: 15823
diff changeset
1092 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: 15823
diff changeset
1093 } else {
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1094 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: 15823
diff changeset
1095 }
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1096
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1097 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: 15823
diff changeset
1098 g_free(msg);
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1099 } else if(g_list_length(jb->resources) == 1) {
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1100 /* 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: 15823
diff changeset
1101 * so no need to ask who to send to */
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1102 jbr = jb->resources->data;
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1103
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1104 do_transfer_send(xfer, jbr->name);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1106 } else {
17441
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1107 /* 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: 15823
diff changeset
1108 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
1109 char *msg = g_strdup_printf(_("Please select the resource of %s to which you would like to send a file"), xfer->who);
17441
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1110 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: 15823
diff changeset
1111 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: 15823
diff changeset
1112 PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL);
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1113
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1114 for(l = jb->resources; l; l = l->next)
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1115 {
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1116 jbr = l->data;
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1117
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1118 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: 15823
diff changeset
1119 }
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1120
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1121 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: 15823
diff changeset
1122
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1123 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: 15823
diff changeset
1124
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
1125 purple_request_fields(jsx->js->gc, _("Select a Resource"), msg, NULL, fields,
17441
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1126 _("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
1127 jsx->js->gc->account, xfer->who, NULL, xfer);
17441
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1128
cc1b4d2e5a9b if there are multiple resources available, ask the user which resource to
Nathan Walp <nwalp@pidgin.im>
parents: 15823
diff changeset
1129 g_free(msg);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1130 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1131 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1132 xmlnode *si, *feature, *x, *field, *value;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1133
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1134 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
1135 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
1136 if(jsx->iq_id)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1137 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
1138
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1139 jsx->accepted = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1140
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1141 si = xmlnode_new_child(iq->node, "si");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1142 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
1143
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1144 feature = xmlnode_new_child(si, "feature");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1145 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
1146
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1147 x = xmlnode_new_child(feature, "x");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1148 xmlnode_set_namespace(x, "jabber:x:data");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1149 xmlnode_set_attrib(x, "type", "submit");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1150
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1151 field = xmlnode_new_child(x, "field");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1152 xmlnode_set_attrib(field, "var", "stream-method");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1153
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1154 value = xmlnode_new_child(field, "value");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1155 if(jsx->stream_method & STREAM_METHOD_BYTESTREAMS)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156 xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1157 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1158 else if(jsx->stream_method & STREAM_METHOD_IBB)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1159 xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1160 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1161
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1162 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1163 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1164 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1165
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1166 PurpleXfer *jabber_si_new_xfer(PurpleConnection *gc, const char *who)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1167 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1168 JabberStream *js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1169
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1170 PurpleXfer *xfer;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1171 JabberSIXfer *jsx;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1172
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1173 js = gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1174
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1175 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1176 if (xfer)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1177 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1178 xfer->data = jsx = g_new0(JabberSIXfer, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1179 jsx->js = js;
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
1180 jsx->local_streamhost_fd = -1;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1181
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1182 purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1183 purple_xfer_set_cancel_send_fnc(xfer, jabber_si_xfer_cancel_send);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1184 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1185
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1186 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
1187 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1188
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1189 return xfer;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1190 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1191
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1192 void jabber_si_xfer_send(PurpleConnection *gc, const char *who, const char *file)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1193 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1194 JabberStream *js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1195
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1196 PurpleXfer *xfer;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1197
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1198 js = gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1199
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1200 xfer = jabber_si_new_xfer(gc, who);
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 (file)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1203 purple_xfer_request_accepted(xfer, file);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1204 else
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1205 purple_xfer_request(xfer);
15374
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1208 void jabber_si_parse(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1209 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1210 JabberSIXfer *jsx;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1211 PurpleXfer *xfer;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1212 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
1213 const char *stream_id, *filename, *filesize_c, *profile, *from;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1214 size_t filesize = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1215
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1216 if(!(si = xmlnode_get_child(packet, "si")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1217 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1218
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1219 if(!(profile = xmlnode_get_attrib(si, "profile")) ||
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1220 strcmp(profile, "http://jabber.org/protocol/si/profile/file-transfer"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1221 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1222
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1223 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
1224 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1225
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1226 if(!(file = xmlnode_get_child(si, "file")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1227 return;
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 if(!(filename = xmlnode_get_attrib(file, "name")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1230 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1231
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1232 if((filesize_c = xmlnode_get_attrib(file, "size")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1233 filesize = atoi(filesize_c);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1234
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1235 if(!(feature = xmlnode_get_child(si, "feature")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1236 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1237
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1238 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
1239 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1240
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1241 if(!(from = xmlnode_get_attrib(packet, "from")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1242 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1243
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1244 /* 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
1245 * 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
1246 * with it */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1247 if((xfer = jabber_si_xfer_find(js, stream_id, from)))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1248 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1249
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1250 jsx = g_new0(JabberSIXfer, 1);
23029
3c33405fd630 applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22912
diff changeset
1251 jsx->local_streamhost_fd = -1;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1252
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1253 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
1254 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
1255 if(var && !strcmp(var, "stream-method")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1256 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
1257 option = xmlnode_get_next_twin(option)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1258 if((value = xmlnode_get_child(option, "value"))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1259 char *val;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1260 if((val = xmlnode_get_data(value))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1261 if(!strcmp(val, "http://jabber.org/protocol/bytestreams")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1262 jsx->stream_method |= STREAM_METHOD_BYTESTREAMS;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1263 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1264 } else if(!strcmp(val, "http://jabber.org/protocol/ibb")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1265 jsx->stream_method |= STREAM_METHOD_IBB;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1266 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1267 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1268 g_free(val);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1269 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1270 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1271 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1272 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1273 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1274
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1275 if(jsx->stream_method == STREAM_METHOD_UNKNOWN) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1276 g_free(jsx);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1277 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1278 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1279
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1280 jsx->js = js;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1281 jsx->stream_id = g_strdup(stream_id);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1282 jsx->iq_id = g_strdup(xmlnode_get_attrib(packet, "id"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1283
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1284 xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE, from);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1285 if (xfer)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1286 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1287 xfer->data = jsx;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1288
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1289 purple_xfer_set_filename(xfer, filename);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1290 if(filesize > 0)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1291 purple_xfer_set_size(xfer, filesize);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1292
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1293 purple_xfer_set_init_fnc(xfer, jabber_si_xfer_init);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1294 purple_xfer_set_request_denied_fnc(xfer, jabber_si_xfer_request_denied);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1295 purple_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1296 purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1297
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1298 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
1299
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15786
diff changeset
1300 purple_xfer_request(xfer);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1301 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1302 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1303
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1304