summaryrefslogtreecommitdiff
path: root/gio/src/tlsinteraction.hg
blob: 3d7d07954651acacbd07598d871f1866bfe96f6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* Copyright (C) 2012 The giomm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glibmm/object.h>
#include <giomm/asyncresult.h>
#include <giomm/tlsconnection.h>

_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)
_PINCLUDE(gio/gio.h)

namespace Gio
{

_WRAP_ENUM(TlsInteractionResult, GTlsInteractionResult, decl_prefix GIOMM_API)
_WRAP_ENUM(TlsCertificateRequestFlags, GTlsCertificateRequestFlags, decl_prefix GIOMM_API)

class GIOMM_API Cancellable;
class GIOMM_API TlsPassword;

/** TlsInteraction - Interaction with the user during TLS operations.
 * TlsInteraction provides a mechanism for the TLS connection and database code
 * to interact with the user. It can be used to ask the user for passwords.
 *
 * To use a TlsInteraction with a TLS connection use
 * Gio::TlsConnection::set_interaction().
 *
 * Callers should instantiate a derived class that implements the various
 * interaction methods to show the required dialogs.
 *
 * Callers should use the 'invoke' functions like invoke_ask_password() to run
 * interaction methods. These functions make sure that the interaction is
 * invoked in the main loop and not in the current thread, if the current
 * thread is not running the main loop.
 *
 * Derived classes can choose to implement whichever interactions methods
 * they'd like to support by overriding those virtual methods. Any interactions
 * not implemented will return Gio::TLS_INTERACTION_UNHANDLED. If a derived
 * class implements an async method, it must also implement the corresponding
 * finish method.
 * @newin{2,36}
 */
class GIOMM_API TlsInteraction : public Glib::Object
{
  _CLASS_GOBJECT(TlsInteraction, GTlsInteraction, G_TLS_INTERACTION, Glib::Object, GObject, , , GIOMM_API)

protected:
  _CTOR_DEFAULT

public:
  _WRAP_METHOD(TlsInteractionResult ask_password(const Glib::RefPtr<TlsPassword>& password, const Glib::RefPtr<Cancellable>& cancellable{?}), g_tls_interaction_ask_password, errthrow)
  _WRAP_METHOD(void ask_password_async(const Glib::RefPtr<TlsPassword>& password,
    const SlotAsyncReady& slot{callback?}, const Glib::RefPtr<Cancellable>& cancellable{.?}),
    g_tls_interaction_ask_password_async, slot_name slot, slot_callback giomm_SignalProxy_async_callback)
  _WRAP_METHOD(TlsInteractionResult ask_password_finish(const Glib::RefPtr<AsyncResult>& result), g_tls_interaction_ask_password_finish, errthrow)
  _WRAP_METHOD(TlsInteractionResult invoke_ask_password(const Glib::RefPtr<TlsPassword>& password, const Glib::RefPtr<Cancellable>& cancellable{?}), g_tls_interaction_invoke_ask_password, errthrow)

  _WRAP_METHOD(TlsInteractionResult invoke_request_certificate(const Glib::RefPtr<TlsConnection>& connection, TlsCertificateRequestFlags flags, const Glib::RefPtr<Cancellable>& cancellable{?}), g_tls_interaction_invoke_request_certificate, errthrow)

  _WRAP_METHOD(TlsInteractionResult request_certificate(const Glib::RefPtr<TlsConnection>& connection, TlsCertificateRequestFlags flags, const Glib::RefPtr<Cancellable>& cancellable{?}), g_tls_interaction_request_certificate, errthrow)

  _WRAP_METHOD(void request_certificate_async(const Glib::RefPtr<TlsConnection>& connection,
    TlsCertificateRequestFlags flags, const SlotAsyncReady& slot{callback?}, const Glib::RefPtr<Cancellable>& cancellable{.?}),
    g_tls_interaction_request_certificate_async, slot_name slot, slot_callback giomm_SignalProxy_async_callback)

  _WRAP_METHOD(TlsInteractionResult request_certificate_finish(const Glib::RefPtr<AsyncResult>& result), g_tls_interaction_request_certificate_finish, errthrow)

protected:
#m4 _CONVERSION(`GTlsPassword*',`const Glib::RefPtr<TlsPassword>&',`Glib::wrap($3, true)')
  _WRAP_VFUNC(TlsInteractionResult ask_password(const Glib::RefPtr<TlsPassword>& password, const Glib::RefPtr<Cancellable>& cancellable), "ask_password", errthrow)
  _WRAP_VFUNC(void ask_password_async(const Glib::RefPtr<TlsPassword>& password,
    const SlotAsyncReady& slot{callback}, const Glib::RefPtr<Cancellable>& cancellable{.}),
    "ask_password_async", slot_name slot, slot_callback giomm_SignalProxy_async_callback)

#m4 _CONVERSION(`GAsyncResult*',`const Glib::RefPtr<AsyncResult>&',`Glib::wrap($3, true)')
  _WRAP_VFUNC(TlsInteractionResult ask_password_finish(const Glib::RefPtr<AsyncResult>& result), "ask_password_finish", errthrow)
};

} // namespace Gio