[glibmm] giomm: Add the TlsCertificate class.
- From: Josà Alburquerque <jaalburqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] giomm: Add the TlsCertificate class.
- Date: Sun, 11 Nov 2012 21:28:45 +0000 (UTC)
commit 229f5cf137dabf7d047ab0a3a09d7bbf4a561665
Author: Josà Alburquerque <jaalburqu svn gnome org>
Date: Sun Nov 11 16:24:09 2012 -0500
giomm: Add the TlsCertificate class.
* gio/src/filelist.am:
* gio/src/tlscertificate.{ccg,hg}: Add the sources wrapping the
constructors, methods and (most) properties and include the sources in
the build.
* gio/src/enums.hg: Add the TlsCertificateFlags enum (wrapping the C
enum).
* tools/extra_defs_gen/generate_defs_gio.cc: Add the GTlsCertificate
GType to the list of types for which signal and property defs are to
be generated.
* gio/src/gio_signals.defs: Regenerate the signal and property defs
file.
* tools/m4/convert_gio.m4: Add necessary conversions.
* gio/src/gio_extra_objects.defs: Add TlsClientConnection to avoid a
gmmproc docs warning.
ChangeLog | 20 ++++++++
gio/src/enums.hg | 1 +
gio/src/filelist.am | 1 +
gio/src/gio_extra_objects.defs | 6 ++
gio/src/gio_signals.defs | 47 ++++++++++++++++++
gio/src/tlscertificate.ccg | 19 +++++++
gio/src/tlscertificate.hg | 74 +++++++++++++++++++++++++++++
tools/extra_defs_gen/generate_defs_gio.cc | 1 +
tools/m4/convert_gio.m4 | 6 ++
9 files changed, 175 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e6b339e..b3aecb2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2012-11-11 Josà Alburquerque <jaalburquerque gmail com>
+
+ giomm: Add the TlsCertificate class.
+
+ * gio/src/filelist.am:
+ * gio/src/tlscertificate.{ccg,hg}: Add the sources wrapping the
+ constructors, methods and (most) properties and include the sources in
+ the build.
+ * gio/src/enums.hg: Add the TlsCertificateFlags enum (wrapping the C
+ enum).
+ * tools/extra_defs_gen/generate_defs_gio.cc: Add the GTlsCertificate
+ GType to the list of types for which signal and property defs are to
+ be generated.
+ * gio/src/gio_signals.defs: Regenerate the signal and property defs
+ file.
+ * tools/m4/convert_gio.m4: Add necessary conversions.
+
+ * gio/src/gio_extra_objects.defs: Add TlsClientConnection to avoid a
+ gmmproc docs warning.
+
2012-11-08 Josà Alburquerque <jaalburquerque gmail com>
gmmproc: _WRAP_CTOR: Handle *_new() functions with a final GError**.
diff --git a/gio/src/enums.hg b/gio/src/enums.hg
index 1c48dc5..315e7fd 100644
--- a/gio/src/enums.hg
+++ b/gio/src/enums.hg
@@ -29,6 +29,7 @@ _WRAP_ENUM(DataStreamByteOrder, GDataStreamByteOrder, NO_GTYPE)
_WRAP_ENUM(DataStreamNewlineType, GDataStreamNewlineType, NO_GTYPE)
_WRAP_ENUM(ErrorEnum, GIOErrorEnum, NO_GTYPE)
_WRAP_ENUM(SocketFamily, GSocketFamily)
+_WRAP_ENUM(TlsCertificateFlags, GTlsCertificateFlags)
} // namespace Gio
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index db061b1..f07b380 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -113,6 +113,7 @@ giomm_files_any_hg = \
tcpconnection.hg \
threadedsocketservice.hg \
themedicon.hg \
+ tlscertificate.hg \
volume.hg \
volumemonitor.hg \
zlibdecompressor.hg \
diff --git a/gio/src/gio_extra_objects.defs b/gio/src/gio_extra_objects.defs
index 4be8ea2..94cc165 100644
--- a/gio/src/gio_extra_objects.defs
+++ b/gio/src/gio_extra_objects.defs
@@ -174,3 +174,9 @@
(c-name "GSimpleAction")
(gtype-id "G_TYPE_SIMPLE_ACTION")
)
+
+(define-object TlsClientConnection
+ (in-module "Gio")
+ (c-name "GTlsClientConnection")
+ (gtype-id "G_TYPE_TLS_CLIENT_CONNECTION")
+)
diff --git a/gio/src/gio_signals.defs b/gio/src/gio_signals.defs
index 097b027..c6168b2 100644
--- a/gio/src/gio_signals.defs
+++ b/gio/src/gio_signals.defs
@@ -1781,6 +1781,53 @@
(construct-only #f)
)
+;; From GTlsCertificate
+
+(define-property certificate
+ (of-object "GTlsCertificate")
+ (prop-type "GParamBoxed")
+ (docs "The DER representation of the certificate")
+ (readable #t)
+ (writable #t)
+ (construct-only #t)
+)
+
+(define-property certificate-pem
+ (of-object "GTlsCertificate")
+ (prop-type "GParamString")
+ (docs "The PEM representation of the certificate")
+ (readable #t)
+ (writable #t)
+ (construct-only #t)
+)
+
+(define-property private-key
+ (of-object "GTlsCertificate")
+ (prop-type "GParamBoxed")
+ (docs "The DER representation of the certificate's private key")
+ (readable #f)
+ (writable #t)
+ (construct-only #t)
+)
+
+(define-property private-key-pem
+ (of-object "GTlsCertificate")
+ (prop-type "GParamString")
+ (docs "The PEM representation of the certificate's private key")
+ (readable #f)
+ (writable #t)
+ (construct-only #t)
+)
+
+(define-property issuer
+ (of-object "GTlsCertificate")
+ (prop-type "GParamObject")
+ (docs "The certificate for the issuing entity")
+ (readable #t)
+ (writable #t)
+ (construct-only #t)
+)
+
;; From GUnixConnection
;; From GSocketListener
diff --git a/gio/src/tlscertificate.ccg b/gio/src/tlscertificate.ccg
new file mode 100644
index 0000000..7225d99
--- /dev/null
+++ b/gio/src/tlscertificate.ccg
@@ -0,0 +1,19 @@
+/* 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gio/gio.h>
+#include <giomm/socketconnectable.h>
diff --git a/gio/src/tlscertificate.hg b/gio/src/tlscertificate.hg
new file mode 100644
index 0000000..d4aebcf
--- /dev/null
+++ b/gio/src/tlscertificate.hg
@@ -0,0 +1,74 @@
+/* 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, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glibmm/object.h>
+#include <giomm/enums.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+class SocketConnectable;
+
+/** TlsCertificate - TLS certificate.
+ * A certificate used for TLS authentication and encryption. This can represent
+ * either a certificate only (eg, the certificate received by a client from a
+ * server), or the combination of a certificate and a private key (which is
+ * needed when acting as a TlsServerConnection).
+ * @newin{2,36}
+ */
+class TlsCertificate : public Glib::Object
+{
+ _CLASS_GOBJECT(TlsCertificate, GTlsCertificate, G_TLS_CERTIFICATE, Glib::Object, GObject)
+
+protected:
+ _WRAP_CTOR(TlsCertificate(const char* data, gssize length), g_tls_certificate_new_from_pem, errthrow)
+ _WRAP_CTOR(TlsCertificate(const std::string& file), g_tls_certificate_new_from_file, errthrow)
+ _WRAP_CTOR(TlsCertificate(const std::string& cert_file, const std::string& key_file), g_tls_certificate_new_from_files, errthrow)
+
+public:
+ _WRAP_METHOD_DOCS_ONLY(g_tls_certificate_new_from_pem)
+ _WRAP_CREATE(const char* data, gssize length = -1)
+
+ _WRAP_METHOD_DOCS_ONLY(g_tls_certificate_new_from_file)
+ _WRAP_CREATE(const std::string& file)
+
+ _WRAP_METHOD_DOCS_ONLY(g_tls_certificate_new_from_files)
+ _WRAP_CREATE(const std::string& cert_file, const std::string& key_file)
+
+#m4 _CONVERSION(`GList*', `std::vector< Glib::RefPtr<TlsCertificate> >', `Glib::ListHandler< Glib::RefPtr<TlsCertificate> >::list_to_vector($3, Glib::OWNERSHIP_DEEP)')
+ _WRAP_METHOD(static std::vector< Glib::RefPtr<TlsCertificate> > create_list_from_file(const std::string& file), g_tls_certificate_list_new_from_file, errthrow)
+
+ _WRAP_METHOD(Glib::RefPtr<TlsCertificate> get_issuer(), g_tls_certificate_get_issuer)
+ _WRAP_METHOD(Glib::RefPtr<const TlsCertificate> get_issuer() const, g_tls_certificate_get_issuer, constversion)
+
+ _WRAP_METHOD(TlsCertificateFlags verify(const Glib::RefPtr<const SocketConnectable>& identity{?}, const Glib::RefPtr<const TlsCertificate>& trusted_ca{?}) const, g_tls_certificate_verify)
+ _WRAP_METHOD(bool is_same(const Glib::RefPtr<const TlsCertificate>& cert_two) const, g_tls_certificate_is_same)
+
+ //TODO: _WRAP_PROPERTY("certificate", GByteArray*)
+
+ _WRAP_PROPERTY("certificate-pem", char*)
+ _WRAP_PROPERTY("issuer", Glib::RefPtr<TlsCertificate>)
+
+ //TODO: _WRAP_PROPERTY("private-key", GByteArray*)
+
+ _WRAP_PROPERTY("private-key-pem", char*)
+};
+
+} // namespace Gio
diff --git a/tools/extra_defs_gen/generate_defs_gio.cc b/tools/extra_defs_gen/generate_defs_gio.cc
index 5042e17..278db64 100644
--- a/tools/extra_defs_gen/generate_defs_gio.cc
+++ b/tools/extra_defs_gen/generate_defs_gio.cc
@@ -114,6 +114,7 @@ int main(int, char**)
<< get_defs(G_TYPE_SOCKET_CLIENT)
<< get_defs(G_TYPE_SOCKET_CONNECTION)
<< get_defs(G_TYPE_TCP_CONNECTION)
+ << get_defs(G_TYPE_TLS_CERTIFICATE)
#ifndef G_OS_WIN32
<< get_defs(G_TYPE_UNIX_CONNECTION)
#endif
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index 6e5f60e..2f143b6 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -39,6 +39,7 @@ _CONV_ENUM(G,SocketFamily)
_CONV_ENUM(G,SocketMsgFlags)
_CONV_ENUM(G,SocketProtocol)
_CONV_ENUM(G,SocketType)
+_CONV_ENUM(G, TlsCertificateFlags)
_CONV_ENUM(G,UnixSocketAddressType)
_CONV_ENUM(G,ZlibCompressorFormat)
@@ -249,6 +250,7 @@ _CONVERSION(`GSocketAddressEnumerator*',`Glib::RefPtr<SocketAddressEnumerator>',
#SocketConnectable
_CONVERSION(`const Glib::RefPtr<SocketConnectable>&',`GSocketConnectable*',__CONVERT_CONST_REFPTR_TO_P)
+_CONVERSION(`const Glib::RefPtr<const SocketConnectable>&', `GSocketConnectable*', `const_cast<GSocketConnectable*>(Glib::unwrap($3))')
#SocketConnection
_CONVERSION(`GSocketConnection*',`Glib::RefPtr<SocketConnection>',`Glib::wrap($3)')
@@ -260,6 +262,10 @@ _CONVERSION(`GSocketControlMessage*',`Glib::RefPtr<SocketControlMessage>',`Glib:
#TimeZoneMonitor
_CONVERSION(`GTimeZoneMonitor*',`Glib::RefPtr<TimeZoneMonitor>',`Glib::wrap($3)')
+#TlsCertificate
+_CONVERSION(`GTlsCertificate*', `Glib::RefPtr<TlsCertificate>', `Glib::wrap($3)')
+_CONVERSION(`const Glib::RefPtr<const TlsCertificate>&', `GTlsCertificate*', `const_cast<GTlsCertificate*>(Glib::unwrap($3))')
+
#UnixFDList
_CONVERSION(`GUnixFDList*',`Glib::RefPtr<UnixFDList>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<UnixFDList>&',`GUnixFDList*',`Glib::unwrap($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]