Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit 23e091d

Browse files
Add more Tls bindings
1 parent 04fecda commit 23e091d

6 files changed

+1050
-0
lines changed

src/auto/tls_client_connection.rs

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
// This file was generated by gir (https://github.com/gtk-rs/gir @ 72ba992)
2+
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
3+
// DO NOT EDIT
4+
5+
use Error;
6+
use IOStream;
7+
use SocketConnectable;
8+
use TlsCertificateFlags;
9+
use TlsConnection;
10+
use ffi;
11+
use glib;
12+
use glib::object::Downcast;
13+
use glib::object::IsA;
14+
use glib::signal::SignalHandlerId;
15+
use glib::signal::connect;
16+
use glib::translate::*;
17+
use glib_ffi;
18+
use gobject_ffi;
19+
use std::boxed::Box as Box_;
20+
use std::mem;
21+
use std::mem::transmute;
22+
use std::ptr;
23+
24+
glib_wrapper! {
25+
pub struct TlsClientConnection(Object<ffi::GTlsClientConnection, ffi::GTlsClientConnectionInterface>): TlsConnection, IOStream;
26+
27+
match fn {
28+
get_type => || ffi::g_tls_client_connection_get_type(),
29+
}
30+
}
31+
32+
impl TlsClientConnection {
33+
pub fn new<'a, P: IsA<IOStream>, Q: IsA<SocketConnectable> + 'a, R: Into<Option<&'a Q>>>(base_io_stream: &P, server_identity: R) -> Result<TlsClientConnection, Error> {
34+
let server_identity = server_identity.into();
35+
let server_identity = server_identity.to_glib_none();
36+
unsafe {
37+
let mut error = ptr::null_mut();
38+
let ret = ffi::g_tls_client_connection_new(base_io_stream.to_glib_none().0, server_identity.0, &mut error);
39+
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
40+
}
41+
}
42+
}
43+
44+
pub trait TlsClientConnectionExt {
45+
#[cfg(any(feature = "v2_46", feature = "dox"))]
46+
fn copy_session_state<P: IsA<TlsClientConnection>>(&self, source: &P);
47+
48+
//fn get_accepted_cas(&self) -> /*Ignored*/Vec<glib::ByteArray>;
49+
50+
fn get_server_identity(&self) -> Option<SocketConnectable>;
51+
52+
fn get_use_ssl3(&self) -> bool;
53+
54+
fn get_validation_flags(&self) -> TlsCertificateFlags;
55+
56+
fn set_server_identity<P: IsA<SocketConnectable>>(&self, identity: &P);
57+
58+
fn set_use_ssl3(&self, use_ssl3: bool);
59+
60+
fn set_validation_flags(&self, flags: TlsCertificateFlags);
61+
62+
fn connect_property_accepted_cas_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
63+
64+
fn connect_property_server_identity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
65+
66+
fn connect_property_use_ssl3_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
67+
68+
fn connect_property_validation_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
69+
}
70+
71+
impl<O: IsA<TlsClientConnection> + IsA<glib::object::Object>> TlsClientConnectionExt for O {
72+
#[cfg(any(feature = "v2_46", feature = "dox"))]
73+
fn copy_session_state<P: IsA<TlsClientConnection>>(&self, source: &P) {
74+
unsafe {
75+
ffi::g_tls_client_connection_copy_session_state(self.to_glib_none().0, source.to_glib_none().0);
76+
}
77+
}
78+
79+
//fn get_accepted_cas(&self) -> /*Ignored*/Vec<glib::ByteArray> {
80+
// unsafe { TODO: call ffi::g_tls_client_connection_get_accepted_cas() }
81+
//}
82+
83+
fn get_server_identity(&self) -> Option<SocketConnectable> {
84+
unsafe {
85+
from_glib_none(ffi::g_tls_client_connection_get_server_identity(self.to_glib_none().0))
86+
}
87+
}
88+
89+
fn get_use_ssl3(&self) -> bool {
90+
unsafe {
91+
from_glib(ffi::g_tls_client_connection_get_use_ssl3(self.to_glib_none().0))
92+
}
93+
}
94+
95+
fn get_validation_flags(&self) -> TlsCertificateFlags {
96+
unsafe {
97+
from_glib(ffi::g_tls_client_connection_get_validation_flags(self.to_glib_none().0))
98+
}
99+
}
100+
101+
fn set_server_identity<P: IsA<SocketConnectable>>(&self, identity: &P) {
102+
unsafe {
103+
ffi::g_tls_client_connection_set_server_identity(self.to_glib_none().0, identity.to_glib_none().0);
104+
}
105+
}
106+
107+
fn set_use_ssl3(&self, use_ssl3: bool) {
108+
unsafe {
109+
ffi::g_tls_client_connection_set_use_ssl3(self.to_glib_none().0, use_ssl3.to_glib());
110+
}
111+
}
112+
113+
fn set_validation_flags(&self, flags: TlsCertificateFlags) {
114+
unsafe {
115+
ffi::g_tls_client_connection_set_validation_flags(self.to_glib_none().0, flags.to_glib());
116+
}
117+
}
118+
119+
fn connect_property_accepted_cas_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
120+
unsafe {
121+
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
122+
connect(self.to_glib_none().0, "notify::accepted-cas",
123+
transmute(notify_accepted_cas_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
124+
}
125+
}
126+
127+
fn connect_property_server_identity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
128+
unsafe {
129+
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
130+
connect(self.to_glib_none().0, "notify::server-identity",
131+
transmute(notify_server_identity_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
132+
}
133+
}
134+
135+
fn connect_property_use_ssl3_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
136+
unsafe {
137+
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
138+
connect(self.to_glib_none().0, "notify::use-ssl3",
139+
transmute(notify_use_ssl3_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
140+
}
141+
}
142+
143+
fn connect_property_validation_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
144+
unsafe {
145+
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
146+
connect(self.to_glib_none().0, "notify::validation-flags",
147+
transmute(notify_validation_flags_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
148+
}
149+
}
150+
}
151+
152+
unsafe extern "C" fn notify_accepted_cas_trampoline<P>(this: *mut ffi::GTlsClientConnection, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
153+
where P: IsA<TlsClientConnection> {
154+
let f: &&(Fn(&P) + 'static) = transmute(f);
155+
f(&TlsClientConnection::from_glib_borrow(this).downcast_unchecked())
156+
}
157+
158+
unsafe extern "C" fn notify_server_identity_trampoline<P>(this: *mut ffi::GTlsClientConnection, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
159+
where P: IsA<TlsClientConnection> {
160+
let f: &&(Fn(&P) + 'static) = transmute(f);
161+
f(&TlsClientConnection::from_glib_borrow(this).downcast_unchecked())
162+
}
163+
164+
unsafe extern "C" fn notify_use_ssl3_trampoline<P>(this: *mut ffi::GTlsClientConnection, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
165+
where P: IsA<TlsClientConnection> {
166+
let f: &&(Fn(&P) + 'static) = transmute(f);
167+
f(&TlsClientConnection::from_glib_borrow(this).downcast_unchecked())
168+
}
169+
170+
unsafe extern "C" fn notify_validation_flags_trampoline<P>(this: *mut ffi::GTlsClientConnection, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
171+
where P: IsA<TlsClientConnection> {
172+
let f: &&(Fn(&P) + 'static) = transmute(f);
173+
f(&TlsClientConnection::from_glib_borrow(this).downcast_unchecked())
174+
}

0 commit comments

Comments
 (0)