gio/auto/
dbus_object_manager.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, DBusInterface, 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    /// The `GDBusObjectManager` type is the base type for service- and
16    /// client-side implementations of the standardized
17    /// [`org.freedesktop.DBus.ObjectManager`](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager)
18    /// interface.
19    ///
20    /// See `Gio::DBusObjectManagerClient` for the client-side implementation
21    /// and [`DBusObjectManagerServer`][crate::DBusObjectManagerServer] for the service-side implementation.
22    ///
23    /// ## Signals
24    ///
25    ///
26    /// #### `interface-added`
27    ///  Emitted when @interface is added to @object.
28    ///
29    /// This signal exists purely as a convenience to avoid having to
30    /// connect signals to all objects managed by @manager.
31    ///
32    ///
33    ///
34    ///
35    /// #### `interface-removed`
36    ///  Emitted when @interface has been removed from @object.
37    ///
38    /// This signal exists purely as a convenience to avoid having to
39    /// connect signals to all objects managed by @manager.
40    ///
41    ///
42    ///
43    ///
44    /// #### `object-added`
45    ///  Emitted when @object is added to @manager.
46    ///
47    ///
48    ///
49    ///
50    /// #### `object-removed`
51    ///  Emitted when @object is removed from @manager.
52    ///
53    ///
54    ///
55    /// # Implements
56    ///
57    /// [`DBusObjectManagerExt`][trait@crate::prelude::DBusObjectManagerExt]
58    #[doc(alias = "GDBusObjectManager")]
59    pub struct DBusObjectManager(Interface<ffi::GDBusObjectManager, ffi::GDBusObjectManagerIface>);
60
61    match fn {
62        type_ => || ffi::g_dbus_object_manager_get_type(),
63    }
64}
65
66impl DBusObjectManager {
67    pub const NONE: Option<&'static DBusObjectManager> = None;
68}
69
70mod sealed {
71    pub trait Sealed {}
72    impl<T: super::IsA<super::DBusObjectManager>> Sealed for T {}
73}
74
75/// Trait containing all [`struct@DBusObjectManager`] methods.
76///
77/// # Implementors
78///
79/// [`DBusObjectManagerServer`][struct@crate::DBusObjectManagerServer], [`DBusObjectManager`][struct@crate::DBusObjectManager]
80pub trait DBusObjectManagerExt: IsA<DBusObjectManager> + sealed::Sealed + 'static {
81    /// Gets the interface proxy for @interface_name at @object_path, if
82    /// any.
83    /// ## `object_path`
84    /// Object path to look up.
85    /// ## `interface_name`
86    /// D-Bus interface name to look up.
87    ///
88    /// # Returns
89    ///
90    /// A #GDBusInterface instance or [`None`]. Free
91    ///   with g_object_unref().
92    #[doc(alias = "g_dbus_object_manager_get_interface")]
93    #[doc(alias = "get_interface")]
94    fn interface(&self, object_path: &str, interface_name: &str) -> Option<DBusInterface> {
95        unsafe {
96            from_glib_full(ffi::g_dbus_object_manager_get_interface(
97                self.as_ref().to_glib_none().0,
98                object_path.to_glib_none().0,
99                interface_name.to_glib_none().0,
100            ))
101        }
102    }
103
104    /// Gets the #GDBusObject at @object_path, if any.
105    /// ## `object_path`
106    /// Object path to look up.
107    ///
108    /// # Returns
109    ///
110    /// A #GDBusObject or [`None`]. Free with
111    ///   g_object_unref().
112    #[doc(alias = "g_dbus_object_manager_get_object")]
113    #[doc(alias = "get_object")]
114    fn object(&self, object_path: &str) -> Option<DBusObject> {
115        unsafe {
116            from_glib_full(ffi::g_dbus_object_manager_get_object(
117                self.as_ref().to_glib_none().0,
118                object_path.to_glib_none().0,
119            ))
120        }
121    }
122
123    /// Gets the object path that @self is for.
124    ///
125    /// # Returns
126    ///
127    /// A string owned by @self. Do not free.
128    #[doc(alias = "g_dbus_object_manager_get_object_path")]
129    #[doc(alias = "get_object_path")]
130    fn object_path(&self) -> glib::GString {
131        unsafe {
132            from_glib_none(ffi::g_dbus_object_manager_get_object_path(
133                self.as_ref().to_glib_none().0,
134            ))
135        }
136    }
137
138    /// Gets all #GDBusObject objects known to @self.
139    ///
140    /// # Returns
141    ///
142    /// A list of
143    ///   #GDBusObject objects. The returned list should be freed with
144    ///   g_list_free() after each element has been freed with
145    ///   g_object_unref().
146    #[doc(alias = "g_dbus_object_manager_get_objects")]
147    #[doc(alias = "get_objects")]
148    fn objects(&self) -> Vec<DBusObject> {
149        unsafe {
150            FromGlibPtrContainer::from_glib_full(ffi::g_dbus_object_manager_get_objects(
151                self.as_ref().to_glib_none().0,
152            ))
153        }
154    }
155
156    /// Emitted when @interface is added to @object.
157    ///
158    /// This signal exists purely as a convenience to avoid having to
159    /// connect signals to all objects managed by @manager.
160    /// ## `object`
161    /// The #GDBusObject on which an interface was added.
162    /// ## `interface`
163    /// The #GDBusInterface that was added.
164    #[doc(alias = "interface-added")]
165    fn connect_interface_added<F: Fn(&Self, &DBusObject, &DBusInterface) + 'static>(
166        &self,
167        f: F,
168    ) -> SignalHandlerId {
169        unsafe extern "C" fn interface_added_trampoline<
170            P: IsA<DBusObjectManager>,
171            F: Fn(&P, &DBusObject, &DBusInterface) + 'static,
172        >(
173            this: *mut ffi::GDBusObjectManager,
174            object: *mut ffi::GDBusObject,
175            interface: *mut ffi::GDBusInterface,
176            f: glib::ffi::gpointer,
177        ) {
178            let f: &F = &*(f as *const F);
179            f(
180                DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
181                &from_glib_borrow(object),
182                &from_glib_borrow(interface),
183            )
184        }
185        unsafe {
186            let f: Box_<F> = Box_::new(f);
187            connect_raw(
188                self.as_ptr() as *mut _,
189                b"interface-added\0".as_ptr() as *const _,
190                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
191                    interface_added_trampoline::<Self, F> as *const (),
192                )),
193                Box_::into_raw(f),
194            )
195        }
196    }
197
198    /// Emitted when @interface has been removed from @object.
199    ///
200    /// This signal exists purely as a convenience to avoid having to
201    /// connect signals to all objects managed by @manager.
202    /// ## `object`
203    /// The #GDBusObject on which an interface was removed.
204    /// ## `interface`
205    /// The #GDBusInterface that was removed.
206    #[doc(alias = "interface-removed")]
207    fn connect_interface_removed<F: Fn(&Self, &DBusObject, &DBusInterface) + 'static>(
208        &self,
209        f: F,
210    ) -> SignalHandlerId {
211        unsafe extern "C" fn interface_removed_trampoline<
212            P: IsA<DBusObjectManager>,
213            F: Fn(&P, &DBusObject, &DBusInterface) + 'static,
214        >(
215            this: *mut ffi::GDBusObjectManager,
216            object: *mut ffi::GDBusObject,
217            interface: *mut ffi::GDBusInterface,
218            f: glib::ffi::gpointer,
219        ) {
220            let f: &F = &*(f as *const F);
221            f(
222                DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
223                &from_glib_borrow(object),
224                &from_glib_borrow(interface),
225            )
226        }
227        unsafe {
228            let f: Box_<F> = Box_::new(f);
229            connect_raw(
230                self.as_ptr() as *mut _,
231                b"interface-removed\0".as_ptr() as *const _,
232                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
233                    interface_removed_trampoline::<Self, F> as *const (),
234                )),
235                Box_::into_raw(f),
236            )
237        }
238    }
239
240    /// Emitted when @object is added to @manager.
241    /// ## `object`
242    /// The #GDBusObject that was added.
243    #[doc(alias = "object-added")]
244    fn connect_object_added<F: Fn(&Self, &DBusObject) + 'static>(&self, f: F) -> SignalHandlerId {
245        unsafe extern "C" fn object_added_trampoline<
246            P: IsA<DBusObjectManager>,
247            F: Fn(&P, &DBusObject) + 'static,
248        >(
249            this: *mut ffi::GDBusObjectManager,
250            object: *mut ffi::GDBusObject,
251            f: glib::ffi::gpointer,
252        ) {
253            let f: &F = &*(f as *const F);
254            f(
255                DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
256                &from_glib_borrow(object),
257            )
258        }
259        unsafe {
260            let f: Box_<F> = Box_::new(f);
261            connect_raw(
262                self.as_ptr() as *mut _,
263                b"object-added\0".as_ptr() as *const _,
264                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
265                    object_added_trampoline::<Self, F> as *const (),
266                )),
267                Box_::into_raw(f),
268            )
269        }
270    }
271
272    /// Emitted when @object is removed from @manager.
273    /// ## `object`
274    /// The #GDBusObject that was removed.
275    #[doc(alias = "object-removed")]
276    fn connect_object_removed<F: Fn(&Self, &DBusObject) + 'static>(&self, f: F) -> SignalHandlerId {
277        unsafe extern "C" fn object_removed_trampoline<
278            P: IsA<DBusObjectManager>,
279            F: Fn(&P, &DBusObject) + 'static,
280        >(
281            this: *mut ffi::GDBusObjectManager,
282            object: *mut ffi::GDBusObject,
283            f: glib::ffi::gpointer,
284        ) {
285            let f: &F = &*(f as *const F);
286            f(
287                DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(),
288                &from_glib_borrow(object),
289            )
290        }
291        unsafe {
292            let f: Box_<F> = Box_::new(f);
293            connect_raw(
294                self.as_ptr() as *mut _,
295                b"object-removed\0".as_ptr() as *const _,
296                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
297                    object_removed_trampoline::<Self, F> as *const (),
298                )),
299                Box_::into_raw(f),
300            )
301        }
302    }
303}
304
305impl<O: IsA<DBusObjectManager>> DBusObjectManagerExt for O {}