GApplication: allow handles_commandline and service
[platform/upstream/glib.git] / gio / gtlsconnection.h
1 /* GIO - GLib Input, Output and Streaming Library
2  *
3  * Copyright (C) 2010 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __G_TLS_CONNECTION_H__
22 #define __G_TLS_CONNECTION_H__
23
24 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25 #error "Only <gio/gio.h> can be included directly."
26 #endif
27
28 #include <gio/giostream.h>
29
30 G_BEGIN_DECLS
31
32 #define G_TYPE_TLS_CONNECTION            (g_tls_connection_get_type ())
33 #define G_TLS_CONNECTION(inst)           (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TLS_CONNECTION, GTlsConnection))
34 #define G_TLS_CONNECTION_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
35 #define G_IS_TLS_CONNECTION(inst)        (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TLS_CONNECTION))
36 #define G_IS_TLS_CONNECTION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TLS_CONNECTION))
37 #define G_TLS_CONNECTION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_TLS_CONNECTION, GTlsConnectionClass))
38
39 typedef struct _GTlsConnectionClass   GTlsConnectionClass;
40 typedef struct _GTlsConnectionPrivate GTlsConnectionPrivate;
41
42 struct _GTlsConnection {
43   GIOStream parent_instance;
44
45   GTlsConnectionPrivate *priv;
46 };
47
48 struct _GTlsConnectionClass
49 {
50   GIOStreamClass parent_class;
51
52   /* signals */
53   gboolean          ( *accept_certificate) (GTlsConnection       *connection,
54                                             GTlsCertificate      *peer_cert,
55                                             GTlsCertificateFlags  errors);
56
57   /* methods */
58   gboolean ( *handshake )        (GTlsConnection       *conn,
59                                   GCancellable         *cancellable,
60                                   GError              **error);
61
62   void     ( *handshake_async )  (GTlsConnection       *conn,
63                                   int                   io_priority,
64                                   GCancellable         *cancellable,
65                                   GAsyncReadyCallback   callback,
66                                   gpointer              user_data);
67   gboolean ( *handshake_finish ) (GTlsConnection       *conn,
68                                   GAsyncResult         *result,
69                                   GError              **error);
70
71   /*< private >*/
72   /* Padding for future expansion */
73   gpointer padding[8];
74 };
75
76 GLIB_AVAILABLE_IN_ALL
77 GType                 g_tls_connection_get_type                    (void) G_GNUC_CONST;
78
79 GLIB_DEPRECATED
80 void                  g_tls_connection_set_use_system_certdb       (GTlsConnection       *conn,
81                                                                     gboolean              use_system_certdb);
82 GLIB_DEPRECATED
83 gboolean              g_tls_connection_get_use_system_certdb       (GTlsConnection       *conn);
84
85 GLIB_AVAILABLE_IN_ALL
86 void                  g_tls_connection_set_database                (GTlsConnection       *conn,
87                                                                     GTlsDatabase         *database);
88 GLIB_AVAILABLE_IN_ALL
89 GTlsDatabase *        g_tls_connection_get_database                (GTlsConnection       *conn);
90
91 GLIB_AVAILABLE_IN_ALL
92 void                  g_tls_connection_set_certificate             (GTlsConnection       *conn,
93                                                                     GTlsCertificate      *certificate);
94 GLIB_AVAILABLE_IN_ALL
95 GTlsCertificate      *g_tls_connection_get_certificate             (GTlsConnection       *conn);
96
97 GLIB_AVAILABLE_IN_ALL
98 void                  g_tls_connection_set_interaction             (GTlsConnection       *conn,
99                                                                     GTlsInteraction      *interaction);
100 GLIB_AVAILABLE_IN_ALL
101 GTlsInteraction *     g_tls_connection_get_interaction             (GTlsConnection       *conn);
102
103 GLIB_AVAILABLE_IN_ALL
104 GTlsCertificate      *g_tls_connection_get_peer_certificate        (GTlsConnection       *conn);
105 GLIB_AVAILABLE_IN_ALL
106 GTlsCertificateFlags  g_tls_connection_get_peer_certificate_errors (GTlsConnection       *conn);
107
108 GLIB_AVAILABLE_IN_ALL
109 void                  g_tls_connection_set_require_close_notify    (GTlsConnection       *conn,
110                                                                     gboolean              require_close_notify);
111 GLIB_AVAILABLE_IN_ALL
112 gboolean              g_tls_connection_get_require_close_notify    (GTlsConnection       *conn);
113
114 GLIB_AVAILABLE_IN_ALL
115 void                  g_tls_connection_set_rehandshake_mode        (GTlsConnection       *conn,
116                                                                     GTlsRehandshakeMode   mode);
117 GLIB_AVAILABLE_IN_ALL
118 GTlsRehandshakeMode   g_tls_connection_get_rehandshake_mode        (GTlsConnection       *conn);
119
120 GLIB_AVAILABLE_IN_ALL
121 gboolean              g_tls_connection_handshake                   (GTlsConnection       *conn,
122                                                                     GCancellable         *cancellable,
123                                                                     GError              **error);
124
125 GLIB_AVAILABLE_IN_ALL
126 void                  g_tls_connection_handshake_async             (GTlsConnection       *conn,
127                                                                     int                   io_priority,
128                                                                     GCancellable         *cancellable,
129                                                                     GAsyncReadyCallback   callback,
130                                                                     gpointer              user_data);
131 GLIB_AVAILABLE_IN_ALL
132 gboolean              g_tls_connection_handshake_finish            (GTlsConnection       *conn,
133                                                                     GAsyncResult         *result,
134                                                                     GError              **error);
135
136 /**
137  * G_TLS_ERROR:
138  *
139  * Error domain for TLS. Errors in this domain will be from the
140  * #GTlsError enumeration. See #GError for more information on error
141  * domains.
142  */
143 #define G_TLS_ERROR (g_tls_error_quark ())
144 GLIB_AVAILABLE_IN_ALL
145 GQuark g_tls_error_quark (void);
146
147
148 /*< protected >*/
149 GLIB_AVAILABLE_IN_ALL
150 gboolean              g_tls_connection_emit_accept_certificate     (GTlsConnection       *conn,
151                                                                     GTlsCertificate      *peer_cert,
152                                                                     GTlsCertificateFlags  errors);
153
154 G_END_DECLS
155
156 #endif /* __G_TLS_CONNECTION_H__ */