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 glib.ConstructionException; 39 private import glib.ErrorG; 40 private import glib.GException; 41 private import glib.Str; 42 private import glib.Variant; 43 private import gobject.ObjectG; 44 private import gobject.Signals; 45 public import gtkc.gdktypes; 46 private import gtkc.gio; 47 public import gtkc.giotypes; 48 49 50 /** 51 * #GDBusProxy is a base class used for proxies to access a D-Bus 52 * interface on a remote object. A #GDBusProxy can be constructed for 53 * both well-known and unique names. 54 * 55 * By default, #GDBusProxy will cache all properties (and listen to 56 * changes) of the remote object, and proxy all signals that gets 57 * emitted. This behaviour can be changed by passing suitable 58 * #GDBusProxyFlags when the proxy is created. If the proxy is for a 59 * well-known name, the property cache is flushed when the name owner 60 * vanishes and reloaded when a name owner appears. 61 * 62 * If a #GDBusProxy is used for a well-known name, the owner of the 63 * name is tracked and can be read from 64 * #GDBusProxy:g-name-owner. Connect to the #GObject::notify signal to 65 * get notified of changes. Additionally, only signals and property 66 * changes emitted from the current name owner are considered and 67 * calls are always sent to the current name owner. This avoids a 68 * number of race conditions when the name is lost by one owner and 69 * claimed by another. However, if no name owner currently exists, 70 * then calls will be sent to the well-known name which may result in 71 * the message bus launching an owner (unless 72 * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START is set). 73 * 74 * The generic #GDBusProxy::g-properties-changed and 75 * #GDBusProxy::g-signal signals are not very convenient to work with. 76 * Therefore, the recommended way of working with proxies is to subclass 77 * #GDBusProxy, and have more natural properties and signals in your derived 78 * class. This [example][gdbus-example-gdbus-codegen] shows how this can 79 * easily be done using the [gdbus-codegen][gdbus-codegen] tool. 80 * 81 * A #GDBusProxy instance can be used from multiple threads but note 82 * that all signals (e.g. #GDBusProxy::g-signal, #GDBusProxy::g-properties-changed 83 * and #GObject::notify) are emitted in the 84 * [thread-default main context][g-main-context-push-thread-default] 85 * of the thread where the instance was constructed. 86 * 87 * An example using a proxy for a well-known name can be found in 88 * [gdbus-example-watch-proxy.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-watch-proxy.c) 89 * 90 * Since: 2.26 91 */ 92 public class DBusProxy : ObjectG, AsyncInitableIF, DBusInterfaceIF, InitableIF 93 { 94 /** the main Gtk struct */ 95 protected GDBusProxy* gDBusProxy; 96 97 /** Get the main Gtk struct */ 98 public GDBusProxy* getDBusProxyStruct() 99 { 100 return gDBusProxy; 101 } 102 103 /** the main Gtk struct as a void* */ 104 protected override void* getStruct() 105 { 106 return cast(void*)gDBusProxy; 107 } 108 109 protected override void setStruct(GObject* obj) 110 { 111 gDBusProxy = cast(GDBusProxy*)obj; 112 super.setStruct(obj); 113 } 114 115 /** 116 * Sets our main struct and passes it to the parent class. 117 */ 118 public this (GDBusProxy* gDBusProxy, bool ownedRef = false) 119 { 120 this.gDBusProxy = gDBusProxy; 121 super(cast(GObject*)gDBusProxy, ownedRef); 122 } 123 124 // add the AsyncInitable capabilities 125 mixin AsyncInitableT!(GDBusProxy); 126 127 // add the DBusInterface capabilities 128 mixin DBusInterfaceT!(GDBusProxy); 129 130 // add the Initable capabilities 131 mixin InitableT!(GDBusProxy); 132 133 /** 134 * Finishes creating a GDBusProxy. 135 * 136 * Params: 137 * res = A GAsyncResult obtained from the GAsyncReadyCallback 138 * function passed to g_dbus_proxy_new(). 139 * forBus = If true finish an address. 140 * 141 * Throws: GException on failure. 142 * Throws: ConstructionException GTK+ fails to create the object. 143 * 144 * Since: 2.26 145 */ 146 public this (AsyncResultIF res, bool forBus = false) 147 { 148 GError* err = null; 149 GDBusProxy* p; 150 151 if ( forBus ) 152 { 153 p = g_dbus_proxy_new_for_bus_finish((res is null) ? null : res.getAsyncResultStruct(), &err); 154 } 155 else 156 { 157 p = g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err); 158 } 159 160 if (err !is null) 161 { 162 throw new GException( new ErrorG(err) ); 163 } 164 165 if(p is null) 166 { 167 throw new ConstructionException("null returned by g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err)"); 168 } 169 this(p, true); 170 } 171 172 /** 173 */ 174 175 public static GType getType() 176 { 177 return g_dbus_proxy_get_type(); 178 } 179 180 /** 181 * Like g_dbus_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. 182 * 183 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. 184 * 185 * Params: 186 * busType = A #GBusType. 187 * flags = Flags used when constructing the proxy. 188 * info = A #GDBusInterfaceInfo specifying the minimal interface 189 * that @proxy conforms to or %NULL. 190 * name = A bus name (well-known or unique). 191 * objectPath = An object path. 192 * interfaceName = A D-Bus interface name. 193 * cancellable = A #GCancellable or %NULL. 194 * 195 * Return: A #GDBusProxy or %NULL if error is set. Free with g_object_unref(). 196 * 197 * Since: 2.26 198 * 199 * Throws: GException on failure. 200 * Throws: ConstructionException GTK+ fails to create the object. 201 */ 202 public this(GBusType busType, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable) 203 { 204 GError* err = null; 205 206 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); 207 208 if(p is null) 209 { 210 throw new ConstructionException("null returned by new_for_bus_sync"); 211 } 212 213 if (err !is null) 214 { 215 throw new GException( new ErrorG(err) ); 216 } 217 218 this(cast(GDBusProxy*) p, true); 219 } 220 221 /** 222 * Creates a proxy for accessing @interface_name on the remote object 223 * at @object_path owned by @name at @connection and synchronously 224 * loads D-Bus properties unless the 225 * %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used. 226 * 227 * If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up 228 * match rules for signals. Connect to the #GDBusProxy::g-signal signal 229 * to handle signals from the remote object. 230 * 231 * If @name is a well-known name and the 232 * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION 233 * flags aren't set and no name owner currently exists, the message bus 234 * will be requested to launch a name owner for the name. 235 * 236 * This is a synchronous failable constructor. See g_dbus_proxy_new() 237 * and g_dbus_proxy_new_finish() for the asynchronous version. 238 * 239 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. 240 * 241 * Params: 242 * connection = A #GDBusConnection. 243 * flags = Flags used when constructing the proxy. 244 * info = A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL. 245 * name = A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. 246 * objectPath = An object path. 247 * interfaceName = A D-Bus interface name. 248 * cancellable = A #GCancellable or %NULL. 249 * 250 * Return: A #GDBusProxy or %NULL if error is set. 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(p is null) 264 { 265 throw new ConstructionException("null returned by new_sync"); 266 } 267 268 if (err !is null) 269 { 270 throw new GException( new ErrorG(err) ); 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 * Return: %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); 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 * Return: %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); 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 * Return: %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); 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 * Return: %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); 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 * Return: A reference to the #GVariant instance that holds the value 624 * for @property_name or %NULL if the value is not in the cache. The 625 * 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); 639 } 640 641 /** 642 * Gets the names of all cached properties on @proxy. 643 * 644 * Return: A %NULL-terminated array of strings or %NULL if 645 * @proxy has no cached properties. Free the returned array with 646 * g_strfreev(). 647 * 648 * Since: 2.26 649 */ 650 public string[] getCachedPropertyNames() 651 { 652 return Str.toStringArray(g_dbus_proxy_get_cached_property_names(gDBusProxy)); 653 } 654 655 /** 656 * Gets the connection @proxy is for. 657 * 658 * Return: A #GDBusConnection owned by @proxy. Do not free. 659 * 660 * Since: 2.26 661 */ 662 public DBusConnection getConnection() 663 { 664 auto p = g_dbus_proxy_get_connection(gDBusProxy); 665 666 if(p is null) 667 { 668 return null; 669 } 670 671 return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p); 672 } 673 674 /** 675 * Gets the timeout to use if -1 (specifying default timeout) is 676 * passed as @timeout_msec in the g_dbus_proxy_call() and 677 * g_dbus_proxy_call_sync() functions. 678 * 679 * See the #GDBusProxy:g-default-timeout property for more details. 680 * 681 * Return: Timeout to use for @proxy. 682 * 683 * Since: 2.26 684 */ 685 public int getDefaultTimeout() 686 { 687 return g_dbus_proxy_get_default_timeout(gDBusProxy); 688 } 689 690 /** 691 * Gets the flags that @proxy was constructed with. 692 * 693 * Return: Flags from the #GDBusProxyFlags enumeration. 694 * 695 * Since: 2.26 696 */ 697 public GDBusProxyFlags getFlags() 698 { 699 return g_dbus_proxy_get_flags(gDBusProxy); 700 } 701 702 /** 703 * Returns the #GDBusInterfaceInfo, if any, specifying the interface 704 * that @proxy conforms to. See the #GDBusProxy:g-interface-info 705 * property for more details. 706 * 707 * Return: A #GDBusInterfaceInfo or %NULL. Do not unref the returned 708 * object, it is owned by @proxy. 709 * 710 * Since: 2.26 711 */ 712 public DBusInterfaceInfo getInterfaceInfo() 713 { 714 auto p = g_dbus_proxy_get_interface_info(gDBusProxy); 715 716 if(p is null) 717 { 718 return null; 719 } 720 721 return ObjectG.getDObject!(DBusInterfaceInfo)(cast(GDBusInterfaceInfo*) p); 722 } 723 724 /** 725 * Gets the D-Bus interface name @proxy is for. 726 * 727 * Return: A string owned by @proxy. Do not free. 728 * 729 * Since: 2.26 730 */ 731 public string getInterfaceName() 732 { 733 return Str.toString(g_dbus_proxy_get_interface_name(gDBusProxy)); 734 } 735 736 /** 737 * Gets the name that @proxy was constructed for. 738 * 739 * Return: A string owned by @proxy. Do not free. 740 * 741 * Since: 2.26 742 */ 743 public string getName() 744 { 745 return Str.toString(g_dbus_proxy_get_name(gDBusProxy)); 746 } 747 748 /** 749 * The unique name that owns the name that @proxy is for or %NULL if 750 * no-one currently owns that name. You may connect to the 751 * #GObject::notify signal to track changes to the 752 * #GDBusProxy:g-name-owner property. 753 * 754 * Return: The name owner or %NULL if no name owner exists. Free with g_free(). 755 * 756 * Since: 2.26 757 */ 758 public string getNameOwner() 759 { 760 return Str.toString(g_dbus_proxy_get_name_owner(gDBusProxy)); 761 } 762 763 /** 764 * Gets the object path @proxy is for. 765 * 766 * Return: A string owned by @proxy. Do not free. 767 * 768 * Since: 2.26 769 */ 770 public string getObjectPath() 771 { 772 return Str.toString(g_dbus_proxy_get_object_path(gDBusProxy)); 773 } 774 775 /** 776 * If @value is not %NULL, sets the cached value for the property with 777 * name @property_name to the value in @value. 778 * 779 * If @value is %NULL, then the cached value is removed from the 780 * property cache. 781 * 782 * If @proxy has an expected interface (see 783 * #GDBusProxy:g-interface-info) and @property_name is referenced by 784 * it, then @value is checked against the type of the property. 785 * 786 * If the @value #GVariant is floating, it is consumed. This allows 787 * convenient 'inline' use of g_variant_new(), e.g. 788 * |[<!-- language="C" --> 789 * g_dbus_proxy_set_cached_property (proxy, 790 * "SomeProperty", 791 * g_variant_new ("(si)", 792 * "A String", 793 * 42)); 794 * ]| 795 * 796 * Normally you will not need to use this method since @proxy 797 * is tracking changes using the 798 * `org.freedesktop.DBus.Properties.PropertiesChanged` 799 * D-Bus signal. However, for performance reasons an object may 800 * decide to not use this signal for some properties and instead 801 * use a proprietary out-of-band mechanism to transmit changes. 802 * 803 * As a concrete example, consider an object with a property 804 * `ChatroomParticipants` which is an array of strings. Instead of 805 * transmitting the same (long) array every time the property changes, 806 * it is more efficient to only transmit the delta using e.g. signals 807 * `ChatroomParticipantJoined(String name)` and 808 * `ChatroomParticipantParted(String name)`. 809 * 810 * Params: 811 * propertyName = Property name. 812 * value = Value for the property or %NULL to remove it from the cache. 813 * 814 * Since: 2.26 815 */ 816 public void setCachedProperty(string propertyName, Variant value) 817 { 818 g_dbus_proxy_set_cached_property(gDBusProxy, Str.toStringz(propertyName), (value is null) ? null : value.getVariantStruct()); 819 } 820 821 /** 822 * Sets the timeout to use if -1 (specifying default timeout) is 823 * passed as @timeout_msec in the g_dbus_proxy_call() and 824 * g_dbus_proxy_call_sync() functions. 825 * 826 * See the #GDBusProxy:g-default-timeout property for more details. 827 * 828 * Params: 829 * timeoutMsec = Timeout in milliseconds. 830 * 831 * Since: 2.26 832 */ 833 public void setDefaultTimeout(int timeoutMsec) 834 { 835 g_dbus_proxy_set_default_timeout(gDBusProxy, timeoutMsec); 836 } 837 838 /** 839 * Ensure that interactions with @proxy conform to the given 840 * interface. See the #GDBusProxy:g-interface-info property for more 841 * details. 842 * 843 * Params: 844 * info = Minimum interface this proxy conforms to or %NULL to unset. 845 * 846 * Since: 2.26 847 */ 848 public void setInterfaceInfo(DBusInterfaceInfo info) 849 { 850 g_dbus_proxy_set_interface_info(gDBusProxy, (info is null) ? null : info.getDBusInterfaceInfoStruct()); 851 } 852 853 int[string] connectedSignals; 854 855 void delegate(Variant, string[], DBusProxy)[] onGPropertiesChangedListeners; 856 /** 857 * Emitted when one or more D-Bus properties on @proxy changes. The 858 * local cache has already been updated when this signal fires. Note 859 * that both @changed_properties and @invalidated_properties are 860 * guaranteed to never be %NULL (either may be empty though). 861 * 862 * If the proxy has the flag 863 * %G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES set, then 864 * @invalidated_properties will always be empty. 865 * 866 * This signal corresponds to the 867 * `PropertiesChanged` D-Bus signal on the 868 * `org.freedesktop.DBus.Properties` interface. 869 * 870 * Params: 871 * changedProperties = A #GVariant containing the properties that changed 872 * invalidatedProperties = A %NULL terminated array of properties that was invalidated 873 * 874 * Since: 2.26 875 */ 876 void addOnGPropertiesChanged(void delegate(Variant, string[], DBusProxy) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 877 { 878 if ( "g-properties-changed" !in connectedSignals ) 879 { 880 Signals.connectData( 881 this, 882 "g-properties-changed", 883 cast(GCallback)&callBackGPropertiesChanged, 884 cast(void*)this, 885 null, 886 connectFlags); 887 connectedSignals["g-properties-changed"] = 1; 888 } 889 onGPropertiesChangedListeners ~= dlg; 890 } 891 extern(C) static void callBackGPropertiesChanged(GDBusProxy* dbusproxyStruct, GVariant* changedProperties, char** invalidatedProperties, DBusProxy _dbusproxy) 892 { 893 foreach ( void delegate(Variant, string[], DBusProxy) dlg; _dbusproxy.onGPropertiesChangedListeners ) 894 { 895 dlg(new Variant(changedProperties), Str.toStringArray(invalidatedProperties), _dbusproxy); 896 } 897 } 898 899 void delegate(string, string, Variant, DBusProxy)[] onGSignalListeners; 900 /** 901 * Emitted when a signal from the remote object and interface that @proxy is for, has been received. 902 * 903 * Params: 904 * senderName = The sender of the signal or %NULL if the connection is not a bus connection. 905 * signalName = The name of the signal. 906 * parameters = A #GVariant tuple with parameters for the signal. 907 * 908 * Since: 2.26 909 */ 910 void addOnGSignal(void delegate(string, string, Variant, DBusProxy) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 911 { 912 if ( "g-signal" !in connectedSignals ) 913 { 914 Signals.connectData( 915 this, 916 "g-signal", 917 cast(GCallback)&callBackGSignal, 918 cast(void*)this, 919 null, 920 connectFlags); 921 connectedSignals["g-signal"] = 1; 922 } 923 onGSignalListeners ~= dlg; 924 } 925 extern(C) static void callBackGSignal(GDBusProxy* dbusproxyStruct, char* senderName, char* signalName, GVariant* parameters, DBusProxy _dbusproxy) 926 { 927 foreach ( void delegate(string, string, Variant, DBusProxy) dlg; _dbusproxy.onGSignalListeners ) 928 { 929 dlg(Str.toString(senderName), Str.toString(signalName), new Variant(parameters), _dbusproxy); 930 } 931 } 932 }