gnutls: rearrange some code to avoid a warning
[platform/upstream/glib-networking.git] / tls / gnutls / gtlsconnection-gnutls.h
1 /* GIO - GLib Connection, Output and Gnutlsing Library
2  *
3  * Copyright © 2009 Red Hat, Inc.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published
7  * by the Free Software Foundation; either version 2 of the licence or (at
8  * your option) any later version.
9  *
10  * See the included COPYING file for more information.
11  */
12
13 #ifndef __G_TLS_CONNECTION_GNUTLS_H__
14 #define __G_TLS_CONNECTION_GNUTLS_H__
15
16 #include <gio/gio.h>
17 #include <gnutls/gnutls.h>
18
19 G_BEGIN_DECLS
20
21 #define G_TYPE_TLS_CONNECTION_GNUTLS            (g_tls_connection_gnutls_get_type ())
22 #define G_TLS_CONNECTION_GNUTLS(inst)           (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CONNECTION_GNUTLS, GTlsConnectionGnutls))
23 #define G_TLS_CONNECTION_GNUTLS_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_CONNECTION_GNUTLS, GTlsConnectionGnutlsClass))
24 #define G_IS_TLS_CONNECTION_GNUTLS(inst)        (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CONNECTION_GNUTLS))
25 #define G_IS_TLS_CONNECTION_GNUTLS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_CONNECTION_GNUTLS))
26 #define G_TLS_CONNECTION_GNUTLS_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_CONNECTION_GNUTLS, GTlsConnectionGnutlsClass))
27
28 typedef struct _GTlsConnectionGnutlsPrivate                   GTlsConnectionGnutlsPrivate;
29 typedef struct _GTlsConnectionGnutlsClass                     GTlsConnectionGnutlsClass;
30 typedef struct _GTlsConnectionGnutls                          GTlsConnectionGnutls;
31
32 struct _GTlsConnectionGnutlsClass
33 {
34   GTlsConnectionClass parent_class;
35
36   void     (*begin_handshake)  (GTlsConnectionGnutls  *gnutls);
37   gboolean (*verify_peer)      (GTlsConnectionGnutls  *gnutls,
38                                 GTlsCertificate       *peer_certificate,
39                                 GTlsCertificateFlags  *errors);
40   void     (*finish_handshake) (GTlsConnectionGnutls  *gnutls,
41                                 GError               **inout_error);
42 };
43
44 struct _GTlsConnectionGnutls
45 {
46   GTlsConnection parent_instance;
47   GTlsConnectionGnutlsPrivate *priv;
48 };
49
50 GType g_tls_connection_gnutls_get_type (void) G_GNUC_CONST;
51
52 gnutls_certificate_credentials g_tls_connection_gnutls_get_credentials (GTlsConnectionGnutls *connection);
53 gnutls_session                 g_tls_connection_gnutls_get_session     (GTlsConnectionGnutls *connection);
54 void                           g_tls_connection_gnutls_get_certificate (GTlsConnectionGnutls *gnutls,
55                                                                          gnutls_retr_st       *st);
56
57 gssize   g_tls_connection_gnutls_read          (GTlsConnectionGnutls  *gnutls,
58                                                 void                  *buffer,
59                                                 gsize                  size,
60                                                 gboolean               blocking,
61                                                 GCancellable          *cancellable,
62                                                 GError               **error);
63 gssize   g_tls_connection_gnutls_write         (GTlsConnectionGnutls  *gnutls,
64                                                 const void            *buffer,
65                                                 gsize                  size,
66                                                 gboolean               blocking,
67                                                 GCancellable          *cancellable,
68                                                 GError               **error);
69
70 gboolean g_tls_connection_gnutls_check         (GTlsConnectionGnutls  *gnutls,
71                                                 GIOCondition           condition);
72 GSource *g_tls_connection_gnutls_create_source (GTlsConnectionGnutls  *gnutls,
73                                                 GIOCondition           condition,
74                                                 GCancellable          *cancellable);
75
76 G_END_DECLS
77
78 #endif /* __G_TLS_CONNECTION_GNUTLS_H___ */