gio/auto/dbus_object_skeleton.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, DBusInterfaceSkeleton, DBusMethodInvocation, DBusObject};
6use glib::{
7 object::ObjectType as _,
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// A `GDBusObjectSkeleton` instance is essentially a group of D-Bus
16 /// interfaces. The set of exported interfaces on the object may be
17 /// dynamic and change at runtime.
18 ///
19 /// This type is intended to be used with [`DBusObjectManager`][crate::DBusObjectManager].
20 ///
21 /// ## Properties
22 ///
23 ///
24 /// #### `g-object-path`
25 /// The object path where the object is exported.
26 ///
27 /// Readable | Writeable | Construct
28 ///
29 /// ## Signals
30 ///
31 ///
32 /// #### `authorize-method`
33 /// Emitted when a method is invoked by a remote caller and used to
34 /// determine if the method call is authorized.
35 ///
36 /// This signal is like #GDBusInterfaceSkeleton's
37 /// #GDBusInterfaceSkeleton::g-authorize-method signal,
38 /// except that it is for the enclosing object.
39 ///
40 /// The default class handler just returns [`true`].
41 ///
42 ///
43 /// <details><summary><h4>DBusObject</h4></summary>
44 ///
45 ///
46 /// #### `interface-added`
47 /// Emitted when @interface is added to @object.
48 ///
49 ///
50 ///
51 ///
52 /// #### `interface-removed`
53 /// Emitted when @interface is removed from @object.
54 ///
55 ///
56 /// </details>
57 ///
58 /// # Implements
59 ///
60 /// [`DBusObjectSkeletonExt`][trait@crate::prelude::DBusObjectSkeletonExt], [`trait@glib::ObjectExt`], [`DBusObjectExt`][trait@crate::prelude::DBusObjectExt]
61 #[doc(alias = "GDBusObjectSkeleton")]
62 pub struct DBusObjectSkeleton(Object<ffi::GDBusObjectSkeleton, ffi::GDBusObjectSkeletonClass>) @implements DBusObject;
63
64 match fn {
65 type_ => || ffi::g_dbus_object_skeleton_get_type(),
66 }
67}
68
69impl DBusObjectSkeleton {
70 pub const NONE: Option<&'static DBusObjectSkeleton> = None;
71
72 /// Creates a new #GDBusObjectSkeleton.
73 /// ## `object_path`
74 /// An object path.
75 ///
76 /// # Returns
77 ///
78 /// A #GDBusObjectSkeleton. Free with g_object_unref().
79 #[doc(alias = "g_dbus_object_skeleton_new")]
80 pub fn new(object_path: &str) -> DBusObjectSkeleton {
81 unsafe {
82 from_glib_full(ffi::g_dbus_object_skeleton_new(
83 object_path.to_glib_none().0,
84 ))
85 }
86 }
87}
88
89mod sealed {
90 pub trait Sealed {}
91 impl<T: super::IsA<super::DBusObjectSkeleton>> Sealed for T {}
92}
93
94/// Trait containing all [`struct@DBusObjectSkeleton`] methods.
95///
96/// # Implementors
97///
98/// [`DBusObjectSkeleton`][struct@crate::DBusObjectSkeleton]
99pub trait DBusObjectSkeletonExt: IsA<DBusObjectSkeleton> + sealed::Sealed + 'static {
100 /// Adds @interface_ to @self.
101 ///
102 /// If @self already contains a #GDBusInterfaceSkeleton with the same
103 /// interface name, it is removed before @interface_ is added.
104 ///
105 /// Note that @self takes its own reference on @interface_ and holds
106 /// it until removed.
107 /// ## `interface_`
108 /// A #GDBusInterfaceSkeleton.
109 #[doc(alias = "g_dbus_object_skeleton_add_interface")]
110 fn add_interface(&self, interface_: &impl IsA<DBusInterfaceSkeleton>) {
111 unsafe {
112 ffi::g_dbus_object_skeleton_add_interface(
113 self.as_ref().to_glib_none().0,
114 interface_.as_ref().to_glib_none().0,
115 );
116 }
117 }
118
119 /// This method simply calls g_dbus_interface_skeleton_flush() on all
120 /// interfaces belonging to @self. See that method for when flushing
121 /// is useful.
122 #[doc(alias = "g_dbus_object_skeleton_flush")]
123 fn flush(&self) {
124 unsafe {
125 ffi::g_dbus_object_skeleton_flush(self.as_ref().to_glib_none().0);
126 }
127 }
128
129 /// Removes @interface_ from @self.
130 /// ## `interface_`
131 /// A #GDBusInterfaceSkeleton.
132 #[doc(alias = "g_dbus_object_skeleton_remove_interface")]
133 fn remove_interface(&self, interface_: &impl IsA<DBusInterfaceSkeleton>) {
134 unsafe {
135 ffi::g_dbus_object_skeleton_remove_interface(
136 self.as_ref().to_glib_none().0,
137 interface_.as_ref().to_glib_none().0,
138 );
139 }
140 }
141
142 /// Removes the #GDBusInterface with @interface_name from @self.
143 ///
144 /// If no D-Bus interface of the given interface exists, this function
145 /// does nothing.
146 /// ## `interface_name`
147 /// A D-Bus interface name.
148 #[doc(alias = "g_dbus_object_skeleton_remove_interface_by_name")]
149 fn remove_interface_by_name(&self, interface_name: &str) {
150 unsafe {
151 ffi::g_dbus_object_skeleton_remove_interface_by_name(
152 self.as_ref().to_glib_none().0,
153 interface_name.to_glib_none().0,
154 );
155 }
156 }
157
158 /// Sets the object path for @self.
159 /// ## `object_path`
160 /// A valid D-Bus object path.
161 #[doc(alias = "g_dbus_object_skeleton_set_object_path")]
162 fn set_object_path(&self, object_path: &str) {
163 unsafe {
164 ffi::g_dbus_object_skeleton_set_object_path(
165 self.as_ref().to_glib_none().0,
166 object_path.to_glib_none().0,
167 );
168 }
169 }
170
171 /// The object path where the object is exported.
172 #[doc(alias = "g-object-path")]
173 fn g_object_path(&self) -> Option<glib::GString> {
174 ObjectExt::property(self.as_ref(), "g-object-path")
175 }
176
177 /// The object path where the object is exported.
178 #[doc(alias = "g-object-path")]
179 fn set_g_object_path(&self, g_object_path: Option<&str>) {
180 ObjectExt::set_property(self.as_ref(), "g-object-path", g_object_path)
181 }
182
183 /// Emitted when a method is invoked by a remote caller and used to
184 /// determine if the method call is authorized.
185 ///
186 /// This signal is like #GDBusInterfaceSkeleton's
187 /// #GDBusInterfaceSkeleton::g-authorize-method signal,
188 /// except that it is for the enclosing object.
189 ///
190 /// The default class handler just returns [`true`].
191 /// ## `interface`
192 /// The #GDBusInterfaceSkeleton that @invocation is for.
193 /// ## `invocation`
194 /// A #GDBusMethodInvocation.
195 ///
196 /// # Returns
197 ///
198 /// [`true`] if the call is authorized, [`false`] otherwise.
199 #[doc(alias = "authorize-method")]
200 fn connect_authorize_method<
201 F: Fn(&Self, &DBusInterfaceSkeleton, &DBusMethodInvocation) -> bool + 'static,
202 >(
203 &self,
204 f: F,
205 ) -> SignalHandlerId {
206 unsafe extern "C" fn authorize_method_trampoline<
207 P: IsA<DBusObjectSkeleton>,
208 F: Fn(&P, &DBusInterfaceSkeleton, &DBusMethodInvocation) -> bool + 'static,
209 >(
210 this: *mut ffi::GDBusObjectSkeleton,
211 interface: *mut ffi::GDBusInterfaceSkeleton,
212 invocation: *mut ffi::GDBusMethodInvocation,
213 f: glib::ffi::gpointer,
214 ) -> glib::ffi::gboolean {
215 let f: &F = &*(f as *const F);
216 f(
217 DBusObjectSkeleton::from_glib_borrow(this).unsafe_cast_ref(),
218 &from_glib_borrow(interface),
219 &from_glib_borrow(invocation),
220 )
221 .into_glib()
222 }
223 unsafe {
224 let f: Box_<F> = Box_::new(f);
225 connect_raw(
226 self.as_ptr() as *mut _,
227 b"authorize-method\0".as_ptr() as *const _,
228 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
229 authorize_method_trampoline::<Self, F> as *const (),
230 )),
231 Box_::into_raw(f),
232 )
233 }
234 }
235
236 #[doc(alias = "g-object-path")]
237 fn connect_g_object_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
238 unsafe extern "C" fn notify_g_object_path_trampoline<
239 P: IsA<DBusObjectSkeleton>,
240 F: Fn(&P) + 'static,
241 >(
242 this: *mut ffi::GDBusObjectSkeleton,
243 _param_spec: glib::ffi::gpointer,
244 f: glib::ffi::gpointer,
245 ) {
246 let f: &F = &*(f as *const F);
247 f(DBusObjectSkeleton::from_glib_borrow(this).unsafe_cast_ref())
248 }
249 unsafe {
250 let f: Box_<F> = Box_::new(f);
251 connect_raw(
252 self.as_ptr() as *mut _,
253 b"notify::g-object-path\0".as_ptr() as *const _,
254 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
255 notify_g_object_path_trampoline::<Self, F> as *const (),
256 )),
257 Box_::into_raw(f),
258 )
259 }
260 }
261}
262
263impl<O: IsA<DBusObjectSkeleton>> DBusObjectSkeletonExt for O {}