annotate libpurple/protocols/bonjour/bonjour_ft.c @ 32769:d9d55a03ec7b

propagate from branch 'im.pidgin.pidgin.2.x.y' (head c67a060046437347c5cc4f58bdff008d7b8c4496) to branch 'im.pidgin.pidgin' (head 40617c1e9cdf903724dbeee455fccc8d64ace22f)
author Richard Laager <rlaager@wiktel.com>
date Fri, 06 Apr 2012 04:30:06 +0000
parents cf70e3c23c9d
children
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
28070
7921a53b94b3 Oops, Elliott correctly pointed out this was wrong...
Paul Aurich <paul@darkrain42.org>
parents: 28049
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
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
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
21533
178fe7d45700 Fix receiving files from Gajim clients by making the SOCKS5 target hash correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21531
diff changeset
36 bonjour_bytestreams_connect(PurpleXfer *xfer, PurpleBuddy *pb);
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
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
21531
07c91ea3da0e Fix some confusion between iq ids and sids. This allows me to send files to Gajim (as long as Gajim has initiated the connection to me - there seems to a bug there where it will try to make a new connection if I've initiated the connection). Also fix a null ptr deref crash.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21527
diff changeset
40 bonjour_xfer_receive(PurpleConnection *pc, const char *id, const char *sid, const char *from,
32291
df7fb85b11ba Update Bonjour for 64-bit file transfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32216
diff changeset
41 const goffset filesize, const char *filename, int option);
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
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 {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
50 xmlnode *error_node;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
51 XepIq *iq;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
52
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
53 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
54 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
55
30583
9c8b28dc6656 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29481
diff changeset
56 if(!to || !id) {
9c8b28dc6656 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29481
diff changeset
57 purple_debug_info("bonjour", "xep file transfer stream initialization error.\n");
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;
30583
9c8b28dc6656 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29481
diff changeset
59 }
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
60
30583
9c8b28dc6656 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29481
diff changeset
61 iq = xep_iq_new(bd, XEP_IQ_ERROR, to, bonjour_get_jid(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")) {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
71 xmlnode *tmp_node = xmlnode_new_child(error_node, "forbidden");
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
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")) {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
78 xmlnode *tmp_node = xmlnode_new_child(error_node, "item-not-found");
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
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 {
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
93 XepXfer *xf = purple_xfer_get_protocol_data(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
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 if(xf)
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
98 xep_ft_si_reject(xf->data, xf->sid, purple_xfer_get_remote_user(xfer), "403", "cancel");
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
99
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
100 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
101 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
104 {
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
105 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
106 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
107 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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
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
109 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
110 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
111 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
112 };
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 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
115 _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
116 {
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 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
118 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
119 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
120
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 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
122
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 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
124 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
125 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
126 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
127 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
128 }
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 }
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
130
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
132 {
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
133 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
134
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 /* 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
136 * 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
137 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
138 struct socket_cleanup *sc = g_new0(struct socket_cleanup, 1);
32331
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
139 sc->fd = purple_xfer_get_fd(xfer);
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
140 purple_xfer_set_fd(xfer, -1);
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
141 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
142 _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
143 }
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
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
145 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
146 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
149 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
150 {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
151 GSList *xfers;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
152 PurpleXfer *xfer;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
153 XepXfer *xf;
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
154
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
156 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
157
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
158 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
159 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
160
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
162 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
163 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
164 break;
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
165 xf = purple_xfer_get_protocol_data(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
166 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
167 break;
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
168 if(xf->sid && purple_xfer_get_remote_user(xfer) && !strcmp(xf->sid, sid) &&
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
169 !strcmp(purple_xfer_get_remote_user(xfer), from))
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
170 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
171 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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
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
173 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
174
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
176 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
179 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
180 {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
181 xmlnode *si_node, *feature, *field, *file, *x;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
182 XepIq *iq;
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
183 XepXfer *xf = purple_xfer_get_protocol_data(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
184 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
185 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
186
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
188 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
189
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
190 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
191 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
192 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
193
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
194 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
195
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 /* Assign stream id. */
21531
07c91ea3da0e Fix some confusion between iq ids and sids. This allows me to send files to Gajim (as long as Gajim has initiated the connection to me - there seems to a bug there where it will try to make a new connection if I've initiated the connection). Also fix a null ptr deref crash.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21527
diff changeset
197 g_free(xf->iq_id);
07c91ea3da0e Fix some confusion between iq ids and sids. This allows me to send files to Gajim (as long as Gajim has initiated the connection to me - there seems to a bug there where it will try to make a new connection if I've initiated the connection). Also fix a null ptr deref crash.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21527
diff changeset
198 xf->iq_id = g_strdup_printf("%u", next_id++);
30583
9c8b28dc6656 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29481
diff changeset
199 iq = xep_iq_new(xf->data, XEP_IQ_SET, to, bonjour_get_jid(bd->jabber_data->account), 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
200 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
201 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
202
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 /*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
204 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
205 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
206 xmlnode_set_attrib(si_node, "profile", "http://jabber.org/protocol/si/profile/file-transfer");
21531
07c91ea3da0e Fix some confusion between iq ids and sids. This allows me to send files to Gajim (as long as Gajim has initiated the connection to me - there seems to a bug there where it will try to make a new connection if I've initiated the connection). Also fix a null ptr deref crash.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21527
diff changeset
207 g_free(xf->sid);
07c91ea3da0e Fix some confusion between iq ids and sids. This allows me to send files to Gajim (as long as Gajim has initiated the connection to me - there seems to a bug there where it will try to make a new connection if I've initiated the connection). Also fix a null ptr deref crash.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21527
diff changeset
208 xf->sid = g_strdup(xf->iq_id);
07c91ea3da0e Fix some confusion between iq ids and sids. This allows me to send files to Gajim (as long as Gajim has initiated the connection to me - there seems to a bug there where it will try to make a new connection if I've initiated the connection). Also fix a null ptr deref crash.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21527
diff changeset
209 xmlnode_set_attrib(si_node, "id", 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
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 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
212 xmlnode_set_namespace(file, "http://jabber.org/protocol/si/profile/file-transfer");
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
213 xmlnode_set_attrib(file, "name", purple_xfer_get_filename(xfer));
32291
df7fb85b11ba Update Bonjour for 64-bit file transfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32216
diff changeset
214 g_snprintf(buf, sizeof(buf), "%" G_GOFFSET_FORMAT, purple_xfer_get_size(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
215 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
216
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
218 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
219
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
221 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
222 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
223
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
225 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
226 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
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 if (xf->mode & XEP_BYTESTREAMS) {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
229 xmlnode *option = xmlnode_new_child(field, "option");
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
230 xmlnode *value = xmlnode_new_child(option, "value");
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
231 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
232 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 if (xf->mode & XEP_IBB) {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
234 xmlnode *option = xmlnode_new_child(field, "option");
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
235 xmlnode *value = xmlnode_new_child(option, "value");
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
236 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
237 }
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
238
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
239 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
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
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 static void
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
243 xep_ft_si_result(PurpleXfer *xfer, const char *to)
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
244 {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
245 xmlnode *si_node, *feature, *field, *value, *x;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
246 XepIq *iq;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
247 XepXfer *xf;
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
248 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
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 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
251 return;
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
252 xf = purple_xfer_get_protocol_data(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
253 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
254 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
255
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
256 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
257
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
258 purple_debug_info("bonjour", "xep file transfer stream initialization result.\n");
30583
9c8b28dc6656 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29481
diff changeset
259 iq = xep_iq_new(bd, XEP_IQ_RESULT, to, bonjour_get_jid(bd->jabber_data->account), 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
260 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
261 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
262
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
264 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
265 /*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
266
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
268 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
269
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
270 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
271 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
272 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
273
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
275 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
276
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
277 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
278 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
279
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
280 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
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
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
284 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
285 {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
286 XepXfer *xf;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
287
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
288 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
289 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
290 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
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
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
293 purple_debug_misc("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
294
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
295 xf = purple_xfer_get_protocol_data(xfer);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
296 if(xf != NULL) {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
297 BonjourData *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
298 if(bd != NULL) {
21829
cc0809ec0c85 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
299 bd->xfer_lists = g_slist_remove(bd->xfer_lists, xfer);
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
300 purple_debug_misc("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
301 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
302 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
303 purple_proxy_connect_cancel(xf->proxy_connection);
23559
3ba2cddc49f0 Fix a double free when connecting to the sender of a bonjour file fails. Also plug a small leak. Fixes #5971. (this time only commit the one file instead of my whole tree)
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23558
diff changeset
304 if (xf->proxy_info != NULL)
3ba2cddc49f0 Fix a double free when connecting to the sender of a bonjour file fails. Also plug a small leak. Fixes #5971. (this time only commit the one file instead of my whole tree)
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23558
diff changeset
305 purple_proxy_info_destroy(xf->proxy_info);
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
306 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
307 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
308 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
309 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
310 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
311 g_free(xf->buddy_ip);
21441
da75dd6c41fb Leak fix, cleanup and code reuse.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21440
diff changeset
312 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
313 g_free(xf);
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
314 purple_xfer_set_protocol_data(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
315 }
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
316
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
317 purple_debug_misc("bonjour", "Need close socket.\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
318 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
319
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
321 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
322 {
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
323 PurpleXfer *xfer;
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
324 XepXfer *xep_xfer;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
325 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
326
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
327 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
328 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
329
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
330 purple_debug_info("bonjour", "Bonjour-new-xfer to %s.\n", who);
31979
e895aebcb504 Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 31960
diff changeset
331 bd = purple_connection_get_protocol_data(gc);
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
332 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
333 return NULL;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
334
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 /* Build the file transfer handle */
32305
2ec94166be43 On the way to hiding the PurpleConnection struct.
andrew.victor@mxit.com
parents: 32291
diff changeset
336 xfer = purple_xfer_new(purple_connection_get_account(gc), PURPLE_XFER_SEND, who);
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
337 xep_xfer = g_new0(XepXfer, 1);
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
338 purple_xfer_set_protocol_data(xfer, xep_xfer);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
339 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
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 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
342
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
343 /* 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
344 /*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
345 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
346 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
347
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
348 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
349 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
350 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
351
21829
cc0809ec0c85 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
352 bd->xfer_lists = g_slist_append(bd->xfer_lists, xfer);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
353
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
354 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
355 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
356
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
357 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
358 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
359 {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
360 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
361
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
362 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
363 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
364
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
365 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
366
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
367 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
368
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
369 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
370 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
371 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
372 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
373
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
374 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
375
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
376 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
377 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
378 {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
379 PurpleBuddy *buddy;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
380 BonjourBuddy *bb;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
381 XepXfer *xf;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
382
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
383 xf = purple_xfer_get_protocol_data(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
384 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
385 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
386
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
387 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
388
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
389 buddy = purple_find_buddy(purple_xfer_get_account(xfer), purple_xfer_get_remote_user(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
390 /* this buddy is offline. */
25791
252e26edb7a9 Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 23708
diff changeset
391 if (buddy == NULL || (bb = purple_buddy_get_protocol_data(buddy)) == 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
392 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
393
21806
41959f031322 Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21533
diff changeset
394 /* Assume it is the first IP. We could do something like keep track of which one is in use or something. */
41959f031322 Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21533
diff changeset
395 if (bb->ips)
41959f031322 Update Bonjour prpl to support multiple presence records for the same buddy. Eliminate the Howl backend to avoid having to maintain yet another set of code. References #4187 (more to come to fix the rest of the ticket).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21533
diff changeset
396 xf->buddy_ip = g_strdup(bb->ips->data);
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
397 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
398 /* 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
399 purple_debug_info("bonjour", "Bonjour xfer type is PURPLE_XFER_SEND.\n");
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
400 xep_ft_si_offer(xfer, purple_xfer_get_remote_user(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
401 } 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
402 /* accept file transfer request, send SI result. */
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
403 xep_ft_si_result(xfer, purple_xfer_get_remote_user(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
404 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
405 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
408 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
409 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
410 {
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
411 const char *type, *id;
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
412 BonjourData *bd;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
413 PurpleXfer *xfer;
25791
252e26edb7a9 Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 23708
diff changeset
414 const gchar *name = 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
415
24675
35d0ce5f319a Further cleanup to fix CID 373.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23708
diff changeset
416 g_return_if_fail(pc != NULL);
35d0ce5f319a Further cleanup to fix CID 373.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23708
diff changeset
417 g_return_if_fail(packet != NULL);
35d0ce5f319a Further cleanup to fix CID 373.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23708
diff changeset
418 g_return_if_fail(pb != NULL);
35d0ce5f319a Further cleanup to fix CID 373.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23708
diff changeset
419
31979
e895aebcb504 Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 31960
diff changeset
420 bd = purple_connection_get_protocol_data(pc);
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 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
422 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
423
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
424 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
425
25791
252e26edb7a9 Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 23708
diff changeset
426 name = purple_buddy_get_name(pb);
252e26edb7a9 Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 23708
diff changeset
427
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
428 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
429 id = xmlnode_get_attrib(packet, "id");
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
430 if(!type)
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
431 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
432
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
433 if(!strcmp(type, "set")) {
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
434 const char *profile;
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
435 xmlnode *si;
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
436 gboolean parsed_receive = FALSE;
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
437
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
438 si = xmlnode_get_child(packet, "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
439
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
440 purple_debug_info("bonjour", "si offer Message type - SET.\n");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
441 if (si && (profile = xmlnode_get_attrib(si, "profile"))
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
442 && !strcmp(profile, "http://jabber.org/protocol/si/profile/file-transfer")) {
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
443 const char *filename = NULL, *filesize_str = NULL;
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
444 int filesize = 0;
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
445 xmlnode *file;
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
446
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
447 const char *sid = xmlnode_get_attrib(si, "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
448
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
449 if ((file = xmlnode_get_child(si, "file"))) {
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
450 filename = xmlnode_get_attrib(file, "name");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
451 if((filesize_str = xmlnode_get_attrib(file, "size")))
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
452 filesize = atoi(filesize_str);
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
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
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
455 /* TODO: Make sure that it is advertising a bytestreams transfer */
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
456
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
457 if (filename) {
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
458 bonjour_xfer_receive(pc, id, sid, name, filesize, filename, XEP_BYTESTREAMS);
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
459
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
460 parsed_receive = TRUE;
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
461 }
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
462 }
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
463
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
464 if (!parsed_receive) {
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
465 BonjourData *bd = purple_connection_get_protocol_data(pc);
25791
252e26edb7a9 Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 23708
diff changeset
466
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
467 purple_debug_info("bonjour", "rejecting unrecognized si SET offer.\n");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
468 xep_ft_si_reject(bd, id, name, "403", "cancel");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
469 /*TODO: Send Cancel (501) */
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
470 }
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
471 } else if(!strcmp(type, "result")) {
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
472 purple_debug_info("bonjour", "si offer Message type - RESULT.\n");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
473
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
474 xfer = bonjour_si_xfer_find(bd, id, name);
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
475
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
476 if(xfer == NULL) {
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
477 BonjourData *bd = purple_connection_get_protocol_data(pc);
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
478 purple_debug_info("bonjour", "xfer find fail.\n");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
479 xep_ft_si_reject(bd, id, name, "403", "cancel");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
480 } else
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
481 bonjour_bytestreams_init(xfer);
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
482
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
483 } else if(!strcmp(type, "error")) {
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
484 purple_debug_info("bonjour", "si offer Message type - ERROR.\n");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
485
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
486 xfer = bonjour_si_xfer_find(bd, id, name);
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
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
488 if(xfer == NULL)
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
489 purple_debug_info("bonjour", "xfer find fail.\n");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
490 else
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
491 purple_xfer_cancel_remote(xfer);
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
492 } else
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
493 purple_debug_info("bonjour", "si offer Message type - Unknown-%s.\n", type);
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
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
32371
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
496 /**
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
497 * Will compare a host with a buddy_ip.
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
498 *
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
499 * Additionally to a common '!strcmp(host, buddy_ip)', it will also return TRUE
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
500 * if 'host' is a link local IPv6 address without an appended interface
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
501 * identifier and 'buddy_ip' string is "host" + "%iface".
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
502 *
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
503 * Note: This may theoretically result in the attempt to connect to the wrong
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
504 * host, because we do not know for sure which interface the according link
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
505 * local IPv6 address might relate to and RFC4862 for instance only ensures the
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
506 * uniqueness of this address on a given link. So we could possibly have two
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
507 * distinct buddies with the same ipv6 link local address on two distinct
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
508 * interfaces. Unfortunately XEP-0065 does not seem to specify how to deal with
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
509 * link local ip addresses properly...
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
510 * However, in practice the possiblity for such a conflict is relatively low
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
511 * (2011 - might be different in the future though?).
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
512 *
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
513 * @param host ipv4 or ipv6 address string
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
514 * @param buddy_ip ipv4 or ipv6 address string
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
515 * @return TRUE if they match, FALSE otherwise
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
516 */
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
517 static gboolean
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
518 xep_cmp_addr(const char *host, const char *buddy_ip)
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
519 {
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
520 #if defined(AF_INET6) && defined(HAVE_GETADDRINFO)
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
521 struct addrinfo hint, *res = NULL;
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
522 int ret;
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
523
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
524 memset(&hint, 0, sizeof(hint));
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
525 hint.ai_family = AF_UNSPEC;
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
526 hint.ai_flags = AI_NUMERICHOST;
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
527
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
528 ret = getaddrinfo(host, NULL, &hint, &res);
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
529 if(ret)
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
530 goto out;
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
531
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
532 if(res->ai_family != AF_INET6 ||
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
533 !IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)res->ai_addr)->sin6_addr)) {
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
534 freeaddrinfo(res);
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
535 goto out;
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
536 }
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
537 freeaddrinfo(res);
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
538
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
539 if(strlen(buddy_ip) <= strlen(host) ||
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
540 buddy_ip[strlen(host)] != '%')
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
541 return FALSE;
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
542
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
543 return !strncmp(host, buddy_ip, strlen(host));
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
544
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
545 out:
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
546 #endif
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
547 return !strcmp(host, buddy_ip);
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
548 }
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
549
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
550 static gboolean
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
551 __xep_bytestreams_parse(PurpleBuddy *pb, PurpleXfer *xfer, xmlnode *query,
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
552 const char *iq_id)
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
553 {
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
554 const char *jid, *host, *port;
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
555 int portnum;
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
556 xmlnode *streamhost;
32373
cf70e3c23c9d Fix compilation of Bonjour prpl on 3.0.
andrew.victor@mxit.com
parents: 32372
diff changeset
557 XepXfer *xf = purple_xfer_get_protocol_data(xfer);
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
558
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
559 for(streamhost = xmlnode_get_child(query, "streamhost");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
560 streamhost;
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
561 streamhost = xmlnode_get_next_twin(streamhost)) {
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
562
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
563 if(!(jid = xmlnode_get_attrib(streamhost, "jid")) ||
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
564 !(host = xmlnode_get_attrib(streamhost, "host")) ||
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
565 !(port = xmlnode_get_attrib(streamhost, "port")) ||
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
566 !(portnum = atoi(port))) {
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
567 purple_debug_info("bonjour", "bytestream offer Message parse error.\n");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
568 continue;
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
569 }
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
570
32371
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
571 if(!xep_cmp_addr(host, xf->buddy_ip))
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
572 continue;
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
573
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
574 g_free(xf->iq_id);
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
575 xf->iq_id = g_strdup(iq_id);
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
576 xf->jid = g_strdup(jid);
32371
58d4a721f0c0 Fix IPv6 link local file transfer.
linus.luessing@web.de
parents: 32370
diff changeset
577 xf->proxy_host = g_strdup(xf->buddy_ip);
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
578 xf->proxy_port = portnum;
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
579 purple_debug_info("bonjour", "bytestream offer parse"
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
580 "jid=%s host=%s port=%d.\n", jid, host, portnum);
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
581 bonjour_bytestreams_connect(xfer, pb);
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
582 return TRUE;
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 }
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
584
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
585 return FALSE;
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
586 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
587
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
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 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
590 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
591 {
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
592 const char *type, *from, *iq_id, *sid;
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
593 xmlnode *query;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
594 BonjourData *bd;
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
595 PurpleXfer *xfer;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
596
24675
35d0ce5f319a Further cleanup to fix CID 373.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23708
diff changeset
597 g_return_if_fail(pc != NULL);
35d0ce5f319a Further cleanup to fix CID 373.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23708
diff changeset
598 g_return_if_fail(packet != NULL);
35d0ce5f319a Further cleanup to fix CID 373.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23708
diff changeset
599 g_return_if_fail(pb != NULL);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
600
31979
e895aebcb504 Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 31960
diff changeset
601 bd = purple_connection_get_protocol_data(pc);
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
602 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
603 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
604
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
605 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
606
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
607 type = xmlnode_get_attrib(packet, "type");
25130
16734635febf Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23708
diff changeset
608 from = purple_buddy_get_name(pb);
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
609 query = xmlnode_get_child(packet,"query");
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
610 if(!type)
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
611 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
612
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
613 if(strcmp(type, "set")) {
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
614 purple_debug_info("bonjour", "bytestream offer Message type - Unknown-%s.\n", type);
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
615 return;
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
616 }
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
617
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
618 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
619
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
620 iq_id = xmlnode_get_attrib(packet, "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
621
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
622 sid = xmlnode_get_attrib(query, "sid");
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
623 xfer = bonjour_si_xfer_find(bd, sid, from);
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
624 if(xfer && __xep_bytestreams_parse(pb, xfer, query, iq_id))
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
625 return; /* success */
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
626
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
627 purple_debug_error("bonjour", "Didn't find an acceptable streamhost.\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
628
32370
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
629 if (iq_id && xfer != NULL)
c37cd9c2da7f Remove some layers of indentation in bonjour_ft.c
linus.luessing@web.de
parents: 31481
diff changeset
630 xep_ft_si_reject(bd, iq_id, xfer->who, "404", "cancel");
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
631 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
632
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
633 static void
21531
07c91ea3da0e Fix some confusion between iq ids and sids. This allows me to send files to Gajim (as long as Gajim has initiated the connection to me - there seems to a bug there where it will try to make a new connection if I've initiated the connection). Also fix a null ptr deref crash.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21527
diff changeset
634 bonjour_xfer_receive(PurpleConnection *pc, const char *id, const char *sid, const char *from,
32291
df7fb85b11ba Update Bonjour for 64-bit file transfers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32216
diff changeset
635 const goffset filesize, const char *filename, int option)
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
636 {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
637 PurpleXfer *xfer;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
638 XepXfer *xf;
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
639 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
640
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
641 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
642 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
643
31979
e895aebcb504 Convert bonjour prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
andrew.victor@mxit.com
parents: 31960
diff changeset
644 bd = purple_connection_get_protocol_data(pc);
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
645 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
646 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
647
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
648 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
649
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
650 /* Build the file transfer handle */
32305
2ec94166be43 On the way to hiding the PurpleConnection struct.
andrew.victor@mxit.com
parents: 32291
diff changeset
651 xfer = purple_xfer_new(purple_connection_get_account(pc), PURPLE_XFER_RECEIVE, from);
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
652 xf = g_new0(XepXfer, 1);
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
653 purple_xfer_set_protocol_data(xfer, xf);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
654 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
655 purple_xfer_set_filename(xfer, filename);
21531
07c91ea3da0e Fix some confusion between iq ids and sids. This allows me to send files to Gajim (as long as Gajim has initiated the connection to me - there seems to a bug there where it will try to make a new connection if I've initiated the connection). Also fix a null ptr deref crash.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21527
diff changeset
656 xf->iq_id = g_strdup(id);
07c91ea3da0e Fix some confusion between iq ids and sids. This allows me to send files to Gajim (as long as Gajim has initiated the connection to me - there seems to a bug there where it will try to make a new connection if I've initiated the connection). Also fix a null ptr deref crash.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21527
diff changeset
657 xf->sid = g_strdup(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
658
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
659 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
660 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
661 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
662 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
663 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
664 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
665
21829
cc0809ec0c85 This is the second part of the fix to support having multiple presence records in Bonjour (and also supporting multiple presences using the same IP). Incoming conversations are no longer immediately attached to a buddy - we use an algorithm to match a conversation to a buddy based on the IP and, if possible the "from" attribute of the stream or the first tag in the stream. Thanks to Sjoerd Simons from Telepahy Salut for noticing and suggesting the algorithm. Fixes #4187. It'd be good if a few people test this.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21806
diff changeset
666 bd->xfer_lists = g_slist_append(bd->xfer_lists, xfer);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
667
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
668 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
669 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
672 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
673 {
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 PurpleXfer *xfer = data;
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
675 XepXfer *xf = purple_xfer_get_protocol_data(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
676 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
677 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
678
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
679 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
680 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
681
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
682 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
683
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
684 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
685 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
686 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
687 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
688
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 } else if(acceptfd == -1) {
21527
5b9da9db7e81 Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21522
diff changeset
690 /* This should cancel the ft */
21531
07c91ea3da0e Fix some confusion between iq ids and sids. This allows me to send files to Gajim (as long as Gajim has initiated the connection to me - there seems to a bug there where it will try to make a new connection if I've initiated the connection). Also fix a null ptr deref crash.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21527
diff changeset
691 purple_debug_error("bonjour", "Error accepting incoming SOCKS5 connection. (%d)\n", errno);
21527
5b9da9db7e81 Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21522
diff changeset
692
5b9da9db7e81 Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21522
diff changeset
693 close(source);
5b9da9db7e81 Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21522
diff changeset
694 purple_xfer_cancel_remote(xfer);
5b9da9db7e81 Various bugfixes including using purple_account_remove_buddy() in addition to purple_blist_remove_buddy() to make sure that the buddy gets cleaned up fully when logging out or we go offline.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21522
diff changeset
695 return;
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
696 } 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
697 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
698
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
699 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
700
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
701 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
702 fcntl(acceptfd, F_SETFL, flags | O_NONBLOCK);
23708
0dd3df365017 These fds don't need to be inherited by child processes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23559
diff changeset
703 #ifndef _WIN32
0dd3df365017 These fds don't need to be inherited by child processes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23559
diff changeset
704 fcntl(acceptfd, F_SETFD, FD_CLOEXEC);
0dd3df365017 These fds don't need to be inherited by child processes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23559
diff changeset
705 #endif
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
706
32331
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
707 purple_input_remove(purple_xfer_get_watcher(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
708 close(source);
32331
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
709 purple_xfer_set_watcher(xfer, purple_input_add(acceptfd, PURPLE_INPUT_READ,
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
710 bonjour_sock5_request_cb, 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
711 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
712 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
713 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, 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 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
715 case 0x01:
32331
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
716 purple_xfer_set_fd(xfer, 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
717 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
718 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
719 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
720 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
721 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
722 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
723 } else {
32331
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
724 purple_input_remove(purple_xfer_get_watcher(xfer));
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
725 purple_xfer_set_watcher(xfer, purple_input_add(source, PURPLE_INPUT_WRITE,
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
726 bonjour_sock5_request_cb, 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
727 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
728 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
729 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
730 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
731 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
732 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
733 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
734 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
735 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
736 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
737 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
738 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
739 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
740 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
741 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
742 } else {
32331
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
743 purple_input_remove(purple_xfer_get_watcher(xfer));
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
744 purple_xfer_set_watcher(xfer, purple_input_add(source, PURPLE_INPUT_READ,
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
745 bonjour_sock5_request_cb, 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
746 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
747 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
748 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
749 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
750 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
751 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
752 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
753 } else {
32331
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
754 purple_input_remove(purple_xfer_get_watcher(xfer));
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
755 purple_xfer_set_watcher(xfer, purple_input_add(source, PURPLE_INPUT_WRITE,
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
756 bonjour_sock5_request_cb, 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
757 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
758 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
759 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
760 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
761 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
762 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
763 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
764 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
765 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
766 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
767 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
768 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
769 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
770 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
771 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
772 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
773 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
774 } 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
775 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
776 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
777 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
778 } else {
32331
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
779 purple_input_remove(purple_xfer_get_watcher(xfer));
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
780 purple_xfer_set_watcher(xfer, 0);
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
781 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
782 /*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
783 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
784 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
785 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
786 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
787 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
788 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
789 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
790 }
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
791
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
792 static void
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
793 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
794 {
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
795 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
796 XepXfer *xf;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
797 XepIq *iq;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
798 xmlnode *query, *streamhost;
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
799 gchar *port;
29481
755219afed9f Implementation of IPv6 support for Bonjour
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28070
diff changeset
800 GSList *local_ips;
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
801 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
802
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
803 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
804 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
805 /*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
806 return;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
807 }
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
808
32331
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
809 purple_xfer_set_watcher(xfer, purple_input_add(sock, PURPLE_INPUT_READ,
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
810 bonjour_sock5_request_cb, xfer));
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
811 xf = purple_xfer_get_protocol_data(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 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
813
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
814 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
815
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
816 iq = xep_iq_new(bd, XEP_IQ_SET, purple_xfer_get_remote_user(xfer), bonjour_get_jid(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
817
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
818 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
819 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
820 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
821 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
822
32331
1ffa35da9a7b Bonjour: Use file-transfer accessor functions.
andrew.victor@mxit.com
parents: 32305
diff changeset
823 purple_xfer_set_local_port(xfer, purple_network_get_port_from_fd(sock));
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
824
29481
755219afed9f Implementation of IPv6 support for Bonjour
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28070
diff changeset
825 local_ips = bonjour_jabber_get_local_ips(sock);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
826
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
827 port = g_strdup_printf("%hu", purple_xfer_get_local_port(xfer));
29481
755219afed9f Implementation of IPv6 support for Bonjour
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28070
diff changeset
828 while(local_ips) {
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
829 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
830 xmlnode_set_attrib(streamhost, "jid", xf->sid);
29481
755219afed9f Implementation of IPv6 support for Bonjour
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28070
diff changeset
831 xmlnode_set_attrib(streamhost, "host", local_ips->data);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
832 xmlnode_set_attrib(streamhost, "port", port);
29481
755219afed9f Implementation of IPv6 support for Bonjour
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28070
diff changeset
833 g_free(local_ips->data);
755219afed9f Implementation of IPv6 support for Bonjour
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28070
diff changeset
834 local_ips = g_slist_delete_link(local_ips, local_ips);
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
835 }
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
836 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
837
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
838 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
839 }
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
840
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
841 static void
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
842 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
843 {
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
844 XepXfer *xf;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
845 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
846 return;
29481
755219afed9f Implementation of IPv6 support for Bonjour
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28070
diff changeset
847
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
848 purple_debug_info("bonjour", "Bonjour-bytestreams-init.\n");
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
849 xf = purple_xfer_get_protocol_data(xfer);
29481
755219afed9f Implementation of IPv6 support for Bonjour
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28070
diff changeset
850
32216
d2ef8926b960 Remove deprecated purple_network_listen_map_external().
andrew.victor@mxit.com
parents: 32215
diff changeset
851 xf->listen_data = purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, FALSE,
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
852 bonjour_bytestreams_listen, xfer);
29481
755219afed9f Implementation of IPv6 support for Bonjour
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28070
diff changeset
853 if (xf->listen_data == NULL)
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
854 purple_xfer_cancel_local(xfer);
29481
755219afed9f Implementation of IPv6 support for Bonjour
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28070
diff changeset
855
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
856 return;
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
857 }
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
858
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
859 static void
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
860 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
861 {
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
862 PurpleXfer *xfer = data;
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
863 XepXfer *xf = purple_xfer_get_protocol_data(xfer);
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
864 XepIq *iq;
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
865 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
866 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
867
23559
3ba2cddc49f0 Fix a double free when connecting to the sender of a bonjour file fails. Also plug a small leak. Fixes #5971. (this time only commit the one file instead of my whole tree)
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23558
diff changeset
868 xf->proxy_connection = NULL;
3ba2cddc49f0 Fix a double free when connecting to the sender of a bonjour file fails. Also plug a small leak. Fixes #5971. (this time only commit the one file instead of my whole tree)
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23558
diff changeset
869
21533
178fe7d45700 Fix receiving files from Gajim clients by making the SOCKS5 target hash correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21531
diff changeset
870 if(source < 0) {
178fe7d45700 Fix receiving files from Gajim clients by making the SOCKS5 target hash correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21531
diff changeset
871 purple_debug_error("bonjour", "Error connecting via SOCKS5 - %s\n",
178fe7d45700 Fix receiving files from Gajim clients by making the SOCKS5 target hash correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21531
diff changeset
872 error_message ? error_message : "(null)");
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
873 xep_ft_si_reject(xf->data, xf->iq_id, purple_xfer_get_remote_user(xfer), "404", "cancel");
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
874 /* 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
875 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
876 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
877 }
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
878
21533
178fe7d45700 Fix receiving files from Gajim clients by making the SOCKS5 target hash correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21531
diff changeset
879 purple_debug_info("bonjour", "Connected successfully via SOCKS5, starting transfer.\n");
178fe7d45700 Fix receiving files from Gajim clients by making the SOCKS5 target hash correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21531
diff changeset
880
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
881 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
882
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
883 /* 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
884
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
885 /* Notify Initiator of Connection */
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
886 iq = xep_iq_new(bd, XEP_IQ_RESULT, purple_xfer_get_remote_user(xfer), bonjour_get_jid(bd->jabber_data->account), xf->iq_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
887 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
888 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
889 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
890 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
891 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
892
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
893 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
894 }
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
895
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
896 static void
21533
178fe7d45700 Fix receiving files from Gajim clients by making the SOCKS5 target hash correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21531
diff changeset
897 bonjour_bytestreams_connect(PurpleXfer *xfer, PurpleBuddy *pb)
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
898 {
25791
252e26edb7a9 Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 23708
diff changeset
899 PurpleAccount *account = NULL;
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
900 XepXfer *xf;
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
901 char dstaddr[41];
25791
252e26edb7a9 Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 23708
diff changeset
902 const gchar *name = 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
903 unsigned char hashval[20];
23018
ef0bcbe33689 applied changes from 3d595739f53a259d5dae408a05f64d2836f02ac9
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22486
diff changeset
904 char *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
905 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
906
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
907 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
908 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
909
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
910 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
911
31960
0a166ca06445 Convert the bonjour prpl to use the new API.
andrew.victor@mxit.com
parents: 31481
diff changeset
912 xf = purple_xfer_get_protocol_data(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
913 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
914 return;
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
915
25791
252e26edb7a9 Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 23708
diff changeset
916 name = purple_buddy_get_name(pb);
252e26edb7a9 Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 23708
diff changeset
917 account = purple_buddy_get_account(pb);
252e26edb7a9 Finished moving to api for bonjour
Gary Kramlich <grim@reaperworld.com>
parents: 23708
diff changeset
918
30583
9c8b28dc6656 The hostname used for a bonjour account should always be the current machine
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29481
diff changeset
919 p = g_strdup_printf("%s%s%s", xf->sid, name, bonjour_get_jid(account));
21465
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
920 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
921 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
922 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
923
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
924 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
925 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
926 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
927 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
928
e489c81e1f6f Cleanup and fix the socks5 proxy connect address to be correct.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21441
diff changeset
929 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
930 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
931 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
932 purple_proxy_info_set_port(xf->proxy_info, xf->proxy_port);
31481
b671728e6ee9 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <daniel.atallah@gmail.com>
parents: 30583
diff changeset
933 xf->proxy_connection = purple_proxy_connect_socks5_account(
27119
d078048fb03a Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <mark@kingant.net>
parents: 25871
diff changeset
934 purple_account_get_connection(account),
31481
b671728e6ee9 Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <daniel.atallah@gmail.com>
parents: 30583
diff changeset
935 account,
27119
d078048fb03a Pass the gc as the handle in a bunch of calls to purple_proxy_connect
Mark Doliner <mark@kingant.net>
parents: 25871
diff changeset
936 xf->proxy_info,
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
937 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
938 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
939
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
940 if(xf->proxy_connection == NULL) {
31988
b6defcebfe4b Steps toward hiding PurpleXfer.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31979
diff changeset
941 xep_ft_si_reject(xf->data, xf->iq_id, purple_xfer_get_remote_user(xfer), "404", "cancel");
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
942 /* 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
943 purple_xfer_cancel_local(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
944 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
945 }
d8106b63b0a4 I thought I was just fixing a leak in this commit, but it turns out I forgot to add the new files in the previous commit.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
946