1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gio.DBusProxy; 26 27 private import gio.AsyncInitableIF; 28 private import gio.AsyncInitableT; 29 private import gio.AsyncResultIF; 30 private import gio.Cancellable; 31 private import gio.DBusConnection; 32 private import gio.DBusInterfaceIF; 33 private import gio.DBusInterfaceInfo; 34 private import gio.DBusInterfaceT; 35 private import gio.InitableIF; 36 private import gio.InitableT; 37 private import gio.UnixFDList; 38 private import gio.c.functions; 39 public import gio.c.types; 40 private import glib.ConstructionException; 41 private import glib.ErrorG; 42 private import glib.GException; 43 private import glib.Str; 44 private import glib.Variant; 45 private import gobject.ObjectG; 46 private import gobject.Signals; 47 public import gtkc.giotypes; 48 private import std.algorithm; 49 50 51 /** 52 * #GDBusProxy is a base class used for proxies to access a D-Bus 53 * interface on a remote object. A #GDBusProxy can be constructed for 54 * both well-known and unique names. 55 * 56 * By default, #GDBusProxy will cache all properties (and listen to 57 * changes) of the remote object, and proxy all signals that get 58 * emitted. This behaviour can be changed by passing suitable 59 * #GDBusProxyFlags when the proxy is created. If the proxy is for a 60 * well-known name, the property cache is flushed when the name owner 61 * vanishes and reloaded when a name owner appears. 62 * 63 * If a #GDBusProxy is used for a well-known name, the owner of the 64 * name is tracked and can be read from 65 * #GDBusProxy:g-name-owner. Connect to the #GObject::notify signal to 66 * get notified of changes. Additionally, only signals and property 67 * changes emitted from the current name owner are considered and 68 * calls are always sent to the current name owner. This avoids a 69 * number of race conditions when the name is lost by one owner and 70 * claimed by another. However, if no name owner currently exists, 71 * then calls will be sent to the well-known name which may result in 72 * the message bus launching an owner (unless 73 * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START is set). 74 * 75 * The generic #GDBusProxy::g-properties-changed and 76 * #GDBusProxy::g-signal signals are not very convenient to work with. 77 * Therefore, the recommended way of working with proxies is to subclass 78 * #GDBusProxy, and have more natural properties and signals in your derived 79 * class. This [example][gdbus-example-gdbus-codegen] shows how this can 80 * easily be done using the [gdbus-codegen][gdbus-codegen] tool. 81 * 82 * A #GDBusProxy instance can be used from multiple threads but note 83 * that all signals (e.g. #GDBusProxy::g-signal, #GDBusProxy::g-properties-changed 84 * and #GObject::notify) are emitted in the 85 * [thread-default main context][g-main-context-push-thread-default] 86 * of the thread where the instance was constructed. 87 * 88 * An example using a proxy for a well-known name can be found in 89 * [gdbus-example-watch-proxy.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-watch-proxy.c) 90 * 91 * Since: 2.26 92 */ 93 public class DBusProxy : ObjectG, AsyncInitableIF, DBusInterfaceIF, InitableIF 94 { 95 /** the main Gtk struct */ 96 protected GDBusProxy* gDBusProxy; 97 98 /** Get the main Gtk struct */ 99 public GDBusProxy* getDBusProxyStruct(bool transferOwnership = false) 100 { 101 if (transferOwnership) 102 ownedRef = false; 103 return gDBusProxy; 104 } 105 106 /** the main Gtk struct as a void* */ 107 protected override void* getStruct() 108 { 109 return cast(void*)gDBusProxy; 110 } 111 112 /** 113 * Sets our main struct and passes it to the parent class. 114 */ 115 public this (GDBusProxy* gDBusProxy, bool ownedRef = false) 116 { 117 this.gDBusProxy = gDBusProxy; 118 super(cast(GObject*)gDBusProxy, ownedRef); 119 } 120 121 // add the AsyncInitable capabilities 122 mixin AsyncInitableT!(GDBusProxy); 123 124 // add the DBusInterface capabilities 125 mixin DBusInterfaceT!(GDBusProxy); 126 127 // add the Initable capabilities 128 mixin InitableT!(GDBusProxy); 129 130 /** 131 * Finishes creating a GDBusProxy. 132 * 133 * Params: 134 * res = A GAsyncResult obtained from the GAsyncReadyCallback 135 * function passed to g_dbus_proxy_new(). 136 * forBus = If true finish an address. 137 * 138 * Throws: GException on failure. 139 * Throws: ConstructionException GTK+ fails to create the object. 140 * 141 * Since: 2.26 142 */ 143 public this (AsyncResultIF res, bool forBus = false) 144 { 145 GError* err = null; 146 GDBusProxy* p; 147 148 if ( forBus ) 149 { 150 p = g_dbus_proxy_new_for_bus_finish((res is null) ? null : res.getAsyncResultStruct(), &err); 151 } 152 else 153 { 154 p = g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err); 155 } 156 157 if (err !is null) 158 { 159 throw new GException( new ErrorG(err) ); 160 } 161 162 if(p is null) 163 { 164 throw new ConstructionException("null returned by g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err)"); 165 } 166 this(p, true); 167 } 168 169 /** 170 */ 171 172 /** */ 173 public static GType getType() 174 { 175 return g_dbus_proxy_get_type(); 176 } 177 178 /** 179 * Like g_dbus_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. 180 * 181 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. 182 * 183 * Params: 184 * busType = A #GBusType. 185 * flags = Flags used when constructing the proxy. 186 * info = A #GDBusInterfaceInfo specifying the minimal interface 187 * that @proxy conforms to or %NULL. 188 * name = A bus name (well-known or unique). 189 * objectPath = An object path. 190 * interfaceName = A D-Bus interface name. 191 * cancellable = A #GCancellable or %NULL. 192 * 193 * Returns: A #GDBusProxy or %NULL if error is set. 194 * Free with g_object_unref(). 195 * 196 * Since: 2.26 197 * 198 * Throws: GException on failure. 199 * Throws: ConstructionException GTK+ fails to create the object. 200 */ 201 public this(GBusType busType, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable) 202 { 203 GError* err = null; 204 205 auto p = g_dbus_proxy_new_for_bus_sync(busType, flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 206 207 if (err !is null) 208 { 209 throw new GException( new ErrorG(err) ); 210 } 211 212 if(p is null) 213 { 214 throw new ConstructionException("null returned by new_for_bus_sync"); 215 } 216 217 this(cast(GDBusProxy*) p, true); 218 } 219 220 /** 221 * Creates a proxy for accessing @interface_name on the remote object 222 * at @object_path owned by @name at @connection and synchronously 223 * loads D-Bus properties unless the 224 * %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used. 225 * 226 * If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up 227 * match rules for signals. Connect to the #GDBusProxy::g-signal signal 228 * to handle signals from the remote object. 229 * 230 * If @name is a well-known name and the 231 * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION 232 * flags aren't set and no name owner currently exists, the message bus 233 * will be requested to launch a name owner for the name. 234 * 235 * This is a synchronous failable constructor. See g_dbus_proxy_new() 236 * and g_dbus_proxy_new_finish() for the asynchronous version. 237 * 238 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. 239 * 240 * Params: 241 * connection = A #GDBusConnection. 242 * flags = Flags used when constructing the proxy. 243 * info = A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL. 244 * name = A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. 245 * objectPath = An object path. 246 * interfaceName = A D-Bus interface name. 247 * cancellable = A #GCancellable or %NULL. 248 * 249 * Returns: A #GDBusProxy or %NULL if error is set. 250 * Free with g_object_unref(). 251 * 252 * Since: 2.26 253 * 254 * Throws: GException on failure. 255 * Throws: ConstructionException GTK+ fails to create the object. 256 */ 257 public this(DBusConnection connection, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable) 258 { 259 GError* err = null; 260 261 auto p = g_dbus_proxy_new_sync((connection is null) ? null : connection.getDBusConnectionStruct(), flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 262 263 if (err !is null) 264 { 265 throw new GException( new ErrorG(err) ); 266 } 267 268 if(p is null) 269 { 270 throw new ConstructionException("null returned by new_sync"); 271 } 272 273 this(cast(GDBusProxy*) p, true); 274 } 275 276 /** 277 * Creates a proxy for accessing @interface_name on the remote object 278 * at @object_path owned by @name at @connection and asynchronously 279 * loads D-Bus properties unless the 280 * %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used. Connect to 281 * the #GDBusProxy::g-properties-changed signal to get notified about 282 * property changes. 283 * 284 * If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up 285 * match rules for signals. Connect to the #GDBusProxy::g-signal signal 286 * to handle signals from the remote object. 287 * 288 * If @name is a well-known name and the 289 * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION 290 * flags aren't set and no name owner currently exists, the message bus 291 * will be requested to launch a name owner for the name. 292 * 293 * This is a failable asynchronous constructor - when the proxy is 294 * ready, @callback will be invoked and you can use 295 * g_dbus_proxy_new_finish() to get the result. 296 * 297 * See g_dbus_proxy_new_sync() and for a synchronous version of this constructor. 298 * 299 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. 300 * 301 * Params: 302 * connection = A #GDBusConnection. 303 * flags = Flags used when constructing the proxy. 304 * info = A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL. 305 * name = A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. 306 * objectPath = An object path. 307 * interfaceName = A D-Bus interface name. 308 * cancellable = A #GCancellable or %NULL. 309 * callback = Callback function to invoke when the proxy is ready. 310 * userData = User data to pass to @callback. 311 * 312 * Since: 2.26 313 */ 314 public static void newProxy(DBusConnection connection, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 315 { 316 g_dbus_proxy_new((connection is null) ? null : connection.getDBusConnectionStruct(), flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 317 } 318 319 /** 320 * Like g_dbus_proxy_new() but takes a #GBusType instead of a #GDBusConnection. 321 * 322 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. 323 * 324 * Params: 325 * busType = A #GBusType. 326 * flags = Flags used when constructing the proxy. 327 * info = A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL. 328 * name = A bus name (well-known or unique). 329 * objectPath = An object path. 330 * interfaceName = A D-Bus interface name. 331 * cancellable = A #GCancellable or %NULL. 332 * callback = Callback function to invoke when the proxy is ready. 333 * userData = User data to pass to @callback. 334 * 335 * Since: 2.26 336 */ 337 public static void newForBus(GBusType busType, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 338 { 339 g_dbus_proxy_new_for_bus(busType, flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 340 } 341 342 /** 343 * Asynchronously invokes the @method_name method on @proxy. 344 * 345 * If @method_name contains any dots, then @name is split into interface and 346 * method name parts. This allows using @proxy for invoking methods on 347 * other interfaces. 348 * 349 * If the #GDBusConnection associated with @proxy is closed then 350 * the operation will fail with %G_IO_ERROR_CLOSED. If 351 * @cancellable is canceled, the operation will fail with 352 * %G_IO_ERROR_CANCELLED. If @parameters contains a value not 353 * compatible with the D-Bus protocol, the operation fails with 354 * %G_IO_ERROR_INVALID_ARGUMENT. 355 * 356 * If the @parameters #GVariant is floating, it is consumed. This allows 357 * convenient 'inline' use of g_variant_new(), e.g.: 358 * |[<!-- language="C" --> 359 * g_dbus_proxy_call (proxy, 360 * "TwoStrings", 361 * g_variant_new ("(ss)", 362 * "Thing One", 363 * "Thing Two"), 364 * G_DBUS_CALL_FLAGS_NONE, 365 * -1, 366 * NULL, 367 * (GAsyncReadyCallback) two_strings_done, 368 * &data); 369 * ]| 370 * 371 * If @proxy has an expected interface (see 372 * #GDBusProxy:g-interface-info) and @method_name is referenced by it, 373 * then the return value is checked against the return type. 374 * 375 * This is an asynchronous method. When the operation is finished, 376 * @callback will be invoked in the 377 * [thread-default main context][g-main-context-push-thread-default] 378 * of the thread you are calling this method from. 379 * You can then call g_dbus_proxy_call_finish() to get the result of 380 * the operation. See g_dbus_proxy_call_sync() for the synchronous 381 * version of this method. 382 * 383 * If @callback is %NULL then the D-Bus method call message will be sent with 384 * the %G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED flag set. 385 * 386 * Params: 387 * methodName = Name of method to invoke. 388 * parameters = A #GVariant tuple with parameters for the signal or %NULL if not passing parameters. 389 * flags = Flags from the #GDBusCallFlags enumeration. 390 * timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning 391 * "infinite") or -1 to use the proxy default timeout. 392 * cancellable = A #GCancellable or %NULL. 393 * callback = A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't 394 * care about the result of the method invocation. 395 * userData = The data to pass to @callback. 396 * 397 * Since: 2.26 398 */ 399 public void call(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 400 { 401 g_dbus_proxy_call(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 402 } 403 404 /** 405 * Finishes an operation started with g_dbus_proxy_call(). 406 * 407 * Params: 408 * res = A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_proxy_call(). 409 * 410 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 411 * return values. Free with g_variant_unref(). 412 * 413 * Since: 2.26 414 * 415 * Throws: GException on failure. 416 */ 417 public Variant callFinish(AsyncResultIF res) 418 { 419 GError* err = null; 420 421 auto p = g_dbus_proxy_call_finish(gDBusProxy, (res is null) ? null : res.getAsyncResultStruct(), &err); 422 423 if (err !is null) 424 { 425 throw new GException( new ErrorG(err) ); 426 } 427 428 if(p is null) 429 { 430 return null; 431 } 432 433 return new Variant(cast(GVariant*) p, true); 434 } 435 436 /** 437 * Synchronously invokes the @method_name method on @proxy. 438 * 439 * If @method_name contains any dots, then @name is split into interface and 440 * method name parts. This allows using @proxy for invoking methods on 441 * other interfaces. 442 * 443 * If the #GDBusConnection associated with @proxy is disconnected then 444 * the operation will fail with %G_IO_ERROR_CLOSED. If 445 * @cancellable is canceled, the operation will fail with 446 * %G_IO_ERROR_CANCELLED. If @parameters contains a value not 447 * compatible with the D-Bus protocol, the operation fails with 448 * %G_IO_ERROR_INVALID_ARGUMENT. 449 * 450 * If the @parameters #GVariant is floating, it is consumed. This allows 451 * convenient 'inline' use of g_variant_new(), e.g.: 452 * |[<!-- language="C" --> 453 * g_dbus_proxy_call_sync (proxy, 454 * "TwoStrings", 455 * g_variant_new ("(ss)", 456 * "Thing One", 457 * "Thing Two"), 458 * G_DBUS_CALL_FLAGS_NONE, 459 * -1, 460 * NULL, 461 * &error); 462 * ]| 463 * 464 * The calling thread is blocked until a reply is received. See 465 * g_dbus_proxy_call() for the asynchronous version of this 466 * method. 467 * 468 * If @proxy has an expected interface (see 469 * #GDBusProxy:g-interface-info) and @method_name is referenced by it, 470 * then the return value is checked against the return type. 471 * 472 * Params: 473 * methodName = Name of method to invoke. 474 * parameters = A #GVariant tuple with parameters for the signal 475 * or %NULL if not passing parameters. 476 * flags = Flags from the #GDBusCallFlags enumeration. 477 * timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning 478 * "infinite") or -1 to use the proxy default timeout. 479 * cancellable = A #GCancellable or %NULL. 480 * 481 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 482 * return values. Free with g_variant_unref(). 483 * 484 * Since: 2.26 485 * 486 * Throws: GException on failure. 487 */ 488 public Variant callSync(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable) 489 { 490 GError* err = null; 491 492 auto p = g_dbus_proxy_call_sync(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 493 494 if (err !is null) 495 { 496 throw new GException( new ErrorG(err) ); 497 } 498 499 if(p is null) 500 { 501 return null; 502 } 503 504 return new Variant(cast(GVariant*) p, true); 505 } 506 507 /** 508 * Like g_dbus_proxy_call() but also takes a #GUnixFDList object. 509 * 510 * This method is only available on UNIX. 511 * 512 * Params: 513 * methodName = Name of method to invoke. 514 * parameters = A #GVariant tuple with parameters for the signal or %NULL if not passing parameters. 515 * flags = Flags from the #GDBusCallFlags enumeration. 516 * timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning 517 * "infinite") or -1 to use the proxy default timeout. 518 * fdList = A #GUnixFDList or %NULL. 519 * cancellable = A #GCancellable or %NULL. 520 * callback = A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't 521 * care about the result of the method invocation. 522 * userData = The data to pass to @callback. 523 * 524 * Since: 2.30 525 */ 526 public void callWithUnixFdList(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, UnixFDList fdList, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 527 { 528 g_dbus_proxy_call_with_unix_fd_list(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (fdList is null) ? null : fdList.getUnixFDListStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 529 } 530 531 /** 532 * Finishes an operation started with g_dbus_proxy_call_with_unix_fd_list(). 533 * 534 * Params: 535 * outFdList = Return location for a #GUnixFDList or %NULL. 536 * res = A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_proxy_call_with_unix_fd_list(). 537 * 538 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 539 * return values. Free with g_variant_unref(). 540 * 541 * Since: 2.30 542 * 543 * Throws: GException on failure. 544 */ 545 public Variant callWithUnixFdListFinish(out UnixFDList outFdList, AsyncResultIF res) 546 { 547 GUnixFDList* outoutFdList = null; 548 GError* err = null; 549 550 auto p = g_dbus_proxy_call_with_unix_fd_list_finish(gDBusProxy, &outoutFdList, (res is null) ? null : res.getAsyncResultStruct(), &err); 551 552 if (err !is null) 553 { 554 throw new GException( new ErrorG(err) ); 555 } 556 557 outFdList = ObjectG.getDObject!(UnixFDList)(outoutFdList); 558 559 if(p is null) 560 { 561 return null; 562 } 563 564 return new Variant(cast(GVariant*) p, true); 565 } 566 567 /** 568 * Like g_dbus_proxy_call_sync() but also takes and returns #GUnixFDList objects. 569 * 570 * This method is only available on UNIX. 571 * 572 * Params: 573 * methodName = Name of method to invoke. 574 * parameters = A #GVariant tuple with parameters for the signal 575 * or %NULL if not passing parameters. 576 * flags = Flags from the #GDBusCallFlags enumeration. 577 * timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning 578 * "infinite") or -1 to use the proxy default timeout. 579 * fdList = A #GUnixFDList or %NULL. 580 * outFdList = Return location for a #GUnixFDList or %NULL. 581 * cancellable = A #GCancellable or %NULL. 582 * 583 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 584 * return values. Free with g_variant_unref(). 585 * 586 * Since: 2.30 587 * 588 * Throws: GException on failure. 589 */ 590 public Variant callWithUnixFdListSync(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, UnixFDList fdList, out UnixFDList outFdList, Cancellable cancellable) 591 { 592 GUnixFDList* outoutFdList = null; 593 GError* err = null; 594 595 auto p = g_dbus_proxy_call_with_unix_fd_list_sync(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (fdList is null) ? null : fdList.getUnixFDListStruct(), &outoutFdList, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 596 597 if (err !is null) 598 { 599 throw new GException( new ErrorG(err) ); 600 } 601 602 outFdList = ObjectG.getDObject!(UnixFDList)(outoutFdList); 603 604 if(p is null) 605 { 606 return null; 607 } 608 609 return new Variant(cast(GVariant*) p, true); 610 } 611 612 /** 613 * Looks up the value for a property from the cache. This call does no 614 * blocking IO. 615 * 616 * If @proxy has an expected interface (see 617 * #GDBusProxy:g-interface-info) and @property_name is referenced by 618 * it, then @value is checked against the type of the property. 619 * 620 * Params: 621 * propertyName = Property name. 622 * 623 * Returns: A reference to the #GVariant instance 624 * that holds the value for @property_name or %NULL if the value is not in 625 * the cache. The returned reference must be freed with g_variant_unref(). 626 * 627 * Since: 2.26 628 */ 629 public Variant getCachedProperty(string propertyName) 630 { 631 auto p = g_dbus_proxy_get_cached_property(gDBusProxy, Str.toStringz(propertyName)); 632 633 if(p is null) 634 { 635 return null; 636 } 637 638 return new Variant(cast(GVariant*) p, true); 639 } 640 641 /** 642 * Gets the names of all cached properties on @proxy. 643 * 644 * Returns: A 645 * %NULL-terminated array of strings or %NULL if 646 * @proxy has no cached properties. Free the returned array with 647 * g_strfreev(). 648 * 649 * Since: 2.26 650 */ 651 public string[] getCachedPropertyNames() 652 { 653 auto retStr = g_dbus_proxy_get_cached_property_names(gDBusProxy); 654 655 scope(exit) Str.freeStringArray(retStr); 656 return Str.toStringArray(retStr); 657 } 658 659 /** 660 * Gets the connection @proxy is for. 661 * 662 * Returns: A #GDBusConnection owned by @proxy. Do not free. 663 * 664 * Since: 2.26 665 */ 666 public DBusConnection getConnection() 667 { 668 auto p = g_dbus_proxy_get_connection(gDBusProxy); 669 670 if(p is null) 671 { 672 return null; 673 } 674 675 return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p); 676 } 677 678 /** 679 * Gets the timeout to use if -1 (specifying default timeout) is 680 * passed as @timeout_msec in the g_dbus_proxy_call() and 681 * g_dbus_proxy_call_sync() functions. 682 * 683 * See the #GDBusProxy:g-default-timeout property for more details. 684 * 685 * Returns: Timeout to use for @proxy. 686 * 687 * Since: 2.26 688 */ 689 public int getDefaultTimeout() 690 { 691 return g_dbus_proxy_get_default_timeout(gDBusProxy); 692 } 693 694 /** 695 * Gets the flags that @proxy was constructed with. 696 * 697 * Returns: Flags from the #GDBusProxyFlags enumeration. 698 * 699 * Since: 2.26 700 */ 701 public GDBusProxyFlags getFlags() 702 { 703 return g_dbus_proxy_get_flags(gDBusProxy); 704 } 705 706 /** 707 * Returns the #GDBusInterfaceInfo, if any, specifying the interface 708 * that @proxy conforms to. See the #GDBusProxy:g-interface-info 709 * property for more details. 710 * 711 * Returns: A #GDBusInterfaceInfo or %NULL. 712 * Do not unref the returned object, it is owned by @proxy. 713 * 714 * Since: 2.26 715 */ 716 public DBusInterfaceInfo getInterfaceInfo() 717 { 718 auto p = g_dbus_proxy_get_interface_info(gDBusProxy); 719 720 if(p is null) 721 { 722 return null; 723 } 724 725 return ObjectG.getDObject!(DBusInterfaceInfo)(cast(GDBusInterfaceInfo*) p); 726 } 727 728 /** 729 * Gets the D-Bus interface name @proxy is for. 730 * 731 * Returns: A string owned by @proxy. Do not free. 732 * 733 * Since: 2.26 734 */ 735 public string getInterfaceName() 736 { 737 return Str.toString(g_dbus_proxy_get_interface_name(gDBusProxy)); 738 } 739 740 /** 741 * Gets the name that @proxy was constructed for. 742 * 743 * Returns: A string owned by @proxy. Do not free. 744 * 745 * Since: 2.26 746 */ 747 public string getName() 748 { 749 return Str.toString(g_dbus_proxy_get_name(gDBusProxy)); 750 } 751 752 /** 753 * The unique name that owns the name that @proxy is for or %NULL if 754 * no-one currently owns that name. You may connect to the 755 * #GObject::notify signal to track changes to the 756 * #GDBusProxy:g-name-owner property. 757 * 758 * Returns: The name owner or %NULL if no name 759 * owner exists. Free with g_free(). 760 * 761 * Since: 2.26 762 */ 763 public string getNameOwner() 764 { 765 auto retStr = g_dbus_proxy_get_name_owner(gDBusProxy); 766 767 scope(exit) Str.freeString(retStr); 768 return Str.toString(retStr); 769 } 770 771 /** 772 * Gets the object path @proxy is for. 773 * 774 * Returns: A string owned by @proxy. Do not free. 775 * 776 * Since: 2.26 777 */ 778 public string getObjectPath() 779 { 780 return Str.toString(g_dbus_proxy_get_object_path(gDBusProxy)); 781 } 782 783 /** 784 * If @value is not %NULL, sets the cached value for the property with 785 * name @property_name to the value in @value. 786 * 787 * If @value is %NULL, then the cached value is removed from the 788 * property cache. 789 * 790 * If @proxy has an expected interface (see 791 * #GDBusProxy:g-interface-info) and @property_name is referenced by 792 * it, then @value is checked against the type of the property. 793 * 794 * If the @value #GVariant is floating, it is consumed. This allows 795 * convenient 'inline' use of g_variant_new(), e.g. 796 * |[<!-- language="C" --> 797 * g_dbus_proxy_set_cached_property (proxy, 798 * "SomeProperty", 799 * g_variant_new ("(si)", 800 * "A String", 801 * 42)); 802 * ]| 803 * 804 * Normally you will not need to use this method since @proxy 805 * is tracking changes using the 806 * `org.freedesktop.DBus.Properties.PropertiesChanged` 807 * D-Bus signal. However, for performance reasons an object may 808 * decide to not use this signal for some properties and instead 809 * use a proprietary out-of-band mechanism to transmit changes. 810 * 811 * As a concrete example, consider an object with a property 812 * `ChatroomParticipants` which is an array of strings. Instead of 813 * transmitting the same (long) array every time the property changes, 814 * it is more efficient to only transmit the delta using e.g. signals 815 * `ChatroomParticipantJoined(String name)` and 816 * `ChatroomParticipantParted(String name)`. 817 * 818 * Params: 819 * propertyName = Property name. 820 * value = Value for the property or %NULL to remove it from the cache. 821 * 822 * Since: 2.26 823 */ 824 public void setCachedProperty(string propertyName, Variant value) 825 { 826 g_dbus_proxy_set_cached_property(gDBusProxy, Str.toStringz(propertyName), (value is null) ? null : value.getVariantStruct()); 827 } 828 829 /** 830 * Sets the timeout to use if -1 (specifying default timeout) is 831 * passed as @timeout_msec in the g_dbus_proxy_call() and 832 * g_dbus_proxy_call_sync() functions. 833 * 834 * See the #GDBusProxy:g-default-timeout property for more details. 835 * 836 * Params: 837 * timeoutMsec = Timeout in milliseconds. 838 * 839 * Since: 2.26 840 */ 841 public void setDefaultTimeout(int timeoutMsec) 842 { 843 g_dbus_proxy_set_default_timeout(gDBusProxy, timeoutMsec); 844 } 845 846 /** 847 * Ensure that interactions with @proxy conform to the given 848 * interface. See the #GDBusProxy:g-interface-info property for more 849 * details. 850 * 851 * Params: 852 * info = Minimum interface this proxy conforms to 853 * or %NULL to unset. 854 * 855 * Since: 2.26 856 */ 857 public void setInterfaceInfo(DBusInterfaceInfo info) 858 { 859 g_dbus_proxy_set_interface_info(gDBusProxy, (info is null) ? null : info.getDBusInterfaceInfoStruct()); 860 } 861 862 /** 863 * Emitted when one or more D-Bus properties on @proxy changes. The 864 * local cache has already been updated when this signal fires. Note 865 * that both @changed_properties and @invalidated_properties are 866 * guaranteed to never be %NULL (either may be empty though). 867 * 868 * If the proxy has the flag 869 * %G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES set, then 870 * @invalidated_properties will always be empty. 871 * 872 * This signal corresponds to the 873 * `PropertiesChanged` D-Bus signal on the 874 * `org.freedesktop.DBus.Properties` interface. 875 * 876 * Params: 877 * changedProperties = A #GVariant containing the properties that changed 878 * invalidatedProperties = A %NULL terminated array of properties that was invalidated 879 * 880 * Since: 2.26 881 */ 882 gulong addOnGPropertiesChanged(void delegate(Variant, string[], DBusProxy) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 883 { 884 return Signals.connect(this, "g-properties-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 885 } 886 887 /** 888 * Emitted when a signal from the remote object and interface that @proxy is for, has been received. 889 * 890 * Params: 891 * senderName = The sender of the signal or %NULL if the connection is not a bus connection. 892 * signalName = The name of the signal. 893 * parameters = A #GVariant tuple with parameters for the signal. 894 * 895 * Since: 2.26 896 */ 897 gulong addOnGSignal(void delegate(string, string, Variant, DBusProxy) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 898 { 899 return Signals.connect(this, "g-signal", dlg, connectFlags ^ ConnectFlags.SWAPPED); 900 } 901 }