1#![allow(deprecated)]
6
7#[cfg(feature = "v1_6")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
9use crate::DnsEntry;
10#[cfg(feature = "v1_38")]
11#[cfg_attr(docsrs, doc(cfg(feature = "v1_38")))]
12use crate::RadioFlags;
13use crate::{
14 ActiveConnection, ClientPermission, ClientPermissionResult, Connection, ConnectivityState,
15 Device, RemoteConnection, State, ffi,
16};
17#[cfg(feature = "v1_12")]
18#[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
19use crate::{Checkpoint, CheckpointCreateFlags};
20#[cfg(feature = "v1_24")]
21#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
22use crate::{ClientInstanceFlags, Object, Ternary};
23#[cfg(feature = "v1_22")]
24#[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
25use crate::{ManagerReloadFlags, Metered};
26use glib::{
27 GString,
28 object::ObjectType as _,
29 prelude::*,
30 signal::{SignalHandlerId, connect_raw},
31 translate::*,
32};
33use std::{boxed::Box as Box_, pin::Pin};
34
35#[cfg(feature = "gio_v2_22")]
36#[cfg_attr(docsrs, doc(cfg(feature = "gio_v2_22")))]
37glib::wrapper! {
38 #[doc(alias = "NMClient")]
360 pub struct Client(Object<ffi::NMClient, ffi::NMClientClass>) @implements gio::AsyncInitable, gio::Initable;
361
362 match fn {
363 type_ => || ffi::nm_client_get_type(),
364 }
365}
366
367#[cfg(not(any(feature = "gio_v2_22")))]
368#[cfg(feature = "gio_v2_22")]
369glib::wrapper! {
370 #[doc(alias = "NMClient")]
371 pub struct Client(Object<ffi::NMClient, ffi::NMClientClass>) @implements gio::Initable;
372
373 match fn {
374 type_ => || ffi::nm_client_get_type(),
375 }
376}
377
378#[cfg(not(any(feature = "gio_v2_22")))]
379glib::wrapper! {
380 #[doc(alias = "NMClient")]
381 pub struct Client(Object<ffi::NMClient, ffi::NMClientClass>);
382
383 match fn {
384 type_ => || ffi::nm_client_get_type(),
385 }
386}
387
388impl Client {
389 #[doc(alias = "nm_client_new")]
429 pub fn new(cancellable: Option<&impl IsA<gio::Cancellable>>) -> Result<Client, glib::Error> {
430 assert_initialized_main_thread!();
431 unsafe {
432 let mut error = std::ptr::null_mut();
433 let ret =
434 ffi::nm_client_new(cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
435 if error.is_null() {
436 Ok(from_glib_full(ret))
437 } else {
438 Err(from_glib_full(error))
439 }
440 }
441 }
442
443 pub fn builder() -> ClientBuilder {
448 ClientBuilder::new()
449 }
450
451 #[doc(alias = "nm_client_activate_connection_async")]
484 pub fn activate_connection_async<P: FnOnce(Result<ActiveConnection, glib::Error>) + 'static>(
485 &self,
486 connection: Option<&impl IsA<Connection>>,
487 device: Option<&impl IsA<Device>>,
488 specific_object: Option<&str>,
489 cancellable: Option<&impl IsA<gio::Cancellable>>,
490 callback: P,
491 ) {
492 let main_context = glib::MainContext::ref_thread_default();
493 let is_main_context_owner = main_context.is_owner();
494 let has_acquired_main_context = (!is_main_context_owner)
495 .then(|| main_context.acquire().ok())
496 .flatten();
497 assert!(
498 is_main_context_owner || has_acquired_main_context.is_some(),
499 "Async operations only allowed if the thread is owning the MainContext"
500 );
501
502 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
503 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
504 unsafe extern "C" fn activate_connection_async_trampoline<
505 P: FnOnce(Result<ActiveConnection, glib::Error>) + 'static,
506 >(
507 _source_object: *mut glib::gobject_ffi::GObject,
508 res: *mut gio::ffi::GAsyncResult,
509 user_data: glib::ffi::gpointer,
510 ) {
511 let mut error = std::ptr::null_mut();
512 let ret = ffi::nm_client_activate_connection_finish(
513 _source_object as *mut _,
514 res,
515 &mut error,
516 );
517 let result = if error.is_null() {
518 Ok(from_glib_full(ret))
519 } else {
520 Err(from_glib_full(error))
521 };
522 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
523 Box_::from_raw(user_data as *mut _);
524 let callback: P = callback.into_inner();
525 callback(result);
526 }
527 let callback = activate_connection_async_trampoline::<P>;
528 unsafe {
529 ffi::nm_client_activate_connection_async(
530 self.to_glib_none().0,
531 connection.map(|p| p.as_ref()).to_glib_none().0,
532 device.map(|p| p.as_ref()).to_glib_none().0,
533 specific_object.to_glib_none().0,
534 cancellable.map(|p| p.as_ref()).to_glib_none().0,
535 Some(callback),
536 Box_::into_raw(user_data) as *mut _,
537 );
538 }
539 }
540
541 pub fn activate_connection_future(
542 &self,
543 connection: Option<&(impl IsA<Connection> + Clone + 'static)>,
544 device: Option<&(impl IsA<Device> + Clone + 'static)>,
545 specific_object: Option<&str>,
546 ) -> Pin<Box_<dyn std::future::Future<Output = Result<ActiveConnection, glib::Error>> + 'static>>
547 {
548 let connection = connection.map(ToOwned::to_owned);
549 let device = device.map(ToOwned::to_owned);
550 let specific_object = specific_object.map(ToOwned::to_owned);
551 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
552 obj.activate_connection_async(
553 connection.as_ref().map(::std::borrow::Borrow::borrow),
554 device.as_ref().map(::std::borrow::Borrow::borrow),
555 specific_object.as_ref().map(::std::borrow::Borrow::borrow),
556 Some(cancellable),
557 move |res| {
558 send.resolve(res);
559 },
560 );
561 }))
562 }
563
564 #[doc(alias = "nm_client_add_and_activate_connection_async")]
624 pub fn add_and_activate_connection_async<
625 P: FnOnce(Result<ActiveConnection, glib::Error>) + 'static,
626 >(
627 &self,
628 partial: Option<&impl IsA<Connection>>,
629 device: Option<&impl IsA<Device>>,
630 specific_object: Option<&str>,
631 cancellable: Option<&impl IsA<gio::Cancellable>>,
632 callback: P,
633 ) {
634 let main_context = glib::MainContext::ref_thread_default();
635 let is_main_context_owner = main_context.is_owner();
636 let has_acquired_main_context = (!is_main_context_owner)
637 .then(|| main_context.acquire().ok())
638 .flatten();
639 assert!(
640 is_main_context_owner || has_acquired_main_context.is_some(),
641 "Async operations only allowed if the thread is owning the MainContext"
642 );
643
644 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
645 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
646 unsafe extern "C" fn add_and_activate_connection_async_trampoline<
647 P: FnOnce(Result<ActiveConnection, glib::Error>) + 'static,
648 >(
649 _source_object: *mut glib::gobject_ffi::GObject,
650 res: *mut gio::ffi::GAsyncResult,
651 user_data: glib::ffi::gpointer,
652 ) {
653 let mut error = std::ptr::null_mut();
654 let ret = ffi::nm_client_add_and_activate_connection_finish(
655 _source_object as *mut _,
656 res,
657 &mut error,
658 );
659 let result = if error.is_null() {
660 Ok(from_glib_full(ret))
661 } else {
662 Err(from_glib_full(error))
663 };
664 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
665 Box_::from_raw(user_data as *mut _);
666 let callback: P = callback.into_inner();
667 callback(result);
668 }
669 let callback = add_and_activate_connection_async_trampoline::<P>;
670 unsafe {
671 ffi::nm_client_add_and_activate_connection_async(
672 self.to_glib_none().0,
673 partial.map(|p| p.as_ref()).to_glib_none().0,
674 device.map(|p| p.as_ref()).to_glib_none().0,
675 specific_object.to_glib_none().0,
676 cancellable.map(|p| p.as_ref()).to_glib_none().0,
677 Some(callback),
678 Box_::into_raw(user_data) as *mut _,
679 );
680 }
681 }
682
683 pub fn add_and_activate_connection_future(
684 &self,
685 partial: Option<&(impl IsA<Connection> + Clone + 'static)>,
686 device: Option<&(impl IsA<Device> + Clone + 'static)>,
687 specific_object: Option<&str>,
688 ) -> Pin<Box_<dyn std::future::Future<Output = Result<ActiveConnection, glib::Error>> + 'static>>
689 {
690 let partial = partial.map(ToOwned::to_owned);
691 let device = device.map(ToOwned::to_owned);
692 let specific_object = specific_object.map(ToOwned::to_owned);
693 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
694 obj.add_and_activate_connection_async(
695 partial.as_ref().map(::std::borrow::Borrow::borrow),
696 device.as_ref().map(::std::borrow::Borrow::borrow),
697 specific_object.as_ref().map(::std::borrow::Borrow::borrow),
698 Some(cancellable),
699 move |res| {
700 send.resolve(res);
701 },
702 );
703 }))
704 }
705
706 #[doc(alias = "nm_client_add_connection_async")]
758 pub fn add_connection_async<P: FnOnce(Result<RemoteConnection, glib::Error>) + 'static>(
759 &self,
760 connection: &impl IsA<Connection>,
761 save_to_disk: bool,
762 cancellable: Option<&impl IsA<gio::Cancellable>>,
763 callback: P,
764 ) {
765 let main_context = glib::MainContext::ref_thread_default();
766 let is_main_context_owner = main_context.is_owner();
767 let has_acquired_main_context = (!is_main_context_owner)
768 .then(|| main_context.acquire().ok())
769 .flatten();
770 assert!(
771 is_main_context_owner || has_acquired_main_context.is_some(),
772 "Async operations only allowed if the thread is owning the MainContext"
773 );
774
775 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
776 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
777 unsafe extern "C" fn add_connection_async_trampoline<
778 P: FnOnce(Result<RemoteConnection, glib::Error>) + 'static,
779 >(
780 _source_object: *mut glib::gobject_ffi::GObject,
781 res: *mut gio::ffi::GAsyncResult,
782 user_data: glib::ffi::gpointer,
783 ) {
784 let mut error = std::ptr::null_mut();
785 let ret =
786 ffi::nm_client_add_connection_finish(_source_object as *mut _, res, &mut error);
787 let result = if error.is_null() {
788 Ok(from_glib_full(ret))
789 } else {
790 Err(from_glib_full(error))
791 };
792 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
793 Box_::from_raw(user_data as *mut _);
794 let callback: P = callback.into_inner();
795 callback(result);
796 }
797 let callback = add_connection_async_trampoline::<P>;
798 unsafe {
799 ffi::nm_client_add_connection_async(
800 self.to_glib_none().0,
801 connection.as_ref().to_glib_none().0,
802 save_to_disk.into_glib(),
803 cancellable.map(|p| p.as_ref()).to_glib_none().0,
804 Some(callback),
805 Box_::into_raw(user_data) as *mut _,
806 );
807 }
808 }
809
810 pub fn add_connection_future(
811 &self,
812 connection: &(impl IsA<Connection> + Clone + 'static),
813 save_to_disk: bool,
814 ) -> Pin<Box_<dyn std::future::Future<Output = Result<RemoteConnection, glib::Error>> + 'static>>
815 {
816 let connection = connection.clone();
817 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
818 obj.add_connection_async(&connection, save_to_disk, Some(cancellable), move |res| {
819 send.resolve(res);
820 });
821 }))
822 }
823
824 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
841 #[allow(deprecated)]
842 #[doc(alias = "nm_client_check_connectivity")]
843 pub fn check_connectivity(
844 &self,
845 cancellable: Option<&impl IsA<gio::Cancellable>>,
846 ) -> Result<ConnectivityState, glib::Error> {
847 unsafe {
848 let mut error = std::ptr::null_mut();
849 let ret = ffi::nm_client_check_connectivity(
850 self.to_glib_none().0,
851 cancellable.map(|p| p.as_ref()).to_glib_none().0,
852 &mut error,
853 );
854 if error.is_null() {
855 Ok(from_glib(ret))
856 } else {
857 Err(from_glib_full(error))
858 }
859 }
860 }
861
862 #[doc(alias = "nm_client_check_connectivity_async")]
871 pub fn check_connectivity_async<P: FnOnce(Result<ConnectivityState, glib::Error>) + 'static>(
872 &self,
873 cancellable: Option<&impl IsA<gio::Cancellable>>,
874 callback: P,
875 ) {
876 let main_context = glib::MainContext::ref_thread_default();
877 let is_main_context_owner = main_context.is_owner();
878 let has_acquired_main_context = (!is_main_context_owner)
879 .then(|| main_context.acquire().ok())
880 .flatten();
881 assert!(
882 is_main_context_owner || has_acquired_main_context.is_some(),
883 "Async operations only allowed if the thread is owning the MainContext"
884 );
885
886 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
887 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
888 unsafe extern "C" fn check_connectivity_async_trampoline<
889 P: FnOnce(Result<ConnectivityState, glib::Error>) + 'static,
890 >(
891 _source_object: *mut glib::gobject_ffi::GObject,
892 res: *mut gio::ffi::GAsyncResult,
893 user_data: glib::ffi::gpointer,
894 ) {
895 let mut error = std::ptr::null_mut();
896 let ret =
897 ffi::nm_client_check_connectivity_finish(_source_object as *mut _, res, &mut error);
898 let result = if error.is_null() {
899 Ok(from_glib(ret))
900 } else {
901 Err(from_glib_full(error))
902 };
903 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
904 Box_::from_raw(user_data as *mut _);
905 let callback: P = callback.into_inner();
906 callback(result);
907 }
908 let callback = check_connectivity_async_trampoline::<P>;
909 unsafe {
910 ffi::nm_client_check_connectivity_async(
911 self.to_glib_none().0,
912 cancellable.map(|p| p.as_ref()).to_glib_none().0,
913 Some(callback),
914 Box_::into_raw(user_data) as *mut _,
915 );
916 }
917 }
918
919 pub fn check_connectivity_future(
920 &self,
921 ) -> Pin<Box_<dyn std::future::Future<Output = Result<ConnectivityState, glib::Error>> + 'static>>
922 {
923 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
924 obj.check_connectivity_async(Some(cancellable), move |res| {
925 send.resolve(res);
926 });
927 }))
928 }
929
930 #[cfg(feature = "v1_12")]
942 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
943 #[doc(alias = "nm_client_checkpoint_adjust_rollback_timeout")]
944 pub fn checkpoint_adjust_rollback_timeout<P: FnOnce(Result<(), glib::Error>) + 'static>(
945 &self,
946 checkpoint_path: &str,
947 add_timeout: u32,
948 cancellable: Option<&impl IsA<gio::Cancellable>>,
949 callback: P,
950 ) {
951 let main_context = glib::MainContext::ref_thread_default();
952 let is_main_context_owner = main_context.is_owner();
953 let has_acquired_main_context = (!is_main_context_owner)
954 .then(|| main_context.acquire().ok())
955 .flatten();
956 assert!(
957 is_main_context_owner || has_acquired_main_context.is_some(),
958 "Async operations only allowed if the thread is owning the MainContext"
959 );
960
961 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
962 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
963 unsafe extern "C" fn checkpoint_adjust_rollback_timeout_trampoline<
964 P: FnOnce(Result<(), glib::Error>) + 'static,
965 >(
966 _source_object: *mut glib::gobject_ffi::GObject,
967 res: *mut gio::ffi::GAsyncResult,
968 user_data: glib::ffi::gpointer,
969 ) {
970 let mut error = std::ptr::null_mut();
971 ffi::nm_client_checkpoint_adjust_rollback_timeout_finish(
972 _source_object as *mut _,
973 res,
974 &mut error,
975 );
976 let result = if error.is_null() {
977 Ok(())
978 } else {
979 Err(from_glib_full(error))
980 };
981 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
982 Box_::from_raw(user_data as *mut _);
983 let callback: P = callback.into_inner();
984 callback(result);
985 }
986 let callback = checkpoint_adjust_rollback_timeout_trampoline::<P>;
987 unsafe {
988 ffi::nm_client_checkpoint_adjust_rollback_timeout(
989 self.to_glib_none().0,
990 checkpoint_path.to_glib_none().0,
991 add_timeout,
992 cancellable.map(|p| p.as_ref()).to_glib_none().0,
993 Some(callback),
994 Box_::into_raw(user_data) as *mut _,
995 );
996 }
997 }
998
999 #[cfg(feature = "v1_12")]
1000 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1001 pub fn checkpoint_adjust_rollback_timeout_future(
1002 &self,
1003 checkpoint_path: &str,
1004 add_timeout: u32,
1005 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
1006 let checkpoint_path = String::from(checkpoint_path);
1007 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1008 obj.checkpoint_adjust_rollback_timeout(
1009 &checkpoint_path,
1010 add_timeout,
1011 Some(cancellable),
1012 move |res| {
1013 send.resolve(res);
1014 },
1015 );
1016 }))
1017 }
1018
1019 #[cfg(feature = "v1_12")]
1035 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1036 #[doc(alias = "nm_client_checkpoint_create")]
1037 pub fn checkpoint_create<P: FnOnce(Result<Checkpoint, glib::Error>) + 'static>(
1038 &self,
1039 devices: &[Device],
1040 rollback_timeout: u32,
1041 flags: CheckpointCreateFlags,
1042 cancellable: Option<&impl IsA<gio::Cancellable>>,
1043 callback: P,
1044 ) {
1045 let main_context = glib::MainContext::ref_thread_default();
1046 let is_main_context_owner = main_context.is_owner();
1047 let has_acquired_main_context = (!is_main_context_owner)
1048 .then(|| main_context.acquire().ok())
1049 .flatten();
1050 assert!(
1051 is_main_context_owner || has_acquired_main_context.is_some(),
1052 "Async operations only allowed if the thread is owning the MainContext"
1053 );
1054
1055 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1056 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1057 unsafe extern "C" fn checkpoint_create_trampoline<
1058 P: FnOnce(Result<Checkpoint, glib::Error>) + 'static,
1059 >(
1060 _source_object: *mut glib::gobject_ffi::GObject,
1061 res: *mut gio::ffi::GAsyncResult,
1062 user_data: glib::ffi::gpointer,
1063 ) {
1064 let mut error = std::ptr::null_mut();
1065 let ret =
1066 ffi::nm_client_checkpoint_create_finish(_source_object as *mut _, res, &mut error);
1067 let result = if error.is_null() {
1068 Ok(from_glib_full(ret))
1069 } else {
1070 Err(from_glib_full(error))
1071 };
1072 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
1073 Box_::from_raw(user_data as *mut _);
1074 let callback: P = callback.into_inner();
1075 callback(result);
1076 }
1077 let callback = checkpoint_create_trampoline::<P>;
1078 unsafe {
1079 ffi::nm_client_checkpoint_create(
1080 self.to_glib_none().0,
1081 devices.to_glib_none().0,
1082 rollback_timeout,
1083 flags.into_glib(),
1084 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1085 Some(callback),
1086 Box_::into_raw(user_data) as *mut _,
1087 );
1088 }
1089 }
1090
1091 #[cfg(feature = "v1_12")]
1092 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1093 pub fn checkpoint_create_future(
1094 &self,
1095 devices: &[Device],
1096 rollback_timeout: u32,
1097 flags: CheckpointCreateFlags,
1098 ) -> Pin<Box_<dyn std::future::Future<Output = Result<Checkpoint, glib::Error>> + 'static>>
1099 {
1100 let devices = devices.to_vec();
1101 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1102 obj.checkpoint_create(
1103 devices.as_slice(),
1104 rollback_timeout,
1105 flags,
1106 Some(cancellable),
1107 move |res| {
1108 send.resolve(res);
1109 },
1110 );
1111 }))
1112 }
1113
1114 #[cfg(feature = "v1_12")]
1115 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1116 #[doc(alias = "nm_client_checkpoint_destroy")]
1117 pub fn checkpoint_destroy<P: FnOnce(Result<(), glib::Error>) + 'static>(
1118 &self,
1119 checkpoint_path: &str,
1120 cancellable: Option<&impl IsA<gio::Cancellable>>,
1121 callback: P,
1122 ) {
1123 let main_context = glib::MainContext::ref_thread_default();
1124 let is_main_context_owner = main_context.is_owner();
1125 let has_acquired_main_context = (!is_main_context_owner)
1126 .then(|| main_context.acquire().ok())
1127 .flatten();
1128 assert!(
1129 is_main_context_owner || has_acquired_main_context.is_some(),
1130 "Async operations only allowed if the thread is owning the MainContext"
1131 );
1132
1133 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1134 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1135 unsafe extern "C" fn checkpoint_destroy_trampoline<
1136 P: FnOnce(Result<(), glib::Error>) + 'static,
1137 >(
1138 _source_object: *mut glib::gobject_ffi::GObject,
1139 res: *mut gio::ffi::GAsyncResult,
1140 user_data: glib::ffi::gpointer,
1141 ) {
1142 let mut error = std::ptr::null_mut();
1143 ffi::nm_client_checkpoint_destroy_finish(_source_object as *mut _, res, &mut error);
1144 let result = if error.is_null() {
1145 Ok(())
1146 } else {
1147 Err(from_glib_full(error))
1148 };
1149 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
1150 Box_::from_raw(user_data as *mut _);
1151 let callback: P = callback.into_inner();
1152 callback(result);
1153 }
1154 let callback = checkpoint_destroy_trampoline::<P>;
1155 unsafe {
1156 ffi::nm_client_checkpoint_destroy(
1157 self.to_glib_none().0,
1158 checkpoint_path.to_glib_none().0,
1159 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1160 Some(callback),
1161 Box_::into_raw(user_data) as *mut _,
1162 );
1163 }
1164 }
1165
1166 #[cfg(feature = "v1_12")]
1167 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1168 pub fn checkpoint_destroy_future(
1169 &self,
1170 checkpoint_path: &str,
1171 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
1172 let checkpoint_path = String::from(checkpoint_path);
1173 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1174 obj.checkpoint_destroy(&checkpoint_path, Some(cancellable), move |res| {
1175 send.resolve(res);
1176 });
1177 }))
1178 }
1179
1180 #[cfg(feature = "v1_10")]
1212 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
1213 #[doc(alias = "nm_client_connectivity_check_get_available")]
1214 pub fn connectivity_check_get_available(&self) -> bool {
1215 unsafe {
1216 from_glib(ffi::nm_client_connectivity_check_get_available(
1217 self.to_glib_none().0,
1218 ))
1219 }
1220 }
1221
1222 #[cfg(feature = "v1_10")]
1228 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
1229 #[doc(alias = "nm_client_connectivity_check_get_enabled")]
1230 pub fn connectivity_check_get_enabled(&self) -> bool {
1231 unsafe {
1232 from_glib(ffi::nm_client_connectivity_check_get_enabled(
1233 self.to_glib_none().0,
1234 ))
1235 }
1236 }
1237
1238 #[cfg(feature = "v1_20")]
1245 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
1246 #[doc(alias = "nm_client_connectivity_check_get_uri")]
1247 pub fn connectivity_check_get_uri(&self) -> glib::GString {
1248 unsafe {
1249 from_glib_none(ffi::nm_client_connectivity_check_get_uri(
1250 self.to_glib_none().0,
1251 ))
1252 }
1253 }
1254
1255 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
1266 #[cfg(feature = "v1_10")]
1267 #[cfg_attr(docsrs, doc(cfg(feature = "v1_10")))]
1268 #[allow(deprecated)]
1269 #[doc(alias = "nm_client_connectivity_check_set_enabled")]
1270 pub fn connectivity_check_set_enabled(&self, enabled: bool) {
1271 unsafe {
1272 ffi::nm_client_connectivity_check_set_enabled(
1273 self.to_glib_none().0,
1274 enabled.into_glib(),
1275 );
1276 }
1277 }
1278
1279 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
1357 #[allow(deprecated)]
1358 #[doc(alias = "nm_client_deactivate_connection")]
1359 pub fn deactivate_connection(
1360 &self,
1361 active: &impl IsA<ActiveConnection>,
1362 cancellable: Option<&impl IsA<gio::Cancellable>>,
1363 ) -> Result<(), glib::Error> {
1364 unsafe {
1365 let mut error = std::ptr::null_mut();
1366 let is_ok = ffi::nm_client_deactivate_connection(
1367 self.to_glib_none().0,
1368 active.as_ref().to_glib_none().0,
1369 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1370 &mut error,
1371 );
1372 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1373 if error.is_null() {
1374 Ok(())
1375 } else {
1376 Err(from_glib_full(error))
1377 }
1378 }
1379 }
1380
1381 #[doc(alias = "nm_client_deactivate_connection_async")]
1389 pub fn deactivate_connection_async<P: FnOnce(Result<(), glib::Error>) + 'static>(
1390 &self,
1391 active: &impl IsA<ActiveConnection>,
1392 cancellable: Option<&impl IsA<gio::Cancellable>>,
1393 callback: P,
1394 ) {
1395 let main_context = glib::MainContext::ref_thread_default();
1396 let is_main_context_owner = main_context.is_owner();
1397 let has_acquired_main_context = (!is_main_context_owner)
1398 .then(|| main_context.acquire().ok())
1399 .flatten();
1400 assert!(
1401 is_main_context_owner || has_acquired_main_context.is_some(),
1402 "Async operations only allowed if the thread is owning the MainContext"
1403 );
1404
1405 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
1406 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
1407 unsafe extern "C" fn deactivate_connection_async_trampoline<
1408 P: FnOnce(Result<(), glib::Error>) + 'static,
1409 >(
1410 _source_object: *mut glib::gobject_ffi::GObject,
1411 res: *mut gio::ffi::GAsyncResult,
1412 user_data: glib::ffi::gpointer,
1413 ) {
1414 let mut error = std::ptr::null_mut();
1415 ffi::nm_client_deactivate_connection_finish(_source_object as *mut _, res, &mut error);
1416 let result = if error.is_null() {
1417 Ok(())
1418 } else {
1419 Err(from_glib_full(error))
1420 };
1421 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
1422 Box_::from_raw(user_data as *mut _);
1423 let callback: P = callback.into_inner();
1424 callback(result);
1425 }
1426 let callback = deactivate_connection_async_trampoline::<P>;
1427 unsafe {
1428 ffi::nm_client_deactivate_connection_async(
1429 self.to_glib_none().0,
1430 active.as_ref().to_glib_none().0,
1431 cancellable.map(|p| p.as_ref()).to_glib_none().0,
1432 Some(callback),
1433 Box_::into_raw(user_data) as *mut _,
1434 );
1435 }
1436 }
1437
1438 pub fn deactivate_connection_future(
1439 &self,
1440 active: &(impl IsA<ActiveConnection> + Clone + 'static),
1441 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
1442 let active = active.clone();
1443 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
1444 obj.deactivate_connection_async(&active, Some(cancellable), move |res| {
1445 send.resolve(res);
1446 });
1447 }))
1448 }
1449
1450 #[doc(alias = "nm_client_get_activating_connection")]
1459 #[doc(alias = "get_activating_connection")]
1460 #[doc(alias = "activating-connection")]
1461 pub fn activating_connection(&self) -> ActiveConnection {
1462 unsafe {
1463 from_glib_none(ffi::nm_client_get_activating_connection(
1464 self.to_glib_none().0,
1465 ))
1466 }
1467 }
1468
1469 #[doc(alias = "nm_client_get_active_connections")]
1477 #[doc(alias = "get_active_connections")]
1478 #[doc(alias = "active-connections")]
1479 pub fn active_connections(&self) -> Vec<ActiveConnection> {
1480 unsafe {
1481 FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_active_connections(
1482 self.to_glib_none().0,
1483 ))
1484 }
1485 }
1486
1487 #[cfg(feature = "v1_2")]
1503 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
1504 #[doc(alias = "nm_client_get_all_devices")]
1505 #[doc(alias = "get_all_devices")]
1506 #[doc(alias = "all-devices")]
1507 pub fn all_devices(&self) -> Vec<Device> {
1508 unsafe {
1509 FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_all_devices(
1510 self.to_glib_none().0,
1511 ))
1512 }
1513 }
1514
1515 #[cfg(feature = "v1_24")]
1525 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1526 #[doc(alias = "nm_client_get_capabilities")]
1527 #[doc(alias = "get_capabilities")]
1528 pub fn capabilities(&self) -> Vec<u32> {
1529 unsafe {
1530 let mut length = std::mem::MaybeUninit::uninit();
1531 let ret = FromGlibContainer::from_glib_none_num(
1532 ffi::nm_client_get_capabilities(self.to_glib_none().0, length.as_mut_ptr()),
1533 length.assume_init() as _,
1534 );
1535 ret
1536 }
1537 }
1538
1539 #[cfg(feature = "v1_12")]
1547 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
1548 #[doc(alias = "nm_client_get_checkpoints")]
1549 #[doc(alias = "get_checkpoints")]
1550 pub fn checkpoints(&self) -> Vec<Checkpoint> {
1551 unsafe {
1552 FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_checkpoints(
1553 self.to_glib_none().0,
1554 ))
1555 }
1556 }
1557
1558 #[doc(alias = "nm_client_get_connection_by_id")]
1570 #[doc(alias = "get_connection_by_id")]
1571 pub fn connection_by_id(&self, id: &str) -> RemoteConnection {
1572 unsafe {
1573 from_glib_none(ffi::nm_client_get_connection_by_id(
1574 self.to_glib_none().0,
1575 id.to_glib_none().0,
1576 ))
1577 }
1578 }
1579
1580 #[doc(alias = "nm_client_get_connection_by_path")]
1592 #[doc(alias = "get_connection_by_path")]
1593 pub fn connection_by_path(&self, path: &str) -> RemoteConnection {
1594 unsafe {
1595 from_glib_none(ffi::nm_client_get_connection_by_path(
1596 self.to_glib_none().0,
1597 path.to_glib_none().0,
1598 ))
1599 }
1600 }
1601
1602 #[doc(alias = "nm_client_get_connection_by_uuid")]
1614 #[doc(alias = "get_connection_by_uuid")]
1615 pub fn connection_by_uuid(&self, uuid: &str) -> RemoteConnection {
1616 unsafe {
1617 from_glib_none(ffi::nm_client_get_connection_by_uuid(
1618 self.to_glib_none().0,
1619 uuid.to_glib_none().0,
1620 ))
1621 }
1622 }
1623
1624 #[doc(alias = "nm_client_get_connections")]
1634 #[doc(alias = "get_connections")]
1635 pub fn connections(&self) -> Vec<RemoteConnection> {
1636 unsafe {
1637 FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_connections(
1638 self.to_glib_none().0,
1639 ))
1640 }
1641 }
1642
1643 #[doc(alias = "nm_client_get_connectivity")]
1652 #[doc(alias = "get_connectivity")]
1653 pub fn connectivity(&self) -> ConnectivityState {
1654 unsafe { from_glib(ffi::nm_client_get_connectivity(self.to_glib_none().0)) }
1655 }
1656
1657 #[cfg(feature = "v1_22")]
1679 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
1680 #[doc(alias = "nm_client_get_dbus_name_owner")]
1681 #[doc(alias = "get_dbus_name_owner")]
1682 #[doc(alias = "dbus-name-owner")]
1683 pub fn dbus_name_owner(&self) -> glib::GString {
1684 unsafe { from_glib_none(ffi::nm_client_get_dbus_name_owner(self.to_glib_none().0)) }
1685 }
1686
1687 #[doc(alias = "nm_client_get_device_by_iface")]
1695 #[doc(alias = "get_device_by_iface")]
1696 pub fn device_by_iface(&self, iface: &str) -> Device {
1697 unsafe {
1698 from_glib_none(ffi::nm_client_get_device_by_iface(
1699 self.to_glib_none().0,
1700 iface.to_glib_none().0,
1701 ))
1702 }
1703 }
1704
1705 #[doc(alias = "nm_client_get_device_by_path")]
1713 #[doc(alias = "get_device_by_path")]
1714 pub fn device_by_path(&self, object_path: &str) -> Device {
1715 unsafe {
1716 from_glib_none(ffi::nm_client_get_device_by_path(
1717 self.to_glib_none().0,
1718 object_path.to_glib_none().0,
1719 ))
1720 }
1721 }
1722
1723 #[doc(alias = "nm_client_get_devices")]
1734 #[doc(alias = "get_devices")]
1735 pub fn devices(&self) -> Vec<Device> {
1736 unsafe {
1737 FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_devices(self.to_glib_none().0))
1738 }
1739 }
1740
1741 #[cfg(feature = "v1_6")]
1750 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
1751 #[doc(alias = "nm_client_get_dns_configuration")]
1752 #[doc(alias = "get_dns_configuration")]
1753 #[doc(alias = "dns-configuration")]
1754 pub fn dns_configuration(&self) -> Vec<DnsEntry> {
1755 unsafe {
1756 FromGlibPtrContainer::from_glib_none(ffi::nm_client_get_dns_configuration(
1757 self.to_glib_none().0,
1758 ))
1759 }
1760 }
1761
1762 #[cfg(feature = "v1_6")]
1769 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
1770 #[doc(alias = "nm_client_get_dns_mode")]
1771 #[doc(alias = "get_dns_mode")]
1772 #[doc(alias = "dns-mode")]
1773 pub fn dns_mode(&self) -> glib::GString {
1774 unsafe { from_glib_none(ffi::nm_client_get_dns_mode(self.to_glib_none().0)) }
1775 }
1776
1777 #[cfg(feature = "v1_6")]
1784 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
1785 #[doc(alias = "nm_client_get_dns_rc_manager")]
1786 #[doc(alias = "get_dns_rc_manager")]
1787 #[doc(alias = "dns-rc-manager")]
1788 pub fn dns_rc_manager(&self) -> glib::GString {
1789 unsafe { from_glib_none(ffi::nm_client_get_dns_rc_manager(self.to_glib_none().0)) }
1790 }
1791
1792 #[cfg(feature = "v1_24")]
1797 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1798 #[doc(alias = "nm_client_get_instance_flags")]
1799 #[doc(alias = "get_instance_flags")]
1800 #[doc(alias = "instance-flags")]
1801 pub fn instance_flags(&self) -> ClientInstanceFlags {
1802 unsafe { from_glib(ffi::nm_client_get_instance_flags(self.to_glib_none().0)) }
1803 }
1804
1805 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
1824 #[allow(deprecated)]
1825 #[doc(alias = "nm_client_get_logging")]
1826 #[doc(alias = "get_logging")]
1827 pub fn logging(&self) -> Result<(Option<glib::GString>, Option<glib::GString>), glib::Error> {
1828 unsafe {
1829 let mut level = std::ptr::null_mut();
1830 let mut domains = std::ptr::null_mut();
1831 let mut error = std::ptr::null_mut();
1832 let is_ok = ffi::nm_client_get_logging(
1833 self.to_glib_none().0,
1834 &mut level,
1835 &mut domains,
1836 &mut error,
1837 );
1838 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1839 if error.is_null() {
1840 Ok((from_glib_full(level), from_glib_full(domains)))
1841 } else {
1842 Err(from_glib_full(error))
1843 }
1844 }
1845 }
1846
1847 #[cfg(feature = "v1_22")]
1860 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
1861 #[doc(alias = "nm_client_get_metered")]
1862 #[doc(alias = "get_metered")]
1863 pub fn metered(&self) -> Metered {
1864 unsafe { from_glib(ffi::nm_client_get_metered(self.to_glib_none().0)) }
1865 }
1866
1867 #[doc(alias = "nm_client_get_nm_running")]
1873 #[doc(alias = "get_nm_running")]
1874 #[doc(alias = "nm-running")]
1875 pub fn is_nm_running(&self) -> bool {
1876 unsafe { from_glib(ffi::nm_client_get_nm_running(self.to_glib_none().0)) }
1877 }
1878
1879 #[cfg(feature = "v1_24")]
1887 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1888 #[doc(alias = "nm_client_get_object_by_path")]
1889 #[doc(alias = "get_object_by_path")]
1890 pub fn object_by_path(&self, dbus_path: &str) -> Object {
1891 unsafe {
1892 from_glib_none(ffi::nm_client_get_object_by_path(
1893 self.to_glib_none().0,
1894 dbus_path.to_glib_none().0,
1895 ))
1896 }
1897 }
1898
1899 #[doc(alias = "nm_client_get_permission_result")]
1908 #[doc(alias = "get_permission_result")]
1909 pub fn permission_result(&self, permission: ClientPermission) -> ClientPermissionResult {
1910 unsafe {
1911 from_glib(ffi::nm_client_get_permission_result(
1912 self.to_glib_none().0,
1913 permission.into_glib(),
1914 ))
1915 }
1916 }
1917
1918 #[cfg(feature = "v1_24")]
1928 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
1929 #[doc(alias = "nm_client_get_permissions_state")]
1930 #[doc(alias = "get_permissions_state")]
1931 #[doc(alias = "permissions-state")]
1932 pub fn permissions_state(&self) -> Ternary {
1933 unsafe { from_glib(ffi::nm_client_get_permissions_state(self.to_glib_none().0)) }
1934 }
1935
1936 #[doc(alias = "nm_client_get_primary_connection")]
1953 #[doc(alias = "get_primary_connection")]
1954 #[doc(alias = "primary-connection")]
1955 pub fn primary_connection(&self) -> ActiveConnection {
1956 unsafe { from_glib_none(ffi::nm_client_get_primary_connection(self.to_glib_none().0)) }
1957 }
1958
1959 #[cfg(feature = "v1_38")]
1965 #[cfg_attr(docsrs, doc(cfg(feature = "v1_38")))]
1966 #[doc(alias = "nm_client_get_radio_flags")]
1967 #[doc(alias = "get_radio_flags")]
1968 #[doc(alias = "radio-flags")]
1969 pub fn radio_flags(&self) -> RadioFlags {
1970 unsafe { from_glib(ffi::nm_client_get_radio_flags(self.to_glib_none().0)) }
1971 }
1972
1973 #[doc(alias = "nm_client_get_startup")]
1980 #[doc(alias = "get_startup")]
1981 #[doc(alias = "startup")]
1982 pub fn is_startup(&self) -> bool {
1983 unsafe { from_glib(ffi::nm_client_get_startup(self.to_glib_none().0)) }
1984 }
1985
1986 #[doc(alias = "nm_client_get_state")]
1992 #[doc(alias = "get_state")]
1993 pub fn state(&self) -> State {
1994 unsafe { from_glib(ffi::nm_client_get_state(self.to_glib_none().0)) }
1995 }
1996
1997 #[doc(alias = "nm_client_get_version")]
2003 #[doc(alias = "get_version")]
2004 pub fn version(&self) -> glib::GString {
2005 unsafe { glib::GString::from_glib_none(ffi::nm_client_get_version(self.to_glib_none().0)) }
2006 }
2007
2008 #[cfg(feature = "v1_42")]
2019 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
2020 #[doc(alias = "nm_client_get_version_info")]
2021 #[doc(alias = "get_version_info")]
2022 #[doc(alias = "version-info")]
2023 pub fn version_info(&self) -> Vec<u32> {
2024 unsafe {
2025 let mut length = std::mem::MaybeUninit::uninit();
2026 let ret = FromGlibContainer::from_glib_none_num(
2027 ffi::nm_client_get_version_info(self.to_glib_none().0, length.as_mut_ptr()),
2028 length.assume_init() as _,
2029 );
2030 ret
2031 }
2032 }
2033
2034 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2071 #[allow(deprecated)]
2072 #[doc(alias = "nm_client_load_connections")]
2073 pub fn load_connections(
2074 &self,
2075 filenames: &[&str],
2076 cancellable: Option<&impl IsA<gio::Cancellable>>,
2077 ) -> Result<glib::GString, glib::Error> {
2078 unsafe {
2079 let mut failures = std::ptr::null_mut();
2080 let mut error = std::ptr::null_mut();
2081 let is_ok = ffi::nm_client_load_connections(
2082 self.to_glib_none().0,
2083 filenames.to_glib_none().0,
2084 &mut failures,
2085 cancellable.map(|p| p.as_ref()).to_glib_none().0,
2086 &mut error,
2087 );
2088 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2089 if error.is_null() {
2090 Ok(from_glib_full(std::ptr::read(failures)))
2091 } else {
2092 Err(from_glib_full(error))
2093 }
2094 }
2095 }
2096
2097 #[doc(alias = "nm_client_load_connections_async")]
2108 pub fn load_connections_async<P: FnOnce(Result<Vec<glib::GString>, glib::Error>) + 'static>(
2109 &self,
2110 filenames: &[&str],
2111 cancellable: Option<&impl IsA<gio::Cancellable>>,
2112 callback: P,
2113 ) {
2114 let main_context = glib::MainContext::ref_thread_default();
2115 let is_main_context_owner = main_context.is_owner();
2116 let has_acquired_main_context = (!is_main_context_owner)
2117 .then(|| main_context.acquire().ok())
2118 .flatten();
2119 assert!(
2120 is_main_context_owner || has_acquired_main_context.is_some(),
2121 "Async operations only allowed if the thread is owning the MainContext"
2122 );
2123
2124 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2125 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2126 unsafe extern "C" fn load_connections_async_trampoline<
2127 P: FnOnce(Result<Vec<glib::GString>, glib::Error>) + 'static,
2128 >(
2129 _source_object: *mut glib::gobject_ffi::GObject,
2130 res: *mut gio::ffi::GAsyncResult,
2131 user_data: glib::ffi::gpointer,
2132 ) {
2133 let mut error = std::ptr::null_mut();
2134 let mut failures = std::ptr::null_mut();
2135 ffi::nm_client_load_connections_finish(
2136 _source_object as *mut _,
2137 &mut failures,
2138 res,
2139 &mut error,
2140 );
2141 let result = if error.is_null() {
2142 Ok(FromGlibPtrContainer::from_glib_full(failures))
2143 } else {
2144 Err(from_glib_full(error))
2145 };
2146 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2147 Box_::from_raw(user_data as *mut _);
2148 let callback: P = callback.into_inner();
2149 callback(result);
2150 }
2151 let callback = load_connections_async_trampoline::<P>;
2152 unsafe {
2153 ffi::nm_client_load_connections_async(
2154 self.to_glib_none().0,
2155 filenames.to_glib_none().0,
2156 cancellable.map(|p| p.as_ref()).to_glib_none().0,
2157 Some(callback),
2158 Box_::into_raw(user_data) as *mut _,
2159 );
2160 }
2161 }
2162
2163 pub fn load_connections_future(
2164 &self,
2165 filenames: &[&str],
2166 ) -> Pin<
2167 Box_<dyn std::future::Future<Output = Result<Vec<glib::GString>, glib::Error>> + 'static>,
2168 > {
2169 let filenames = filenames
2170 .iter()
2171 .map(ToString::to_string)
2172 .collect::<Vec<_>>();
2173 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2174 obj.load_connections_async(
2175 filenames
2176 .iter()
2177 .map(|s| s.as_str())
2178 .collect::<Vec<&str>>()
2179 .as_slice(),
2180 Some(cancellable),
2181 move |res| {
2182 send.resolve(res);
2183 },
2184 );
2185 }))
2186 }
2187
2188 #[doc(alias = "nm_client_networking_get_enabled")]
2194 pub fn networking_get_enabled(&self) -> bool {
2195 unsafe { from_glib(ffi::nm_client_networking_get_enabled(self.to_glib_none().0)) }
2196 }
2197
2198 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2213 #[allow(deprecated)]
2214 #[doc(alias = "nm_client_networking_set_enabled")]
2215 pub fn networking_set_enabled(&self, enabled: bool) -> Result<(), glib::Error> {
2216 unsafe {
2217 let mut error = std::ptr::null_mut();
2218 let is_ok = ffi::nm_client_networking_set_enabled(
2219 self.to_glib_none().0,
2220 enabled.into_glib(),
2221 &mut error,
2222 );
2223 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2224 if error.is_null() {
2225 Ok(())
2226 } else {
2227 Err(from_glib_full(error))
2228 }
2229 }
2230 }
2231
2232 #[cfg(feature = "v1_22")]
2244 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
2245 #[doc(alias = "nm_client_reload")]
2246 pub fn reload<P: FnOnce(Result<(), glib::Error>) + 'static>(
2247 &self,
2248 flags: ManagerReloadFlags,
2249 cancellable: Option<&impl IsA<gio::Cancellable>>,
2250 callback: P,
2251 ) {
2252 let main_context = glib::MainContext::ref_thread_default();
2253 let is_main_context_owner = main_context.is_owner();
2254 let has_acquired_main_context = (!is_main_context_owner)
2255 .then(|| main_context.acquire().ok())
2256 .flatten();
2257 assert!(
2258 is_main_context_owner || has_acquired_main_context.is_some(),
2259 "Async operations only allowed if the thread is owning the MainContext"
2260 );
2261
2262 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2263 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2264 unsafe extern "C" fn reload_trampoline<P: FnOnce(Result<(), glib::Error>) + 'static>(
2265 _source_object: *mut glib::gobject_ffi::GObject,
2266 res: *mut gio::ffi::GAsyncResult,
2267 user_data: glib::ffi::gpointer,
2268 ) {
2269 let mut error = std::ptr::null_mut();
2270 ffi::nm_client_reload_finish(_source_object as *mut _, res, &mut error);
2271 let result = if error.is_null() {
2272 Ok(())
2273 } else {
2274 Err(from_glib_full(error))
2275 };
2276 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2277 Box_::from_raw(user_data as *mut _);
2278 let callback: P = callback.into_inner();
2279 callback(result);
2280 }
2281 let callback = reload_trampoline::<P>;
2282 unsafe {
2283 ffi::nm_client_reload(
2284 self.to_glib_none().0,
2285 flags.into_glib(),
2286 cancellable.map(|p| p.as_ref()).to_glib_none().0,
2287 Some(callback),
2288 Box_::into_raw(user_data) as *mut _,
2289 );
2290 }
2291 }
2292
2293 #[cfg(feature = "v1_22")]
2294 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
2295 pub fn reload_future(
2296 &self,
2297 flags: ManagerReloadFlags,
2298 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
2299 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2300 obj.reload(flags, Some(cancellable), move |res| {
2301 send.resolve(res);
2302 });
2303 }))
2304 }
2305
2306 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2320 #[allow(deprecated)]
2321 #[doc(alias = "nm_client_reload_connections")]
2322 pub fn reload_connections(
2323 &self,
2324 cancellable: Option<&impl IsA<gio::Cancellable>>,
2325 ) -> Result<(), glib::Error> {
2326 unsafe {
2327 let mut error = std::ptr::null_mut();
2328 let is_ok = ffi::nm_client_reload_connections(
2329 self.to_glib_none().0,
2330 cancellable.map(|p| p.as_ref()).to_glib_none().0,
2331 &mut error,
2332 );
2333 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2334 if error.is_null() {
2335 Ok(())
2336 } else {
2337 Err(from_glib_full(error))
2338 }
2339 }
2340 }
2341
2342 #[doc(alias = "nm_client_reload_connections_async")]
2350 pub fn reload_connections_async<P: FnOnce(Result<(), glib::Error>) + 'static>(
2351 &self,
2352 cancellable: Option<&impl IsA<gio::Cancellable>>,
2353 callback: P,
2354 ) {
2355 let main_context = glib::MainContext::ref_thread_default();
2356 let is_main_context_owner = main_context.is_owner();
2357 let has_acquired_main_context = (!is_main_context_owner)
2358 .then(|| main_context.acquire().ok())
2359 .flatten();
2360 assert!(
2361 is_main_context_owner || has_acquired_main_context.is_some(),
2362 "Async operations only allowed if the thread is owning the MainContext"
2363 );
2364
2365 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2366 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2367 unsafe extern "C" fn reload_connections_async_trampoline<
2368 P: FnOnce(Result<(), glib::Error>) + 'static,
2369 >(
2370 _source_object: *mut glib::gobject_ffi::GObject,
2371 res: *mut gio::ffi::GAsyncResult,
2372 user_data: glib::ffi::gpointer,
2373 ) {
2374 let mut error = std::ptr::null_mut();
2375 ffi::nm_client_reload_connections_finish(_source_object as *mut _, res, &mut error);
2376 let result = if error.is_null() {
2377 Ok(())
2378 } else {
2379 Err(from_glib_full(error))
2380 };
2381 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2382 Box_::from_raw(user_data as *mut _);
2383 let callback: P = callback.into_inner();
2384 callback(result);
2385 }
2386 let callback = reload_connections_async_trampoline::<P>;
2387 unsafe {
2388 ffi::nm_client_reload_connections_async(
2389 self.to_glib_none().0,
2390 cancellable.map(|p| p.as_ref()).to_glib_none().0,
2391 Some(callback),
2392 Box_::into_raw(user_data) as *mut _,
2393 );
2394 }
2395 }
2396
2397 pub fn reload_connections_future(
2398 &self,
2399 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
2400 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2401 obj.reload_connections_async(Some(cancellable), move |res| {
2402 send.resolve(res);
2403 });
2404 }))
2405 }
2406
2407 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2423 #[allow(deprecated)]
2424 #[doc(alias = "nm_client_save_hostname")]
2425 pub fn save_hostname(
2426 &self,
2427 hostname: Option<&str>,
2428 cancellable: Option<&impl IsA<gio::Cancellable>>,
2429 ) -> Result<(), glib::Error> {
2430 unsafe {
2431 let mut error = std::ptr::null_mut();
2432 let is_ok = ffi::nm_client_save_hostname(
2433 self.to_glib_none().0,
2434 hostname.to_glib_none().0,
2435 cancellable.map(|p| p.as_ref()).to_glib_none().0,
2436 &mut error,
2437 );
2438 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2439 if error.is_null() {
2440 Ok(())
2441 } else {
2442 Err(from_glib_full(error))
2443 }
2444 }
2445 }
2446
2447 #[doc(alias = "nm_client_save_hostname_async")]
2457 pub fn save_hostname_async<P: FnOnce(Result<(), glib::Error>) + 'static>(
2458 &self,
2459 hostname: Option<&str>,
2460 cancellable: Option<&impl IsA<gio::Cancellable>>,
2461 callback: P,
2462 ) {
2463 let main_context = glib::MainContext::ref_thread_default();
2464 let is_main_context_owner = main_context.is_owner();
2465 let has_acquired_main_context = (!is_main_context_owner)
2466 .then(|| main_context.acquire().ok())
2467 .flatten();
2468 assert!(
2469 is_main_context_owner || has_acquired_main_context.is_some(),
2470 "Async operations only allowed if the thread is owning the MainContext"
2471 );
2472
2473 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2474 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2475 unsafe extern "C" fn save_hostname_async_trampoline<
2476 P: FnOnce(Result<(), glib::Error>) + 'static,
2477 >(
2478 _source_object: *mut glib::gobject_ffi::GObject,
2479 res: *mut gio::ffi::GAsyncResult,
2480 user_data: glib::ffi::gpointer,
2481 ) {
2482 let mut error = std::ptr::null_mut();
2483 ffi::nm_client_save_hostname_finish(_source_object as *mut _, res, &mut error);
2484 let result = if error.is_null() {
2485 Ok(())
2486 } else {
2487 Err(from_glib_full(error))
2488 };
2489 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2490 Box_::from_raw(user_data as *mut _);
2491 let callback: P = callback.into_inner();
2492 callback(result);
2493 }
2494 let callback = save_hostname_async_trampoline::<P>;
2495 unsafe {
2496 ffi::nm_client_save_hostname_async(
2497 self.to_glib_none().0,
2498 hostname.to_glib_none().0,
2499 cancellable.map(|p| p.as_ref()).to_glib_none().0,
2500 Some(callback),
2501 Box_::into_raw(user_data) as *mut _,
2502 );
2503 }
2504 }
2505
2506 pub fn save_hostname_future(
2507 &self,
2508 hostname: Option<&str>,
2509 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
2510 let hostname = hostname.map(ToOwned::to_owned);
2511 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2512 obj.save_hostname_async(
2513 hostname.as_ref().map(::std::borrow::Borrow::borrow),
2514 Some(cancellable),
2515 move |res| {
2516 send.resolve(res);
2517 },
2518 );
2519 }))
2520 }
2521
2522 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2538 #[allow(deprecated)]
2539 #[doc(alias = "nm_client_set_logging")]
2540 pub fn set_logging(
2541 &self,
2542 level: Option<&str>,
2543 domains: Option<&str>,
2544 ) -> Result<(), glib::Error> {
2545 unsafe {
2546 let mut error = std::ptr::null_mut();
2547 let is_ok = ffi::nm_client_set_logging(
2548 self.to_glib_none().0,
2549 level.to_glib_none().0,
2550 domains.to_glib_none().0,
2551 &mut error,
2552 );
2553 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2554 if error.is_null() {
2555 Ok(())
2556 } else {
2557 Err(from_glib_full(error))
2558 }
2559 }
2560 }
2561
2562 #[cfg(feature = "v1_42")]
2622 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
2623 #[doc(alias = "nm_client_wait_shutdown")]
2624 pub fn wait_shutdown<P: FnOnce(Result<(), glib::Error>) + 'static>(
2625 &self,
2626 integrate_maincontext: bool,
2627 cancellable: Option<&impl IsA<gio::Cancellable>>,
2628 callback: P,
2629 ) {
2630 let main_context = glib::MainContext::ref_thread_default();
2631 let is_main_context_owner = main_context.is_owner();
2632 let has_acquired_main_context = (!is_main_context_owner)
2633 .then(|| main_context.acquire().ok())
2634 .flatten();
2635 assert!(
2636 is_main_context_owner || has_acquired_main_context.is_some(),
2637 "Async operations only allowed if the thread is owning the MainContext"
2638 );
2639
2640 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
2641 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
2642 unsafe extern "C" fn wait_shutdown_trampoline<
2643 P: FnOnce(Result<(), glib::Error>) + 'static,
2644 >(
2645 _source_object: *mut glib::gobject_ffi::GObject,
2646 res: *mut gio::ffi::GAsyncResult,
2647 user_data: glib::ffi::gpointer,
2648 ) {
2649 let mut error: *mut glib::ffi::GError = std::ptr::null_mut();
2650 ffi::nm_client_wait_shutdown_finish(res, &mut error);
2651 let result = if error.is_null() {
2652 Ok(())
2653 } else {
2654 Err(from_glib_full(error))
2655 };
2656 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
2657 Box_::from_raw(user_data as *mut _);
2658 let callback: P = callback.into_inner();
2659 callback(result);
2660 }
2661 let callback = wait_shutdown_trampoline::<P>;
2662 unsafe {
2663 ffi::nm_client_wait_shutdown(
2664 self.to_glib_none().0,
2665 integrate_maincontext.into_glib(),
2666 cancellable.map(|p| p.as_ref()).to_glib_none().0,
2667 Some(callback),
2668 Box_::into_raw(user_data) as *mut _,
2669 );
2670 }
2671 }
2672
2673 #[cfg(feature = "v1_42")]
2674 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
2675 pub fn wait_shutdown_future(
2676 &self,
2677 integrate_maincontext: bool,
2678 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
2679 Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
2680 obj.wait_shutdown(integrate_maincontext, Some(cancellable), move |res| {
2681 send.resolve(res);
2682 });
2683 }))
2684 }
2685
2686 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2696 #[allow(deprecated)]
2697 #[doc(alias = "nm_client_wimax_get_enabled")]
2698 pub fn wimax_get_enabled(&self) -> bool {
2699 unsafe { from_glib(ffi::nm_client_wimax_get_enabled(self.to_glib_none().0)) }
2700 }
2701
2702 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2712 #[allow(deprecated)]
2713 #[doc(alias = "nm_client_wimax_hardware_get_enabled")]
2714 pub fn wimax_hardware_get_enabled(&self) -> bool {
2715 unsafe {
2716 from_glib(ffi::nm_client_wimax_hardware_get_enabled(
2717 self.to_glib_none().0,
2718 ))
2719 }
2720 }
2721
2722 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2730 #[allow(deprecated)]
2731 #[doc(alias = "nm_client_wimax_set_enabled")]
2732 pub fn wimax_set_enabled(&self, enabled: bool) {
2733 unsafe {
2734 ffi::nm_client_wimax_set_enabled(self.to_glib_none().0, enabled.into_glib());
2735 }
2736 }
2737
2738 #[doc(alias = "nm_client_wireless_get_enabled")]
2744 pub fn wireless_get_enabled(&self) -> bool {
2745 unsafe { from_glib(ffi::nm_client_wireless_get_enabled(self.to_glib_none().0)) }
2746 }
2747
2748 #[doc(alias = "nm_client_wireless_hardware_get_enabled")]
2754 pub fn wireless_hardware_get_enabled(&self) -> bool {
2755 unsafe {
2756 from_glib(ffi::nm_client_wireless_hardware_get_enabled(
2757 self.to_glib_none().0,
2758 ))
2759 }
2760 }
2761
2762 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2771 #[allow(deprecated)]
2772 #[doc(alias = "nm_client_wireless_set_enabled")]
2773 pub fn wireless_set_enabled(&self, enabled: bool) {
2774 unsafe {
2775 ffi::nm_client_wireless_set_enabled(self.to_glib_none().0, enabled.into_glib());
2776 }
2777 }
2778
2779 #[doc(alias = "nm_client_wwan_get_enabled")]
2785 pub fn wwan_get_enabled(&self) -> bool {
2786 unsafe { from_glib(ffi::nm_client_wwan_get_enabled(self.to_glib_none().0)) }
2787 }
2788
2789 #[doc(alias = "nm_client_wwan_hardware_get_enabled")]
2795 pub fn wwan_hardware_get_enabled(&self) -> bool {
2796 unsafe {
2797 from_glib(ffi::nm_client_wwan_hardware_get_enabled(
2798 self.to_glib_none().0,
2799 ))
2800 }
2801 }
2802
2803 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2812 #[allow(deprecated)]
2813 #[doc(alias = "nm_client_wwan_set_enabled")]
2814 pub fn wwan_set_enabled(&self, enabled: bool) {
2815 unsafe {
2816 ffi::nm_client_wwan_set_enabled(self.to_glib_none().0, enabled.into_glib());
2817 }
2818 }
2819
2820 #[doc(alias = "can-modify")]
2822 pub fn can_modify(&self) -> bool {
2823 ObjectExt::property(self, "can-modify")
2824 }
2825
2826 #[doc(alias = "connectivity-check-available")]
2827 pub fn is_connectivity_check_available(&self) -> bool {
2828 ObjectExt::property(self, "connectivity-check-available")
2829 }
2830
2831 #[doc(alias = "connectivity-check-enabled")]
2832 pub fn is_connectivity_check_enabled(&self) -> bool {
2833 ObjectExt::property(self, "connectivity-check-enabled")
2834 }
2835
2836 #[doc(alias = "connectivity-check-enabled")]
2837 pub fn set_connectivity_check_enabled(&self, connectivity_check_enabled: bool) {
2838 ObjectExt::set_property(
2839 self,
2840 "connectivity-check-enabled",
2841 connectivity_check_enabled,
2842 )
2843 }
2844
2845 #[cfg(feature = "v1_22")]
2847 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
2848 #[doc(alias = "connectivity-check-uri")]
2849 pub fn connectivity_check_uri(&self) -> Option<glib::GString> {
2850 ObjectExt::property(self, "connectivity-check-uri")
2851 }
2852
2853 pub fn hostname(&self) -> Option<glib::GString> {
2856 ObjectExt::property(self, "hostname")
2857 }
2858
2859 #[cfg(feature = "v1_24")]
2871 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
2872 #[doc(alias = "instance-flags")]
2873 pub fn set_instance_flags(&self, instance_flags: u32) {
2874 ObjectExt::set_property(self, "instance-flags", instance_flags)
2875 }
2876
2877 #[cfg(not(feature = "v1_22"))]
2878 #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_22"))))]
2879 pub fn metered(&self) -> u32 {
2880 ObjectExt::property(self, "metered")
2881 }
2882
2883 #[doc(alias = "networking-enabled")]
2887 pub fn is_networking_enabled(&self) -> bool {
2888 ObjectExt::property(self, "networking-enabled")
2889 }
2890
2891 #[doc(alias = "networking-enabled")]
2895 pub fn set_networking_enabled(&self, networking_enabled: bool) {
2896 ObjectExt::set_property(self, "networking-enabled", networking_enabled)
2897 }
2898
2899 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2905 #[doc(alias = "wimax-enabled")]
2906 pub fn is_wimax_enabled(&self) -> bool {
2907 ObjectExt::property(self, "wimax-enabled")
2908 }
2909
2910 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2916 #[doc(alias = "wimax-enabled")]
2917 pub fn set_wimax_enabled(&self, wimax_enabled: bool) {
2918 ObjectExt::set_property(self, "wimax-enabled", wimax_enabled)
2919 }
2920
2921 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
2927 #[doc(alias = "wimax-hardware-enabled")]
2928 pub fn is_wimax_hardware_enabled(&self) -> bool {
2929 ObjectExt::property(self, "wimax-hardware-enabled")
2930 }
2931
2932 #[doc(alias = "wireless-enabled")]
2936 pub fn is_wireless_enabled(&self) -> bool {
2937 ObjectExt::property(self, "wireless-enabled")
2938 }
2939
2940 #[doc(alias = "wireless-enabled")]
2944 pub fn set_wireless_enabled(&self, wireless_enabled: bool) {
2945 ObjectExt::set_property(self, "wireless-enabled", wireless_enabled)
2946 }
2947
2948 #[doc(alias = "wireless-hardware-enabled")]
2950 pub fn is_wireless_hardware_enabled(&self) -> bool {
2951 ObjectExt::property(self, "wireless-hardware-enabled")
2952 }
2953
2954 #[doc(alias = "wwan-enabled")]
2958 pub fn is_wwan_enabled(&self) -> bool {
2959 ObjectExt::property(self, "wwan-enabled")
2960 }
2961
2962 #[doc(alias = "wwan-enabled")]
2966 pub fn set_wwan_enabled(&self, wwan_enabled: bool) {
2967 ObjectExt::set_property(self, "wwan-enabled", wwan_enabled)
2968 }
2969
2970 #[doc(alias = "wwan-hardware-enabled")]
2972 pub fn is_wwan_hardware_enabled(&self) -> bool {
2973 ObjectExt::property(self, "wwan-hardware-enabled")
2974 }
2975
2976 #[doc(alias = "nm_client_new_async")]
3002 pub fn new_async<P: FnOnce(Result<Client, glib::Error>) + 'static>(
3003 cancellable: Option<&impl IsA<gio::Cancellable>>,
3004 callback: P,
3005 ) {
3006 assert_initialized_main_thread!();
3007
3008 let main_context = glib::MainContext::ref_thread_default();
3009 let is_main_context_owner = main_context.is_owner();
3010 let has_acquired_main_context = (!is_main_context_owner)
3011 .then(|| main_context.acquire().ok())
3012 .flatten();
3013 assert!(
3014 is_main_context_owner || has_acquired_main_context.is_some(),
3015 "Async operations only allowed if the thread is owning the MainContext"
3016 );
3017
3018 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
3019 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
3020 unsafe extern "C" fn new_async_trampoline<
3021 P: FnOnce(Result<Client, glib::Error>) + 'static,
3022 >(
3023 _source_object: *mut glib::gobject_ffi::GObject,
3024 res: *mut gio::ffi::GAsyncResult,
3025 user_data: glib::ffi::gpointer,
3026 ) {
3027 let mut error = std::ptr::null_mut();
3028 let ret = ffi::nm_client_new_finish(res, &mut error);
3029 let result = if error.is_null() {
3030 Ok(from_glib_full(ret))
3031 } else {
3032 Err(from_glib_full(error))
3033 };
3034 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
3035 Box_::from_raw(user_data as *mut _);
3036 let callback: P = callback.into_inner();
3037 callback(result);
3038 }
3039 let callback = new_async_trampoline::<P>;
3040 unsafe {
3041 ffi::nm_client_new_async(
3042 cancellable.map(|p| p.as_ref()).to_glib_none().0,
3043 Some(callback),
3044 Box_::into_raw(user_data) as *mut _,
3045 );
3046 }
3047 }
3048
3049 pub fn new_future()
3050 -> Pin<Box_<dyn std::future::Future<Output = Result<Client, glib::Error>> + 'static>> {
3051 skip_assert_initialized!();
3052 Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| {
3053 Self::new_async(Some(cancellable), move |res| {
3054 send.resolve(res);
3055 });
3056 }))
3057 }
3058
3059 #[doc(alias = "active-connection-added")]
3063 pub fn connect_active_connection_added<F: Fn(&Self, &ActiveConnection) + 'static>(
3064 &self,
3065 f: F,
3066 ) -> SignalHandlerId {
3067 unsafe extern "C" fn active_connection_added_trampoline<
3068 F: Fn(&Client, &ActiveConnection) + 'static,
3069 >(
3070 this: *mut ffi::NMClient,
3071 active_connection: *mut ffi::NMActiveConnection,
3072 f: glib::ffi::gpointer,
3073 ) {
3074 let f: &F = &*(f as *const F);
3075 f(
3076 &from_glib_borrow(this),
3077 &from_glib_borrow(active_connection),
3078 )
3079 }
3080 unsafe {
3081 let f: Box_<F> = Box_::new(f);
3082 connect_raw(
3083 self.as_ptr() as *mut _,
3084 c"active-connection-added".as_ptr() as *const _,
3085 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3086 active_connection_added_trampoline::<F> as *const (),
3087 )),
3088 Box_::into_raw(f),
3089 )
3090 }
3091 }
3092
3093 #[doc(alias = "active-connection-removed")]
3097 pub fn connect_active_connection_removed<F: Fn(&Self, &ActiveConnection) + 'static>(
3098 &self,
3099 f: F,
3100 ) -> SignalHandlerId {
3101 unsafe extern "C" fn active_connection_removed_trampoline<
3102 F: Fn(&Client, &ActiveConnection) + 'static,
3103 >(
3104 this: *mut ffi::NMClient,
3105 active_connection: *mut ffi::NMActiveConnection,
3106 f: glib::ffi::gpointer,
3107 ) {
3108 let f: &F = &*(f as *const F);
3109 f(
3110 &from_glib_borrow(this),
3111 &from_glib_borrow(active_connection),
3112 )
3113 }
3114 unsafe {
3115 let f: Box_<F> = Box_::new(f);
3116 connect_raw(
3117 self.as_ptr() as *mut _,
3118 c"active-connection-removed".as_ptr() as *const _,
3119 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3120 active_connection_removed_trampoline::<F> as *const (),
3121 )),
3122 Box_::into_raw(f),
3123 )
3124 }
3125 }
3126
3127 #[doc(alias = "any-device-added")]
3132 pub fn connect_any_device_added<F: Fn(&Self, &Device) + 'static>(
3133 &self,
3134 f: F,
3135 ) -> SignalHandlerId {
3136 unsafe extern "C" fn any_device_added_trampoline<F: Fn(&Client, &Device) + 'static>(
3137 this: *mut ffi::NMClient,
3138 device: *mut ffi::NMDevice,
3139 f: glib::ffi::gpointer,
3140 ) {
3141 let f: &F = &*(f as *const F);
3142 f(&from_glib_borrow(this), &from_glib_borrow(device))
3143 }
3144 unsafe {
3145 let f: Box_<F> = Box_::new(f);
3146 connect_raw(
3147 self.as_ptr() as *mut _,
3148 c"any-device-added".as_ptr() as *const _,
3149 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3150 any_device_added_trampoline::<F> as *const (),
3151 )),
3152 Box_::into_raw(f),
3153 )
3154 }
3155 }
3156
3157 #[doc(alias = "any-device-removed")]
3162 pub fn connect_any_device_removed<F: Fn(&Self, &Device) + 'static>(
3163 &self,
3164 f: F,
3165 ) -> SignalHandlerId {
3166 unsafe extern "C" fn any_device_removed_trampoline<F: Fn(&Client, &Device) + 'static>(
3167 this: *mut ffi::NMClient,
3168 device: *mut ffi::NMDevice,
3169 f: glib::ffi::gpointer,
3170 ) {
3171 let f: &F = &*(f as *const F);
3172 f(&from_glib_borrow(this), &from_glib_borrow(device))
3173 }
3174 unsafe {
3175 let f: Box_<F> = Box_::new(f);
3176 connect_raw(
3177 self.as_ptr() as *mut _,
3178 c"any-device-removed".as_ptr() as *const _,
3179 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3180 any_device_removed_trampoline::<F> as *const (),
3181 )),
3182 Box_::into_raw(f),
3183 )
3184 }
3185 }
3186
3187 #[doc(alias = "connection-added")]
3191 pub fn connect_connection_added<F: Fn(&Self, &RemoteConnection) + 'static>(
3192 &self,
3193 f: F,
3194 ) -> SignalHandlerId {
3195 unsafe extern "C" fn connection_added_trampoline<
3196 F: Fn(&Client, &RemoteConnection) + 'static,
3197 >(
3198 this: *mut ffi::NMClient,
3199 connection: *mut ffi::NMRemoteConnection,
3200 f: glib::ffi::gpointer,
3201 ) {
3202 let f: &F = &*(f as *const F);
3203 f(&from_glib_borrow(this), &from_glib_borrow(connection))
3204 }
3205 unsafe {
3206 let f: Box_<F> = Box_::new(f);
3207 connect_raw(
3208 self.as_ptr() as *mut _,
3209 c"connection-added".as_ptr() as *const _,
3210 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3211 connection_added_trampoline::<F> as *const (),
3212 )),
3213 Box_::into_raw(f),
3214 )
3215 }
3216 }
3217
3218 #[doc(alias = "connection-removed")]
3222 pub fn connect_connection_removed<F: Fn(&Self, &RemoteConnection) + 'static>(
3223 &self,
3224 f: F,
3225 ) -> SignalHandlerId {
3226 unsafe extern "C" fn connection_removed_trampoline<
3227 F: Fn(&Client, &RemoteConnection) + 'static,
3228 >(
3229 this: *mut ffi::NMClient,
3230 connection: *mut ffi::NMRemoteConnection,
3231 f: glib::ffi::gpointer,
3232 ) {
3233 let f: &F = &*(f as *const F);
3234 f(&from_glib_borrow(this), &from_glib_borrow(connection))
3235 }
3236 unsafe {
3237 let f: Box_<F> = Box_::new(f);
3238 connect_raw(
3239 self.as_ptr() as *mut _,
3240 c"connection-removed".as_ptr() as *const _,
3241 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3242 connection_removed_trampoline::<F> as *const (),
3243 )),
3244 Box_::into_raw(f),
3245 )
3246 }
3247 }
3248
3249 #[doc(alias = "device-added")]
3254 pub fn connect_device_added<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId {
3255 unsafe extern "C" fn device_added_trampoline<F: Fn(&Client, &Device) + 'static>(
3256 this: *mut ffi::NMClient,
3257 device: *mut ffi::NMDevice,
3258 f: glib::ffi::gpointer,
3259 ) {
3260 let f: &F = &*(f as *const F);
3261 f(&from_glib_borrow(this), &from_glib_borrow(device))
3262 }
3263 unsafe {
3264 let f: Box_<F> = Box_::new(f);
3265 connect_raw(
3266 self.as_ptr() as *mut _,
3267 c"device-added".as_ptr() as *const _,
3268 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3269 device_added_trampoline::<F> as *const (),
3270 )),
3271 Box_::into_raw(f),
3272 )
3273 }
3274 }
3275
3276 #[doc(alias = "device-removed")]
3281 pub fn connect_device_removed<F: Fn(&Self, &Device) + 'static>(&self, f: F) -> SignalHandlerId {
3282 unsafe extern "C" fn device_removed_trampoline<F: Fn(&Client, &Device) + 'static>(
3283 this: *mut ffi::NMClient,
3284 device: *mut ffi::NMDevice,
3285 f: glib::ffi::gpointer,
3286 ) {
3287 let f: &F = &*(f as *const F);
3288 f(&from_glib_borrow(this), &from_glib_borrow(device))
3289 }
3290 unsafe {
3291 let f: Box_<F> = Box_::new(f);
3292 connect_raw(
3293 self.as_ptr() as *mut _,
3294 c"device-removed".as_ptr() as *const _,
3295 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3296 device_removed_trampoline::<F> as *const (),
3297 )),
3298 Box_::into_raw(f),
3299 )
3300 }
3301 }
3302
3303 #[doc(alias = "permission-changed")]
3309 pub fn connect_permission_changed<F: Fn(&Self, u32, u32) + 'static>(
3310 &self,
3311 f: F,
3312 ) -> SignalHandlerId {
3313 unsafe extern "C" fn permission_changed_trampoline<F: Fn(&Client, u32, u32) + 'static>(
3314 this: *mut ffi::NMClient,
3315 permission: std::ffi::c_uint,
3316 result: std::ffi::c_uint,
3317 f: glib::ffi::gpointer,
3318 ) {
3319 let f: &F = &*(f as *const F);
3320 f(&from_glib_borrow(this), permission, result)
3321 }
3322 unsafe {
3323 let f: Box_<F> = Box_::new(f);
3324 connect_raw(
3325 self.as_ptr() as *mut _,
3326 c"permission-changed".as_ptr() as *const _,
3327 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3328 permission_changed_trampoline::<F> as *const (),
3329 )),
3330 Box_::into_raw(f),
3331 )
3332 }
3333 }
3334
3335 #[doc(alias = "activating-connection")]
3336 pub fn connect_activating_connection_notify<F: Fn(&Self) + 'static>(
3337 &self,
3338 f: F,
3339 ) -> SignalHandlerId {
3340 unsafe extern "C" fn notify_activating_connection_trampoline<F: Fn(&Client) + 'static>(
3341 this: *mut ffi::NMClient,
3342 _param_spec: glib::ffi::gpointer,
3343 f: glib::ffi::gpointer,
3344 ) {
3345 let f: &F = &*(f as *const F);
3346 f(&from_glib_borrow(this))
3347 }
3348 unsafe {
3349 let f: Box_<F> = Box_::new(f);
3350 connect_raw(
3351 self.as_ptr() as *mut _,
3352 c"notify::activating-connection".as_ptr() as *const _,
3353 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3354 notify_activating_connection_trampoline::<F> as *const (),
3355 )),
3356 Box_::into_raw(f),
3357 )
3358 }
3359 }
3360
3361 #[doc(alias = "active-connections")]
3362 pub fn connect_active_connections_notify<F: Fn(&Self) + 'static>(
3363 &self,
3364 f: F,
3365 ) -> SignalHandlerId {
3366 unsafe extern "C" fn notify_active_connections_trampoline<F: Fn(&Client) + 'static>(
3367 this: *mut ffi::NMClient,
3368 _param_spec: glib::ffi::gpointer,
3369 f: glib::ffi::gpointer,
3370 ) {
3371 let f: &F = &*(f as *const F);
3372 f(&from_glib_borrow(this))
3373 }
3374 unsafe {
3375 let f: Box_<F> = Box_::new(f);
3376 connect_raw(
3377 self.as_ptr() as *mut _,
3378 c"notify::active-connections".as_ptr() as *const _,
3379 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3380 notify_active_connections_trampoline::<F> as *const (),
3381 )),
3382 Box_::into_raw(f),
3383 )
3384 }
3385 }
3386
3387 #[cfg(feature = "v1_2")]
3388 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
3389 #[doc(alias = "all-devices")]
3390 pub fn connect_all_devices_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3391 unsafe extern "C" fn notify_all_devices_trampoline<F: Fn(&Client) + 'static>(
3392 this: *mut ffi::NMClient,
3393 _param_spec: glib::ffi::gpointer,
3394 f: glib::ffi::gpointer,
3395 ) {
3396 let f: &F = &*(f as *const F);
3397 f(&from_glib_borrow(this))
3398 }
3399 unsafe {
3400 let f: Box_<F> = Box_::new(f);
3401 connect_raw(
3402 self.as_ptr() as *mut _,
3403 c"notify::all-devices".as_ptr() as *const _,
3404 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3405 notify_all_devices_trampoline::<F> as *const (),
3406 )),
3407 Box_::into_raw(f),
3408 )
3409 }
3410 }
3411
3412 #[doc(alias = "can-modify")]
3413 pub fn connect_can_modify_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3414 unsafe extern "C" fn notify_can_modify_trampoline<F: Fn(&Client) + 'static>(
3415 this: *mut ffi::NMClient,
3416 _param_spec: glib::ffi::gpointer,
3417 f: glib::ffi::gpointer,
3418 ) {
3419 let f: &F = &*(f as *const F);
3420 f(&from_glib_borrow(this))
3421 }
3422 unsafe {
3423 let f: Box_<F> = Box_::new(f);
3424 connect_raw(
3425 self.as_ptr() as *mut _,
3426 c"notify::can-modify".as_ptr() as *const _,
3427 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3428 notify_can_modify_trampoline::<F> as *const (),
3429 )),
3430 Box_::into_raw(f),
3431 )
3432 }
3433 }
3434
3435 #[cfg(feature = "v1_24")]
3436 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
3437 #[doc(alias = "capabilities")]
3438 pub fn connect_capabilities_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3439 unsafe extern "C" fn notify_capabilities_trampoline<F: Fn(&Client) + 'static>(
3440 this: *mut ffi::NMClient,
3441 _param_spec: glib::ffi::gpointer,
3442 f: glib::ffi::gpointer,
3443 ) {
3444 let f: &F = &*(f as *const F);
3445 f(&from_glib_borrow(this))
3446 }
3447 unsafe {
3448 let f: Box_<F> = Box_::new(f);
3449 connect_raw(
3450 self.as_ptr() as *mut _,
3451 c"notify::capabilities".as_ptr() as *const _,
3452 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3453 notify_capabilities_trampoline::<F> as *const (),
3454 )),
3455 Box_::into_raw(f),
3456 )
3457 }
3458 }
3459
3460 #[cfg(feature = "v1_12")]
3461 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
3462 #[doc(alias = "checkpoints")]
3463 pub fn connect_checkpoints_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3464 unsafe extern "C" fn notify_checkpoints_trampoline<F: Fn(&Client) + 'static>(
3465 this: *mut ffi::NMClient,
3466 _param_spec: glib::ffi::gpointer,
3467 f: glib::ffi::gpointer,
3468 ) {
3469 let f: &F = &*(f as *const F);
3470 f(&from_glib_borrow(this))
3471 }
3472 unsafe {
3473 let f: Box_<F> = Box_::new(f);
3474 connect_raw(
3475 self.as_ptr() as *mut _,
3476 c"notify::checkpoints".as_ptr() as *const _,
3477 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3478 notify_checkpoints_trampoline::<F> as *const (),
3479 )),
3480 Box_::into_raw(f),
3481 )
3482 }
3483 }
3484
3485 #[doc(alias = "connections")]
3486 pub fn connect_connections_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3487 unsafe extern "C" fn notify_connections_trampoline<F: Fn(&Client) + 'static>(
3488 this: *mut ffi::NMClient,
3489 _param_spec: glib::ffi::gpointer,
3490 f: glib::ffi::gpointer,
3491 ) {
3492 let f: &F = &*(f as *const F);
3493 f(&from_glib_borrow(this))
3494 }
3495 unsafe {
3496 let f: Box_<F> = Box_::new(f);
3497 connect_raw(
3498 self.as_ptr() as *mut _,
3499 c"notify::connections".as_ptr() as *const _,
3500 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3501 notify_connections_trampoline::<F> as *const (),
3502 )),
3503 Box_::into_raw(f),
3504 )
3505 }
3506 }
3507
3508 #[doc(alias = "connectivity")]
3509 pub fn connect_connectivity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3510 unsafe extern "C" fn notify_connectivity_trampoline<F: Fn(&Client) + 'static>(
3511 this: *mut ffi::NMClient,
3512 _param_spec: glib::ffi::gpointer,
3513 f: glib::ffi::gpointer,
3514 ) {
3515 let f: &F = &*(f as *const F);
3516 f(&from_glib_borrow(this))
3517 }
3518 unsafe {
3519 let f: Box_<F> = Box_::new(f);
3520 connect_raw(
3521 self.as_ptr() as *mut _,
3522 c"notify::connectivity".as_ptr() as *const _,
3523 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3524 notify_connectivity_trampoline::<F> as *const (),
3525 )),
3526 Box_::into_raw(f),
3527 )
3528 }
3529 }
3530
3531 #[doc(alias = "connectivity-check-available")]
3532 pub fn connect_connectivity_check_available_notify<F: Fn(&Self) + 'static>(
3533 &self,
3534 f: F,
3535 ) -> SignalHandlerId {
3536 unsafe extern "C" fn notify_connectivity_check_available_trampoline<
3537 F: Fn(&Client) + 'static,
3538 >(
3539 this: *mut ffi::NMClient,
3540 _param_spec: glib::ffi::gpointer,
3541 f: glib::ffi::gpointer,
3542 ) {
3543 let f: &F = &*(f as *const F);
3544 f(&from_glib_borrow(this))
3545 }
3546 unsafe {
3547 let f: Box_<F> = Box_::new(f);
3548 connect_raw(
3549 self.as_ptr() as *mut _,
3550 c"notify::connectivity-check-available".as_ptr() as *const _,
3551 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3552 notify_connectivity_check_available_trampoline::<F> as *const (),
3553 )),
3554 Box_::into_raw(f),
3555 )
3556 }
3557 }
3558
3559 #[doc(alias = "connectivity-check-enabled")]
3560 pub fn connect_connectivity_check_enabled_notify<F: Fn(&Self) + 'static>(
3561 &self,
3562 f: F,
3563 ) -> SignalHandlerId {
3564 unsafe extern "C" fn notify_connectivity_check_enabled_trampoline<
3565 F: Fn(&Client) + 'static,
3566 >(
3567 this: *mut ffi::NMClient,
3568 _param_spec: glib::ffi::gpointer,
3569 f: glib::ffi::gpointer,
3570 ) {
3571 let f: &F = &*(f as *const F);
3572 f(&from_glib_borrow(this))
3573 }
3574 unsafe {
3575 let f: Box_<F> = Box_::new(f);
3576 connect_raw(
3577 self.as_ptr() as *mut _,
3578 c"notify::connectivity-check-enabled".as_ptr() as *const _,
3579 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3580 notify_connectivity_check_enabled_trampoline::<F> as *const (),
3581 )),
3582 Box_::into_raw(f),
3583 )
3584 }
3585 }
3586
3587 #[cfg(feature = "v1_22")]
3588 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
3589 #[doc(alias = "connectivity-check-uri")]
3590 pub fn connect_connectivity_check_uri_notify<F: Fn(&Self) + 'static>(
3591 &self,
3592 f: F,
3593 ) -> SignalHandlerId {
3594 unsafe extern "C" fn notify_connectivity_check_uri_trampoline<F: Fn(&Client) + 'static>(
3595 this: *mut ffi::NMClient,
3596 _param_spec: glib::ffi::gpointer,
3597 f: glib::ffi::gpointer,
3598 ) {
3599 let f: &F = &*(f as *const F);
3600 f(&from_glib_borrow(this))
3601 }
3602 unsafe {
3603 let f: Box_<F> = Box_::new(f);
3604 connect_raw(
3605 self.as_ptr() as *mut _,
3606 c"notify::connectivity-check-uri".as_ptr() as *const _,
3607 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3608 notify_connectivity_check_uri_trampoline::<F> as *const (),
3609 )),
3610 Box_::into_raw(f),
3611 )
3612 }
3613 }
3614
3615 #[cfg(feature = "v1_22")]
3616 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
3617 #[doc(alias = "dbus-name-owner")]
3618 pub fn connect_dbus_name_owner_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3619 unsafe extern "C" fn notify_dbus_name_owner_trampoline<F: Fn(&Client) + 'static>(
3620 this: *mut ffi::NMClient,
3621 _param_spec: glib::ffi::gpointer,
3622 f: glib::ffi::gpointer,
3623 ) {
3624 let f: &F = &*(f as *const F);
3625 f(&from_glib_borrow(this))
3626 }
3627 unsafe {
3628 let f: Box_<F> = Box_::new(f);
3629 connect_raw(
3630 self.as_ptr() as *mut _,
3631 c"notify::dbus-name-owner".as_ptr() as *const _,
3632 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3633 notify_dbus_name_owner_trampoline::<F> as *const (),
3634 )),
3635 Box_::into_raw(f),
3636 )
3637 }
3638 }
3639
3640 #[doc(alias = "devices")]
3641 pub fn connect_devices_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3642 unsafe extern "C" fn notify_devices_trampoline<F: Fn(&Client) + 'static>(
3643 this: *mut ffi::NMClient,
3644 _param_spec: glib::ffi::gpointer,
3645 f: glib::ffi::gpointer,
3646 ) {
3647 let f: &F = &*(f as *const F);
3648 f(&from_glib_borrow(this))
3649 }
3650 unsafe {
3651 let f: Box_<F> = Box_::new(f);
3652 connect_raw(
3653 self.as_ptr() as *mut _,
3654 c"notify::devices".as_ptr() as *const _,
3655 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3656 notify_devices_trampoline::<F> as *const (),
3657 )),
3658 Box_::into_raw(f),
3659 )
3660 }
3661 }
3662
3663 #[cfg(feature = "v1_6")]
3664 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
3665 #[doc(alias = "dns-configuration")]
3666 pub fn connect_dns_configuration_notify<F: Fn(&Self) + 'static>(
3667 &self,
3668 f: F,
3669 ) -> SignalHandlerId {
3670 unsafe extern "C" fn notify_dns_configuration_trampoline<F: Fn(&Client) + 'static>(
3671 this: *mut ffi::NMClient,
3672 _param_spec: glib::ffi::gpointer,
3673 f: glib::ffi::gpointer,
3674 ) {
3675 let f: &F = &*(f as *const F);
3676 f(&from_glib_borrow(this))
3677 }
3678 unsafe {
3679 let f: Box_<F> = Box_::new(f);
3680 connect_raw(
3681 self.as_ptr() as *mut _,
3682 c"notify::dns-configuration".as_ptr() as *const _,
3683 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3684 notify_dns_configuration_trampoline::<F> as *const (),
3685 )),
3686 Box_::into_raw(f),
3687 )
3688 }
3689 }
3690
3691 #[cfg(feature = "v1_6")]
3692 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
3693 #[doc(alias = "dns-mode")]
3694 pub fn connect_dns_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3695 unsafe extern "C" fn notify_dns_mode_trampoline<F: Fn(&Client) + 'static>(
3696 this: *mut ffi::NMClient,
3697 _param_spec: glib::ffi::gpointer,
3698 f: glib::ffi::gpointer,
3699 ) {
3700 let f: &F = &*(f as *const F);
3701 f(&from_glib_borrow(this))
3702 }
3703 unsafe {
3704 let f: Box_<F> = Box_::new(f);
3705 connect_raw(
3706 self.as_ptr() as *mut _,
3707 c"notify::dns-mode".as_ptr() as *const _,
3708 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3709 notify_dns_mode_trampoline::<F> as *const (),
3710 )),
3711 Box_::into_raw(f),
3712 )
3713 }
3714 }
3715
3716 #[cfg(feature = "v1_6")]
3717 #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
3718 #[doc(alias = "dns-rc-manager")]
3719 pub fn connect_dns_rc_manager_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3720 unsafe extern "C" fn notify_dns_rc_manager_trampoline<F: Fn(&Client) + 'static>(
3721 this: *mut ffi::NMClient,
3722 _param_spec: glib::ffi::gpointer,
3723 f: glib::ffi::gpointer,
3724 ) {
3725 let f: &F = &*(f as *const F);
3726 f(&from_glib_borrow(this))
3727 }
3728 unsafe {
3729 let f: Box_<F> = Box_::new(f);
3730 connect_raw(
3731 self.as_ptr() as *mut _,
3732 c"notify::dns-rc-manager".as_ptr() as *const _,
3733 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3734 notify_dns_rc_manager_trampoline::<F> as *const (),
3735 )),
3736 Box_::into_raw(f),
3737 )
3738 }
3739 }
3740
3741 #[doc(alias = "hostname")]
3742 pub fn connect_hostname_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3743 unsafe extern "C" fn notify_hostname_trampoline<F: Fn(&Client) + 'static>(
3744 this: *mut ffi::NMClient,
3745 _param_spec: glib::ffi::gpointer,
3746 f: glib::ffi::gpointer,
3747 ) {
3748 let f: &F = &*(f as *const F);
3749 f(&from_glib_borrow(this))
3750 }
3751 unsafe {
3752 let f: Box_<F> = Box_::new(f);
3753 connect_raw(
3754 self.as_ptr() as *mut _,
3755 c"notify::hostname".as_ptr() as *const _,
3756 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3757 notify_hostname_trampoline::<F> as *const (),
3758 )),
3759 Box_::into_raw(f),
3760 )
3761 }
3762 }
3763
3764 #[cfg(feature = "v1_24")]
3765 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
3766 #[doc(alias = "instance-flags")]
3767 pub fn connect_instance_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3768 unsafe extern "C" fn notify_instance_flags_trampoline<F: Fn(&Client) + 'static>(
3769 this: *mut ffi::NMClient,
3770 _param_spec: glib::ffi::gpointer,
3771 f: glib::ffi::gpointer,
3772 ) {
3773 let f: &F = &*(f as *const F);
3774 f(&from_glib_borrow(this))
3775 }
3776 unsafe {
3777 let f: Box_<F> = Box_::new(f);
3778 connect_raw(
3779 self.as_ptr() as *mut _,
3780 c"notify::instance-flags".as_ptr() as *const _,
3781 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3782 notify_instance_flags_trampoline::<F> as *const (),
3783 )),
3784 Box_::into_raw(f),
3785 )
3786 }
3787 }
3788
3789 #[cfg(feature = "v1_2")]
3790 #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
3791 #[doc(alias = "metered")]
3792 pub fn connect_metered_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3793 unsafe extern "C" fn notify_metered_trampoline<F: Fn(&Client) + 'static>(
3794 this: *mut ffi::NMClient,
3795 _param_spec: glib::ffi::gpointer,
3796 f: glib::ffi::gpointer,
3797 ) {
3798 let f: &F = &*(f as *const F);
3799 f(&from_glib_borrow(this))
3800 }
3801 unsafe {
3802 let f: Box_<F> = Box_::new(f);
3803 connect_raw(
3804 self.as_ptr() as *mut _,
3805 c"notify::metered".as_ptr() as *const _,
3806 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3807 notify_metered_trampoline::<F> as *const (),
3808 )),
3809 Box_::into_raw(f),
3810 )
3811 }
3812 }
3813
3814 #[doc(alias = "networking-enabled")]
3815 pub fn connect_networking_enabled_notify<F: Fn(&Self) + 'static>(
3816 &self,
3817 f: F,
3818 ) -> SignalHandlerId {
3819 unsafe extern "C" fn notify_networking_enabled_trampoline<F: Fn(&Client) + 'static>(
3820 this: *mut ffi::NMClient,
3821 _param_spec: glib::ffi::gpointer,
3822 f: glib::ffi::gpointer,
3823 ) {
3824 let f: &F = &*(f as *const F);
3825 f(&from_glib_borrow(this))
3826 }
3827 unsafe {
3828 let f: Box_<F> = Box_::new(f);
3829 connect_raw(
3830 self.as_ptr() as *mut _,
3831 c"notify::networking-enabled".as_ptr() as *const _,
3832 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3833 notify_networking_enabled_trampoline::<F> as *const (),
3834 )),
3835 Box_::into_raw(f),
3836 )
3837 }
3838 }
3839
3840 #[doc(alias = "nm-running")]
3841 pub fn connect_nm_running_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3842 unsafe extern "C" fn notify_nm_running_trampoline<F: Fn(&Client) + 'static>(
3843 this: *mut ffi::NMClient,
3844 _param_spec: glib::ffi::gpointer,
3845 f: glib::ffi::gpointer,
3846 ) {
3847 let f: &F = &*(f as *const F);
3848 f(&from_glib_borrow(this))
3849 }
3850 unsafe {
3851 let f: Box_<F> = Box_::new(f);
3852 connect_raw(
3853 self.as_ptr() as *mut _,
3854 c"notify::nm-running".as_ptr() as *const _,
3855 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3856 notify_nm_running_trampoline::<F> as *const (),
3857 )),
3858 Box_::into_raw(f),
3859 )
3860 }
3861 }
3862
3863 #[cfg(feature = "v1_24")]
3864 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
3865 #[doc(alias = "permissions-state")]
3866 pub fn connect_permissions_state_notify<F: Fn(&Self) + 'static>(
3867 &self,
3868 f: F,
3869 ) -> SignalHandlerId {
3870 unsafe extern "C" fn notify_permissions_state_trampoline<F: Fn(&Client) + 'static>(
3871 this: *mut ffi::NMClient,
3872 _param_spec: glib::ffi::gpointer,
3873 f: glib::ffi::gpointer,
3874 ) {
3875 let f: &F = &*(f as *const F);
3876 f(&from_glib_borrow(this))
3877 }
3878 unsafe {
3879 let f: Box_<F> = Box_::new(f);
3880 connect_raw(
3881 self.as_ptr() as *mut _,
3882 c"notify::permissions-state".as_ptr() as *const _,
3883 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3884 notify_permissions_state_trampoline::<F> as *const (),
3885 )),
3886 Box_::into_raw(f),
3887 )
3888 }
3889 }
3890
3891 #[doc(alias = "primary-connection")]
3892 pub fn connect_primary_connection_notify<F: Fn(&Self) + 'static>(
3893 &self,
3894 f: F,
3895 ) -> SignalHandlerId {
3896 unsafe extern "C" fn notify_primary_connection_trampoline<F: Fn(&Client) + 'static>(
3897 this: *mut ffi::NMClient,
3898 _param_spec: glib::ffi::gpointer,
3899 f: glib::ffi::gpointer,
3900 ) {
3901 let f: &F = &*(f as *const F);
3902 f(&from_glib_borrow(this))
3903 }
3904 unsafe {
3905 let f: Box_<F> = Box_::new(f);
3906 connect_raw(
3907 self.as_ptr() as *mut _,
3908 c"notify::primary-connection".as_ptr() as *const _,
3909 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3910 notify_primary_connection_trampoline::<F> as *const (),
3911 )),
3912 Box_::into_raw(f),
3913 )
3914 }
3915 }
3916
3917 #[cfg(feature = "v1_38")]
3918 #[cfg_attr(docsrs, doc(cfg(feature = "v1_38")))]
3919 #[doc(alias = "radio-flags")]
3920 pub fn connect_radio_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3921 unsafe extern "C" fn notify_radio_flags_trampoline<F: Fn(&Client) + 'static>(
3922 this: *mut ffi::NMClient,
3923 _param_spec: glib::ffi::gpointer,
3924 f: glib::ffi::gpointer,
3925 ) {
3926 let f: &F = &*(f as *const F);
3927 f(&from_glib_borrow(this))
3928 }
3929 unsafe {
3930 let f: Box_<F> = Box_::new(f);
3931 connect_raw(
3932 self.as_ptr() as *mut _,
3933 c"notify::radio-flags".as_ptr() as *const _,
3934 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3935 notify_radio_flags_trampoline::<F> as *const (),
3936 )),
3937 Box_::into_raw(f),
3938 )
3939 }
3940 }
3941
3942 #[doc(alias = "startup")]
3943 pub fn connect_startup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3944 unsafe extern "C" fn notify_startup_trampoline<F: Fn(&Client) + 'static>(
3945 this: *mut ffi::NMClient,
3946 _param_spec: glib::ffi::gpointer,
3947 f: glib::ffi::gpointer,
3948 ) {
3949 let f: &F = &*(f as *const F);
3950 f(&from_glib_borrow(this))
3951 }
3952 unsafe {
3953 let f: Box_<F> = Box_::new(f);
3954 connect_raw(
3955 self.as_ptr() as *mut _,
3956 c"notify::startup".as_ptr() as *const _,
3957 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3958 notify_startup_trampoline::<F> as *const (),
3959 )),
3960 Box_::into_raw(f),
3961 )
3962 }
3963 }
3964
3965 #[doc(alias = "state")]
3966 pub fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3967 unsafe extern "C" fn notify_state_trampoline<F: Fn(&Client) + 'static>(
3968 this: *mut ffi::NMClient,
3969 _param_spec: glib::ffi::gpointer,
3970 f: glib::ffi::gpointer,
3971 ) {
3972 let f: &F = &*(f as *const F);
3973 f(&from_glib_borrow(this))
3974 }
3975 unsafe {
3976 let f: Box_<F> = Box_::new(f);
3977 connect_raw(
3978 self.as_ptr() as *mut _,
3979 c"notify::state".as_ptr() as *const _,
3980 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3981 notify_state_trampoline::<F> as *const (),
3982 )),
3983 Box_::into_raw(f),
3984 )
3985 }
3986 }
3987
3988 #[doc(alias = "version")]
3989 pub fn connect_version_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3990 unsafe extern "C" fn notify_version_trampoline<F: Fn(&Client) + 'static>(
3991 this: *mut ffi::NMClient,
3992 _param_spec: glib::ffi::gpointer,
3993 f: glib::ffi::gpointer,
3994 ) {
3995 let f: &F = &*(f as *const F);
3996 f(&from_glib_borrow(this))
3997 }
3998 unsafe {
3999 let f: Box_<F> = Box_::new(f);
4000 connect_raw(
4001 self.as_ptr() as *mut _,
4002 c"notify::version".as_ptr() as *const _,
4003 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4004 notify_version_trampoline::<F> as *const (),
4005 )),
4006 Box_::into_raw(f),
4007 )
4008 }
4009 }
4010
4011 #[cfg(feature = "v1_42")]
4012 #[cfg_attr(docsrs, doc(cfg(feature = "v1_42")))]
4013 #[doc(alias = "version-info")]
4014 pub fn connect_version_info_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4015 unsafe extern "C" fn notify_version_info_trampoline<F: Fn(&Client) + 'static>(
4016 this: *mut ffi::NMClient,
4017 _param_spec: glib::ffi::gpointer,
4018 f: glib::ffi::gpointer,
4019 ) {
4020 let f: &F = &*(f as *const F);
4021 f(&from_glib_borrow(this))
4022 }
4023 unsafe {
4024 let f: Box_<F> = Box_::new(f);
4025 connect_raw(
4026 self.as_ptr() as *mut _,
4027 c"notify::version-info".as_ptr() as *const _,
4028 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4029 notify_version_info_trampoline::<F> as *const (),
4030 )),
4031 Box_::into_raw(f),
4032 )
4033 }
4034 }
4035
4036 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
4037 #[doc(alias = "wimax-enabled")]
4038 pub fn connect_wimax_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4039 unsafe extern "C" fn notify_wimax_enabled_trampoline<F: Fn(&Client) + 'static>(
4040 this: *mut ffi::NMClient,
4041 _param_spec: glib::ffi::gpointer,
4042 f: glib::ffi::gpointer,
4043 ) {
4044 let f: &F = &*(f as *const F);
4045 f(&from_glib_borrow(this))
4046 }
4047 unsafe {
4048 let f: Box_<F> = Box_::new(f);
4049 connect_raw(
4050 self.as_ptr() as *mut _,
4051 c"notify::wimax-enabled".as_ptr() as *const _,
4052 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4053 notify_wimax_enabled_trampoline::<F> as *const (),
4054 )),
4055 Box_::into_raw(f),
4056 )
4057 }
4058 }
4059
4060 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
4061 #[doc(alias = "wimax-hardware-enabled")]
4062 pub fn connect_wimax_hardware_enabled_notify<F: Fn(&Self) + 'static>(
4063 &self,
4064 f: F,
4065 ) -> SignalHandlerId {
4066 unsafe extern "C" fn notify_wimax_hardware_enabled_trampoline<F: Fn(&Client) + 'static>(
4067 this: *mut ffi::NMClient,
4068 _param_spec: glib::ffi::gpointer,
4069 f: glib::ffi::gpointer,
4070 ) {
4071 let f: &F = &*(f as *const F);
4072 f(&from_glib_borrow(this))
4073 }
4074 unsafe {
4075 let f: Box_<F> = Box_::new(f);
4076 connect_raw(
4077 self.as_ptr() as *mut _,
4078 c"notify::wimax-hardware-enabled".as_ptr() as *const _,
4079 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4080 notify_wimax_hardware_enabled_trampoline::<F> as *const (),
4081 )),
4082 Box_::into_raw(f),
4083 )
4084 }
4085 }
4086
4087 #[doc(alias = "wireless-enabled")]
4088 pub fn connect_wireless_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4089 unsafe extern "C" fn notify_wireless_enabled_trampoline<F: Fn(&Client) + 'static>(
4090 this: *mut ffi::NMClient,
4091 _param_spec: glib::ffi::gpointer,
4092 f: glib::ffi::gpointer,
4093 ) {
4094 let f: &F = &*(f as *const F);
4095 f(&from_glib_borrow(this))
4096 }
4097 unsafe {
4098 let f: Box_<F> = Box_::new(f);
4099 connect_raw(
4100 self.as_ptr() as *mut _,
4101 c"notify::wireless-enabled".as_ptr() as *const _,
4102 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4103 notify_wireless_enabled_trampoline::<F> as *const (),
4104 )),
4105 Box_::into_raw(f),
4106 )
4107 }
4108 }
4109
4110 #[doc(alias = "wireless-hardware-enabled")]
4111 pub fn connect_wireless_hardware_enabled_notify<F: Fn(&Self) + 'static>(
4112 &self,
4113 f: F,
4114 ) -> SignalHandlerId {
4115 unsafe extern "C" fn notify_wireless_hardware_enabled_trampoline<
4116 F: Fn(&Client) + 'static,
4117 >(
4118 this: *mut ffi::NMClient,
4119 _param_spec: glib::ffi::gpointer,
4120 f: glib::ffi::gpointer,
4121 ) {
4122 let f: &F = &*(f as *const F);
4123 f(&from_glib_borrow(this))
4124 }
4125 unsafe {
4126 let f: Box_<F> = Box_::new(f);
4127 connect_raw(
4128 self.as_ptr() as *mut _,
4129 c"notify::wireless-hardware-enabled".as_ptr() as *const _,
4130 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4131 notify_wireless_hardware_enabled_trampoline::<F> as *const (),
4132 )),
4133 Box_::into_raw(f),
4134 )
4135 }
4136 }
4137
4138 #[doc(alias = "wwan-enabled")]
4139 pub fn connect_wwan_enabled_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4140 unsafe extern "C" fn notify_wwan_enabled_trampoline<F: Fn(&Client) + 'static>(
4141 this: *mut ffi::NMClient,
4142 _param_spec: glib::ffi::gpointer,
4143 f: glib::ffi::gpointer,
4144 ) {
4145 let f: &F = &*(f as *const F);
4146 f(&from_glib_borrow(this))
4147 }
4148 unsafe {
4149 let f: Box_<F> = Box_::new(f);
4150 connect_raw(
4151 self.as_ptr() as *mut _,
4152 c"notify::wwan-enabled".as_ptr() as *const _,
4153 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4154 notify_wwan_enabled_trampoline::<F> as *const (),
4155 )),
4156 Box_::into_raw(f),
4157 )
4158 }
4159 }
4160
4161 #[doc(alias = "wwan-hardware-enabled")]
4162 pub fn connect_wwan_hardware_enabled_notify<F: Fn(&Self) + 'static>(
4163 &self,
4164 f: F,
4165 ) -> SignalHandlerId {
4166 unsafe extern "C" fn notify_wwan_hardware_enabled_trampoline<F: Fn(&Client) + 'static>(
4167 this: *mut ffi::NMClient,
4168 _param_spec: glib::ffi::gpointer,
4169 f: glib::ffi::gpointer,
4170 ) {
4171 let f: &F = &*(f as *const F);
4172 f(&from_glib_borrow(this))
4173 }
4174 unsafe {
4175 let f: Box_<F> = Box_::new(f);
4176 connect_raw(
4177 self.as_ptr() as *mut _,
4178 c"notify::wwan-hardware-enabled".as_ptr() as *const _,
4179 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4180 notify_wwan_hardware_enabled_trampoline::<F> as *const (),
4181 )),
4182 Box_::into_raw(f),
4183 )
4184 }
4185 }
4186}
4187
4188impl Default for Client {
4189 fn default() -> Self {
4190 glib::object::Object::new::<Self>()
4191 }
4192}
4193
4194#[must_use = "The builder must be built to be used"]
4199pub struct ClientBuilder {
4200 builder: glib::object::ObjectBuilder<'static, Client>,
4201}
4202
4203impl ClientBuilder {
4204 fn new() -> Self {
4205 Self {
4206 builder: glib::object::Object::builder(),
4207 }
4208 }
4209
4210 pub fn connectivity_check_enabled(self, connectivity_check_enabled: bool) -> Self {
4211 Self {
4212 builder: self
4213 .builder
4214 .property("connectivity-check-enabled", connectivity_check_enabled),
4215 }
4216 }
4217
4218 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
4220 #[cfg(feature = "v1_24")]
4235 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
4236 pub fn instance_flags(self, instance_flags: u32) -> Self {
4237 Self {
4238 builder: self.builder.property("instance-flags", instance_flags),
4239 }
4240 }
4241
4242 pub fn networking_enabled(self, networking_enabled: bool) -> Self {
4246 Self {
4247 builder: self
4248 .builder
4249 .property("networking-enabled", networking_enabled),
4250 }
4251 }
4252
4253 #[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
4256 pub fn wimax_enabled(self, wimax_enabled: bool) -> Self {
4257 Self {
4258 builder: self.builder.property("wimax-enabled", wimax_enabled),
4259 }
4260 }
4261
4262 pub fn wireless_enabled(self, wireless_enabled: bool) -> Self {
4266 Self {
4267 builder: self.builder.property("wireless-enabled", wireless_enabled),
4268 }
4269 }
4270
4271 pub fn wwan_enabled(self, wwan_enabled: bool) -> Self {
4275 Self {
4276 builder: self.builder.property("wwan-enabled", wwan_enabled),
4277 }
4278 }
4279
4280 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
4283 pub fn build(self) -> Client {
4284 assert_initialized_main_thread!();
4285 self.builder.build()
4286 }
4287}