annotate libpurple/protocols/bonjour/bonjour_ft.c @ 21522:dc703f13449a

Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 15 Nov 2007 14:53:53 +0000
parents 3d70e3ec8a47
children 5b9da9db7e81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
1 /*
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
2 * purple - Bonjour Protocol Plugin
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
3 *
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
6 * source distribution.
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
7 *
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
12 *
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
17 *
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
21 */
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
22 #include "internal.h"
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
23 #include "util.h"
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
24 #include "debug.h"
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
25 #include "notify.h"
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
26 #include "proxy.h"
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
27 #include "ft.h"
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
28 #include "buddy.h"
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
29 #include "bonjour.h"
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
30 #include "bonjour_ft.h"
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
31 #include "cipher.h"
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
32
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
33 static void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
34 bonjour_bytestreams_init(PurpleXfer *xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
35 static void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
36 bonjour_bytestreams_connect(PurpleXfer *xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
37 static void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
38 bonjour_xfer_init(PurpleXfer *xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
39 static void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
40 bonjour_xfer_receive(PurpleConnection *pc, const char *id, const char *from,
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
41 const int filesize, const char *filename, int option);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
42 static void bonjour_free_xfer(PurpleXfer *xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
43
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
44 /* Look for specific xfer handle */
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
45 static unsigned int next_id = 0;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
46
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
47 static void
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
48 xep_ft_si_reject(BonjourData *bd, const char *id, const char *to, const char *error_code, const char *error_type)
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
49 {
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
50 xmlnode *error_node = NULL;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
51 xmlnode *tmp_node = NULL;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
52 XepIq *iq = NULL;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
53
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
54 g_return_if_fail(error_code != NULL);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
55 g_return_if_fail(error_type != NULL);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
56
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
57 if(!to || !id)
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
58 return;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
59
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
60 purple_debug_info("bonjour", "xep file transfer stream initialization error.\n");
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
61 iq = xep_iq_new(bd, XEP_IQ_ERROR, to, purple_account_get_username(bd->jabber_data->account), id);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
62 if(iq == NULL)
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
63 return;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
64
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
65 error_node = xmlnode_new_child(iq->node, "error");
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
66 xmlnode_set_attrib(error_node, "code", error_code);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
67 xmlnode_set_attrib(error_node, "type", error_type);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
68
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
69 /* TODO: Make this better */
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
70 if (!strcmp(error_code, "403")) {
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
71 tmp_node = xmlnode_new_child(error_node, "forbidden");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
72 xmlnode_set_namespace(tmp_node, "urn:ietf:params:xml:ns:xmpp-stanzas");
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
73
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
74 tmp_node = xmlnode_new_child(error_node, "text");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
75 xmlnode_set_namespace(tmp_node, "urn:ietf:params:xml:ns:xmpp-stanzas");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
76 xmlnode_insert_data(tmp_node, "Offer Declined", -1);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
77 } else if (!strcmp(error_code, "404")) {
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
78 tmp_node = xmlnode_new_child(error_node, "item-not-found");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
79 xmlnode_set_namespace(tmp_node, "urn:ietf:params:xml:ns:xmpp-stanzas");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
80 }
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
81
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
82 xep_iq_send_and_free(iq);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
83 }
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
84
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
85 static void bonjour_xfer_cancel_send(PurpleXfer *xfer)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
86 {
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
87 purple_debug_info("bonjour", "Bonjour-xfer-cancel-send.\n");
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
88 bonjour_free_xfer(xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
89 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
90
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
91 static void bonjour_xfer_request_denied(PurpleXfer *xfer)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
92 {
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
93 XepXfer *xf = NULL;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
94
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
95 purple_debug_info("bonjour", "Bonjour-xfer-request-denied.\n");
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
96
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
97 xf = xfer->data;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
98 if(xf)
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
99 xep_ft_si_reject(xf->data, xf->sid, xfer->who, "403", "cancel");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
100
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
101 bonjour_free_xfer(xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
102 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
103
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
104 static void bonjour_xfer_cancel_recv(PurpleXfer *xfer)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
105 {
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
106 purple_debug_info("bonjour", "Bonjour-xfer-cancel-recv.\n");
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
107 bonjour_free_xfer(xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
108 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
109
21467
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
110 struct socket_cleanup {
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
111 int fd;
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
112 guint handle;
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
113 };
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
114
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
115 static void
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
116 _wait_for_socket_close(gpointer data, gint source, PurpleInputCondition cond)
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
117 {
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
118 struct socket_cleanup *sc = data;
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
119 char buf[1];
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
120 int ret;
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
121
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
122 ret = recv(source, buf, 1, 0);
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
123
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
124 if (ret == 0 || (ret == -1 && !(errno == EAGAIN || errno == EWOULDBLOCK))) {
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
125 purple_debug_info("bonjour", "Client completed recieving; closing server socket.\n");
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
126 purple_input_remove(sc->handle);
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
127 close(sc->fd);
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
128 g_free(sc);
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
129 }
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
130 }
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
131
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
132 static void bonjour_xfer_end(PurpleXfer *xfer)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
133 {
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
134 purple_debug_info("bonjour", "Bonjour-xfer-end.\n");
21467
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
135
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
136 /* We can't allow the server side to close the connection until the client is complete,
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
137 * otherwise there is a RST resulting in an error on the client side */
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
138 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND && purple_xfer_is_completed(xfer)) {
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
139 struct socket_cleanup *sc = g_new0(struct socket_cleanup, 1);
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
140 sc->fd = xfer->fd;
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
141 xfer->fd = -1;
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
142 sc->handle = purple_input_add(sc->fd, PURPLE_INPUT_READ,
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
143 _wait_for_socket_close, sc);
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
144 }
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
145
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
146 bonjour_free_xfer(xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
147 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
148
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
149 static PurpleXfer*
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
150 bonjour_si_xfer_find(BonjourData *bd, const char *sid, const char *from)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
151 {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
152 GList *xfers = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
153 PurpleXfer *xfer = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
154 XepXfer *xf = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
155
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
156 if(!sid || !from || !bd)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
157 return NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
158
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
159 purple_debug_info("bonjour", "Look for sid=%s from=%s xferlists.\n",
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
160 sid, from);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
161
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
162 for(xfers = bd->xfer_lists; xfers; xfers = xfers->next) {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
163 xfer = xfers->data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
164 if(xfer == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
165 break;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
166 xf = xfer->data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
167 if(xf == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
168 break;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
169 if(xf->sid && xfer->who && !strcmp(xf->sid, sid) &&
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
170 !strcmp(xfer->who, from))
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
171 return xfer;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
172 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
173
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
174 purple_debug_info("bonjour", "Look for xfer list fail\n");
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
175
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
176 return NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
177 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
178
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
179 static void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
180 xep_ft_si_offer(PurpleXfer *xfer, const gchar *to)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
181 {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
182 xmlnode *si_node = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
183 xmlnode *feature = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
184 xmlnode *field = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
185 xmlnode *option = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
186 xmlnode *value = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
187 xmlnode *file = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
188 xmlnode *x = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
189 XepIq *iq = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
190 XepXfer *xf = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
191 BonjourData *bd = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
192 char buf[32];
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
193
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
194 xf = xfer->data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
195 if(!xf)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
196 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
197
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
198 bd = xf->data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
199 if(!bd)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
200 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
201
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
202 purple_debug_info("bonjour", "xep file transfer stream initialization offer-id=%d.\n", next_id);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
203
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
204 /* Assign stream id. */
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
205 memset(buf, 0, 32);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
206 g_snprintf(buf, sizeof(buf), "%u", next_id++);
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
207 iq = xep_iq_new(xf->data, XEP_IQ_SET, to, purple_account_get_username(bd->jabber_data->account), buf);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
208 if(iq == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
209 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
210
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
211 g_free(xf->sid);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
212 xf->sid = g_strdup(buf);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
213 /*Construct Stream initialization offer message.*/
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
214 si_node = xmlnode_new_child(iq->node, "si");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
215 xmlnode_set_namespace(si_node, "http://jabber.org/protocol/si");
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
216 xmlnode_set_attrib(si_node, "profile", "http://jabber.org/protocol/si/profile/file-transfer");
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
217
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
218 file = xmlnode_new_child(si_node, "file");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
219 xmlnode_set_namespace(file, "http://jabber.org/protocol/si/profile/file-transfer");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
220 xmlnode_set_attrib(file, "name", xfer->filename);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
221 memset(buf, 0, 32);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
222 g_snprintf(buf, sizeof(buf), "%" G_GSIZE_FORMAT, xfer->size);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
223 xmlnode_set_attrib(file, "size", buf);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
224
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
225 feature = xmlnode_new_child(si_node, "feature");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
226 xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
227
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
228 x = xmlnode_new_child(feature, "x");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
229 xmlnode_set_namespace(x, "jabber:x:data");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
230 xmlnode_set_attrib(x, "type", "form");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
231
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
232 field = xmlnode_new_child(x, "field");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
233 xmlnode_set_attrib(field, "var", "stream-method");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
234 xmlnode_set_attrib(field, "type", "list-single");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
235
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
236 if (xf->mode & XEP_BYTESTREAMS) {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
237 option = xmlnode_new_child(field, "option");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
238 value = xmlnode_new_child(option, "value");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
239 xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
240 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
241 if (xf->mode & XEP_IBB) {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
242 option = xmlnode_new_child(field, "option");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
243 value = xmlnode_new_child(option, "value");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
244 xmlnode_insert_data(value, "http://jabber.org/protocol/ibb", -1);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
245 }
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
246
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
247 xep_iq_send_and_free(iq);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
248 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
249
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
250 static void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
251 xep_ft_si_result(PurpleXfer *xfer, char *to)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
252 {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
253 xmlnode *si_node = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
254 xmlnode *feature = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
255 xmlnode *field = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
256 xmlnode *value = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
257 xmlnode *x = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
258 XepIq *iq = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
259 XepXfer *xf = NULL;
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
260 BonjourData *bd;
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
261
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
262 if(!to || !xfer)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
263 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
264 xf = xfer->data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
265 if(!xf)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
266 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
267
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
268 bd = xf->data;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
269
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
270 purple_debug_info("bonjour", "xep file transfer stream initialization result.\n");
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
271 iq = xep_iq_new(bd, XEP_IQ_RESULT, to, purple_account_get_username(bd->jabber_data->account), xf->sid);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
272 if(iq == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
273 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
274
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
275 si_node = xmlnode_new_child(iq->node, "si");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
276 xmlnode_set_namespace(si_node, "http://jabber.org/protocol/si");
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
277 /*xmlnode_set_attrib(si_node, "profile", "http://jabber.org/protocol/si/profile/file-transfer");*/
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
278
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
279 feature = xmlnode_new_child(si_node, "feature");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
280 xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
281
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
282 x = xmlnode_new_child(feature, "x");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
283 xmlnode_set_namespace(x, "jabber:x:data");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
284 xmlnode_set_attrib(x, "type", "submit");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
285
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
286 field = xmlnode_new_child(x, "field");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
287 xmlnode_set_attrib(field, "var", "stream-method");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
288
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
289 value = xmlnode_new_child(field, "value");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
290 xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
291
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
292 xep_iq_send_and_free(iq);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
293 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
294
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
295 static void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
296 bonjour_free_xfer(PurpleXfer *xfer)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
297 {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
298 XepXfer *xf = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
299 BonjourData *bd = NULL;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
300
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
301 if(xfer == NULL) {
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
302 purple_debug_info("bonjour", "bonjour-free-xfer-null.\n");
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
303 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
304 }
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
305
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
306 purple_debug_info("bonjour", "bonjour-free-xfer-%p.\n", xfer);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
307
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
308 xf = (XepXfer*)xfer->data;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
309 if(xf != NULL) {
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
310 bd = (BonjourData*)xf->data;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
311 if(bd != NULL) {
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
312 bd->xfer_lists = g_list_remove(bd->xfer_lists, xfer);
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
313 purple_debug_info("bonjour", "B free xfer from lists(%p).\n", bd->xfer_lists);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
314 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
315 if (xf->proxy_connection != NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
316 purple_proxy_connect_cancel(xf->proxy_connection);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
317 if (xf->listen_data != NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
318 purple_network_listen_cancel(xf->listen_data);
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
319 g_free(xf->iq_id);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
320 g_free(xf->jid);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
321 g_free(xf->proxy_host);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
322 g_free(xf->buddy_ip);
21441
da75dd6c41fb Leak fix, cleanup and code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21440
diff changeset
323 g_free(xf->sid);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
324 g_free(xf);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
325 xfer->data = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
326 }
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
327
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
328 purple_debug_info("bonjour", "Need close socket=%d.\n", xfer->fd);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
329 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
330
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
331 PurpleXfer *
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
332 bonjour_new_xfer(PurpleConnection *gc, const char *who)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
333 {
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
334 PurpleXfer *xfer;
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
335 XepXfer *xep_xfer = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
336 BonjourData *bd = NULL;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
337
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
338 if(who == NULL || gc == NULL)
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
339 return NULL;
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
340
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
341 purple_debug_info("bonjour", "Bonjour-new-xfer to %s.\n", who);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
342 bd = (BonjourData*) gc->proto_data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
343 if(bd == NULL)
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
344 return NULL;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
345
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
346 /* Build the file transfer handle */
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
347 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
348 xfer->data = xep_xfer = g_new0(XepXfer, 1);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
349 xep_xfer->data = bd;
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
350
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
351 purple_debug_info("bonjour", "Bonjour-new-xfer bd=%p data=%p.\n", bd, xep_xfer->data);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
352
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
353 /* We don't support IBB yet */
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
354 /*xep_xfer->mode = XEP_BYTESTREAMS | XEP_IBB;*/
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
355 xep_xfer->mode = XEP_BYTESTREAMS;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
356 xep_xfer->sid = NULL;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
357
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
358 purple_xfer_set_init_fnc(xfer, bonjour_xfer_init);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
359 purple_xfer_set_cancel_send_fnc(xfer, bonjour_xfer_cancel_send);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
360 purple_xfer_set_end_fnc(xfer, bonjour_xfer_end);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
361
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
362 bd->xfer_lists = g_list_append(bd->xfer_lists, xfer);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
363
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
364 return xfer;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
365 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
366
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
367 void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
368 bonjour_send_file(PurpleConnection *gc, const char *who, const char *file)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
369 {
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
370 PurpleXfer *xfer = NULL;
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
371
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
372 g_return_if_fail(gc != NULL);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
373 g_return_if_fail(who != NULL);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
374
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
375 purple_debug_info("bonjour", "Bonjour-send-file to=%s.\n", who);
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
376
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
377 xfer = bonjour_new_xfer(gc, who);
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
378
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
379 if (file)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
380 purple_xfer_request_accepted(xfer, file);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
381 else
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
382 purple_xfer_request(xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
383
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
384 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
385
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
386 static void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
387 bonjour_xfer_init(PurpleXfer *xfer)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
388 {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
389 PurpleBuddy *buddy = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
390 BonjourBuddy *bd = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
391 XepXfer *xf = NULL;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
392
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
393 xf = (XepXfer*)xfer->data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
394 if(xf == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
395 return;
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
396
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
397 purple_debug_info("bonjour", "Bonjour-xfer-init.\n");
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
398
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
399 buddy = purple_find_buddy(xfer->account, xfer->who);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
400 /* this buddy is offline. */
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
401 if (buddy == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
402 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
403
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
404 bd = (BonjourBuddy *)buddy->proto_data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
405 xf->buddy_ip = g_strdup(bd->ip);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
406 if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
407 /* initiate file transfer, send SI offer. */
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
408 purple_debug_info("bonjour", "Bonjour xfer type is PURPLE_XFER_SEND.\n");
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
409 xep_ft_si_offer(xfer, xfer->who);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
410 } else {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
411 /* accept file transfer request, send SI result. */
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
412 xep_ft_si_result(xfer, xfer->who);
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
413 purple_debug_info("bonjour", "Bonjour xfer type is PURPLE_XFER_RECEIVE.\n");
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
414 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
415 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
416
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
417 void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
418 xep_si_parse(PurpleConnection *pc, xmlnode *packet, PurpleBuddy *pb)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
419 {
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
420 const char *type, *id;
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
421 BonjourData *bd = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
422 PurpleXfer *xfer = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
423
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
424 if(pc == NULL || packet == NULL || pb == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
425 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
426 bd = (BonjourData*) pc->proto_data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
427 if(bd == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
428 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
429
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
430 purple_debug_info("bonjour", "xep-si-parse.\n");
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
431
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
432 type = xmlnode_get_attrib(packet, "type");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
433 id = xmlnode_get_attrib(packet, "id");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
434 if(type) {
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
435 if(!strcmp(type, "set")) {
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
436 const char *profile;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
437 xmlnode *si;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
438 gboolean parsed_receive = FALSE;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
439
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
440 si = xmlnode_get_child(packet, "si");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
441
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
442 purple_debug_info("bonjour", "si offer Message type - SET.\n");
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
443 if (si && (profile = xmlnode_get_attrib(si, "profile"))
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
444 && !strcmp(profile, "http://jabber.org/protocol/si/profile/file-transfer")) {
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
445 const char *filename = NULL, *filesize_str = NULL;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
446 int filesize = 0;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
447 xmlnode *file;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
448
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
449 if ((file = xmlnode_get_child(si, "file"))) {
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
450 filename = xmlnode_get_attrib(file, "name");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
451 if((filesize_str = xmlnode_get_attrib(file, "size")))
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
452 filesize = atoi(filesize_str);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
453 }
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
454
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
455 /* TODO: Make sure that it is advertising a bytestreams transfer */
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
456
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
457 bonjour_xfer_receive(pc, id, pb->name, filesize, filename, XEP_BYTESTREAMS);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
458
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
459 parsed_receive = TRUE;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
460 }
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
461
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
462 if (!parsed_receive) {
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
463 purple_debug_info("bonjour", "rejecting unrecognized si SET offer.\n");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
464 xep_ft_si_reject((BonjourData *)pc->proto_data, id, pb->name, "403", "cancel");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
465 /*TODO: Send Cancel (501) */
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
466 }
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
467 } else if(!strcmp(type, "result")) {
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
468 purple_debug_info("bonjour", "si offer Message type - RESULT.\n");
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
469
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
470 xfer = bonjour_si_xfer_find(bd, id, pb->name);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
471
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
472 if(xfer == NULL) {
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
473 purple_debug_info("bonjour", "xfer find fail.\n");
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
474 xep_ft_si_reject((BonjourData *)pc->proto_data, id, pb->name, "403", "cancel");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
475 } else
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
476 bonjour_bytestreams_init(xfer);
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
477
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
478 } else if(!strcmp(type, "error")) {
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
479 purple_debug_info("bonjour", "si offer Message type - ERROR.\n");
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
480
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
481 xfer = bonjour_si_xfer_find(bd, id, pb->name);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
482
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
483 if(xfer == NULL)
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
484 purple_debug_info("bonjour", "xfer find fail.\n");
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
485 else
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
486 purple_xfer_cancel_remote(xfer);
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
487 } else
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
488 purple_debug_info("bonjour", "si offer Message type - Unknown-%d.\n", type);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
489 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
490 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
491
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
492 void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
493 xep_bytestreams_parse(PurpleConnection *pc, xmlnode *packet, PurpleBuddy *pb)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
494 {
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
495 const char *type = NULL, *from = NULL;
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
496 xmlnode *query = NULL, *streamhost = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
497 BonjourData *bd = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
498 PurpleXfer *xfer = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
499 XepXfer *xf = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
500 int portnum;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
501
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
502 if(pc == NULL || packet == NULL || pb == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
503 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
504
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
505 bd = (BonjourData*) pc->proto_data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
506 if(bd == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
507 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
508
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
509 purple_debug_info("bonjour", "xep-bytestreams-parse.\n");
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
510
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
511 type = xmlnode_get_attrib(packet, "type");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
512 from = pb->name;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
513 query = xmlnode_get_child(packet,"query");
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
514 if(type) {
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
515 if(!strcmp(type, "set")) {
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
516 const char *iq_id, *sid;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
517 gboolean found = FALSE;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
518
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
519 purple_debug_info("bonjour", "bytestream offer Message type - SET.\n");
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
520
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
521 iq_id = xmlnode_get_attrib(packet, "id");
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
522
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
523 sid = xmlnode_get_attrib(query, "sid");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
524 xfer = bonjour_si_xfer_find(bd, sid, from);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
525
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
526 if(xfer) {
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
527 const char *jid, *host, *port;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
528
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
529 xf = (XepXfer*)xfer->data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
530 for(streamhost = xmlnode_get_child(query, "streamhost");
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
531 streamhost;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
532 streamhost = xmlnode_get_next_twin(streamhost)) {
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
533
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
534 if((jid = xmlnode_get_attrib(streamhost, "jid")) &&
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
535 (host = xmlnode_get_attrib(streamhost, "host")) &&
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
536 (port = xmlnode_get_attrib(streamhost, "port")) &&
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
537 (portnum = atoi(port))) {
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
538
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
539 if(!strcmp(host, xf->buddy_ip)) {
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
540 g_free(xf->iq_id);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
541 xf->iq_id = g_strdup(iq_id);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
542 xf->jid = g_strdup(jid);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
543 xf->proxy_host = g_strdup(host);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
544 xf->proxy_port = portnum;
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
545 purple_debug_info("bonjour", "bytestream offer parse"
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
546 "jid=%s host=%s port=%d.\n", jid, host, portnum);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
547 bonjour_bytestreams_connect(xfer);
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
548 found = TRUE;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
549 break;
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
550 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
551 } else {
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
552 purple_debug_info("bonjour", "bytestream offer Message parse error.\n");
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
553 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
554 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
555 } else {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
556
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
557 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
558
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
559 if (!found) {
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
560 purple_debug_error("bonjour", "Didn't find an acceptable streamhost.\n");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
561
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
562 if (iq_id)
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
563 xep_ft_si_reject(bd, iq_id, xfer->who, "404", "cancel");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
564 }
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
565
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
566 } else {
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
567 purple_debug_info("bonjour", "bytestream offer Message type - Unknown-%s.\n", type);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
568 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
569 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
570 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
571
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
572 static void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
573 bonjour_xfer_receive(PurpleConnection *pc, const char *id, const char *from,
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
574 const int filesize, const char *filename, int option)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
575 {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
576 PurpleXfer *xfer = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
577 XepXfer *xf = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
578 BonjourData *bd = NULL;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
579
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
580 if(pc == NULL || id == NULL || from == NULL)
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
581 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
582
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
583 bd = (BonjourData*) pc->proto_data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
584 if(bd == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
585 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
586
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
587 purple_debug_info("bonjour", "bonjour-xfer-receive.\n");
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
588
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
589 /* Build the file transfer handle */
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
590 xfer = purple_xfer_new(pc->account, PURPLE_XFER_RECEIVE, from);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
591 xfer->data = xf = g_new0(XepXfer, 1);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
592 xf->data = bd;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
593 purple_xfer_set_filename(xfer, filename);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
594 xf->sid = g_strdup(id);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
595
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
596 if(filesize > 0)
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
597 purple_xfer_set_size(xfer, filesize);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
598 purple_xfer_set_init_fnc(xfer, bonjour_xfer_init);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
599 purple_xfer_set_request_denied_fnc(xfer, bonjour_xfer_request_denied);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
600 purple_xfer_set_cancel_recv_fnc(xfer, bonjour_xfer_cancel_recv);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
601 purple_xfer_set_end_fnc(xfer, bonjour_xfer_end);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
602
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
603 bd->xfer_lists = g_list_append(bd->xfer_lists, xfer);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
604
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
605 purple_xfer_request(xfer);
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
606 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
607
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
608 static void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
609 bonjour_sock5_request_cb(gpointer data, gint source, PurpleInputCondition cond)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
610 {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
611 PurpleXfer *xfer = data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
612 XepXfer *xf = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
613 int acceptfd;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
614 int len = 0;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
615
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
616 xf = xfer->data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
617 if(xf == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
618 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
619
21467
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
620 purple_debug_info("bonjour", "bonjour_sock5_request_cb - req_state = 0x%x\n", xf->sock5_req_state);
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
621
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
622 switch(xf->sock5_req_state){
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
623 case 0x00:
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
624 acceptfd = accept(source, NULL, 0);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
625 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
626
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
627 } else if(acceptfd == -1) {
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
628 /* TODO: This should cancel the ft */
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
629 } else {
21467
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
630 int flags;
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
631
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
632 purple_debug_info("bonjour", "Accepted SOCKS5 ft connection - fd=%d\n", acceptfd);
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
633
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
634 flags = fcntl(acceptfd, F_GETFL);
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
635 fcntl(acceptfd, F_SETFL, flags | O_NONBLOCK);
3d70e3ec8a47 My changes to disable external port mapping exposed a flaw where the server socket was being closed immediately, before the client had read all the data - this caused the client to receive a RST and consequently error. The solution is to wait for the client to close the connection before closing the server connection. I'm surprised this hasn't been a problem elsewhere - it seems like it would be.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21466
diff changeset
636
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
637 purple_input_remove(xfer->watcher);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
638 close(source);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
639 xfer->watcher = purple_input_add(acceptfd, PURPLE_INPUT_READ,
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
640 bonjour_sock5_request_cb, xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
641 xf->sock5_req_state++;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
642 xf->rxlen = 0;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
643 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
644 break;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
645 case 0x01:
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
646 xfer->fd = source;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
647 len = read(source, xf->rx_buf + xf->rxlen, 3);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
648 if(len < 0 && errno == EAGAIN)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
649 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
650 else if(len <= 0){
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
651 purple_input_remove(xfer->watcher);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
652 xfer->watcher = 0;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
653 close(source);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
654 purple_xfer_cancel_remote(xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
655 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
656 } else {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
657 purple_input_remove(xfer->watcher);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
658 xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE,
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
659 bonjour_sock5_request_cb, xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
660 xf->sock5_req_state++;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
661 xf->rxlen = 0;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
662 bonjour_sock5_request_cb(xfer, source, PURPLE_INPUT_WRITE);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
663 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
664 break;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
665 case 0x02:
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
666 xf->tx_buf[0] = 0x05;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
667 xf->tx_buf[1] = 0x00;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
668 len = write(source, xf->tx_buf, 2);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
669 if (len < 0 && errno == EAGAIN)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
670 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
671 else if (len < 0) {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
672 purple_input_remove(xfer->watcher);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
673 xfer->watcher = 0;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
674 close(source);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
675 purple_xfer_cancel_remote(xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
676 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
677 } else {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
678 purple_input_remove(xfer->watcher);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
679 xfer->watcher = purple_input_add(source, PURPLE_INPUT_READ,
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
680 bonjour_sock5_request_cb, xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
681 xf->sock5_req_state++;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
682 xf->rxlen = 0;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
683 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
684 break;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
685 case 0x03:
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
686 len = read(source, xf->rx_buf + xf->rxlen, 20);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
687 if(len<=0){
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
688 } else {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
689 purple_input_remove(xfer->watcher);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
690 xfer->watcher = purple_input_add(source, PURPLE_INPUT_WRITE,
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
691 bonjour_sock5_request_cb, xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
692 xf->sock5_req_state++;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
693 xf->rxlen = 0;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
694 bonjour_sock5_request_cb(xfer, source, PURPLE_INPUT_WRITE);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
695 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
696 break;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
697 case 0x04:
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
698 xf->tx_buf[0] = 0x05;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
699 xf->tx_buf[1] = 0x00;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
700 xf->tx_buf[2] = 0x00;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
701 xf->tx_buf[3] = 0x03;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
702 xf->tx_buf[4] = strlen(xf->buddy_ip);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
703 memcpy(xf->tx_buf + 5, xf->buddy_ip, strlen(xf->buddy_ip));
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
704 xf->tx_buf[5+strlen(xf->buddy_ip)] = 0x00;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
705 xf->tx_buf[6+strlen(xf->buddy_ip)] = 0x00;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
706 len = write(source, xf->tx_buf, 7 + strlen(xf->buddy_ip));
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
707 if (len < 0 && errno == EAGAIN) {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
708 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
709 } else if (len < 0) {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
710 purple_input_remove(xfer->watcher);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
711 xfer->watcher = 0;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
712 close(source);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
713 purple_xfer_cancel_remote(xfer);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
714 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
715 } else {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
716 purple_input_remove(xfer->watcher);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
717 xfer->watcher = 0;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
718 xf->rxlen = 0;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
719 /*close(source);*/
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
720 purple_xfer_start(xfer, source, NULL, -1);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
721 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
722 break;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
723 default:
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
724 break;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
725 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
726 return;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
727 }
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
728
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
729 static void
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
730 bonjour_bytestreams_listen(int sock, gpointer data)
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
731 {
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
732 PurpleXfer *xfer = data;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
733 XepXfer *xf;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
734 XepIq *iq;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
735 xmlnode *query, *streamhost;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
736 char *port;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
737 const char *next_ip;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
738 const char *local_ip = NULL;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
739 char token [] = ";";
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
740 BonjourData *bd;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
741
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
742 purple_debug_info("bonjour", "Bonjour-bytestreams-listen. sock=%d.\n", sock);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
743 if (sock < 0 || xfer == NULL) {
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
744 /*purple_xfer_cancel_local(xfer);*/
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
745 return;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
746 }
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
747
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
748 xfer->watcher = purple_input_add(sock, PURPLE_INPUT_READ,
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
749 bonjour_sock5_request_cb, xfer);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
750 xf = (XepXfer*)xfer->data;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
751 xf->listen_data = NULL;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
752
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
753 bd = xf->data;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
754
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
755 iq = xep_iq_new(bd, XEP_IQ_SET, xfer->who, purple_account_get_username(bd->jabber_data->account), xf->sid);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
756
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
757 query = xmlnode_new_child(iq->node, "query");
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
758 xmlnode_set_namespace(query, "http://jabber.org/protocol/bytestreams");
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
759 xmlnode_set_attrib(query, "sid", xf->sid);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
760 xmlnode_set_attrib(query, "mode", "tcp");
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
761
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
762 xfer->local_port = purple_network_get_port_from_fd(sock);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
763
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
764 local_ip = purple_network_get_my_ip_ext2(sock);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
765 /* cheat a little here - the intent of the "const" attribute is to make it clear that the string doesn't need to be freed */
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
766 next_ip = strtok((char *)local_ip, token);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
767
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
768 port = g_strdup_printf("%hu", xfer->local_port);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
769 while(next_ip != NULL) {
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
770 streamhost = xmlnode_new_child(query, "streamhost");
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
771 xmlnode_set_attrib(streamhost, "jid", xf->sid);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
772 xmlnode_set_attrib(streamhost, "host", next_ip);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
773 xmlnode_set_attrib(streamhost, "port", port);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
774 next_ip = strtok(NULL, token);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
775 }
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
776 g_free(port);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
777
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
778 xep_iq_send_and_free(iq);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
779 }
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
780
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
781 static void
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
782 bonjour_bytestreams_init(PurpleXfer *xfer)
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
783 {
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
784 XepXfer *xf = NULL;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
785 if(xfer == NULL)
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
786 return;
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
787 purple_debug_info("bonjour", "Bonjour-bytestreams-init.\n");
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
788 xf = xfer->data;
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
789 purple_network_listen_map_external(FALSE);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
790 xf->listen_data = purple_network_listen_range(0, 0, SOCK_STREAM,
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
791 bonjour_bytestreams_listen, xfer);
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
792 purple_network_listen_map_external(TRUE);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
793 if (xf->listen_data == NULL) {
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
794 purple_xfer_cancel_local(xfer);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
795 }
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
796 return;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
797 }
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
798
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
799 static void
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
800 bonjour_bytestreams_connect_cb(gpointer data, gint source, const gchar *error_message)
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
801 {
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
802 PurpleXfer *xfer = data;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
803 XepXfer *xf = xfer->data;
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
804 XepIq *iq = NULL;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
805 xmlnode *q_node, *tmp_node;
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
806 BonjourData *bd;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
807
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
808 if(data == NULL || source < 0) {
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
809 xep_ft_si_reject(xf->data, xf->iq_id, xfer->who, "404", "cancel");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
810 /* Cancel the connection */
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
811 purple_xfer_cancel_local(xfer);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
812 return;
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
813 }
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
814
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
815 bd = xf->data;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
816
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
817 purple_proxy_info_destroy(xf->proxy_info);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
818 xf->proxy_connection = NULL;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
819 xf->proxy_info = NULL;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
820 /* Here, start the file transfer.*/
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
821
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
822 /* Notify Initiator of Connection */
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
823 iq = xep_iq_new(bd, XEP_IQ_RESULT, xfer->who, purple_account_get_username(bd->jabber_data->account), xf->iq_id);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
824 q_node = xmlnode_new_child(iq->node, "query");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
825 xmlnode_set_namespace(q_node, "http://jabber.org/protocol/bytestreams");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
826 tmp_node = xmlnode_new_child(q_node, "streamhost-used");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
827 xmlnode_set_attrib(tmp_node, "jid", xf->jid);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
828 xep_iq_send_and_free(iq);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
829
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
830 purple_xfer_start(xfer, source, NULL, -1);
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
831 }
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
832
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
833 static void
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
834 bonjour_bytestreams_connect(PurpleXfer *xfer)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
835 {
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
836 XepXfer *xf = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
837 char dstaddr[41];
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
838 unsigned char hashval[20];
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
839 char *p = NULL;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
840 int i;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
841
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
842 if(xfer == NULL)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
843 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
844
21466
7a05b6f84545 Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21465
diff changeset
845 purple_debug_info("bonjour", "bonjour-bytestreams-connect.\n");
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
846
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
847 xf = (XepXfer*)xfer->data;
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
848 if(!xf)
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
849 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
850
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
851 p = g_strdup_printf("%s@%s", xf->sid, xfer->who);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
852 purple_cipher_digest_region("sha1", (guchar *)p, strlen(p),
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
853 sizeof(hashval), hashval, NULL);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
854 g_free(p);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
855
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
856 memset(dstaddr, 0, 41);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
857 p = dstaddr;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
858 for(i = 0; i < 20; i++, p += 2)
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
859 snprintf(p, 3, "%02x", hashval[i]);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
860
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
861 xf->proxy_info = purple_proxy_info_new();
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
862 purple_proxy_info_set_type(xf->proxy_info, PURPLE_PROXY_SOCKS5);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
863 purple_proxy_info_set_host(xf->proxy_info, xf->proxy_host);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
864 purple_proxy_info_set_port(xf->proxy_info, xf->proxy_port);
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
865 xf->proxy_connection = purple_proxy_connect_socks5(NULL, xf->proxy_info,
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
866 dstaddr, 0,
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
867 bonjour_bytestreams_connect_cb, xfer);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
868
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
869 if(xf->proxy_connection == NULL) {
21522
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
870 xep_ft_si_reject(xf->data, xf->iq_id, xfer->who, "404", "cancel");
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
871 /* Cancel the connection */
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
872 purple_xfer_cancel_local(xfer);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
873 /*purple_proxy_info_destroy(xf->proxy_info);
dc703f13449a Fix a couple bugs in the Bonjour XEP-0065 implementation, mainly related to error handling, but also send a <streamhost-used /> result. Also fix a XEP-0096 bug where the SI profile wasn't being specified. These bring ft with gajim closer to working, but we aren't there yet.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21467
diff changeset
874 xf->proxy_info = NULL;*/
21440
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
875 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
876 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
877