1#![allow(deprecated)]
5
6#[cfg(feature = "v2_70")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
8use crate::TlsProtocolVersion;
9use crate::{
10 ffi, AsyncResult, Cancellable, DatagramBased, TlsCertificate, TlsCertificateFlags, TlsDatabase,
11 TlsInteraction, TlsRehandshakeMode,
12};
13use glib::{
14 object::ObjectType as _,
15 prelude::*,
16 signal::{connect_raw, SignalHandlerId},
17 translate::*,
18};
19use std::{boxed::Box as Box_, pin::Pin};
20
21glib::wrapper! {
22 #[doc(alias = "GDtlsConnection")]
23 pub struct DtlsConnection(Interface<ffi::GDtlsConnection, ffi::GDtlsConnectionInterface>) @requires DatagramBased;
24
25 match fn {
26 type_ => || ffi::g_dtls_connection_get_type(),
27 }
28}
29
30impl DtlsConnection {
31 pub const NONE: Option<&'static DtlsConnection> = None;
32}
33
34mod sealed {
35 pub trait Sealed {}
36 impl<T: super::IsA<super::DtlsConnection>> Sealed for T {}
37}
38
39pub trait DtlsConnectionExt: IsA<DtlsConnection> + sealed::Sealed + 'static {
40 #[doc(alias = "g_dtls_connection_close")]
41 fn close(&self, cancellable: Option<&impl IsA<Cancellable>>) -> Result<(), glib::Error> {
42 unsafe {
43 let mut error = std::ptr::null_mut();
44 let is_ok = ffi::g_dtls_connection_close(
45 self.as_ref().to_glib_none().0,
46 cancellable.map(|p| p.as_ref()).to_glib_none().0,
47 &mut error,
48 );
49 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
50 if error.is_null() {
51 Ok(())
52 } else {
53 Err(from_glib_full(error))
54 }
55 }
56 }
57
58 #[doc(alias = "g_dtls_connection_close_async")]
59 fn close_async<P: FnOnce(Result<(), glib::Error>) + 'static>(
60 &self,
61 io_priority: glib::Priority,
62 cancellable: Option<&impl IsA<Cancellable>>,
63 callback: P,
64 ) {
65 let main_context = glib::MainContext::ref_thread_default();
66 let is_main_context_owner = main_context.is_owner();
67 let has_acquired_main_context = (!is_main_context_owner)
68 .then(|| main_context.acquire().ok())
69 .flatten();
70 assert!(
71 is_main_context_owner || has_acquired_main_context.is_some(),
72 "Async operations only allowed if the thread is owning the MainContext"
73 );
74
75 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
76 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
77 unsafe extern "C" fn close_async_trampoline<
78 P: FnOnce(Result<(), glib::Error>) + 'static,
79 >(
80 _source_object: *mut glib::gobject_ffi::GObject,
81 res: *mut crate::ffi::GAsyncResult,
82 user_data: glib::ffi::gpointer,
83 ) {
84 let mut error = std::ptr::null_mut();
85 ffi::g_dtls_connection_close_finish(_source_object as *mut _, res, &mut error);
86 let result = if error.is_null() {
87 Ok(())
88 } else {
89 Err(from_glib_full(error))
90 };
91 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
92 Box_::from_raw(user_data as *mut _);
93 let callback: P = callback.into_inner();
94 callback(result);
95 }
96 let callback = close_async_trampoline::<P>;
97 unsafe {
98 ffi::g_dtls_connection_close_async(
99 self.as_ref().to_glib_none().0,
100 io_priority.into_glib(),
101 cancellable.map(|p| p.as_ref()).to_glib_none().0,
102 Some(callback),
103 Box_::into_raw(user_data) as *mut _,
104 );
105 }
106 }
107
108 fn close_future(
109 &self,
110 io_priority: glib::Priority,
111 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
112 Box_::pin(crate::GioFuture::new(
113 self,
114 move |obj, cancellable, send| {
115 obj.close_async(io_priority, Some(cancellable), move |res| {
116 send.resolve(res);
117 });
118 },
119 ))
120 }
121
122 #[doc(alias = "g_dtls_connection_emit_accept_certificate")]
123 fn emit_accept_certificate(
124 &self,
125 peer_cert: &impl IsA<TlsCertificate>,
126 errors: TlsCertificateFlags,
127 ) -> bool {
128 unsafe {
129 from_glib(ffi::g_dtls_connection_emit_accept_certificate(
130 self.as_ref().to_glib_none().0,
131 peer_cert.as_ref().to_glib_none().0,
132 errors.into_glib(),
133 ))
134 }
135 }
136
137 #[doc(alias = "g_dtls_connection_get_certificate")]
138 #[doc(alias = "get_certificate")]
139 fn certificate(&self) -> Option<TlsCertificate> {
140 unsafe {
141 from_glib_none(ffi::g_dtls_connection_get_certificate(
142 self.as_ref().to_glib_none().0,
143 ))
144 }
145 }
146
147 #[cfg(feature = "v2_70")]
148 #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
149 #[doc(alias = "g_dtls_connection_get_ciphersuite_name")]
150 #[doc(alias = "get_ciphersuite_name")]
151 #[doc(alias = "ciphersuite-name")]
152 fn ciphersuite_name(&self) -> Option<glib::GString> {
153 unsafe {
154 from_glib_full(ffi::g_dtls_connection_get_ciphersuite_name(
155 self.as_ref().to_glib_none().0,
156 ))
157 }
158 }
159
160 #[doc(alias = "g_dtls_connection_get_database")]
161 #[doc(alias = "get_database")]
162 fn database(&self) -> Option<TlsDatabase> {
163 unsafe {
164 from_glib_none(ffi::g_dtls_connection_get_database(
165 self.as_ref().to_glib_none().0,
166 ))
167 }
168 }
169
170 #[doc(alias = "g_dtls_connection_get_interaction")]
171 #[doc(alias = "get_interaction")]
172 fn interaction(&self) -> Option<TlsInteraction> {
173 unsafe {
174 from_glib_none(ffi::g_dtls_connection_get_interaction(
175 self.as_ref().to_glib_none().0,
176 ))
177 }
178 }
179
180 #[cfg(feature = "v2_60")]
181 #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
182 #[doc(alias = "g_dtls_connection_get_negotiated_protocol")]
183 #[doc(alias = "get_negotiated_protocol")]
184 #[doc(alias = "negotiated-protocol")]
185 fn negotiated_protocol(&self) -> Option<glib::GString> {
186 unsafe {
187 from_glib_none(ffi::g_dtls_connection_get_negotiated_protocol(
188 self.as_ref().to_glib_none().0,
189 ))
190 }
191 }
192
193 #[doc(alias = "g_dtls_connection_get_peer_certificate")]
194 #[doc(alias = "get_peer_certificate")]
195 #[doc(alias = "peer-certificate")]
196 fn peer_certificate(&self) -> Option<TlsCertificate> {
197 unsafe {
198 from_glib_none(ffi::g_dtls_connection_get_peer_certificate(
199 self.as_ref().to_glib_none().0,
200 ))
201 }
202 }
203
204 #[doc(alias = "g_dtls_connection_get_peer_certificate_errors")]
205 #[doc(alias = "get_peer_certificate_errors")]
206 #[doc(alias = "peer-certificate-errors")]
207 fn peer_certificate_errors(&self) -> TlsCertificateFlags {
208 unsafe {
209 from_glib(ffi::g_dtls_connection_get_peer_certificate_errors(
210 self.as_ref().to_glib_none().0,
211 ))
212 }
213 }
214
215 #[cfg(feature = "v2_70")]
216 #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
217 #[doc(alias = "g_dtls_connection_get_protocol_version")]
218 #[doc(alias = "get_protocol_version")]
219 #[doc(alias = "protocol-version")]
220 fn protocol_version(&self) -> TlsProtocolVersion {
221 unsafe {
222 from_glib(ffi::g_dtls_connection_get_protocol_version(
223 self.as_ref().to_glib_none().0,
224 ))
225 }
226 }
227
228 #[cfg_attr(feature = "v2_64", deprecated = "Since 2.64")]
229 #[allow(deprecated)]
230 #[doc(alias = "g_dtls_connection_get_rehandshake_mode")]
231 #[doc(alias = "get_rehandshake_mode")]
232 #[doc(alias = "rehandshake-mode")]
233 fn rehandshake_mode(&self) -> TlsRehandshakeMode {
234 unsafe {
235 from_glib(ffi::g_dtls_connection_get_rehandshake_mode(
236 self.as_ref().to_glib_none().0,
237 ))
238 }
239 }
240
241 #[doc(alias = "g_dtls_connection_get_require_close_notify")]
242 #[doc(alias = "get_require_close_notify")]
243 #[doc(alias = "require-close-notify")]
244 fn requires_close_notify(&self) -> bool {
245 unsafe {
246 from_glib(ffi::g_dtls_connection_get_require_close_notify(
247 self.as_ref().to_glib_none().0,
248 ))
249 }
250 }
251
252 #[doc(alias = "g_dtls_connection_handshake")]
253 fn handshake(&self, cancellable: Option<&impl IsA<Cancellable>>) -> Result<(), glib::Error> {
254 unsafe {
255 let mut error = std::ptr::null_mut();
256 let is_ok = ffi::g_dtls_connection_handshake(
257 self.as_ref().to_glib_none().0,
258 cancellable.map(|p| p.as_ref()).to_glib_none().0,
259 &mut error,
260 );
261 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
262 if error.is_null() {
263 Ok(())
264 } else {
265 Err(from_glib_full(error))
266 }
267 }
268 }
269
270 #[doc(alias = "g_dtls_connection_handshake_async")]
271 fn handshake_async<P: FnOnce(Result<(), glib::Error>) + 'static>(
272 &self,
273 io_priority: glib::Priority,
274 cancellable: Option<&impl IsA<Cancellable>>,
275 callback: P,
276 ) {
277 let main_context = glib::MainContext::ref_thread_default();
278 let is_main_context_owner = main_context.is_owner();
279 let has_acquired_main_context = (!is_main_context_owner)
280 .then(|| main_context.acquire().ok())
281 .flatten();
282 assert!(
283 is_main_context_owner || has_acquired_main_context.is_some(),
284 "Async operations only allowed if the thread is owning the MainContext"
285 );
286
287 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
288 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
289 unsafe extern "C" fn handshake_async_trampoline<
290 P: FnOnce(Result<(), glib::Error>) + 'static,
291 >(
292 _source_object: *mut glib::gobject_ffi::GObject,
293 res: *mut crate::ffi::GAsyncResult,
294 user_data: glib::ffi::gpointer,
295 ) {
296 let mut error = std::ptr::null_mut();
297 ffi::g_dtls_connection_handshake_finish(_source_object as *mut _, res, &mut error);
298 let result = if error.is_null() {
299 Ok(())
300 } else {
301 Err(from_glib_full(error))
302 };
303 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
304 Box_::from_raw(user_data as *mut _);
305 let callback: P = callback.into_inner();
306 callback(result);
307 }
308 let callback = handshake_async_trampoline::<P>;
309 unsafe {
310 ffi::g_dtls_connection_handshake_async(
311 self.as_ref().to_glib_none().0,
312 io_priority.into_glib(),
313 cancellable.map(|p| p.as_ref()).to_glib_none().0,
314 Some(callback),
315 Box_::into_raw(user_data) as *mut _,
316 );
317 }
318 }
319
320 fn handshake_future(
321 &self,
322 io_priority: glib::Priority,
323 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
324 Box_::pin(crate::GioFuture::new(
325 self,
326 move |obj, cancellable, send| {
327 obj.handshake_async(io_priority, Some(cancellable), move |res| {
328 send.resolve(res);
329 });
330 },
331 ))
332 }
333
334 #[cfg(feature = "v2_60")]
335 #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
336 #[doc(alias = "g_dtls_connection_set_advertised_protocols")]
337 #[doc(alias = "advertised-protocols")]
338 fn set_advertised_protocols(&self, protocols: &[&str]) {
339 unsafe {
340 ffi::g_dtls_connection_set_advertised_protocols(
341 self.as_ref().to_glib_none().0,
342 protocols.to_glib_none().0,
343 );
344 }
345 }
346
347 #[doc(alias = "g_dtls_connection_set_certificate")]
348 #[doc(alias = "certificate")]
349 fn set_certificate(&self, certificate: &impl IsA<TlsCertificate>) {
350 unsafe {
351 ffi::g_dtls_connection_set_certificate(
352 self.as_ref().to_glib_none().0,
353 certificate.as_ref().to_glib_none().0,
354 );
355 }
356 }
357
358 #[doc(alias = "g_dtls_connection_set_database")]
359 #[doc(alias = "database")]
360 fn set_database(&self, database: Option<&impl IsA<TlsDatabase>>) {
361 unsafe {
362 ffi::g_dtls_connection_set_database(
363 self.as_ref().to_glib_none().0,
364 database.map(|p| p.as_ref()).to_glib_none().0,
365 );
366 }
367 }
368
369 #[doc(alias = "g_dtls_connection_set_interaction")]
370 #[doc(alias = "interaction")]
371 fn set_interaction(&self, interaction: Option<&impl IsA<TlsInteraction>>) {
372 unsafe {
373 ffi::g_dtls_connection_set_interaction(
374 self.as_ref().to_glib_none().0,
375 interaction.map(|p| p.as_ref()).to_glib_none().0,
376 );
377 }
378 }
379
380 #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")]
381 #[allow(deprecated)]
382 #[doc(alias = "g_dtls_connection_set_rehandshake_mode")]
383 #[doc(alias = "rehandshake-mode")]
384 fn set_rehandshake_mode(&self, mode: TlsRehandshakeMode) {
385 unsafe {
386 ffi::g_dtls_connection_set_rehandshake_mode(
387 self.as_ref().to_glib_none().0,
388 mode.into_glib(),
389 );
390 }
391 }
392
393 #[doc(alias = "g_dtls_connection_set_require_close_notify")]
394 #[doc(alias = "require-close-notify")]
395 fn set_require_close_notify(&self, require_close_notify: bool) {
396 unsafe {
397 ffi::g_dtls_connection_set_require_close_notify(
398 self.as_ref().to_glib_none().0,
399 require_close_notify.into_glib(),
400 );
401 }
402 }
403
404 #[doc(alias = "g_dtls_connection_shutdown")]
405 fn shutdown(
406 &self,
407 shutdown_read: bool,
408 shutdown_write: bool,
409 cancellable: Option<&impl IsA<Cancellable>>,
410 ) -> Result<(), glib::Error> {
411 unsafe {
412 let mut error = std::ptr::null_mut();
413 let is_ok = ffi::g_dtls_connection_shutdown(
414 self.as_ref().to_glib_none().0,
415 shutdown_read.into_glib(),
416 shutdown_write.into_glib(),
417 cancellable.map(|p| p.as_ref()).to_glib_none().0,
418 &mut error,
419 );
420 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
421 if error.is_null() {
422 Ok(())
423 } else {
424 Err(from_glib_full(error))
425 }
426 }
427 }
428
429 #[doc(alias = "g_dtls_connection_shutdown_async")]
430 fn shutdown_async<P: FnOnce(Result<(), glib::Error>) + 'static>(
431 &self,
432 shutdown_read: bool,
433 shutdown_write: bool,
434 io_priority: glib::Priority,
435 cancellable: Option<&impl IsA<Cancellable>>,
436 callback: P,
437 ) {
438 let main_context = glib::MainContext::ref_thread_default();
439 let is_main_context_owner = main_context.is_owner();
440 let has_acquired_main_context = (!is_main_context_owner)
441 .then(|| main_context.acquire().ok())
442 .flatten();
443 assert!(
444 is_main_context_owner || has_acquired_main_context.is_some(),
445 "Async operations only allowed if the thread is owning the MainContext"
446 );
447
448 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
449 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
450 unsafe extern "C" fn shutdown_async_trampoline<
451 P: FnOnce(Result<(), glib::Error>) + 'static,
452 >(
453 _source_object: *mut glib::gobject_ffi::GObject,
454 res: *mut crate::ffi::GAsyncResult,
455 user_data: glib::ffi::gpointer,
456 ) {
457 let mut error = std::ptr::null_mut();
458 ffi::g_dtls_connection_shutdown_finish(_source_object as *mut _, res, &mut error);
459 let result = if error.is_null() {
460 Ok(())
461 } else {
462 Err(from_glib_full(error))
463 };
464 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
465 Box_::from_raw(user_data as *mut _);
466 let callback: P = callback.into_inner();
467 callback(result);
468 }
469 let callback = shutdown_async_trampoline::<P>;
470 unsafe {
471 ffi::g_dtls_connection_shutdown_async(
472 self.as_ref().to_glib_none().0,
473 shutdown_read.into_glib(),
474 shutdown_write.into_glib(),
475 io_priority.into_glib(),
476 cancellable.map(|p| p.as_ref()).to_glib_none().0,
477 Some(callback),
478 Box_::into_raw(user_data) as *mut _,
479 );
480 }
481 }
482
483 fn shutdown_future(
484 &self,
485 shutdown_read: bool,
486 shutdown_write: bool,
487 io_priority: glib::Priority,
488 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
489 Box_::pin(crate::GioFuture::new(
490 self,
491 move |obj, cancellable, send| {
492 obj.shutdown_async(
493 shutdown_read,
494 shutdown_write,
495 io_priority,
496 Some(cancellable),
497 move |res| {
498 send.resolve(res);
499 },
500 );
501 },
502 ))
503 }
504
505 #[cfg(feature = "v2_60")]
506 #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
507 #[doc(alias = "advertised-protocols")]
508 fn advertised_protocols(&self) -> Vec<glib::GString> {
509 ObjectExt::property(self.as_ref(), "advertised-protocols")
510 }
511
512 #[doc(alias = "base-socket")]
513 fn base_socket(&self) -> Option<DatagramBased> {
514 ObjectExt::property(self.as_ref(), "base-socket")
515 }
516
517 #[doc(alias = "accept-certificate")]
518 fn connect_accept_certificate<
519 F: Fn(&Self, &TlsCertificate, TlsCertificateFlags) -> bool + 'static,
520 >(
521 &self,
522 f: F,
523 ) -> SignalHandlerId {
524 unsafe extern "C" fn accept_certificate_trampoline<
525 P: IsA<DtlsConnection>,
526 F: Fn(&P, &TlsCertificate, TlsCertificateFlags) -> bool + 'static,
527 >(
528 this: *mut ffi::GDtlsConnection,
529 peer_cert: *mut ffi::GTlsCertificate,
530 errors: ffi::GTlsCertificateFlags,
531 f: glib::ffi::gpointer,
532 ) -> glib::ffi::gboolean {
533 let f: &F = &*(f as *const F);
534 f(
535 DtlsConnection::from_glib_borrow(this).unsafe_cast_ref(),
536 &from_glib_borrow(peer_cert),
537 from_glib(errors),
538 )
539 .into_glib()
540 }
541 unsafe {
542 let f: Box_<F> = Box_::new(f);
543 connect_raw(
544 self.as_ptr() as *mut _,
545 b"accept-certificate\0".as_ptr() as *const _,
546 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
547 accept_certificate_trampoline::<Self, F> as *const (),
548 )),
549 Box_::into_raw(f),
550 )
551 }
552 }
553
554 #[cfg(feature = "v2_60")]
555 #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
556 #[doc(alias = "advertised-protocols")]
557 fn connect_advertised_protocols_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
558 unsafe extern "C" fn notify_advertised_protocols_trampoline<
559 P: IsA<DtlsConnection>,
560 F: Fn(&P) + 'static,
561 >(
562 this: *mut ffi::GDtlsConnection,
563 _param_spec: glib::ffi::gpointer,
564 f: glib::ffi::gpointer,
565 ) {
566 let f: &F = &*(f as *const F);
567 f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref())
568 }
569 unsafe {
570 let f: Box_<F> = Box_::new(f);
571 connect_raw(
572 self.as_ptr() as *mut _,
573 b"notify::advertised-protocols\0".as_ptr() as *const _,
574 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
575 notify_advertised_protocols_trampoline::<Self, F> as *const (),
576 )),
577 Box_::into_raw(f),
578 )
579 }
580 }
581
582 #[doc(alias = "certificate")]
583 fn connect_certificate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
584 unsafe extern "C" fn notify_certificate_trampoline<
585 P: IsA<DtlsConnection>,
586 F: Fn(&P) + 'static,
587 >(
588 this: *mut ffi::GDtlsConnection,
589 _param_spec: glib::ffi::gpointer,
590 f: glib::ffi::gpointer,
591 ) {
592 let f: &F = &*(f as *const F);
593 f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref())
594 }
595 unsafe {
596 let f: Box_<F> = Box_::new(f);
597 connect_raw(
598 self.as_ptr() as *mut _,
599 b"notify::certificate\0".as_ptr() as *const _,
600 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
601 notify_certificate_trampoline::<Self, F> as *const (),
602 )),
603 Box_::into_raw(f),
604 )
605 }
606 }
607
608 #[cfg(feature = "v2_70")]
609 #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
610 #[doc(alias = "ciphersuite-name")]
611 fn connect_ciphersuite_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
612 unsafe extern "C" fn notify_ciphersuite_name_trampoline<
613 P: IsA<DtlsConnection>,
614 F: Fn(&P) + 'static,
615 >(
616 this: *mut ffi::GDtlsConnection,
617 _param_spec: glib::ffi::gpointer,
618 f: glib::ffi::gpointer,
619 ) {
620 let f: &F = &*(f as *const F);
621 f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref())
622 }
623 unsafe {
624 let f: Box_<F> = Box_::new(f);
625 connect_raw(
626 self.as_ptr() as *mut _,
627 b"notify::ciphersuite-name\0".as_ptr() as *const _,
628 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
629 notify_ciphersuite_name_trampoline::<Self, F> as *const (),
630 )),
631 Box_::into_raw(f),
632 )
633 }
634 }
635
636 #[doc(alias = "database")]
637 fn connect_database_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
638 unsafe extern "C" fn notify_database_trampoline<
639 P: IsA<DtlsConnection>,
640 F: Fn(&P) + 'static,
641 >(
642 this: *mut ffi::GDtlsConnection,
643 _param_spec: glib::ffi::gpointer,
644 f: glib::ffi::gpointer,
645 ) {
646 let f: &F = &*(f as *const F);
647 f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref())
648 }
649 unsafe {
650 let f: Box_<F> = Box_::new(f);
651 connect_raw(
652 self.as_ptr() as *mut _,
653 b"notify::database\0".as_ptr() as *const _,
654 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
655 notify_database_trampoline::<Self, F> as *const (),
656 )),
657 Box_::into_raw(f),
658 )
659 }
660 }
661
662 #[doc(alias = "interaction")]
663 fn connect_interaction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
664 unsafe extern "C" fn notify_interaction_trampoline<
665 P: IsA<DtlsConnection>,
666 F: Fn(&P) + 'static,
667 >(
668 this: *mut ffi::GDtlsConnection,
669 _param_spec: glib::ffi::gpointer,
670 f: glib::ffi::gpointer,
671 ) {
672 let f: &F = &*(f as *const F);
673 f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref())
674 }
675 unsafe {
676 let f: Box_<F> = Box_::new(f);
677 connect_raw(
678 self.as_ptr() as *mut _,
679 b"notify::interaction\0".as_ptr() as *const _,
680 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
681 notify_interaction_trampoline::<Self, F> as *const (),
682 )),
683 Box_::into_raw(f),
684 )
685 }
686 }
687
688 #[cfg(feature = "v2_60")]
689 #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
690 #[doc(alias = "negotiated-protocol")]
691 fn connect_negotiated_protocol_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
692 unsafe extern "C" fn notify_negotiated_protocol_trampoline<
693 P: IsA<DtlsConnection>,
694 F: Fn(&P) + 'static,
695 >(
696 this: *mut ffi::GDtlsConnection,
697 _param_spec: glib::ffi::gpointer,
698 f: glib::ffi::gpointer,
699 ) {
700 let f: &F = &*(f as *const F);
701 f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref())
702 }
703 unsafe {
704 let f: Box_<F> = Box_::new(f);
705 connect_raw(
706 self.as_ptr() as *mut _,
707 b"notify::negotiated-protocol\0".as_ptr() as *const _,
708 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
709 notify_negotiated_protocol_trampoline::<Self, F> as *const (),
710 )),
711 Box_::into_raw(f),
712 )
713 }
714 }
715
716 #[doc(alias = "peer-certificate")]
717 fn connect_peer_certificate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
718 unsafe extern "C" fn notify_peer_certificate_trampoline<
719 P: IsA<DtlsConnection>,
720 F: Fn(&P) + 'static,
721 >(
722 this: *mut ffi::GDtlsConnection,
723 _param_spec: glib::ffi::gpointer,
724 f: glib::ffi::gpointer,
725 ) {
726 let f: &F = &*(f as *const F);
727 f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref())
728 }
729 unsafe {
730 let f: Box_<F> = Box_::new(f);
731 connect_raw(
732 self.as_ptr() as *mut _,
733 b"notify::peer-certificate\0".as_ptr() as *const _,
734 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
735 notify_peer_certificate_trampoline::<Self, F> as *const (),
736 )),
737 Box_::into_raw(f),
738 )
739 }
740 }
741
742 #[doc(alias = "peer-certificate-errors")]
743 fn connect_peer_certificate_errors_notify<F: Fn(&Self) + 'static>(
744 &self,
745 f: F,
746 ) -> SignalHandlerId {
747 unsafe extern "C" fn notify_peer_certificate_errors_trampoline<
748 P: IsA<DtlsConnection>,
749 F: Fn(&P) + 'static,
750 >(
751 this: *mut ffi::GDtlsConnection,
752 _param_spec: glib::ffi::gpointer,
753 f: glib::ffi::gpointer,
754 ) {
755 let f: &F = &*(f as *const F);
756 f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref())
757 }
758 unsafe {
759 let f: Box_<F> = Box_::new(f);
760 connect_raw(
761 self.as_ptr() as *mut _,
762 b"notify::peer-certificate-errors\0".as_ptr() as *const _,
763 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
764 notify_peer_certificate_errors_trampoline::<Self, F> as *const (),
765 )),
766 Box_::into_raw(f),
767 )
768 }
769 }
770
771 #[cfg(feature = "v2_70")]
772 #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
773 #[doc(alias = "protocol-version")]
774 fn connect_protocol_version_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
775 unsafe extern "C" fn notify_protocol_version_trampoline<
776 P: IsA<DtlsConnection>,
777 F: Fn(&P) + 'static,
778 >(
779 this: *mut ffi::GDtlsConnection,
780 _param_spec: glib::ffi::gpointer,
781 f: glib::ffi::gpointer,
782 ) {
783 let f: &F = &*(f as *const F);
784 f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref())
785 }
786 unsafe {
787 let f: Box_<F> = Box_::new(f);
788 connect_raw(
789 self.as_ptr() as *mut _,
790 b"notify::protocol-version\0".as_ptr() as *const _,
791 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
792 notify_protocol_version_trampoline::<Self, F> as *const (),
793 )),
794 Box_::into_raw(f),
795 )
796 }
797 }
798
799 #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")]
800 #[doc(alias = "rehandshake-mode")]
801 fn connect_rehandshake_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
802 unsafe extern "C" fn notify_rehandshake_mode_trampoline<
803 P: IsA<DtlsConnection>,
804 F: Fn(&P) + 'static,
805 >(
806 this: *mut ffi::GDtlsConnection,
807 _param_spec: glib::ffi::gpointer,
808 f: glib::ffi::gpointer,
809 ) {
810 let f: &F = &*(f as *const F);
811 f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref())
812 }
813 unsafe {
814 let f: Box_<F> = Box_::new(f);
815 connect_raw(
816 self.as_ptr() as *mut _,
817 b"notify::rehandshake-mode\0".as_ptr() as *const _,
818 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
819 notify_rehandshake_mode_trampoline::<Self, F> as *const (),
820 )),
821 Box_::into_raw(f),
822 )
823 }
824 }
825
826 #[doc(alias = "require-close-notify")]
827 fn connect_require_close_notify_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
828 unsafe extern "C" fn notify_require_close_notify_trampoline<
829 P: IsA<DtlsConnection>,
830 F: Fn(&P) + 'static,
831 >(
832 this: *mut ffi::GDtlsConnection,
833 _param_spec: glib::ffi::gpointer,
834 f: glib::ffi::gpointer,
835 ) {
836 let f: &F = &*(f as *const F);
837 f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref())
838 }
839 unsafe {
840 let f: Box_<F> = Box_::new(f);
841 connect_raw(
842 self.as_ptr() as *mut _,
843 b"notify::require-close-notify\0".as_ptr() as *const _,
844 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
845 notify_require_close_notify_trampoline::<Self, F> as *const (),
846 )),
847 Box_::into_raw(f),
848 )
849 }
850 }
851}
852
853impl<O: IsA<DtlsConnection>> DtlsConnectionExt for O {}