annotate libpurple/protocols/gg/lib/session.h @ 32789:8331b45b6200

disapproval of revision '183ac4d83596ebf70192f4694b131e45a7a5a4c5'
author Ethan Blanton <elb@pidgin.im>
date Sat, 05 May 2012 17:11:58 +0000
parents 93b08d43f684
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31410
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1 /*
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2 * (C) Copyright 2008-2010 Wojtek Kaniewski <wojtekka@irc.pl>
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3 *
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5 * it under the terms of the GNU Lesser General Public License Version
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
6 * 2.1 as published by the Free Software Foundation.
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
7 *
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
11 * GNU Lesser General Public License for more details.
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
12 *
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
13 * You should have received a copy of the GNU Lesser General Public
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
14 * License along with this program; if not, write to the Free Software
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
16 * USA.
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
17 */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
18
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
19 #ifndef LIBGADU_SESSION_H
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
20 #define LIBGADU_SESSION_H
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
21
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
22 #ifdef GG_CONFIG_HAVE_GNUTLS
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
23 # include <gnutls/gnutls.h>
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
24 #endif
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
25
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
26 #define GG_SESSION_CHECK(gs, result) \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
27 do { \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
28 if ((gs) == NULL) { \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
29 errno = EINVAL; \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
30 return (result); \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
31 } \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
32 } while (0)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
33
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
34 #define GG_SESSION_CHECK_CONNECTED(gs, result) \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
35 do { \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
36 GG_SESSION_CHECK(gs, result); \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
37 \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
38 if (!GG_SESSION_IS_CONNECTED(gs)) { \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
39 errno = ENOTCONN; \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
40 return (result); \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
41 } \
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
42 } while (0)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
43
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
44 #define GG_SESSION_IS_PROTOCOL_7_7(gs) ((gs)->protocol_version >= 0x2a)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
45 #define GG_SESSION_IS_PROTOCOL_8_0(gs) ((gs)->protocol_version >= 0x2d)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
46
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
47 #define GG_SESSION_IS_IDLE(gs) ((gs)->state == GG_STATE_IDLE)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
48 #define GG_SESSION_IS_CONNECTING(gs) ((gs)->state != GG_STATE_IDLE && (gs)->state != GG_STATE_CONNECTED)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
49 #define GG_SESSION_IS_CONNECTED(gs) ((gs)->state == GG_STATE_CONNECTED)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
50
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
51 #ifdef GG_CONFIG_HAVE_GNUTLS
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
52
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
53 typedef struct {
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
54 gnutls_session_t session;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
55 gnutls_certificate_credentials_t xcred;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
56 } gg_session_gnutls_t;
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
57
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
58 #define GG_SESSION_GNUTLS(gs) ((gg_session_gnutls_t*) (gs)->ssl)->session
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
59
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
60 #endif /* GG_CONFIG_HAVE_GNUTLS */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
61
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
62 #ifdef GG_CONFIG_HAVE_OPENSSL
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
63
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
64 #define GG_SESSION_OPENSSL(gs) ((SSL*) (gs)->ssl)
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
65
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
66 #endif /* GG_CONFIG_HAVE_OPENSSL */
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
67
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
68 int gg_session_handle_packet(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge);
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
69
93b08d43f684 matekm and kkszysiu collaborated on this patch to update our internal libgadu
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
70 #endif /* LIBGADU_SESSION_H */