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