summaryrefslogtreecommitdiff
path: root/gio/src/tlsclientconnection.hg
blob: 194a73017ed76e6a37ffefb2115342ced73b9bd8 (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
93
94
95
96
/* Copyright (C) 2013 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/interface.h>
#include <giomm/enums.h>
#include <giomm/iostream.h>

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

#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GTlsClientConnectionInterface GTlsClientConnectionInterface;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

namespace Glib
{
class GLIBMM_API ByteArray;
}

namespace Gio
{

class GIOMM_API SocketConnectable;
class GIOMM_API TlsClientConnectionImpl;

// See https://bugzilla.gnome.org/show_bug.cgi?id=776537
// especially the last paragraph of comment 6.

/** TLS client-side connection.
 * %TlsClientConnection is the client-side subclass of TlsConnection,
 * representing a client-side TLS connection.
 * @newin{2,36}
 */
class GIOMM_API TlsClientConnection : public Glib::Interface
{
  _CLASS_INTERFACE(TlsClientConnection, GTlsClientConnection, G_TLS_CLIENT_CONNECTION, GTlsClientConnectionInterface, , , GIOMM_API)

public:
  // It's not possible to use _WRAP_CTOR/_WRAP_CREATE to wrap the new
  // function because this is an interface.
#m4 _CONVERSION(`GIOStream*',`Glib::RefPtr<TlsClientConnectionImpl>',`std::dynamic_pointer_cast<TlsClientConnectionImpl>(Glib::wrap(G_TLS_CONNECTION($3)))')
  _WRAP_METHOD(static Glib::RefPtr<TlsClientConnectionImpl> create(const Glib::RefPtr<IOStream>& base_io_stream,
    const Glib::RefPtr<const SocketConnectable>& server_identity{?}), g_tls_client_connection_new, errthrow)

  _WRAP_METHOD(void set_server_identity(const Glib::RefPtr<SocketConnectable>& identity), g_tls_client_connection_set_server_identity)

  _WRAP_METHOD(Glib::RefPtr<SocketConnectable> get_server_identity(), g_tls_client_connection_get_server_identity, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const SocketConnectable> get_server_identity() const, g_tls_client_connection_get_server_identity, constversion)

  //TODO: Deprecate in glibmm 2.72.
  _WRAP_METHOD_DOCS_ONLY(g_tls_client_connection_set_validation_flags)
  void set_validation_flags(TlsCertificateFlags flags);
  _WRAP_METHOD_DOCS_ONLY(g_tls_client_connection_get_validation_flags)
  TlsCertificateFlags get_validation_flags() const;
  _IGNORE(g_tls_client_connection_set_validation_flags, g_tls_client_connection_get_validation_flags)
  //_WRAP_METHOD(void set_validation_flags(TlsCertificateFlags flags), g_tls_client_connection_set_validation_flags,
  //  deprecated "Do not attempt to ignore validation errors.")
  //_WRAP_METHOD(TlsCertificateFlags get_validation_flags() const, g_tls_client_connection_get_validation_flags,
  //  deprecated "Do not attempt to ignore validation errors.")

  _IGNORE(g_tls_client_connection_set_use_ssl3, g_tls_client_connection_get_use_ssl3) dnl// deprecated

#m4 _CONVERSION(`GList*',`std::vector< Glib::RefPtr<Glib::ByteArray> >',`Glib::ListHandler< Glib::RefPtr<Glib::ByteArray> >::list_to_vector($3, Glib::OWNERSHIP_DEEP)')
  _WRAP_METHOD(std::vector< Glib::RefPtr<Glib::ByteArray> > get_accepted_cas(), g_tls_client_connection_get_accepted_cas)

#m4 _CONVERSION(`GList*',`std::vector< Glib::RefPtr<const Glib::ByteArray> >',`Glib::ListHandler< Glib::RefPtr<const Glib::ByteArray> >::list_to_vector($3, Glib::OWNERSHIP_DEEP)')
  _WRAP_METHOD(std::vector< Glib::RefPtr<const Glib::ByteArray> > get_accepted_cas() const, g_tls_client_connection_get_accepted_cas)

  _WRAP_METHOD(void copy_session_state(const Glib::RefPtr<TlsClientConnection>& source), g_tls_client_connection_copy_session_state)

  // property_accepted_cas() won't work unless a Glib::Value<std::vector<Glib::RefPtr<Glib::ByteArray>>>
  // specialization is added. Workaround: Use get_accepted_cas().
  //_WRAP_PROPERTY("accepted-cas", std::vector<Glib::RefPtr<Glib::ByteArray>>)
  _WRAP_PROPERTY("server-identity", Glib::RefPtr<SocketConnectable>)
  //TODO: Deprecate in glibmm 2.72.
  _WRAP_PROPERTY("validation-flags", TlsCertificateFlags)
  //_WRAP_PROPERTY("validation-flags", TlsCertificateFlags,
  //  deprecated "Do not attempt to ignore validation errors.")
  _IGNORE_PROPERTY(use-ssl3) dnl// deprecated
};

} // namespace Gio