1#[cfg(unix)]
6#[cfg_attr(docsrs, doc(cfg(unix)))]
7use crate::UnixFDList;
8use crate::{
9 AsyncInitable, AsyncResult, BusType, Cancellable, DBusCallFlags, DBusConnection, DBusInterface,
10 DBusInterfaceInfo, DBusProxyFlags, Initable, ffi,
11};
12use glib::{
13 prelude::*,
14 signal::{SignalHandlerId, connect_raw},
15 translate::*,
16};
17use std::{boxed::Box as Box_, pin::Pin};
18
19glib::wrapper! {
20 #[doc(alias = "GDBusProxy")]
21 pub struct DBusProxy(Object<ffi::GDBusProxy, ffi::GDBusProxyClass>) @implements AsyncInitable, DBusInterface, Initable;
22
23 match fn {
24 type_ => || ffi::g_dbus_proxy_get_type(),
25 }
26}
27
28impl DBusProxy {
29 pub const NONE: Option<&'static DBusProxy> = None;
30
31 #[doc(alias = "g_dbus_proxy_new_for_bus_sync")]
32 #[doc(alias = "new_for_bus_sync")]
33 pub fn for_bus_sync(
34 bus_type: BusType,
35 flags: DBusProxyFlags,
36 info: Option<&DBusInterfaceInfo>,
37 name: &str,
38 object_path: &str,
39 interface_name: &str,
40 cancellable: Option<&impl IsA<Cancellable>>,
41 ) -> Result<DBusProxy, glib::Error> {
42 unsafe {
43 let mut error = std::ptr::null_mut();
44 let ret = ffi::g_dbus_proxy_new_for_bus_sync(
45 bus_type.into_glib(),
46 flags.into_glib(),
47 info.to_glib_none().0,
48 name.to_glib_none().0,
49 object_path.to_glib_none().0,
50 interface_name.to_glib_none().0,
51 cancellable.map(|p| p.as_ref()).to_glib_none().0,
52 &mut error,
53 );
54 if error.is_null() {
55 Ok(from_glib_full(ret))
56 } else {
57 Err(from_glib_full(error))
58 }
59 }
60 }
61
62 #[doc(alias = "g_dbus_proxy_new_sync")]
63 pub fn new_sync(
64 connection: &DBusConnection,
65 flags: DBusProxyFlags,
66 info: Option<&DBusInterfaceInfo>,
67 name: Option<&str>,
68 object_path: &str,
69 interface_name: &str,
70 cancellable: Option<&impl IsA<Cancellable>>,
71 ) -> Result<DBusProxy, glib::Error> {
72 unsafe {
73 let mut error = std::ptr::null_mut();
74 let ret = ffi::g_dbus_proxy_new_sync(
75 connection.to_glib_none().0,
76 flags.into_glib(),
77 info.to_glib_none().0,
78 name.to_glib_none().0,
79 object_path.to_glib_none().0,
80 interface_name.to_glib_none().0,
81 cancellable.map(|p| p.as_ref()).to_glib_none().0,
82 &mut error,
83 );
84 if error.is_null() {
85 Ok(from_glib_full(ret))
86 } else {
87 Err(from_glib_full(error))
88 }
89 }
90 }
91
92 #[doc(alias = "g_dbus_proxy_new")]
93 pub fn new<P: FnOnce(Result<DBusProxy, glib::Error>) + 'static>(
94 connection: &DBusConnection,
95 flags: DBusProxyFlags,
96 info: Option<&DBusInterfaceInfo>,
97 name: Option<&str>,
98 object_path: &str,
99 interface_name: &str,
100 cancellable: Option<&impl IsA<Cancellable>>,
101 callback: P,
102 ) {
103 let main_context = glib::MainContext::ref_thread_default();
104 let is_main_context_owner = main_context.is_owner();
105 let has_acquired_main_context = (!is_main_context_owner)
106 .then(|| main_context.acquire().ok())
107 .flatten();
108 assert!(
109 is_main_context_owner || has_acquired_main_context.is_some(),
110 "Async operations only allowed if the thread is owning the MainContext"
111 );
112
113 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
114 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
115 unsafe extern "C" fn new_trampoline<P: FnOnce(Result<DBusProxy, glib::Error>) + 'static>(
116 _source_object: *mut glib::gobject_ffi::GObject,
117 res: *mut crate::ffi::GAsyncResult,
118 user_data: glib::ffi::gpointer,
119 ) {
120 unsafe {
121 let mut error = std::ptr::null_mut();
122 let ret = ffi::g_dbus_proxy_new_finish(res, &mut error);
123 let result = if error.is_null() {
124 Ok(from_glib_full(ret))
125 } else {
126 Err(from_glib_full(error))
127 };
128 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
129 Box_::from_raw(user_data as *mut _);
130 let callback: P = callback.into_inner();
131 callback(result);
132 }
133 }
134 let callback = new_trampoline::<P>;
135 unsafe {
136 ffi::g_dbus_proxy_new(
137 connection.to_glib_none().0,
138 flags.into_glib(),
139 info.to_glib_none().0,
140 name.to_glib_none().0,
141 object_path.to_glib_none().0,
142 interface_name.to_glib_none().0,
143 cancellable.map(|p| p.as_ref()).to_glib_none().0,
144 Some(callback),
145 Box_::into_raw(user_data) as *mut _,
146 );
147 }
148 }
149
150 pub fn new_future(
151 connection: &DBusConnection,
152 flags: DBusProxyFlags,
153 info: Option<&DBusInterfaceInfo>,
154 name: Option<&str>,
155 object_path: &str,
156 interface_name: &str,
157 ) -> Pin<Box_<dyn std::future::Future<Output = Result<DBusProxy, glib::Error>> + 'static>> {
158 let connection = connection.clone();
159 let info = info.map(ToOwned::to_owned);
160 let name = name.map(ToOwned::to_owned);
161 let object_path = String::from(object_path);
162 let interface_name = String::from(interface_name);
163 Box_::pin(crate::GioFuture::new(
164 &(),
165 move |_obj, cancellable, send| {
166 Self::new(
167 &connection,
168 flags,
169 info.as_ref().map(::std::borrow::Borrow::borrow),
170 name.as_ref().map(::std::borrow::Borrow::borrow),
171 &object_path,
172 &interface_name,
173 Some(cancellable),
174 move |res| {
175 send.resolve(res);
176 },
177 );
178 },
179 ))
180 }
181
182 #[doc(alias = "g_dbus_proxy_new_for_bus")]
183 #[doc(alias = "new_for_bus")]
184 pub fn for_bus<P: FnOnce(Result<DBusProxy, glib::Error>) + 'static>(
185 bus_type: BusType,
186 flags: DBusProxyFlags,
187 info: Option<&DBusInterfaceInfo>,
188 name: &str,
189 object_path: &str,
190 interface_name: &str,
191 cancellable: Option<&impl IsA<Cancellable>>,
192 callback: P,
193 ) {
194 let main_context = glib::MainContext::ref_thread_default();
195 let is_main_context_owner = main_context.is_owner();
196 let has_acquired_main_context = (!is_main_context_owner)
197 .then(|| main_context.acquire().ok())
198 .flatten();
199 assert!(
200 is_main_context_owner || has_acquired_main_context.is_some(),
201 "Async operations only allowed if the thread is owning the MainContext"
202 );
203
204 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
205 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
206 unsafe extern "C" fn for_bus_trampoline<
207 P: FnOnce(Result<DBusProxy, glib::Error>) + 'static,
208 >(
209 _source_object: *mut glib::gobject_ffi::GObject,
210 res: *mut crate::ffi::GAsyncResult,
211 user_data: glib::ffi::gpointer,
212 ) {
213 unsafe {
214 let mut error = std::ptr::null_mut();
215 let ret = ffi::g_dbus_proxy_new_for_bus_finish(res, &mut error);
216 let result = if error.is_null() {
217 Ok(from_glib_full(ret))
218 } else {
219 Err(from_glib_full(error))
220 };
221 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
222 Box_::from_raw(user_data as *mut _);
223 let callback: P = callback.into_inner();
224 callback(result);
225 }
226 }
227 let callback = for_bus_trampoline::<P>;
228 unsafe {
229 ffi::g_dbus_proxy_new_for_bus(
230 bus_type.into_glib(),
231 flags.into_glib(),
232 info.to_glib_none().0,
233 name.to_glib_none().0,
234 object_path.to_glib_none().0,
235 interface_name.to_glib_none().0,
236 cancellable.map(|p| p.as_ref()).to_glib_none().0,
237 Some(callback),
238 Box_::into_raw(user_data) as *mut _,
239 );
240 }
241 }
242
243 pub fn for_bus_future(
244 bus_type: BusType,
245 flags: DBusProxyFlags,
246 info: Option<&DBusInterfaceInfo>,
247 name: &str,
248 object_path: &str,
249 interface_name: &str,
250 ) -> Pin<Box_<dyn std::future::Future<Output = Result<DBusProxy, glib::Error>> + 'static>> {
251 let info = info.map(ToOwned::to_owned);
252 let name = String::from(name);
253 let object_path = String::from(object_path);
254 let interface_name = String::from(interface_name);
255 Box_::pin(crate::GioFuture::new(
256 &(),
257 move |_obj, cancellable, send| {
258 Self::for_bus(
259 bus_type,
260 flags,
261 info.as_ref().map(::std::borrow::Borrow::borrow),
262 &name,
263 &object_path,
264 &interface_name,
265 Some(cancellable),
266 move |res| {
267 send.resolve(res);
268 },
269 );
270 },
271 ))
272 }
273}
274
275unsafe impl Send for DBusProxy {}
276unsafe impl Sync for DBusProxy {}
277
278pub trait DBusProxyExt: IsA<DBusProxy> + 'static {
279 #[doc(alias = "g_dbus_proxy_call")]
280 fn call<P: FnOnce(Result<glib::Variant, glib::Error>) + 'static>(
281 &self,
282 method_name: &str,
283 parameters: Option<&glib::Variant>,
284 flags: DBusCallFlags,
285 timeout_msec: i32,
286 cancellable: Option<&impl IsA<Cancellable>>,
287 callback: P,
288 ) {
289 let main_context = glib::MainContext::ref_thread_default();
290 let is_main_context_owner = main_context.is_owner();
291 let has_acquired_main_context = (!is_main_context_owner)
292 .then(|| main_context.acquire().ok())
293 .flatten();
294 assert!(
295 is_main_context_owner || has_acquired_main_context.is_some(),
296 "Async operations only allowed if the thread is owning the MainContext"
297 );
298
299 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
300 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
301 unsafe extern "C" fn call_trampoline<
302 P: FnOnce(Result<glib::Variant, glib::Error>) + 'static,
303 >(
304 _source_object: *mut glib::gobject_ffi::GObject,
305 res: *mut crate::ffi::GAsyncResult,
306 user_data: glib::ffi::gpointer,
307 ) {
308 unsafe {
309 let mut error = std::ptr::null_mut();
310 let ret = ffi::g_dbus_proxy_call_finish(_source_object as *mut _, res, &mut error);
311 let result = if error.is_null() {
312 Ok(from_glib_full(ret))
313 } else {
314 Err(from_glib_full(error))
315 };
316 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
317 Box_::from_raw(user_data as *mut _);
318 let callback: P = callback.into_inner();
319 callback(result);
320 }
321 }
322 let callback = call_trampoline::<P>;
323 unsafe {
324 ffi::g_dbus_proxy_call(
325 self.as_ref().to_glib_none().0,
326 method_name.to_glib_none().0,
327 parameters.to_glib_none().0,
328 flags.into_glib(),
329 timeout_msec,
330 cancellable.map(|p| p.as_ref()).to_glib_none().0,
331 Some(callback),
332 Box_::into_raw(user_data) as *mut _,
333 );
334 }
335 }
336
337 fn call_future(
338 &self,
339 method_name: &str,
340 parameters: Option<&glib::Variant>,
341 flags: DBusCallFlags,
342 timeout_msec: i32,
343 ) -> Pin<Box_<dyn std::future::Future<Output = Result<glib::Variant, glib::Error>> + 'static>>
344 {
345 let method_name = String::from(method_name);
346 let parameters = parameters.map(ToOwned::to_owned);
347 Box_::pin(crate::GioFuture::new(
348 self,
349 move |obj, cancellable, send| {
350 obj.call(
351 &method_name,
352 parameters.as_ref().map(::std::borrow::Borrow::borrow),
353 flags,
354 timeout_msec,
355 Some(cancellable),
356 move |res| {
357 send.resolve(res);
358 },
359 );
360 },
361 ))
362 }
363
364 #[doc(alias = "g_dbus_proxy_call_sync")]
365 fn call_sync(
366 &self,
367 method_name: &str,
368 parameters: Option<&glib::Variant>,
369 flags: DBusCallFlags,
370 timeout_msec: i32,
371 cancellable: Option<&impl IsA<Cancellable>>,
372 ) -> Result<glib::Variant, glib::Error> {
373 unsafe {
374 let mut error = std::ptr::null_mut();
375 let ret = ffi::g_dbus_proxy_call_sync(
376 self.as_ref().to_glib_none().0,
377 method_name.to_glib_none().0,
378 parameters.to_glib_none().0,
379 flags.into_glib(),
380 timeout_msec,
381 cancellable.map(|p| p.as_ref()).to_glib_none().0,
382 &mut error,
383 );
384 if error.is_null() {
385 Ok(from_glib_full(ret))
386 } else {
387 Err(from_glib_full(error))
388 }
389 }
390 }
391
392 #[cfg(unix)]
393 #[cfg_attr(docsrs, doc(cfg(unix)))]
394 #[doc(alias = "g_dbus_proxy_call_with_unix_fd_list")]
395 fn call_with_unix_fd_list<
396 P: FnOnce(Result<(glib::Variant, Option<UnixFDList>), glib::Error>) + 'static,
397 >(
398 &self,
399 method_name: &str,
400 parameters: Option<&glib::Variant>,
401 flags: DBusCallFlags,
402 timeout_msec: i32,
403 fd_list: Option<&impl IsA<UnixFDList>>,
404 cancellable: Option<&impl IsA<Cancellable>>,
405 callback: P,
406 ) {
407 let main_context = glib::MainContext::ref_thread_default();
408 let is_main_context_owner = main_context.is_owner();
409 let has_acquired_main_context = (!is_main_context_owner)
410 .then(|| main_context.acquire().ok())
411 .flatten();
412 assert!(
413 is_main_context_owner || has_acquired_main_context.is_some(),
414 "Async operations only allowed if the thread is owning the MainContext"
415 );
416
417 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
418 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
419 unsafe extern "C" fn call_with_unix_fd_list_trampoline<
420 P: FnOnce(Result<(glib::Variant, Option<UnixFDList>), glib::Error>) + 'static,
421 >(
422 _source_object: *mut glib::gobject_ffi::GObject,
423 res: *mut crate::ffi::GAsyncResult,
424 user_data: glib::ffi::gpointer,
425 ) {
426 unsafe {
427 let mut error = std::ptr::null_mut();
428 let mut out_fd_list = std::ptr::null_mut();
429 let ret = ffi::g_dbus_proxy_call_with_unix_fd_list_finish(
430 _source_object as *mut _,
431 &mut out_fd_list,
432 res,
433 &mut error,
434 );
435 let result = if error.is_null() {
436 Ok((from_glib_full(ret), from_glib_full(out_fd_list)))
437 } else {
438 Err(from_glib_full(error))
439 };
440 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
441 Box_::from_raw(user_data as *mut _);
442 let callback: P = callback.into_inner();
443 callback(result);
444 }
445 }
446 let callback = call_with_unix_fd_list_trampoline::<P>;
447 unsafe {
448 ffi::g_dbus_proxy_call_with_unix_fd_list(
449 self.as_ref().to_glib_none().0,
450 method_name.to_glib_none().0,
451 parameters.to_glib_none().0,
452 flags.into_glib(),
453 timeout_msec,
454 fd_list.map(|p| p.as_ref()).to_glib_none().0,
455 cancellable.map(|p| p.as_ref()).to_glib_none().0,
456 Some(callback),
457 Box_::into_raw(user_data) as *mut _,
458 );
459 }
460 }
461
462 #[cfg(unix)]
463 #[cfg_attr(docsrs, doc(cfg(unix)))]
464 fn call_with_unix_fd_list_future(
465 &self,
466 method_name: &str,
467 parameters: Option<&glib::Variant>,
468 flags: DBusCallFlags,
469 timeout_msec: i32,
470 fd_list: Option<&(impl IsA<UnixFDList> + Clone + 'static)>,
471 ) -> Pin<
472 Box_<
473 dyn std::future::Future<
474 Output = Result<(glib::Variant, Option<UnixFDList>), glib::Error>,
475 > + 'static,
476 >,
477 > {
478 let method_name = String::from(method_name);
479 let parameters = parameters.map(ToOwned::to_owned);
480 let fd_list = fd_list.map(ToOwned::to_owned);
481 Box_::pin(crate::GioFuture::new(
482 self,
483 move |obj, cancellable, send| {
484 obj.call_with_unix_fd_list(
485 &method_name,
486 parameters.as_ref().map(::std::borrow::Borrow::borrow),
487 flags,
488 timeout_msec,
489 fd_list.as_ref().map(::std::borrow::Borrow::borrow),
490 Some(cancellable),
491 move |res| {
492 send.resolve(res);
493 },
494 );
495 },
496 ))
497 }
498
499 #[cfg(unix)]
500 #[cfg_attr(docsrs, doc(cfg(unix)))]
501 #[doc(alias = "g_dbus_proxy_call_with_unix_fd_list_sync")]
502 fn call_with_unix_fd_list_sync(
503 &self,
504 method_name: &str,
505 parameters: Option<&glib::Variant>,
506 flags: DBusCallFlags,
507 timeout_msec: i32,
508 fd_list: Option<&impl IsA<UnixFDList>>,
509 cancellable: Option<&impl IsA<Cancellable>>,
510 ) -> Result<(glib::Variant, Option<UnixFDList>), glib::Error> {
511 unsafe {
512 let mut out_fd_list = std::ptr::null_mut();
513 let mut error = std::ptr::null_mut();
514 let ret = ffi::g_dbus_proxy_call_with_unix_fd_list_sync(
515 self.as_ref().to_glib_none().0,
516 method_name.to_glib_none().0,
517 parameters.to_glib_none().0,
518 flags.into_glib(),
519 timeout_msec,
520 fd_list.map(|p| p.as_ref()).to_glib_none().0,
521 &mut out_fd_list,
522 cancellable.map(|p| p.as_ref()).to_glib_none().0,
523 &mut error,
524 );
525 if error.is_null() {
526 Ok((from_glib_full(ret), from_glib_full(out_fd_list)))
527 } else {
528 Err(from_glib_full(error))
529 }
530 }
531 }
532
533 #[doc(alias = "g_dbus_proxy_get_cached_property")]
534 #[doc(alias = "get_cached_property")]
535 fn cached_property(&self, property_name: &str) -> Option<glib::Variant> {
536 unsafe {
537 from_glib_full(ffi::g_dbus_proxy_get_cached_property(
538 self.as_ref().to_glib_none().0,
539 property_name.to_glib_none().0,
540 ))
541 }
542 }
543
544 #[doc(alias = "g_dbus_proxy_get_cached_property_names")]
545 #[doc(alias = "get_cached_property_names")]
546 fn cached_property_names(&self) -> Vec<glib::GString> {
547 unsafe {
548 FromGlibPtrContainer::from_glib_full(ffi::g_dbus_proxy_get_cached_property_names(
549 self.as_ref().to_glib_none().0,
550 ))
551 }
552 }
553
554 #[doc(alias = "g_dbus_proxy_get_connection")]
555 #[doc(alias = "get_connection")]
556 fn connection(&self) -> DBusConnection {
557 unsafe {
558 from_glib_none(ffi::g_dbus_proxy_get_connection(
559 self.as_ref().to_glib_none().0,
560 ))
561 }
562 }
563
564 #[doc(alias = "g_dbus_proxy_get_default_timeout")]
565 #[doc(alias = "get_default_timeout")]
566 fn default_timeout(&self) -> i32 {
567 unsafe { ffi::g_dbus_proxy_get_default_timeout(self.as_ref().to_glib_none().0) }
568 }
569
570 #[doc(alias = "g_dbus_proxy_get_flags")]
571 #[doc(alias = "get_flags")]
572 fn flags(&self) -> DBusProxyFlags {
573 unsafe { from_glib(ffi::g_dbus_proxy_get_flags(self.as_ref().to_glib_none().0)) }
574 }
575
576 #[doc(alias = "g_dbus_proxy_get_interface_info")]
577 #[doc(alias = "get_interface_info")]
578 fn interface_info(&self) -> Option<DBusInterfaceInfo> {
579 unsafe {
580 from_glib_none(ffi::g_dbus_proxy_get_interface_info(
581 self.as_ref().to_glib_none().0,
582 ))
583 }
584 }
585
586 #[doc(alias = "g_dbus_proxy_get_interface_name")]
587 #[doc(alias = "get_interface_name")]
588 fn interface_name(&self) -> glib::GString {
589 unsafe {
590 from_glib_none(ffi::g_dbus_proxy_get_interface_name(
591 self.as_ref().to_glib_none().0,
592 ))
593 }
594 }
595
596 #[doc(alias = "g_dbus_proxy_get_name")]
597 #[doc(alias = "get_name")]
598 fn name(&self) -> Option<glib::GString> {
599 unsafe { from_glib_none(ffi::g_dbus_proxy_get_name(self.as_ref().to_glib_none().0)) }
600 }
601
602 #[doc(alias = "g_dbus_proxy_get_name_owner")]
603 #[doc(alias = "get_name_owner")]
604 fn name_owner(&self) -> Option<glib::GString> {
605 unsafe {
606 from_glib_full(ffi::g_dbus_proxy_get_name_owner(
607 self.as_ref().to_glib_none().0,
608 ))
609 }
610 }
611
612 #[doc(alias = "g_dbus_proxy_get_object_path")]
613 #[doc(alias = "get_object_path")]
614 fn object_path(&self) -> glib::GString {
615 unsafe {
616 from_glib_none(ffi::g_dbus_proxy_get_object_path(
617 self.as_ref().to_glib_none().0,
618 ))
619 }
620 }
621
622 #[doc(alias = "g_dbus_proxy_set_cached_property")]
623 fn set_cached_property(&self, property_name: &str, value: Option<&glib::Variant>) {
624 unsafe {
625 ffi::g_dbus_proxy_set_cached_property(
626 self.as_ref().to_glib_none().0,
627 property_name.to_glib_none().0,
628 value.to_glib_none().0,
629 );
630 }
631 }
632
633 #[doc(alias = "g_dbus_proxy_set_default_timeout")]
634 fn set_default_timeout(&self, timeout_msec: i32) {
635 unsafe {
636 ffi::g_dbus_proxy_set_default_timeout(self.as_ref().to_glib_none().0, timeout_msec);
637 }
638 }
639
640 #[doc(alias = "g_dbus_proxy_set_interface_info")]
641 fn set_interface_info(&self, info: Option<&DBusInterfaceInfo>) {
642 unsafe {
643 ffi::g_dbus_proxy_set_interface_info(
644 self.as_ref().to_glib_none().0,
645 info.to_glib_none().0,
646 );
647 }
648 }
649
650 #[doc(alias = "g-connection")]
651 fn g_connection(&self) -> Option<DBusConnection> {
652 ObjectExt::property(self.as_ref(), "g-connection")
653 }
654
655 #[doc(alias = "g-default-timeout")]
656 fn g_default_timeout(&self) -> i32 {
657 ObjectExt::property(self.as_ref(), "g-default-timeout")
658 }
659
660 #[doc(alias = "g-default-timeout")]
661 fn set_g_default_timeout(&self, g_default_timeout: i32) {
662 ObjectExt::set_property(self.as_ref(), "g-default-timeout", g_default_timeout)
663 }
664
665 #[doc(alias = "g-flags")]
666 fn g_flags(&self) -> DBusProxyFlags {
667 ObjectExt::property(self.as_ref(), "g-flags")
668 }
669
670 #[doc(alias = "g-interface-info")]
671 fn g_interface_info(&self) -> Option<DBusInterfaceInfo> {
672 ObjectExt::property(self.as_ref(), "g-interface-info")
673 }
674
675 #[doc(alias = "g-interface-info")]
676 fn set_g_interface_info(&self, g_interface_info: Option<&DBusInterfaceInfo>) {
677 ObjectExt::set_property(self.as_ref(), "g-interface-info", g_interface_info)
678 }
679
680 #[doc(alias = "g-interface-name")]
681 fn g_interface_name(&self) -> Option<glib::GString> {
682 ObjectExt::property(self.as_ref(), "g-interface-name")
683 }
684
685 #[doc(alias = "g-name")]
686 fn g_name(&self) -> Option<glib::GString> {
687 ObjectExt::property(self.as_ref(), "g-name")
688 }
689
690 #[doc(alias = "g-name-owner")]
691 fn g_name_owner(&self) -> Option<glib::GString> {
692 ObjectExt::property(self.as_ref(), "g-name-owner")
693 }
694
695 #[doc(alias = "g-object-path")]
696 fn g_object_path(&self) -> Option<glib::GString> {
697 ObjectExt::property(self.as_ref(), "g-object-path")
698 }
699
700 #[doc(alias = "g-default-timeout")]
701 fn connect_g_default_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
702 &self,
703 f: F,
704 ) -> SignalHandlerId {
705 unsafe extern "C" fn notify_g_default_timeout_trampoline<
706 P: IsA<DBusProxy>,
707 F: Fn(&P) + Send + Sync + 'static,
708 >(
709 this: *mut ffi::GDBusProxy,
710 _param_spec: glib::ffi::gpointer,
711 f: glib::ffi::gpointer,
712 ) {
713 unsafe {
714 let f: &F = &*(f as *const F);
715 f(DBusProxy::from_glib_borrow(this).unsafe_cast_ref())
716 }
717 }
718 unsafe {
719 let f: Box_<F> = Box_::new(f);
720 connect_raw(
721 self.as_ptr() as *mut _,
722 c"notify::g-default-timeout".as_ptr(),
723 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
724 notify_g_default_timeout_trampoline::<Self, F> as *const (),
725 )),
726 Box_::into_raw(f),
727 )
728 }
729 }
730
731 #[doc(alias = "g-interface-info")]
732 fn connect_g_interface_info_notify<F: Fn(&Self) + Send + Sync + 'static>(
733 &self,
734 f: F,
735 ) -> SignalHandlerId {
736 unsafe extern "C" fn notify_g_interface_info_trampoline<
737 P: IsA<DBusProxy>,
738 F: Fn(&P) + Send + Sync + 'static,
739 >(
740 this: *mut ffi::GDBusProxy,
741 _param_spec: glib::ffi::gpointer,
742 f: glib::ffi::gpointer,
743 ) {
744 unsafe {
745 let f: &F = &*(f as *const F);
746 f(DBusProxy::from_glib_borrow(this).unsafe_cast_ref())
747 }
748 }
749 unsafe {
750 let f: Box_<F> = Box_::new(f);
751 connect_raw(
752 self.as_ptr() as *mut _,
753 c"notify::g-interface-info".as_ptr(),
754 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
755 notify_g_interface_info_trampoline::<Self, F> as *const (),
756 )),
757 Box_::into_raw(f),
758 )
759 }
760 }
761
762 #[doc(alias = "g-name-owner")]
763 fn connect_g_name_owner_notify<F: Fn(&Self) + Send + Sync + 'static>(
764 &self,
765 f: F,
766 ) -> SignalHandlerId {
767 unsafe extern "C" fn notify_g_name_owner_trampoline<
768 P: IsA<DBusProxy>,
769 F: Fn(&P) + Send + Sync + 'static,
770 >(
771 this: *mut ffi::GDBusProxy,
772 _param_spec: glib::ffi::gpointer,
773 f: glib::ffi::gpointer,
774 ) {
775 unsafe {
776 let f: &F = &*(f as *const F);
777 f(DBusProxy::from_glib_borrow(this).unsafe_cast_ref())
778 }
779 }
780 unsafe {
781 let f: Box_<F> = Box_::new(f);
782 connect_raw(
783 self.as_ptr() as *mut _,
784 c"notify::g-name-owner".as_ptr(),
785 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
786 notify_g_name_owner_trampoline::<Self, F> as *const (),
787 )),
788 Box_::into_raw(f),
789 )
790 }
791 }
792}
793
794impl<O: IsA<DBusProxy>> DBusProxyExt for O {}