annotate libpurple/protocols/msn/directconn.c @ 31572:2201ecdf0c45

Add the slpcall as a parameter when creating a slpmsg.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 09 May 2011 06:44:45 +0000
parents 5de2d1b3669c
children 9a23c70bdb7a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file directconn.c MSN direct connection functions
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
4 * purple
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18431
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
30742
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30088
diff changeset
24
30758
230caecf5435 Include internal.h on each c file to avoid windows breakage as recommended by Daniel.
masca@cpw.pidgin.im
parents: 30742
diff changeset
25 #include "internal.h"
30742
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30088
diff changeset
26 #include "cipher.h"
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30088
diff changeset
27 #include "debug.h"
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 30088
diff changeset
28
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "msn.h"
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
30 #include "msnutils.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "directconn.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "slp.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "slpmsg.h"
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30758
diff changeset
35 #include "p2p.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
30053
56871d6c06fc I've seen packet sizes larger than our current maximum. Hopefully 8KiB is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30052
diff changeset
37 #define DC_MAX_BODY_SIZE 8*1024
30762
e03f912141dd Start moving p2p specific code to its own module.
masca@cpw.pidgin.im
parents: 30758
diff changeset
38 #define DC_MAX_PACKET_SIZE (P2P_PACKET_HEADER_SIZE + DC_MAX_BODY_SIZE)
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
39
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
40 static void
30041
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
41 msn_dc_calculate_nonce_hash(MsnDirectConnNonceType type,
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
42 const guchar nonce[16], gchar nonce_hash[37])
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 {
30019
bc720282a62d Clean up msn_dc_generate_nonce. It just looked weird.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30018
diff changeset
44 guchar digest[20];
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
30041
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
46 if (type == DC_NONCE_SHA1) {
30039
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
47 PurpleCipher *cipher = purple_ciphers_find_cipher("sha1");
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
48 PurpleCipherContext *context = purple_cipher_context_new(cipher, NULL);
30041
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
49 purple_cipher_context_append(context, nonce, sizeof(nonce));
30039
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
50 purple_cipher_context_digest(context, sizeof(digest), digest, NULL);
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
51 purple_cipher_context_destroy(context);
30041
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
52 } else if (type == DC_NONCE_PLAIN) {
30039
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
53 memcpy(digest, nonce, 16);
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
54 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55
30041
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
56 g_sprintf(nonce_hash,
30123
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
57 "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
58
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
59 digest[3],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
60 digest[2],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
61 digest[1],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
62 digest[0],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
63
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
64 digest[5],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
65 digest[4],
30120
ef7303c25751 For some reason, this line creates the following warning:
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30101
diff changeset
66
30123
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
67 digest[7],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
68 digest[6],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
69
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
70 digest[8],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
71 digest[9],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
72
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
73 digest[10],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
74 digest[11],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
75 digest[12],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
76 digest[13],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
77 digest[14],
f7e1d5d397b6 It's probably best just to be explicit about the ordering here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30120
diff changeset
78 digest[15]
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
79 );
30041
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
80 }
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
81
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
82 static void
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
83 msn_dc_generate_nonce(MsnDirectConn *dc)
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
84 {
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
85 guint32 *nonce;
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
86 int i;
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
87
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
88 nonce = (guint32 *)&dc->nonce;
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
89 for (i = 0; i < 4; i++)
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
90 nonce[i] = rand();
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
91
3affd3508612 Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30039
diff changeset
92 msn_dc_calculate_nonce_hash(dc->nonce_type, dc->nonce, dc->nonce_hash);
30037
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
93
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
94 if (purple_debug_is_verbose())
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
95 purple_debug_info("msn", "DC %p generated nonce %s\n", dc, dc->nonce_hash);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
96 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
30022
ca7dec8303cb This DC stuff is a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30021
diff changeset
98 static MsnDirectConnPacket *
30044
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
99 msn_dc_new_packet(guint32 length)
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
100 {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
101 MsnDirectConnPacket *p;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
103 p = g_new0(MsnDirectConnPacket, 1);
30045
63684aa5d6ab The length of a DC packet does not include itself.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30044
diff changeset
104 p->length = length;
30044
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
105 p->data = g_malloc(length);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
107 return p;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
110 static void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
111 msn_dc_destroy_packet(MsnDirectConnPacket *p)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
112 {
30023
ecd237d3f578 Minor cleanups.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30022
diff changeset
113 g_free(p->data);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
114
30805
dfada77da5cb Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents: 30804
diff changeset
115 if (p->part)
30847
74c4aa38adfc Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents: 30830
diff changeset
116 msn_slpmsgpart_unref(p->part);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
118 g_free(p);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
119 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
121 MsnDirectConn *
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
122 msn_dc_new(MsnSlpCall *slpcall)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
123 {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
124 MsnDirectConn *dc;
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
125
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
126 g_return_val_if_fail(slpcall != NULL, NULL);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
127
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
128 dc = g_new0(MsnDirectConn, 1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129
30024
db0f95b6a2cf Fix typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30023
diff changeset
130 if (purple_debug_is_verbose())
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
131 purple_debug_info("msn", "msn_dc_new %p\n", dc);
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
132
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
133 dc->slplink = slpcall->slplink;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
134 dc->slpcall = slpcall;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
135
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
136 if (dc->slplink->dc != NULL)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
137 purple_debug_warning("msn", "msn_dc_new: slplink already has an allocated DC!\n");
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
138
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
139 dc->slplink->dc = dc;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
141 dc->msg_body = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
142 dc->prev_ack = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
143 dc->listen_data = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
144 dc->connect_data = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
145 dc->listenfd = -1;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
146 dc->listenfd_handle = 0;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
147 dc->connect_timeout_handle = 0;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
148 dc->fd = -1;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
149 dc->recv_handle = 0;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
150 dc->send_handle = 0;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
151 dc->state = DC_STATE_CLOSED;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
152 dc->in_buffer = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
153 dc->out_queue = g_queue_new();
30044
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
154 dc->msg_pos = -1;
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
155 dc->send_connection_info_msg_cb = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
156 dc->ext_ip = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
157 dc->timeout_handle = 0;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
158 dc->progress = FALSE;
30080
3dac28d77320 C comments only.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30079
diff changeset
159 /*dc->num_calls = 1;*/
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160
30039
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
161 /* TODO: Probably should set this based on buddy caps */
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
162 dc->nonce_type = DC_NONCE_PLAIN;
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
163 msn_dc_generate_nonce(dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
164
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
165 return dc;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
166 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
168 void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
169 msn_dc_destroy(MsnDirectConn *dc)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
170 {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
171 MsnSlpLink *slplink;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
172
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
173 if (purple_debug_is_verbose())
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
174 purple_debug_info("msn", "msn_dc_destroy %p\n", dc);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
175
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
176 g_return_if_fail(dc != NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
178 if (dc->slpcall != NULL)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
179 dc->slpcall->wait_for_socket = FALSE;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
180
30088
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30080
diff changeset
181 slplink = dc->slplink;
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30080
diff changeset
182 if (slplink) {
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30080
diff changeset
183 slplink->dc = NULL;
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30080
diff changeset
184 if (slplink->swboard == NULL)
30830
e935d15725c3 Hide msn_slplink_destroy and use the unref version everywhere.
masca@cpw.pidgin.im
parents: 30805
diff changeset
185 msn_slplink_unref(slplink);
30088
e432507151d1 NULL-ify some reverse links so that there's no double-free on exit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30080
diff changeset
186 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187
30031
6d1894d0170e NULL-ing this stuff after free is nice in theory, but totally pointless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30024
diff changeset
188 g_free(dc->msg_body);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
189
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
190 if (dc->prev_ack) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
191 msn_slpmsg_destroy(dc->prev_ack);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
194 if (dc->listen_data != NULL) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
195 purple_network_listen_cancel(dc->listen_data);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
196 }
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
197
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
198 if (dc->connect_data != NULL) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
199 purple_proxy_connect_cancel(dc->connect_data);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
200 }
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
201
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
202 if (dc->listenfd != -1) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
203 purple_network_remove_port_mapping(dc->listenfd);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
204 close(dc->listenfd);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
205 }
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
206
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
207 if (dc->listenfd_handle != 0) {
30064
60ea80b5af53 This is not a timeout, but an input handler.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30063
diff changeset
208 purple_input_remove(dc->listenfd_handle);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
209 }
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
210
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
211 if (dc->connect_timeout_handle != 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
212 purple_timeout_remove(dc->connect_timeout_handle);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
213 }
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
214
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
215 if (dc->fd != -1) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
216 close(dc->fd);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
217 }
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
218
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
219 if (dc->send_handle != 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
220 purple_input_remove(dc->send_handle);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
221 }
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
222
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
223 if (dc->recv_handle != 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
224 purple_input_remove(dc->recv_handle);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226
30031
6d1894d0170e NULL-ing this stuff after free is nice in theory, but totally pointless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30024
diff changeset
227 g_free(dc->in_buffer);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
228
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
229 if (dc->out_queue != NULL) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
230 while (!g_queue_is_empty(dc->out_queue))
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
231 msn_dc_destroy_packet( g_queue_pop_head(dc->out_queue) );
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
233 g_queue_free(dc->out_queue);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
30031
6d1894d0170e NULL-ing this stuff after free is nice in theory, but totally pointless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30024
diff changeset
236 g_free(dc->ext_ip);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
238 if (dc->timeout_handle != 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
239 purple_timeout_remove(dc->timeout_handle);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
240 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
241
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
242 g_free(dc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
245 /*
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
246 void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
247 msn_dc_ref(MsnDirectConn *dc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 {
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
249 g_return_if_fail(dc != NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
251 dc->num_calls++;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 void
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
255 msn_dc_unref(MsnDirectConn *dc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 {
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
257 g_return_if_fail(dc != NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
259
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
260 if (dc->num_calls > 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
261 dc->num_calls--;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
262 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 }
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
264 */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 void
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
267 msn_dc_send_invite(MsnDirectConn *dc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
269 MsnSlpCall *slpcall;
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
270 MsnSlpMessage *msg;
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
271 gchar *header;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
272
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
273 if (purple_debug_is_verbose())
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
274 purple_debug_info("msn", "msn_dc_send_invite %p\n", dc);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
275
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
276 g_return_if_fail(dc != NULL);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
277
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
278 slpcall = dc->slpcall;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
279 g_return_if_fail(slpcall != NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
281 header = g_strdup_printf(
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
282 "INVITE MSNMSGR:%s MSNSLP/1.0",
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
283 slpcall->slplink->remote_user
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
284 );
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
285
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
286 msg = msn_slpmsg_sip_new(
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
287 slpcall,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
288 0,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
289 header,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
290 slpcall->branch,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
291 "application/x-msnmsgr-transrespbody",
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
292 dc->msg_body
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
293 );
30033
a613180bfeab Set some information for debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30032
diff changeset
294 msg->info = "DC INVITE";
a613180bfeab Set some information for debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30032
diff changeset
295 msg->text_body = TRUE;
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
296 g_free(header);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
297 g_free(dc->msg_body);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
298 dc->msg_body = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
300 msn_slplink_queue_slpmsg(slpcall->slplink, msg);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
301 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
302
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
303 void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
304 msn_dc_send_ok(MsnDirectConn *dc)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
305 {
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
306 if (purple_debug_is_verbose())
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
307 purple_debug_info("msn", "msn_dc_send_ok %p\n", dc);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
308
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
309 g_return_if_fail(dc != NULL);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
310
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
311 msn_slp_send_ok(dc->slpcall, dc->slpcall->branch,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
312 "application/x-msnmsgr-transrespbody", dc->msg_body);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
313 g_free(dc->msg_body);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
314 dc->msg_body = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
315
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
316 msn_slplink_send_slpmsg(dc->slpcall->slplink, dc->prev_ack);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
317 msn_slpmsg_destroy(dc->prev_ack);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
318 dc->prev_ack = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
319 msn_slplink_send_queued_slpmsgs(dc->slpcall->slplink);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321
30047
6936ffd13cb9 Make msn_dc_fallback_to_p2p non-static, and remove some old code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30045
diff changeset
322 void
30101
7f564cf26ea3 I think it's more accurate to say that a DC is a P2P transfer, so if that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
323 msn_dc_fallback_to_sb(MsnDirectConn *dc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 {
30067
ccae796bdbad Ref the slplink before destroying the DC, or we might lose our slpcall.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30066
diff changeset
325 MsnSlpLink *slplink;
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
326 MsnSlpCall *slpcall;
30070
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
327 GQueue *queue = NULL;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
328
30101
7f564cf26ea3 I think it's more accurate to say that a DC is a P2P transfer, so if that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
329 purple_debug_info("msn", "msn_dc_fallback_to_sb %p\n", dc);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
330
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
331 g_return_if_fail(dc != NULL);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
332
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
333 slpcall = dc->slpcall;
30067
ccae796bdbad Ref the slplink before destroying the DC, or we might lose our slpcall.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30066
diff changeset
334 slplink = msn_slplink_ref(dc->slplink);
30070
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
335 if (slpcall && !g_queue_is_empty(dc->out_queue)) {
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
336 queue = dc->out_queue;
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
337 dc->out_queue = NULL;
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
338 }
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
339
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
340 msn_dc_destroy(dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
341
30070
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
342 if (slpcall) {
30066
28f774432954 Use msn_dc_fallback_to_p2p where possible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30064
diff changeset
343 msn_slpcall_session_init(slpcall);
30070
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
344 if (queue) {
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
345 while (!g_queue_is_empty(queue)) {
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
346 MsnDirectConnPacket *p = g_queue_pop_head(queue);
30805
dfada77da5cb Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents: 30804
diff changeset
347 msn_slplink_send_msgpart(slplink, (MsnSlpMessage*)p->part->ack_data);
30070
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
348 msn_dc_destroy_packet(p);
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
349 }
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
350 g_queue_free(queue);
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
351 }
0b88a1b54475 If there's stuff stuck in the DC queue, then try to send it over the SB if
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30067
diff changeset
352 }
30067
ccae796bdbad Ref the slplink before destroying the DC, or we might lose our slpcall.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30066
diff changeset
353 msn_slplink_unref(slplink);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
354 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
355
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
356 static void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
357 msn_dc_send_cb(gpointer data, gint fd, PurpleInputCondition cond)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
358 {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
359 MsnDirectConn *dc = data;
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
360 MsnDirectConnPacket *p;
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
361 int bytes_to_send;
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
362 int bytes_sent;
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 15822
diff changeset
363
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
364 g_return_if_fail(dc != NULL);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
365 g_return_if_fail(fd != -1);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
366
30031
6d1894d0170e NULL-ing this stuff after free is nice in theory, but totally pointless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30024
diff changeset
367 if (g_queue_is_empty(dc->out_queue)) {
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
368 if (dc->send_handle != 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
369 purple_input_remove(dc->send_handle);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
370 dc->send_handle = 0;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
371 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
375 p = g_queue_peek_head(dc->out_queue);
30044
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
376
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
377 if (dc->msg_pos < 0) {
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
378 /* First we send the length of the packet */
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
379 guint32 len = GUINT32_TO_LE(p->length);
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
380 bytes_sent = send(fd, &len, 4, 0);
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
381 if (bytes_sent < 0) {
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
382 if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
383 return;
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
384
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
385 purple_debug_warning("msn", "msn_dc_send_cb: send error\n");
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
386 msn_dc_destroy(dc);
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
387 return;
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
388 }
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
389 dc->msg_pos = 0;
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
390 }
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
391
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
392 bytes_to_send = p->length - dc->msg_pos;
30050
99f81d97cbe6 I'm pretty sure we need to actually use dc->msg_pos for something, instead
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30049
diff changeset
393 bytes_sent = send(fd, p->data + dc->msg_pos, bytes_to_send, 0);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
394 if (bytes_sent < 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
395 if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
396 return;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
397
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
398 purple_debug_warning("msn", "msn_dc_send_cb: send error\n");
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
399 msn_dc_destroy(dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
400 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
403 dc->progress = TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
405 dc->msg_pos += bytes_sent;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
406 if (dc->msg_pos == p->length) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
407 if (p->sent_cb != NULL)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
408 p->sent_cb(p);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
410 g_queue_pop_head(dc->out_queue);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
411 msn_dc_destroy_packet(p);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
412
30044
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
413 dc->msg_pos = -1;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 static void
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
418 msn_dc_enqueue_packet(MsnDirectConn *dc, MsnDirectConnPacket *p)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
420 gboolean was_empty;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
421
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
422 was_empty = g_queue_is_empty(dc->out_queue);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
423 g_queue_push_tail(dc->out_queue, p);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
425 if (was_empty && dc->send_handle == 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
426 dc->send_handle = purple_input_add(dc->fd, PURPLE_INPUT_WRITE, msn_dc_send_cb, dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
427 msn_dc_send_cb(dc, dc->fd, PURPLE_INPUT_WRITE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430
20578
7c30d5aa5e01 Fix incorrect purple_proxy_connect() callback and comment out an unused function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20514
diff changeset
431 static void
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
432 msn_dc_send_foo(MsnDirectConn *dc)
20578
7c30d5aa5e01 Fix incorrect purple_proxy_connect() callback and comment out an unused function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20514
diff changeset
433 {
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
434 MsnDirectConnPacket *p;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
435
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
436 if (purple_debug_is_verbose())
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
437 purple_debug_info("msn", "msn_dc_send_foo %p\n", dc);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
438
30044
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
439 p = msn_dc_new_packet(4);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
440
30044
87854e2529a0 It seems like every DC packet requires a length, so why make every little
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30043
diff changeset
441 memcpy(p->data, "foo\0", 4);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
442
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
443 msn_dc_enqueue_packet(dc, p);
20578
7c30d5aa5e01 Fix incorrect purple_proxy_connect() callback and comment out an unused function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20514
diff changeset
444 }
7c30d5aa5e01 Fix incorrect purple_proxy_connect() callback and comment out an unused function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20514
diff changeset
445
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
446 #if 0 /* We don't actually need this */
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
447 typedef struct {
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
448 guint32 null;
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
449 guint32 id;
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
450 guint32 null[5];
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
451 guint32 flags;
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
452 guint8 nonce[16];
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
453 } MsnDirectConnNoncePacket;
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
454 #endif
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
455 #define DC_NONCE_PACKET_SIZE (8 * 4 + 16)
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
456 #define DC_NONCE_PACKET_NONCE (8 * 4)
30048
b491612862dc Try and reduce some code duplication.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30047
diff changeset
457
b491612862dc Try and reduce some code duplication.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30047
diff changeset
458 static void
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
459 msn_dc_send_handshake(MsnDirectConn *dc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
461 MsnDirectConnPacket *p;
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
462 gchar *h;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
463
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
464 p = msn_dc_new_packet(DC_NONCE_PACKET_SIZE);
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
465 h = (gchar *)p->data;
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
466
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
467 msn_push32le(h, 0); /* NUL */
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
468
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
469 msn_push32le(h, dc->slpcall->slplink->slp_seq_id++);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
471 /* More NUL stuff */
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
472 msn_push64le(h, 0);
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
473 msn_push64le(h, 0);
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
474 msn_push32le(h, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
476 /* Flags */
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
477 msn_push32le(h, P2P_DC_HANDSHAKE);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
478
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
479 /* The real Nonce, yay! */
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
480 memcpy(h, dc->nonce, 16);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
481
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
482 msn_dc_enqueue_packet(dc, p);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
483 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
484
30037
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
485 static gboolean
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
486 msn_dc_verify_handshake(MsnDirectConn *dc, guint32 packet_length)
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
487 {
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
488 guchar nonce[16];
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
489 gchar nonce_hash[37];
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
490
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
491 if (packet_length != DC_NONCE_PACKET_SIZE)
30037
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
492 return FALSE;
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
493
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
494 memcpy(nonce, dc->in_buffer + 4 + DC_NONCE_PACKET_NONCE, 16);
30037
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
495
30049
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
496 if (dc->nonce_type == DC_NONCE_PLAIN) {
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
497 if (memcmp(dc->nonce, nonce, 16) == 0) {
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
498 purple_debug_info("msn",
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
499 "Nonce from buddy request and nonce from DC attempt match, "
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
500 "allowing direct connection\n");
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
501 return TRUE;
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
502 } else {
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
503 purple_debug_warning("msn",
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
504 "Nonce from buddy request and nonce from DC attempt "
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
505 "don't match, ignoring direct connection\n");
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
506 return FALSE;
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
507 }
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
508
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
509 } else if (dc->nonce_type == DC_NONCE_SHA1) {
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
510 msn_dc_calculate_nonce_hash(dc->nonce_type, nonce, nonce_hash);
30037
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
511
30049
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
512 if (g_str_equal(dc->remote_nonce, nonce_hash)) {
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
513 purple_debug_info("msn",
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
514 "Received nonce %s from buddy request "
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
515 "and calculated nonce %s from DC attempt. "
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
516 "Nonces match, allowing direct connection\n",
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
517 dc->remote_nonce, nonce_hash);
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
518 return TRUE;
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
519 } else {
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
520 purple_debug_warning("msn",
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
521 "Received nonce %s from buddy request "
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
522 "and calculated nonce %s from DC attempt. "
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
523 "Nonces don't match, ignoring direct connection\n",
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
524 dc->remote_nonce, nonce_hash);
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
525 return FALSE;
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
526 }
b0a7b31dcc5d I think this finally works with both aMSN and the official client, for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30048
diff changeset
527 } else
30043
97942038af05 Obviously, if this comparison fails, I should be returning FALSE.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30042
diff changeset
528 return FALSE;
30037
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
529 }
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
530
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
531 static void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
532 msn_dc_send_packet_cb(MsnDirectConnPacket *p)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
533 {
30805
dfada77da5cb Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents: 30804
diff changeset
534 if (p->part != NULL && p->part->ack_cb != NULL)
dfada77da5cb Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents: 30804
diff changeset
535 p->part->ack_cb(p->part, p->part->ack_data);
dfada77da5cb Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents: 30804
diff changeset
536 }
dfada77da5cb Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents: 30804
diff changeset
537
30797
efe9b0338606 Add a function that enqueue a Part instead of a Message since directconn does not sends messages.
masca@cpw.pidgin.im
parents: 30784
diff changeset
538 void
efe9b0338606 Add a function that enqueue a Part instead of a Message since directconn does not sends messages.
masca@cpw.pidgin.im
parents: 30784
diff changeset
539 msn_dc_enqueue_part(MsnDirectConn *dc, MsnSlpMessagePart *part)
efe9b0338606 Add a function that enqueue a Part instead of a Message since directconn does not sends messages.
masca@cpw.pidgin.im
parents: 30784
diff changeset
540 {
efe9b0338606 Add a function that enqueue a Part instead of a Message since directconn does not sends messages.
masca@cpw.pidgin.im
parents: 30784
diff changeset
541 MsnDirectConnPacket *p;
31116
5de2d1b3669c Use the serializing function for SlpMsgParts on a direct connection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31095
diff changeset
542 size_t length;
30797
efe9b0338606 Add a function that enqueue a Part instead of a Message since directconn does not sends messages.
masca@cpw.pidgin.im
parents: 30784
diff changeset
543
31116
5de2d1b3669c Use the serializing function for SlpMsgParts on a direct connection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31095
diff changeset
544 p = msn_dc_new_packet(0);
5de2d1b3669c Use the serializing function for SlpMsgParts on a direct connection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31095
diff changeset
545 p->data = (guchar *)msn_slpmsgpart_serialize(part, &length);
5de2d1b3669c Use the serializing function for SlpMsgParts on a direct connection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31095
diff changeset
546 p->length = length - P2P_PACKET_FOOTER_SIZE; /* DC doesn't need footer? */
30797
efe9b0338606 Add a function that enqueue a Part instead of a Message since directconn does not sends messages.
masca@cpw.pidgin.im
parents: 30784
diff changeset
547
efe9b0338606 Add a function that enqueue a Part instead of a Message since directconn does not sends messages.
masca@cpw.pidgin.im
parents: 30784
diff changeset
548 p->sent_cb = msn_dc_send_packet_cb;
31037
0d5e038911a7 Correct the ref counts on the SlpMsgParts. When it's removed from the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31036
diff changeset
549 p->part = msn_slpmsgpart_ref(part);
30797
efe9b0338606 Add a function that enqueue a Part instead of a Message since directconn does not sends messages.
masca@cpw.pidgin.im
parents: 30784
diff changeset
550
efe9b0338606 Add a function that enqueue a Part instead of a Message since directconn does not sends messages.
masca@cpw.pidgin.im
parents: 30784
diff changeset
551 msn_dc_enqueue_packet(dc, p);
efe9b0338606 Add a function that enqueue a Part instead of a Message since directconn does not sends messages.
masca@cpw.pidgin.im
parents: 30784
diff changeset
552 }
efe9b0338606 Add a function that enqueue a Part instead of a Message since directconn does not sends messages.
masca@cpw.pidgin.im
parents: 30784
diff changeset
553
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
554 static int
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
555 msn_dc_process_packet(MsnDirectConn *dc, guint32 packet_length)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 {
30858
2d00d29a45fd Process SlpMessageParts, a sequence of parts will generate a SlpMessage.
masca@cpw.pidgin.im
parents: 30853
diff changeset
557 MsnSlpMessagePart *part;
2d00d29a45fd Process SlpMessageParts, a sequence of parts will generate a SlpMessage.
masca@cpw.pidgin.im
parents: 30853
diff changeset
558
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
559 g_return_val_if_fail(dc != NULL, DC_PROCESS_ERROR);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
560
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
561 switch (dc->state) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
562 case DC_STATE_CLOSED:
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
563 break;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
564
30023
ecd237d3f578 Minor cleanups.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30022
diff changeset
565 case DC_STATE_FOO:
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
566 /* FOO message is always 4 bytes long */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
567 if (packet_length != 4 || memcmp(dc->in_buffer, "\4\0\0\0foo", 8) != 0)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
568 return DC_PROCESS_FALLBACK;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
569
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
570 dc->state = DC_STATE_HANDSHAKE;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
571 break;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
572
30023
ecd237d3f578 Minor cleanups.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30022
diff changeset
573 case DC_STATE_HANDSHAKE:
30037
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
574 if (!msn_dc_verify_handshake(dc, packet_length))
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
575 return DC_PROCESS_FALLBACK;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
576
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
577 msn_dc_send_handshake(dc);
30015
bcb5e6c2e5a3 Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30014
diff changeset
578 dc->state = DC_STATE_ESTABLISHED;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
580 msn_slpcall_session_init(dc->slpcall);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
581 dc->slpcall = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
582 break;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
583
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
584 case DC_STATE_HANDSHAKE_REPLY:
30037
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
585 if (!msn_dc_verify_handshake(dc, packet_length))
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
586 return DC_PROCESS_FALLBACK;
4e532eedcab4 Save remote nonce, and verify we get the same data when initiating the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30033
diff changeset
587
30015
bcb5e6c2e5a3 Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30014
diff changeset
588 dc->state = DC_STATE_ESTABLISHED;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
589
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
590 msn_slpcall_session_init(dc->slpcall);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
591 dc->slpcall = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
592 break;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
593
30015
bcb5e6c2e5a3 Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30014
diff changeset
594 case DC_STATE_ESTABLISHED:
31088
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
595 if (packet_length) {
b55b3d34846c A direct connection really has no need of the whole P2P packet header,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31086
diff changeset
596 part = msn_slpmsgpart_new_from_data(dc->in_buffer + 4, packet_length);
31064
455406966695 Ignore short packets related to p2pv2.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31044
diff changeset
597 if (part) {
455406966695 Ignore short packets related to p2pv2.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31044
diff changeset
598 msn_slplink_process_msg(dc->slplink, part);
455406966695 Ignore short packets related to p2pv2.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31044
diff changeset
599 msn_slpmsgpart_unref(part);
455406966695 Ignore short packets related to p2pv2.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31044
diff changeset
600 }
30932
dec85cefc758 Don't attempt to process zero-length DC messages. We should probably
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30860
diff changeset
601 }
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
602
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
603 /*
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
604 if (dc->num_calls == 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
605 msn_dc_destroy(dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
606
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
607 return DC_PROCESS_CLOSE;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
608 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
609 */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
610 break;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
611 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
612
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
613 return DC_PROCESS_OK;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
616 static void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
617 msn_dc_recv_cb(gpointer data, gint fd, PurpleInputCondition cond)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618 {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
619 MsnDirectConn *dc;
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
620 int free_buf_space;
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
621 int bytes_received;
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
622 guint32 packet_length;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
623
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
624 g_return_if_fail(data != NULL);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
625 g_return_if_fail(fd != -1);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
626
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
627 dc = data;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
628 free_buf_space = dc->in_size - dc->in_pos;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
629
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
630 bytes_received = recv(fd, dc->in_buffer + dc->in_pos, free_buf_space, 0);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
631 if (bytes_received < 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
632 if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
633 return;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
634
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
635 purple_debug_warning("msn", "msn_dc_recv_cb: recv error\n");
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
636
30015
bcb5e6c2e5a3 Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30014
diff changeset
637 if(dc->state != DC_STATE_ESTABLISHED)
30101
7f564cf26ea3 I think it's more accurate to say that a DC is a P2P transfer, so if that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
638 msn_dc_fallback_to_sb(dc);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
639 else
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
640 msn_dc_destroy(dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
641 return;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
642
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
643 } else if (bytes_received == 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
644 /* EOF. Remote side closed connection. */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
645 purple_debug_info("msn", "msn_dc_recv_cb: recv EOF\n");
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
646
30015
bcb5e6c2e5a3 Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30014
diff changeset
647 if(dc->state != DC_STATE_ESTABLISHED)
30101
7f564cf26ea3 I think it's more accurate to say that a DC is a P2P transfer, so if that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
648 msn_dc_fallback_to_sb(dc);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
649 else
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
650 msn_dc_destroy(dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
651 return;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
652 }
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
653
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
654 dc->progress = TRUE;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
655
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
656 dc->in_pos += bytes_received;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
657
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
658 /* Wait for packet length */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
659 while (dc->in_pos >= 4) {
30053
56871d6c06fc I've seen packet sizes larger than our current maximum. Hopefully 8KiB is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30052
diff changeset
660 packet_length = GUINT32_FROM_LE(*((guint32*)dc->in_buffer));
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
661
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
662 if (packet_length > DC_MAX_PACKET_SIZE) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
663 /* Oversized packet */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
664 purple_debug_warning("msn", "msn_dc_recv_cb: oversized packet received\n");
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
665 return;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
666 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
668 /* Wait for the whole packet to arrive */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
669 if (dc->in_pos < 4 + packet_length)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
670 return;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
671
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
672 switch (msn_dc_process_packet(dc, packet_length)) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
673 case DC_PROCESS_CLOSE:
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
674 return;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
675
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
676 case DC_PROCESS_FALLBACK:
30101
7f564cf26ea3 I think it's more accurate to say that a DC is a P2P transfer, so if that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
677 purple_debug_warning("msn", "msn_dc_recv_cb: packet processing error, fall back to SB\n");
7f564cf26ea3 I think it's more accurate to say that a DC is a P2P transfer, so if that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
678 msn_dc_fallback_to_sb(dc);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
679 return;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
680
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
681 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
682
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
683 if (dc->in_pos > packet_length + 4) {
30054
531fe008410e Valgrind pointed out that dest and src may overlap, so we need to use
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30053
diff changeset
684 g_memmove(dc->in_buffer, dc->in_buffer + 4 + packet_length, dc->in_pos - packet_length - 4);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
685 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
686
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
687 dc->in_pos -= packet_length + 4;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
688 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
689 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
690
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
691 static gboolean
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
692 msn_dc_timeout(gpointer data)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
693 {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
694 MsnDirectConn *dc = data;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
695
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
696 g_return_val_if_fail(dc != NULL, FALSE);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
697
30062
783d736704b8 If removing a timeout and return FALSE in its handler isn't good, then
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30059
diff changeset
698 if (dc->progress) {
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
699 dc->progress = FALSE;
30062
783d736704b8 If removing a timeout and return FALSE in its handler isn't good, then
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30059
diff changeset
700 return TRUE;
783d736704b8 If removing a timeout and return FALSE in its handler isn't good, then
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30059
diff changeset
701 } else {
783d736704b8 If removing a timeout and return FALSE in its handler isn't good, then
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30059
diff changeset
702 dc->timeout_handle = 0;
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
703 msn_dc_destroy(dc);
30062
783d736704b8 If removing a timeout and return FALSE in its handler isn't good, then
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30059
diff changeset
704 return FALSE;
783d736704b8 If removing a timeout and return FALSE in its handler isn't good, then
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30059
diff changeset
705 }
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
706 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
707
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
708 static void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
709 msn_dc_init(MsnDirectConn *dc)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
710 {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
711 g_return_if_fail(dc != NULL);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
712
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
713 dc->in_size = DC_MAX_PACKET_SIZE + 4;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
714 dc->in_pos = 0;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
715 dc->in_buffer = g_malloc(dc->in_size);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
716
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
717 dc->recv_handle = purple_input_add(dc->fd, PURPLE_INPUT_READ, msn_dc_recv_cb, dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
718 dc->send_handle = purple_input_add(dc->fd, PURPLE_INPUT_WRITE, msn_dc_send_cb, dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
719
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
720 dc->timeout_handle = purple_timeout_add_seconds(DC_TIMEOUT, msn_dc_timeout, dc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
721 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723 void
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
724 msn_dc_connected_to_peer_cb(gpointer data, gint fd, const gchar *error_msg)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 {
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
726 MsnDirectConn *dc = data;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
727
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
728 if (purple_debug_is_verbose())
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
729 purple_debug_info("msn", "msn_dc_connected_to_peer_cb %p\n", dc);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
730
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
731 g_return_if_fail(dc != NULL);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
732
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
733 dc->connect_data = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
734 purple_timeout_remove(dc->connect_timeout_handle);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
735 dc->connect_timeout_handle = 0;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
736
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
737 dc->fd = fd;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
738 if (dc->fd != -1) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
739 msn_dc_init(dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
740 msn_dc_send_foo(dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
741 msn_dc_send_handshake(dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
742 dc->state = DC_STATE_HANDSHAKE_REPLY;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
743 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
744 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
745
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
746 /*
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
747 * This callback will be called when we're the server
30079
1aa1e1e1876d Make it more explicit that incoming and outgoing timeouts are different.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30070
diff changeset
748 * and nobody has connected us in DC_INCOMING_TIMEOUT seconds
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
749 */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
750 static gboolean
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
751 msn_dc_incoming_connection_timeout_cb(gpointer data) {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
752 MsnDirectConn *dc = data;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
753
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
754 if (purple_debug_is_verbose())
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
755 purple_debug_info("msn", "msn_dc_incoming_connection_timeout_cb %p\n", dc);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
756
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
757 g_return_val_if_fail(dc != NULL, FALSE);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
758
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
759 if (dc->listen_data != NULL) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
760 purple_network_listen_cancel(dc->listen_data);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
761 dc->listen_data = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
762 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
763
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
764 if (dc->listenfd_handle != 0) {
30064
60ea80b5af53 This is not a timeout, but an input handler.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30063
diff changeset
765 purple_input_remove(dc->listenfd_handle);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
766 dc->listenfd_handle = 0;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
767 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
768
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
769 if (dc->listenfd != -1) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
770 purple_network_remove_port_mapping(dc->listenfd);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
771 close(dc->listenfd);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
772 dc->listenfd = -1;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
773 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774
30056
f0de96a35877 This should probably work a bit better. At least, we want to get rid of any
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30054
diff changeset
775 dc->connect_timeout_handle = 0;
30101
7f564cf26ea3 I think it's more accurate to say that a DC is a P2P transfer, so if that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
776 msn_dc_fallback_to_sb(dc);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
777
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
778 return FALSE;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
779 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
780
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
781 /*
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
782 * This callback will be called when we're unable to connect to
30079
1aa1e1e1876d Make it more explicit that incoming and outgoing timeouts are different.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30070
diff changeset
783 * the remote host in DC_OUTGOING_TIMEOUT seconds.
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
784 */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
785 gboolean
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
786 msn_dc_outgoing_connection_timeout_cb(gpointer data)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
787 {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
788 MsnDirectConn *dc = data;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
789
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
790 purple_debug_info("msn", "msn_dc_outgoing_connection_timeout_cb %p\n", dc);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
791
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
792 g_return_val_if_fail(dc != NULL, FALSE);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
793
30059
a6642358155b We can't both remove a timeout and return FALSE in its callback.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30056
diff changeset
794 dc->connect_timeout_handle = 0;
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
795
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
796 if (dc->connect_data != NULL) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
797 purple_proxy_connect_cancel(dc->connect_data);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
798 dc->connect_data = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
799 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
800
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
801 if (dc->ext_ip && dc->ext_port) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
802 /* Try external IP/port if available. */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
803 dc->connect_data = purple_proxy_connect(
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
804 NULL,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
805 dc->slpcall->slplink->session->account,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
806 dc->ext_ip,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
807 dc->ext_port,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
808 msn_dc_connected_to_peer_cb,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
809 dc
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
810 );
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
811
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
812 g_free(dc->ext_ip);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
813 dc->ext_ip = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
814
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
815 if (dc->connect_data) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
816 dc->connect_timeout_handle = purple_timeout_add_seconds(
30079
1aa1e1e1876d Make it more explicit that incoming and outgoing timeouts are different.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30070
diff changeset
817 DC_OUTGOING_TIMEOUT,
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
818 msn_dc_outgoing_connection_timeout_cb,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
819 dc
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
820 );
30063
0662e5baada0 Fallback to P2P if connecting to external IP didn't work immediately.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30062
diff changeset
821 } else {
0662e5baada0 Fallback to P2P if connecting to external IP didn't work immediately.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30062
diff changeset
822 /*
0662e5baada0 Fallback to P2P if connecting to external IP didn't work immediately.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30062
diff changeset
823 * Connection failed
30101
7f564cf26ea3 I think it's more accurate to say that a DC is a P2P transfer, so if that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
824 * Fall back to SB transfer
30063
0662e5baada0 Fallback to P2P if connecting to external IP didn't work immediately.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30062
diff changeset
825 */
0662e5baada0 Fallback to P2P if connecting to external IP didn't work immediately.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30062
diff changeset
826 msn_dc_outgoing_connection_timeout_cb(dc);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
827 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
828
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
829 } else {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
830 /*
30059
a6642358155b We can't both remove a timeout and return FALSE in its callback.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30056
diff changeset
831 * Both internal and external connection attempts failed.
30101
7f564cf26ea3 I think it's more accurate to say that a DC is a P2P transfer, so if that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
832 * Fall back to SB transfer.
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
833 */
30101
7f564cf26ea3 I think it's more accurate to say that a DC is a P2P transfer, so if that
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30088
diff changeset
834 msn_dc_fallback_to_sb(dc);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
835 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
836
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
837 return FALSE;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
838 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
839
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
840 /*
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
841 * This callback will be called when we're the server
30079
1aa1e1e1876d Make it more explicit that incoming and outgoing timeouts are different.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30070
diff changeset
842 * and somebody has connected to us in DC_INCOMING_TIMEOUT seconds.
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
843 */
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
844 static void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
845 msn_dc_incoming_connection_cb(gpointer data, gint listenfd, PurpleInputCondition cond)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
846 {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
847 MsnDirectConn *dc = data;
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
848
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
849 if (purple_debug_is_verbose())
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
850 purple_debug_info("msn", "msn_dc_incoming_connection_cb %p\n", dc);
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
851
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
852 g_return_if_fail(dc != NULL);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
853
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
854 if (dc->connect_timeout_handle != 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
855 purple_timeout_remove(dc->connect_timeout_handle);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
856 dc->connect_timeout_handle = 0;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
857 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
858
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
859 if (dc->listenfd_handle != 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
860 purple_input_remove(dc->listenfd_handle);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
861 dc->listenfd_handle = 0;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
862 }
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
863
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
864 dc->fd = accept(listenfd, NULL, 0);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
865
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
866 purple_network_remove_port_mapping(dc->listenfd);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
867 close(dc->listenfd);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
868 dc->listenfd = -1;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
869
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
870 if (dc->fd != -1) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
871 msn_dc_init(dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
872 dc->state = DC_STATE_FOO;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
873 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
874 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
875
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
876 void
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
877 msn_dc_listen_socket_created_cb(int listenfd, gpointer data)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
878 {
30016
0ea33256f462 Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30015
diff changeset
879 MsnDirectConn *dc = data;
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
880
30021
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
881 if (purple_debug_is_verbose())
24579d001831 This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30020
diff changeset
882 purple_debug_info("msn", "msn_dc_listen_socket_created_cb %p\n", dc);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
883
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
884 g_return_if_fail(dc != NULL);
30014
b1cda3f8fdc9 De-spacify.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30013
diff changeset
885
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
886 dc->listen_data = NULL;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
887
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
888 if (listenfd != -1) {
30031
6d1894d0170e NULL-ing this stuff after free is nice in theory, but totally pointless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30024
diff changeset
889 const char *ext_ip;
6d1894d0170e NULL-ing this stuff after free is nice in theory, but totally pointless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30024
diff changeset
890 const char *int_ip;
6d1894d0170e NULL-ing this stuff after free is nice in theory, but totally pointless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30024
diff changeset
891 int port;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
893 ext_ip = purple_network_get_my_ip(listenfd);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
894 int_ip = purple_network_get_local_system_ip(listenfd);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
895 port = purple_network_get_port_from_fd(listenfd);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
896
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
897 dc->listenfd = listenfd;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
898 dc->listenfd_handle = purple_input_add(
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
899 listenfd,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
900 PURPLE_INPUT_READ,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
901 msn_dc_incoming_connection_cb,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
902 dc
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
903 );
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
904 dc->connect_timeout_handle = purple_timeout_add_seconds(
30079
1aa1e1e1876d Make it more explicit that incoming and outgoing timeouts are different.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30070
diff changeset
905 DC_INCOMING_TIMEOUT,
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
906 msn_dc_incoming_connection_timeout_cb,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
907 dc
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
908 );
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
909
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
910 if (strcmp(int_ip, ext_ip) != 0) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
911 dc->msg_body = g_strdup_printf(
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
912 "Bridge: TCPv1\r\n"
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
913 "Listening: true\r\n"
30039
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
914 "%sNonce: {%s}\r\n"
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
915 "IPv4External-Addrs: %s\r\n"
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
916 "IPv4External-Port: %d\r\n"
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
917 "IPv4Internal-Addrs: %s\r\n"
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
918 "IPv4Internal-Port: %d\r\n"
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
919 "\r\n",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
920
30039
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
921 dc->nonce_type != DC_NONCE_PLAIN ? "Hashed-" : "",
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
922 dc->nonce_hash,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
923 ext_ip,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
924 port,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
925 int_ip,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
926 port
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
927 );
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
928
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
929 } else {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
930 dc->msg_body = g_strdup_printf(
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
931 "Bridge: TCPv1\r\n"
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
932 "Listening: true\r\n"
30039
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
933 "%sNonce: {%s}\r\n"
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
934 "IPv4External-Addrs: %s\r\n"
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
935 "IPv4External-Port: %d\r\n"
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
936 "\r\n",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937
30039
a97d60c15e25 Support old-style Nonce, which should let us use direct connections to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30037
diff changeset
938 dc->nonce_type != DC_NONCE_PLAIN ? "Hashed-" : "",
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
939 dc->nonce_hash,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
940 ext_ip,
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
941 port
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
942 );
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
943 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
944
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
945 if (dc->slpcall->wait_for_socket) {
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
946 if (dc->send_connection_info_msg_cb != NULL)
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
947 dc->send_connection_info_msg_cb(dc);
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
948
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
949 dc->slpcall->wait_for_socket = FALSE;
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
950 }
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
951 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952 }
30013
119bd7b072eb Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents: 27893
diff changeset
953