gio/auto/dbus_proxy.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
5#[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 /// `GDBusProxy` is a base class used for proxies to access a D-Bus
21 /// interface on a remote object. A `GDBusProxy` can be constructed for
22 /// both well-known and unique names.
23 ///
24 /// By default, `GDBusProxy` will cache all properties (and listen to
25 /// changes) of the remote object, and proxy all signals that get
26 /// emitted. This behaviour can be changed by passing suitable
27 /// [`DBusProxyFlags`][crate::DBusProxyFlags] when the proxy is created. If the proxy is for a
28 /// well-known name, the property cache is flushed when the name owner
29 /// vanishes and reloaded when a name owner appears.
30 ///
31 /// The unique name owner of the proxy’s name is tracked and can be read from
32 /// [`g-name-owner`][struct@crate::DBusProxy#g-name-owner]. Connect to the
33 /// [`notify`][struct@crate::glib::Object#notify] signal to get notified of changes.
34 /// Additionally, only signals and property changes emitted from the current name
35 /// owner are considered and calls are always sent to the current name owner.
36 /// This avoids a number of race conditions when the name is lost by one owner
37 /// and claimed by another. However, if no name owner currently exists,
38 /// then calls will be sent to the well-known name which may result in
39 /// the message bus launching an owner (unless
40 /// `G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START` is set).
41 ///
42 /// If the proxy is for a stateless D-Bus service, where the name owner may
43 /// be started and stopped between calls, the
44 /// [`g-name-owner`][struct@crate::DBusProxy#g-name-owner] tracking of `GDBusProxy` will cause the
45 /// proxy to drop signal and property changes from the service after it has
46 /// restarted for the first time. When interacting with a stateless D-Bus
47 /// service, do not use `GDBusProxy` — use direct D-Bus method calls and signal
48 /// connections.
49 ///
50 /// The generic [`g-properties-changed`][struct@crate::DBusProxy#g-properties-changed] and
51 /// [`g-signal`][struct@crate::DBusProxy#g-signal] signals are not very convenient to work
52 /// with. Therefore, the recommended way of working with proxies is to subclass
53 /// `GDBusProxy`, and have more natural properties and signals in your derived
54 /// class. This [example](migrating-gdbus.html#using-gdbus-codegen) shows how
55 /// this can easily be done using the [`gdbus-codegen`](gdbus-codegen.html) tool.
56 ///
57 /// A `GDBusProxy` instance can be used from multiple threads but note
58 /// that all signals (e.g. [`g-signal`][struct@crate::DBusProxy#g-signal],
59 /// [`g-properties-changed`][struct@crate::DBusProxy#g-properties-changed] and
60 /// [`notify`][struct@crate::glib::Object#notify]) are emitted in the thread-default main
61 /// context (see [`glib::MainContext::push_thread_default()`][crate::glib::MainContext::push_thread_default()]) of the thread
62 /// where the instance was constructed.
63 ///
64 ///
65 /// ## A watch proxy example
66 /// An example using a proxy for a well-known name can be found in
67 /// [`gdbus-example-watch-proxy.c`](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gdbus-example-watch-proxy.c).
68 ///
69 /// ## Properties
70 ///
71 ///
72 /// #### `g-bus-type`
73 /// If this property is not [`BusType::None`][crate::BusType::None], then
74 /// #GDBusProxy:g-connection must be [`None`] and will be set to the
75 /// #GDBusConnection obtained by calling g_bus_get() with the value
76 /// of this property.
77 ///
78 /// Writable | Construct Only
79 ///
80 ///
81 /// #### `g-connection`
82 /// The #GDBusConnection the proxy is for.
83 ///
84 /// Readable | Writable | Construct Only
85 ///
86 ///
87 /// #### `g-default-timeout`
88 /// The timeout to use if -1 (specifying default timeout) is passed
89 /// as @timeout_msec in the g_dbus_proxy_call() and
90 /// g_dbus_proxy_call_sync() functions.
91 ///
92 /// This allows applications to set a proxy-wide timeout for all
93 /// remote method invocations on the proxy. If this property is -1,
94 /// the default timeout (typically 25 seconds) is used. If set to
95 /// `G_MAXINT`, then no timeout is used.
96 ///
97 /// Readable | Writable | Construct
98 ///
99 ///
100 /// #### `g-flags`
101 /// Flags from the #GDBusProxyFlags enumeration.
102 ///
103 /// Readable | Writable | Construct Only
104 ///
105 ///
106 /// #### `g-interface-info`
107 /// Ensure that interactions with this proxy conform to the given
108 /// interface. This is mainly to ensure that malformed data received
109 /// from the other peer is ignored. The given #GDBusInterfaceInfo is
110 /// said to be the "expected interface".
111 ///
112 /// The checks performed are:
113 /// - When completing a method call, if the type signature of
114 /// the reply message isn't what's expected, the reply is
115 /// discarded and the #GError is set to [`IOErrorEnum::InvalidArgument`][crate::IOErrorEnum::InvalidArgument].
116 ///
117 /// - Received signals that have a type signature mismatch are dropped and
118 /// a warning is logged via g_warning().
119 ///
120 /// - Properties received via the initial `GetAll()` call or via the
121 /// `::PropertiesChanged` signal (on the
122 /// [org.freedesktop.DBus.Properties](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties)
123 /// interface) or set using g_dbus_proxy_set_cached_property()
124 /// with a type signature mismatch are ignored and a warning is
125 /// logged via g_warning().
126 ///
127 /// Note that these checks are never done on methods, signals and
128 /// properties that are not referenced in the given
129 /// #GDBusInterfaceInfo, since extending a D-Bus interface on the
130 /// service-side is not considered an ABI break.
131 ///
132 /// Readable | Writable
133 ///
134 ///
135 /// #### `g-interface-name`
136 /// The D-Bus interface name the proxy is for.
137 ///
138 /// Readable | Writable | Construct Only
139 ///
140 ///
141 /// #### `g-name`
142 /// The well-known or unique name that the proxy is for.
143 ///
144 /// Readable | Writable | Construct Only
145 ///
146 ///
147 /// #### `g-name-owner`
148 /// The unique name that owns #GDBusProxy:g-name or [`None`] if no-one
149 /// currently owns that name. You may connect to #GObject::notify signal to
150 /// track changes to this property.
151 ///
152 /// Readable
153 ///
154 ///
155 /// #### `g-object-path`
156 /// The object path the proxy is for.
157 ///
158 /// Readable | Writable | Construct Only
159 ///
160 /// ## Signals
161 ///
162 ///
163 /// #### `g-properties-changed`
164 /// Emitted when one or more D-Bus properties on @proxy changes. The
165 /// local cache has already been updated when this signal fires. Note
166 /// that both @changed_properties and @invalidated_properties are
167 /// guaranteed to never be [`None`] (either may be empty though).
168 ///
169 /// If the proxy has the flag
170 /// [`DBusProxyFlags::GET_INVALIDATED_PROPERTIES`][crate::DBusProxyFlags::GET_INVALIDATED_PROPERTIES] set, then
171 /// @invalidated_properties will always be empty.
172 ///
173 /// This signal corresponds to the
174 /// `PropertiesChanged` D-Bus signal on the
175 /// `org.freedesktop.DBus.Properties` interface.
176 ///
177 ///
178 ///
179 ///
180 /// #### `g-signal`
181 /// Emitted when a signal from the remote object and interface that @proxy is for, has been received.
182 ///
183 /// Since 2.72 this signal supports detailed connections. You can connect to
184 /// the detailed signal `g-signal::x` in order to receive callbacks only when
185 /// signal `x` is received from the remote object.
186 ///
187 /// Detailed
188 ///
189 /// # Implements
190 ///
191 /// [`DBusProxyExt`][trait@crate::prelude::DBusProxyExt], [`trait@glib::ObjectExt`], [`AsyncInitableExt`][trait@crate::prelude::AsyncInitableExt], [`DBusInterfaceExt`][trait@crate::prelude::DBusInterfaceExt], [`InitableExt`][trait@crate::prelude::InitableExt], [`DBusProxyExtManual`][trait@crate::prelude::DBusProxyExtManual]
192 #[doc(alias = "GDBusProxy")]
193 pub struct DBusProxy(Object<ffi::GDBusProxy, ffi::GDBusProxyClass>) @implements AsyncInitable, DBusInterface, Initable;
194
195 match fn {
196 type_ => || ffi::g_dbus_proxy_get_type(),
197 }
198}
199
200impl DBusProxy {
201 pub const NONE: Option<&'static DBusProxy> = None;
202
203 /// Like g_dbus_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
204 ///
205 /// #GDBusProxy is used in this [example][`DBusProxy`][crate::DBusProxy]#a-watch-proxy-example].
206 /// ## `bus_type`
207 /// A #GBusType.
208 /// ## `flags`
209 /// Flags used when constructing the proxy.
210 /// ## `info`
211 /// A #GDBusInterfaceInfo specifying the minimal interface
212 /// that @proxy conforms to or [`None`].
213 /// ## `name`
214 /// A bus name (well-known or unique).
215 /// ## `object_path`
216 /// An object path.
217 /// ## `interface_name`
218 /// A D-Bus interface name.
219 /// ## `cancellable`
220 /// A #GCancellable or [`None`].
221 ///
222 /// # Returns
223 ///
224 /// A #GDBusProxy or [`None`] if error is set.
225 /// Free with g_object_unref().
226 #[doc(alias = "g_dbus_proxy_new_for_bus_sync")]
227 #[doc(alias = "new_for_bus_sync")]
228 pub fn for_bus_sync(
229 bus_type: BusType,
230 flags: DBusProxyFlags,
231 info: Option<&DBusInterfaceInfo>,
232 name: &str,
233 object_path: &str,
234 interface_name: &str,
235 cancellable: Option<&impl IsA<Cancellable>>,
236 ) -> Result<DBusProxy, glib::Error> {
237 unsafe {
238 let mut error = std::ptr::null_mut();
239 let ret = ffi::g_dbus_proxy_new_for_bus_sync(
240 bus_type.into_glib(),
241 flags.into_glib(),
242 info.to_glib_none().0,
243 name.to_glib_none().0,
244 object_path.to_glib_none().0,
245 interface_name.to_glib_none().0,
246 cancellable.map(|p| p.as_ref()).to_glib_none().0,
247 &mut error,
248 );
249 if error.is_null() {
250 Ok(from_glib_full(ret))
251 } else {
252 Err(from_glib_full(error))
253 }
254 }
255 }
256
257 /// Creates a proxy for accessing @interface_name on the remote object
258 /// at @object_path owned by @name at @connection and synchronously
259 /// loads D-Bus properties unless the
260 /// [`DBusProxyFlags::DO_NOT_LOAD_PROPERTIES`][crate::DBusProxyFlags::DO_NOT_LOAD_PROPERTIES] flag is used.
261 ///
262 /// If the [`DBusProxyFlags::DO_NOT_CONNECT_SIGNALS`][crate::DBusProxyFlags::DO_NOT_CONNECT_SIGNALS] flag is not set, also sets up
263 /// match rules for signals. Connect to the #GDBusProxy::g-signal signal
264 /// to handle signals from the remote object.
265 ///
266 /// If both [`DBusProxyFlags::DO_NOT_LOAD_PROPERTIES`][crate::DBusProxyFlags::DO_NOT_LOAD_PROPERTIES] and
267 /// [`DBusProxyFlags::DO_NOT_CONNECT_SIGNALS`][crate::DBusProxyFlags::DO_NOT_CONNECT_SIGNALS] are set, this constructor is
268 /// guaranteed to return immediately without blocking.
269 ///
270 /// If @name is a well-known name and the
271 /// [`DBusProxyFlags::DO_NOT_AUTO_START`][crate::DBusProxyFlags::DO_NOT_AUTO_START] and [`DBusProxyFlags::DO_NOT_AUTO_START_AT_CONSTRUCTION`][crate::DBusProxyFlags::DO_NOT_AUTO_START_AT_CONSTRUCTION]
272 /// flags aren't set and no name owner currently exists, the message bus
273 /// will be requested to launch a name owner for the name.
274 ///
275 /// This is a synchronous failable constructor. See g_dbus_proxy_new()
276 /// and g_dbus_proxy_new_finish() for the asynchronous version.
277 ///
278 /// #GDBusProxy is used in this [example][`DBusProxy`][crate::DBusProxy]#a-watch-proxy-example].
279 /// ## `connection`
280 /// A #GDBusConnection.
281 /// ## `flags`
282 /// Flags used when constructing the proxy.
283 /// ## `info`
284 /// A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or [`None`].
285 /// ## `name`
286 /// A bus name (well-known or unique) or [`None`] if @connection is not a message bus connection.
287 /// ## `object_path`
288 /// An object path.
289 /// ## `interface_name`
290 /// A D-Bus interface name.
291 /// ## `cancellable`
292 /// A #GCancellable or [`None`].
293 ///
294 /// # Returns
295 ///
296 /// A #GDBusProxy or [`None`] if error is set.
297 /// Free with g_object_unref().
298 #[doc(alias = "g_dbus_proxy_new_sync")]
299 pub fn new_sync(
300 connection: &DBusConnection,
301 flags: DBusProxyFlags,
302 info: Option<&DBusInterfaceInfo>,
303 name: Option<&str>,
304 object_path: &str,
305 interface_name: &str,
306 cancellable: Option<&impl IsA<Cancellable>>,
307 ) -> Result<DBusProxy, glib::Error> {
308 unsafe {
309 let mut error = std::ptr::null_mut();
310 let ret = ffi::g_dbus_proxy_new_sync(
311 connection.to_glib_none().0,
312 flags.into_glib(),
313 info.to_glib_none().0,
314 name.to_glib_none().0,
315 object_path.to_glib_none().0,
316 interface_name.to_glib_none().0,
317 cancellable.map(|p| p.as_ref()).to_glib_none().0,
318 &mut error,
319 );
320 if error.is_null() {
321 Ok(from_glib_full(ret))
322 } else {
323 Err(from_glib_full(error))
324 }
325 }
326 }
327
328 /// Creates a proxy for accessing @interface_name on the remote object
329 /// at @object_path owned by @name at @connection and asynchronously
330 /// loads D-Bus properties unless the
331 /// [`DBusProxyFlags::DO_NOT_LOAD_PROPERTIES`][crate::DBusProxyFlags::DO_NOT_LOAD_PROPERTIES] flag is used. Connect to
332 /// the #GDBusProxy::g-properties-changed signal to get notified about
333 /// property changes.
334 ///
335 /// If the [`DBusProxyFlags::DO_NOT_CONNECT_SIGNALS`][crate::DBusProxyFlags::DO_NOT_CONNECT_SIGNALS] flag is not set, also sets up
336 /// match rules for signals. Connect to the #GDBusProxy::g-signal signal
337 /// to handle signals from the remote object.
338 ///
339 /// If both [`DBusProxyFlags::DO_NOT_LOAD_PROPERTIES`][crate::DBusProxyFlags::DO_NOT_LOAD_PROPERTIES] and
340 /// [`DBusProxyFlags::DO_NOT_CONNECT_SIGNALS`][crate::DBusProxyFlags::DO_NOT_CONNECT_SIGNALS] are set, this constructor is
341 /// guaranteed to complete immediately without blocking.
342 ///
343 /// If @name is a well-known name and the
344 /// [`DBusProxyFlags::DO_NOT_AUTO_START`][crate::DBusProxyFlags::DO_NOT_AUTO_START] and [`DBusProxyFlags::DO_NOT_AUTO_START_AT_CONSTRUCTION`][crate::DBusProxyFlags::DO_NOT_AUTO_START_AT_CONSTRUCTION]
345 /// flags aren't set and no name owner currently exists, the message bus
346 /// will be requested to launch a name owner for the name.
347 ///
348 /// This is a failable asynchronous constructor - when the proxy is
349 /// ready, @callback will be invoked and you can use
350 /// g_dbus_proxy_new_finish() to get the result.
351 ///
352 /// See g_dbus_proxy_new_sync() and for a synchronous version of this constructor.
353 ///
354 /// #GDBusProxy is used in this [example][`DBusProxy`][crate::DBusProxy]#a-watch-proxy-example].
355 /// ## `connection`
356 /// A #GDBusConnection.
357 /// ## `flags`
358 /// Flags used when constructing the proxy.
359 /// ## `info`
360 /// A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or [`None`].
361 /// ## `name`
362 /// A bus name (well-known or unique) or [`None`] if @connection is not a message bus connection.
363 /// ## `object_path`
364 /// An object path.
365 /// ## `interface_name`
366 /// A D-Bus interface name.
367 /// ## `cancellable`
368 /// A #GCancellable or [`None`].
369 /// ## `callback`
370 /// Callback function to invoke when the proxy is ready.
371 #[doc(alias = "g_dbus_proxy_new")]
372 pub fn new<P: FnOnce(Result<DBusProxy, glib::Error>) + 'static>(
373 connection: &DBusConnection,
374 flags: DBusProxyFlags,
375 info: Option<&DBusInterfaceInfo>,
376 name: Option<&str>,
377 object_path: &str,
378 interface_name: &str,
379 cancellable: Option<&impl IsA<Cancellable>>,
380 callback: P,
381 ) {
382 let main_context = glib::MainContext::ref_thread_default();
383 let is_main_context_owner = main_context.is_owner();
384 let has_acquired_main_context = (!is_main_context_owner)
385 .then(|| main_context.acquire().ok())
386 .flatten();
387 assert!(
388 is_main_context_owner || has_acquired_main_context.is_some(),
389 "Async operations only allowed if the thread is owning the MainContext"
390 );
391
392 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
393 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
394 unsafe extern "C" fn new_trampoline<P: FnOnce(Result<DBusProxy, glib::Error>) + 'static>(
395 _source_object: *mut glib::gobject_ffi::GObject,
396 res: *mut crate::ffi::GAsyncResult,
397 user_data: glib::ffi::gpointer,
398 ) {
399 unsafe {
400 let mut error = std::ptr::null_mut();
401 let ret = ffi::g_dbus_proxy_new_finish(res, &mut error);
402 let result = if error.is_null() {
403 Ok(from_glib_full(ret))
404 } else {
405 Err(from_glib_full(error))
406 };
407 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
408 Box_::from_raw(user_data as *mut _);
409 let callback: P = callback.into_inner();
410 callback(result);
411 }
412 }
413 let callback = new_trampoline::<P>;
414 unsafe {
415 ffi::g_dbus_proxy_new(
416 connection.to_glib_none().0,
417 flags.into_glib(),
418 info.to_glib_none().0,
419 name.to_glib_none().0,
420 object_path.to_glib_none().0,
421 interface_name.to_glib_none().0,
422 cancellable.map(|p| p.as_ref()).to_glib_none().0,
423 Some(callback),
424 Box_::into_raw(user_data) as *mut _,
425 );
426 }
427 }
428
429 pub fn new_future(
430 connection: &DBusConnection,
431 flags: DBusProxyFlags,
432 info: Option<&DBusInterfaceInfo>,
433 name: Option<&str>,
434 object_path: &str,
435 interface_name: &str,
436 ) -> Pin<Box_<dyn std::future::Future<Output = Result<DBusProxy, glib::Error>> + 'static>> {
437 let connection = connection.clone();
438 let info = info.map(ToOwned::to_owned);
439 let name = name.map(ToOwned::to_owned);
440 let object_path = String::from(object_path);
441 let interface_name = String::from(interface_name);
442 Box_::pin(crate::GioFuture::new(
443 &(),
444 move |_obj, cancellable, send| {
445 Self::new(
446 &connection,
447 flags,
448 info.as_ref().map(::std::borrow::Borrow::borrow),
449 name.as_ref().map(::std::borrow::Borrow::borrow),
450 &object_path,
451 &interface_name,
452 Some(cancellable),
453 move |res| {
454 send.resolve(res);
455 },
456 );
457 },
458 ))
459 }
460
461 /// Like g_dbus_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
462 ///
463 /// #GDBusProxy is used in this [example][`DBusProxy`][crate::DBusProxy]#a-watch-proxy-example].
464 /// ## `bus_type`
465 /// A #GBusType.
466 /// ## `flags`
467 /// Flags used when constructing the proxy.
468 /// ## `info`
469 /// A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or [`None`].
470 /// ## `name`
471 /// A bus name (well-known or unique).
472 /// ## `object_path`
473 /// An object path.
474 /// ## `interface_name`
475 /// A D-Bus interface name.
476 /// ## `cancellable`
477 /// A #GCancellable or [`None`].
478 /// ## `callback`
479 /// Callback function to invoke when the proxy is ready.
480 #[doc(alias = "g_dbus_proxy_new_for_bus")]
481 #[doc(alias = "new_for_bus")]
482 pub fn for_bus<P: FnOnce(Result<DBusProxy, glib::Error>) + 'static>(
483 bus_type: BusType,
484 flags: DBusProxyFlags,
485 info: Option<&DBusInterfaceInfo>,
486 name: &str,
487 object_path: &str,
488 interface_name: &str,
489 cancellable: Option<&impl IsA<Cancellable>>,
490 callback: P,
491 ) {
492 let main_context = glib::MainContext::ref_thread_default();
493 let is_main_context_owner = main_context.is_owner();
494 let has_acquired_main_context = (!is_main_context_owner)
495 .then(|| main_context.acquire().ok())
496 .flatten();
497 assert!(
498 is_main_context_owner || has_acquired_main_context.is_some(),
499 "Async operations only allowed if the thread is owning the MainContext"
500 );
501
502 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
503 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
504 unsafe extern "C" fn for_bus_trampoline<
505 P: FnOnce(Result<DBusProxy, glib::Error>) + 'static,
506 >(
507 _source_object: *mut glib::gobject_ffi::GObject,
508 res: *mut crate::ffi::GAsyncResult,
509 user_data: glib::ffi::gpointer,
510 ) {
511 unsafe {
512 let mut error = std::ptr::null_mut();
513 let ret = ffi::g_dbus_proxy_new_for_bus_finish(res, &mut error);
514 let result = if error.is_null() {
515 Ok(from_glib_full(ret))
516 } else {
517 Err(from_glib_full(error))
518 };
519 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
520 Box_::from_raw(user_data as *mut _);
521 let callback: P = callback.into_inner();
522 callback(result);
523 }
524 }
525 let callback = for_bus_trampoline::<P>;
526 unsafe {
527 ffi::g_dbus_proxy_new_for_bus(
528 bus_type.into_glib(),
529 flags.into_glib(),
530 info.to_glib_none().0,
531 name.to_glib_none().0,
532 object_path.to_glib_none().0,
533 interface_name.to_glib_none().0,
534 cancellable.map(|p| p.as_ref()).to_glib_none().0,
535 Some(callback),
536 Box_::into_raw(user_data) as *mut _,
537 );
538 }
539 }
540
541 pub fn for_bus_future(
542 bus_type: BusType,
543 flags: DBusProxyFlags,
544 info: Option<&DBusInterfaceInfo>,
545 name: &str,
546 object_path: &str,
547 interface_name: &str,
548 ) -> Pin<Box_<dyn std::future::Future<Output = Result<DBusProxy, glib::Error>> + 'static>> {
549 let info = info.map(ToOwned::to_owned);
550 let name = String::from(name);
551 let object_path = String::from(object_path);
552 let interface_name = String::from(interface_name);
553 Box_::pin(crate::GioFuture::new(
554 &(),
555 move |_obj, cancellable, send| {
556 Self::for_bus(
557 bus_type,
558 flags,
559 info.as_ref().map(::std::borrow::Borrow::borrow),
560 &name,
561 &object_path,
562 &interface_name,
563 Some(cancellable),
564 move |res| {
565 send.resolve(res);
566 },
567 );
568 },
569 ))
570 }
571}
572
573unsafe impl Send for DBusProxy {}
574unsafe impl Sync for DBusProxy {}
575
576/// Trait containing all [`struct@DBusProxy`] methods.
577///
578/// # Implementors
579///
580/// [`DBusProxy`][struct@crate::DBusProxy]
581pub trait DBusProxyExt: IsA<DBusProxy> + 'static {
582 /// data);
583 /// ]|
584 ///
585 /// If @self has an expected interface (see
586 /// #GDBusProxy:g-interface-info) and @method_name is referenced by it,
587 /// then the return value is checked against the return type.
588 ///
589 /// This is an asynchronous method. When the operation is finished,
590 /// @callback will be invoked in the thread-default main context
591 /// (see [`glib::MainContext::push_thread_default()`][crate::glib::MainContext::push_thread_default()])
592 /// of the thread you are calling this method from.
593 /// You can then call g_dbus_proxy_call_finish() to get the result of
594 /// the operation. See g_dbus_proxy_call_sync() for the synchronous
595 /// version of this method.
596 ///
597 /// If @callback is [`None`] then the D-Bus method call message will be sent with
598 /// the [`DBusMessageFlags::NO_REPLY_EXPECTED`][crate::DBusMessageFlags::NO_REPLY_EXPECTED] flag set.
599 /// ## `method_name`
600 /// Name of method to invoke.
601 /// ## `parameters`
602 /// A #GVariant tuple with parameters for the signal or [`None`] if not passing parameters.
603 /// ## `flags`
604 /// Flags from the #GDBusCallFlags enumeration.
605 /// ## `timeout_msec`
606 /// The timeout in milliseconds (with `G_MAXINT` meaning
607 /// "infinite") or -1 to use the proxy default timeout.
608 /// ## `cancellable`
609 /// A #GCancellable or [`None`].
610 /// ## `callback`
611 /// A #GAsyncReadyCallback to call when the request is satisfied or [`None`] if you don't
612 /// care about the result of the method invocation.
613 #[doc(alias = "g_dbus_proxy_call")]
614 fn call<P: FnOnce(Result<glib::Variant, glib::Error>) + 'static>(
615 &self,
616 method_name: &str,
617 parameters: Option<&glib::Variant>,
618 flags: DBusCallFlags,
619 timeout_msec: i32,
620 cancellable: Option<&impl IsA<Cancellable>>,
621 callback: P,
622 ) {
623 let main_context = glib::MainContext::ref_thread_default();
624 let is_main_context_owner = main_context.is_owner();
625 let has_acquired_main_context = (!is_main_context_owner)
626 .then(|| main_context.acquire().ok())
627 .flatten();
628 assert!(
629 is_main_context_owner || has_acquired_main_context.is_some(),
630 "Async operations only allowed if the thread is owning the MainContext"
631 );
632
633 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
634 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
635 unsafe extern "C" fn call_trampoline<
636 P: FnOnce(Result<glib::Variant, glib::Error>) + 'static,
637 >(
638 _source_object: *mut glib::gobject_ffi::GObject,
639 res: *mut crate::ffi::GAsyncResult,
640 user_data: glib::ffi::gpointer,
641 ) {
642 unsafe {
643 let mut error = std::ptr::null_mut();
644 let ret = ffi::g_dbus_proxy_call_finish(_source_object as *mut _, res, &mut error);
645 let result = if error.is_null() {
646 Ok(from_glib_full(ret))
647 } else {
648 Err(from_glib_full(error))
649 };
650 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
651 Box_::from_raw(user_data as *mut _);
652 let callback: P = callback.into_inner();
653 callback(result);
654 }
655 }
656 let callback = call_trampoline::<P>;
657 unsafe {
658 ffi::g_dbus_proxy_call(
659 self.as_ref().to_glib_none().0,
660 method_name.to_glib_none().0,
661 parameters.to_glib_none().0,
662 flags.into_glib(),
663 timeout_msec,
664 cancellable.map(|p| p.as_ref()).to_glib_none().0,
665 Some(callback),
666 Box_::into_raw(user_data) as *mut _,
667 );
668 }
669 }
670
671 fn call_future(
672 &self,
673 method_name: &str,
674 parameters: Option<&glib::Variant>,
675 flags: DBusCallFlags,
676 timeout_msec: i32,
677 ) -> Pin<Box_<dyn std::future::Future<Output = Result<glib::Variant, glib::Error>> + 'static>>
678 {
679 let method_name = String::from(method_name);
680 let parameters = parameters.map(ToOwned::to_owned);
681 Box_::pin(crate::GioFuture::new(
682 self,
683 move |obj, cancellable, send| {
684 obj.call(
685 &method_name,
686 parameters.as_ref().map(::std::borrow::Borrow::borrow),
687 flags,
688 timeout_msec,
689 Some(cancellable),
690 move |res| {
691 send.resolve(res);
692 },
693 );
694 },
695 ))
696 }
697
698 /// error);
699 /// ]|
700 ///
701 /// The calling thread is blocked until a reply is received. See
702 /// g_dbus_proxy_call() for the asynchronous version of this
703 /// method.
704 ///
705 /// If @self has an expected interface (see
706 /// #GDBusProxy:g-interface-info) and @method_name is referenced by it,
707 /// then the return value is checked against the return type.
708 /// ## `method_name`
709 /// Name of method to invoke.
710 /// ## `parameters`
711 /// A #GVariant tuple with parameters for the signal
712 /// or [`None`] if not passing parameters.
713 /// ## `flags`
714 /// Flags from the #GDBusCallFlags enumeration.
715 /// ## `timeout_msec`
716 /// The timeout in milliseconds (with `G_MAXINT` meaning
717 /// "infinite") or -1 to use the proxy default timeout.
718 /// ## `cancellable`
719 /// A #GCancellable or [`None`].
720 ///
721 /// # Returns
722 ///
723 /// [`None`] if @error is set. Otherwise a #GVariant tuple with
724 /// return values. Free with g_variant_unref().
725 #[doc(alias = "g_dbus_proxy_call_sync")]
726 fn call_sync(
727 &self,
728 method_name: &str,
729 parameters: Option<&glib::Variant>,
730 flags: DBusCallFlags,
731 timeout_msec: i32,
732 cancellable: Option<&impl IsA<Cancellable>>,
733 ) -> Result<glib::Variant, glib::Error> {
734 unsafe {
735 let mut error = std::ptr::null_mut();
736 let ret = ffi::g_dbus_proxy_call_sync(
737 self.as_ref().to_glib_none().0,
738 method_name.to_glib_none().0,
739 parameters.to_glib_none().0,
740 flags.into_glib(),
741 timeout_msec,
742 cancellable.map(|p| p.as_ref()).to_glib_none().0,
743 &mut error,
744 );
745 if error.is_null() {
746 Ok(from_glib_full(ret))
747 } else {
748 Err(from_glib_full(error))
749 }
750 }
751 }
752
753 /// Like g_dbus_proxy_call() but also takes a #GUnixFDList object.
754 ///
755 /// This method is only available on UNIX.
756 /// ## `method_name`
757 /// Name of method to invoke.
758 /// ## `parameters`
759 /// A #GVariant tuple with parameters for the signal or [`None`] if not passing parameters.
760 /// ## `flags`
761 /// Flags from the #GDBusCallFlags enumeration.
762 /// ## `timeout_msec`
763 /// The timeout in milliseconds (with `G_MAXINT` meaning
764 /// "infinite") or -1 to use the proxy default timeout.
765 /// ## `fd_list`
766 /// A #GUnixFDList or [`None`].
767 /// ## `cancellable`
768 /// A #GCancellable or [`None`].
769 /// ## `callback`
770 /// A #GAsyncReadyCallback to call when the request is satisfied or [`None`] if you don't
771 /// care about the result of the method invocation.
772 #[cfg(unix)]
773 #[cfg_attr(docsrs, doc(cfg(unix)))]
774 #[doc(alias = "g_dbus_proxy_call_with_unix_fd_list")]
775 fn call_with_unix_fd_list<
776 P: FnOnce(Result<(glib::Variant, Option<UnixFDList>), glib::Error>) + 'static,
777 >(
778 &self,
779 method_name: &str,
780 parameters: Option<&glib::Variant>,
781 flags: DBusCallFlags,
782 timeout_msec: i32,
783 fd_list: Option<&impl IsA<UnixFDList>>,
784 cancellable: Option<&impl IsA<Cancellable>>,
785 callback: P,
786 ) {
787 let main_context = glib::MainContext::ref_thread_default();
788 let is_main_context_owner = main_context.is_owner();
789 let has_acquired_main_context = (!is_main_context_owner)
790 .then(|| main_context.acquire().ok())
791 .flatten();
792 assert!(
793 is_main_context_owner || has_acquired_main_context.is_some(),
794 "Async operations only allowed if the thread is owning the MainContext"
795 );
796
797 let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
798 Box_::new(glib::thread_guard::ThreadGuard::new(callback));
799 unsafe extern "C" fn call_with_unix_fd_list_trampoline<
800 P: FnOnce(Result<(glib::Variant, Option<UnixFDList>), glib::Error>) + 'static,
801 >(
802 _source_object: *mut glib::gobject_ffi::GObject,
803 res: *mut crate::ffi::GAsyncResult,
804 user_data: glib::ffi::gpointer,
805 ) {
806 unsafe {
807 let mut error = std::ptr::null_mut();
808 let mut out_fd_list = std::ptr::null_mut();
809 let ret = ffi::g_dbus_proxy_call_with_unix_fd_list_finish(
810 _source_object as *mut _,
811 &mut out_fd_list,
812 res,
813 &mut error,
814 );
815 let result = if error.is_null() {
816 Ok((from_glib_full(ret), from_glib_full(out_fd_list)))
817 } else {
818 Err(from_glib_full(error))
819 };
820 let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
821 Box_::from_raw(user_data as *mut _);
822 let callback: P = callback.into_inner();
823 callback(result);
824 }
825 }
826 let callback = call_with_unix_fd_list_trampoline::<P>;
827 unsafe {
828 ffi::g_dbus_proxy_call_with_unix_fd_list(
829 self.as_ref().to_glib_none().0,
830 method_name.to_glib_none().0,
831 parameters.to_glib_none().0,
832 flags.into_glib(),
833 timeout_msec,
834 fd_list.map(|p| p.as_ref()).to_glib_none().0,
835 cancellable.map(|p| p.as_ref()).to_glib_none().0,
836 Some(callback),
837 Box_::into_raw(user_data) as *mut _,
838 );
839 }
840 }
841
842 #[cfg(unix)]
843 #[cfg_attr(docsrs, doc(cfg(unix)))]
844 fn call_with_unix_fd_list_future(
845 &self,
846 method_name: &str,
847 parameters: Option<&glib::Variant>,
848 flags: DBusCallFlags,
849 timeout_msec: i32,
850 fd_list: Option<&(impl IsA<UnixFDList> + Clone + 'static)>,
851 ) -> Pin<
852 Box_<
853 dyn std::future::Future<
854 Output = Result<(glib::Variant, Option<UnixFDList>), glib::Error>,
855 > + 'static,
856 >,
857 > {
858 let method_name = String::from(method_name);
859 let parameters = parameters.map(ToOwned::to_owned);
860 let fd_list = fd_list.map(ToOwned::to_owned);
861 Box_::pin(crate::GioFuture::new(
862 self,
863 move |obj, cancellable, send| {
864 obj.call_with_unix_fd_list(
865 &method_name,
866 parameters.as_ref().map(::std::borrow::Borrow::borrow),
867 flags,
868 timeout_msec,
869 fd_list.as_ref().map(::std::borrow::Borrow::borrow),
870 Some(cancellable),
871 move |res| {
872 send.resolve(res);
873 },
874 );
875 },
876 ))
877 }
878
879 /// Like g_dbus_proxy_call_sync() but also takes and returns #GUnixFDList objects.
880 ///
881 /// This method is only available on UNIX.
882 /// ## `method_name`
883 /// Name of method to invoke.
884 /// ## `parameters`
885 /// A #GVariant tuple with parameters for the signal
886 /// or [`None`] if not passing parameters.
887 /// ## `flags`
888 /// Flags from the #GDBusCallFlags enumeration.
889 /// ## `timeout_msec`
890 /// The timeout in milliseconds (with `G_MAXINT` meaning
891 /// "infinite") or -1 to use the proxy default timeout.
892 /// ## `fd_list`
893 /// A #GUnixFDList or [`None`].
894 /// ## `cancellable`
895 /// A #GCancellable or [`None`].
896 ///
897 /// # Returns
898 ///
899 /// [`None`] if @error is set. Otherwise a #GVariant tuple with
900 /// return values. Free with g_variant_unref().
901 ///
902 /// ## `out_fd_list`
903 /// Return location for a #GUnixFDList or [`None`].
904 #[cfg(unix)]
905 #[cfg_attr(docsrs, doc(cfg(unix)))]
906 #[doc(alias = "g_dbus_proxy_call_with_unix_fd_list_sync")]
907 fn call_with_unix_fd_list_sync(
908 &self,
909 method_name: &str,
910 parameters: Option<&glib::Variant>,
911 flags: DBusCallFlags,
912 timeout_msec: i32,
913 fd_list: Option<&impl IsA<UnixFDList>>,
914 cancellable: Option<&impl IsA<Cancellable>>,
915 ) -> Result<(glib::Variant, Option<UnixFDList>), glib::Error> {
916 unsafe {
917 let mut out_fd_list = std::ptr::null_mut();
918 let mut error = std::ptr::null_mut();
919 let ret = ffi::g_dbus_proxy_call_with_unix_fd_list_sync(
920 self.as_ref().to_glib_none().0,
921 method_name.to_glib_none().0,
922 parameters.to_glib_none().0,
923 flags.into_glib(),
924 timeout_msec,
925 fd_list.map(|p| p.as_ref()).to_glib_none().0,
926 &mut out_fd_list,
927 cancellable.map(|p| p.as_ref()).to_glib_none().0,
928 &mut error,
929 );
930 if error.is_null() {
931 Ok((from_glib_full(ret), from_glib_full(out_fd_list)))
932 } else {
933 Err(from_glib_full(error))
934 }
935 }
936 }
937
938 /// Looks up the value for a property from the cache. This call does no
939 /// blocking IO.
940 ///
941 /// If @self has an expected interface (see
942 /// #GDBusProxy:g-interface-info) and @property_name is referenced by
943 /// it, then @value is checked against the type of the property.
944 /// ## `property_name`
945 /// Property name.
946 ///
947 /// # Returns
948 ///
949 /// A reference to the #GVariant instance
950 /// that holds the value for @property_name or [`None`] if the value is not in
951 /// the cache. The returned reference must be freed with g_variant_unref().
952 #[doc(alias = "g_dbus_proxy_get_cached_property")]
953 #[doc(alias = "get_cached_property")]
954 fn cached_property(&self, property_name: &str) -> Option<glib::Variant> {
955 unsafe {
956 from_glib_full(ffi::g_dbus_proxy_get_cached_property(
957 self.as_ref().to_glib_none().0,
958 property_name.to_glib_none().0,
959 ))
960 }
961 }
962
963 /// Gets the names of all cached properties on @self.
964 ///
965 /// # Returns
966 ///
967 /// A
968 /// [`None`]-terminated array of strings or [`None`] if
969 /// @self has no cached properties. Free the returned array with
970 /// g_strfreev().
971 #[doc(alias = "g_dbus_proxy_get_cached_property_names")]
972 #[doc(alias = "get_cached_property_names")]
973 fn cached_property_names(&self) -> Vec<glib::GString> {
974 unsafe {
975 FromGlibPtrContainer::from_glib_full(ffi::g_dbus_proxy_get_cached_property_names(
976 self.as_ref().to_glib_none().0,
977 ))
978 }
979 }
980
981 /// Gets the connection @self is for.
982 ///
983 /// # Returns
984 ///
985 /// A #GDBusConnection owned by @self. Do not free.
986 #[doc(alias = "g_dbus_proxy_get_connection")]
987 #[doc(alias = "get_connection")]
988 #[doc(alias = "g-connection")]
989 fn connection(&self) -> DBusConnection {
990 unsafe {
991 from_glib_none(ffi::g_dbus_proxy_get_connection(
992 self.as_ref().to_glib_none().0,
993 ))
994 }
995 }
996
997 /// Gets the timeout to use if -1 (specifying default timeout) is
998 /// passed as @timeout_msec in the g_dbus_proxy_call() and
999 /// g_dbus_proxy_call_sync() functions.
1000 ///
1001 /// See the #GDBusProxy:g-default-timeout property for more details.
1002 ///
1003 /// # Returns
1004 ///
1005 /// Timeout to use for @self.
1006 #[doc(alias = "g_dbus_proxy_get_default_timeout")]
1007 #[doc(alias = "get_default_timeout")]
1008 #[doc(alias = "g-default-timeout")]
1009 fn default_timeout(&self) -> i32 {
1010 unsafe { ffi::g_dbus_proxy_get_default_timeout(self.as_ref().to_glib_none().0) }
1011 }
1012
1013 /// Gets the flags that @self was constructed with.
1014 ///
1015 /// # Returns
1016 ///
1017 /// Flags from the #GDBusProxyFlags enumeration.
1018 #[doc(alias = "g_dbus_proxy_get_flags")]
1019 #[doc(alias = "get_flags")]
1020 #[doc(alias = "g-flags")]
1021 fn flags(&self) -> DBusProxyFlags {
1022 unsafe { from_glib(ffi::g_dbus_proxy_get_flags(self.as_ref().to_glib_none().0)) }
1023 }
1024
1025 /// Returns the #GDBusInterfaceInfo, if any, specifying the interface
1026 /// that @self conforms to. See the #GDBusProxy:g-interface-info
1027 /// property for more details.
1028 ///
1029 /// # Returns
1030 ///
1031 /// A #GDBusInterfaceInfo or [`None`].
1032 /// Do not unref the returned object, it is owned by @self.
1033 #[doc(alias = "g_dbus_proxy_get_interface_info")]
1034 #[doc(alias = "get_interface_info")]
1035 #[doc(alias = "g-interface-info")]
1036 fn interface_info(&self) -> Option<DBusInterfaceInfo> {
1037 unsafe {
1038 from_glib_none(ffi::g_dbus_proxy_get_interface_info(
1039 self.as_ref().to_glib_none().0,
1040 ))
1041 }
1042 }
1043
1044 /// Gets the D-Bus interface name @self is for.
1045 ///
1046 /// # Returns
1047 ///
1048 /// A string owned by @self. Do not free.
1049 #[doc(alias = "g_dbus_proxy_get_interface_name")]
1050 #[doc(alias = "get_interface_name")]
1051 #[doc(alias = "g-interface-name")]
1052 fn interface_name(&self) -> glib::GString {
1053 unsafe {
1054 from_glib_none(ffi::g_dbus_proxy_get_interface_name(
1055 self.as_ref().to_glib_none().0,
1056 ))
1057 }
1058 }
1059
1060 /// Gets the name that @self was constructed for.
1061 ///
1062 /// When connected to a message bus, this will usually be non-[`None`].
1063 /// However, it may be [`None`] for a proxy that communicates using a peer-to-peer
1064 /// pattern.
1065 ///
1066 /// # Returns
1067 ///
1068 /// A string owned by @self. Do not free.
1069 #[doc(alias = "g_dbus_proxy_get_name")]
1070 #[doc(alias = "get_name")]
1071 #[doc(alias = "g-name")]
1072 fn name(&self) -> Option<glib::GString> {
1073 unsafe { from_glib_none(ffi::g_dbus_proxy_get_name(self.as_ref().to_glib_none().0)) }
1074 }
1075
1076 /// The unique name that owns the name that @self is for or [`None`] if
1077 /// no-one currently owns that name. You may connect to the
1078 /// #GObject::notify signal to track changes to the
1079 /// #GDBusProxy:g-name-owner property.
1080 ///
1081 /// # Returns
1082 ///
1083 /// The name owner or [`None`] if no name
1084 /// owner exists. Free with g_free().
1085 #[doc(alias = "g_dbus_proxy_get_name_owner")]
1086 #[doc(alias = "get_name_owner")]
1087 #[doc(alias = "g-name-owner")]
1088 fn name_owner(&self) -> Option<glib::GString> {
1089 unsafe {
1090 from_glib_full(ffi::g_dbus_proxy_get_name_owner(
1091 self.as_ref().to_glib_none().0,
1092 ))
1093 }
1094 }
1095
1096 /// Gets the object path @self is for.
1097 ///
1098 /// # Returns
1099 ///
1100 /// A string owned by @self. Do not free.
1101 #[doc(alias = "g_dbus_proxy_get_object_path")]
1102 #[doc(alias = "get_object_path")]
1103 #[doc(alias = "g-object-path")]
1104 fn object_path(&self) -> glib::GString {
1105 unsafe {
1106 from_glib_none(ffi::g_dbus_proxy_get_object_path(
1107 self.as_ref().to_glib_none().0,
1108 ))
1109 }
1110 }
1111
1112 ///
1113 /// g_dbus_proxy_set_cached_property (proxy,
1114 /// "SomeProperty",
1115 /// g_variant_new ("(si)",
1116 /// "A String",
1117 /// 42));
1118 /// ]|
1119 ///
1120 /// Normally you will not need to use this method since @self
1121 /// is tracking changes using the
1122 /// `org.freedesktop.DBus.Properties.PropertiesChanged`
1123 /// D-Bus signal. However, for performance reasons an object may
1124 /// decide to not use this signal for some properties and instead
1125 /// use a proprietary out-of-band mechanism to transmit changes.
1126 ///
1127 /// As a concrete example, consider an object with a property
1128 /// `ChatroomParticipants` which is an array of strings. Instead of
1129 /// transmitting the same (long) array every time the property changes,
1130 /// it is more efficient to only transmit the delta using e.g. signals
1131 /// `ChatroomParticipantJoined(String name)` and
1132 /// `ChatroomParticipantParted(String name)`.
1133 /// ## `property_name`
1134 /// Property name.
1135 /// ## `value`
1136 /// Value for the property or [`None`] to remove it from the cache.
1137 #[doc(alias = "g_dbus_proxy_set_cached_property")]
1138 fn set_cached_property(&self, property_name: &str, value: Option<&glib::Variant>) {
1139 unsafe {
1140 ffi::g_dbus_proxy_set_cached_property(
1141 self.as_ref().to_glib_none().0,
1142 property_name.to_glib_none().0,
1143 value.to_glib_none().0,
1144 );
1145 }
1146 }
1147
1148 /// Sets the timeout to use if -1 (specifying default timeout) is
1149 /// passed as @timeout_msec in the g_dbus_proxy_call() and
1150 /// g_dbus_proxy_call_sync() functions.
1151 ///
1152 /// See the #GDBusProxy:g-default-timeout property for more details.
1153 /// ## `timeout_msec`
1154 /// Timeout in milliseconds.
1155 #[doc(alias = "g_dbus_proxy_set_default_timeout")]
1156 #[doc(alias = "g-default-timeout")]
1157 fn set_default_timeout(&self, timeout_msec: i32) {
1158 unsafe {
1159 ffi::g_dbus_proxy_set_default_timeout(self.as_ref().to_glib_none().0, timeout_msec);
1160 }
1161 }
1162
1163 /// Ensure that interactions with @self conform to the given
1164 /// interface. See the #GDBusProxy:g-interface-info property for more
1165 /// details.
1166 /// ## `info`
1167 /// Minimum interface this proxy conforms to
1168 /// or [`None`] to unset.
1169 #[doc(alias = "g_dbus_proxy_set_interface_info")]
1170 #[doc(alias = "g-interface-info")]
1171 fn set_interface_info(&self, info: Option<&DBusInterfaceInfo>) {
1172 unsafe {
1173 ffi::g_dbus_proxy_set_interface_info(
1174 self.as_ref().to_glib_none().0,
1175 info.to_glib_none().0,
1176 );
1177 }
1178 }
1179
1180 #[doc(alias = "g-default-timeout")]
1181 fn connect_g_default_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
1182 &self,
1183 f: F,
1184 ) -> SignalHandlerId {
1185 unsafe extern "C" fn notify_g_default_timeout_trampoline<
1186 P: IsA<DBusProxy>,
1187 F: Fn(&P) + Send + Sync + 'static,
1188 >(
1189 this: *mut ffi::GDBusProxy,
1190 _param_spec: glib::ffi::gpointer,
1191 f: glib::ffi::gpointer,
1192 ) {
1193 unsafe {
1194 let f: &F = &*(f as *const F);
1195 f(DBusProxy::from_glib_borrow(this).unsafe_cast_ref())
1196 }
1197 }
1198 unsafe {
1199 let f: Box_<F> = Box_::new(f);
1200 connect_raw(
1201 self.as_ptr() as *mut _,
1202 c"notify::g-default-timeout".as_ptr(),
1203 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1204 notify_g_default_timeout_trampoline::<Self, F> as *const (),
1205 )),
1206 Box_::into_raw(f),
1207 )
1208 }
1209 }
1210
1211 #[doc(alias = "g-interface-info")]
1212 fn connect_g_interface_info_notify<F: Fn(&Self) + Send + Sync + 'static>(
1213 &self,
1214 f: F,
1215 ) -> SignalHandlerId {
1216 unsafe extern "C" fn notify_g_interface_info_trampoline<
1217 P: IsA<DBusProxy>,
1218 F: Fn(&P) + Send + Sync + 'static,
1219 >(
1220 this: *mut ffi::GDBusProxy,
1221 _param_spec: glib::ffi::gpointer,
1222 f: glib::ffi::gpointer,
1223 ) {
1224 unsafe {
1225 let f: &F = &*(f as *const F);
1226 f(DBusProxy::from_glib_borrow(this).unsafe_cast_ref())
1227 }
1228 }
1229 unsafe {
1230 let f: Box_<F> = Box_::new(f);
1231 connect_raw(
1232 self.as_ptr() as *mut _,
1233 c"notify::g-interface-info".as_ptr(),
1234 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1235 notify_g_interface_info_trampoline::<Self, F> as *const (),
1236 )),
1237 Box_::into_raw(f),
1238 )
1239 }
1240 }
1241
1242 #[doc(alias = "g-name-owner")]
1243 fn connect_g_name_owner_notify<F: Fn(&Self) + Send + Sync + 'static>(
1244 &self,
1245 f: F,
1246 ) -> SignalHandlerId {
1247 unsafe extern "C" fn notify_g_name_owner_trampoline<
1248 P: IsA<DBusProxy>,
1249 F: Fn(&P) + Send + Sync + 'static,
1250 >(
1251 this: *mut ffi::GDBusProxy,
1252 _param_spec: glib::ffi::gpointer,
1253 f: glib::ffi::gpointer,
1254 ) {
1255 unsafe {
1256 let f: &F = &*(f as *const F);
1257 f(DBusProxy::from_glib_borrow(this).unsafe_cast_ref())
1258 }
1259 }
1260 unsafe {
1261 let f: Box_<F> = Box_::new(f);
1262 connect_raw(
1263 self.as_ptr() as *mut _,
1264 c"notify::g-name-owner".as_ptr(),
1265 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1266 notify_g_name_owner_trampoline::<Self, F> as *const (),
1267 )),
1268 Box_::into_raw(f),
1269 )
1270 }
1271 }
1272}
1273
1274impl<O: IsA<DBusProxy>> DBusProxyExt for O {}