This repository was archived by the owner on Jun 8, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 31
More tls bindings #83
Merged
GuillaumeGomez
merged 1 commit into
gtk-rs:master
from
MathieuDuponchelle:more_tls_bindings
Feb 22, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
// This file was generated by gir (https://github.com/gtk-rs/gir @ 72ba992) | ||
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70) | ||
// DO NOT EDIT | ||
|
||
use Error; | ||
use IOStream; | ||
use SocketConnectable; | ||
use TlsCertificateFlags; | ||
use TlsConnection; | ||
use ffi; | ||
use glib; | ||
use glib::object::Downcast; | ||
use glib::object::IsA; | ||
use glib::signal::SignalHandlerId; | ||
use glib::signal::connect; | ||
use glib::translate::*; | ||
use glib_ffi; | ||
use gobject_ffi; | ||
use std::boxed::Box as Box_; | ||
use std::mem; | ||
use std::mem::transmute; | ||
use std::ptr; | ||
|
||
glib_wrapper! { | ||
pub struct TlsClientConnection(Object<ffi::GTlsClientConnection, ffi::GTlsClientConnectionInterface>): TlsConnection, IOStream; | ||
|
||
match fn { | ||
get_type => || ffi::g_tls_client_connection_get_type(), | ||
} | ||
} | ||
|
||
impl TlsClientConnection { | ||
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> { | ||
let server_identity = server_identity.into(); | ||
let server_identity = server_identity.to_glib_none(); | ||
unsafe { | ||
let mut error = ptr::null_mut(); | ||
let ret = ffi::g_tls_client_connection_new(base_io_stream.to_glib_none().0, server_identity.0, &mut error); | ||
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } | ||
} | ||
} | ||
} | ||
|
||
pub trait TlsClientConnectionExt { | ||
#[cfg(any(feature = "v2_46", feature = "dox"))] | ||
fn copy_session_state<P: IsA<TlsClientConnection>>(&self, source: &P); | ||
|
||
//fn get_accepted_cas(&self) -> /*Ignored*/Vec<glib::ByteArray>; | ||
|
||
fn get_server_identity(&self) -> Option<SocketConnectable>; | ||
|
||
fn get_use_ssl3(&self) -> bool; | ||
|
||
fn get_validation_flags(&self) -> TlsCertificateFlags; | ||
|
||
fn set_server_identity<P: IsA<SocketConnectable>>(&self, identity: &P); | ||
|
||
fn set_use_ssl3(&self, use_ssl3: bool); | ||
|
||
fn set_validation_flags(&self, flags: TlsCertificateFlags); | ||
|
||
fn connect_property_accepted_cas_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; | ||
|
||
fn connect_property_server_identity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; | ||
|
||
fn connect_property_use_ssl3_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; | ||
|
||
fn connect_property_validation_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; | ||
} | ||
|
||
impl<O: IsA<TlsClientConnection> + IsA<glib::object::Object>> TlsClientConnectionExt for O { | ||
#[cfg(any(feature = "v2_46", feature = "dox"))] | ||
fn copy_session_state<P: IsA<TlsClientConnection>>(&self, source: &P) { | ||
unsafe { | ||
ffi::g_tls_client_connection_copy_session_state(self.to_glib_none().0, source.to_glib_none().0); | ||
} | ||
} | ||
|
||
//fn get_accepted_cas(&self) -> /*Ignored*/Vec<glib::ByteArray> { | ||
// unsafe { TODO: call ffi::g_tls_client_connection_get_accepted_cas() } | ||
//} | ||
|
||
fn get_server_identity(&self) -> Option<SocketConnectable> { | ||
unsafe { | ||
from_glib_none(ffi::g_tls_client_connection_get_server_identity(self.to_glib_none().0)) | ||
} | ||
} | ||
|
||
fn get_use_ssl3(&self) -> bool { | ||
unsafe { | ||
from_glib(ffi::g_tls_client_connection_get_use_ssl3(self.to_glib_none().0)) | ||
} | ||
} | ||
|
||
fn get_validation_flags(&self) -> TlsCertificateFlags { | ||
unsafe { | ||
from_glib(ffi::g_tls_client_connection_get_validation_flags(self.to_glib_none().0)) | ||
} | ||
} | ||
|
||
fn set_server_identity<P: IsA<SocketConnectable>>(&self, identity: &P) { | ||
unsafe { | ||
ffi::g_tls_client_connection_set_server_identity(self.to_glib_none().0, identity.to_glib_none().0); | ||
} | ||
} | ||
|
||
fn set_use_ssl3(&self, use_ssl3: bool) { | ||
unsafe { | ||
ffi::g_tls_client_connection_set_use_ssl3(self.to_glib_none().0, use_ssl3.to_glib()); | ||
} | ||
} | ||
|
||
fn set_validation_flags(&self, flags: TlsCertificateFlags) { | ||
unsafe { | ||
ffi::g_tls_client_connection_set_validation_flags(self.to_glib_none().0, flags.to_glib()); | ||
} | ||
} | ||
|
||
fn connect_property_accepted_cas_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { | ||
unsafe { | ||
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f)); | ||
connect(self.to_glib_none().0, "notify::accepted-cas", | ||
transmute(notify_accepted_cas_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _) | ||
} | ||
} | ||
|
||
fn connect_property_server_identity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { | ||
unsafe { | ||
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f)); | ||
connect(self.to_glib_none().0, "notify::server-identity", | ||
transmute(notify_server_identity_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _) | ||
} | ||
} | ||
|
||
fn connect_property_use_ssl3_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { | ||
unsafe { | ||
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f)); | ||
connect(self.to_glib_none().0, "notify::use-ssl3", | ||
transmute(notify_use_ssl3_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _) | ||
} | ||
} | ||
|
||
fn connect_property_validation_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { | ||
unsafe { | ||
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f)); | ||
connect(self.to_glib_none().0, "notify::validation-flags", | ||
transmute(notify_validation_flags_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _) | ||
} | ||
} | ||
} | ||
|
||
unsafe extern "C" fn notify_accepted_cas_trampoline<P>(this: *mut ffi::GTlsClientConnection, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) | ||
where P: IsA<TlsClientConnection> { | ||
let f: &&(Fn(&P) + 'static) = transmute(f); | ||
f(&TlsClientConnection::from_glib_borrow(this).downcast_unchecked()) | ||
} | ||
|
||
unsafe extern "C" fn notify_server_identity_trampoline<P>(this: *mut ffi::GTlsClientConnection, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) | ||
where P: IsA<TlsClientConnection> { | ||
let f: &&(Fn(&P) + 'static) = transmute(f); | ||
f(&TlsClientConnection::from_glib_borrow(this).downcast_unchecked()) | ||
} | ||
|
||
unsafe extern "C" fn notify_use_ssl3_trampoline<P>(this: *mut ffi::GTlsClientConnection, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) | ||
where P: IsA<TlsClientConnection> { | ||
let f: &&(Fn(&P) + 'static) = transmute(f); | ||
f(&TlsClientConnection::from_glib_borrow(this).downcast_unchecked()) | ||
} | ||
|
||
unsafe extern "C" fn notify_validation_flags_trampoline<P>(this: *mut ffi::GTlsClientConnection, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) | ||
where P: IsA<TlsClientConnection> { | ||
let f: &&(Fn(&P) + 'static) = transmute(f); | ||
f(&TlsClientConnection::from_glib_borrow(this).downcast_unchecked()) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another byte array instead of GBytes, how weird