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