Mercurial > pidgin.yaz
annotate libpurple/protocols/gg/lib/dcc7.c @ 32357:1aa7d06e30c0
The id field is unused
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 21 Aug 2011 18:00:53 +0000 |
parents | 3a90a59ddea2 |
children | 9c9143e32b6c |
rev | line source |
---|---|
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1 /* $Id: dcc7.c 1087 2011-04-14 20:53:25Z wojtekka $ */ |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
3 /* |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
4 * (C) Copyright 2001-2010 Wojtek Kaniewski <wojtekka@irc.pl> |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
5 * Tomasz Chiliński <chilek@chilan.com> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
6 * Adam Wysocki <gophi@ekg.chmurka.net> |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
7 * Bartłomiej Zimoń <uzi18@o2.pl> |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
8 * |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
9 * Thanks to Jakub Zawadzki <darkjames@darkjames.ath.cx> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
10 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
11 * This program is free software; you can redistribute it and/or modify |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
12 * it under the terms of the GNU Lesser General Public License Version |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
13 * 2.1 as published by the Free Software Foundation. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
14 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
18 * GNU Lesser General Public License for more details. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
19 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
20 * You should have received a copy of the GNU Lesser General Public |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
21 * License along with this program; if not, write to the Free Software |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
23 * USA. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
24 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
25 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
26 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
27 * \file dcc7.c |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
28 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
29 * \brief Obsługa połączeń bezpośrednich od wersji Gadu-Gadu 7.x |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
30 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
31 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
32 #include <sys/types.h> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
33 #include <sys/stat.h> |
29939
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
diff
changeset
|
34 #ifndef _WIN32 |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
diff
changeset
|
35 # include <sys/ioctl.h> |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
diff
changeset
|
36 # include <sys/socket.h> |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
diff
changeset
|
37 # include <netinet/in.h> |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
diff
changeset
|
38 # include <arpa/inet.h> |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
diff
changeset
|
39 # ifdef sun |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
diff
changeset
|
40 # include <sys/filio.h> |
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
diff
changeset
|
41 # endif |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
42 #endif |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
43 #include <time.h> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
44 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
45 #include <ctype.h> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
46 #include <errno.h> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
47 #include <fcntl.h> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
48 #include <stdarg.h> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
49 #include <string.h> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
50 #include <stdio.h> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
51 #include <stdlib.h> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
52 #include <unistd.h> |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
53 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
54 #include "compat.h" |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
55 #include "libgadu.h" |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
56 #include "protocol.h" |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
57 #include "resolver.h" |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
58 #include "libgadu-internal.h" |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
59 #include "libgadu-debug.h" |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
60 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
61 #define gg_debug_dcc(dcc, level, fmt...) \ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
62 gg_debug_session(((dcc) != NULL) ? (dcc)->sess : NULL, level, fmt) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
63 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
64 #define gg_debug_dump_dcc(dcc, level, buf, len) \ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
65 gg_debug_dump(((dcc) != NULL) ? (dcc)->sess : NULL, level, buf, len) |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
66 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
67 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
68 * \internal Dodaje połączenie bezpośrednie do sesji. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
69 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
70 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
71 * \param dcc Struktura połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
72 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
73 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
74 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
75 static int gg_dcc7_session_add(struct gg_session *sess, struct gg_dcc7 *dcc) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
76 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
77 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_session_add(%p, %p)\n", sess, dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
78 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
79 if (!sess || !dcc || dcc->next) { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
80 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_session_add() invalid parameters\n"); |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
81 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
82 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
83 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
84 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
85 dcc->next = sess->dcc7_list; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
86 sess->dcc7_list = dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
87 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
88 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
89 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
90 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
91 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
92 * \internal Usuwa połączenie bezpośrednie z sesji. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
93 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
94 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
95 * \param dcc Struktura połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
96 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
97 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
98 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
99 static int gg_dcc7_session_remove(struct gg_session *sess, struct gg_dcc7 *dcc) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
100 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
101 struct gg_dcc7 *tmp; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
102 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
103 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_session_remove(%p, %p)\n", sess, dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
104 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
105 if (sess == NULL || dcc == NULL) { |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
106 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_session_remove() invalid parameters\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
107 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
108 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
109 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
110 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
111 if (sess->dcc7_list == dcc) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
112 sess->dcc7_list = dcc->next; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
113 dcc->next = NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
114 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
115 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
116 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
117 for (tmp = sess->dcc7_list; tmp != NULL; tmp = tmp->next) { |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
118 if (tmp->next == dcc) { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
119 tmp->next = dcc->next; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
120 dcc->next = NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
121 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
122 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
123 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
124 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
125 errno = ENOENT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
126 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
127 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
128 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
129 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
130 * \internal Zwraca strukturę połączenia o danym identyfikatorze. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
131 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
132 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
133 * \param id Identyfikator połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
134 * \param uin Numer nadawcy lub odbiorcy |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
135 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
136 * \return Struktura połączenia lub \c NULL jeśli nie znaleziono |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
137 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
138 static struct gg_dcc7 *gg_dcc7_session_find(struct gg_session *sess, gg_dcc7_id_t id, uin_t uin) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
139 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
140 struct gg_dcc7 *tmp; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
141 int empty; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
142 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
143 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_session_find(%p, ..., %d)\n", sess, (int) uin); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
144 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
145 empty = !memcmp(&id, "\0\0\0\0\0\0\0\0", 8); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
146 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
147 for (tmp = sess->dcc7_list; tmp; tmp = tmp->next) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
148 if (empty) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
149 if (tmp->peer_uin == uin && !tmp->state == GG_STATE_WAITING_FOR_ACCEPT) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
150 return tmp; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
151 } else { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
152 if (!memcmp(&tmp->cid, &id, sizeof(id))) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
153 return tmp; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
154 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
155 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
156 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
157 return NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
158 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
159 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
160 /** |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
161 * \internal Rozpoczyna proces pobierania adresu |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
162 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
163 * \param dcc Struktura połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
164 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
165 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
166 */ |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
167 static int gg_dcc7_get_relay_addr(struct gg_dcc7 *dcc) |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
168 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
169 gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_get_relay_addr(%p)\n", dcc); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
170 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
171 if (dcc == NULL || dcc->sess == NULL) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
172 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_get_relay_addr() invalid parameters\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
173 errno = EINVAL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
174 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
175 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
176 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
177 if (dcc->sess->resolver_start(&dcc->fd, &dcc->resolver, GG_RELAY_HOST) == -1) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
178 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_get_relay_addr() resolving failed (errno=%d, %s)\n", errno, strerror(errno)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
179 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
180 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
181 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
182 dcc->state = GG_STATE_RESOLVING_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
183 dcc->check = GG_CHECK_READ; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
184 dcc->timeout = GG_DEFAULT_TIMEOUT; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
185 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
186 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
187 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
188 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
189 /** |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
190 * \internal Nawiązuje połączenie bezpośrednie |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
191 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
192 * \param dcc Struktura połączenia |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
193 * |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
194 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
195 */ |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
196 static int gg_dcc7_connect(struct gg_dcc7 *dcc) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
197 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
198 gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_connect(%p)\n", dcc); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
199 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
200 if (dcc == NULL) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
201 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_connect() invalid parameters\n"); |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
202 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
203 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
204 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
205 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
206 if ((dcc->fd = gg_connect(&dcc->remote_addr, dcc->remote_port, 1)) == -1) { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
207 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_connect() connection failed\n"); |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
208 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
209 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
210 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
211 dcc->state = GG_STATE_CONNECTING; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
212 dcc->check = GG_CHECK_WRITE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
213 dcc->timeout = GG_DCC7_TIMEOUT_CONNECT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
214 dcc->soft_timeout = 1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
215 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
216 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
217 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
218 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
219 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
220 * \internal Tworzy gniazdo nasłuchujące dla połączenia bezpośredniego |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
221 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
222 * \param dcc Struktura połączenia |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
223 * \param addr Preferowany adres (jeśli równy 0, nasłuchujemy na wszystkich interfejsach) |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
224 * \param port Preferowany port (jeśli równy 0, nasłuchujemy na losowym) |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
225 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
226 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
227 */ |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
228 static int gg_dcc7_listen(struct gg_dcc7 *dcc, uint32_t addr, uint16_t port) |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
229 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
230 struct sockaddr_in sin; |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
231 socklen_t sin_len = sizeof(sin); |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
232 int errsv; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
233 int fd; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
234 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
235 gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_listen(%p, %d)\n", dcc, port); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
236 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
237 if (!dcc) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
238 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_listen() invalid parameters\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
239 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
240 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
241 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
242 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
243 if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
244 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_listen() can't create socket (%s)\n", strerror(errno)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
245 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
246 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
247 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
248 sin.sin_family = AF_INET; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
249 sin.sin_addr.s_addr = addr; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
250 sin.sin_port = htons(port); |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
251 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
252 if (bind(fd, (struct sockaddr*) &sin, sizeof(sin)) == -1) { |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
253 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_listen() unable to bind to %s:%d\n", inet_ntoa(sin.sin_addr), port); |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
254 goto fail; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
255 } |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
256 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
257 if (port == 0 && getsockname(fd, (struct sockaddr*) &sin, &sin_len) == -1) { |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
258 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_listen() unable to bind to port %d\n", port); |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
259 goto fail; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
260 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
261 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
262 if (listen(fd, 1)) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
263 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_listen() unable to listen (%s)\n", strerror(errno)); |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
264 goto fail; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
265 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
266 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
267 dcc->fd = fd; |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
268 dcc->local_addr = sin.sin_addr.s_addr; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
269 dcc->local_port = ntohs(sin.sin_port); |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
270 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
271 dcc->state = GG_STATE_LISTENING; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
272 dcc->check = GG_CHECK_READ; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
273 dcc->timeout = GG_DCC7_TIMEOUT_FILE_ACK; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
274 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
275 return 0; |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
276 |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
277 fail: |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
278 errsv = errno; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
279 close(fd); |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
280 errno = errsv; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
281 return -1; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
282 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
283 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
284 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
285 * \internal Tworzy gniazdo nasłuchujące i wysyła jego parametry |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
286 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
287 * \param dcc Struktura połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
288 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
289 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
290 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
291 static int gg_dcc7_listen_and_send_info(struct gg_dcc7 *dcc) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
292 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
293 struct gg_dcc7_info pkt; |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
294 uint16_t external_port; |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
295 uint32_t external_addr; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
296 struct in_addr addr; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
297 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
298 gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_listen_and_send_info(%p)\n", dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
299 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
300 if (gg_dcc7_listen(dcc, dcc->sess->client_addr, dcc->sess->client_port) == -1) |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
301 return -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
302 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
303 if (dcc->sess->external_port != 0) |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
304 external_port = dcc->sess->external_port; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
305 else |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
306 external_port = dcc->local_port; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
307 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
308 if (dcc->sess->external_addr != 0) |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
309 external_addr = dcc->sess->external_addr; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
310 else |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
311 external_addr = dcc->local_addr; |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
312 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
313 addr.s_addr = external_addr; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
314 |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
315 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// dcc7_listen_and_send_info() sending IP address %s and port %d\n", inet_ntoa(addr), external_port); |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
316 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
317 memset(&pkt, 0, sizeof(pkt)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
318 pkt.uin = gg_fix32(dcc->peer_uin); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
319 pkt.type = GG_DCC7_TYPE_P2P; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
320 pkt.id = dcc->cid; |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
321 snprintf((char*) pkt.info, sizeof(pkt.info), "%s %d", inet_ntoa(addr), external_port); |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
322 snprintf((char*) pkt.hash, sizeof(pkt.hash), "%u", external_addr + external_port * rand()); |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
323 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
324 return gg_send_packet(dcc->sess, GG_DCC7_INFO, &pkt, sizeof(pkt), NULL); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
325 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
326 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
327 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
328 * \internal Odwraca połączenie po nieudanym connect() |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
329 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
330 * \param dcc Struktura połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
331 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
332 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
333 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
334 static int gg_dcc7_reverse_connect(struct gg_dcc7 *dcc) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
335 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
336 gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_reverse_connect(%p)\n", dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
337 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
338 if (dcc->reverse) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
339 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_reverse_connect() already reverse connection\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
340 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
341 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
342 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
343 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_reverse_connect() timeout, trying reverse connection\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
344 close(dcc->fd); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
345 dcc->fd = -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
346 dcc->reverse = 1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
347 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
348 return gg_dcc7_listen_and_send_info(dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
349 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
350 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
351 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
352 * \internal Wysyła do serwera żądanie nadania identyfikatora sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
353 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
354 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
355 * \param type Rodzaj połączenia (\c GG_DCC7_TYPE_FILE lub \c GG_DCC7_TYPE_VOICE) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
356 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
357 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
358 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
359 static int gg_dcc7_request_id(struct gg_session *sess, uint32_t type) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
360 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
361 struct gg_dcc7_id_request pkt; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
362 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
363 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_request_id(%p, %d)\n", sess, type); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
364 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
365 if (!sess) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
366 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_request_id() invalid parameters\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
367 errno = EFAULT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
368 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
369 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
370 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
371 if (sess->state != GG_STATE_CONNECTED) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
372 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_request_id() not connected\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
373 errno = ENOTCONN; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
374 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
375 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
376 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
377 if (type != GG_DCC7_TYPE_VOICE && type != GG_DCC7_TYPE_FILE) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
378 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_request_id() invalid transfer type (%d)\n", type); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
379 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
380 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
381 } |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
382 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
383 memset(&pkt, 0, sizeof(pkt)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
384 pkt.type = gg_fix32(type); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
385 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
386 return gg_send_packet(sess, GG_DCC7_ID_REQUEST, &pkt, sizeof(pkt), NULL); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
387 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
388 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
389 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
390 * \internal Rozpoczyna wysyłanie pliku. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
391 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
392 * Funkcja jest wykorzystywana przez \c gg_dcc7_send_file() oraz |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
393 * \c gg_dcc_send_file_fd(). |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
394 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
395 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
396 * \param rcpt Numer odbiorcy |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
397 * \param fd Deskryptor pliku |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
398 * \param size Rozmiar pliku |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
399 * \param filename1250 Nazwa pliku w kodowaniu CP-1250 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
400 * \param hash Skrót SHA-1 pliku |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
401 * \param seek Flaga mówiąca, czy można używać lseek() |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
402 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
403 * \return Struktura \c gg_dcc7 lub \c NULL w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
404 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
405 * \ingroup dcc7 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
406 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
407 static struct gg_dcc7 *gg_dcc7_send_file_common(struct gg_session *sess, uin_t rcpt, int fd, size_t size, const char *filename1250, const char *hash, int seek) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
408 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
409 struct gg_dcc7 *dcc = NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
410 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
411 if (!sess || !rcpt || !filename1250 || !hash || fd == -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
412 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_send_file_common() invalid parameters\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
413 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
414 goto fail; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
415 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
416 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
417 if (!(dcc = malloc(sizeof(struct gg_dcc7)))) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
418 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_send_file_common() not enough memory\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
419 goto fail; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
420 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
421 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
422 if (gg_dcc7_request_id(sess, GG_DCC7_TYPE_FILE) == -1) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
423 goto fail; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
424 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
425 memset(dcc, 0, sizeof(struct gg_dcc7)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
426 dcc->type = GG_SESSION_DCC7_SEND; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
427 dcc->dcc_type = GG_DCC7_TYPE_FILE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
428 dcc->state = GG_STATE_REQUESTING_ID; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
429 dcc->timeout = GG_DEFAULT_TIMEOUT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
430 dcc->sess = sess; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
431 dcc->fd = -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
432 dcc->uin = sess->uin; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
433 dcc->peer_uin = rcpt; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
434 dcc->file_fd = fd; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
435 dcc->size = size; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
436 dcc->seek = seek; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
437 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
438 strncpy((char*) dcc->filename, filename1250, GG_DCC7_FILENAME_LEN - 1); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
439 dcc->filename[GG_DCC7_FILENAME_LEN] = 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
440 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
441 memcpy(dcc->hash, hash, GG_DCC7_HASH_LEN); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
442 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
443 if (gg_dcc7_session_add(sess, dcc) == -1) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
444 goto fail; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
445 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
446 return dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
447 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
448 fail: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
449 free(dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
450 return NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
451 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
452 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
453 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
454 * Rozpoczyna wysyłanie pliku o danej nazwie. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
455 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
456 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
457 * \param rcpt Numer odbiorcy |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
458 * \param filename Nazwa pliku w lokalnym systemie plików |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
459 * \param filename1250 Nazwa pliku w kodowaniu CP-1250 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
460 * \param hash Skrót SHA-1 pliku (lub \c NULL jeśli ma być wyznaczony) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
461 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
462 * \return Struktura \c gg_dcc7 lub \c NULL w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
463 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
464 * \ingroup dcc7 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
465 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
466 struct gg_dcc7 *gg_dcc7_send_file(struct gg_session *sess, uin_t rcpt, const char *filename, const char *filename1250, const char *hash) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
467 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
468 struct gg_dcc7 *dcc = NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
469 const char *tmp; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
470 char hash_buf[GG_DCC7_HASH_LEN]; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
471 struct stat st; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
472 int fd = -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
473 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
474 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_send_file(%p, %d, \"%s\", %p)\n", sess, rcpt, filename, hash); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
475 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
476 if (!sess || !rcpt || !filename) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
477 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_send_file() invalid parameters\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
478 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
479 goto fail; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
480 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
481 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
482 if (!filename1250) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
483 filename1250 = filename; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
484 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
485 if (stat(filename, &st) == -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
486 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_send_file() stat() failed (%s)\n", strerror(errno)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
487 goto fail; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
488 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
489 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
490 if ((st.st_mode & S_IFDIR)) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
491 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_send_file() that's a directory\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
492 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
493 goto fail; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
494 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
495 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
496 if ((fd = open(filename, O_RDONLY)) == -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
497 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_send_file() open() failed (%s)\n", strerror(errno)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
498 goto fail; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
499 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
500 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
501 if (!hash) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
502 if (gg_file_hash_sha1(fd, (uint8_t*) hash_buf) == -1) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
503 goto fail; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
504 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
505 hash = hash_buf; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
506 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
507 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
508 if ((tmp = strrchr(filename1250, '/'))) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
509 filename1250 = tmp + 1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
510 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
511 if (!(dcc = gg_dcc7_send_file_common(sess, rcpt, fd, st.st_size, filename1250, hash, 1))) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
512 goto fail; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
513 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
514 return dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
515 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
516 fail: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
517 if (fd != -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
518 int errsv = errno; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
519 close(fd); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
520 errno = errsv; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
521 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
522 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
523 free(dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
524 return NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
525 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
526 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
527 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
528 * \internal Rozpoczyna wysyłanie pliku o danym deskryptorze. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
529 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
530 * \note Wysyłanie pliku nie będzie działać poprawnie, jeśli deskryptor |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
531 * źródłowy jest w trybie nieblokującym i w pewnym momencie zabraknie danych. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
532 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
533 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
534 * \param rcpt Numer odbiorcy |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
535 * \param fd Deskryptor pliku |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
536 * \param size Rozmiar pliku |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
537 * \param filename1250 Nazwa pliku w kodowaniu CP-1250 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
538 * \param hash Skrót SHA-1 pliku |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
539 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
540 * \return Struktura \c gg_dcc7 lub \c NULL w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
541 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
542 * \ingroup dcc7 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
543 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
544 struct gg_dcc7 *gg_dcc7_send_file_fd(struct gg_session *sess, uin_t rcpt, int fd, size_t size, const char *filename1250, const char *hash) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
545 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
546 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_send_file_fd(%p, %d, %d, %u, \"%s\", %p)\n", sess, rcpt, fd, size, filename1250, hash); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
547 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
548 return gg_dcc7_send_file_common(sess, rcpt, fd, size, filename1250, hash, 0); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
549 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
550 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
551 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
552 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
553 * Potwierdza chęć odebrania pliku. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
554 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
555 * \param dcc Struktura połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
556 * \param offset Początkowy offset przy wznawianiu przesyłania pliku |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
557 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
558 * \note Biblioteka nie zmienia położenia w odbieranych plikach. Jeśli offset |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
559 * początkowy jest różny od zera, należy ustawić go funkcją \c lseek() lub |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
560 * podobną. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
561 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
562 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
563 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
564 * \ingroup dcc7 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
565 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
566 int gg_dcc7_accept(struct gg_dcc7 *dcc, unsigned int offset) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
567 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
568 struct gg_dcc7_accept pkt; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
569 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
570 gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_accept(%p, %d)\n", dcc, offset); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
571 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
572 if (!dcc || !dcc->sess) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
573 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_accept() invalid parameters\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
574 errno = EFAULT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
575 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
576 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
577 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
578 memset(&pkt, 0, sizeof(pkt)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
579 pkt.uin = gg_fix32(dcc->peer_uin); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
580 pkt.id = dcc->cid; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
581 pkt.offset = gg_fix32(offset); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
582 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
583 if (gg_send_packet(dcc->sess, GG_DCC7_ACCEPT, &pkt, sizeof(pkt), NULL) == -1) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
584 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
585 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
586 dcc->offset = offset; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
587 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
588 return gg_dcc7_listen_and_send_info(dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
589 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
590 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
591 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
592 * Odrzuca próbę przesłania pliku. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
593 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
594 * \param dcc Struktura połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
595 * \param reason Powód odrzucenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
596 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
597 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
598 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
599 * \ingroup dcc7 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
600 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
601 int gg_dcc7_reject(struct gg_dcc7 *dcc, int reason) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
602 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
603 struct gg_dcc7_reject pkt; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
604 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
605 gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_reject(%p, %d)\n", dcc, reason); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
606 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
607 if (!dcc || !dcc->sess) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
608 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_reject() invalid parameters\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
609 errno = EFAULT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
610 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
611 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
612 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
613 memset(&pkt, 0, sizeof(pkt)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
614 pkt.uin = gg_fix32(dcc->peer_uin); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
615 pkt.id = dcc->cid; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
616 pkt.reason = gg_fix32(reason); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
617 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
618 return gg_send_packet(dcc->sess, GG_DCC7_REJECT, &pkt, sizeof(pkt), NULL); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
619 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
620 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
621 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
622 * \internal Obsługuje pakiet identyfikatora połączenia bezpośredniego. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
623 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
624 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
625 * \param e Struktura zdarzenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
626 * \param payload Treść pakietu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
627 * \param len Długość pakietu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
628 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
629 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
630 */ |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
631 int gg_dcc7_handle_id(struct gg_session *sess, struct gg_event *e, const void *payload, int len) |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
632 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
633 const struct gg_dcc7_id_reply *p = payload; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
634 struct gg_dcc7 *tmp; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
635 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
636 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_handle_id(%p, %p, %p, %d)\n", sess, e, payload, len); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
637 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
638 for (tmp = sess->dcc7_list; tmp; tmp = tmp->next) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
639 gg_debug_session(sess, GG_DEBUG_MISC, "// checking dcc %p, state %d, type %d\n", tmp, tmp->state, tmp->dcc_type); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
640 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
641 if (tmp->state != GG_STATE_REQUESTING_ID || tmp->dcc_type != gg_fix32(p->type)) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
642 continue; |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
643 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
644 tmp->cid = p->id; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
645 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
646 switch (tmp->dcc_type) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
647 case GG_DCC7_TYPE_FILE: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
648 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
649 struct gg_dcc7_new s; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
650 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
651 memset(&s, 0, sizeof(s)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
652 s.id = tmp->cid; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
653 s.type = gg_fix32(GG_DCC7_TYPE_FILE); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
654 s.uin_from = gg_fix32(tmp->uin); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
655 s.uin_to = gg_fix32(tmp->peer_uin); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
656 s.size = gg_fix32(tmp->size); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
657 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
658 strncpy((char*) s.filename, (char*) tmp->filename, GG_DCC7_FILENAME_LEN); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
659 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
660 tmp->state = GG_STATE_WAITING_FOR_ACCEPT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
661 tmp->timeout = GG_DCC7_TIMEOUT_FILE_ACK; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
662 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
663 return gg_send_packet(sess, GG_DCC7_NEW, &s, sizeof(s), NULL); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
664 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
665 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
666 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
667 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
668 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
669 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
670 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
671 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
672 * \internal Obsługuje pakiet akceptacji połączenia bezpośredniego. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
673 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
674 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
675 * \param e Struktura zdarzenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
676 * \param payload Treść pakietu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
677 * \param len Długość pakietu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
678 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
679 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
680 */ |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
681 int gg_dcc7_handle_accept(struct gg_session *sess, struct gg_event *e, const void *payload, int len) |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
682 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
683 const struct gg_dcc7_accept *p = payload; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
684 struct gg_dcc7 *dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
685 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
686 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_handle_accept(%p, %p, %p, %d)\n", sess, e, payload, len); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
687 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
688 if (!(dcc = gg_dcc7_session_find(sess, p->id, gg_fix32(p->uin)))) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
689 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_accept() unknown dcc session\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
690 // XXX wysłać reject? |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
691 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
692 e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
693 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
694 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
695 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
696 if (dcc->state != GG_STATE_WAITING_FOR_ACCEPT) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
697 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_accept() invalid state\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
698 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
699 e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
700 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
701 } |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
702 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
703 // XXX czy dla odwrotnego połączenia powinniśmy wywołać już zdarzenie GG_DCC7_ACCEPT? |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
704 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
705 dcc->offset = gg_fix32(p->offset); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
706 dcc->state = GG_STATE_WAITING_FOR_INFO; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
707 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
708 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
709 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
710 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
711 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
712 * \internal Obsługuje pakiet informacji o połączeniu bezpośrednim. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
713 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
714 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
715 * \param e Struktura zdarzenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
716 * \param payload Treść pakietu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
717 * \param len Długość pakietu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
718 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
719 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
720 */ |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
721 int gg_dcc7_handle_info(struct gg_session *sess, struct gg_event *e, const void *payload, int len) |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
722 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
723 const struct gg_dcc7_info *p = payload; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
724 struct gg_dcc7 *dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
725 char *tmp; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
726 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
727 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_handle_info(%p, %p, %p, %d)\n", sess, e, payload, len); |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
728 gg_debug_session(sess, GG_DEBUG_FUNCTION, "// gg_dcc7_handle_info() received address: %s, hash: %s\n", p->info, p->hash); |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
729 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
730 if (!(dcc = gg_dcc7_session_find(sess, p->id, gg_fix32(p->uin)))) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
731 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() unknown dcc session\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
732 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
733 } |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
734 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
735 if (dcc->state == GG_STATE_CONNECTED) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
736 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() state is already connected\n"); |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
737 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
738 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
739 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
740 switch (p->type) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
741 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
742 case GG_DCC7_TYPE_P2P: |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
743 if ((dcc->remote_addr = inet_addr(p->info)) == INADDR_NONE) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
744 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid IP address\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
745 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
746 e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
747 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
748 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
749 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
750 if (!(tmp = strchr(p->info, ' ')) || !(dcc->remote_port = atoi(tmp + 1))) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
751 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid IP port\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
752 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
753 e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
754 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
755 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
756 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
757 if (dcc->state == GG_STATE_WAITING_FOR_INFO) { |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
758 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() waiting for info so send one\n"); |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
759 gg_dcc7_listen_and_send_info(dcc); |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
760 e->type = GG_EVENT_DCC7_PENDING; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
761 e->event.dcc7_pending.dcc7 = dcc; |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
762 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
763 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
764 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
765 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
766 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
767 case GG_DCC7_TYPE_SERVER: |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
768 if (!(tmp = strstr(p->info, "GG"))) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
769 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() unknown info packet\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
770 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
771 e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
772 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
773 } |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
774 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
775 #if defined(HAVE_UINT64_T) && defined(HAVE_STRTOULL) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
776 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
777 uint64_t cid; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
778 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
779 cid = strtoull(tmp + 2, NULL, 0); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
780 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
781 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() info.str=%s, info.id=%llu, sess.id=%llu\n", tmp + 2, cid, *((unsigned long long*) &dcc->cid)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
782 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
783 cid = gg_fix64(cid); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
784 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
785 if (memcmp(&dcc->cid, &cid, sizeof(cid)) != 0) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
786 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid session id\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
787 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
788 e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
789 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
790 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
791 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
792 #endif |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
793 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
794 if (gg_dcc7_get_relay_addr(dcc) == -1) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
795 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_handle_info() unable to retrieve relay address\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
796 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
797 e->event.dcc7_error = GG_ERROR_DCC7_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
798 return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
799 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
800 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
801 // XXX wysyłać dopiero jeśli uda się połączyć z serwerem? |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
802 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
803 gg_send_packet(dcc->sess, GG_DCC7_INFO, payload, len, NULL); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
804 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
805 return 0; |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
806 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
807 default: |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
808 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() unhandled transfer type (%d)\n", p->type); |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
809 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
810 e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
811 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
812 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
813 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
814 // jeśli nadal czekamy na połączenie przychodzące, a druga strona nie |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
815 // daje rady i oferuje namiary na siebie, bierzemy co dają. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
816 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
817 // if (dcc->state != GG_STATE_WAITING_FOR_INFO && (dcc->state != GG_STATE_LISTENING || dcc->reverse)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
818 // gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid state\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
819 // e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
820 // e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
821 // return 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
822 // } |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
823 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
824 if (dcc->state == GG_STATE_LISTENING) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
825 close(dcc->fd); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
826 dcc->fd = -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
827 dcc->reverse = 1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
828 } |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
829 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
830 if (dcc->type == GG_SESSION_DCC7_SEND) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
831 e->type = GG_EVENT_DCC7_ACCEPT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
832 e->event.dcc7_accept.dcc7 = dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
833 e->event.dcc7_accept.type = gg_fix32(p->type); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
834 e->event.dcc7_accept.remote_ip = dcc->remote_addr; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
835 e->event.dcc7_accept.remote_port = dcc->remote_port; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
836 } else { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
837 e->type = GG_EVENT_DCC7_PENDING; |
31415
a42f7d3ad459
Update internal/external libgadu to 1.9.0, except for some superfluous
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
29939
diff
changeset
|
838 e->event.dcc7_pending.dcc7 = dcc; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
839 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
840 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
841 if (gg_dcc7_connect(dcc) == -1) { |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
842 if (gg_dcc7_reverse_connect(dcc) == -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
843 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
844 e->event.dcc7_error = GG_ERROR_DCC7_NET; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
845 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
846 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
847 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
848 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
849 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
850 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
851 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
852 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
853 * \internal Obsługuje pakiet odrzucenia połączenia bezpośredniego. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
854 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
855 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
856 * \param e Struktura zdarzenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
857 * \param payload Treść pakietu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
858 * \param len Długość pakietu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
859 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
860 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
861 */ |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
862 int gg_dcc7_handle_reject(struct gg_session *sess, struct gg_event *e, const void *payload, int len) |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
863 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
864 const struct gg_dcc7_reject *p = payload; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
865 struct gg_dcc7 *dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
866 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
867 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_handle_reject(%p, %p, %p, %d)\n", sess, e, payload, len); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
868 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
869 if (!(dcc = gg_dcc7_session_find(sess, p->id, gg_fix32(p->uin)))) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
870 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_reject() unknown dcc session\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
871 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
872 } |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
873 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
874 if (dcc->state != GG_STATE_WAITING_FOR_ACCEPT) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
875 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_reject() invalid state\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
876 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
877 e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
878 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
879 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
880 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
881 e->type = GG_EVENT_DCC7_REJECT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
882 e->event.dcc7_reject.dcc7 = dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
883 e->event.dcc7_reject.reason = gg_fix32(p->reason); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
884 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
885 // XXX ustawić state na rejected? |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
886 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
887 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
888 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
889 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
890 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
891 * \internal Obsługuje pakiet nowego połączenia bezpośredniego. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
892 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
893 * \param sess Struktura sesji |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
894 * \param e Struktura zdarzenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
895 * \param payload Treść pakietu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
896 * \param len Długość pakietu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
897 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
898 * \return 0 jeśli się powiodło, -1 w przypadku błędu |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
899 */ |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
900 int gg_dcc7_handle_new(struct gg_session *sess, struct gg_event *e, const void *payload, int len) |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
901 { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
902 const struct gg_dcc7_new *p = payload; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
903 struct gg_dcc7 *dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
904 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
905 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_handle_new(%p, %p, %p, %d)\n", sess, e, payload, len); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
906 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
907 switch (gg_fix32(p->type)) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
908 case GG_DCC7_TYPE_FILE: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
909 if (!(dcc = malloc(sizeof(struct gg_dcc7)))) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
910 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_new() not enough memory\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
911 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
912 } |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
913 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
914 memset(dcc, 0, sizeof(struct gg_dcc7)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
915 dcc->type = GG_SESSION_DCC7_GET; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
916 dcc->dcc_type = GG_DCC7_TYPE_FILE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
917 dcc->fd = -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
918 dcc->file_fd = -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
919 dcc->uin = sess->uin; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
920 dcc->peer_uin = gg_fix32(p->uin_from); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
921 dcc->cid = p->id; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
922 dcc->sess = sess; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
923 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
924 if (gg_dcc7_session_add(sess, dcc) == -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
925 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_new() unable to add to session\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
926 gg_dcc7_free(dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
927 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
928 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
929 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
930 dcc->size = gg_fix32(p->size); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
931 strncpy((char*) dcc->filename, (char*) p->filename, GG_DCC7_FILENAME_LEN - 1); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
932 dcc->filename[GG_DCC7_FILENAME_LEN] = 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
933 memcpy(dcc->hash, p->hash, GG_DCC7_HASH_LEN); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
934 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
935 e->type = GG_EVENT_DCC7_NEW; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
936 e->event.dcc7_new = dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
937 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
938 break; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
939 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
940 case GG_DCC7_TYPE_VOICE: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
941 if (!(dcc = malloc(sizeof(struct gg_dcc7)))) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
942 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_packet() not enough memory\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
943 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
944 } |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
945 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
946 memset(dcc, 0, sizeof(struct gg_dcc7)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
947 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
948 dcc->type = GG_SESSION_DCC7_VOICE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
949 dcc->dcc_type = GG_DCC7_TYPE_VOICE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
950 dcc->fd = -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
951 dcc->file_fd = -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
952 dcc->uin = sess->uin; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
953 dcc->peer_uin = gg_fix32(p->uin_from); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
954 dcc->cid = p->id; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
955 dcc->sess = sess; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
956 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
957 if (gg_dcc7_session_add(sess, dcc) == -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
958 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_new() unable to add to session\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
959 gg_dcc7_free(dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
960 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
961 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
962 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
963 e->type = GG_EVENT_DCC7_NEW; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
964 e->event.dcc7_new = dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
965 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
966 break; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
967 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
968 default: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
969 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_new() unknown dcc type (%d) from %ld\n", gg_fix32(p->type), gg_fix32(p->uin_from)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
970 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
971 break; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
972 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
973 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
974 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
975 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
976 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
977 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
978 * \internal Ustawia odpowiednie stany wewnętrzne w zależności od rodzaju |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
979 * połączenia. |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
980 * |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
981 * \param dcc Struktura połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
982 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
983 * \return 0 jeśli się powiodło, -1 w przypadku błędu. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
984 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
985 static int gg_dcc7_postauth_fixup(struct gg_dcc7 *dcc) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
986 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
987 gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_postauth_fixup(%p)\n", dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
988 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
989 if (!dcc) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
990 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_postauth_fixup() invalid parameters\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
991 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
992 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
993 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
994 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
995 switch (dcc->type) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
996 case GG_SESSION_DCC7_GET: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
997 dcc->state = GG_STATE_GETTING_FILE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
998 dcc->check = GG_CHECK_READ; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
999 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1000 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1001 case GG_SESSION_DCC7_SEND: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1002 dcc->state = GG_STATE_SENDING_FILE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1003 dcc->check = GG_CHECK_WRITE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1004 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1005 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1006 case GG_SESSION_DCC7_VOICE: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1007 dcc->state = GG_STATE_READING_VOICE_DATA; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1008 dcc->check = GG_CHECK_READ; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1009 return 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1010 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1011 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1012 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1013 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1014 return -1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1015 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1016 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1017 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1018 * Funkcja wywoływana po zaobserwowaniu zmian na deskryptorze połączenia. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1019 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1020 * Funkcja zwraca strukturę zdarzenia \c gg_event. Jeśli rodzaj zdarzenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1021 * to \c GG_EVENT_NONE, nie wydarzyło się jeszcze nic wartego odnotowania. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1022 * Strukturę zdarzenia należy zwolnić funkcja \c gg_event_free(). |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1023 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1024 * \param dcc Struktura połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1025 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1026 * \return Struktura zdarzenia lub \c NULL jeśli wystąpił błąd |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1027 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1028 * \ingroup dcc7 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1029 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1030 struct gg_event *gg_dcc7_watch_fd(struct gg_dcc7 *dcc) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1031 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1032 struct gg_event *e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1033 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1034 gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_watch_fd(%p)\n", dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1035 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1036 if (!dcc || (dcc->type != GG_SESSION_DCC7_SEND && dcc->type != GG_SESSION_DCC7_GET && dcc->type != GG_SESSION_DCC7_VOICE)) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1037 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() invalid parameters\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1038 errno = EINVAL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1039 return NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1040 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1041 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1042 if (!(e = malloc(sizeof(struct gg_event)))) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1043 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() not enough memory\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1044 return NULL; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1045 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1046 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1047 memset(e, 0, sizeof(struct gg_event)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1048 e->type = GG_EVENT_NONE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1049 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1050 switch (dcc->state) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1051 case GG_STATE_LISTENING: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1052 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1053 struct sockaddr_in sin; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1054 int fd, one = 1; |
29939
db6735e579f8
Partially fix libgadu build on Win32. Refs #10542. I'm still not sure how to
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
29938
diff
changeset
|
1055 socklen_t sin_len = sizeof(sin); |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1056 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1057 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_LISTENING\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1058 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1059 if ((fd = accept(dcc->fd, (struct sockaddr*) &sin, &sin_len)) == -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1060 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() accept() failed (%s)\n", strerror(errno)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1061 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1062 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1063 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1064 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() connection from %s:%d\n", inet_ntoa(sin.sin_addr), htons(sin.sin_port)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1065 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1066 #ifdef FIONBIO |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1067 if (ioctl(fd, FIONBIO, &one) == -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1068 #else |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1069 if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1070 #endif |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1071 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() can't set nonblocking (%s)\n", strerror(errno)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1072 close(fd); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1073 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1074 e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1075 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1076 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1077 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1078 close(dcc->fd); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1079 dcc->fd = fd; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1080 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1081 dcc->state = GG_STATE_READING_ID; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1082 dcc->check = GG_CHECK_READ; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1083 dcc->timeout = GG_DEFAULT_TIMEOUT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1084 dcc->incoming = 1; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1085 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1086 dcc->remote_port = ntohs(sin.sin_port); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1087 dcc->remote_addr = sin.sin_addr.s_addr; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1088 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1089 e->type = GG_EVENT_DCC7_CONNECTED; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1090 e->event.dcc7_connected.dcc7 = dcc; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1091 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1092 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1093 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1094 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1095 case GG_STATE_CONNECTING: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1096 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1097 int res = 0, error = 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1098 unsigned int error_size = sizeof(error); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1099 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1100 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_CONNECTING\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1101 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1102 dcc->soft_timeout = 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1103 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1104 if (dcc->timeout == 0) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1105 error = ETIMEDOUT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1106 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1107 if (error || (res = getsockopt(dcc->fd, SOL_SOCKET, SO_ERROR, &error, &error_size)) == -1 || error != 0) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1108 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() connection failed (%s)\n", (res == -1) ? strerror(errno) : strerror(error)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1109 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1110 if (dcc->relay) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1111 for (dcc->relay_index++; dcc->relay_index < dcc->relay_count; dcc->relay_index++) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1112 dcc->remote_addr = dcc->relay_list[dcc->relay_index].addr; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1113 dcc->remote_port = dcc->relay_list[dcc->relay_index].port; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1114 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1115 if (gg_dcc7_connect(dcc) == 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1116 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1117 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1118 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1119 if (dcc->relay_index >= dcc->relay_count) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1120 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() no relay available"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1121 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1122 e->event.dcc_error = GG_ERROR_DCC7_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1123 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1124 } |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1125 } else { |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1126 if (gg_dcc7_reverse_connect(dcc) != -1) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1127 e->type = GG_EVENT_DCC7_PENDING; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1128 e->event.dcc7_pending.dcc7 = dcc; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1129 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1130 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1131 e->event.dcc_error = GG_ERROR_DCC7_NET; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1132 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1133 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1134 return e; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1135 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1136 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1137 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1138 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() connected, sending id\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1139 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1140 dcc->state = GG_STATE_SENDING_ID; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1141 dcc->check = GG_CHECK_WRITE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1142 dcc->timeout = GG_DEFAULT_TIMEOUT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1143 dcc->incoming = 0; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1144 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1145 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1146 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1147 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1148 case GG_STATE_READING_ID: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1149 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1150 int res; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1151 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1152 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_READING_ID\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1153 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1154 if (!dcc->relay) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1155 struct gg_dcc7_welcome_p2p welcome, welcome_ok; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1156 welcome_ok.id = dcc->cid; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1157 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1158 if ((res = read(dcc->fd, &welcome, sizeof(welcome))) != sizeof(welcome)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1159 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() read() failed (%d, %s)\n", res, strerror(errno)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1160 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1161 e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1162 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1163 } |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1164 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1165 if (memcmp(&welcome, &welcome_ok, sizeof(welcome))) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1166 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() invalid id\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1167 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1168 e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1169 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1170 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1171 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1172 struct gg_dcc7_welcome_server welcome, welcome_ok; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1173 welcome_ok.magic = GG_DCC7_WELCOME_SERVER; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1174 welcome_ok.id = dcc->cid; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1175 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1176 if ((res = read(dcc->fd, &welcome, sizeof(welcome))) != sizeof(welcome)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1177 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() read() failed (%d, %s)\n", res, strerror(errno)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1178 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1179 e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1180 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1181 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1182 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1183 if (memcmp(&welcome, &welcome_ok, sizeof(welcome)) != 0) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1184 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() invalid id\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1185 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1186 e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1187 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1188 } |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1189 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1190 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1191 if (dcc->incoming) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1192 dcc->state = GG_STATE_SENDING_ID; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1193 dcc->check = GG_CHECK_WRITE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1194 dcc->timeout = GG_DEFAULT_TIMEOUT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1195 } else { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1196 gg_dcc7_postauth_fixup(dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1197 dcc->timeout = GG_DEFAULT_TIMEOUT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1198 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1199 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1200 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1201 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1202 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1203 case GG_STATE_SENDING_ID: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1204 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1205 int res; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1206 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1207 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_SENDING_ID\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1208 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1209 if (!dcc->relay) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1210 struct gg_dcc7_welcome_p2p welcome; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1211 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1212 welcome.id = dcc->cid; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1213 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1214 if ((res = write(dcc->fd, &welcome, sizeof(welcome))) != sizeof(welcome)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1215 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() write() failed (%d, %s)\n", res, strerror(errno)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1216 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1217 e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1218 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1219 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1220 } else { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1221 struct gg_dcc7_welcome_server welcome; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1222 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1223 welcome.magic = gg_fix32(GG_DCC7_WELCOME_SERVER); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1224 welcome.id = dcc->cid; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1225 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1226 if ((res = write(dcc->fd, &welcome, sizeof(welcome))) != sizeof(welcome)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1227 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() write() failed (%d, %s)\n", res, strerror(errno)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1228 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1229 e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1230 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1231 } |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1232 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1233 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1234 if (dcc->incoming) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1235 gg_dcc7_postauth_fixup(dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1236 dcc->timeout = GG_DEFAULT_TIMEOUT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1237 } else { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1238 dcc->state = GG_STATE_READING_ID; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1239 dcc->check = GG_CHECK_READ; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1240 dcc->timeout = GG_DEFAULT_TIMEOUT; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1241 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1242 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1243 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1244 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1245 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1246 case GG_STATE_SENDING_FILE: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1247 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1248 char buf[1024]; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1249 int chunk, res; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1250 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1251 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_SENDING_FILE (offset=%d, size=%d)\n", dcc->offset, dcc->size); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1252 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1253 if (dcc->offset >= dcc->size) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1254 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() offset >= size, finished\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1255 e->type = GG_EVENT_DCC7_DONE; |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1256 e->event.dcc7_done.dcc7 = dcc; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1257 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1258 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1259 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1260 if (dcc->seek && lseek(dcc->file_fd, dcc->offset, SEEK_SET) == (off_t) -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1261 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() lseek() failed (%s)\n", strerror(errno)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1262 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1263 e->event.dcc_error = GG_ERROR_DCC7_FILE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1264 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1265 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1266 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1267 if ((chunk = dcc->size - dcc->offset) > sizeof(buf)) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1268 chunk = sizeof(buf); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1269 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1270 if ((res = read(dcc->file_fd, buf, chunk)) < 1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1271 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() read() failed (res=%d, %s)\n", res, strerror(errno)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1272 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1273 e->event.dcc_error = (res == -1) ? GG_ERROR_DCC7_FILE : GG_ERROR_DCC7_EOF; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1274 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1275 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1276 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1277 if ((res = write(dcc->fd, buf, res)) == -1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1278 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() write() failed (%s)\n", strerror(errno)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1279 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1280 e->event.dcc_error = GG_ERROR_DCC7_NET; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1281 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1282 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1283 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1284 dcc->offset += res; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1285 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1286 if (dcc->offset >= dcc->size) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1287 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() finished\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1288 e->type = GG_EVENT_DCC7_DONE; |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1289 e->event.dcc7_done.dcc7 = dcc; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1290 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1291 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1292 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1293 dcc->state = GG_STATE_SENDING_FILE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1294 dcc->check = GG_CHECK_WRITE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1295 dcc->timeout = GG_DCC7_TIMEOUT_SEND; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1296 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1297 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1298 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1299 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1300 case GG_STATE_GETTING_FILE: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1301 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1302 char buf[1024]; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1303 int res, wres; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1304 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1305 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_GETTING_FILE (offset=%d, size=%d)\n", dcc->offset, dcc->size); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1306 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1307 if (dcc->offset >= dcc->size) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1308 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() finished\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1309 e->type = GG_EVENT_DCC7_DONE; |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1310 e->event.dcc7_done.dcc7 = dcc; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1311 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1312 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1313 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1314 if ((res = read(dcc->fd, buf, sizeof(buf))) < 1) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1315 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() read() failed (fd=%d, res=%d, %s)\n", dcc->fd, res, strerror(errno)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1316 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1317 e->event.dcc_error = (res == -1) ? GG_ERROR_DCC7_NET : GG_ERROR_DCC7_EOF; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1318 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1319 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1320 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1321 // XXX zapisywać do skutku? |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1322 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1323 if ((wres = write(dcc->file_fd, buf, res)) < res) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1324 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() write() failed (fd=%d, res=%d, %s)\n", dcc->file_fd, wres, strerror(errno)); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1325 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1326 e->event.dcc_error = GG_ERROR_DCC7_FILE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1327 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1328 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1329 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1330 dcc->offset += res; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1331 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1332 if (dcc->offset >= dcc->size) { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1333 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() finished\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1334 e->type = GG_EVENT_DCC7_DONE; |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1335 e->event.dcc7_done.dcc7 = dcc; |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1336 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1337 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1338 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1339 dcc->state = GG_STATE_GETTING_FILE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1340 dcc->check = GG_CHECK_READ; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1341 dcc->timeout = GG_DCC7_TIMEOUT_GET; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1342 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1343 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1344 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1345 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1346 case GG_STATE_RESOLVING_RELAY: |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1347 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1348 struct in_addr addr; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1349 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1350 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_RESOLVING_RELAY\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1351 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1352 if (read(dcc->fd, &addr, sizeof(addr)) < sizeof(addr) || addr.s_addr == INADDR_NONE) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1353 int errno_save = errno; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1354 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1355 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() resolving failed\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1356 close(dcc->fd); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1357 dcc->fd = -1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1358 dcc->sess->resolver_cleanup(&dcc->resolver, 0); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1359 errno = errno_save; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1360 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1361 e->event.dcc_error = GG_ERROR_DCC7_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1362 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1363 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1364 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1365 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() resolved, connecting to %s:%d\n", inet_ntoa(addr), GG_RELAY_PORT); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1366 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1367 if ((dcc->fd = gg_connect(&addr, GG_RELAY_PORT, 1)) == -1) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1368 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() connection failed (errno=%d, %s), critical\n", errno, strerror(errno)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1369 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1370 e->event.dcc_error = GG_ERROR_DCC7_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1371 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1372 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1373 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1374 dcc->state = GG_STATE_CONNECTING_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1375 dcc->check = GG_CHECK_WRITE; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1376 dcc->timeout = GG_DEFAULT_TIMEOUT; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1377 |
32072
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1378 e->type = GG_EVENT_DCC7_PENDING; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1379 e->event.dcc7_pending.dcc7 = dcc; |
3a90a59ddea2
Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents:
31860
diff
changeset
|
1380 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1381 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1382 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1383 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1384 case GG_STATE_CONNECTING_RELAY: |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1385 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1386 int res; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1387 unsigned int res_size = sizeof(res); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1388 struct gg_dcc7_relay_req pkt; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1389 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1390 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_CONNECTING_RELAY\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1391 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1392 if (getsockopt(dcc->fd, SOL_SOCKET, SO_ERROR, &res, &res_size) != 0 || res != 0) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1393 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() connection failed (errno=%d, %s)\n", res, strerror(res)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1394 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1395 e->event.dcc_error = GG_ERROR_DCC7_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1396 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1397 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1398 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1399 memset(&pkt, 0, sizeof(pkt)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1400 pkt.magic = gg_fix32(GG_DCC7_RELAY_REQUEST); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1401 pkt.len = gg_fix32(sizeof(pkt)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1402 pkt.id = dcc->cid; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1403 pkt.type = gg_fix16(GG_DCC7_RELAY_TYPE_SERVER); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1404 pkt.dunno1 = gg_fix16(GG_DCC7_RELAY_DUNNO1); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1405 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1406 gg_debug_dcc(dcc, GG_DEBUG_DUMP, "// gg_dcc7_watch_fd() send pkt(0x%.2x)\n", gg_fix32(pkt.magic)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1407 gg_debug_dump_dcc(dcc, GG_DEBUG_DUMP, (const char*) &pkt, sizeof(pkt)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1408 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1409 if ((res = write(dcc->fd, &pkt, sizeof(pkt))) != sizeof(pkt)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1410 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() sending failed\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1411 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1412 e->event.dcc_error = GG_ERROR_DCC7_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1413 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1414 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1415 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1416 dcc->state = GG_STATE_READING_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1417 dcc->check = GG_CHECK_READ; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1418 dcc->timeout = GG_DEFAULT_TIMEOUT; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1419 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1420 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1421 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1422 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1423 case GG_STATE_READING_RELAY: |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1424 { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1425 char buf[256]; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1426 struct gg_dcc7_relay_reply *pkt; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1427 struct gg_dcc7_relay_reply_server srv; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1428 int res; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1429 int i; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1430 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1431 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_READING_RELAY\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1432 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1433 if ((res = read(dcc->fd, buf, sizeof(buf))) < sizeof(*pkt)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1434 if (res == 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1435 errno = ECONNRESET; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1436 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() read() failed (%d, %s)\n", res, strerror(errno)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1437 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1438 e->event.dcc_error = GG_ERROR_DCC7_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1439 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1440 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1441 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1442 pkt = (struct gg_dcc7_relay_reply*) buf; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1443 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1444 if (gg_fix32(pkt->magic) != GG_DCC7_RELAY_REPLY || gg_fix32(pkt->rcount) < 1 || gg_fix32(pkt->rcount > 256) || gg_fix32(pkt->len) < sizeof(*pkt) + gg_fix32(pkt->rcount) * sizeof(srv)) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1445 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_wathc_fd() invalid reply\n"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1446 errno = EINVAL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1447 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1448 e->event.dcc_error = GG_ERROR_DCC7_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1449 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1450 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1451 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1452 gg_debug_dcc(dcc, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() read pkt(0x%.2x)\n", gg_fix32(pkt->magic)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1453 gg_debug_dump_dcc(dcc, GG_DEBUG_DUMP, buf, res); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1454 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1455 free(dcc->relay_list); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1456 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1457 dcc->relay_index = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1458 dcc->relay_count = gg_fix32(pkt->rcount); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1459 dcc->relay_list = malloc(dcc->relay_count * sizeof(gg_dcc7_relay_t)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1460 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1461 if (dcc->relay_list == NULL) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1462 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() not enough memory"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1463 dcc->relay_count = 0; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1464 free(e); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1465 return NULL; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1466 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1467 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1468 for (i = 0; i < dcc->relay_count; i++) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1469 struct in_addr addr; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1470 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1471 memcpy(&srv, buf + sizeof(*pkt) + i * sizeof(srv), sizeof(srv)); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1472 dcc->relay_list[i].addr = srv.addr; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1473 dcc->relay_list[i].port = gg_fix16(srv.port); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1474 dcc->relay_list[i].family = srv.family; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1475 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1476 addr.s_addr = srv.addr; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1477 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// %s %d %d\n", inet_ntoa(addr), gg_fix16(srv.port), srv.family); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1478 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1479 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1480 dcc->relay = 1; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1481 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1482 for (; dcc->relay_index < dcc->relay_count; dcc->relay_index++) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1483 dcc->remote_addr = dcc->relay_list[dcc->relay_index].addr; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1484 dcc->remote_port = dcc->relay_list[dcc->relay_index].port; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1485 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1486 if (gg_dcc7_connect(dcc) == 0) |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1487 break; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1488 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1489 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1490 if (dcc->relay_index >= dcc->relay_count) { |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1491 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() no relay available"); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1492 e->type = GG_EVENT_DCC7_ERROR; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1493 e->event.dcc_error = GG_ERROR_DCC7_RELAY; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1494 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1495 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1496 |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1497 return e; |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1498 } |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1499 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1500 default: |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1501 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1502 gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_???\n"); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1503 e->type = GG_EVENT_DCC7_ERROR; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1504 e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1505 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1506 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1507 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1508 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1509 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1510 return e; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1511 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1512 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1513 /** |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1514 * Zwalnia zasoby używane przez połączenie bezpośrednie. |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1515 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1516 * \param dcc Struktura połączenia |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1517 * |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1518 * \ingroup dcc7 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1519 */ |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1520 void gg_dcc7_free(struct gg_dcc7 *dcc) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1521 { |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1522 gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_free(%p)\n", dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1523 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1524 if (!dcc) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1525 return; |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1526 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1527 if (dcc->fd != -1) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1528 close(dcc->fd); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1529 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1530 if (dcc->file_fd != -1) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1531 close(dcc->file_fd); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1532 |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1533 if (dcc->sess) |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1534 gg_dcc7_session_remove(dcc->sess, dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1535 |
31860
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1536 free(dcc->relay_list); |
93b08d43f684
matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31534
diff
changeset
|
1537 |
29938
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1538 free(dcc); |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1539 } |
6359fde67f4c
Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1540 |