libpurple/protocols/gg/lib/libgadu.c

Fri, 21 Oct 2011 12:48:30 +0000

author
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
date
Fri, 21 Oct 2011 12:48:30 +0000
changeset 32688
9e137d441acd
parent 32675
a8ba546a18bc
child 33285
32cbdbf016bd
permissions
-rw-r--r--

Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343

31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1 /* $Id: libgadu.c 1102 2011-05-05 21:17:57Z wojtekka $ */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
3 /*
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
4 * (C) Copyright 2001-2010 Wojtek Kaniewski <wojtekka@irc.pl>
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
5 * Robert J. Woźny <speedy@ziew.org>
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
6 * Arkadiusz Miśkiewicz <arekm@pld-linux.org>
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
7 * Tomasz Chiliński <chilek@chilan.com>
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
8 * Adam Wysocki <gophi@ekg.chmurka.net>
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
9 *
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
11 * it under the terms of the GNU Lesser General Public License Version
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
12 * 2.1 as published by the Free Software Foundation.
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
13 *
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
17 * GNU Lesser General Public License for more details.
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
18 *
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
19 * You should have received a copy of the GNU Lesser General Public
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
20 * License along with this program; if not, write to the Free Software
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
22 * USA.
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
23 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
24
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
25 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
26 * \file libgadu.c
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
27 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
28 * \brief Główny moduł biblioteki
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
29 */
29106
51c7b2177e42 Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents: 28076
diff changeset
30
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
31 #include <sys/types.h>
32675
a8ba546a18bc Gadu-Gadu: synchronize internal libgadu with upstream. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 31965
diff changeset
32 #ifdef sun
a8ba546a18bc Gadu-Gadu: synchronize internal libgadu with upstream. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 31965
diff changeset
33 # include <sys/filio.h>
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
34 #endif
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
35
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
36 #include "compat.h"
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
37 #include "libgadu.h"
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
38 #include "protocol.h"
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
39 #include "resolver.h"
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
40 #include "libgadu-internal.h"
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
41 #include "encoding.h"
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
42 #include "libgadu-debug.h"
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
43 #include "session.h"
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
44 #include "message.h"
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
45 #include "deflate.h"
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
46
32688
9e137d441acd Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32675
diff changeset
47 #include <errno.h>
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
48 #include <stdarg.h>
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
49 #include <stdio.h>
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
50 #include <stdlib.h>
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
51 #include <string.h>
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
52 #include <signal.h>
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
53 #include <time.h>
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
54 #include <unistd.h>
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
55 #ifdef GG_CONFIG_HAVE_GNUTLS
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
56 # include <gnutls/gnutls.h>
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
57 #endif
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
58 #ifdef GG_CONFIG_HAVE_OPENSSL
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
59 # include <openssl/err.h>
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
60 # include <openssl/rand.h>
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
61 #endif
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
62
32688
9e137d441acd Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32675
diff changeset
63 #define GG_LIBGADU_VERSION "1.11.0"
9e137d441acd Gadu-Gadu: synchronize internal libgadu with upstream - second encounter. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32675
diff changeset
64
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
65 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
66 * Port gniazda nasłuchującego dla połączeń bezpośrednich.
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
67 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
68 * \ingroup ip
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
69 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
70 int gg_dcc_port = 0;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
71
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
72 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
73 * Adres IP gniazda nasłuchującego dla połączeń bezpośrednich.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
74 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
75 * \ingroup ip
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
76 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
77 unsigned long gg_dcc_ip = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
78
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
79 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
80 * Adres lokalnego interfejsu IP, z którego wywoływane są wszystkie połączenia.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
81 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
82 * \ingroup ip
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
83 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
84 unsigned long gg_local_ip = 0;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
85
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
86 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
87 * Flaga włączenia połączeń przez serwer pośredniczący.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
88 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
89 * \ingroup proxy
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
90 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
91 int gg_proxy_enabled = 0;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
92
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
93 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
94 * Adres serwera pośredniczącego.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
95 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
96 * \ingroup proxy
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
97 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
98 char *gg_proxy_host = NULL;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
99
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
100 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
101 * Port serwera pośredniczącego.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
102 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
103 * \ingroup proxy
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
104 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
105 int gg_proxy_port = 0;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
106
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
107 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
108 * Flaga używania serwera pośredniczącego jedynie dla usług HTTP.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
109 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
110 * \ingroup proxy
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
111 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
112 int gg_proxy_http_only = 0;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
113
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
114 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
115 * Nazwa użytkownika do autoryzacji serwera pośredniczącego.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
116 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
117 * \ingroup proxy
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
118 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
119 char *gg_proxy_username = NULL;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
120
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
121 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
122 * Hasło użytkownika do autoryzacji serwera pośredniczącego.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
123 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
124 * \ingroup proxy
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
125 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
126 char *gg_proxy_password = NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
127
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
128 #ifndef DOXYGEN
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
129
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
130 #ifndef lint
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
131 static char rcsid[]
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
132 #ifdef __GNUC__
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
133 __attribute__ ((unused))
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
134 #endif
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
135 = "$Id: libgadu.c 1102 2011-05-05 21:17:57Z wojtekka $";
12007
bf1190509b70 [gaim-migrate @ 14300]
Bartosz Oler <bartosz@pidgin.im>
parents: 11546
diff changeset
136 #endif
bf1190509b70 [gaim-migrate @ 14300]
Bartosz Oler <bartosz@pidgin.im>
parents: 11546
diff changeset
137
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
138 #endif /* DOXYGEN */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
139
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
140 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
141 * Zwraca wersję biblioteki.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
142 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
143 * \return Wskaźnik na statyczny bufor z wersją biblioteki.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
144 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
145 * \ingroup version
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
146 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
147 const char *gg_libgadu_version()
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
148 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
149 return GG_LIBGADU_VERSION;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
150 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
151
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
152 #ifdef GG_CONFIG_HAVE_UINT64_T
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
153 /**
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
154 * \internal Zamienia kolejność bajtów w 64-bitowym słowie.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
155 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
156 * Ze względu na little-endianowość protokołu Gadu-Gadu, na maszynach
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
157 * big-endianowych odwraca kolejność bajtów w słowie.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
158 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
159 * \param x Liczba do zamiany
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
160 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
161 * \return Liczba z odpowiednią kolejnością bajtów
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
162 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
163 * \ingroup helper
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
164 */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
165 uint64_t gg_fix64(uint64_t x)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
166 {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
167 #ifndef GG_CONFIG_BIGENDIAN
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
168 return x;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
169 #else
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
170 return (uint64_t)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
171 (((x & (uint64_t) 0x00000000000000ffULL) << 56) |
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
172 ((x & (uint64_t) 0x000000000000ff00ULL) << 40) |
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
173 ((x & (uint64_t) 0x0000000000ff0000ULL) << 24) |
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
174 ((x & (uint64_t) 0x00000000ff000000ULL) << 8) |
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
175 ((x & (uint64_t) 0x000000ff00000000ULL) >> 8) |
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
176 ((x & (uint64_t) 0x0000ff0000000000ULL) >> 24) |
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
177 ((x & (uint64_t) 0x00ff000000000000ULL) >> 40) |
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
178 ((x & (uint64_t) 0xff00000000000000ULL) >> 56));
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
179 #endif
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
180 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
181 #endif /* GG_CONFIG_HAVE_UINT64_T */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
182
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
183 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
184 * \internal Zamienia kolejność bajtów w 32-bitowym słowie.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
185 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
186 * Ze względu na little-endianowość protokołu Gadu-Gadu, na maszynach
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
187 * big-endianowych odwraca kolejność bajtów w słowie.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
188 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
189 * \param x Liczba do zamiany
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
190 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
191 * \return Liczba z odpowiednią kolejnością bajtów
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
192 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
193 * \ingroup helper
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
194 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
195 uint32_t gg_fix32(uint32_t x)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
196 {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
197 #ifndef GG_CONFIG_BIGENDIAN
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
198 return x;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
199 #else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
200 return (uint32_t)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
201 (((x & (uint32_t) 0x000000ffU) << 24) |
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
202 ((x & (uint32_t) 0x0000ff00U) << 8) |
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
203 ((x & (uint32_t) 0x00ff0000U) >> 8) |
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
204 ((x & (uint32_t) 0xff000000U) >> 24));
12007
bf1190509b70 [gaim-migrate @ 14300]
Bartosz Oler <bartosz@pidgin.im>
parents: 11546
diff changeset
205 #endif
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
206 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
207
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
208 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
209 * \internal Zamienia kolejność bajtów w 16-bitowym słowie.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
210 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
211 * Ze względu na little-endianowość protokołu Gadu-Gadu, na maszynach
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
212 * big-endianowych zamienia kolejność bajtów w słowie.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
213 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
214 * \param x Liczba do zamiany
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
215 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
216 * \return Liczba z odpowiednią kolejnością bajtów
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
217 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
218 * \ingroup helper
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
219 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
220 uint16_t gg_fix16(uint16_t x)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
221 {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
222 #ifndef GG_CONFIG_BIGENDIAN
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
223 return x;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
224 #else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
225 return (uint16_t)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
226 (((x & (uint16_t) 0x00ffU) << 8) |
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
227 ((x & (uint16_t) 0xff00U) >> 8));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
228 #endif
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
229 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
230
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
231 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
232 * \internal Liczy skrót z hasła i ziarna.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
233 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
234 * \param password Hasło
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
235 * \param seed Ziarno podane przez serwer
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
236 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
237 * \return Wartość skrótu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
238 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
239 unsigned int gg_login_hash(const unsigned char *password, unsigned int seed)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
240 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
241 unsigned int x, y, z;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
242
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
243 y = seed;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
244
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
245 for (x = 0; *password; password++) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
246 x = (x & 0xffffff00) | *password;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
247 y ^= x;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
248 y += x;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
249 x <<= 8;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
250 y ^= x;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
251 x <<= 8;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
252 y -= x;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
253 x <<= 8;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
254 y ^= x;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
255
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
256 z = y & 0x1F;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
257 y = (y << z) | (y >> (32 - z));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
258 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
259
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
260 return y;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
261 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
262
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
263 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
264 * \internal Odbiera od serwera dane binarne.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
265 *
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
266 * Funkcja odbiera dane od serwera zajmując się SSL/TLS w razie konieczności.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
267 * Obsługuje EINTR, więc użytkownik nie musi się przejmować przerwanymi
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
268 * wywołaniami systemowymi.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
269 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
270 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
271 * \param buf Bufor na danymi
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
272 * \param length Długość bufora
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
273 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
274 * \return To samo co funkcja systemowa \c read
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
275 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
276 int gg_read(struct gg_session *sess, char *buf, int length)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
277 {
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
278 int res;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
279
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
280 #ifdef GG_CONFIG_HAVE_GNUTLS
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
281 if (sess->ssl != NULL) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
282 for (;;) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
283 res = gnutls_record_recv(GG_SESSION_GNUTLS(sess), buf, length);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
284
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
285 if (res < 0) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
286 if (!gnutls_error_is_fatal(res) || res == GNUTLS_E_INTERRUPTED)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
287 continue;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
288
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
289 if (res == GNUTLS_E_AGAIN)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
290 errno = EAGAIN;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
291 else
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
292 errno = EINVAL;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
293
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
294 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
295 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
296
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
297 return res;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
298 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
299 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
300 #endif
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
301
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
302 #ifdef GG_CONFIG_HAVE_OPENSSL
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
303 if (sess->ssl != NULL) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
304 for (;;) {
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
305 int err;
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
306
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
307 res = SSL_read(sess->ssl, buf, length);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
308
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
309 if (res < 0) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
310 err = SSL_get_error(sess->ssl, res);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
311
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
312 if (err == SSL_ERROR_SYSCALL && errno == EINTR)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
313 continue;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
314
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
315 if (err == SSL_ERROR_WANT_READ)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
316 errno = EAGAIN;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
317 else if (err != SSL_ERROR_SYSCALL)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
318 errno = EINVAL;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
319
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
320 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
321 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
322
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
323 return res;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
324 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
325 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
326 #endif
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
327
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
328 for (;;) {
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
329 res = read(sess->fd, buf, length);
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
330
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
331 if (res == -1 && errno == EINTR)
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
332 continue;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
333
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
334 return res;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
335 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
336 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
337
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
338 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
339 * \internal Wysyła do serwera dane binarne.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
340 *
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
341 * Funkcja wysyła dane do serwera zajmując się SSL/TLS w razie konieczności.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
342 * Obsługuje EINTR, więc użytkownik nie musi się przejmować przerwanymi
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
343 * wywołaniami systemowymi.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
344 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
345 * \note Funkcja nie zajmuje się buforowaniem wysyłanych danych (patrz
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
346 * gg_write()).
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
347 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
348 * \param sess Struktura sesji
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
349 * \param buf Bufor z danymi
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
350 * \param length Długość bufora
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
351 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
352 * \return To samo co funkcja systemowa \c write
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
353 */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
354 static int gg_write_common(struct gg_session *sess, const char *buf, int length)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
355 {
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
356 int res;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
357
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
358 #ifdef GG_CONFIG_HAVE_GNUTLS
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
359 if (sess->ssl != NULL) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
360 for (;;) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
361 res = gnutls_record_send(GG_SESSION_GNUTLS(sess), buf, length);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
362
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
363 if (res < 0) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
364 if (!gnutls_error_is_fatal(res) || res == GNUTLS_E_INTERRUPTED)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
365 continue;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
366
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
367 if (res == GNUTLS_E_AGAIN)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
368 errno = EAGAIN;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
369 else
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
370 errno = EINVAL;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
371
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
372 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
373 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
374
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
375 return res;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
376 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
377 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
378 #endif
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
379
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
380 #ifdef GG_CONFIG_HAVE_OPENSSL
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
381 if (sess->ssl != NULL) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
382 for (;;) {
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
383 int err;
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
384
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
385 res = SSL_write(sess->ssl, buf, length);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
386
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
387 if (res < 0) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
388 err = SSL_get_error(sess->ssl, res);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
389
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
390 if (err == SSL_ERROR_SYSCALL && errno == EINTR)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
391 continue;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
392
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
393 if (err == SSL_ERROR_WANT_WRITE)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
394 errno = EAGAIN;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
395 else if (err != SSL_ERROR_SYSCALL)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
396 errno = EINVAL;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
397
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
398 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
399 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
400
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
401 return res;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
402 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
403 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
404 #endif
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
405
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
406 for (;;) {
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
407 res = write(sess->fd, buf, length);
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
408
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
409 if (res == -1 && errno == EINTR)
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
410 continue;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
411
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
412 return res;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
413 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
414 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
415
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
416
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
417
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
418 /**
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
419 * \internal Wysyła do serwera dane binarne.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
420 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
421 * Funkcja wysyła dane do serwera zajmując się TLS w razie konieczności.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
422 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
423 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
424 * \param buf Bufor z danymi
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
425 * \param length Długość bufora
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
426 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
427 * \return To samo co funkcja systemowa \c write
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
428 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
429 int gg_write(struct gg_session *sess, const char *buf, int length)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
430 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
431 int res = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
432
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
433 if (!sess->async) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
434 int written = 0;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
435
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
436 while (written < length) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
437 res = gg_write_common(sess, buf + written, length - written);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
438
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
439 if (res == -1)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
440 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
441
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
442 written += res;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
443 res = written;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
444 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
445 } else {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
446 res = 0;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
447
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
448 if (sess->send_buf == NULL) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
449 res = gg_write_common(sess, buf, length);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
450
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
451 if (res == -1)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
452 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
453 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
454
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
455 if (res < length) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
456 char *tmp;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
457
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
458 if (!(tmp = realloc(sess->send_buf, sess->send_left + length - res))) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
459 errno = ENOMEM;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
460 return -1;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
461 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
462
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
463 sess->send_buf = tmp;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
464
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
465 memcpy(sess->send_buf + sess->send_left, buf + res, length - res);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
466
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
467 sess->send_left += length - res;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
468 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
469 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
470
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
471 return res;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
472 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
473
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
474 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
475 * \internal Odbiera pakiet od serwera.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
476 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
477 * Funkcja odczytuje nagłówek pakietu, a następnie jego zawartość i zwraca
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
478 * w zaalokowanym buforze.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
479 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
480 * Przy połączeniach asynchronicznych, funkcja może nie być w stanie
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
481 * skompletować całego pakietu -- w takim przypadku zwróci -1, a kodem błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
482 * będzie \c EAGAIN.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
483 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
484 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
485 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
486 * \return Wskaźnik do zaalokowanego bufora
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
487 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
488 void *gg_recv_packet(struct gg_session *sess)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
489 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
490 struct gg_header h;
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
491 char *packet;
30006
3587e1e5fbe5 gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents: 29824
diff changeset
492 int ret = 0;
3587e1e5fbe5 gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents: 29824
diff changeset
493 unsigned int offset, size = 0;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
494
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
495 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_recv_packet(%p);\n", sess);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
496
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
497 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
498 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
499 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
500 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
501
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
502 if (sess->recv_left < 1) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
503 if (sess->header_buf) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
504 memcpy(&h, sess->header_buf, sess->header_done);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
505 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() header recv: resuming last read (%d bytes left)\n", sizeof(h) - sess->header_done);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
506 free(sess->header_buf);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
507 sess->header_buf = NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
508 } else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
509 sess->header_done = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
510
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
511 while (sess->header_done < sizeof(h)) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
512 ret = gg_read(sess, (char*) &h + sess->header_done, sizeof(h) - sess->header_done);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
513
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
514 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() header recv(%d,%p,%d) = %d\n", sess->fd, &h + sess->header_done, sizeof(h) - sess->header_done, ret);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
515
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
516 if (!ret) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
517 errno = ECONNRESET;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
518 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() header recv() failed: connection broken\n");
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
519 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
520 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
521
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
522 if (ret == -1) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
523 if (errno == EAGAIN) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
524 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() header recv() incomplete header received\n");
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
525
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
526 if (!(sess->header_buf = malloc(sess->header_done))) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
527 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() header recv() not enough memory\n");
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
528 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
529 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
530
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
531 memcpy(sess->header_buf, &h, sess->header_done);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
532
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
533 errno = EAGAIN;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
534
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
535 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
536 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
537
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
538 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() header recv() failed: errno=%d, %s\n", errno, strerror(errno));
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
539
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
540 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
541 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
542
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
543 sess->header_done += ret;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
544 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
545
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
546 h.type = gg_fix32(h.type);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
547 h.length = gg_fix32(h.length);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
548 } else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
549 memcpy(&h, sess->recv_buf, sizeof(h));
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
550
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
551 /* jakieś sensowne limity na rozmiar pakietu */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
552 if (h.length > 65535) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
553 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() invalid packet length (%d)\n", h.length);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
554 errno = ERANGE;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
555 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
556 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
557
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
558 if (sess->recv_left > 0) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
559 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() resuming last gg_recv_packet()\n");
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
560 size = sess->recv_left;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
561 offset = sess->recv_done;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
562 } else {
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
563 if (!(sess->recv_buf = malloc(sizeof(h) + h.length + 1))) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
564 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() not enough memory for packet data\n");
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
565 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
566 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
567
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
568 memcpy(sess->recv_buf, &h, sizeof(h));
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
569
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
570 offset = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
571 size = h.length;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
572 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
573
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
574 while (size > 0) {
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
575 ret = gg_read(sess, sess->recv_buf + sizeof(h) + offset, size);
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
576 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() body recv(%d,%p,%d) = %d\n", sess->fd, sess->recv_buf + sizeof(h) + offset, size, ret);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
577 if (!ret) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
578 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() body recv() failed: connection broken\n");
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
579 errno = ECONNRESET;
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
580 goto fail;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
581 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
582 if (ret > -1 && ret <= size) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
583 offset += ret;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
584 size -= ret;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
585 } else if (ret == -1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
586 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() body recv() failed (errno=%d, %s)\n", errno, strerror(errno));
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
587
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
588 if (errno == EAGAIN) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
589 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet() %d bytes received, %d left\n", offset, size);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
590 sess->recv_left = size;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
591 sess->recv_done = offset;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
592 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
593 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
594
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
595 goto fail;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
596 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
597 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
598
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
599 packet = sess->recv_buf;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
600 sess->recv_buf = NULL;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
601 sess->recv_left = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
602
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
603 gg_debug_session(sess, GG_DEBUG_DUMP, "// gg_recv_packet(type=0x%.2x, length=%d)\n", h.type, h.length);
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
604 gg_debug_dump(sess, GG_DEBUG_DUMP, packet, sizeof(h) + h.length);
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
605
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
606 return packet;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
607
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
608 fail:
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
609 free(sess->recv_buf);
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
610 sess->recv_buf = NULL;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
611 sess->recv_left = 0;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
612
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
613 return NULL;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
614 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
615
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
616 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
617 * \internal Wysyła pakiet do serwera.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
618 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
619 * Funkcja konstruuje pakiet do wysłania z dowolnej liczby fragmentów. Jeśli
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
620 * rozmiar pakietu jest za duży, by móc go wysłać za jednym razem, pozostała
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
621 * część zostanie zakolejkowana i wysłana, gdy będzie to możliwe.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
622 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
623 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
624 * \param type Rodzaj pakietu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
625 * \param ... Lista kolejnych części pakietu (wskaźnik na bufor i długość
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
626 * typu \c int) zakończona \c NULL
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
627 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
628 * \return 0 jeśli się powiodło, -1 w przypadku błędu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
629 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
630 int gg_send_packet(struct gg_session *sess, int type, ...)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
631 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
632 struct gg_header *h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
633 char *tmp;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
634 unsigned int tmp_length;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
635 void *payload;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
636 unsigned int payload_length;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
637 va_list ap;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
638 int res;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
639
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
640 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_packet(%p, 0x%.2x, ...);\n", sess, type);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
641
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
642 tmp_length = sizeof(struct gg_header);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
643
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
644 if (!(tmp = malloc(tmp_length))) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
645 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_send_packet() not enough memory for packet header\n");
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
646 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
647 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
648
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
649 va_start(ap, type);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
650
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
651 payload = va_arg(ap, void *);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
652
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
653 while (payload) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
654 char *tmp2;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
655
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
656 payload_length = va_arg(ap, unsigned int);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
657
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
658 if (!(tmp2 = realloc(tmp, tmp_length + payload_length))) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
659 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_send_packet() not enough memory for payload\n");
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
660 free(tmp);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
661 va_end(ap);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
662 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
663 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
664
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
665 tmp = tmp2;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
666
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
667 memcpy(tmp + tmp_length, payload, payload_length);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
668 tmp_length += payload_length;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
669
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
670 payload = va_arg(ap, void *);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
671 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
672
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
673 va_end(ap);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
674
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
675 h = (struct gg_header*) tmp;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
676 h->type = gg_fix32(type);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
677 h->length = gg_fix32(tmp_length - sizeof(struct gg_header));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
678
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
679 gg_debug_session(sess, GG_DEBUG_DUMP, "// gg_send_packet(type=0x%.2x, length=%d)\n", gg_fix32(h->type), gg_fix32(h->length));
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
680 gg_debug_dump(sess, GG_DEBUG_DUMP, tmp, tmp_length);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
681
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
682 res = gg_write(sess, tmp, tmp_length);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
683
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
684 free(tmp);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
685
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
686 if (res == -1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
687 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_send_packet() write() failed. res = %d, errno = %d (%s)\n", res, errno, strerror(errno));
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
688 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
689 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
690
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
691 if (sess->async)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
692 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_send_packet() partial write(), %d sent, %d left, %d total left\n", res, tmp_length - res, sess->send_left);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
693
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
694 if (sess->send_buf)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
695 sess->check |= GG_CHECK_WRITE;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
696
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
697 return 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
698 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
699
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
700 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
701 * \internal Funkcja zwrotna sesji.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
702 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
703 * Pole \c callback struktury \c gg_session zawiera wskaźnik do tej funkcji.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
704 * Wywołuje ona \c gg_watch_fd i zachowuje wynik w polu \c event.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
705 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
706 * \note Korzystanie z tej funkcjonalności nie jest już zalecane.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
707 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
708 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
709 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
710 * \return 0 jeśli się powiodło, -1 w przypadku błędu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
711 */
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
712 static int gg_session_callback(struct gg_session *sess)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
713 {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
714 if (!sess) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
715 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
716 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
717 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
718
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
719 return ((sess->event = gg_watch_fd(sess)) != NULL) ? 0 : -1;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
720 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
721
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
722 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
723 * Łączy się z serwerem Gadu-Gadu.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
724 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
725 * Przy połączeniu synchronicznym funkcja zakończy działanie po nawiązaniu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
726 * połączenia lub gdy wystąpi błąd. Po udanym połączeniu należy wywoływać
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
727 * funkcję \c gg_watch_fd(), która odbiera informacje od serwera i zwraca
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
728 * informacje o zdarzeniach.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
729 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
730 * Przy połączeniu asynchronicznym funkcja rozpocznie procedurę połączenia
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
731 * i zwróci zaalokowaną strukturę. Pole \c fd struktury \c gg_session zawiera
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
732 * deskryptor, który należy obserwować funkcją \c select, \c poll lub za
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
733 * pomocą mechanizmów użytej pętli zdarzeń (Glib, Qt itp.). Pole \c check
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
734 * jest maską bitową mówiącą, czy biblioteka chce być informowana o możliwości
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
735 * odczytu danych (\c GG_CHECK_READ) czy zapisu danych (\c GG_CHECK_WRITE).
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
736 * Po zaobserwowaniu zmian na deskryptorze należy wywołać funkcję
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
737 * \c gg_watch_fd(). Podczas korzystania z połączeń asynchronicznych, w trakcie
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
738 * połączenia może zostać stworzony dodatkowy proces rozwiązujący nazwę
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
739 * serwera -- z tego powodu program musi poprawnie obsłużyć sygnał SIGCHLD.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
740 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
741 * \note Po nawiązaniu połączenia z serwerem należy wysłać listę kontaktów
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
742 * za pomocą funkcji \c gg_notify() lub \c gg_notify_ex().
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
743 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
744 * \note Funkcja zwróci błąd ENOSYS jeśli połączenie SSL było wymagane, ale
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
745 * obsługa SSL nie jest wkompilowana.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
746 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
747 * \param p Struktura opisująca parametry połączenia. Wymagane pola: uin,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
748 * password, async.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
749 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
750 * \return Wskaźnik do zaalokowanej struktury sesji \c gg_session lub NULL
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
751 * w przypadku błędu.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
752 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
753 * \ingroup login
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
754 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
755 struct gg_session *gg_login(const struct gg_login_params *p)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
756 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
757 struct gg_session *sess = NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
758 char *hostname;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
759 int port;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
760
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
761 if (!p) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
762 gg_debug(GG_DEBUG_FUNCTION, "** gg_login(%p);\n", p);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
763 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
764 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
765 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
766
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
767 gg_debug(GG_DEBUG_FUNCTION, "** gg_login(%p: [uin=%u, async=%d, ...]);\n", p, p->uin, p->async);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
768
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
769 if (!(sess = malloc(sizeof(struct gg_session)))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
770 gg_debug(GG_DEBUG_MISC, "// gg_login() not enough memory for session data\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
771 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
772 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
773
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
774 memset(sess, 0, sizeof(struct gg_session));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
775
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
776 if (!p->password || !p->uin) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
777 gg_debug(GG_DEBUG_MISC, "// gg_login() invalid arguments. uin and password needed\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
778 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
779 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
780 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
781
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
782 if (!(sess->password = strdup(p->password))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
783 gg_debug(GG_DEBUG_MISC, "// gg_login() not enough memory for password\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
784 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
785 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
786
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
787 if (p->hash_type < 0 || p->hash_type > GG_LOGIN_HASH_SHA1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
788 gg_debug(GG_DEBUG_MISC, "// gg_login() invalid arguments. unknown hash type (%d)\n", p->hash_type);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
789 errno = EFAULT;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
790 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
791 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
792
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
793 sess->uin = p->uin;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
794 sess->state = GG_STATE_RESOLVING;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
795 sess->check = GG_CHECK_READ;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
796 sess->timeout = GG_DEFAULT_TIMEOUT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
797 sess->async = p->async;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
798 sess->type = GG_SESSION_GG;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
799 sess->initial_status = p->status;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
800 sess->callback = gg_session_callback;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
801 sess->destroy = gg_free_session;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
802 sess->port = (p->server_port) ? p->server_port : ((gg_proxy_enabled) ? GG_HTTPS_PORT : GG_DEFAULT_PORT);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
803 sess->server_addr = p->server_addr;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
804 sess->external_port = p->external_port;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
805 sess->external_addr = p->external_addr;
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
806 sess->client_addr = p->client_addr;
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
807 sess->client_port = p->client_port;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
808
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
809 if (p->protocol_features == 0) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
810 sess->protocol_features = GG_FEATURE_MSG80 | GG_FEATURE_STATUS80 | GG_FEATURE_DND_FFC | GG_FEATURE_IMAGE_DESCR | GG_FEATURE_UNKNOWN_100 | GG_FEATURE_USER_DATA | GG_FEATURE_MSG_ACK | GG_FEATURE_TYPING_NOTIFICATION;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
811 } else {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
812 sess->protocol_features = (p->protocol_features & ~(GG_FEATURE_STATUS77 | GG_FEATURE_MSG77));
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
813
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
814 if (!(p->protocol_features & GG_FEATURE_STATUS77))
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
815 sess->protocol_features |= GG_FEATURE_STATUS80;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
816
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
817 if (!(p->protocol_features & GG_FEATURE_MSG77))
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
818 sess->protocol_features |= GG_FEATURE_MSG80;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
819 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
820
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
821 if (!(sess->status_flags = p->status_flags))
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
822 sess->status_flags = GG_STATUS_FLAG_UNKNOWN | GG_STATUS_FLAG_SPAM;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
823
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
824 sess->protocol_version = (p->protocol_version) ? p->protocol_version : GG_DEFAULT_PROTOCOL_VERSION;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
825
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
826 if (p->era_omnix)
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
827 sess->protocol_flags |= GG_ERA_OMNIX_MASK;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
828 if (p->has_audio)
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
829 sess->protocol_flags |= GG_HAS_AUDIO_MASK;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
830 sess->client_version = (p->client_version) ? strdup(p->client_version) : NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
831 sess->last_sysmsg = p->last_sysmsg;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
832 sess->image_size = p->image_size;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
833 sess->pid = -1;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
834 sess->encoding = p->encoding;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
835
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
836 if (gg_session_set_resolver(sess, p->resolver) == -1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
837 gg_debug(GG_DEBUG_MISC, "// gg_login() invalid arguments. unsupported resolver type (%d)\n", p->resolver);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
838 errno = EFAULT;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
839 goto fail;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
840 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
841
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
842 if (p->status_descr) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
843 int max_length;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
844
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
845 if (sess->protocol_version >= 0x2d)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
846 max_length = GG_STATUS_DESCR_MAXSIZE;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
847 else
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
848 max_length = GG_STATUS_DESCR_MAXSIZE_PRE_8_0;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
849
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
850 if (sess->protocol_version >= 0x2d)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
851 sess->initial_descr = gg_encoding_convert(p->status_descr, p->encoding, GG_ENCODING_UTF8, -1, -1);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
852 else
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
853 sess->initial_descr = strdup(p->status_descr);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
854
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
855 if (!sess->initial_descr) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
856 gg_debug(GG_DEBUG_MISC, "// gg_login() not enough memory for status\n");
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
857 goto fail;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
858 }
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
859
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
860 // XXX pamiętać, żeby nie ciąć w środku znaku utf-8
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
861
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
862 if (strlen(sess->initial_descr) > max_length)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
863 sess->initial_descr[max_length] = 0;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
864 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
865
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
866 if (p->tls != GG_SSL_DISABLED) {
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
867 #ifdef GG_CONFIG_HAVE_GNUTLS
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
868 gg_session_gnutls_t *tmp;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
869
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
870 tmp = malloc(sizeof(gg_session_gnutls_t));
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
871
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
872 if (tmp == NULL) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
873 gg_debug(GG_DEBUG_MISC, "// gg_login() out of memory for GnuTLS session\n");
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
874 goto fail;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
875 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
876
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
877 sess->ssl = tmp;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
878
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
879 gnutls_global_init();
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
880 gnutls_certificate_allocate_credentials(&tmp->xcred);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
881 gnutls_init(&tmp->session, GNUTLS_CLIENT);
31965
8fadb7594280 gg: Fix build w/ older versions of GnuTLS.
Paul Aurich <darkrain42@pidgin.im>
parents: 31826
diff changeset
882 gnutls_set_default_priority(tmp->session);
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
883 gnutls_credentials_set(tmp->session, GNUTLS_CRD_CERTIFICATE, tmp->xcred);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
884 #elif defined(GG_CONFIG_HAVE_OPENSSL)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
885 char buf[1024];
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
886
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
887 OpenSSL_add_ssl_algorithms();
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
888
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
889 if (!RAND_status()) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
890 char rdata[1024];
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
891 struct {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
892 time_t time;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
893 void *ptr;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
894 } rstruct;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
895
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
896 time(&rstruct.time);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
897 rstruct.ptr = (void *) &rstruct;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
898
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
899 RAND_seed((void *) rdata, sizeof(rdata));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
900 RAND_seed((void *) &rstruct, sizeof(rstruct));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
901 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
902
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
903 sess->ssl_ctx = SSL_CTX_new(SSLv3_client_method());
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
904
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
905 if (!sess->ssl_ctx) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
906 ERR_error_string_n(ERR_get_error(), buf, sizeof(buf));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
907 gg_debug(GG_DEBUG_MISC, "// gg_login() SSL_CTX_new() failed: %s\n", buf);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
908 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
909 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
910
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
911 SSL_CTX_set_verify(sess->ssl_ctx, SSL_VERIFY_NONE, NULL);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
912
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
913 sess->ssl = SSL_new(sess->ssl_ctx);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
914
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
915 if (!sess->ssl) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
916 ERR_error_string_n(ERR_get_error(), buf, sizeof(buf));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
917 gg_debug(GG_DEBUG_MISC, "// gg_login() SSL_new() failed: %s\n", buf);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
918 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
919 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
920 #else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
921 gg_debug(GG_DEBUG_MISC, "// gg_login() client requested TLS but no support compiled in\n");
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
922
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
923 if (p->tls == GG_SSL_REQUIRED) {
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
924 errno = ENOSYS;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
925 goto fail;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
926 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
927 #endif
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
928 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
929
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
930 if (gg_proxy_enabled) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
931 hostname = gg_proxy_host;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
932 sess->proxy_port = port = gg_proxy_port;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
933 } else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
934 hostname = GG_APPMSG_HOST;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
935 port = GG_APPMSG_PORT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
936 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
937
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
938 if (p->hash_type)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
939 sess->hash_type = p->hash_type;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
940 else
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
941 sess->hash_type = GG_LOGIN_HASH_SHA1;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
942
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
943 if (!p->async) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
944 struct in_addr addr;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
945
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
946 if (!sess->server_addr) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
947 if ((addr.s_addr = inet_addr(hostname)) == INADDR_NONE) {
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
948 struct in_addr *addr_list = NULL;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
949 int addr_count;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
950
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
951 if (gg_gethostbyname_real(hostname, &addr_list, &addr_count, 0) == -1 || addr_count == 0) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
952 gg_debug(GG_DEBUG_MISC, "// gg_login() host \"%s\" not found\n", hostname);
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
953 free(addr_list);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
954 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
955 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
956
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
957 addr = addr_list[0];
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
958
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
959 free(addr_list);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
960 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
961 } else {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
962 addr.s_addr = sess->server_addr;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
963 port = sess->port;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
964 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
965
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
966 sess->hub_addr = addr.s_addr;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
967
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
968 if (gg_proxy_enabled)
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
969 sess->proxy_addr = addr.s_addr;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
970
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
971 if ((sess->fd = gg_connect(&addr, port, 0)) == -1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
972 gg_debug(GG_DEBUG_MISC, "// gg_login() connection failed (errno=%d, %s)\n", errno, strerror(errno));
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
973
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
974 /* nie wyszło? próbujemy portu 443. */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
975 if (sess->server_addr) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
976 sess->port = GG_HTTPS_PORT;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
977
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
978 if ((sess->fd = gg_connect(&addr, GG_HTTPS_PORT, 0)) == -1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
979 /* ostatnia deska ratunku zawiodła?
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
980 * w takim razie zwijamy manatki. */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
981 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_login() connection failed (errno=%d, %s)\n", errno, strerror(errno));
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
982 goto fail;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
983 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
984 } else {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
985 goto fail;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
986 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
987 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
988
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
989 if (sess->server_addr)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
990 sess->state = GG_STATE_CONNECTING_GG;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
991 else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
992 sess->state = GG_STATE_CONNECTING_HUB;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
993
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
994 while (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
995 struct gg_event *e;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
996
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
997 if (!(e = gg_watch_fd(sess))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
998 gg_debug(GG_DEBUG_MISC, "// gg_login() critical error in gg_watch_fd()\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
999 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1000 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1001
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1002 if (e->type == GG_EVENT_CONN_FAILED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1003 errno = EACCES;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1004 gg_debug(GG_DEBUG_MISC, "// gg_login() could not login\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1005 gg_event_free(e);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1006 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1007 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1008
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1009 gg_event_free(e);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1010 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1011
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1012 return sess;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1013 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1014
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1015 if (!sess->server_addr || gg_proxy_enabled) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1016 if (sess->resolver_start(&sess->fd, &sess->resolver, hostname) == -1) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1017 gg_debug(GG_DEBUG_MISC, "// gg_login() resolving failed (errno=%d, %s)\n", errno, strerror(errno));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1018 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1019 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1020 } else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1021 if ((sess->fd = gg_connect(&sess->server_addr, sess->port, sess->async)) == -1) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1022 gg_debug(GG_DEBUG_MISC, "// gg_login() direct connection failed (errno=%d, %s)\n", errno, strerror(errno));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1023 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1024 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1025 sess->state = GG_STATE_CONNECTING_GG;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1026 sess->check = GG_CHECK_WRITE;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1027 sess->soft_timeout = 1;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1028 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1029
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1030 return sess;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1031
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1032 fail:
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1033 if (sess) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1034 free(sess->password);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1035 free(sess->initial_descr);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1036 free(sess);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1037 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1038
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1039 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1040 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1041
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1042 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1043 * Wysyła do serwera pakiet utrzymania połączenia.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1044 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1045 * Klient powinien regularnie co minutę wysyłać pakiet utrzymania połączenia,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1046 * inaczej serwer uzna, że klient stracił łączność z siecią i zerwie
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1047 * połączenie.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1048 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1049 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1050 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1051 * \return 0 jeśli się powiodło, -1 w przypadku błędu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1052 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1053 * \ingroup login
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1054 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1055 int gg_ping(struct gg_session *sess)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1056 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1057 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_ping(%p);\n", sess);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1058
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1059 if (!sess) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1060 errno = EFAULT;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1061 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1062 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1063
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1064 if (sess->state != GG_STATE_CONNECTED) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1065 errno = ENOTCONN;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1066 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1067 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1068
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1069 return gg_send_packet(sess, GG_PING, NULL);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1070 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1071
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1072 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1073 * Kończy połączenie z serwerem.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1074 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1075 * Funkcja nie zwalnia zasobów, więc po jej wywołaniu należy użyć
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1076 * \c gg_free_session(). Jeśli chce się ustawić opis niedostępności, należy
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1077 * wcześniej wywołać funkcję \c gg_change_status_descr() lub
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1078 * \c gg_change_status_descr_time().
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1079 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1080 * \note Jeśli w buforze nadawczym połączenia z serwerem znajdują się jeszcze
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1081 * dane (np. z powodu strat pakietów na łączu), prawdopodobnie zostaną one
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1082 * utracone przy zrywaniu połączenia. Aby mieć pewność, że opis statusu
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1083 * zostanie zachowany, należy ustawić stan \c GG_STATUS_NOT_AVAIL_DESCR
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1084 * za pomocą funkcji \c gg_change_status_descr() i poczekać na zdarzenie
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1085 * \c GG_EVENT_DISCONNECT_ACK.
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1086 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1087 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1088 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1089 * \ingroup login
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1090 */
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1091 void gg_logoff(struct gg_session *sess)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1092 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1093 if (!sess)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1094 return;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1095
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1096 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_logoff(%p);\n", sess);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1097
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1098 #ifdef GG_CONFIG_HAVE_GNUTLS
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1099 if (sess->ssl != NULL)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1100 gnutls_bye(GG_SESSION_GNUTLS(sess), GNUTLS_SHUT_RDWR);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1101 #endif
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1102
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1103 #ifdef GG_CONFIG_HAVE_OPENSSL
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1104 if (sess->ssl != NULL)
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1105 SSL_shutdown(sess->ssl);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1106 #endif
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1107
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1108 sess->resolver_cleanup(&sess->resolver, 1);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1109
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1110 if (sess->fd != -1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1111 close(sess->fd);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1112 sess->fd = -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1113 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1114
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1115 #ifdef GG_CONFIG_HAVE_GNUTLS
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1116 if (sess->ssl != NULL) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1117 gg_session_gnutls_t *tmp;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1118
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1119 tmp = (gg_session_gnutls_t*) sess->ssl;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1120 gnutls_deinit(tmp->session);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1121 gnutls_certificate_free_credentials(tmp->xcred);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1122 gnutls_global_deinit();
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1123 free(sess->ssl);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1124 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1125 #endif
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1126
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1127 if (sess->send_buf) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1128 free(sess->send_buf);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1129 sess->send_buf = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1130 sess->send_left = 0;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1131 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1132 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1133
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1134 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1135 * Zwalnia zasoby używane przez połączenie z serwerem. Funkcję należy wywołać
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1136 * po zamknięciu połączenia z serwerem, by nie doprowadzić do wycieku zasobów
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1137 * systemowych.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1138 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1139 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1140 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1141 * \ingroup login
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1142 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1143 void gg_free_session(struct gg_session *sess)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1144 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1145 struct gg_dcc7 *dcc;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1146
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1147 if (!sess)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1148 return;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1149
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1150 /* XXX dopisać zwalnianie i zamykanie wszystkiego, co mogło zostać */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1151
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1152 free(sess->password);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1153 free(sess->initial_descr);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1154 free(sess->client_version);
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1155 free(sess->recv_buf);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1156 free(sess->header_buf);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1157
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1158 #ifdef GG_CONFIG_HAVE_OPENSSL
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1159 if (sess->ssl)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1160 SSL_free(sess->ssl);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1161
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1162 if (sess->ssl_ctx)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1163 SSL_CTX_free(sess->ssl_ctx);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1164 #endif
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1165
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1166 sess->resolver_cleanup(&sess->resolver, 1);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1167
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1168 if (sess->fd != -1)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1169 close(sess->fd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1170
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1171 while (sess->images)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1172 gg_image_queue_remove(sess, sess->images, 1);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1173
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1174 free(sess->send_buf);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1175
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1176 for (dcc = sess->dcc7_list; dcc; dcc = dcc->next)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1177 dcc->sess = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1178
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1179 free(sess);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1180 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1181
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1182 #ifndef DOXYGEN
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1183
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1184 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1185 * \internal Funkcja wysyłająca pakiet zmiany statusu użytkownika.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1186 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1187 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1188 * \param status Nowy status użytkownika
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1189 * \param descr Opis statusu użytkownika (lub \c NULL)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1190 * \param time Czas powrotu w postaci uniksowego znacznika czasu (lub 0)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1191 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1192 * \return 0 jeśli się powiodło, -1 w przypadku błędu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1193 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1194 * \ingroup status
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1195 */
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1196 static int gg_change_status_common(struct gg_session *sess, int status, const char *descr, int time)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1197 {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1198 char *new_descr = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1199 uint32_t new_time;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1200 int descr_len = 0;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1201 int descr_len_max;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1202 int packet_type;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1203 int append_null = 0;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1204 int res;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1205
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1206 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1207 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1208 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1209 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1210
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1211 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1212 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1213 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1214 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1215
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1216 /* XXX, obcinać stany których stary protokół niezna (czyt. dnd->aw; ffc->av) */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1217
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1218 /* dodaj flagę obsługi połączeń głosowych zgodną z GG 7.x */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1219 if ((sess->protocol_version >= 0x2a) && (sess->protocol_version < 0x2d /* ? */ ) && (sess->protocol_flags & GG_HAS_AUDIO_MASK) && !GG_S_I(status))
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1220 status |= GG_STATUS_VOICE_MASK;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1221
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1222 sess->status = status;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1223
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1224 if (sess->protocol_version >= 0x2d) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1225 if (descr != NULL && sess->encoding != GG_ENCODING_UTF8) {
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1226 new_descr = gg_encoding_convert(descr, GG_ENCODING_CP1250, GG_ENCODING_UTF8, -1, -1);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1227
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1228 if (!new_descr)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1229 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1230 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1231
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1232 if (sess->protocol_version >= 0x2e)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1233 packet_type = GG_NEW_STATUS80;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1234 else /* sess->protocol_version == 0x2d */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1235 packet_type = GG_NEW_STATUS80BETA;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1236 descr_len_max = GG_STATUS_DESCR_MAXSIZE;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1237 append_null = 1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1238
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1239 } else {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1240 packet_type = GG_NEW_STATUS;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1241 descr_len_max = GG_STATUS_DESCR_MAXSIZE_PRE_8_0;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1242
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1243 if (time != 0)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1244 append_null = 1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1245 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1246
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1247 if (descr) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1248 descr_len = strlen((new_descr) ? new_descr : descr);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1249
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1250 if (descr_len > descr_len_max)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1251 descr_len = descr_len_max;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1252
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1253 // XXX pamiętać o tym, żeby nie ucinać w środku znaku utf-8
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1254 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1255
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1256 if (time)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1257 new_time = gg_fix32(time);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1258
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1259 if (packet_type == GG_NEW_STATUS80) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1260 struct gg_new_status80 p;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1261
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1262 p.status = gg_fix32(status);
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1263 p.flags = gg_fix32(sess->status_flags);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1264 p.description_size = gg_fix32(descr_len);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1265 res = gg_send_packet(sess,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1266 packet_type,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1267 &p,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1268 sizeof(p),
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1269 (new_descr) ? new_descr : descr,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1270 descr_len,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1271 NULL);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1272
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1273 } else {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1274 struct gg_new_status p;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1275
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1276 p.status = gg_fix32(status);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1277 res = gg_send_packet(sess,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1278 packet_type,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1279 &p,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1280 sizeof(p),
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1281 (new_descr) ? new_descr : descr,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1282 descr_len,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1283 (append_null) ? "\0" : NULL,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1284 (append_null) ? 1 : 0,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1285 (time) ? &new_time : NULL,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1286 (time) ? sizeof(new_time) : 0,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1287 NULL);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1288 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1289
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1290 free(new_descr);
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1291
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1292 if (GG_S_NA(status)) {
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1293 sess->state = GG_STATE_DISCONNECTING;
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1294 sess->timeout = GG_TIMEOUT_DISCONNECT;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1295 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1296
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1297 return res;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1298 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1299
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1300 #endif /* DOXYGEN */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1301
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1302 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1303 * Zmienia status użytkownika.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1304 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1305 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1306 * \param status Nowy status użytkownika
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1307 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1308 * \return 0 jeśli się powiodło, -1 w przypadku błędu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1309 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1310 * \ingroup status
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1311 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1312 int gg_change_status(struct gg_session *sess, int status)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1313 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1314 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_change_status(%p, %d);\n", sess, status);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1315
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1316 return gg_change_status_common(sess, status, NULL, 0);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1317 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1318
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1319 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1320 * Zmienia status użytkownika na status opisowy.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1321 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1322 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1323 * \param status Nowy status użytkownika
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1324 * \param descr Opis statusu użytkownika
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1325 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1326 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1327 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1328 * \ingroup status
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1329 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1330 int gg_change_status_descr(struct gg_session *sess, int status, const char *descr)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1331 {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1332 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_change_status_descr(%p, %d, \"%s\");\n", sess, status, descr);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1333
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1334 return gg_change_status_common(sess, status, descr, 0);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1335 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1336
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1337 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1338 * Zmienia status użytkownika na status opisowy z podanym czasem powrotu.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1339 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1340 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1341 * \param status Nowy status użytkownika
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1342 * \param descr Opis statusu użytkownika
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1343 * \param time Czas powrotu w postaci uniksowego znacznika czasu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1344 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1345 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1346 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1347 * \ingroup status
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1348 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1349 int gg_change_status_descr_time(struct gg_session *sess, int status, const char *descr, int time)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1350 {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1351 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_change_status_descr_time(%p, %d, \"%s\", %d);\n", sess, status, descr, time);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1352
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1353 return gg_change_status_common(sess, status, descr, time);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1354 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1355
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1356 /**
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1357 * Funkcja zmieniająca flagi statusu.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1358 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1359 * \param sess Struktura sesji
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1360 * \param flags Nowe flagi statusu
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1361 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1362 * \return 0 jeśli się powiodło, -1 w przypadku błędu
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1363 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1364 * \note Aby zmiany weszły w życie, należy ponownie ustawić status za pomocą
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1365 * funkcji z rodziny \c gg_change_status().
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1366 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1367 * \ingroup status
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1368 */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1369 int gg_change_status_flags(struct gg_session *sess, int flags)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1370 {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1371 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_change_status_flags(%p, 0x%08x);\n", sess, flags);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1372
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1373 if (sess == NULL) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1374 errno = EFAULT;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1375 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1376 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1377
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1378 sess->status_flags = flags;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1379
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1380 return 0;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1381 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1382
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1383 /**
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1384 * Wysyła wiadomość do użytkownika.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1385 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1386 * Zwraca losowy numer sekwencyjny, który można zignorować albo wykorzystać
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1387 * do potwierdzenia.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1388 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1389 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1390 * \param msgclass Klasa wiadomości
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1391 * \param recipient Numer adresata
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1392 * \param message Treść wiadomości
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1393 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1394 * \return Numer sekwencyjny wiadomości lub -1 w przypadku błędu.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1395 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1396 * \ingroup messages
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1397 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1398 int gg_send_message(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1399 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1400 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message(%p, %d, %u, %p)\n", sess, msgclass, recipient, message);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1401
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1402 return gg_send_message_confer_richtext(sess, msgclass, 1, &recipient, message, NULL, 0);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1403 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1404
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1405 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1406 * Wysyła wiadomość formatowaną.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1407 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1408 * Zwraca losowy numer sekwencyjny, który można zignorować albo wykorzystać
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1409 * do potwierdzenia.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1410 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1411 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1412 * \param msgclass Klasa wiadomości
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1413 * \param recipient Numer adresata
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1414 * \param message Treść wiadomości
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1415 * \param format Informacje o formatowaniu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1416 * \param formatlen Długość informacji o formatowaniu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1417 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1418 * \return Numer sekwencyjny wiadomości lub -1 w przypadku błędu.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1419 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1420 * \ingroup messages
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1421 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1422 int gg_send_message_richtext(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, const unsigned char *format, int formatlen)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1423 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1424 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_richtext(%p, %d, %u, %p, %p, %d);\n", sess, msgclass, recipient, message, format, formatlen);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1425
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1426 return gg_send_message_confer_richtext(sess, msgclass, 1, &recipient, message, format, formatlen);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1427 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1428
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1429 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1430 * Wysyła wiadomość w ramach konferencji.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1431 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1432 * Zwraca losowy numer sekwencyjny, który można zignorować albo wykorzystać
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1433 * do potwierdzenia.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1434 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1435 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1436 * \param msgclass Klasa wiadomości
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1437 * \param recipients_count Liczba adresatów
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1438 * \param recipients Wskaźnik do tablicy z numerami adresatów
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1439 * \param message Treść wiadomości
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1440 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1441 * \return Numer sekwencyjny wiadomości lub -1 w przypadku błędu.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1442 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1443 * \ingroup messages
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1444 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1445 int gg_send_message_confer(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *message)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1446 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1447 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_confer(%p, %d, %d, %p, %p);\n", sess, msgclass, recipients_count, recipients, message);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1448
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1449 return gg_send_message_confer_richtext(sess, msgclass, recipients_count, recipients, message, NULL, 0);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1450 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1451
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1452 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1453 * Wysyła wiadomość formatowaną w ramach konferencji.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1454 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1455 * Zwraca losowy numer sekwencyjny, który można zignorować albo wykorzystać
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1456 * do potwierdzenia.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1457 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1458 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1459 * \param msgclass Klasa wiadomości
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1460 * \param recipients_count Liczba adresatów
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1461 * \param recipients Wskaźnik do tablicy z numerami adresatów
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1462 * \param message Treść wiadomości
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1463 * \param format Informacje o formatowaniu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1464 * \param formatlen Długość informacji o formatowaniu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1465 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1466 * \return Numer sekwencyjny wiadomości lub -1 w przypadku błędu.
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1467 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1468 * \ingroup messages
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1469 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1470 int gg_send_message_confer_richtext(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *message, const unsigned char *format, int formatlen)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1471 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1472 struct gg_send_msg s;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1473 struct gg_send_msg80 s80;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1474 struct gg_msg_recipients r;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1475 char *cp_msg = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1476 char *utf_msg = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1477 char *html_msg = NULL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1478 int seq_no;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1479 int i, j, k;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1480 uin_t *recps;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1481
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1482 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_confer_richtext(%p, %d, %d, %p, %p, %p, %d);\n", sess, msgclass, recipients_count, recipients, message, format, formatlen);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1483
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1484 if (!sess) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1485 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1486 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1487 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1488
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1489 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1490 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1491 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1492 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1493
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1494 if (message == NULL || recipients_count <= 0 || recipients_count > 0xffff || (recipients_count != 1 && recipients == NULL)) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1495 errno = EINVAL;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1496 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1497 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1498
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1499 if (sess->encoding == GG_ENCODING_UTF8) {
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1500 if (!(cp_msg = gg_encoding_convert((const char *) message, GG_ENCODING_UTF8, GG_ENCODING_CP1250, -1, -1)))
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1501 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1502
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1503 utf_msg = (char*) message;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1504 } else {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1505 if (sess->protocol_version >= 0x2d) {
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1506 if (!(utf_msg = gg_encoding_convert((const char *) message, GG_ENCODING_CP1250, GG_ENCODING_UTF8, -1, -1)))
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1507 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1508 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1509
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1510 cp_msg = (char*) message;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1511 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1512
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1513 if (sess->protocol_version < 0x2d) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1514 if (!sess->seq)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1515 sess->seq = 0x01740000 | (rand() & 0xffff);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1516 seq_no = sess->seq;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1517 sess->seq += (rand() % 0x300) + 0x300;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1518
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1519 s.msgclass = gg_fix32(msgclass);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1520 s.seq = gg_fix32(seq_no);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1521 } else {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1522 int len;
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1523
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1524 // Drobne odchylenie od protokołu. Jeśli wysyłamy kilka
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1525 // wiadomości w ciągu jednej sekundy, zwiększamy poprzednią
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1526 // wartość, żeby każda wiadomość miała unikalny numer.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1527
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1528 seq_no = time(NULL);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1529
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1530 if (seq_no <= sess->seq)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1531 seq_no = sess->seq + 1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1532
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1533 sess->seq = seq_no;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1534
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1535 if (format == NULL || formatlen < 3) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1536 format = (unsigned char*) "\x02\x06\x00\x00\x00\x08\x00\x00\x00";
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1537 formatlen = 9;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1538 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1539
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1540 len = gg_message_text_to_html(NULL, utf_msg, (char*) format + 3, formatlen - 3);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1541
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1542 html_msg = malloc(len + 1);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1543
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1544 if (html_msg == NULL) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1545 seq_no = -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1546 goto cleanup;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1547 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1548
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1549 gg_message_text_to_html(html_msg, utf_msg, (char*) format + 3, formatlen - 3);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1550
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1551 s80.seq = gg_fix32(seq_no);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1552 s80.msgclass = gg_fix32(msgclass);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1553 s80.offset_plain = gg_fix32(sizeof(s80) + strlen(html_msg) + 1);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1554 s80.offset_attr = gg_fix32(sizeof(s80) + strlen(html_msg) + 1 + strlen(cp_msg) + 1);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1555 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1556
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1557 if (recipients_count > 1) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1558 r.flag = 0x01;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1559 r.count = gg_fix32(recipients_count - 1);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1560
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1561 recps = malloc(sizeof(uin_t) * recipients_count);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1562
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1563 if (!recps) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1564 seq_no = -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1565 goto cleanup;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1566 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1567
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1568 for (i = 0; i < recipients_count; i++) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1569 for (j = 0, k = 0; j < recipients_count; j++) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1570 if (recipients[j] != recipients[i]) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1571 recps[k] = gg_fix32(recipients[j]);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1572 k++;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1573 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1574 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1575
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1576 if (sess->protocol_version < 0x2d) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1577 s.recipient = gg_fix32(recipients[i]);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1578
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1579 if (gg_send_packet(sess, GG_SEND_MSG, &s, sizeof(s), cp_msg, strlen(cp_msg) + 1, &r, sizeof(r), recps, (recipients_count - 1) * sizeof(uin_t), format, formatlen, NULL) == -1)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1580 seq_no = -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1581 } else {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1582 s80.recipient = gg_fix32(recipients[i]);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1583
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1584 if (gg_send_packet(sess, GG_SEND_MSG80, &s80, sizeof(s80), html_msg, strlen(html_msg) + 1, cp_msg, strlen(cp_msg) + 1, &r, sizeof(r), recps, (recipients_count - 1) * sizeof(uin_t), format, formatlen, NULL) == -1)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1585 seq_no = -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1586 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1587 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1588
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1589 free(recps);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1590 } else {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1591 if (sess->protocol_version < 0x2d) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1592 s.recipient = gg_fix32(recipients[0]);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1593
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1594 if (gg_send_packet(sess, GG_SEND_MSG, &s, sizeof(s), cp_msg, strlen(cp_msg) + 1, format, formatlen, NULL) == -1)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1595 seq_no = -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1596 } else {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1597 s80.recipient = gg_fix32(recipients[0]);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1598
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1599 if (gg_send_packet(sess, GG_SEND_MSG80, &s80, sizeof(s80), html_msg, strlen(html_msg) + 1, cp_msg, strlen(cp_msg) + 1, format, formatlen, NULL) == -1)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1600 seq_no = -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1601 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1602 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1603
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1604 cleanup:
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1605 if (cp_msg != (char*) message)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1606 free(cp_msg);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1607
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1608 if (utf_msg != (char*) message)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1609 free(utf_msg);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1610
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1611 free(html_msg);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1612
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1613 return seq_no;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1614 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1615
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1616 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1617 * Wysyła wiadomość binarną przeznaczoną dla klienta.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1618 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1619 * Wiadomości między klientami przesyła się np. w celu wywołania zwrotnego
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1620 * połączenia bezpośredniego. Funkcja zwraca losowy numer sekwencyjny,
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1621 * który można zignorować albo wykorzystać do potwierdzenia.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1622 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1623 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1624 * \param msgclass Klasa wiadomości
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1625 * \param recipient Numer adresata
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1626 * \param message Treść wiadomości
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1627 * \param message_len Długość wiadomości
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1628 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1629 * \return Numer sekwencyjny wiadomości lub -1 w przypadku błędu.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1630 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1631 * \ingroup messages
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1632 */
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1633 int gg_send_message_ctcp(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, int message_len)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1634 {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1635 struct gg_send_msg s;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1636
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1637 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_ctcp(%p, %d, %u, ...);\n", sess, msgclass, recipient);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1638
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1639 if (!sess) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1640 errno = EFAULT;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1641 return -1;
11546
acb5676e57bb [gaim-migrate @ 13801]
Daniel Atallah <datallah@pidgin.im>
parents: 11360
diff changeset
1642 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1643
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1644 if (sess->state != GG_STATE_CONNECTED) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1645 errno = ENOTCONN;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1646 return -1;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1647 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1648
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1649 s.recipient = gg_fix32(recipient);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1650 s.seq = gg_fix32(0);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1651 s.msgclass = gg_fix32(msgclass);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1652
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1653 return gg_send_packet(sess, GG_SEND_MSG, &s, sizeof(s), message, message_len, NULL);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1654 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1655
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1656 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1657 * Wysyła żądanie obrazka o podanych parametrach.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1658 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1659 * Wiadomości obrazkowe nie zawierają samych obrazków, a tylko ich rozmiary
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1660 * i sumy kontrolne. Odbiorca najpierw szuka obrazków w swojej pamięci
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1661 * podręcznej i dopiero gdy ich nie znajdzie, wysyła żądanie do nadawcy.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1662 * Wynik zostanie przekazany zdarzeniem \c GG_EVENT_IMAGE_REPLY.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1663 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1664 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1665 * \param recipient Numer adresata
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1666 * \param size Rozmiar obrazka w bajtach
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1667 * \param crc32 Suma kontrola obrazka
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1668 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1669 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1670 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1671 * \ingroup messages
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1672 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1673 int gg_image_request(struct gg_session *sess, uin_t recipient, int size, uint32_t crc32)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1674 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1675 struct gg_send_msg s;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1676 struct gg_msg_image_request r;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1677 char dummy = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1678 int res;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1679
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1680 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_image_request(%p, %d, %u, 0x%.4x);\n", sess, recipient, size, crc32);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1681
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1682 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1683 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1684 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1685 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1686
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1687 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1688 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1689 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1690 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1691
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1692 if (size < 0) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1693 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1694 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1695 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1696
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1697 s.recipient = gg_fix32(recipient);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1698 s.seq = gg_fix32(0);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1699 s.msgclass = gg_fix32(GG_CLASS_MSG);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1700
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1701 r.flag = 0x04;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1702 r.size = gg_fix32(size);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1703 r.crc32 = gg_fix32(crc32);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1704
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1705 res = gg_send_packet(sess, GG_SEND_MSG, &s, sizeof(s), &dummy, 1, &r, sizeof(r), NULL);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1706
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1707 if (!res) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1708 struct gg_image_queue *q = malloc(sizeof(*q));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1709 char *buf;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1710
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1711 if (!q) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1712 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_image_request() not enough memory for image queue\n");
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1713 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1714 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1715
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1716 buf = malloc(size);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1717 if (size && !buf)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1718 {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1719 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_image_request() not enough memory for image\n");
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1720 free(q);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1721 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1722 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1723
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1724 memset(q, 0, sizeof(*q));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1725
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1726 q->sender = recipient;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1727 q->size = size;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1728 q->crc32 = crc32;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1729 q->image = buf;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1730
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1731 if (!sess->images)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1732 sess->images = q;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1733 else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1734 struct gg_image_queue *qq;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1735
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1736 for (qq = sess->images; qq->next; qq = qq->next)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1737 ;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1738
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1739 qq->next = q;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1740 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1741 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1742
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1743 return res;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1744 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1745
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1746 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1747 * Wysyła żądany obrazek.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1748 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1749 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1750 * \param recipient Numer adresata
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1751 * \param filename Nazwa pliku
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1752 * \param image Bufor z obrazkiem
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1753 * \param size Rozmiar obrazka
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1754 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1755 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1756 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1757 * \ingroup messages
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1758 */
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1759 int gg_image_reply(struct gg_session *sess, uin_t recipient, const char *filename, const char *image, int size)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1760 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1761 struct gg_msg_image_reply *r;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1762 struct gg_send_msg s;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1763 const char *tmp;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1764 char buf[1910];
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1765 int res = -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1766
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1767 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_image_reply(%p, %d, \"%s\", %p, %d);\n", sess, recipient, filename, image, size);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1768
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1769 if (!sess || !filename || !image) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1770 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1771 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1772 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1773
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1774 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1775 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1776 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1777 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1778
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1779 if (size < 0) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1780 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1781 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1782 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1783
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1784 /* wytnij ścieżki, zostaw tylko nazwę pliku */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1785 while ((tmp = strrchr(filename, '/')) || (tmp = strrchr(filename, '\\')))
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1786 filename = tmp + 1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1787
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1788 if (strlen(filename) < 1 || strlen(filename) > 1024) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1789 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1790 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1791 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1792
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1793 s.recipient = gg_fix32(recipient);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1794 s.seq = gg_fix32(0);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1795 s.msgclass = gg_fix32(GG_CLASS_MSG);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1796
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1797 buf[0] = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1798 r = (void*) &buf[1];
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1799
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1800 r->flag = 0x05;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1801 r->size = gg_fix32(size);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1802 r->crc32 = gg_fix32(gg_crc32(0, (unsigned char*) image, size));
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1803
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1804 while (size > 0) {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1805 int buflen, chunklen;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1806
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1807 /* \0 + struct gg_msg_image_reply */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1808 buflen = sizeof(struct gg_msg_image_reply) + 1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1809
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1810 /* w pierwszym kawałku jest nazwa pliku */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1811 if (r->flag == 0x05) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1812 strcpy(buf + buflen, filename);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1813 buflen += strlen(filename) + 1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1814 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1815
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1816 chunklen = (size >= sizeof(buf) - buflen) ? (sizeof(buf) - buflen) : size;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1817
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1818 memcpy(buf + buflen, image, chunklen);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1819 size -= chunklen;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1820 image += chunklen;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1821
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1822 res = gg_send_packet(sess, GG_SEND_MSG, &s, sizeof(s), buf, buflen + chunklen, NULL);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1823
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1824 if (res == -1)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1825 break;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1826
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1827 r->flag = 0x06;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1828 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1829
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1830 return res;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1831 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1832
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1833 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1834 * Wysyła do serwera listę kontaktów.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1835 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1836 * Funkcja informuje serwer o liście kontaktów, których statusy będą
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1837 * obserwowane lub kontaktów, które bedą blokowane. Dla każdego z \c count
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1838 * kontaktów tablica \c userlist zawiera numer, a tablica \c types rodzaj
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1839 * kontaktu (\c GG_USER_NORMAL, \c GG_USER_OFFLINE, \c GG_USER_BLOCKED).
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1840 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1841 * Listę kontaktów należy \b zawsze wysyłać po połączeniu, nawet jeśli
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1842 * jest pusta.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1843 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1844 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1845 * \param userlist Wskaźnik do tablicy numerów kontaktów
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1846 * \param types Wskaźnik do tablicy rodzajów kontaktów
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1847 * \param count Liczba kontaktów
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1848 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1849 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1850 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1851 * \ingroup contacts
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1852 */
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1853 int gg_notify_ex(struct gg_session *sess, uin_t *userlist, char *types, int count)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1854 {
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1855 struct gg_notify *n;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1856 uin_t *u;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1857 char *t;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1858 int i, res = 0;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1859
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1860 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_notify_ex(%p, %p, %p, %d);\n", sess, userlist, types, count);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1861
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1862 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1863 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1864 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1865 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1866
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1867 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1868 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1869 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1870 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1871
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1872 if (!userlist || !count)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1873 return gg_send_packet(sess, GG_LIST_EMPTY, NULL);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1874
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1875 while (count > 0) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1876 int part_count, packet_type;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1877
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1878 if (count > 400) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1879 part_count = 400;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1880 packet_type = GG_NOTIFY_FIRST;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1881 } else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1882 part_count = count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1883 packet_type = GG_NOTIFY_LAST;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1884 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1885
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1886 if (!(n = (struct gg_notify*) malloc(sizeof(*n) * part_count)))
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1887 return -1;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1888
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1889 for (u = userlist, t = types, i = 0; i < part_count; u++, t++, i++) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1890 n[i].uin = gg_fix32(*u);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1891 n[i].dunno1 = *t;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1892 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1893
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1894 if (gg_send_packet(sess, packet_type, n, sizeof(*n) * part_count, NULL) == -1) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1895 free(n);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1896 res = -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1897 break;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1898 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1899
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1900 count -= part_count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1901 userlist += part_count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1902 types += part_count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1903
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1904 free(n);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1905 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1906
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1907 return res;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1908 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1909
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1910 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1911 * Wysyła do serwera listę kontaktów.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1912 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1913 * Funkcja jest odpowiednikiem \c gg_notify_ex(), gdzie wszystkie kontakty
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1914 * są rodzaju \c GG_USER_NORMAL.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1915 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1916 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1917 * \param userlist Wskaźnik do tablicy numerów kontaktów
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1918 * \param count Liczba kontaktów
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1919 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1920 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1921 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1922 * \ingroup contacts
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1923 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1924 int gg_notify(struct gg_session *sess, uin_t *userlist, int count)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1925 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1926 struct gg_notify *n;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1927 uin_t *u;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1928 int i, res = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1929
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1930 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_notify(%p, %p, %d);\n", sess, userlist, count);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1931
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1932 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1933 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1934 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1935 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1936
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1937 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1938 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1939 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1940 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1941
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1942 if (!userlist || !count)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1943 return gg_send_packet(sess, GG_LIST_EMPTY, NULL);
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1944
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1945 while (count > 0) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1946 int part_count, packet_type;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1947
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1948 if (count > 400) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1949 part_count = 400;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1950 packet_type = GG_NOTIFY_FIRST;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1951 } else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1952 part_count = count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1953 packet_type = GG_NOTIFY_LAST;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1954 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1955
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1956 if (!(n = (struct gg_notify*) malloc(sizeof(*n) * part_count)))
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1957 return -1;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1958
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1959 for (u = userlist, i = 0; i < part_count; u++, i++) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1960 n[i].uin = gg_fix32(*u);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1961 n[i].dunno1 = GG_USER_NORMAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1962 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1963
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1964 if (gg_send_packet(sess, packet_type, n, sizeof(*n) * part_count, NULL) == -1) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1965 res = -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1966 free(n);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1967 break;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1968 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1969
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1970 free(n);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1971
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1972 userlist += part_count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1973 count -= part_count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1974 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1975
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1976 return res;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1977 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1978
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1979 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1980 * Dodaje kontakt.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1981 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1982 * Dodaje do listy kontaktów dany numer w trakcie połączenia. Aby zmienić
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1983 * rodzaj kontaktu (np. z normalnego na zablokowany), należy najpierw usunąć
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1984 * poprzedni rodzaj, ponieważ serwer operuje na maskach bitowych.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1985 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1986 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1987 * \param uin Numer kontaktu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1988 * \param type Rodzaj kontaktu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1989 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1990 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1991 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1992 * \ingroup contacts
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1993 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1994 int gg_add_notify_ex(struct gg_session *sess, uin_t uin, char type)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1995 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1996 struct gg_add_remove a;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1997
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1998 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_add_notify_ex(%p, %u, %d);\n", sess, uin, type);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1999
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2000 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2001 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2002 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2003 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2004
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2005 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2006 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2007 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2008 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2009
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2010 a.uin = gg_fix32(uin);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2011 a.dunno1 = type;
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2012
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2013 return gg_send_packet(sess, GG_ADD_NOTIFY, &a, sizeof(a), NULL);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2014 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2015
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2016 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2017 * Dodaje kontakt.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2018 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2019 * Funkcja jest odpowiednikiem \c gg_add_notify_ex(), gdzie rodzaj wszystkich
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2020 * kontaktów to \c GG_USER_NORMAL.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2021 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2022 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2023 * \param uin Numer kontaktu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2024 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2025 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2026 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2027 * \ingroup contacts
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2028 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2029 int gg_add_notify(struct gg_session *sess, uin_t uin)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2030 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2031 return gg_add_notify_ex(sess, uin, GG_USER_NORMAL);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2032 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2033
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2034 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2035 * Usuwa kontakt.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2036 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2037 * Usuwa z listy kontaktów dany numer w trakcie połączenia.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2038 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2039 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2040 * \param uin Numer kontaktu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2041 * \param type Rodzaj kontaktu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2042 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2043 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2044 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2045 * \ingroup contacts
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2046 */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2047 int gg_remove_notify_ex(struct gg_session *sess, uin_t uin, char type)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2048 {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2049 struct gg_add_remove a;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2050
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2051 gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_remove_notify_ex(%p, %u, %d);\n", sess, uin, type);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2052
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2053 if (!sess) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2054 errno = EFAULT;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2055 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2056 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2057
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2058 if (sess->state != GG_STATE_CONNECTED) {
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2059 errno = ENOTCONN;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2060 return -1;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2061 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2062
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2063 a.uin = gg_fix32(uin);
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2064 a.dunno1 = type;
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2065
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2066 return gg_send_packet(sess, GG_REMOVE_NOTIFY, &a, sizeof(a), NULL);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2067 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2068
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2069 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2070 * Usuwa kontakt.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2071 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2072 * Funkcja jest odpowiednikiem \c gg_add_notify_ex(), gdzie rodzaj wszystkich
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2073 * kontaktów to \c GG_USER_NORMAL.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2074 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2075 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2076 * \param uin Numer kontaktu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2077 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2078 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2079 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2080 * \ingroup contacts
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2081 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2082 int gg_remove_notify(struct gg_session *sess, uin_t uin)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2083 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2084 return gg_remove_notify_ex(sess, uin, GG_USER_NORMAL);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2085 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2086
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2087 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2088 * Wysyła do serwera zapytanie dotyczące listy kontaktów.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2089 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2090 * Funkcja służy do importu lub eksportu listy kontaktów do serwera.
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2091 * W odróżnieniu od funkcji \c gg_notify(), ta lista kontaktów jest przez
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2092 * serwer jedynie przechowywana i nie ma wpływu na połączenie. Format
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2093 * listy kontaktów jest ignorowany przez serwer, ale ze względu na
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2094 * kompatybilność z innymi klientami, należy przechowywać dane w tym samym
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2095 * formacie co oryginalny klient Gadu-Gadu.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2096 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2097 * Program nie musi się przejmować fragmentacją listy kontaktów wynikającą
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2098 * z protokołu -- wysyła i odbiera kompletną listę.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2099 *
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2100 * \param sess Struktura sesji
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2101 * \param type Rodzaj zapytania
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2102 * \param request Treść zapytania (może być równe NULL)
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2103 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2104 * \return 0 jeśli się powiodło, -1 w przypadku błędu
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2105 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2106 * \ingroup importexport
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2107 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2108 int gg_userlist_request(struct gg_session *sess, char type, const char *request)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2109 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2110 int len;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2111
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2112 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2113 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2114 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2115 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2116
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2117 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2118 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2119 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2120 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2121
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2122 if (!request) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2123 sess->userlist_blocks = 1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2124 return gg_send_packet(sess, GG_USERLIST_REQUEST, &type, sizeof(type), NULL);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2125 }
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2126
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2127 len = strlen(request);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2128
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2129 sess->userlist_blocks = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2130
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2131 while (len > 2047) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2132 sess->userlist_blocks++;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2133
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2134 if (gg_send_packet(sess, GG_USERLIST_REQUEST, &type, sizeof(type), request, 2047, NULL) == -1)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2135 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2136
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2137 if (type == GG_USERLIST_PUT)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2138 type = GG_USERLIST_PUT_MORE;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2139
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2140 request += 2047;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2141 len -= 2047;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2142 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2143
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2144 sess->userlist_blocks++;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2145
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2146 return gg_send_packet(sess, GG_USERLIST_REQUEST, &type, sizeof(type), request, len, NULL);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2147 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2148
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2149 /**
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2150 * Wysyła do serwera zapytanie dotyczące listy kontaktów (10.0).
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2151 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2152 * Funkcja służy do importu lub eksportu listy kontaktów do serwera.
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2153 * W odróżnieniu od funkcji \c gg_notify(), ta lista kontaktów jest przez
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2154 * serwer jedynie przechowywana i nie ma wpływu na połączenie. Format
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2155 * listy kontaktów jest jednak weryfikowany przez serwer, który stara się
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2156 * synchronizować listę kontaktów zapisaną w formatach GG 7.0 oraz GG 10.0.
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2157 * Serwer przyjmuje listy kontaktów przysłane w formacie niezgodnym z podanym
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2158 * jako \c format_type, ale nie zachowuje ich, a przesłanie takiej listy jest
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2159 * równoznaczne z usunięciem listy kontaktów.
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2160 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2161 * Program nie musi się przejmować kompresją listy kontaktów zgodną
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2162 * z protokołem -- wysyła i odbiera kompletną listę zapisaną czystym tekstem.
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2163 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2164 * \param sess Struktura sesji
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2165 * \param type Rodzaj zapytania
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2166 * \param version Numer ostatniej znanej programowi wersji listy kontaktów lub 0
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2167 * \param format_type Typ formatu listy kontaktów
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2168 * \param request Treść zapytania (może być równe NULL)
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2169 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2170 * \return 0 jeśli się powiodło, -1 w przypadku błędu
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2171 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2172 * \ingroup importexport
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2173 */
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2174 int gg_userlist100_request(struct gg_session *sess, char type, unsigned int version, char format_type, const char *request)
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2175 {
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2176 struct gg_userlist100_request pkt;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2177 unsigned char *zrequest;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2178 size_t zrequest_len;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2179 int ret;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2180
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2181 if (!sess) {
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2182 errno = EFAULT;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2183 return -1;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2184 }
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2185
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2186 if (sess->state != GG_STATE_CONNECTED) {
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2187 errno = ENOTCONN;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2188 return -1;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2189 }
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2190
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2191 pkt.type = type;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2192 pkt.version = gg_fix32(version);
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2193 pkt.format_type = format_type;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2194 pkt.unknown1 = 0x01;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2195
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2196 if (request == NULL)
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2197 return gg_send_packet(sess, GG_USERLIST100_REQUEST, &pkt, sizeof(pkt), NULL);
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2198
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2199 zrequest = gg_deflate(request, &zrequest_len);
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2200
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2201 if (zrequest == NULL) {
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2202 gg_debug_session(sess, GG_DEBUG_MISC, "// gg_userlist100_request() gg_deflate() failed");
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2203 return -1;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2204 }
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2205
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2206 ret = gg_send_packet(sess, GG_USERLIST100_REQUEST, &pkt, sizeof(pkt), zrequest, zrequest_len, NULL);
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2207
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2208 free(zrequest);
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2209
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2210 return ret;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2211 }
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2212
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2213 /**
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2214 * Informuje rozmówcę o pisaniu wiadomości.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2215 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2216 * \param sess Struktura sesji
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2217 * \param recipient Numer adresata
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2218 * \param length Długość wiadomości lub 0 jeśli jest pusta
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2219 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2220 * \return 0 jeśli się powiodło, -1 w przypadku błędu
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2221 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2222 * \ingroup messages
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2223 */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2224 int gg_typing_notification(struct gg_session *sess, uin_t recipient, int length){
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2225 struct gg_typing_notification pkt;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2226 uin_t uin;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2227
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2228 pkt.length = gg_fix16(length);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2229 uin = gg_fix32(recipient);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2230 memcpy(&pkt.uin, &uin, sizeof(uin_t));
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2231
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2232 return gg_send_packet(sess, GG_TYPING_NOTIFICATION, &pkt, sizeof(pkt), NULL);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2233 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2234
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2235 /**
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2236 * Rozłącza inną sesję multilogowania.
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2237 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2238 * \param gs Struktura sesji
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2239 * \param conn_id Sesja do rozłączenia
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2240 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2241 * \return 0 jeśli się powiodło, -1 w przypadku błędu
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2242 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2243 * \ingroup login
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2244 */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2245 int gg_multilogon_disconnect(struct gg_session *gs, gg_multilogon_id_t conn_id)
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2246 {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2247 struct gg_multilogon_disconnect pkt;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2248
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2249 pkt.conn_id = conn_id;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2250
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2251 return gg_send_packet(gs, GG_MULTILOGON_DISCONNECT, &pkt, sizeof(pkt), NULL);
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2252 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2253
29751
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2254 /* @} */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2255
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2256 /**
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2257 * Sprawdza czy biblioteka obsługuje daną funkcję.
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2258 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2259 * \param feature Identyfikator funkcji.
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2260 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2261 * \return Wartość niezerowa jeśli funkcja jest obsłgiwana.
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2262 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2263 * \ingroup version
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2264 */
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2265 int gg_libgadu_check_feature(gg_libgadu_feature_t feature)
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2266 {
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2267 switch (feature)
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2268 {
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2269 case GG_LIBGADU_FEATURE_SSL:
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2270 #if defined(GG_CONFIG_HAVE_OPENSSL) || defined(GG_CONFIG_HAVE_GNUTLS)
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2271 return 1;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2272 #else
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2273 return 0;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2274 #endif
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2275
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2276 case GG_LIBGADU_FEATURE_PTHREAD:
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2277 #ifdef GG_CONFIG_HAVE_PTHREAD
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2278 return 1;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2279 #else
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2280 return 0;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2281 #endif
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2282
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2283 case GG_LIBGADU_FEATURE_USERLIST100:
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2284 #ifdef GG_CONFIG_HAVE_ZLIB
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2285 return 1;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2286 #else
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2287 return 0;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2288 #endif
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2289
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2290 /* Celowo nie ma default, żeby kompilator wyłapał brakujące funkcje */
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2291
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2292 }
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2293
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2294 return 0;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2295 }
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2296
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2297 /*
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2298 * Local variables:
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2299 * c-indentation-style: k&r
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2300 * c-basic-offset: 8
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2301 * indent-tabs-mode: notnil
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2302 * End:
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2303 *
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2304 * vim: shiftwidth=8:
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2305 */

mercurial