libpurple/protocols/gg/lib/libgadu.c

Sun, 13 Jan 2013 15:09:02 -0600

author
Richard Laager <rlaager@pidgin.im>
date
Sun, 13 Jan 2013 15:09:02 -0600
changeset 33601
910e26960232
parent 33292
0ad1dc71f5c7
child 33710
0d7ead568881
permissions
-rw-r--r--

Merge revision 33422 from release-2.x.y

33286
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1 /* $Id: libgadu.c 1245 2012-01-10 22:48:31Z 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"
33285
32cbdbf016bd Gadu-Gadu: synchronize internal libgadu with upstream - part 4. Adds -Wall -Wextra -Werror switches. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32688
diff changeset
40 #include "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"
33285
32cbdbf016bd Gadu-Gadu: synchronize internal libgadu with upstream - part 4. Adds -Wall -Wextra -Werror switches. Refs #343
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 32688
diff changeset
42 #include "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
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
63 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
64 * 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
65 *
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
66 * \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
67 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
68 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
69
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
70 /**
438f88ecc11e Update 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 * 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
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 * \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
74 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
75 unsigned long gg_dcc_ip = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
76
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
77 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
78 * 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
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 * \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
81 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
82 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
83
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
84 /**
438f88ecc11e Update 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 * 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
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 * \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
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 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
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 /**
438f88ecc11e Update 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 * 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
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 * \ingroup proxy
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
95 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
96 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
97
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
98 /**
438f88ecc11e Update 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 * 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
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 * \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
102 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
103 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
104
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
105 /**
438f88ecc11e Update 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 * 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
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 * \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
109 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
110 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
111
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
112 /**
438f88ecc11e Update 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 * 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
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 * \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
116 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
117 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
118
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
119 /**
438f88ecc11e Update 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 * 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
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 * \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
123 */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
124 char *gg_proxy_password = NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
125
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
126 #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
127
438f88ecc11e Update 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 lint
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
129 static char rcsid[]
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
130 #ifdef __GNUC__
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
131 __attribute__ ((unused))
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
132 #endif
33286
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
133 = "$Id: libgadu.c 1245 2012-01-10 22:48:31Z wojtekka $";
12007
bf1190509b70 [gaim-migrate @ 14300]
Bartosz Oler <bartosz@pidgin.im>
parents: 11546
diff changeset
134 #endif
bf1190509b70 [gaim-migrate @ 14300]
Bartosz Oler <bartosz@pidgin.im>
parents: 11546
diff changeset
135
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
136 #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
137
438f88ecc11e Update 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 /**
438f88ecc11e Update 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 * Zwraca wersję biblioteki.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
140 *
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
141 * \return Wskaźnik na statyczny bufor z 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 * \ingroup version
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
144 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
145 const char *gg_libgadu_version()
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 return 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
33286
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
150 #ifdef HAVE_UINT64_T
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
151 /**
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
152 * \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
153 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
154 * 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
155 * 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
156 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
157 * \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
158 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
159 * \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
160 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
161 * \ingroup helper
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 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
164 {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
165 #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
166 return x;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
167 #else
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
168 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
169 (((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
170 ((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
171 ((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
172 ((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
173 ((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
174 ((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
175 ((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
176 ((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
177 #endif
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
178 }
33286
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
179 #endif /* HAVE_UINT64_T */
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
180
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
181 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
182 * \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
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 * 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
185 * big-endianowych odwraca kolejność bajtów w słowie.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
186 *
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
187 * \param x Liczba do zamiany
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 * \return Liczba z odpowiednią kolejnością bajtów
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 * \ingroup helper
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
192 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
193 uint32_t gg_fix32(uint32_t x)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
194 {
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
195 #ifndef GG_CONFIG_BIGENDIAN
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
196 return x;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
197 #else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
198 return (uint32_t)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
199 (((x & (uint32_t) 0x000000ffU) << 24) |
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
200 ((x & (uint32_t) 0x0000ff00U) << 8) |
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
201 ((x & (uint32_t) 0x00ff0000U) >> 8) |
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
202 ((x & (uint32_t) 0xff000000U) >> 24));
12007
bf1190509b70 [gaim-migrate @ 14300]
Bartosz Oler <bartosz@pidgin.im>
parents: 11546
diff changeset
203 #endif
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
204 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
205
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
206 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
207 * \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
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 * 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
210 * big-endianowych zamienia kolejność bajtów w słowie.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
211 *
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
212 * \param x Liczba do zamiany
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 * \return Liczba z odpowiednią kolejnością bajtów
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 * \ingroup helper
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
217 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
218 uint16_t gg_fix16(uint16_t x)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
219 {
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
220 #ifndef GG_CONFIG_BIGENDIAN
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
221 return x;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
222 #else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
223 return (uint16_t)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
224 (((x & (uint16_t) 0x00ffU) << 8) |
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
225 ((x & (uint16_t) 0xff00U) >> 8));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
226 #endif
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
227 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
228
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
229 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
230 * \internal Liczy skrót z hasła i ziarna.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
231 *
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
232 * \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
233 * \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
234 *
438f88ecc11e Update 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 * \return Wartość skrótu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
236 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
237 unsigned int gg_login_hash(const unsigned char *password, unsigned int seed)
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 x, y, z;
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 y = seed;
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 for (x = 0; *password; password++) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
244 x = (x & 0xffffff00) | *password;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
245 y ^= x;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
246 y += x;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
247 x <<= 8;
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
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
254 z = y & 0x1F;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
255 y = (y << z) | (y >> (32 - z));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
256 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
257
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
258 return y;
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
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
261 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
262 * \internal Odbiera od serwera dane binarne.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
263 *
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
264 * 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
265 * 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
266 * wywołaniami systemowymi.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
267 *
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
268 * \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
269 * \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
270 * \param length Długość bufora
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
271 *
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
272 * \return To samo co funkcja systemowa \c read
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
273 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
274 int gg_read(struct gg_session *sess, char *buf, int length)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
275 {
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
276 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
277
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
278 #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
279 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
280 for (;;) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
281 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
282
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
283 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
284 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
285 continue;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
286
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
287 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
288 errno = EAGAIN;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
289 else
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
290 errno = EINVAL;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
291
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
292 return -1;
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
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
295 return res;
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 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
298 #endif
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
299
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
300 #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
301 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
302 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
303 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
304
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
305 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
306
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
307 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
308 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
309
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
310 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
311 continue;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
312
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
313 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
314 errno = EAGAIN;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
315 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
316 errno = EINVAL;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
317
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
318 return -1;
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
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
321 return res;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
322 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
323 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
324 #endif
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
325
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
326 for (;;) {
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
327 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
328
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
329 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
330 continue;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
331
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
332 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
333 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
334 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
335
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
336 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
337 * \internal Wysyła do serwera dane binarne.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
338 *
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
339 * 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
340 * 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
341 * 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
342 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
343 * \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
344 * gg_write()).
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
345 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
346 * \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
347 * \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
348 * \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
349 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
350 * \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
351 */
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
352 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
353 {
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
354 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
355
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
356 #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
357 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
358 for (;;) {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
359 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
360
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
361 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
362 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
363 continue;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
364
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
365 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
366 errno = EAGAIN;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
367 else
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
368 errno = EINVAL;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
369
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
370 return -1;
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
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
373 return res;
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 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
376 #endif
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 #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
379 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
380 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
381 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
382
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
383 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
384
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
385 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
386 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
387
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
388 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
389 continue;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
390
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
391 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
392 errno = EAGAIN;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
393 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
394 errno = EINVAL;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
395
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
396 return -1;
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
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
399 return res;
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 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
402 #endif
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
403
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
404 for (;;) {
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
405 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
406
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
407 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
408 continue;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
409
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
410 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
411 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
412 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
413
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 * \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
418 *
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
419 * 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
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 * \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
422 * \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
423 * \param length Długość bufora
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
424 *
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
425 * \return To samo co funkcja systemowa \c write
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
426 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
427 int gg_write(struct gg_session *sess, const char *buf, int length)
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 res = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
430
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
431 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
432 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
433
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
434 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
435 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
436
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
437 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
438 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
439
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
440 written += res;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
441 res = written;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
442 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
443 } else {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
444 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
445 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
446
33286
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
447 if (res == -1 && errno == EAGAIN)
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
448 res = 0;
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
449 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
450 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
451 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
452
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
453 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
454 char *tmp;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
455
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
456 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
457 errno = ENOMEM;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
458 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
459 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
460
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
461 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
462
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
463 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
464
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
465 sess->send_left += length - res;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
466 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
467 }
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 return res;
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
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
472 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
473 * \internal Odbiera pakiet od serwera.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
474 *
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
475 * 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
476 * w zaalokowanym buforze.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
477 *
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
478 * 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
479 * 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
480 * będzie \c EAGAIN.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
481 *
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
482 * \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
483 *
438f88ecc11e Update 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 * \return Wskaźnik do zaalokowanego bufora
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
485 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
486 void *gg_recv_packet(struct gg_session *sess)
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 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
489 char *packet;
30006
3587e1e5fbe5 gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents: 29824
diff changeset
490 int ret = 0;
3587e1e5fbe5 gadu-gadu: (NULL)-like descriptions and packet size problems. Fixes #11676
Krzysztof Klinikowski <kkszysiu@gmail.com>
parents: 29824
diff changeset
491 unsigned int offset, size = 0;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
492
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
493 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
494
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
495 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
496 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
497 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
498 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
499
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
500 if (sess->recv_left < 1) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
501 if (sess->header_buf) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
502 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
503 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
504 free(sess->header_buf);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
505 sess->header_buf = NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
506 } else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
507 sess->header_done = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
508
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
509 while (sess->header_done < sizeof(h)) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
510 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
511
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
512 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
513
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
514 if (!ret) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
515 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
516 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
517 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
518 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
519
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
520 if (ret == -1) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
521 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
522 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
523
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
524 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
525 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
526 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
527 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
528
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
529 memcpy(sess->header_buf, &h, sess->header_done);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
530
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
531 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
532
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
533 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
534 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
535
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
536 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
537
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
538 return NULL;
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
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
541 sess->header_done += ret;
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
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
544 h.type = gg_fix32(h.type);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
545 h.length = gg_fix32(h.length);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
546 } else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
547 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
548
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
549 /* jakieś sensowne limity na rozmiar pakietu */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
550 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
551 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
552 errno = ERANGE;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
553 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
554 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
555
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
556 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
557 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
558 size = sess->recv_left;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
559 offset = sess->recv_done;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
560 } 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
561 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
562 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
563 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
564 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
565
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
566 memcpy(sess->recv_buf, &h, sizeof(h));
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
567
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
568 offset = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
569 size = h.length;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
570 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
571
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
572 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
573 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
574 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
575 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
576 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
577 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
578 goto fail;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
579 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
580 if (ret > -1 && ret <= size) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
581 offset += ret;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
582 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
583 } 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
584 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
585
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
586 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
587 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
588 sess->recv_left = size;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
589 sess->recv_done = offset;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
590 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
591 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
592
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
593 goto fail;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
594 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
595 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
596
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
597 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
598 sess->recv_buf = NULL;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
599 sess->recv_left = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
600
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
601 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
602 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
603
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
604 return packet;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
605
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
606 fail:
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
607 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
608 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
609 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
610
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
611 return NULL;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
612 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
613
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
614 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
615 * \internal Wysyła pakiet do serwera.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
616 *
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
617 * 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
618 * 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
619 * 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
620 *
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
621 * \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
622 * \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
623 * \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
624 * typu \c int) zakończona \c NULL
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
625 *
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
626 * \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
627 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
628 int gg_send_packet(struct gg_session *sess, int type, ...)
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 struct gg_header *h;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
631 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
632 unsigned int tmp_length;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
633 void *payload;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
634 unsigned int payload_length;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
635 va_list ap;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
636 int res;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
637
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
638 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
639
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
640 tmp_length = sizeof(struct gg_header);
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 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
643 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
644 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
645 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
646
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
647 va_start(ap, type);
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 payload = va_arg(ap, void *);
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 while (payload) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
652 char *tmp2;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
653
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
654 payload_length = va_arg(ap, unsigned int);
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 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
657 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
658 free(tmp);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
659 va_end(ap);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
660 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
661 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
662
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
663 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
664
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
665 memcpy(tmp + tmp_length, payload, payload_length);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
666 tmp_length += payload_length;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
667
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
668 payload = va_arg(ap, void *);
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
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
671 va_end(ap);
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 h = (struct gg_header*) tmp;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
674 h->type = gg_fix32(type);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
675 h->length = gg_fix32(tmp_length - sizeof(struct gg_header));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
676
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
677 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
678 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
679
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
680 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
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 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
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 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
685 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
686 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
687 }
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
688
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
689 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
690 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
691
438f88ecc11e Update 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 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
693 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
694
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
695 return 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
696 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
697
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
698 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
699 * \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
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 * 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
702 * 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
703 *
438f88ecc11e Update 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 * \note Korzystanie z tej funkcjonalności nie jest już zalecane.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
705 *
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
706 * \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
707 *
438f88ecc11e Update 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 * \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
709 */
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
710 static int gg_session_callback(struct gg_session *sess)
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 if (!sess) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
713 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
714 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
715 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
716
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
717 return ((sess->event = gg_watch_fd(sess)) != NULL) ? 0 : -1;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
718 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
719
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
720 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
721 * Łączy się z serwerem Gadu-Gadu.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
722 *
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
723 * 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
724 * 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
725 * 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
726 * informacje o zdarzeniach.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
727 *
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
728 * 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
729 * 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
730 * 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
731 * 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
732 * 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
733 * 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
734 * 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
735 * \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
736 * 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
737 * 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
738 *
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
739 * \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
740 * 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
741 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
742 * \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
743 * obsługa SSL nie jest wkompilowana.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
744 *
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
745 * \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
746 * 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
747 *
438f88ecc11e Update 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 * \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
749 * 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
750 *
438f88ecc11e Update 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 * \ingroup login
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
752 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
753 struct gg_session *gg_login(const struct gg_login_params *p)
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 *sess = NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
756 char *hostname;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
757 int port;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
758
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
759 if (!p) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
760 gg_debug(GG_DEBUG_FUNCTION, "** gg_login(%p);\n", p);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
761 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
762 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
763 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
764
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
765 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
766
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
767 if (!(sess = malloc(sizeof(struct gg_session)))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
768 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
769 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
770 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
771
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
772 memset(sess, 0, sizeof(struct gg_session));
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 if (!p->password || !p->uin) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
775 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
776 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
777 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
778 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
779
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
780 if (!(sess->password = strdup(p->password))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
781 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
782 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
783 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
784
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
785 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
786 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
787 errno = EFAULT;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
788 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
789 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
790
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
791 sess->uin = p->uin;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
792 sess->state = GG_STATE_RESOLVING;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
793 sess->check = GG_CHECK_READ;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
794 sess->timeout = GG_DEFAULT_TIMEOUT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
795 sess->async = p->async;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
796 sess->type = GG_SESSION_GG;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
797 sess->initial_status = p->status;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
798 sess->callback = gg_session_callback;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
799 sess->destroy = gg_free_session;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
800 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
801 sess->server_addr = p->server_addr;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
802 sess->external_port = p->external_port;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
803 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
804 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
805 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
806
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
807 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
808 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
809 } else {
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 = (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
811
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
812 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
813 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
814
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
815 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
816 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
817 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
818
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
819 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
820 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
821
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
822 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
823
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
824 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
825 sess->protocol_flags |= GG_ERA_OMNIX_MASK;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
826 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
827 sess->protocol_flags |= GG_HAS_AUDIO_MASK;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
828 sess->client_version = (p->client_version) ? strdup(p->client_version) : NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
829 sess->last_sysmsg = p->last_sysmsg;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
830 sess->image_size = p->image_size;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
831 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
832 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
833
438f88ecc11e Update 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 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
835 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
836 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
837 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
838 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
841 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
842
438f88ecc11e Update 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 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
844 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
845 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
846 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
847
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
848 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
849 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
850 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
851 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
852
438f88ecc11e Update 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 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
854 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
855 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
856 }
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
857
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
858 // 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
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 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
861 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
862 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
863
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
864 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
865 #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
866 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
867
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
868 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
869
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
870 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
871 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
872 goto fail;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
873 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
874
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
875 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
876
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
877 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
878 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
879 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
880 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
881 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
882 #elif defined(GG_CONFIG_HAVE_OPENSSL)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
883 char buf[1024];
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
884
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
885 OpenSSL_add_ssl_algorithms();
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 if (!RAND_status()) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
888 char rdata[1024];
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
889 struct {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
890 time_t time;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
891 void *ptr;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
892 } rstruct;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
893
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
894 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
895 rstruct.ptr = (void *) &rstruct;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
896
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
897 RAND_seed((void *) rdata, sizeof(rdata));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
898 RAND_seed((void *) &rstruct, sizeof(rstruct));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
899 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
900
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
901 sess->ssl_ctx = SSL_CTX_new(SSLv3_client_method());
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
902
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
903 if (!sess->ssl_ctx) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
904 ERR_error_string_n(ERR_get_error(), buf, sizeof(buf));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
905 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
906 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
907 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
908
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
909 SSL_CTX_set_verify(sess->ssl_ctx, SSL_VERIFY_NONE, NULL);
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 sess->ssl = SSL_new(sess->ssl_ctx);
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 if (!sess->ssl) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
914 ERR_error_string_n(ERR_get_error(), buf, sizeof(buf));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
915 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
916 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
917 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
918 #else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
919 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
920
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
921 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
922 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
923 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
924 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
925 #endif
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
926 }
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
927
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
928 if (gg_proxy_enabled) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
929 hostname = gg_proxy_host;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
930 sess->proxy_port = port = gg_proxy_port;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
931 } else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
932 hostname = GG_APPMSG_HOST;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
933 port = GG_APPMSG_PORT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
934 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
935
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
936 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
937 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
938 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
939 sess->hash_type = GG_LOGIN_HASH_SHA1;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
940
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
941 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
942 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
943
438f88ecc11e Update 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 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
945 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
946 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
947 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
948
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
949 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
950 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
951 free(addr_list);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
952 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
953 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
954
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
955 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
956
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
957 free(addr_list);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
958 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
959 } 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
960 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
961 port = sess->port;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
962 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
963
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
964 sess->hub_addr = addr.s_addr;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
965
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
966 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
967 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
968
438f88ecc11e Update 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 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
970 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
971
438f88ecc11e Update 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 /* 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
973 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
974 sess->port = GG_HTTPS_PORT;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
975
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
976 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
977 /* 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
978 * 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
979 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
980 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
981 }
438f88ecc11e Update 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 } 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
983 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
984 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
985 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
986
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
987 if (sess->server_addr)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
988 sess->state = GG_STATE_CONNECTING_GG;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
989 else
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
990 sess->state = GG_STATE_CONNECTING_HUB;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
991
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
992 while (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
993 struct gg_event *e;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
994
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
995 if (!(e = gg_watch_fd(sess))) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
996 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
997 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
998 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
999
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1000 if (e->type == GG_EVENT_CONN_FAILED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1001 errno = EACCES;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1002 gg_debug(GG_DEBUG_MISC, "// gg_login() could not login\n");
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1003 gg_event_free(e);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1004 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1005 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1006
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1007 gg_event_free(e);
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
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1010 return sess;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1011 }
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
1012
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1013 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
1014 if (sess->resolver_start(&sess->fd, &sess->resolver, hostname) == -1) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1015 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
1016 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1017 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1018 } else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1019 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
1020 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
1021 goto fail;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1022 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1023 sess->state = GG_STATE_CONNECTING_GG;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1024 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
1025 sess->soft_timeout = 1;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1026 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1027
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1028 return sess;
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 fail:
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1031 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
1032 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
1033 free(sess->initial_descr);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1034 free(sess);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1035 }
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
1036
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1037 return NULL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1038 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1039
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
1040 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1041 * 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
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 * 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
1044 * 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
1045 * 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
1046 *
438f88ecc11e Update 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 * \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
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 * \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
1050 *
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
1051 * \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
1052 */
438f88ecc11e Update 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 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
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 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
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 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
1058 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
1059 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
1060 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
1063 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
1064 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
1065 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
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
438f88ecc11e Update 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 * Kończy połączenie z serwerem.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1072 *
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
1073 * 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
1074 * \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
1075 * 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
1076 * \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
1077 *
438f88ecc11e Update 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 * \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
1079 * 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
1080 * 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
1081 * 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
1082 * 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
1083 * \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
1084 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1085 * \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
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 * \ingroup login
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1088 */
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
1089 void gg_logoff(struct gg_session *sess)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1090 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1091 if (!sess)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1092 return;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1093
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
1094 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
1095
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1096 #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
1097 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
1098 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
1099 #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
1100
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1101 #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
1102 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
1103 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
1104 #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
1105
438f88ecc11e Update 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 sess->resolver_cleanup(&sess->resolver, 1);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1107
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
1108 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
1109 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
1110 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 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
1114 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
1115 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
1116 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
1117 }
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1118 }
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1119
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
1120 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1121 * 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
1122 * 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
1123 * 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
1124 *
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1125 * \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
1126 *
438f88ecc11e Update 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 * \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
1128 */
438f88ecc11e Update 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 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
1130 {
438f88ecc11e Update 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 struct gg_dcc7 *dcc;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1132
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
1133 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
1134 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
1135
438f88ecc11e Update 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 /* XXX dopisać zwalnianie i zamykanie wszystkiego, co mogło zostać */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1137
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
1138 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
1139 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
1140 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
1141 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
1142 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
1143
33286
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1144 #ifdef GG_CONFIG_HAVE_GNUTLS
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1145 if (sess->ssl != NULL) {
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1146 gg_session_gnutls_t *tmp;
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1147
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1148 tmp = (gg_session_gnutls_t*) sess->ssl;
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1149 gnutls_deinit(tmp->session);
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1150 gnutls_certificate_free_credentials(tmp->xcred);
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1151 gnutls_global_deinit();
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1152 free(sess->ssl);
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1153 }
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1154 #endif
98d449073931 Update libgadu to 1.11.1
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33285
diff changeset
1155
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 #ifdef GG_CONFIG_HAVE_OPENSSL
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1157 if (sess->ssl)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1158 SSL_free(sess->ssl);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1159
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1160 if (sess->ssl_ctx)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1161 SSL_CTX_free(sess->ssl_ctx);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1162 #endif
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1163
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
1164 sess->resolver_cleanup(&sess->resolver, 1);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1165
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1166 if (sess->fd != -1)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1167 close(sess->fd);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1168
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1169 while (sess->images)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1170 gg_image_queue_remove(sess, sess->images, 1);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1171
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
1172 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
1173
438f88ecc11e Update 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 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
1175 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
1176
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1177 free(sess);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1178 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1179
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
1180 #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
1181
438f88ecc11e Update 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 /**
438f88ecc11e Update 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 * \internal Funkcja wysyłająca pakiet zmiany statusu użytkownika.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1184 *
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
1185 * \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
1186 * \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
1187 * \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
1188 * \param time Czas powrotu w postaci uniksowego znacznika czasu (lub 0)
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1189 *
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
1190 * \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
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 * \ingroup status
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 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
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 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
1197 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
1198 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
1199 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
1200 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
1201 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
1202 int res;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1203
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1204 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1205 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1206 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1207 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1208
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1209 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1210 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1211 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1212 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1213
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
1214 /* 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
1215
438f88ecc11e Update 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 /* 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
1217 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
1218 status |= GG_STATUS_VOICE_MASK;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1219
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1220 sess->status = status;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1221
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
1222 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
1223 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
1224 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
1225
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1226 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
1227 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
1228 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
1231 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
1232 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
1233 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
1234 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
1235 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
1236
438f88ecc11e Update 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 } 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
1238 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
1239 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
1240
438f88ecc11e Update 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 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
1242 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
1243 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
1246 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
1247
438f88ecc11e Update 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 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
1249 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
1250
438f88ecc11e Update 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 // 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
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
438f88ecc11e Update 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 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
1255 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
1256
438f88ecc11e Update 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 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
1258 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
1259
438f88ecc11e Update 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 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
1261 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
1262 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
1263 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
1264 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
1265 &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
1266 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
1267 (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
1268 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
1269 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
1270
438f88ecc11e Update 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 } 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
1272 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
1273
438f88ecc11e Update 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 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
1275 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
1276 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
1277 &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
1278 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
1279 (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
1280 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
1281 (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
1282 (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
1283 (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
1284 (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
1285 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 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
1289
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1290 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
1291 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
1292 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
1293 }
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1294
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
1295 return res;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1296 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1297
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
1298 #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
1299
438f88ecc11e Update 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 /**
438f88ecc11e Update 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 * Zmienia status użytkownika.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1302 *
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
1303 * \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
1304 * \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
1305 *
438f88ecc11e Update 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 * \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
1307 *
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
1308 * \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
1309 */
438f88ecc11e Update 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 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
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 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
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 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
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
438f88ecc11e Update 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 * Zmienia status użytkownika na status opisowy.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1319 *
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
1320 * \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
1321 * \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
1322 * \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
1323 *
438f88ecc11e Update 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 * \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
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 * \ingroup status
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1327 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1328 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
1329 {
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
1330 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
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 return gg_change_status_common(sess, status, descr, 0);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1333 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1334
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
1335 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1336 * Zmienia status użytkownika na status opisowy z podanym czasem powrotu.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1337 *
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
1338 * \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
1339 * \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
1340 * \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
1341 * \param time Czas powrotu w postaci uniksowego znacznika czasu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1342 *
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
1343 * \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
1344 *
438f88ecc11e Update 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 * \ingroup status
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1346 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1347 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
1348 {
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
1349 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
1350
438f88ecc11e Update 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 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
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
438f88ecc11e Update 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 /**
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1355 * 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
1356 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1357 * \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
1358 * \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
1359 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1360 * \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
1361 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1362 * \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
1363 * 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
1364 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1365 * \ingroup 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 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
1368 {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1369 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
1370
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1371 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
1372 errno = EFAULT;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1373 return -1;
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1374 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1375
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1376 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
1377
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1378 return 0;
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
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
1381 /**
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
1382 * 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
1383 *
438f88ecc11e Update 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 * 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
1385 * 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
1386 *
438f88ecc11e Update 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 * \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
1388 * \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
1389 * \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
1390 * \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
1391 *
438f88ecc11e Update 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 * \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
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 * \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
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 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
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 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
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 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
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
438f88ecc11e Update 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 * 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
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 * 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
1407 * 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
1408 *
438f88ecc11e Update 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 * \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
1410 * \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
1411 * \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
1412 * \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
1413 * \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
1414 * \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
1415 *
438f88ecc11e Update 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 * \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
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 * \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
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 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
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 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
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 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
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
438f88ecc11e Update 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 * 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
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 * 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
1431 * 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
1432 *
438f88ecc11e Update 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 * \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
1434 * \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
1435 * \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
1436 * \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
1437 * \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
1438 *
438f88ecc11e Update 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 * \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
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 * \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
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 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
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 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
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 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
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
438f88ecc11e Update 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 * 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
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 * 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
1454 * 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
1455 *
438f88ecc11e Update 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 * \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
1457 * \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
1458 * \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
1459 * \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
1460 * \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
1461 * \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
1462 * \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
1463 *
438f88ecc11e Update 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 * \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
1465 *
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
1466 * \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
1467 */
438f88ecc11e Update 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 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
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 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
1471 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
1472 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
1473 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
1474 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
1475 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
1476 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
1477 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
1478 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
1479
438f88ecc11e Update 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 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
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 if (!sess) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1483 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1484 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1485 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1486
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1487 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1488 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1489 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1490 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1491
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
1492 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
1493 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
1494 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
1495 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
1498 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
1499 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
1500
438f88ecc11e Update 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 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
1502 } 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
1503 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
1504 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
1505 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
1506 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
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
438f88ecc11e Update 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 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
1512 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
1513 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
1514 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
1515 sess->seq += (rand() % 0x300) + 0x300;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1516
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
1517 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
1518 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
1519 } 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
1520 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
1521
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
1522 // 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
1523 // 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
1524 // 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
1525
438f88ecc11e Update 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 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
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 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
1529 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
1530
438f88ecc11e Update 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 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
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 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
1534 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
1535 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
1536 }
438f88ecc11e Update 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
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1538 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
1539
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1540 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
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 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
1543 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
1544 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
1545 }
438f88ecc11e Update 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
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
1547 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
1548
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
1549 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
1550 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
1551 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
1552 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
1553 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
1556 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
1557 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
1558
438f88ecc11e Update 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 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
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 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
1562 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
1563 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
1564 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
1567 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
1568 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
1569 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
1570 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
1571 }
438f88ecc11e Update 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 }
438f88ecc11e Update 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 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
1575 s.recipient = gg_fix32(recipients[i]);
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1576
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
1577 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
1578 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
1579 } 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
1580 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
1581
438f88ecc11e Update 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 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
1583 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
1584 }
438f88ecc11e Update 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 }
438f88ecc11e Update 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 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
1588 } 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
1589 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
1590 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
1591
438f88ecc11e Update 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 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
1593 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
1594 } 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
1595 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
1596
438f88ecc11e Update 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 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
1598 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
1599 }
438f88ecc11e Update 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 }
438f88ecc11e Update 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 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
1603 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
1604 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
1605
438f88ecc11e Update 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 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
1607 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
1608
438f88ecc11e Update 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(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
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 return seq_no;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1612 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1613
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
1614 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1615 * 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
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 * 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
1618 * 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
1619 * który można zignorować albo wykorzystać do potwierdzenia.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1620 *
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
1621 * \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
1622 * \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
1623 * \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
1624 * \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
1625 * \param message_len Długość wiadomości
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1626 *
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
1627 * \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
1628 *
438f88ecc11e Update 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 * \ingroup messages
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1630 */
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
1631 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
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 struct gg_send_msg s;
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 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
1636
438f88ecc11e Update 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 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
1638 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
1639 return -1;
11546
acb5676e57bb [gaim-migrate @ 13801]
Daniel Atallah <datallah@pidgin.im>
parents: 11360
diff changeset
1640 }
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
1641
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1642 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
1643 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
1644 return -1;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1645 }
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
1646
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1647 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
1648 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
1649 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
1650
438f88ecc11e Update 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 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
1652 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1653
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
1654 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1655 * Wysyła żądanie obrazka o podanych parametrach.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1656 *
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
1657 * 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
1658 * 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
1659 * 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
1660 * Wynik zostanie przekazany zdarzeniem \c GG_EVENT_IMAGE_REPLY.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1661 *
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
1662 * \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
1663 * \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
1664 * \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
1665 * \param crc32 Suma kontrola obrazka
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1666 *
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
1667 * \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
1668 *
438f88ecc11e Update 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 * \ingroup messages
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1670 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1671 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
1672 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1673 struct gg_send_msg s;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1674 struct gg_msg_image_request r;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1675 char dummy = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1676 int res;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1677
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
1678 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
1679
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1680 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1681 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1682 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1683 }
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
1684
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1685 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1686 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1687 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1688 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1689
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1690 if (size < 0) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1691 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1692 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1693 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1694
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1695 s.recipient = gg_fix32(recipient);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1696 s.seq = gg_fix32(0);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1697 s.msgclass = gg_fix32(GG_CLASS_MSG);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1698
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1699 r.flag = 0x04;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1700 r.size = gg_fix32(size);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1701 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
1702
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1703 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
1704
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1705 if (!res) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1706 struct gg_image_queue *q = malloc(sizeof(*q));
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1707 char *buf;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1708
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1709 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
1710 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
1711 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1712 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1713
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1714 buf = malloc(size);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1715 if (size && !buf)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1716 {
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
1717 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
1718 free(q);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1719 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1720 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1721
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1722 memset(q, 0, sizeof(*q));
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 q->sender = recipient;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1725 q->size = size;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1726 q->crc32 = crc32;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1727 q->image = buf;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1728
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1729 if (!sess->images)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1730 sess->images = q;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1731 else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1732 struct gg_image_queue *qq;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1733
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1734 for (qq = sess->images; qq->next; qq = qq->next)
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
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1737 qq->next = q;
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 }
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 return res;
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
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
1744 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1745 * Wysyła żądany obrazek.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1746 *
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
1747 * \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
1748 * \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
1749 * \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
1750 * \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
1751 * \param size Rozmiar obrazka
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1752 *
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
1753 * \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
1754 *
438f88ecc11e Update 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 * \ingroup messages
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1756 */
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
1757 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
1758 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1759 struct gg_msg_image_reply *r;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1760 struct gg_send_msg s;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1761 const char *tmp;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1762 char buf[1910];
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1763 int res = -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1764
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
1765 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
1766
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1767 if (!sess || !filename || !image) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1768 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1769 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1770 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1771
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1772 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1773 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1774 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1775 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1776
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1777 if (size < 0) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1778 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1779 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1780 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1781
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
1782 /* wytnij ścieżki, zostaw tylko nazwę pliku */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1783 while ((tmp = strrchr(filename, '/')) || (tmp = strrchr(filename, '\\')))
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1784 filename = tmp + 1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1785
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1786 if (strlen(filename) < 1 || strlen(filename) > 1024) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1787 errno = EINVAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1788 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1789 }
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
1790
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1791 s.recipient = gg_fix32(recipient);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1792 s.seq = gg_fix32(0);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1793 s.msgclass = gg_fix32(GG_CLASS_MSG);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1794
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1795 buf[0] = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1796 r = (void*) &buf[1];
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1797
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1798 r->flag = 0x05;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1799 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
1800 r->crc32 = gg_fix32(gg_crc32(0, (unsigned char*) image, size));
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1801
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1802 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
1803 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
1804
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1805 /* \0 + struct gg_msg_image_reply */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1806 buflen = sizeof(struct gg_msg_image_reply) + 1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1807
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
1808 /* w pierwszym kawałku jest nazwa pliku */
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1809 if (r->flag == 0x05) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1810 strcpy(buf + buflen, filename);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1811 buflen += strlen(filename) + 1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1812 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1813
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
1814 chunklen = (size >= sizeof(buf) - buflen) ? (sizeof(buf) - buflen) : size;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1815
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1816 memcpy(buf + buflen, image, chunklen);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1817 size -= chunklen;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1818 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
1819
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1820 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
1821
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1822 if (res == -1)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1823 break;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1824
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1825 r->flag = 0x06;
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
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1828 return res;
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
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
1831 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1832 * Wysyła do serwera listę kontaktów.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1833 *
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
1834 * 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
1835 * 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
1836 * 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
1837 * 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
1838 *
438f88ecc11e Update 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 * 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
1840 * jest pusta.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1841 *
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
1842 * \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
1843 * \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
1844 * \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
1845 * \param count Liczba kontaktów
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1846 *
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
1847 * \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
1848 *
438f88ecc11e Update 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 * \ingroup contacts
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1850 */
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
1851 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
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 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
1854 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
1855 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
1856 int i, res = 0;
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1857
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
1858 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
1859
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1860 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1861 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1862 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1863 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1864
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1865 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1866 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1867 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1868 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1869
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1870 if (!userlist || !count)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1871 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
1872
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1873 while (count > 0) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1874 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
1875
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1876 if (count > 400) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1877 part_count = 400;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1878 packet_type = GG_NOTIFY_FIRST;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1879 } else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1880 part_count = count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1881 packet_type = GG_NOTIFY_LAST;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1882 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1883
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1884 if (!(n = (struct gg_notify*) malloc(sizeof(*n) * part_count)))
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1885 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
1886
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1887 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
1888 n[i].uin = gg_fix32(*u);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1889 n[i].dunno1 = *t;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1890 }
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
1891
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1892 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
1893 free(n);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1894 res = -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1895 break;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1896 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1897
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1898 count -= part_count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1899 userlist += part_count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1900 types += part_count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1901
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1902 free(n);
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
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1905 return res;
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
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
1908 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1909 * Wysyła do serwera listę kontaktów.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1910 *
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
1911 * 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
1912 * są rodzaju \c GG_USER_NORMAL.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1913 *
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
1914 * \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
1915 * \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
1916 * \param count Liczba kontaktów
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1917 *
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
1918 * \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
1919 *
438f88ecc11e Update 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 * \ingroup contacts
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1921 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1922 int gg_notify(struct gg_session *sess, uin_t *userlist, int count)
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 struct gg_notify *n;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1925 uin_t *u;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1926 int i, res = 0;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1927
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
1928 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
1929
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1930 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1931 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1932 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1933 }
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
1934
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1935 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1936 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1937 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1938 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1939
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1940 if (!userlist || !count)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1941 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
1942
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1943 while (count > 0) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1944 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
1945
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1946 if (count > 400) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1947 part_count = 400;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1948 packet_type = GG_NOTIFY_FIRST;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1949 } else {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1950 part_count = count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1951 packet_type = GG_NOTIFY_LAST;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1952 }
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
1953
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1954 if (!(n = (struct gg_notify*) malloc(sizeof(*n) * part_count)))
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1955 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
1956
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1957 for (u = userlist, i = 0; i < part_count; u++, i++) {
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1958 n[i].uin = gg_fix32(*u);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1959 n[i].dunno1 = GG_USER_NORMAL;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1960 }
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
1961
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1962 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
1963 res = -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1964 free(n);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1965 break;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1966 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1967
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1968 free(n);
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 userlist += part_count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1971 count -= part_count;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1972 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1973
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1974 return res;
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
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
1977 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
1978 * Dodaje kontakt.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1979 *
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
1980 * 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
1981 * 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
1982 * poprzedni rodzaj, ponieważ serwer operuje na maskach bitowych.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1983 *
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
1984 * \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
1985 * \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
1986 * \param type Rodzaj kontaktu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1987 *
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
1988 * \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
1989 *
438f88ecc11e Update 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 * \ingroup contacts
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1991 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1992 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
1993 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1994 struct gg_add_remove a;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1995
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
1996 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
1997
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1998 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
1999 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2000 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2001 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2002
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2003 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2004 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2005 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2006 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2007
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2008 a.uin = gg_fix32(uin);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2009 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
2010
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2011 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
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
438f88ecc11e Update 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 * 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
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 * 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
2018 * 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
2019 *
438f88ecc11e Update 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 * \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
2021 * \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
2022 *
438f88ecc11e Update 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 * \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
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 * \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
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 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
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 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
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
438f88ecc11e Update 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 * 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
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 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
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 * \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
2038 * \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
2039 * \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
2040 *
438f88ecc11e Update 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 * \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
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 * \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
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 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
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 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
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 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
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 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
2052 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
2053 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
2054 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
2057 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
2058 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
2059 }
438f88ecc11e Update 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
438f88ecc11e Update 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 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
2062 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
2063
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2064 return gg_send_packet(sess, GG_REMOVE_NOTIFY, &a, sizeof(a), NULL);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2065 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2066
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
2067 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2068 * Usuwa kontakt.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2069 *
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
2070 * 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
2071 * kontaktów to \c GG_USER_NORMAL.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2072 *
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
2073 * \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
2074 * \param uin Numer kontaktu
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2075 *
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
2076 * \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
2077 *
438f88ecc11e Update 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 * \ingroup contacts
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2079 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2080 int gg_remove_notify(struct gg_session *sess, uin_t uin)
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 return gg_remove_notify_ex(sess, uin, GG_USER_NORMAL);
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
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
2085 /**
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2086 * Wysyła do serwera zapytanie dotyczące listy kontaktów.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2087 *
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
2088 * 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
2089 * 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
2090 * 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
2091 * 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
2092 * 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
2093 * formacie co oryginalny klient Gadu-Gadu.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2094 *
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
2095 * 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
2096 * z protokołu -- wysyła i odbiera kompletną listę.
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2097 *
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
2098 * \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
2099 * \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
2100 * \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
2101 *
438f88ecc11e Update 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 * \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
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 * \ingroup importexport
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2105 */
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2106 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
2107 {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2108 int len;
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 if (!sess) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2111 errno = EFAULT;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2112 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2113 }
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
2114
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2115 if (sess->state != GG_STATE_CONNECTED) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2116 errno = ENOTCONN;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2117 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2118 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2119
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2120 if (!request) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2121 sess->userlist_blocks = 1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2122 return gg_send_packet(sess, GG_USERLIST_REQUEST, &type, sizeof(type), NULL);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2123 }
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
2124
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2125 len = strlen(request);
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2126
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2127 sess->userlist_blocks = 0;
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 while (len > 2047) {
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2130 sess->userlist_blocks++;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2131
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2132 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
2133 return -1;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2134
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2135 if (type == GG_USERLIST_PUT)
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2136 type = GG_USERLIST_PUT_MORE;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2137
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2138 request += 2047;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2139 len -= 2047;
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2140 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2141
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2142 sess->userlist_blocks++;
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 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
2145 }
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2146
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2147 /**
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2148 * 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
2149 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2150 * 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
2151 * 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
2152 * 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
2153 * 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
2154 * 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
2155 * 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
2156 * 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
2157 * 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
2158 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2159 * 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
2160 * 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
2161 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2162 * \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
2163 * \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
2164 * \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
2165 * \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
2166 * \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
2167 *
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2168 * \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
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 * \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
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 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
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 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
2175 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
2176 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
2177 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
2178
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2179 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
2180 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
2181 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
2182 }
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2183
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2184 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
2185 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
2186 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
2187 }
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2188
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2189 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
2190 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
2191 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
2192 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
2193
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2194 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
2195 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
2196
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2197 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
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 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
2200 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
2201 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
2202 }
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2203
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2204 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
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 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
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 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
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
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2211 /**
31609
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2212 * 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
2213 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2214 * \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
2215 * \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
2216 * \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
2217 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2218 * \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
2219 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2220 * \ingroup messages
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 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
2223 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
2224 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
2225
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2226 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
2227 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
2228 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
2229
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2230 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
2231 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2232
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 * 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
2235 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2236 * \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
2237 * \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
2238 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2239 * \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
2240 *
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2241 * \ingroup login
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 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
2244 {
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2245 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
2246
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2247 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
2248
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2249 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
2250 }
d67fbc90b28a matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 31294
diff changeset
2251
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
2252 /* @} */
438f88ecc11e Update our internal libgadu to 1.9.0-rc2. This does not yet build on Windows.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29106
diff changeset
2253
31826
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2254 /**
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2255 * 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
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 * \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
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 * \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
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 * \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
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 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
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 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
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 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
2268 #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
2269 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
2270 #else
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 0;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2272 #endif
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2273
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2274 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
2275 #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
2276 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
2277 #else
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 0;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2279 #endif
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2280
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2281 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
2282 #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
2283 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
2284 #else
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 0;
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2286 #endif
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2287
0f6ab56fbf9d Update libgadu to 0.11.0 plus local changes; thanks to Tomasz Wasilczyk.
Ethan Blanton <elb@pidgin.im>
parents: 31609
diff changeset
2288 /* 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
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 }
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 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
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
11360
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2295 /*
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2296 * Local variables:
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2297 * c-indentation-style: k&r
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2298 * c-basic-offset: 8
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2299 * indent-tabs-mode: notnil
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2300 * End:
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2301 *
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2302 * vim: shiftwidth=8:
b77fd5a8959a [gaim-migrate @ 13582]
Bartosz Oler <bartosz@pidgin.im>
parents:
diff changeset
2303 */

mercurial