Mercurial > pidgin
annotate libpurple/protocols/msn/directconn.c @ 32750:cc258d58ee56
merge of 'a6a5be7291d88240cd7a6b7034ac9942d5bfba4b'
and 'f1f5a7e9b4ed4a9ffe523909a8a68b49928f2731'
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 31 Mar 2012 21:29:04 +0000 |
parents | 4c7ebb2cf4d1 |
children |
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 | 4 * purple |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
15822 | 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); |
31597
4c7ebb2cf4d1
msn: Avoid reading uninit memory.
Paul Aurich <paul@darkrain42.org>
parents:
31584
diff
changeset
|
54 } else { |
4c7ebb2cf4d1
msn: Avoid reading uninit memory.
Paul Aurich <paul@darkrain42.org>
parents:
31584
diff
changeset
|
55 nonce_hash[0] = '\0'; |
4c7ebb2cf4d1
msn: Avoid reading uninit memory.
Paul Aurich <paul@darkrain42.org>
parents:
31584
diff
changeset
|
56 g_return_if_reached(); |
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
|
57 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 |
30041
3affd3508612
Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30039
diff
changeset
|
59 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
|
60 "%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
|
61 |
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[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
|
63 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
|
64 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
|
65 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
|
66 |
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[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
|
68 digest[4], |
30120
ef7303c25751
For some reason, this line creates the following warning:
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30101
diff
changeset
|
69 |
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
|
70 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
|
71 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
|
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[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
|
74 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
|
75 |
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[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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 digest[15] |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
82 ); |
30041
3affd3508612
Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30039
diff
changeset
|
83 } |
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 static void |
3affd3508612
Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30039
diff
changeset
|
86 msn_dc_generate_nonce(MsnDirectConn *dc) |
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 guint32 *nonce; |
3affd3508612
Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30039
diff
changeset
|
89 int i; |
3affd3508612
Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30039
diff
changeset
|
90 |
3affd3508612
Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30039
diff
changeset
|
91 nonce = (guint32 *)&dc->nonce; |
3affd3508612
Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30039
diff
changeset
|
92 for (i = 0; i < 4; i++) |
3affd3508612
Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30039
diff
changeset
|
93 nonce[i] = rand(); |
3affd3508612
Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30039
diff
changeset
|
94 |
3affd3508612
Remove some duplicate code.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30039
diff
changeset
|
95 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
|
96 |
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
|
97 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
|
98 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
|
99 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 |
30022
ca7dec8303cb
This DC stuff is a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30021
diff
changeset
|
101 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
|
102 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
|
103 { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
104 MsnDirectConnPacket *p; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
106 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
|
107 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
|
108 p->data = g_malloc(length); |
15373
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 return p; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
113 static void |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
114 msn_dc_destroy_packet(MsnDirectConnPacket *p) |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
115 { |
30023
ecd237d3f578
Minor cleanups.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30022
diff
changeset
|
116 g_free(p->data); |
30014 | 117 |
30805
dfada77da5cb
Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents:
30804
diff
changeset
|
118 if (p->part) |
30847
74c4aa38adfc
Add support to ref/unref SlpMessageParts.
masca@cpw.pidgin.im
parents:
30830
diff
changeset
|
119 msn_slpmsgpart_unref(p->part); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
121 g_free(p); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
122 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
124 MsnDirectConn * |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
125 msn_dc_new(MsnSlpCall *slpcall) |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
126 { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
127 MsnDirectConn *dc; |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
128 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
129 g_return_val_if_fail(slpcall != NULL, NULL); |
30014 | 130 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
131 dc = g_new0(MsnDirectConn, 1); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 |
30024 | 133 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
|
134 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
|
135 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
136 dc->slplink = slpcall->slplink; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
137 dc->slpcall = slpcall; |
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 if (dc->slplink->dc != NULL) |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
140 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
|
141 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
142 dc->slplink->dc = dc; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
144 dc->msg_body = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
145 dc->prev_ack = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
146 dc->listen_data = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
147 dc->connect_data = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
148 dc->listenfd = -1; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
149 dc->listenfd_handle = 0; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
150 dc->connect_timeout_handle = 0; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
151 dc->fd = -1; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
152 dc->recv_handle = 0; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
153 dc->send_handle = 0; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
154 dc->state = DC_STATE_CLOSED; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
155 dc->in_buffer = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
156 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
|
157 dc->msg_pos = -1; |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
158 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
|
159 dc->ext_ip = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
160 dc->timeout_handle = 0; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
161 dc->progress = FALSE; |
30080
3dac28d77320
C comments only.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30079
diff
changeset
|
162 /*dc->num_calls = 1;*/ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 |
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
|
164 /* 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
|
165 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
|
166 msn_dc_generate_nonce(dc); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
167 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
168 return dc; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
169 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
171 void |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
172 msn_dc_destroy(MsnDirectConn *dc) |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
173 { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
174 MsnSlpLink *slplink; |
30014 | 175 |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
176 if (purple_debug_is_verbose()) |
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
177 purple_debug_info("msn", "msn_dc_destroy %p\n", dc); |
30014 | 178 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
179 g_return_if_fail(dc != NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
181 if (dc->slpcall != NULL) |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
182 dc->slpcall->wait_for_socket = FALSE; |
30014 | 183 |
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
|
184 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
|
185 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
|
186 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
|
187 if (slplink->swboard == NULL) |
30830
e935d15725c3
Hide msn_slplink_destroy and use the unref version everywhere.
masca@cpw.pidgin.im
parents:
30805
diff
changeset
|
188 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
|
189 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 |
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
|
191 g_free(dc->msg_body); |
30014 | 192 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
193 if (dc->prev_ack) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
194 msn_slpmsg_destroy(dc->prev_ack); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
197 if (dc->listen_data != NULL) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
198 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
|
199 } |
30014 | 200 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
201 if (dc->connect_data != NULL) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
202 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
|
203 } |
30014 | 204 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
205 if (dc->listenfd != -1) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
206 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
|
207 close(dc->listenfd); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
208 } |
30014 | 209 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
210 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
|
211 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
|
212 } |
30014 | 213 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
214 if (dc->connect_timeout_handle != 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
215 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
|
216 } |
30014 | 217 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
218 if (dc->fd != -1) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
219 close(dc->fd); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
220 } |
30014 | 221 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
222 if (dc->send_handle != 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
223 purple_input_remove(dc->send_handle); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
224 } |
30014 | 225 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
226 if (dc->recv_handle != 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
227 purple_input_remove(dc->recv_handle); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 |
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
|
230 g_free(dc->in_buffer); |
30014 | 231 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
232 if (dc->out_queue != NULL) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
233 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
|
234 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
|
235 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
236 g_queue_free(dc->out_queue); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 |
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
|
239 g_free(dc->ext_ip); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
241 if (dc->timeout_handle != 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
242 purple_timeout_remove(dc->timeout_handle); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
243 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
244 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
245 g_free(dc); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
248 /* |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
249 void |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
250 msn_dc_ref(MsnDirectConn *dc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 { |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
252 g_return_if_fail(dc != NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
254 dc->num_calls++; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 void |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
258 msn_dc_unref(MsnDirectConn *dc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 { |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
260 g_return_if_fail(dc != NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 |
30014 | 262 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
263 if (dc->num_calls > 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
264 dc->num_calls--; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
265 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 } |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
267 */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 void |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
270 msn_dc_send_invite(MsnDirectConn *dc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
272 MsnSlpCall *slpcall; |
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
273 MsnSlpMessage *msg; |
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
274 gchar *header; |
30014 | 275 |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
276 if (purple_debug_is_verbose()) |
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
277 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
|
278 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
279 g_return_if_fail(dc != NULL); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
280 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
281 slpcall = dc->slpcall; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
282 g_return_if_fail(slpcall != NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
284 header = g_strdup_printf( |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
285 "INVITE MSNMSGR:%s MSNSLP/1.0", |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
286 slpcall->slplink->remote_user |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
287 ); |
30014 | 288 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
289 msg = msn_slpmsg_sip_new( |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
290 slpcall, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
291 0, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
292 header, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
293 slpcall->branch, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
294 "application/x-msnmsgr-transrespbody", |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
295 dc->msg_body |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
296 ); |
30033
a613180bfeab
Set some information for debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30032
diff
changeset
|
297 msg->info = "DC INVITE"; |
a613180bfeab
Set some information for debugging.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30032
diff
changeset
|
298 msg->text_body = TRUE; |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
299 g_free(header); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
300 g_free(dc->msg_body); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
301 dc->msg_body = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
303 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
|
304 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
305 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
306 void |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
307 msn_dc_send_ok(MsnDirectConn *dc) |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
308 { |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
309 if (purple_debug_is_verbose()) |
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
310 purple_debug_info("msn", "msn_dc_send_ok %p\n", dc); |
30014 | 311 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
312 g_return_if_fail(dc != NULL); |
30014 | 313 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
314 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
|
315 "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
|
316 g_free(dc->msg_body); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
317 dc->msg_body = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
318 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
319 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
|
320 msn_slpmsg_destroy(dc->prev_ack); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
321 dc->prev_ack = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
322 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
|
323 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 |
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
|
325 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
|
326 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
|
327 { |
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
|
328 MsnSlpLink *slplink; |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
329 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
|
330 GQueue *queue = NULL; |
30014 | 331 |
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
|
332 purple_debug_info("msn", "msn_dc_fallback_to_sb %p\n", dc); |
30014 | 333 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
334 g_return_if_fail(dc != NULL); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
335 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
336 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
|
337 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
|
338 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
|
339 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
|
340 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
|
341 } |
30014 | 342 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
343 msn_dc_destroy(dc); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
344 |
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
|
345 if (slpcall) { |
30066
28f774432954
Use msn_dc_fallback_to_p2p where possible.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30064
diff
changeset
|
346 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
|
347 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
|
348 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
|
349 MsnDirectConnPacket *p = g_queue_pop_head(queue); |
30805
dfada77da5cb
Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents:
30804
diff
changeset
|
350 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
|
351 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
|
352 } |
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
|
353 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
|
354 } |
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
|
355 } |
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
|
356 msn_slplink_unref(slplink); |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
357 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
358 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
359 static void |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
360 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
|
361 { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
362 MsnDirectConn *dc = data; |
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
363 MsnDirectConnPacket *p; |
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
364 int bytes_to_send; |
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
365 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
|
366 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
367 g_return_if_fail(dc != NULL); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
368 g_return_if_fail(fd != -1); |
30014 | 369 |
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
|
370 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
|
371 if (dc->send_handle != 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
372 purple_input_remove(dc->send_handle); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
373 dc->send_handle = 0; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
374 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
378 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
|
379 |
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 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
|
381 /* 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 |
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 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
|
389 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
|
390 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
|
391 } |
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
|
392 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
|
393 } |
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
|
394 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
395 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
|
396 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
|
397 if (bytes_sent < 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
398 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
399 return; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
400 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
401 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
|
402 msn_dc_destroy(dc); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
403 return; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
406 dc->progress = TRUE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
408 dc->msg_pos += bytes_sent; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
409 if (dc->msg_pos == p->length) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
410 if (p->sent_cb != NULL) |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
411 p->sent_cb(p); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
413 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
|
414 msn_dc_destroy_packet(p); |
30014 | 415 |
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
|
416 dc->msg_pos = -1; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 static void |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
421 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
|
422 { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
423 gboolean was_empty; |
30014 | 424 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
425 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
|
426 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
|
427 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
428 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
|
429 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
|
430 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
|
431 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 |
20578
7c30d5aa5e01
Fix incorrect purple_proxy_connect() callback and comment out an unused function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20514
diff
changeset
|
434 static void |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
435 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
|
436 { |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
437 MsnDirectConnPacket *p; |
30014 | 438 |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
439 if (purple_debug_is_verbose()) |
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
440 purple_debug_info("msn", "msn_dc_send_foo %p\n", dc); |
30014 | 441 |
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
|
442 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
|
443 |
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
|
444 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
|
445 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
446 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
|
447 } |
7c30d5aa5e01
Fix incorrect purple_proxy_connect() callback and comment out an unused function.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20514
diff
changeset
|
448 |
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
|
449 #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
|
450 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
|
451 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
|
452 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
|
453 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
|
454 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
|
455 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
|
456 } 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
|
457 #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
|
458 #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
|
459 #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
|
460 |
b491612862dc
Try and reduce some code duplication.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30047
diff
changeset
|
461 static void |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
462 msn_dc_send_handshake(MsnDirectConn *dc) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
463 { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
464 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
|
465 gchar *h; |
30014 | 466 |
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
|
467 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
|
468 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
|
469 |
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
|
470 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
|
471 |
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_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
|
473 |
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
|
474 /* 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
|
475 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
|
476 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
|
477 msn_push32le(h, 0); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
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 /* 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
|
480 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
|
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 /* 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
|
483 memcpy(h, dc->nonce, 16); |
30014 | 484 |
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
|
485 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
|
486 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
487 |
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
|
488 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
|
489 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
|
490 { |
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
|
491 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
|
492 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
|
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 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
|
495 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
|
496 |
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
|
497 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
|
498 |
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
|
499 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
|
500 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
|
501 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
|
502 "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
|
503 "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
|
504 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
|
505 } 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
|
506 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
|
507 "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
|
508 "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
|
509 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
|
510 } |
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
|
511 |
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 } 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
|
513 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
|
514 |
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
|
515 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
|
516 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
|
517 "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
|
518 "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
|
519 "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
|
520 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
|
521 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
|
522 } 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
|
523 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
|
524 "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
|
525 "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
|
526 "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
|
527 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
|
528 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
|
529 } |
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
|
530 } else |
30043
97942038af05
Obviously, if this comparison fails, I should be returning FALSE.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30042
diff
changeset
|
531 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
|
532 } |
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
|
533 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
534 static void |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
535 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
|
536 { |
30805
dfada77da5cb
Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents:
30804
diff
changeset
|
537 if (p->part != NULL && p->part->ack_cb != NULL) |
dfada77da5cb
Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents:
30804
diff
changeset
|
538 p->part->ack_cb(p->part, p->part->ack_data); |
dfada77da5cb
Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents:
30804
diff
changeset
|
539 } |
dfada77da5cb
Reomove MsnMessage reference from DirectConn.
masca@cpw.pidgin.im
parents:
30804
diff
changeset
|
540 |
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
|
541 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
|
542 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
|
543 { |
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
|
544 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
|
545 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
|
546 |
31116
5de2d1b3669c
Use the serializing function for SlpMsgParts on a direct connection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31095
diff
changeset
|
547 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
|
548 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
|
549 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
|
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 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
|
552 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
|
553 |
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
|
554 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
|
555 } |
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
|
556 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
557 static int |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
558 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
|
559 { |
30858
2d00d29a45fd
Process SlpMessageParts, a sequence of parts will generate a SlpMessage.
masca@cpw.pidgin.im
parents:
30853
diff
changeset
|
560 MsnSlpMessagePart *part; |
2d00d29a45fd
Process SlpMessageParts, a sequence of parts will generate a SlpMessage.
masca@cpw.pidgin.im
parents:
30853
diff
changeset
|
561 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
562 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
|
563 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
564 switch (dc->state) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
565 case DC_STATE_CLOSED: |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
566 break; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
567 |
30023
ecd237d3f578
Minor cleanups.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30022
diff
changeset
|
568 case DC_STATE_FOO: |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
569 /* 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
|
570 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
|
571 return DC_PROCESS_FALLBACK; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
572 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
573 dc->state = DC_STATE_HANDSHAKE; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
574 break; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
575 |
30023
ecd237d3f578
Minor cleanups.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30022
diff
changeset
|
576 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
|
577 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
|
578 return DC_PROCESS_FALLBACK; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
579 |
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
|
580 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
|
581 dc->state = DC_STATE_ESTABLISHED; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
583 msn_slpcall_session_init(dc->slpcall); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
584 dc->slpcall = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
585 break; |
30014 | 586 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
587 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
|
588 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
|
589 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
|
590 |
30015
bcb5e6c2e5a3
Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30014
diff
changeset
|
591 dc->state = DC_STATE_ESTABLISHED; |
30014 | 592 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
593 msn_slpcall_session_init(dc->slpcall); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
594 dc->slpcall = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
595 break; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
596 |
30015
bcb5e6c2e5a3
Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30014
diff
changeset
|
597 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
|
598 if (packet_length) { |
31577
9a23c70bdb7a
Get the P2P version based on the user. Still hard-coded as v1 though.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31116
diff
changeset
|
599 MsnP2PVersion p2p; |
31584
cf702c6ab9e7
Getting the P2P version is probably the slplink's job, since it has
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31577
diff
changeset
|
600 p2p = msn_slplink_get_p2p_version(dc->slplink); |
31577
9a23c70bdb7a
Get the P2P version based on the user. Still hard-coded as v1 though.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31116
diff
changeset
|
601 part = msn_slpmsgpart_new_from_data(p2p, 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
|
602 if (part) { |
455406966695
Ignore short packets related to p2pv2.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31044
diff
changeset
|
603 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
|
604 msn_slpmsgpart_unref(part); |
455406966695
Ignore short packets related to p2pv2.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31044
diff
changeset
|
605 } |
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
|
606 } |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
607 |
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 if (dc->num_calls == 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
610 msn_dc_destroy(dc); |
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 return DC_PROCESS_CLOSE; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
613 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
614 */ |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
615 break; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
616 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
617 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
618 return DC_PROCESS_OK; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
621 static void |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
622 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
|
623 { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
624 MsnDirectConn *dc; |
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
625 int free_buf_space; |
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
626 int bytes_received; |
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
627 guint32 packet_length; |
30014 | 628 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
629 g_return_if_fail(data != NULL); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
630 g_return_if_fail(fd != -1); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
631 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
632 dc = data; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
633 free_buf_space = dc->in_size - dc->in_pos; |
30014 | 634 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
635 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
|
636 if (bytes_received < 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
637 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
638 return; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
639 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
640 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
|
641 |
30015
bcb5e6c2e5a3
Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30014
diff
changeset
|
642 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
|
643 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
|
644 else |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
645 msn_dc_destroy(dc); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
646 return; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
647 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
648 } else if (bytes_received == 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
649 /* EOF. Remote side closed connection. */ |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
650 purple_debug_info("msn", "msn_dc_recv_cb: recv EOF\n"); |
30014 | 651 |
30015
bcb5e6c2e5a3
Re-indent directconn.h, and fix a typo.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30014
diff
changeset
|
652 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
|
653 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
|
654 else |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
655 msn_dc_destroy(dc); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
656 return; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
657 } |
30014 | 658 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
659 dc->progress = TRUE; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
660 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
661 dc->in_pos += bytes_received; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
662 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
663 /* Wait for packet length */ |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
664 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
|
665 packet_length = GUINT32_FROM_LE(*((guint32*)dc->in_buffer)); |
30014 | 666 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
667 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
|
668 /* Oversized packet */ |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
669 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
|
670 return; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
671 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
672 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
673 /* 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
|
674 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
|
675 return; |
30014 | 676 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
677 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
|
678 case DC_PROCESS_CLOSE: |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
679 return; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
680 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
681 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
|
682 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
|
683 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
|
684 return; |
30014 | 685 |
30013
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 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
688 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
|
689 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
|
690 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
691 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
692 dc->in_pos -= packet_length + 4; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
693 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
694 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
695 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
696 static gboolean |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
697 msn_dc_timeout(gpointer data) |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
698 { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
699 MsnDirectConn *dc = data; |
30014 | 700 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
701 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
|
702 |
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
|
703 if (dc->progress) { |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
704 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
|
705 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
|
706 } 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
|
707 dc->timeout_handle = 0; |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
708 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
|
709 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
|
710 } |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
711 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
712 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
713 static void |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
714 msn_dc_init(MsnDirectConn *dc) |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
715 { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
716 g_return_if_fail(dc != NULL); |
30014 | 717 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
718 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
|
719 dc->in_pos = 0; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
720 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
|
721 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
722 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
|
723 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
|
724 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
725 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
|
726 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
727 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
728 void |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
729 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
|
730 { |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
731 MsnDirectConn *dc = data; |
30014 | 732 |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
733 if (purple_debug_is_verbose()) |
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
734 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
|
735 |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
736 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
|
737 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
738 dc->connect_data = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
739 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
|
740 dc->connect_timeout_handle = 0; |
30014 | 741 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
742 dc->fd = fd; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
743 if (dc->fd != -1) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
744 msn_dc_init(dc); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
745 msn_dc_send_foo(dc); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
746 msn_dc_send_handshake(dc); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
747 dc->state = DC_STATE_HANDSHAKE_REPLY; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
748 } |
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 |
30014 | 751 /* |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
752 * 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
|
753 * 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
|
754 */ |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
755 static gboolean |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
756 msn_dc_incoming_connection_timeout_cb(gpointer data) { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
757 MsnDirectConn *dc = data; |
30014 | 758 |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
759 if (purple_debug_is_verbose()) |
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
760 purple_debug_info("msn", "msn_dc_incoming_connection_timeout_cb %p\n", dc); |
30014 | 761 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
762 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
|
763 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
764 if (dc->listen_data != NULL) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
765 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
|
766 dc->listen_data = NULL; |
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_handle != 0) { |
30064
60ea80b5af53
This is not a timeout, but an input handler.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30063
diff
changeset
|
770 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
|
771 dc->listenfd_handle = 0; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
772 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
773 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
774 if (dc->listenfd != -1) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
775 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
|
776 close(dc->listenfd); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
777 dc->listenfd = -1; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
778 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
779 |
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
|
780 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
|
781 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
|
782 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
783 return FALSE; |
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 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
786 /* |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
787 * 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
|
788 * 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
|
789 */ |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
790 gboolean |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
791 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
|
792 { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
793 MsnDirectConn *dc = data; |
30014 | 794 |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
795 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
|
796 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
797 g_return_val_if_fail(dc != NULL, FALSE); |
30014 | 798 |
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
|
799 dc->connect_timeout_handle = 0; |
30013
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->connect_data != NULL) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
802 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
|
803 dc->connect_data = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
804 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
805 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
806 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
|
807 /* Try external IP/port if available. */ |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
808 dc->connect_data = purple_proxy_connect( |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
809 NULL, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
810 dc->slpcall->slplink->session->account, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
811 dc->ext_ip, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
812 dc->ext_port, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
813 msn_dc_connected_to_peer_cb, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
814 dc |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
815 ); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
816 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
817 g_free(dc->ext_ip); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
818 dc->ext_ip = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
819 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
820 if (dc->connect_data) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
821 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
|
822 DC_OUTGOING_TIMEOUT, |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
823 msn_dc_outgoing_connection_timeout_cb, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
824 dc |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
825 ); |
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
|
826 } 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
|
827 /* |
0662e5baada0
Fallback to P2P if connecting to external IP didn't work immediately.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30062
diff
changeset
|
828 * 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
|
829 * 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
|
830 */ |
0662e5baada0
Fallback to P2P if connecting to external IP didn't work immediately.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30062
diff
changeset
|
831 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
|
832 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
833 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
834 } else { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
835 /* |
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
|
836 * 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
|
837 * Fall back to SB transfer. |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
838 */ |
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
|
839 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
|
840 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
841 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
842 return FALSE; |
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 |
30014 | 845 /* |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
846 * 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
|
847 * 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
|
848 */ |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
849 static void |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
850 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
|
851 { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
852 MsnDirectConn *dc = data; |
30014 | 853 |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
854 if (purple_debug_is_verbose()) |
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
855 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
|
856 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
857 g_return_if_fail(dc != NULL); |
30014 | 858 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
859 if (dc->connect_timeout_handle != 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
860 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
|
861 dc->connect_timeout_handle = 0; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
862 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
863 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
864 if (dc->listenfd_handle != 0) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
865 purple_input_remove(dc->listenfd_handle); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
866 dc->listenfd_handle = 0; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
867 } |
30014 | 868 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
869 dc->fd = accept(listenfd, NULL, 0); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
870 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
871 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
|
872 close(dc->listenfd); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
873 dc->listenfd = -1; |
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 if (dc->fd != -1) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
876 msn_dc_init(dc); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
877 dc->state = DC_STATE_FOO; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
878 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
879 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
880 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
881 void |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
882 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
|
883 { |
30016
0ea33256f462
Tabs-to-spaces.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30015
diff
changeset
|
884 MsnDirectConn *dc = data; |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
885 |
30021
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
886 if (purple_debug_is_verbose()) |
24579d001831
This DC stuff seems a bit verbose.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30020
diff
changeset
|
887 purple_debug_info("msn", "msn_dc_listen_socket_created_cb %p\n", dc); |
30014 | 888 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
889 g_return_if_fail(dc != NULL); |
30014 | 890 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
891 dc->listen_data = NULL; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
892 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
893 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
|
894 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
|
895 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
|
896 int port; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
897 |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
898 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
|
899 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
|
900 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
|
901 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
902 dc->listenfd = listenfd; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
903 dc->listenfd_handle = purple_input_add( |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
904 listenfd, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
905 PURPLE_INPUT_READ, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
906 msn_dc_incoming_connection_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 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
|
910 DC_INCOMING_TIMEOUT, |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
911 msn_dc_incoming_connection_timeout_cb, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
912 dc |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
913 ); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
914 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
915 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
|
916 dc->msg_body = g_strdup_printf( |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
917 "Bridge: TCPv1\r\n" |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
918 "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
|
919 "%sNonce: {%s}\r\n" |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
920 "IPv4External-Addrs: %s\r\n" |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
921 "IPv4External-Port: %d\r\n" |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
922 "IPv4Internal-Addrs: %s\r\n" |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
923 "IPv4Internal-Port: %d\r\n" |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
924 "\r\n", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
925 |
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
|
926 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
|
927 dc->nonce_hash, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
928 ext_ip, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
929 port, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
930 int_ip, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
931 port |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
932 ); |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
933 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
934 } else { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
935 dc->msg_body = g_strdup_printf( |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
936 "Bridge: TCPv1\r\n" |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
937 "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
|
938 "%sNonce: {%s}\r\n" |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
939 "IPv4External-Addrs: %s\r\n" |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
940 "IPv4External-Port: %d\r\n" |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
941 "\r\n", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 |
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
|
943 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
|
944 dc->nonce_hash, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
945 ext_ip, |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
946 port |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
947 ); |
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 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
950 if (dc->slpcall->wait_for_socket) { |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
951 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
|
952 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
|
953 |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
954 dc->slpcall->wait_for_socket = FALSE; |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
955 } |
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
956 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 } |
30013
119bd7b072eb
Initial support for direct connections. Preliminary patch from ticket #247
kukkerman@gmail.com
parents:
27893
diff
changeset
|
958 |