gio/auto/
dbus_interface_skeleton.rs1use crate::{
6 ffi, DBusConnection, DBusInterface, DBusInterfaceInfo, DBusInterfaceSkeletonFlags,
7 DBusMethodInvocation,
8};
9use glib::{
10 object::ObjectType as _,
11 prelude::*,
12 signal::{connect_raw, SignalHandlerId},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 #[doc(alias = "GDBusInterfaceSkeleton")]
19 pub struct DBusInterfaceSkeleton(Object<ffi::GDBusInterfaceSkeleton, ffi::GDBusInterfaceSkeletonClass>) @implements DBusInterface;
20
21 match fn {
22 type_ => || ffi::g_dbus_interface_skeleton_get_type(),
23 }
24}
25
26impl DBusInterfaceSkeleton {
27 pub const NONE: Option<&'static DBusInterfaceSkeleton> = None;
28}
29
30pub trait DBusInterfaceSkeletonExt: IsA<DBusInterfaceSkeleton> + 'static {
31 #[doc(alias = "g_dbus_interface_skeleton_export")]
32 fn export(&self, connection: &DBusConnection, object_path: &str) -> Result<(), glib::Error> {
33 unsafe {
34 let mut error = std::ptr::null_mut();
35 let is_ok = ffi::g_dbus_interface_skeleton_export(
36 self.as_ref().to_glib_none().0,
37 connection.to_glib_none().0,
38 object_path.to_glib_none().0,
39 &mut error,
40 );
41 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
42 if error.is_null() {
43 Ok(())
44 } else {
45 Err(from_glib_full(error))
46 }
47 }
48 }
49
50 #[doc(alias = "g_dbus_interface_skeleton_flush")]
51 fn flush(&self) {
52 unsafe {
53 ffi::g_dbus_interface_skeleton_flush(self.as_ref().to_glib_none().0);
54 }
55 }
56
57 #[doc(alias = "g_dbus_interface_skeleton_get_connection")]
58 #[doc(alias = "get_connection")]
59 fn connection(&self) -> Option<DBusConnection> {
60 unsafe {
61 from_glib_none(ffi::g_dbus_interface_skeleton_get_connection(
62 self.as_ref().to_glib_none().0,
63 ))
64 }
65 }
66
67 #[doc(alias = "g_dbus_interface_skeleton_get_connections")]
68 #[doc(alias = "get_connections")]
69 fn connections(&self) -> Vec<DBusConnection> {
70 unsafe {
71 FromGlibPtrContainer::from_glib_full(ffi::g_dbus_interface_skeleton_get_connections(
72 self.as_ref().to_glib_none().0,
73 ))
74 }
75 }
76
77 #[doc(alias = "g_dbus_interface_skeleton_get_flags")]
78 #[doc(alias = "get_flags")]
79 fn flags(&self) -> DBusInterfaceSkeletonFlags {
80 unsafe {
81 from_glib(ffi::g_dbus_interface_skeleton_get_flags(
82 self.as_ref().to_glib_none().0,
83 ))
84 }
85 }
86
87 #[doc(alias = "g_dbus_interface_skeleton_get_info")]
88 #[doc(alias = "get_info")]
89 fn info(&self) -> DBusInterfaceInfo {
90 unsafe {
91 from_glib_none(ffi::g_dbus_interface_skeleton_get_info(
92 self.as_ref().to_glib_none().0,
93 ))
94 }
95 }
96
97 #[doc(alias = "g_dbus_interface_skeleton_get_object_path")]
98 #[doc(alias = "get_object_path")]
99 fn object_path(&self) -> Option<glib::GString> {
100 unsafe {
101 from_glib_none(ffi::g_dbus_interface_skeleton_get_object_path(
102 self.as_ref().to_glib_none().0,
103 ))
104 }
105 }
106
107 #[doc(alias = "g_dbus_interface_skeleton_get_properties")]
108 #[doc(alias = "get_properties")]
109 fn properties(&self) -> glib::Variant {
110 unsafe {
111 from_glib_full(ffi::g_dbus_interface_skeleton_get_properties(
112 self.as_ref().to_glib_none().0,
113 ))
114 }
115 }
116
117 #[doc(alias = "g_dbus_interface_skeleton_has_connection")]
124 fn has_connection(&self, connection: &DBusConnection) -> bool {
125 unsafe {
126 from_glib(ffi::g_dbus_interface_skeleton_has_connection(
127 self.as_ref().to_glib_none().0,
128 connection.to_glib_none().0,
129 ))
130 }
131 }
132
133 #[doc(alias = "g_dbus_interface_skeleton_set_flags")]
134 fn set_flags(&self, flags: DBusInterfaceSkeletonFlags) {
135 unsafe {
136 ffi::g_dbus_interface_skeleton_set_flags(
137 self.as_ref().to_glib_none().0,
138 flags.into_glib(),
139 );
140 }
141 }
142
143 #[doc(alias = "g_dbus_interface_skeleton_unexport")]
144 fn unexport(&self) {
145 unsafe {
146 ffi::g_dbus_interface_skeleton_unexport(self.as_ref().to_glib_none().0);
147 }
148 }
149
150 #[doc(alias = "g_dbus_interface_skeleton_unexport_from_connection")]
151 fn unexport_from_connection(&self, connection: &DBusConnection) {
152 unsafe {
153 ffi::g_dbus_interface_skeleton_unexport_from_connection(
154 self.as_ref().to_glib_none().0,
155 connection.to_glib_none().0,
156 );
157 }
158 }
159
160 #[doc(alias = "g-flags")]
161 fn g_flags(&self) -> DBusInterfaceSkeletonFlags {
162 ObjectExt::property(self.as_ref(), "g-flags")
163 }
164
165 #[doc(alias = "g-flags")]
166 fn set_g_flags(&self, g_flags: DBusInterfaceSkeletonFlags) {
167 ObjectExt::set_property(self.as_ref(), "g-flags", g_flags)
168 }
169
170 #[doc(alias = "g-authorize-method")]
171 fn connect_g_authorize_method<F: Fn(&Self, &DBusMethodInvocation) -> bool + 'static>(
172 &self,
173 f: F,
174 ) -> SignalHandlerId {
175 unsafe extern "C" fn g_authorize_method_trampoline<
176 P: IsA<DBusInterfaceSkeleton>,
177 F: Fn(&P, &DBusMethodInvocation) -> bool + 'static,
178 >(
179 this: *mut ffi::GDBusInterfaceSkeleton,
180 invocation: *mut ffi::GDBusMethodInvocation,
181 f: glib::ffi::gpointer,
182 ) -> glib::ffi::gboolean {
183 let f: &F = &*(f as *const F);
184 f(
185 DBusInterfaceSkeleton::from_glib_borrow(this).unsafe_cast_ref(),
186 &from_glib_borrow(invocation),
187 )
188 .into_glib()
189 }
190 unsafe {
191 let f: Box_<F> = Box_::new(f);
192 connect_raw(
193 self.as_ptr() as *mut _,
194 c"g-authorize-method".as_ptr() as *const _,
195 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
196 g_authorize_method_trampoline::<Self, F> as *const (),
197 )),
198 Box_::into_raw(f),
199 )
200 }
201 }
202
203 #[doc(alias = "g-flags")]
204 fn connect_g_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
205 unsafe extern "C" fn notify_g_flags_trampoline<
206 P: IsA<DBusInterfaceSkeleton>,
207 F: Fn(&P) + 'static,
208 >(
209 this: *mut ffi::GDBusInterfaceSkeleton,
210 _param_spec: glib::ffi::gpointer,
211 f: glib::ffi::gpointer,
212 ) {
213 let f: &F = &*(f as *const F);
214 f(DBusInterfaceSkeleton::from_glib_borrow(this).unsafe_cast_ref())
215 }
216 unsafe {
217 let f: Box_<F> = Box_::new(f);
218 connect_raw(
219 self.as_ptr() as *mut _,
220 c"notify::g-flags".as_ptr() as *const _,
221 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
222 notify_g_flags_trampoline::<Self, F> as *const (),
223 )),
224 Box_::into_raw(f),
225 )
226 }
227 }
228}
229
230impl<O: IsA<DBusInterfaceSkeleton>> DBusInterfaceSkeletonExt for O {}