gio/auto/
dbus_object_skeleton.rs1use 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 #[doc(alias = "GDBusObjectSkeleton")]
16 pub struct DBusObjectSkeleton(Object<ffi::GDBusObjectSkeleton, ffi::GDBusObjectSkeletonClass>) @implements DBusObject;
17
18 match fn {
19 type_ => || ffi::g_dbus_object_skeleton_get_type(),
20 }
21}
22
23impl DBusObjectSkeleton {
24 pub const NONE: Option<&'static DBusObjectSkeleton> = None;
25
26 #[doc(alias = "g_dbus_object_skeleton_new")]
27 pub fn new(object_path: &str) -> DBusObjectSkeleton {
28 unsafe {
29 from_glib_full(ffi::g_dbus_object_skeleton_new(
30 object_path.to_glib_none().0,
31 ))
32 }
33 }
34}
35
36pub trait DBusObjectSkeletonExt: IsA<DBusObjectSkeleton> + 'static {
37 #[doc(alias = "g_dbus_object_skeleton_add_interface")]
38 fn add_interface(&self, interface_: &impl IsA<DBusInterfaceSkeleton>) {
39 unsafe {
40 ffi::g_dbus_object_skeleton_add_interface(
41 self.as_ref().to_glib_none().0,
42 interface_.as_ref().to_glib_none().0,
43 );
44 }
45 }
46
47 #[doc(alias = "g_dbus_object_skeleton_flush")]
48 fn flush(&self) {
49 unsafe {
50 ffi::g_dbus_object_skeleton_flush(self.as_ref().to_glib_none().0);
51 }
52 }
53
54 #[doc(alias = "g_dbus_object_skeleton_remove_interface")]
55 fn remove_interface(&self, interface_: &impl IsA<DBusInterfaceSkeleton>) {
56 unsafe {
57 ffi::g_dbus_object_skeleton_remove_interface(
58 self.as_ref().to_glib_none().0,
59 interface_.as_ref().to_glib_none().0,
60 );
61 }
62 }
63
64 #[doc(alias = "g_dbus_object_skeleton_remove_interface_by_name")]
65 fn remove_interface_by_name(&self, interface_name: &str) {
66 unsafe {
67 ffi::g_dbus_object_skeleton_remove_interface_by_name(
68 self.as_ref().to_glib_none().0,
69 interface_name.to_glib_none().0,
70 );
71 }
72 }
73
74 #[doc(alias = "g_dbus_object_skeleton_set_object_path")]
75 fn set_object_path(&self, object_path: &str) {
76 unsafe {
77 ffi::g_dbus_object_skeleton_set_object_path(
78 self.as_ref().to_glib_none().0,
79 object_path.to_glib_none().0,
80 );
81 }
82 }
83
84 #[doc(alias = "g-object-path")]
85 fn g_object_path(&self) -> Option<glib::GString> {
86 ObjectExt::property(self.as_ref(), "g-object-path")
87 }
88
89 #[doc(alias = "g-object-path")]
90 fn set_g_object_path(&self, g_object_path: Option<&str>) {
91 ObjectExt::set_property(self.as_ref(), "g-object-path", g_object_path)
92 }
93
94 #[doc(alias = "authorize-method")]
95 fn connect_authorize_method<
96 F: Fn(&Self, &DBusInterfaceSkeleton, &DBusMethodInvocation) -> bool + 'static,
97 >(
98 &self,
99 f: F,
100 ) -> SignalHandlerId {
101 unsafe extern "C" fn authorize_method_trampoline<
102 P: IsA<DBusObjectSkeleton>,
103 F: Fn(&P, &DBusInterfaceSkeleton, &DBusMethodInvocation) -> bool + 'static,
104 >(
105 this: *mut ffi::GDBusObjectSkeleton,
106 interface: *mut ffi::GDBusInterfaceSkeleton,
107 invocation: *mut ffi::GDBusMethodInvocation,
108 f: glib::ffi::gpointer,
109 ) -> glib::ffi::gboolean {
110 let f: &F = &*(f as *const F);
111 f(
112 DBusObjectSkeleton::from_glib_borrow(this).unsafe_cast_ref(),
113 &from_glib_borrow(interface),
114 &from_glib_borrow(invocation),
115 )
116 .into_glib()
117 }
118 unsafe {
119 let f: Box_<F> = Box_::new(f);
120 connect_raw(
121 self.as_ptr() as *mut _,
122 c"authorize-method".as_ptr() as *const _,
123 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
124 authorize_method_trampoline::<Self, F> as *const (),
125 )),
126 Box_::into_raw(f),
127 )
128 }
129 }
130
131 #[doc(alias = "g-object-path")]
132 fn connect_g_object_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
133 unsafe extern "C" fn notify_g_object_path_trampoline<
134 P: IsA<DBusObjectSkeleton>,
135 F: Fn(&P) + 'static,
136 >(
137 this: *mut ffi::GDBusObjectSkeleton,
138 _param_spec: glib::ffi::gpointer,
139 f: glib::ffi::gpointer,
140 ) {
141 let f: &F = &*(f as *const F);
142 f(DBusObjectSkeleton::from_glib_borrow(this).unsafe_cast_ref())
143 }
144 unsafe {
145 let f: Box_<F> = Box_::new(f);
146 connect_raw(
147 self.as_ptr() as *mut _,
148 c"notify::g-object-path".as_ptr() as *const _,
149 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
150 notify_g_object_path_trampoline::<Self, F> as *const (),
151 )),
152 Box_::into_raw(f),
153 )
154 }
155 }
156}
157
158impl<O: IsA<DBusObjectSkeleton>> DBusObjectSkeletonExt for O {}