1 // This file was generated by gir (https://github.com/gtk-rs/gir) 2 // from gir-files (https://github.com/gtk-rs/gir-files) 3 // DO NOT EDIT 4 5 use gio_sys; 6 use glib; 7 use glib::object::Cast; 8 use glib::object::IsA; 9 use glib::signal::connect_raw; 10 use glib::signal::SignalHandlerId; 11 use glib::translate::*; 12 use glib_sys; 13 use std::boxed::Box as Box_; 14 use std::fmt; 15 use std::mem::transmute; 16 use std::ptr; 17 use IOStream; 18 use SocketConnectable; 19 use TlsCertificateFlags; 20 use TlsConnection; 21 22 glib_wrapper! { 23 pub struct TlsClientConnection(Interface<gio_sys::GTlsClientConnection>) @requires TlsConnection, IOStream; 24 25 match fn { 26 get_type => || gio_sys::g_tls_client_connection_get_type(), 27 } 28 } 29 30 impl TlsClientConnection { new<P: IsA<IOStream>, Q: IsA<SocketConnectable>>( base_io_stream: &P, server_identity: Option<&Q>, ) -> Result<TlsClientConnection, glib::Error>31 pub fn new<P: IsA<IOStream>, Q: IsA<SocketConnectable>>( 32 base_io_stream: &P, 33 server_identity: Option<&Q>, 34 ) -> Result<TlsClientConnection, glib::Error> { 35 unsafe { 36 let mut error = ptr::null_mut(); 37 let ret = gio_sys::g_tls_client_connection_new( 38 base_io_stream.as_ref().to_glib_none().0, 39 server_identity.map(|p| p.as_ref()).to_glib_none().0, 40 &mut error, 41 ); 42 if error.is_null() { 43 Ok(from_glib_full(ret)) 44 } else { 45 Err(from_glib_full(error)) 46 } 47 } 48 } 49 } 50 51 pub const NONE_TLS_CLIENT_CONNECTION: Option<&TlsClientConnection> = None; 52 53 pub trait TlsClientConnectionExt: 'static { 54 #[cfg(any(feature = "v2_46", feature = "dox"))] copy_session_state<P: IsA<TlsClientConnection>>(&self, source: &P)55 fn copy_session_state<P: IsA<TlsClientConnection>>(&self, source: &P); 56 57 //fn get_accepted_cas(&self) -> /*Ignored*/Vec<glib::ByteArray>; 58 get_server_identity(&self) -> Option<SocketConnectable>59 fn get_server_identity(&self) -> Option<SocketConnectable>; 60 61 #[cfg_attr(feature = "v2_56", deprecated)] get_use_ssl3(&self) -> bool62 fn get_use_ssl3(&self) -> bool; 63 get_validation_flags(&self) -> TlsCertificateFlags64 fn get_validation_flags(&self) -> TlsCertificateFlags; 65 set_server_identity<P: IsA<SocketConnectable>>(&self, identity: &P)66 fn set_server_identity<P: IsA<SocketConnectable>>(&self, identity: &P); 67 68 #[cfg_attr(feature = "v2_56", deprecated)] set_use_ssl3(&self, use_ssl3: bool)69 fn set_use_ssl3(&self, use_ssl3: bool); 70 set_validation_flags(&self, flags: TlsCertificateFlags)71 fn set_validation_flags(&self, flags: TlsCertificateFlags); 72 connect_property_accepted_cas_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId73 fn connect_property_accepted_cas_notify<F: Fn(&Self) + 'static>(&self, f: F) 74 -> SignalHandlerId; 75 connect_property_server_identity_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId76 fn connect_property_server_identity_notify<F: Fn(&Self) + 'static>( 77 &self, 78 f: F, 79 ) -> SignalHandlerId; 80 81 #[cfg_attr(feature = "v2_56", deprecated)] connect_property_use_ssl3_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId82 fn connect_property_use_ssl3_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 83 connect_property_validation_flags_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId84 fn connect_property_validation_flags_notify<F: Fn(&Self) + 'static>( 85 &self, 86 f: F, 87 ) -> SignalHandlerId; 88 } 89 90 impl<O: IsA<TlsClientConnection>> TlsClientConnectionExt for O { 91 #[cfg(any(feature = "v2_46", feature = "dox"))] copy_session_state<P: IsA<TlsClientConnection>>(&self, source: &P)92 fn copy_session_state<P: IsA<TlsClientConnection>>(&self, source: &P) { 93 unsafe { 94 gio_sys::g_tls_client_connection_copy_session_state( 95 self.as_ref().to_glib_none().0, 96 source.as_ref().to_glib_none().0, 97 ); 98 } 99 } 100 101 //fn get_accepted_cas(&self) -> /*Ignored*/Vec<glib::ByteArray> { 102 // unsafe { TODO: call gio_sys:g_tls_client_connection_get_accepted_cas() } 103 //} 104 get_server_identity(&self) -> Option<SocketConnectable>105 fn get_server_identity(&self) -> Option<SocketConnectable> { 106 unsafe { 107 from_glib_none(gio_sys::g_tls_client_connection_get_server_identity( 108 self.as_ref().to_glib_none().0, 109 )) 110 } 111 } 112 get_use_ssl3(&self) -> bool113 fn get_use_ssl3(&self) -> bool { 114 unsafe { 115 from_glib(gio_sys::g_tls_client_connection_get_use_ssl3( 116 self.as_ref().to_glib_none().0, 117 )) 118 } 119 } 120 get_validation_flags(&self) -> TlsCertificateFlags121 fn get_validation_flags(&self) -> TlsCertificateFlags { 122 unsafe { 123 from_glib(gio_sys::g_tls_client_connection_get_validation_flags( 124 self.as_ref().to_glib_none().0, 125 )) 126 } 127 } 128 set_server_identity<P: IsA<SocketConnectable>>(&self, identity: &P)129 fn set_server_identity<P: IsA<SocketConnectable>>(&self, identity: &P) { 130 unsafe { 131 gio_sys::g_tls_client_connection_set_server_identity( 132 self.as_ref().to_glib_none().0, 133 identity.as_ref().to_glib_none().0, 134 ); 135 } 136 } 137 set_use_ssl3(&self, use_ssl3: bool)138 fn set_use_ssl3(&self, use_ssl3: bool) { 139 unsafe { 140 gio_sys::g_tls_client_connection_set_use_ssl3( 141 self.as_ref().to_glib_none().0, 142 use_ssl3.to_glib(), 143 ); 144 } 145 } 146 set_validation_flags(&self, flags: TlsCertificateFlags)147 fn set_validation_flags(&self, flags: TlsCertificateFlags) { 148 unsafe { 149 gio_sys::g_tls_client_connection_set_validation_flags( 150 self.as_ref().to_glib_none().0, 151 flags.to_glib(), 152 ); 153 } 154 } 155 connect_property_accepted_cas_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId156 fn connect_property_accepted_cas_notify<F: Fn(&Self) + 'static>( 157 &self, 158 f: F, 159 ) -> SignalHandlerId { 160 unsafe extern "C" fn notify_accepted_cas_trampoline<P, F: Fn(&P) + 'static>( 161 this: *mut gio_sys::GTlsClientConnection, 162 _param_spec: glib_sys::gpointer, 163 f: glib_sys::gpointer, 164 ) where 165 P: IsA<TlsClientConnection>, 166 { 167 let f: &F = &*(f as *const F); 168 f(&TlsClientConnection::from_glib_borrow(this).unsafe_cast()) 169 } 170 unsafe { 171 let f: Box_<F> = Box_::new(f); 172 connect_raw( 173 self.as_ptr() as *mut _, 174 b"notify::accepted-cas\0".as_ptr() as *const _, 175 Some(transmute( 176 notify_accepted_cas_trampoline::<Self, F> as usize, 177 )), 178 Box_::into_raw(f), 179 ) 180 } 181 } 182 connect_property_server_identity_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId183 fn connect_property_server_identity_notify<F: Fn(&Self) + 'static>( 184 &self, 185 f: F, 186 ) -> SignalHandlerId { 187 unsafe extern "C" fn notify_server_identity_trampoline<P, F: Fn(&P) + 'static>( 188 this: *mut gio_sys::GTlsClientConnection, 189 _param_spec: glib_sys::gpointer, 190 f: glib_sys::gpointer, 191 ) where 192 P: IsA<TlsClientConnection>, 193 { 194 let f: &F = &*(f as *const F); 195 f(&TlsClientConnection::from_glib_borrow(this).unsafe_cast()) 196 } 197 unsafe { 198 let f: Box_<F> = Box_::new(f); 199 connect_raw( 200 self.as_ptr() as *mut _, 201 b"notify::server-identity\0".as_ptr() as *const _, 202 Some(transmute( 203 notify_server_identity_trampoline::<Self, F> as usize, 204 )), 205 Box_::into_raw(f), 206 ) 207 } 208 } 209 connect_property_use_ssl3_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId210 fn connect_property_use_ssl3_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 211 unsafe extern "C" fn notify_use_ssl3_trampoline<P, F: Fn(&P) + 'static>( 212 this: *mut gio_sys::GTlsClientConnection, 213 _param_spec: glib_sys::gpointer, 214 f: glib_sys::gpointer, 215 ) where 216 P: IsA<TlsClientConnection>, 217 { 218 let f: &F = &*(f as *const F); 219 f(&TlsClientConnection::from_glib_borrow(this).unsafe_cast()) 220 } 221 unsafe { 222 let f: Box_<F> = Box_::new(f); 223 connect_raw( 224 self.as_ptr() as *mut _, 225 b"notify::use-ssl3\0".as_ptr() as *const _, 226 Some(transmute(notify_use_ssl3_trampoline::<Self, F> as usize)), 227 Box_::into_raw(f), 228 ) 229 } 230 } 231 connect_property_validation_flags_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId232 fn connect_property_validation_flags_notify<F: Fn(&Self) + 'static>( 233 &self, 234 f: F, 235 ) -> SignalHandlerId { 236 unsafe extern "C" fn notify_validation_flags_trampoline<P, F: Fn(&P) + 'static>( 237 this: *mut gio_sys::GTlsClientConnection, 238 _param_spec: glib_sys::gpointer, 239 f: glib_sys::gpointer, 240 ) where 241 P: IsA<TlsClientConnection>, 242 { 243 let f: &F = &*(f as *const F); 244 f(&TlsClientConnection::from_glib_borrow(this).unsafe_cast()) 245 } 246 unsafe { 247 let f: Box_<F> = Box_::new(f); 248 connect_raw( 249 self.as_ptr() as *mut _, 250 b"notify::validation-flags\0".as_ptr() as *const _, 251 Some(transmute( 252 notify_validation_flags_trampoline::<Self, F> as usize, 253 )), 254 Box_::into_raw(f), 255 ) 256 } 257 } 258 } 259 260 impl fmt::Display for TlsClientConnection { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result261 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 262 write!(f, "TlsClientConnection") 263 } 264 } 265