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::{DBusInterfaceSkeleton, DBusMethodInvocation, DBusObject, ffi};
6use glib::{
7 object::ObjectType as _,
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
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
89/// Trait containing all [`struct@DBusObjectSkeleton`] methods.
90///
91/// # Implementors
92///
93/// [`DBusObjectSkeleton`][struct@crate::DBusObjectSkeleton]
94pub trait DBusObjectSkeletonExt: IsA<DBusObjectSkeleton> + 'static {
95 /// Adds @interface_ to @self.
96 ///
97 /// If @self already contains a #GDBusInterfaceSkeleton with the same
98 /// interface name, it is removed before @interface_ is added.
99 ///
100 /// Note that @self takes its own reference on @interface_ and holds
101 /// it until removed.
102 /// ## `interface_`
103 /// A #GDBusInterfaceSkeleton.
104 #[doc(alias = "g_dbus_object_skeleton_add_interface")]
105 fn add_interface(&self, interface_: &impl IsA<DBusInterfaceSkeleton>) {
106 unsafe {
107 ffi::g_dbus_object_skeleton_add_interface(
108 self.as_ref().to_glib_none().0,
109 interface_.as_ref().to_glib_none().0,
110 );
111 }
112 }
113
114 /// This method simply calls g_dbus_interface_skeleton_flush() on all
115 /// interfaces belonging to @self. See that method for when flushing
116 /// is useful.
117 #[doc(alias = "g_dbus_object_skeleton_flush")]
118 fn flush(&self) {
119 unsafe {
120 ffi::g_dbus_object_skeleton_flush(self.as_ref().to_glib_none().0);
121 }
122 }
123
124 /// Removes @interface_ from @self.
125 /// ## `interface_`
126 /// A #GDBusInterfaceSkeleton.
127 #[doc(alias = "g_dbus_object_skeleton_remove_interface")]
128 fn remove_interface(&self, interface_: &impl IsA<DBusInterfaceSkeleton>) {
129 unsafe {
130 ffi::g_dbus_object_skeleton_remove_interface(
131 self.as_ref().to_glib_none().0,
132 interface_.as_ref().to_glib_none().0,
133 );
134 }
135 }
136
137 /// Removes the #GDBusInterface with @interface_name from @self.
138 ///
139 /// If no D-Bus interface of the given interface exists, this function
140 /// does nothing.
141 /// ## `interface_name`
142 /// A D-Bus interface name.
143 #[doc(alias = "g_dbus_object_skeleton_remove_interface_by_name")]
144 fn remove_interface_by_name(&self, interface_name: &str) {
145 unsafe {
146 ffi::g_dbus_object_skeleton_remove_interface_by_name(
147 self.as_ref().to_glib_none().0,
148 interface_name.to_glib_none().0,
149 );
150 }
151 }
152
153 /// Sets the object path for @self.
154 /// ## `object_path`
155 /// A valid D-Bus object path.
156 #[doc(alias = "g_dbus_object_skeleton_set_object_path")]
157 #[doc(alias = "g-object-path")]
158 fn set_object_path(&self, object_path: &str) {
159 unsafe {
160 ffi::g_dbus_object_skeleton_set_object_path(
161 self.as_ref().to_glib_none().0,
162 object_path.to_glib_none().0,
163 );
164 }
165 }
166
167 /// The object path where the object is exported.
168 #[doc(alias = "g-object-path")]
169 fn g_object_path(&self) -> Option<glib::GString> {
170 ObjectExt::property(self.as_ref(), "g-object-path")
171 }
172
173 /// The object path where the object is exported.
174 #[doc(alias = "g-object-path")]
175 fn set_g_object_path(&self, g_object_path: Option<&str>) {
176 ObjectExt::set_property(self.as_ref(), "g-object-path", g_object_path)
177 }
178
179 /// Emitted when a method is invoked by a remote caller and used to
180 /// determine if the method call is authorized.
181 ///
182 /// This signal is like #GDBusInterfaceSkeleton's
183 /// #GDBusInterfaceSkeleton::g-authorize-method signal,
184 /// except that it is for the enclosing object.
185 ///
186 /// The default class handler just returns [`true`].
187 /// ## `interface`
188 /// The #GDBusInterfaceSkeleton that @invocation is for.
189 /// ## `invocation`
190 /// A #GDBusMethodInvocation.
191 ///
192 /// # Returns
193 ///
194 /// [`true`] if the call is authorized, [`false`] otherwise.
195 #[doc(alias = "authorize-method")]
196 fn connect_authorize_method<
197 F: Fn(&Self, &DBusInterfaceSkeleton, &DBusMethodInvocation) -> bool + 'static,
198 >(
199 &self,
200 f: F,
201 ) -> SignalHandlerId {
202 unsafe extern "C" fn authorize_method_trampoline<
203 P: IsA<DBusObjectSkeleton>,
204 F: Fn(&P, &DBusInterfaceSkeleton, &DBusMethodInvocation) -> bool + 'static,
205 >(
206 this: *mut ffi::GDBusObjectSkeleton,
207 interface: *mut ffi::GDBusInterfaceSkeleton,
208 invocation: *mut ffi::GDBusMethodInvocation,
209 f: glib::ffi::gpointer,
210 ) -> glib::ffi::gboolean {
211 unsafe {
212 let f: &F = &*(f as *const F);
213 f(
214 DBusObjectSkeleton::from_glib_borrow(this).unsafe_cast_ref(),
215 &from_glib_borrow(interface),
216 &from_glib_borrow(invocation),
217 )
218 .into_glib()
219 }
220 }
221 unsafe {
222 let f: Box_<F> = Box_::new(f);
223 connect_raw(
224 self.as_ptr() as *mut _,
225 c"authorize-method".as_ptr(),
226 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
227 authorize_method_trampoline::<Self, F> as *const (),
228 )),
229 Box_::into_raw(f),
230 )
231 }
232 }
233
234 #[doc(alias = "g-object-path")]
235 fn connect_g_object_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
236 unsafe extern "C" fn notify_g_object_path_trampoline<
237 P: IsA<DBusObjectSkeleton>,
238 F: Fn(&P) + 'static,
239 >(
240 this: *mut ffi::GDBusObjectSkeleton,
241 _param_spec: glib::ffi::gpointer,
242 f: glib::ffi::gpointer,
243 ) {
244 unsafe {
245 let f: &F = &*(f as *const F);
246 f(DBusObjectSkeleton::from_glib_borrow(this).unsafe_cast_ref())
247 }
248 }
249 unsafe {
250 let f: Box_<F> = Box_::new(f);
251 connect_raw(
252 self.as_ptr() as *mut _,
253 c"notify::g-object-path".as_ptr(),
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 {}