source: appstream-generator/build/girepo/gio/TlsInteraction.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 14.3 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.TlsInteraction;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.AsyncResultIF;
26private import gio.Cancellable;
27private import gio.TlsConnection;
28private import gio.TlsPassword;
29private import glib.ErrorG;
30private import glib.GException;
31private import gobject.ObjectG;
32
33
34/**
35 * #GTlsInteraction provides a mechanism for the TLS connection and database
36 * code to interact with the user. It can be used to ask the user for passwords.
37 *
38 * To use a #GTlsInteraction with a TLS connection use
39 * g_tls_connection_set_interaction().
40 *
41 * Callers should instantiate a derived class that implements the various
42 * interaction methods to show the required dialogs.
43 *
44 * Callers should use the 'invoke' functions like
45 * g_tls_interaction_invoke_ask_password() to run interaction methods. These
46 * functions make sure that the interaction is invoked in the main loop
47 * and not in the current thread, if the current thread is not running the
48 * main loop.
49 *
50 * Derived classes can choose to implement whichever interactions methods they'd
51 * like to support by overriding those virtual methods in their class
52 * initialization function. Any interactions not implemented will return
53 * %G_TLS_INTERACTION_UNHANDLED. If a derived class implements an async method,
54 * it must also implement the corresponding finish method.
55 *
56 * Since: 2.30
57 */
58public class TlsInteraction : ObjectG
59{
60        /** the main Gtk struct */
61        protected GTlsInteraction* gTlsInteraction;
62
63        /** Get the main Gtk struct */
64        public GTlsInteraction* getTlsInteractionStruct()
65        {
66                return gTlsInteraction;
67        }
68
69        /** the main Gtk struct as a void* */
70        protected override void* getStruct()
71        {
72                return cast(void*)gTlsInteraction;
73        }
74
75        protected override void setStruct(GObject* obj)
76        {
77                gTlsInteraction = cast(GTlsInteraction*)obj;
78                super.setStruct(obj);
79        }
80
81        /**
82         * Sets our main struct and passes it to the parent class.
83         */
84        public this (GTlsInteraction* gTlsInteraction, bool ownedRef = false)
85        {
86                this.gTlsInteraction = gTlsInteraction;
87                super(cast(GObject*)gTlsInteraction, ownedRef);
88        }
89
90
91        /** */
92        public static GType getType()
93        {
94                return g_tls_interaction_get_type();
95        }
96
97        /**
98         * Run synchronous interaction to ask the user for a password. In general,
99         * g_tls_interaction_invoke_ask_password() should be used instead of this
100         * function.
101         *
102         * Derived subclasses usually implement a password prompt, although they may
103         * also choose to provide a password from elsewhere. The @password value will
104         * be filled in and then @callback will be called. Alternatively the user may
105         * abort this password request, which will usually abort the TLS connection.
106         *
107         * If the interaction is cancelled by the cancellation object, or by the
108         * user then %G_TLS_INTERACTION_FAILED will be returned with an error that
109         * contains a %G_IO_ERROR_CANCELLED error code. Certain implementations may
110         * not support immediate cancellation.
111         *
112         * Params:
113         *     password = a #GTlsPassword object
114         *     cancellable = an optional #GCancellable cancellation object
115         *
116         * Returns: The status of the ask password interaction.
117         *
118         * Since: 2.30
119         *
120         * Throws: GException on failure.
121         */
122        public GTlsInteractionResult askPassword(TlsPassword password, Cancellable cancellable)
123        {
124                GError* err = null;
125               
126                auto p = g_tls_interaction_ask_password(gTlsInteraction, (password is null) ? null : password.getTlsPasswordStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
127               
128                if (err !is null)
129                {
130                        throw new GException( new ErrorG(err) );
131                }
132               
133                return p;
134        }
135
136        /**
137         * Run asynchronous interaction to ask the user for a password. In general,
138         * g_tls_interaction_invoke_ask_password() should be used instead of this
139         * function.
140         *
141         * Derived subclasses usually implement a password prompt, although they may
142         * also choose to provide a password from elsewhere. The @password value will
143         * be filled in and then @callback will be called. Alternatively the user may
144         * abort this password request, which will usually abort the TLS connection.
145         *
146         * If the interaction is cancelled by the cancellation object, or by the
147         * user then %G_TLS_INTERACTION_FAILED will be returned with an error that
148         * contains a %G_IO_ERROR_CANCELLED error code. Certain implementations may
149         * not support immediate cancellation.
150         *
151         * Certain implementations may not support immediate cancellation.
152         *
153         * Params:
154         *     password = a #GTlsPassword object
155         *     cancellable = an optional #GCancellable cancellation object
156         *     callback = will be called when the interaction completes
157         *     userData = data to pass to the @callback
158         *
159         * Since: 2.30
160         */
161        public void askPasswordAsync(TlsPassword password, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
162        {
163                g_tls_interaction_ask_password_async(gTlsInteraction, (password is null) ? null : password.getTlsPasswordStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
164        }
165
166        /**
167         * Complete an ask password user interaction request. This should be once
168         * the g_tls_interaction_ask_password_async() completion callback is called.
169         *
170         * If %G_TLS_INTERACTION_HANDLED is returned, then the #GTlsPassword passed
171         * to g_tls_interaction_ask_password() will have its password filled in.
172         *
173         * If the interaction is cancelled by the cancellation object, or by the
174         * user then %G_TLS_INTERACTION_FAILED will be returned with an error that
175         * contains a %G_IO_ERROR_CANCELLED error code.
176         *
177         * Params:
178         *     result = the result passed to the callback
179         *
180         * Returns: The status of the ask password interaction.
181         *
182         * Since: 2.30
183         *
184         * Throws: GException on failure.
185         */
186        public GTlsInteractionResult askPasswordFinish(AsyncResultIF result)
187        {
188                GError* err = null;
189               
190                auto p = g_tls_interaction_ask_password_finish(gTlsInteraction, (result is null) ? null : result.getAsyncResultStruct(), &err);
191               
192                if (err !is null)
193                {
194                        throw new GException( new ErrorG(err) );
195                }
196               
197                return p;
198        }
199
200        /**
201         * Invoke the interaction to ask the user for a password. It invokes this
202         * interaction in the main loop, specifically the #GMainContext returned by
203         * g_main_context_get_thread_default() when the interaction is created. This
204         * is called by called by #GTlsConnection or #GTlsDatabase to ask the user
205         * for a password.
206         *
207         * Derived subclasses usually implement a password prompt, although they may
208         * also choose to provide a password from elsewhere. The @password value will
209         * be filled in and then @callback will be called. Alternatively the user may
210         * abort this password request, which will usually abort the TLS connection.
211         *
212         * The implementation can either be a synchronous (eg: modal dialog) or an
213         * asynchronous one (eg: modeless dialog). This function will take care of
214         * calling which ever one correctly.
215         *
216         * If the interaction is cancelled by the cancellation object, or by the
217         * user then %G_TLS_INTERACTION_FAILED will be returned with an error that
218         * contains a %G_IO_ERROR_CANCELLED error code. Certain implementations may
219         * not support immediate cancellation.
220         *
221         * Params:
222         *     password = a #GTlsPassword object
223         *     cancellable = an optional #GCancellable cancellation object
224         *
225         * Returns: The status of the ask password interaction.
226         *
227         * Since: 2.30
228         *
229         * Throws: GException on failure.
230         */
231        public GTlsInteractionResult invokeAskPassword(TlsPassword password, Cancellable cancellable)
232        {
233                GError* err = null;
234               
235                auto p = g_tls_interaction_invoke_ask_password(gTlsInteraction, (password is null) ? null : password.getTlsPasswordStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
236               
237                if (err !is null)
238                {
239                        throw new GException( new ErrorG(err) );
240                }
241               
242                return p;
243        }
244
245        /**
246         * Invoke the interaction to ask the user to choose a certificate to
247         * use with the connection. It invokes this interaction in the main
248         * loop, specifically the #GMainContext returned by
249         * g_main_context_get_thread_default() when the interaction is
250         * created. This is called by called by #GTlsConnection when the peer
251         * requests a certificate during the handshake.
252         *
253         * Derived subclasses usually implement a certificate selector,
254         * although they may also choose to provide a certificate from
255         * elsewhere. Alternatively the user may abort this certificate
256         * request, which may or may not abort the TLS connection.
257         *
258         * The implementation can either be a synchronous (eg: modal dialog) or an
259         * asynchronous one (eg: modeless dialog). This function will take care of
260         * calling which ever one correctly.
261         *
262         * If the interaction is cancelled by the cancellation object, or by the
263         * user then %G_TLS_INTERACTION_FAILED will be returned with an error that
264         * contains a %G_IO_ERROR_CANCELLED error code. Certain implementations may
265         * not support immediate cancellation.
266         *
267         * Params:
268         *     connection = a #GTlsConnection object
269         *     flags = flags providing more information about the request
270         *     cancellable = an optional #GCancellable cancellation object
271         *
272         * Returns: The status of the certificate request interaction.
273         *
274         * Since: 2.40
275         *
276         * Throws: GException on failure.
277         */
278        public GTlsInteractionResult invokeRequestCertificate(TlsConnection connection, GTlsCertificateRequestFlags flags, Cancellable cancellable)
279        {
280                GError* err = null;
281               
282                auto p = g_tls_interaction_invoke_request_certificate(gTlsInteraction, (connection is null) ? null : connection.getTlsConnectionStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
283               
284                if (err !is null)
285                {
286                        throw new GException( new ErrorG(err) );
287                }
288               
289                return p;
290        }
291
292        /**
293         * Run synchronous interaction to ask the user to choose a certificate to use
294         * with the connection. In general, g_tls_interaction_invoke_request_certificate()
295         * should be used instead of this function.
296         *
297         * Derived subclasses usually implement a certificate selector, although they may
298         * also choose to provide a certificate from elsewhere. Alternatively the user may
299         * abort this certificate request, which will usually abort the TLS connection.
300         *
301         * If %G_TLS_INTERACTION_HANDLED is returned, then the #GTlsConnection
302         * passed to g_tls_interaction_request_certificate() will have had its
303         * #GTlsConnection:certificate filled in.
304         *
305         * If the interaction is cancelled by the cancellation object, or by the
306         * user then %G_TLS_INTERACTION_FAILED will be returned with an error that
307         * contains a %G_IO_ERROR_CANCELLED error code. Certain implementations may
308         * not support immediate cancellation.
309         *
310         * Params:
311         *     connection = a #GTlsConnection object
312         *     flags = flags providing more information about the request
313         *     cancellable = an optional #GCancellable cancellation object
314         *
315         * Returns: The status of the request certificate interaction.
316         *
317         * Since: 2.40
318         *
319         * Throws: GException on failure.
320         */
321        public GTlsInteractionResult requestCertificate(TlsConnection connection, GTlsCertificateRequestFlags flags, Cancellable cancellable)
322        {
323                GError* err = null;
324               
325                auto p = g_tls_interaction_request_certificate(gTlsInteraction, (connection is null) ? null : connection.getTlsConnectionStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
326               
327                if (err !is null)
328                {
329                        throw new GException( new ErrorG(err) );
330                }
331               
332                return p;
333        }
334
335        /**
336         * Run asynchronous interaction to ask the user for a certificate to use with
337         * the connection. In general, g_tls_interaction_invoke_request_certificate() should
338         * be used instead of this function.
339         *
340         * Derived subclasses usually implement a certificate selector, although they may
341         * also choose to provide a certificate from elsewhere. @callback will be called
342         * when the operation completes. Alternatively the user may abort this certificate
343         * request, which will usually abort the TLS connection.
344         *
345         * Params:
346         *     connection = a #GTlsConnection object
347         *     flags = flags providing more information about the request
348         *     cancellable = an optional #GCancellable cancellation object
349         *     callback = will be called when the interaction completes
350         *     userData = data to pass to the @callback
351         *
352         * Since: 2.40
353         */
354        public void requestCertificateAsync(TlsConnection connection, GTlsCertificateRequestFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
355        {
356                g_tls_interaction_request_certificate_async(gTlsInteraction, (connection is null) ? null : connection.getTlsConnectionStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
357        }
358
359        /**
360         * Complete an request certificate user interaction request. This should be once
361         * the g_tls_interaction_request_certificate_async() completion callback is called.
362         *
363         * If %G_TLS_INTERACTION_HANDLED is returned, then the #GTlsConnection
364         * passed to g_tls_interaction_request_certificate_async() will have had its
365         * #GTlsConnection:certificate filled in.
366         *
367         * If the interaction is cancelled by the cancellation object, or by the
368         * user then %G_TLS_INTERACTION_FAILED will be returned with an error that
369         * contains a %G_IO_ERROR_CANCELLED error code.
370         *
371         * Params:
372         *     result = the result passed to the callback
373         *
374         * Returns: The status of the request certificate interaction.
375         *
376         * Since: 2.40
377         *
378         * Throws: GException on failure.
379         */
380        public GTlsInteractionResult requestCertificateFinish(AsyncResultIF result)
381        {
382                GError* err = null;
383               
384                auto p = g_tls_interaction_request_certificate_finish(gTlsInteraction, (result is null) ? null : result.getAsyncResultStruct(), &err);
385               
386                if (err !is null)
387                {
388                        throw new GException( new ErrorG(err) );
389                }
390               
391                return p;
392        }
393}
Note: See TracBrowser for help on using the repository browser.