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.DBusConnection; 26 27 private import gio.ActionGroupIF; 28 private import gio.AsyncInitableIF; 29 private import gio.AsyncInitableT; 30 private import gio.AsyncResultIF; 31 private import gio.Cancellable; 32 private import gio.Credentials; 33 private import gio.DBusAuthObserver; 34 private import gio.DBusInterfaceInfo; 35 private import gio.DBusMessage; 36 private import gio.IOStream; 37 private import gio.InitableIF; 38 private import gio.InitableT; 39 private import gio.MenuModel; 40 private import gio.UnixFDList; 41 private import gio.c.functions; 42 public import gio.c.types; 43 private import glib.ConstructionException; 44 private import glib.ErrorG; 45 private import glib.GException; 46 private import glib.Str; 47 private import glib.Variant; 48 private import glib.VariantType; 49 private import gobject.Closure; 50 private import gobject.ObjectG; 51 private import gobject.Signals; 52 public import gtkc.giotypes; 53 private import std.algorithm; 54 55 56 /** 57 * The #GDBusConnection type is used for D-Bus connections to remote 58 * peers such as a message buses. It is a low-level API that offers a 59 * lot of flexibility. For instance, it lets you establish a connection 60 * over any transport that can by represented as a #GIOStream. 61 * 62 * This class is rarely used directly in D-Bus clients. If you are writing 63 * a D-Bus client, it is often easier to use the g_bus_own_name(), 64 * g_bus_watch_name() or g_dbus_proxy_new_for_bus() APIs. 65 * 66 * As an exception to the usual GLib rule that a particular object must not 67 * be used by two threads at the same time, #GDBusConnection's methods may be 68 * called from any thread. This is so that g_bus_get() and g_bus_get_sync() 69 * can safely return the same #GDBusConnection when called from any thread. 70 * 71 * Most of the ways to obtain a #GDBusConnection automatically initialize it 72 * (i.e. connect to D-Bus): for instance, g_dbus_connection_new() and 73 * g_bus_get(), and the synchronous versions of those methods, give you an 74 * initialized connection. Language bindings for GIO should use 75 * g_initable_new() or g_async_initable_new_async(), which also initialize the 76 * connection. 77 * 78 * If you construct an uninitialized #GDBusConnection, such as via 79 * g_object_new(), you must initialize it via g_initable_init() or 80 * g_async_initable_init_async() before using its methods or properties. 81 * Calling methods or accessing properties on a #GDBusConnection that has not 82 * completed initialization successfully is considered to be invalid, and leads 83 * to undefined behaviour. In particular, if initialization fails with a 84 * #GError, the only valid thing you can do with that #GDBusConnection is to 85 * free it with g_object_unref(). 86 * 87 * ## An example D-Bus server # {#gdbus-server} 88 * 89 * Here is an example for a D-Bus server: 90 * [gdbus-example-server.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-server.c) 91 * 92 * ## An example for exporting a subtree # {#gdbus-subtree-server} 93 * 94 * Here is an example for exporting a subtree: 95 * [gdbus-example-subtree.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-subtree.c) 96 * 97 * ## An example for file descriptor passing # {#gdbus-unix-fd-client} 98 * 99 * Here is an example for passing UNIX file descriptors: 100 * [gdbus-unix-fd-client.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-unix-fd-client.c) 101 * 102 * ## An example for exporting a GObject # {#gdbus-export} 103 * 104 * Here is an example for exporting a #GObject: 105 * [gdbus-example-export.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-export.c) 106 * 107 * Since: 2.26 108 */ 109 public class DBusConnection : ObjectG, AsyncInitableIF, InitableIF 110 { 111 /** the main Gtk struct */ 112 protected GDBusConnection* gDBusConnection; 113 114 /** Get the main Gtk struct */ 115 public GDBusConnection* getDBusConnectionStruct(bool transferOwnership = false) 116 { 117 if (transferOwnership) 118 ownedRef = false; 119 return gDBusConnection; 120 } 121 122 /** the main Gtk struct as a void* */ 123 protected override void* getStruct() 124 { 125 return cast(void*)gDBusConnection; 126 } 127 128 /** 129 * Sets our main struct and passes it to the parent class. 130 */ 131 public this (GDBusConnection* gDBusConnection, bool ownedRef = false) 132 { 133 this.gDBusConnection = gDBusConnection; 134 super(cast(GObject*)gDBusConnection, ownedRef); 135 } 136 137 // add the AsyncInitable capabilities 138 mixin AsyncInitableT!(GDBusConnection); 139 140 // add the Initable capabilities 141 mixin InitableT!(GDBusConnection); 142 143 /** 144 * Finishes an operation started with g_dbus_connection_new(). 145 * 146 * Params: 147 * res = A GAsyncResult obtained from the GAsyncReadyCallback 148 * passed to g_dbus_connection_new(). 149 * address = If true finish an address. 150 * 151 * Throws: GException on failure. 152 * Throws: ConstructionException GTK+ fails to create the object. 153 * 154 * Since: 2.26 155 */ 156 public this (AsyncResultIF res, bool address = false) 157 { 158 GError* err = null; 159 GDBusConnection* p; 160 161 if ( address ) 162 { 163 p = g_dbus_connection_new_for_address_finish((res is null) ? null : res.getAsyncResultStruct(), &err); 164 } 165 else 166 { 167 p = g_dbus_connection_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err); 168 } 169 170 if (err !is null) 171 { 172 throw new GException( new ErrorG(err) ); 173 } 174 175 if(p is null) 176 { 177 throw new ConstructionException("null returned by g_dbus_connection_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err)"); 178 } 179 this(p, true); 180 } 181 182 /** 183 */ 184 185 /** */ 186 public static GType getType() 187 { 188 return g_dbus_connection_get_type(); 189 } 190 191 /** 192 * Synchronously connects and sets up a D-Bus client connection for 193 * exchanging D-Bus messages with an endpoint specified by @address 194 * which must be in the 195 * [D-Bus address format](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses). 196 * 197 * This constructor can only be used to initiate client-side 198 * connections - use g_dbus_connection_new_sync() if you need to act 199 * as the server. In particular, @flags cannot contain the 200 * %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER or 201 * %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS flags. 202 * 203 * This is a synchronous failable constructor. See 204 * g_dbus_connection_new_for_address() for the asynchronous version. 205 * 206 * If @observer is not %NULL it may be used to control the 207 * authentication process. 208 * 209 * Params: 210 * address = a D-Bus address 211 * flags = flags describing how to make the connection 212 * observer = a #GDBusAuthObserver or %NULL 213 * cancellable = a #GCancellable or %NULL 214 * 215 * Returns: a #GDBusConnection or %NULL if @error is set. Free with 216 * g_object_unref(). 217 * 218 * Since: 2.26 219 * 220 * Throws: GException on failure. 221 * Throws: ConstructionException GTK+ fails to create the object. 222 */ 223 public this(string address, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable) 224 { 225 GError* err = null; 226 227 auto __p = g_dbus_connection_new_for_address_sync(Str.toStringz(address), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 228 229 if (err !is null) 230 { 231 throw new GException( new ErrorG(err) ); 232 } 233 234 if(__p is null) 235 { 236 throw new ConstructionException("null returned by new_for_address_sync"); 237 } 238 239 this(cast(GDBusConnection*) __p, true); 240 } 241 242 /** 243 * Synchronously sets up a D-Bus connection for exchanging D-Bus messages 244 * with the end represented by @stream. 245 * 246 * If @stream is a #GSocketConnection, then the corresponding #GSocket 247 * will be put into non-blocking mode. 248 * 249 * The D-Bus connection will interact with @stream from a worker thread. 250 * As a result, the caller should not interact with @stream after this 251 * method has been called, except by calling g_object_unref() on it. 252 * 253 * If @observer is not %NULL it may be used to control the 254 * authentication process. 255 * 256 * This is a synchronous failable constructor. See 257 * g_dbus_connection_new() for the asynchronous version. 258 * 259 * Params: 260 * stream = a #GIOStream 261 * guid = the GUID to use if authenticating as a server or %NULL 262 * flags = flags describing how to make the connection 263 * observer = a #GDBusAuthObserver or %NULL 264 * cancellable = a #GCancellable or %NULL 265 * 266 * Returns: a #GDBusConnection or %NULL if @error is set. Free with g_object_unref(). 267 * 268 * Since: 2.26 269 * 270 * Throws: GException on failure. 271 * Throws: ConstructionException GTK+ fails to create the object. 272 */ 273 public this(IOStream stream, string guid, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable) 274 { 275 GError* err = null; 276 277 auto __p = g_dbus_connection_new_sync((stream is null) ? null : stream.getIOStreamStruct(), Str.toStringz(guid), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 278 279 if (err !is null) 280 { 281 throw new GException( new ErrorG(err) ); 282 } 283 284 if(__p is null) 285 { 286 throw new ConstructionException("null returned by new_sync"); 287 } 288 289 this(cast(GDBusConnection*) __p, true); 290 } 291 292 /** 293 * Asynchronously sets up a D-Bus connection for exchanging D-Bus messages 294 * with the end represented by @stream. 295 * 296 * If @stream is a #GSocketConnection, then the corresponding #GSocket 297 * will be put into non-blocking mode. 298 * 299 * The D-Bus connection will interact with @stream from a worker thread. 300 * As a result, the caller should not interact with @stream after this 301 * method has been called, except by calling g_object_unref() on it. 302 * 303 * If @observer is not %NULL it may be used to control the 304 * authentication process. 305 * 306 * When the operation is finished, @callback will be invoked. You can 307 * then call g_dbus_connection_new_finish() to get the result of the 308 * operation. 309 * 310 * This is an asynchronous failable constructor. See 311 * g_dbus_connection_new_sync() for the synchronous 312 * version. 313 * 314 * Params: 315 * stream = a #GIOStream 316 * guid = the GUID to use if authenticating as a server or %NULL 317 * flags = flags describing how to make the connection 318 * observer = a #GDBusAuthObserver or %NULL 319 * cancellable = a #GCancellable or %NULL 320 * callback = a #GAsyncReadyCallback to call when the request is satisfied 321 * userData = the data to pass to @callback 322 * 323 * Since: 2.26 324 */ 325 public static void new_(IOStream stream, string guid, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 326 { 327 g_dbus_connection_new((stream is null) ? null : stream.getIOStreamStruct(), Str.toStringz(guid), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 328 } 329 330 /** 331 * Asynchronously connects and sets up a D-Bus client connection for 332 * exchanging D-Bus messages with an endpoint specified by @address 333 * which must be in the 334 * [D-Bus address format](https://dbus.freedesktop.org/doc/dbus-specification.html#addresses). 335 * 336 * This constructor can only be used to initiate client-side 337 * connections - use g_dbus_connection_new() if you need to act as the 338 * server. In particular, @flags cannot contain the 339 * %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER or 340 * %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS flags. 341 * 342 * When the operation is finished, @callback will be invoked. You can 343 * then call g_dbus_connection_new_for_address_finish() to get the result of 344 * the operation. 345 * 346 * If @observer is not %NULL it may be used to control the 347 * authentication process. 348 * 349 * This is an asynchronous failable constructor. See 350 * g_dbus_connection_new_for_address_sync() for the synchronous 351 * version. 352 * 353 * Params: 354 * address = a D-Bus address 355 * flags = flags describing how to make the connection 356 * observer = a #GDBusAuthObserver or %NULL 357 * cancellable = a #GCancellable or %NULL 358 * callback = a #GAsyncReadyCallback to call when the request is satisfied 359 * userData = the data to pass to @callback 360 * 361 * Since: 2.26 362 */ 363 public static void newForAddress(string address, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 364 { 365 g_dbus_connection_new_for_address(Str.toStringz(address), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 366 } 367 368 /** 369 * Adds a message filter. Filters are handlers that are run on all 370 * incoming and outgoing messages, prior to standard dispatch. Filters 371 * are run in the order that they were added. The same handler can be 372 * added as a filter more than once, in which case it will be run more 373 * than once. Filters added during a filter callback won't be run on 374 * the message being processed. Filter functions are allowed to modify 375 * and even drop messages. 376 * 377 * Note that filters are run in a dedicated message handling thread so 378 * they can't block and, generally, can't do anything but signal a 379 * worker thread. Also note that filters are rarely needed - use API 380 * such as g_dbus_connection_send_message_with_reply(), 381 * g_dbus_connection_signal_subscribe() or g_dbus_connection_call() instead. 382 * 383 * If a filter consumes an incoming message the message is not 384 * dispatched anywhere else - not even the standard dispatch machinery 385 * (that API such as g_dbus_connection_signal_subscribe() and 386 * g_dbus_connection_send_message_with_reply() relies on) will see the 387 * message. Similarly, if a filter consumes an outgoing message, the 388 * message will not be sent to the other peer. 389 * 390 * If @user_data_free_func is non-%NULL, it will be called (in the 391 * thread-default main context of the thread you are calling this 392 * method from) at some point after @user_data is no longer 393 * needed. (It is not guaranteed to be called synchronously when the 394 * filter is removed, and may be called after @connection has been 395 * destroyed.) 396 * 397 * Params: 398 * filterFunction = a filter function 399 * userData = user data to pass to @filter_function 400 * userDataFreeFunc = function to free @user_data with when filter 401 * is removed or %NULL 402 * 403 * Returns: a filter identifier that can be used with 404 * g_dbus_connection_remove_filter() 405 * 406 * Since: 2.26 407 */ 408 public uint addFilter(GDBusMessageFilterFunction filterFunction, void* userData, GDestroyNotify userDataFreeFunc) 409 { 410 return g_dbus_connection_add_filter(gDBusConnection, filterFunction, userData, userDataFreeFunc); 411 } 412 413 /** 414 * Asynchronously invokes the @method_name method on the 415 * @interface_name D-Bus interface on the remote object at 416 * @object_path owned by @bus_name. 417 * 418 * If @connection is closed then the operation will fail with 419 * %G_IO_ERROR_CLOSED. If @cancellable is canceled, the operation will 420 * fail with %G_IO_ERROR_CANCELLED. If @parameters contains a value 421 * not compatible with the D-Bus protocol, the operation fails with 422 * %G_IO_ERROR_INVALID_ARGUMENT. 423 * 424 * If @reply_type is non-%NULL then the reply will be checked for having this type and an 425 * error will be raised if it does not match. Said another way, if you give a @reply_type 426 * then any non-%NULL return value will be of this type. Unless it’s 427 * %G_VARIANT_TYPE_UNIT, the @reply_type will be a tuple containing one or more 428 * values. 429 * 430 * If the @parameters #GVariant is floating, it is consumed. This allows 431 * convenient 'inline' use of g_variant_new(), e.g.: 432 * |[<!-- language="C" --> 433 * g_dbus_connection_call (connection, 434 * "org.freedesktop.StringThings", 435 * "/org/freedesktop/StringThings", 436 * "org.freedesktop.StringThings", 437 * "TwoStrings", 438 * g_variant_new ("(ss)", 439 * "Thing One", 440 * "Thing Two"), 441 * NULL, 442 * G_DBUS_CALL_FLAGS_NONE, 443 * -1, 444 * NULL, 445 * (GAsyncReadyCallback) two_strings_done, 446 * NULL); 447 * ]| 448 * 449 * This is an asynchronous method. When the operation is finished, 450 * @callback will be invoked in the 451 * [thread-default main context][g-main-context-push-thread-default] 452 * of the thread you are calling this method from. You can then call 453 * g_dbus_connection_call_finish() to get the result of the operation. 454 * See g_dbus_connection_call_sync() for the synchronous version of this 455 * function. 456 * 457 * If @callback is %NULL then the D-Bus method call message will be sent with 458 * the %G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED flag set. 459 * 460 * Params: 461 * busName = a unique or well-known bus name or %NULL if 462 * @connection is not a message bus connection 463 * objectPath = path of remote object 464 * interfaceName = D-Bus interface to invoke method on 465 * methodName = the name of the method to invoke 466 * parameters = a #GVariant tuple with parameters for the method 467 * or %NULL if not passing parameters 468 * replyType = the expected type of the reply (which will be a 469 * tuple), or %NULL 470 * flags = flags from the #GDBusCallFlags enumeration 471 * timeoutMsec = the timeout in milliseconds, -1 to use the default 472 * timeout or %G_MAXINT for no timeout 473 * cancellable = a #GCancellable or %NULL 474 * callback = a #GAsyncReadyCallback to call when the request 475 * is satisfied or %NULL if you don't care about the result of the 476 * method invocation 477 * userData = the data to pass to @callback 478 * 479 * Since: 2.26 480 */ 481 public void call(string busName, string objectPath, string interfaceName, string methodName, Variant parameters, VariantType replyType, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 482 { 483 g_dbus_connection_call(gDBusConnection, Str.toStringz(busName), Str.toStringz(objectPath), Str.toStringz(interfaceName), Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), (replyType is null) ? null : replyType.getVariantTypeStruct(), flags, timeoutMsec, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 484 } 485 486 /** 487 * Finishes an operation started with g_dbus_connection_call(). 488 * 489 * Params: 490 * res = a #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_connection_call() 491 * 492 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 493 * return values. Free with g_variant_unref(). 494 * 495 * Since: 2.26 496 * 497 * Throws: GException on failure. 498 */ 499 public Variant callFinish(AsyncResultIF res) 500 { 501 GError* err = null; 502 503 auto __p = g_dbus_connection_call_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultStruct(), &err); 504 505 if (err !is null) 506 { 507 throw new GException( new ErrorG(err) ); 508 } 509 510 if(__p is null) 511 { 512 return null; 513 } 514 515 return new Variant(cast(GVariant*) __p, true); 516 } 517 518 /** 519 * Synchronously invokes the @method_name method on the 520 * @interface_name D-Bus interface on the remote object at 521 * @object_path owned by @bus_name. 522 * 523 * If @connection is closed then the operation will fail with 524 * %G_IO_ERROR_CLOSED. If @cancellable is canceled, the 525 * operation will fail with %G_IO_ERROR_CANCELLED. If @parameters 526 * contains a value not compatible with the D-Bus protocol, the operation 527 * fails with %G_IO_ERROR_INVALID_ARGUMENT. 528 * 529 * If @reply_type is non-%NULL then the reply will be checked for having 530 * this type and an error will be raised if it does not match. Said 531 * another way, if you give a @reply_type then any non-%NULL return 532 * value will be of this type. 533 * 534 * If the @parameters #GVariant is floating, it is consumed. 535 * This allows convenient 'inline' use of g_variant_new(), e.g.: 536 * |[<!-- language="C" --> 537 * g_dbus_connection_call_sync (connection, 538 * "org.freedesktop.StringThings", 539 * "/org/freedesktop/StringThings", 540 * "org.freedesktop.StringThings", 541 * "TwoStrings", 542 * g_variant_new ("(ss)", 543 * "Thing One", 544 * "Thing Two"), 545 * NULL, 546 * G_DBUS_CALL_FLAGS_NONE, 547 * -1, 548 * NULL, 549 * &error); 550 * ]| 551 * 552 * The calling thread is blocked until a reply is received. See 553 * g_dbus_connection_call() for the asynchronous version of 554 * this method. 555 * 556 * Params: 557 * busName = a unique or well-known bus name or %NULL if 558 * @connection is not a message bus connection 559 * objectPath = path of remote object 560 * interfaceName = D-Bus interface to invoke method on 561 * methodName = the name of the method to invoke 562 * parameters = a #GVariant tuple with parameters for the method 563 * or %NULL if not passing parameters 564 * replyType = the expected type of the reply, or %NULL 565 * flags = flags from the #GDBusCallFlags enumeration 566 * timeoutMsec = the timeout in milliseconds, -1 to use the default 567 * timeout or %G_MAXINT for no timeout 568 * cancellable = a #GCancellable or %NULL 569 * 570 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 571 * return values. Free with g_variant_unref(). 572 * 573 * Since: 2.26 574 * 575 * Throws: GException on failure. 576 */ 577 public Variant callSync(string busName, string objectPath, string interfaceName, string methodName, Variant parameters, VariantType replyType, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable) 578 { 579 GError* err = null; 580 581 auto __p = g_dbus_connection_call_sync(gDBusConnection, Str.toStringz(busName), Str.toStringz(objectPath), Str.toStringz(interfaceName), Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), (replyType is null) ? null : replyType.getVariantTypeStruct(), flags, timeoutMsec, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 582 583 if (err !is null) 584 { 585 throw new GException( new ErrorG(err) ); 586 } 587 588 if(__p is null) 589 { 590 return null; 591 } 592 593 return new Variant(cast(GVariant*) __p, true); 594 } 595 596 /** 597 * Like g_dbus_connection_call() but also takes a #GUnixFDList object. 598 * 599 * This method is only available on UNIX. 600 * 601 * Params: 602 * busName = a unique or well-known bus name or %NULL if 603 * @connection is not a message bus connection 604 * objectPath = path of remote object 605 * interfaceName = D-Bus interface to invoke method on 606 * methodName = the name of the method to invoke 607 * parameters = a #GVariant tuple with parameters for the method 608 * or %NULL if not passing parameters 609 * replyType = the expected type of the reply, or %NULL 610 * flags = flags from the #GDBusCallFlags enumeration 611 * timeoutMsec = the timeout in milliseconds, -1 to use the default 612 * timeout or %G_MAXINT for no timeout 613 * fdList = a #GUnixFDList or %NULL 614 * cancellable = a #GCancellable or %NULL 615 * callback = a #GAsyncReadyCallback to call when the request is 616 * satisfied or %NULL if you don't * care about the result of the 617 * method invocation 618 * userData = The data to pass to @callback. 619 * 620 * Since: 2.30 621 */ 622 public void callWithUnixFdList(string busName, string objectPath, string interfaceName, string methodName, Variant parameters, VariantType replyType, GDBusCallFlags flags, int timeoutMsec, UnixFDList fdList, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 623 { 624 g_dbus_connection_call_with_unix_fd_list(gDBusConnection, Str.toStringz(busName), Str.toStringz(objectPath), Str.toStringz(interfaceName), Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), (replyType is null) ? null : replyType.getVariantTypeStruct(), flags, timeoutMsec, (fdList is null) ? null : fdList.getUnixFDListStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 625 } 626 627 /** 628 * Finishes an operation started with g_dbus_connection_call_with_unix_fd_list(). 629 * 630 * Params: 631 * outFdList = return location for a #GUnixFDList or %NULL 632 * res = a #GAsyncResult obtained from the #GAsyncReadyCallback passed to 633 * g_dbus_connection_call_with_unix_fd_list() 634 * 635 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 636 * return values. Free with g_variant_unref(). 637 * 638 * Since: 2.30 639 * 640 * Throws: GException on failure. 641 */ 642 public Variant callWithUnixFdListFinish(out UnixFDList outFdList, AsyncResultIF res) 643 { 644 GUnixFDList* outoutFdList = null; 645 GError* err = null; 646 647 auto __p = g_dbus_connection_call_with_unix_fd_list_finish(gDBusConnection, &outoutFdList, (res is null) ? null : res.getAsyncResultStruct(), &err); 648 649 if (err !is null) 650 { 651 throw new GException( new ErrorG(err) ); 652 } 653 654 outFdList = ObjectG.getDObject!(UnixFDList)(outoutFdList); 655 656 if(__p is null) 657 { 658 return null; 659 } 660 661 return new Variant(cast(GVariant*) __p, true); 662 } 663 664 /** 665 * Like g_dbus_connection_call_sync() but also takes and returns #GUnixFDList objects. 666 * 667 * This method is only available on UNIX. 668 * 669 * Params: 670 * busName = a unique or well-known bus name or %NULL 671 * if @connection is not a message bus connection 672 * objectPath = path of remote object 673 * interfaceName = D-Bus interface to invoke method on 674 * methodName = the name of the method to invoke 675 * parameters = a #GVariant tuple with parameters for 676 * the method or %NULL if not passing parameters 677 * replyType = the expected type of the reply, or %NULL 678 * flags = flags from the #GDBusCallFlags enumeration 679 * timeoutMsec = the timeout in milliseconds, -1 to use the default 680 * timeout or %G_MAXINT for no timeout 681 * fdList = a #GUnixFDList or %NULL 682 * outFdList = return location for a #GUnixFDList or %NULL 683 * cancellable = a #GCancellable or %NULL 684 * 685 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 686 * return values. Free with g_variant_unref(). 687 * 688 * Since: 2.30 689 * 690 * Throws: GException on failure. 691 */ 692 public Variant callWithUnixFdListSync(string busName, string objectPath, string interfaceName, string methodName, Variant parameters, VariantType replyType, GDBusCallFlags flags, int timeoutMsec, UnixFDList fdList, out UnixFDList outFdList, Cancellable cancellable) 693 { 694 GUnixFDList* outoutFdList = null; 695 GError* err = null; 696 697 auto __p = g_dbus_connection_call_with_unix_fd_list_sync(gDBusConnection, Str.toStringz(busName), Str.toStringz(objectPath), Str.toStringz(interfaceName), Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), (replyType is null) ? null : replyType.getVariantTypeStruct(), flags, timeoutMsec, (fdList is null) ? null : fdList.getUnixFDListStruct(), &outoutFdList, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 698 699 if (err !is null) 700 { 701 throw new GException( new ErrorG(err) ); 702 } 703 704 outFdList = ObjectG.getDObject!(UnixFDList)(outoutFdList); 705 706 if(__p is null) 707 { 708 return null; 709 } 710 711 return new Variant(cast(GVariant*) __p, true); 712 } 713 714 /** 715 * Closes @connection. Note that this never causes the process to 716 * exit (this might only happen if the other end of a shared message 717 * bus connection disconnects, see #GDBusConnection:exit-on-close). 718 * 719 * Once the connection is closed, operations such as sending a message 720 * will return with the error %G_IO_ERROR_CLOSED. Closing a connection 721 * will not automatically flush the connection so queued messages may 722 * be lost. Use g_dbus_connection_flush() if you need such guarantees. 723 * 724 * If @connection is already closed, this method fails with 725 * %G_IO_ERROR_CLOSED. 726 * 727 * When @connection has been closed, the #GDBusConnection::closed 728 * signal is emitted in the 729 * [thread-default main context][g-main-context-push-thread-default] 730 * of the thread that @connection was constructed in. 731 * 732 * This is an asynchronous method. When the operation is finished, 733 * @callback will be invoked in the 734 * [thread-default main context][g-main-context-push-thread-default] 735 * of the thread you are calling this method from. You can 736 * then call g_dbus_connection_close_finish() to get the result of the 737 * operation. See g_dbus_connection_close_sync() for the synchronous 738 * version. 739 * 740 * Params: 741 * cancellable = a #GCancellable or %NULL 742 * callback = a #GAsyncReadyCallback to call when the request is 743 * satisfied or %NULL if you don't care about the result 744 * userData = The data to pass to @callback 745 * 746 * Since: 2.26 747 */ 748 public void close(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 749 { 750 g_dbus_connection_close(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 751 } 752 753 /** 754 * Finishes an operation started with g_dbus_connection_close(). 755 * 756 * Params: 757 * res = a #GAsyncResult obtained from the #GAsyncReadyCallback passed 758 * to g_dbus_connection_close() 759 * 760 * Returns: %TRUE if the operation succeeded, %FALSE if @error is set 761 * 762 * Since: 2.26 763 * 764 * Throws: GException on failure. 765 */ 766 public bool closeFinish(AsyncResultIF res) 767 { 768 GError* err = null; 769 770 auto __p = g_dbus_connection_close_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultStruct(), &err) != 0; 771 772 if (err !is null) 773 { 774 throw new GException( new ErrorG(err) ); 775 } 776 777 return __p; 778 } 779 780 /** 781 * Synchronously closes @connection. The calling thread is blocked 782 * until this is done. See g_dbus_connection_close() for the 783 * asynchronous version of this method and more details about what it 784 * does. 785 * 786 * Params: 787 * cancellable = a #GCancellable or %NULL 788 * 789 * Returns: %TRUE if the operation succeeded, %FALSE if @error is set 790 * 791 * Since: 2.26 792 * 793 * Throws: GException on failure. 794 */ 795 public bool closeSync(Cancellable cancellable) 796 { 797 GError* err = null; 798 799 auto __p = g_dbus_connection_close_sync(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 800 801 if (err !is null) 802 { 803 throw new GException( new ErrorG(err) ); 804 } 805 806 return __p; 807 } 808 809 /** 810 * Emits a signal. 811 * 812 * If the parameters GVariant is floating, it is consumed. 813 * 814 * This can only fail if @parameters is not compatible with the D-Bus protocol 815 * (%G_IO_ERROR_INVALID_ARGUMENT), or if @connection has been closed 816 * (%G_IO_ERROR_CLOSED). 817 * 818 * Params: 819 * destinationBusName = the unique bus name for the destination 820 * for the signal or %NULL to emit to all listeners 821 * objectPath = path of remote object 822 * interfaceName = D-Bus interface to emit a signal on 823 * signalName = the name of the signal to emit 824 * parameters = a #GVariant tuple with parameters for the signal 825 * or %NULL if not passing parameters 826 * 827 * Returns: %TRUE unless @error is set 828 * 829 * Since: 2.26 830 * 831 * Throws: GException on failure. 832 */ 833 public bool emitSignal(string destinationBusName, string objectPath, string interfaceName, string signalName, Variant parameters) 834 { 835 GError* err = null; 836 837 auto __p = g_dbus_connection_emit_signal(gDBusConnection, Str.toStringz(destinationBusName), Str.toStringz(objectPath), Str.toStringz(interfaceName), Str.toStringz(signalName), (parameters is null) ? null : parameters.getVariantStruct(), &err) != 0; 838 839 if (err !is null) 840 { 841 throw new GException( new ErrorG(err) ); 842 } 843 844 return __p; 845 } 846 847 /** 848 * Exports @action_group on @connection at @object_path. 849 * 850 * The implemented D-Bus API should be considered private. It is 851 * subject to change in the future. 852 * 853 * A given object path can only have one action group exported on it. 854 * If this constraint is violated, the export will fail and 0 will be 855 * returned (with @error set accordingly). 856 * 857 * You can unexport the action group using 858 * g_dbus_connection_unexport_action_group() with the return value of 859 * this function. 860 * 861 * The thread default main context is taken at the time of this call. 862 * All incoming action activations and state change requests are 863 * reported from this context. Any changes on the action group that 864 * cause it to emit signals must also come from this same context. 865 * Since incoming action activations and state change requests are 866 * rather likely to cause changes on the action group, this effectively 867 * limits a given action group to being exported from only one main 868 * context. 869 * 870 * Params: 871 * objectPath = a D-Bus object path 872 * actionGroup = a #GActionGroup 873 * 874 * Returns: the ID of the export (never zero), or 0 in case of failure 875 * 876 * Since: 2.32 877 * 878 * Throws: GException on failure. 879 */ 880 public uint exportActionGroup(string objectPath, ActionGroupIF actionGroup) 881 { 882 GError* err = null; 883 884 auto __p = g_dbus_connection_export_action_group(gDBusConnection, Str.toStringz(objectPath), (actionGroup is null) ? null : actionGroup.getActionGroupStruct(), &err); 885 886 if (err !is null) 887 { 888 throw new GException( new ErrorG(err) ); 889 } 890 891 return __p; 892 } 893 894 /** 895 * Exports @menu on @connection at @object_path. 896 * 897 * The implemented D-Bus API should be considered private. 898 * It is subject to change in the future. 899 * 900 * An object path can only have one menu model exported on it. If this 901 * constraint is violated, the export will fail and 0 will be 902 * returned (with @error set accordingly). 903 * 904 * You can unexport the menu model using 905 * g_dbus_connection_unexport_menu_model() with the return value of 906 * this function. 907 * 908 * Params: 909 * objectPath = a D-Bus object path 910 * menu = a #GMenuModel 911 * 912 * Returns: the ID of the export (never zero), or 0 in case of failure 913 * 914 * Since: 2.32 915 * 916 * Throws: GException on failure. 917 */ 918 public uint exportMenuModel(string objectPath, MenuModel menu) 919 { 920 GError* err = null; 921 922 auto __p = g_dbus_connection_export_menu_model(gDBusConnection, Str.toStringz(objectPath), (menu is null) ? null : menu.getMenuModelStruct(), &err); 923 924 if (err !is null) 925 { 926 throw new GException( new ErrorG(err) ); 927 } 928 929 return __p; 930 } 931 932 /** 933 * Asynchronously flushes @connection, that is, writes all queued 934 * outgoing message to the transport and then flushes the transport 935 * (using g_output_stream_flush_async()). This is useful in programs 936 * that wants to emit a D-Bus signal and then exit immediately. Without 937 * flushing the connection, there is no guaranteed that the message has 938 * been sent to the networking buffers in the OS kernel. 939 * 940 * This is an asynchronous method. When the operation is finished, 941 * @callback will be invoked in the 942 * [thread-default main context][g-main-context-push-thread-default] 943 * of the thread you are calling this method from. You can 944 * then call g_dbus_connection_flush_finish() to get the result of the 945 * operation. See g_dbus_connection_flush_sync() for the synchronous 946 * version. 947 * 948 * Params: 949 * cancellable = a #GCancellable or %NULL 950 * callback = a #GAsyncReadyCallback to call when the 951 * request is satisfied or %NULL if you don't care about the result 952 * userData = The data to pass to @callback 953 * 954 * Since: 2.26 955 */ 956 public void flush(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 957 { 958 g_dbus_connection_flush(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 959 } 960 961 /** 962 * Finishes an operation started with g_dbus_connection_flush(). 963 * 964 * Params: 965 * res = a #GAsyncResult obtained from the #GAsyncReadyCallback passed 966 * to g_dbus_connection_flush() 967 * 968 * Returns: %TRUE if the operation succeeded, %FALSE if @error is set 969 * 970 * Since: 2.26 971 * 972 * Throws: GException on failure. 973 */ 974 public bool flushFinish(AsyncResultIF res) 975 { 976 GError* err = null; 977 978 auto __p = g_dbus_connection_flush_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultStruct(), &err) != 0; 979 980 if (err !is null) 981 { 982 throw new GException( new ErrorG(err) ); 983 } 984 985 return __p; 986 } 987 988 /** 989 * Synchronously flushes @connection. The calling thread is blocked 990 * until this is done. See g_dbus_connection_flush() for the 991 * asynchronous version of this method and more details about what it 992 * does. 993 * 994 * Params: 995 * cancellable = a #GCancellable or %NULL 996 * 997 * Returns: %TRUE if the operation succeeded, %FALSE if @error is set 998 * 999 * Since: 2.26 1000 * 1001 * Throws: GException on failure. 1002 */ 1003 public bool flushSync(Cancellable cancellable) 1004 { 1005 GError* err = null; 1006 1007 auto __p = g_dbus_connection_flush_sync(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 1008 1009 if (err !is null) 1010 { 1011 throw new GException( new ErrorG(err) ); 1012 } 1013 1014 return __p; 1015 } 1016 1017 /** 1018 * Gets the capabilities negotiated with the remote peer 1019 * 1020 * Returns: zero or more flags from the #GDBusCapabilityFlags enumeration 1021 * 1022 * Since: 2.26 1023 */ 1024 public GDBusCapabilityFlags getCapabilities() 1025 { 1026 return g_dbus_connection_get_capabilities(gDBusConnection); 1027 } 1028 1029 /** 1030 * Gets whether the process is terminated when @connection is 1031 * closed by the remote peer. See 1032 * #GDBusConnection:exit-on-close for more details. 1033 * 1034 * Returns: whether the process is terminated when @connection is 1035 * closed by the remote peer 1036 * 1037 * Since: 2.26 1038 */ 1039 public bool getExitOnClose() 1040 { 1041 return g_dbus_connection_get_exit_on_close(gDBusConnection) != 0; 1042 } 1043 1044 /** 1045 * Gets the flags used to construct this connection 1046 * 1047 * Returns: zero or more flags from the #GDBusConnectionFlags enumeration 1048 * 1049 * Since: 2.60 1050 */ 1051 public GDBusConnectionFlags getFlags() 1052 { 1053 return g_dbus_connection_get_flags(gDBusConnection); 1054 } 1055 1056 /** 1057 * The GUID of the peer performing the role of server when 1058 * authenticating. See #GDBusConnection:guid for more details. 1059 * 1060 * Returns: The GUID. Do not free this string, it is owned by 1061 * @connection. 1062 * 1063 * Since: 2.26 1064 */ 1065 public string getGuid() 1066 { 1067 return Str.toString(g_dbus_connection_get_guid(gDBusConnection)); 1068 } 1069 1070 /** 1071 * Retrieves the last serial number assigned to a #GDBusMessage on 1072 * the current thread. This includes messages sent via both low-level 1073 * API such as g_dbus_connection_send_message() as well as 1074 * high-level API such as g_dbus_connection_emit_signal(), 1075 * g_dbus_connection_call() or g_dbus_proxy_call(). 1076 * 1077 * Returns: the last used serial or zero when no message has been sent 1078 * within the current thread 1079 * 1080 * Since: 2.34 1081 */ 1082 public uint getLastSerial() 1083 { 1084 return g_dbus_connection_get_last_serial(gDBusConnection); 1085 } 1086 1087 /** 1088 * Gets the credentials of the authenticated peer. This will always 1089 * return %NULL unless @connection acted as a server 1090 * (e.g. %G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER was passed) 1091 * when set up and the client passed credentials as part of the 1092 * authentication process. 1093 * 1094 * In a message bus setup, the message bus is always the server and 1095 * each application is a client. So this method will always return 1096 * %NULL for message bus clients. 1097 * 1098 * Returns: a #GCredentials or %NULL if not 1099 * available. Do not free this object, it is owned by @connection. 1100 * 1101 * Since: 2.26 1102 */ 1103 public Credentials getPeerCredentials() 1104 { 1105 auto __p = g_dbus_connection_get_peer_credentials(gDBusConnection); 1106 1107 if(__p is null) 1108 { 1109 return null; 1110 } 1111 1112 return ObjectG.getDObject!(Credentials)(cast(GCredentials*) __p); 1113 } 1114 1115 /** 1116 * Gets the underlying stream used for IO. 1117 * 1118 * While the #GDBusConnection is active, it will interact with this 1119 * stream from a worker thread, so it is not safe to interact with 1120 * the stream directly. 1121 * 1122 * Returns: the stream used for IO 1123 * 1124 * Since: 2.26 1125 */ 1126 public IOStream getStream() 1127 { 1128 auto __p = g_dbus_connection_get_stream(gDBusConnection); 1129 1130 if(__p is null) 1131 { 1132 return null; 1133 } 1134 1135 return ObjectG.getDObject!(IOStream)(cast(GIOStream*) __p); 1136 } 1137 1138 /** 1139 * Gets the unique name of @connection as assigned by the message 1140 * bus. This can also be used to figure out if @connection is a 1141 * message bus connection. 1142 * 1143 * Returns: the unique name or %NULL if @connection is not a message 1144 * bus connection. Do not free this string, it is owned by 1145 * @connection. 1146 * 1147 * Since: 2.26 1148 */ 1149 public string getUniqueName() 1150 { 1151 return Str.toString(g_dbus_connection_get_unique_name(gDBusConnection)); 1152 } 1153 1154 /** 1155 * Gets whether @connection is closed. 1156 * 1157 * Returns: %TRUE if the connection is closed, %FALSE otherwise 1158 * 1159 * Since: 2.26 1160 */ 1161 public bool isClosed() 1162 { 1163 return g_dbus_connection_is_closed(gDBusConnection) != 0; 1164 } 1165 1166 /** 1167 * Registers callbacks for exported objects at @object_path with the 1168 * D-Bus interface that is described in @interface_info. 1169 * 1170 * Calls to functions in @vtable (and @user_data_free_func) will happen 1171 * in the 1172 * [thread-default main context][g-main-context-push-thread-default] 1173 * of the thread you are calling this method from. 1174 * 1175 * Note that all #GVariant values passed to functions in @vtable will match 1176 * the signature given in @interface_info - if a remote caller passes 1177 * incorrect values, the `org.freedesktop.DBus.Error.InvalidArgs` 1178 * is returned to the remote caller. 1179 * 1180 * Additionally, if the remote caller attempts to invoke methods or 1181 * access properties not mentioned in @interface_info the 1182 * `org.freedesktop.DBus.Error.UnknownMethod` resp. 1183 * `org.freedesktop.DBus.Error.InvalidArgs` errors 1184 * are returned to the caller. 1185 * 1186 * It is considered a programming error if the 1187 * #GDBusInterfaceGetPropertyFunc function in @vtable returns a 1188 * #GVariant of incorrect type. 1189 * 1190 * If an existing callback is already registered at @object_path and 1191 * @interface_name, then @error is set to #G_IO_ERROR_EXISTS. 1192 * 1193 * GDBus automatically implements the standard D-Bus interfaces 1194 * org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable 1195 * and org.freedesktop.Peer, so you don't have to implement those for the 1196 * objects you export. You can implement org.freedesktop.DBus.Properties 1197 * yourself, e.g. to handle getting and setting of properties asynchronously. 1198 * 1199 * Note that the reference count on @interface_info will be 1200 * incremented by 1 (unless allocated statically, e.g. if the 1201 * reference count is -1, see g_dbus_interface_info_ref()) for as long 1202 * as the object is exported. Also note that @vtable will be copied. 1203 * 1204 * See this [server][gdbus-server] for an example of how to use this method. 1205 * 1206 * Params: 1207 * objectPath = the object path to register at 1208 * interfaceInfo = introspection data for the interface 1209 * vtable = a #GDBusInterfaceVTable to call into or %NULL 1210 * userData = data to pass to functions in @vtable 1211 * userDataFreeFunc = function to call when the object path is unregistered 1212 * 1213 * Returns: 0 if @error is set, otherwise a registration id (never 0) 1214 * that can be used with g_dbus_connection_unregister_object() 1215 * 1216 * Since: 2.26 1217 * 1218 * Throws: GException on failure. 1219 */ 1220 public uint registerObject(string objectPath, DBusInterfaceInfo interfaceInfo, GDBusInterfaceVTable* vtable, void* userData, GDestroyNotify userDataFreeFunc) 1221 { 1222 GError* err = null; 1223 1224 auto __p = g_dbus_connection_register_object(gDBusConnection, Str.toStringz(objectPath), (interfaceInfo is null) ? null : interfaceInfo.getDBusInterfaceInfoStruct(), vtable, userData, userDataFreeFunc, &err); 1225 1226 if (err !is null) 1227 { 1228 throw new GException( new ErrorG(err) ); 1229 } 1230 1231 return __p; 1232 } 1233 1234 /** 1235 * Version of g_dbus_connection_register_object() using closures instead of a 1236 * #GDBusInterfaceVTable for easier binding in other languages. 1237 * 1238 * Params: 1239 * objectPath = The object path to register at. 1240 * interfaceInfo = Introspection data for the interface. 1241 * methodCallClosure = #GClosure for handling incoming method calls. 1242 * getPropertyClosure = #GClosure for getting a property. 1243 * setPropertyClosure = #GClosure for setting a property. 1244 * 1245 * Returns: 0 if @error is set, otherwise a registration id (never 0) 1246 * that can be used with g_dbus_connection_unregister_object() . 1247 * 1248 * Since: 2.46 1249 * 1250 * Throws: GException on failure. 1251 */ 1252 public uint registerObjectWithClosures(string objectPath, DBusInterfaceInfo interfaceInfo, Closure methodCallClosure, Closure getPropertyClosure, Closure setPropertyClosure) 1253 { 1254 GError* err = null; 1255 1256 auto __p = g_dbus_connection_register_object_with_closures(gDBusConnection, Str.toStringz(objectPath), (interfaceInfo is null) ? null : interfaceInfo.getDBusInterfaceInfoStruct(), (methodCallClosure is null) ? null : methodCallClosure.getClosureStruct(), (getPropertyClosure is null) ? null : getPropertyClosure.getClosureStruct(), (setPropertyClosure is null) ? null : setPropertyClosure.getClosureStruct(), &err); 1257 1258 if (err !is null) 1259 { 1260 throw new GException( new ErrorG(err) ); 1261 } 1262 1263 return __p; 1264 } 1265 1266 /** 1267 * Registers a whole subtree of dynamic objects. 1268 * 1269 * The @enumerate and @introspection functions in @vtable are used to 1270 * convey, to remote callers, what nodes exist in the subtree rooted 1271 * by @object_path. 1272 * 1273 * When handling remote calls into any node in the subtree, first the 1274 * @enumerate function is used to check if the node exists. If the node exists 1275 * or the #G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES flag is set 1276 * the @introspection function is used to check if the node supports the 1277 * requested method. If so, the @dispatch function is used to determine 1278 * where to dispatch the call. The collected #GDBusInterfaceVTable and 1279 * #gpointer will be used to call into the interface vtable for processing 1280 * the request. 1281 * 1282 * All calls into user-provided code will be invoked in the 1283 * [thread-default main context][g-main-context-push-thread-default] 1284 * of the thread you are calling this method from. 1285 * 1286 * If an existing subtree is already registered at @object_path or 1287 * then @error is set to #G_IO_ERROR_EXISTS. 1288 * 1289 * Note that it is valid to register regular objects (using 1290 * g_dbus_connection_register_object()) in a subtree registered with 1291 * g_dbus_connection_register_subtree() - if so, the subtree handler 1292 * is tried as the last resort. One way to think about a subtree 1293 * handler is to consider it a fallback handler for object paths not 1294 * registered via g_dbus_connection_register_object() or other bindings. 1295 * 1296 * Note that @vtable will be copied so you cannot change it after 1297 * registration. 1298 * 1299 * See this [server][gdbus-subtree-server] for an example of how to use 1300 * this method. 1301 * 1302 * Params: 1303 * objectPath = the object path to register the subtree at 1304 * vtable = a #GDBusSubtreeVTable to enumerate, introspect and 1305 * dispatch nodes in the subtree 1306 * flags = flags used to fine tune the behavior of the subtree 1307 * userData = data to pass to functions in @vtable 1308 * userDataFreeFunc = function to call when the subtree is unregistered 1309 * 1310 * Returns: 0 if @error is set, otherwise a subtree registration id (never 0) 1311 * that can be used with g_dbus_connection_unregister_subtree() . 1312 * 1313 * Since: 2.26 1314 * 1315 * Throws: GException on failure. 1316 */ 1317 public uint registerSubtree(string objectPath, GDBusSubtreeVTable* vtable, GDBusSubtreeFlags flags, void* userData, GDestroyNotify userDataFreeFunc) 1318 { 1319 GError* err = null; 1320 1321 auto __p = g_dbus_connection_register_subtree(gDBusConnection, Str.toStringz(objectPath), vtable, flags, userData, userDataFreeFunc, &err); 1322 1323 if (err !is null) 1324 { 1325 throw new GException( new ErrorG(err) ); 1326 } 1327 1328 return __p; 1329 } 1330 1331 /** 1332 * Removes a filter. 1333 * 1334 * Note that since filters run in a different thread, there is a race 1335 * condition where it is possible that the filter will be running even 1336 * after calling g_dbus_connection_remove_filter(), so you cannot just 1337 * free data that the filter might be using. Instead, you should pass 1338 * a #GDestroyNotify to g_dbus_connection_add_filter(), which will be 1339 * called when it is guaranteed that the data is no longer needed. 1340 * 1341 * Params: 1342 * filterId = an identifier obtained from g_dbus_connection_add_filter() 1343 * 1344 * Since: 2.26 1345 */ 1346 public void removeFilter(uint filterId) 1347 { 1348 g_dbus_connection_remove_filter(gDBusConnection, filterId); 1349 } 1350 1351 /** 1352 * Asynchronously sends @message to the peer represented by @connection. 1353 * 1354 * Unless @flags contain the 1355 * %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number 1356 * will be assigned by @connection and set on @message via 1357 * g_dbus_message_set_serial(). If @out_serial is not %NULL, then the 1358 * serial number used will be written to this location prior to 1359 * submitting the message to the underlying transport. 1360 * 1361 * If @connection is closed then the operation will fail with 1362 * %G_IO_ERROR_CLOSED. If @message is not well-formed, 1363 * the operation fails with %G_IO_ERROR_INVALID_ARGUMENT. 1364 * 1365 * See this [server][gdbus-server] and [client][gdbus-unix-fd-client] 1366 * for an example of how to use this low-level API to send and receive 1367 * UNIX file descriptors. 1368 * 1369 * Note that @message must be unlocked, unless @flags contain the 1370 * %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. 1371 * 1372 * Params: 1373 * message = a #GDBusMessage 1374 * flags = flags affecting how the message is sent 1375 * outSerial = return location for serial number assigned 1376 * to @message when sending it or %NULL 1377 * 1378 * Returns: %TRUE if the message was well-formed and queued for 1379 * transmission, %FALSE if @error is set 1380 * 1381 * Since: 2.26 1382 * 1383 * Throws: GException on failure. 1384 */ 1385 public bool sendMessage(DBusMessage message, GDBusSendMessageFlags flags, out uint outSerial) 1386 { 1387 GError* err = null; 1388 1389 auto __p = g_dbus_connection_send_message(gDBusConnection, (message is null) ? null : message.getDBusMessageStruct(), flags, &outSerial, &err) != 0; 1390 1391 if (err !is null) 1392 { 1393 throw new GException( new ErrorG(err) ); 1394 } 1395 1396 return __p; 1397 } 1398 1399 /** 1400 * Asynchronously sends @message to the peer represented by @connection. 1401 * 1402 * Unless @flags contain the 1403 * %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number 1404 * will be assigned by @connection and set on @message via 1405 * g_dbus_message_set_serial(). If @out_serial is not %NULL, then the 1406 * serial number used will be written to this location prior to 1407 * submitting the message to the underlying transport. 1408 * 1409 * If @connection is closed then the operation will fail with 1410 * %G_IO_ERROR_CLOSED. If @cancellable is canceled, the operation will 1411 * fail with %G_IO_ERROR_CANCELLED. If @message is not well-formed, 1412 * the operation fails with %G_IO_ERROR_INVALID_ARGUMENT. 1413 * 1414 * This is an asynchronous method. When the operation is finished, @callback 1415 * will be invoked in the 1416 * [thread-default main context][g-main-context-push-thread-default] 1417 * of the thread you are calling this method from. You can then call 1418 * g_dbus_connection_send_message_with_reply_finish() to get the result of the operation. 1419 * See g_dbus_connection_send_message_with_reply_sync() for the synchronous version. 1420 * 1421 * Note that @message must be unlocked, unless @flags contain the 1422 * %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. 1423 * 1424 * See this [server][gdbus-server] and [client][gdbus-unix-fd-client] 1425 * for an example of how to use this low-level API to send and receive 1426 * UNIX file descriptors. 1427 * 1428 * Params: 1429 * message = a #GDBusMessage 1430 * flags = flags affecting how the message is sent 1431 * timeoutMsec = the timeout in milliseconds, -1 to use the default 1432 * timeout or %G_MAXINT for no timeout 1433 * outSerial = return location for serial number assigned 1434 * to @message when sending it or %NULL 1435 * cancellable = a #GCancellable or %NULL 1436 * callback = a #GAsyncReadyCallback to call when the request 1437 * is satisfied or %NULL if you don't care about the result 1438 * userData = The data to pass to @callback 1439 * 1440 * Since: 2.26 1441 */ 1442 public void sendMessageWithReply(DBusMessage message, GDBusSendMessageFlags flags, int timeoutMsec, out uint outSerial, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1443 { 1444 g_dbus_connection_send_message_with_reply(gDBusConnection, (message is null) ? null : message.getDBusMessageStruct(), flags, timeoutMsec, &outSerial, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1445 } 1446 1447 /** 1448 * Finishes an operation started with g_dbus_connection_send_message_with_reply(). 1449 * 1450 * Note that @error is only set if a local in-process error 1451 * occurred. That is to say that the returned #GDBusMessage object may 1452 * be of type %G_DBUS_MESSAGE_TYPE_ERROR. Use 1453 * g_dbus_message_to_gerror() to transcode this to a #GError. 1454 * 1455 * See this [server][gdbus-server] and [client][gdbus-unix-fd-client] 1456 * for an example of how to use this low-level API to send and receive 1457 * UNIX file descriptors. 1458 * 1459 * Params: 1460 * res = a #GAsyncResult obtained from the #GAsyncReadyCallback passed to 1461 * g_dbus_connection_send_message_with_reply() 1462 * 1463 * Returns: a locked #GDBusMessage or %NULL if @error is set 1464 * 1465 * Since: 2.26 1466 * 1467 * Throws: GException on failure. 1468 */ 1469 public DBusMessage sendMessageWithReplyFinish(AsyncResultIF res) 1470 { 1471 GError* err = null; 1472 1473 auto __p = g_dbus_connection_send_message_with_reply_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultStruct(), &err); 1474 1475 if (err !is null) 1476 { 1477 throw new GException( new ErrorG(err) ); 1478 } 1479 1480 if(__p is null) 1481 { 1482 return null; 1483 } 1484 1485 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) __p, true); 1486 } 1487 1488 /** 1489 * Synchronously sends @message to the peer represented by @connection 1490 * and blocks the calling thread until a reply is received or the 1491 * timeout is reached. See g_dbus_connection_send_message_with_reply() 1492 * for the asynchronous version of this method. 1493 * 1494 * Unless @flags contain the 1495 * %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number 1496 * will be assigned by @connection and set on @message via 1497 * g_dbus_message_set_serial(). If @out_serial is not %NULL, then the 1498 * serial number used will be written to this location prior to 1499 * submitting the message to the underlying transport. 1500 * 1501 * If @connection is closed then the operation will fail with 1502 * %G_IO_ERROR_CLOSED. If @cancellable is canceled, the operation will 1503 * fail with %G_IO_ERROR_CANCELLED. If @message is not well-formed, 1504 * the operation fails with %G_IO_ERROR_INVALID_ARGUMENT. 1505 * 1506 * Note that @error is only set if a local in-process error 1507 * occurred. That is to say that the returned #GDBusMessage object may 1508 * be of type %G_DBUS_MESSAGE_TYPE_ERROR. Use 1509 * g_dbus_message_to_gerror() to transcode this to a #GError. 1510 * 1511 * See this [server][gdbus-server] and [client][gdbus-unix-fd-client] 1512 * for an example of how to use this low-level API to send and receive 1513 * UNIX file descriptors. 1514 * 1515 * Note that @message must be unlocked, unless @flags contain the 1516 * %G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. 1517 * 1518 * Params: 1519 * message = a #GDBusMessage 1520 * flags = flags affecting how the message is sent. 1521 * timeoutMsec = the timeout in milliseconds, -1 to use the default 1522 * timeout or %G_MAXINT for no timeout 1523 * outSerial = return location for serial number 1524 * assigned to @message when sending it or %NULL 1525 * cancellable = a #GCancellable or %NULL 1526 * 1527 * Returns: a locked #GDBusMessage that is the reply 1528 * to @message or %NULL if @error is set 1529 * 1530 * Since: 2.26 1531 * 1532 * Throws: GException on failure. 1533 */ 1534 public DBusMessage sendMessageWithReplySync(DBusMessage message, GDBusSendMessageFlags flags, int timeoutMsec, out uint outSerial, Cancellable cancellable) 1535 { 1536 GError* err = null; 1537 1538 auto __p = g_dbus_connection_send_message_with_reply_sync(gDBusConnection, (message is null) ? null : message.getDBusMessageStruct(), flags, timeoutMsec, &outSerial, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1539 1540 if (err !is null) 1541 { 1542 throw new GException( new ErrorG(err) ); 1543 } 1544 1545 if(__p is null) 1546 { 1547 return null; 1548 } 1549 1550 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) __p, true); 1551 } 1552 1553 /** 1554 * Sets whether the process should be terminated when @connection is 1555 * closed by the remote peer. See #GDBusConnection:exit-on-close for 1556 * more details. 1557 * 1558 * Note that this function should be used with care. Most modern UNIX 1559 * desktops tie the notion of a user session with the session bus, and expect 1560 * all of a user's applications to quit when their bus connection goes away. 1561 * If you are setting @exit_on_close to %FALSE for the shared session 1562 * bus connection, you should make sure that your application exits 1563 * when the user session ends. 1564 * 1565 * Params: 1566 * exitOnClose = whether the process should be terminated 1567 * when @connection is closed by the remote peer 1568 * 1569 * Since: 2.26 1570 */ 1571 public void setExitOnClose(bool exitOnClose) 1572 { 1573 g_dbus_connection_set_exit_on_close(gDBusConnection, exitOnClose); 1574 } 1575 1576 /** 1577 * Subscribes to signals on @connection and invokes @callback with a whenever 1578 * the signal is received. Note that @callback will be invoked in the 1579 * [thread-default main context][g-main-context-push-thread-default] 1580 * of the thread you are calling this method from. 1581 * 1582 * If @connection is not a message bus connection, @sender must be 1583 * %NULL. 1584 * 1585 * If @sender is a well-known name note that @callback is invoked with 1586 * the unique name for the owner of @sender, not the well-known name 1587 * as one would expect. This is because the message bus rewrites the 1588 * name. As such, to avoid certain race conditions, users should be 1589 * tracking the name owner of the well-known name and use that when 1590 * processing the received signal. 1591 * 1592 * If one of %G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE or 1593 * %G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH are given, @arg0 is 1594 * interpreted as part of a namespace or path. The first argument 1595 * of a signal is matched against that part as specified by D-Bus. 1596 * 1597 * If @user_data_free_func is non-%NULL, it will be called (in the 1598 * thread-default main context of the thread you are calling this 1599 * method from) at some point after @user_data is no longer 1600 * needed. (It is not guaranteed to be called synchronously when the 1601 * signal is unsubscribed from, and may be called after @connection 1602 * has been destroyed.) 1603 * 1604 * As @callback is potentially invoked in a different thread from where it’s 1605 * emitted, it’s possible for this to happen after 1606 * g_dbus_connection_signal_unsubscribe() has been called in another thread. 1607 * Due to this, @user_data should have a strong reference which is freed with 1608 * @user_data_free_func, rather than pointing to data whose lifecycle is tied 1609 * to the signal subscription. For example, if a #GObject is used to store the 1610 * subscription ID from g_dbus_connection_signal_subscribe(), a strong reference 1611 * to that #GObject must be passed to @user_data, and g_object_unref() passed to 1612 * @user_data_free_func. You are responsible for breaking the resulting 1613 * reference count cycle by explicitly unsubscribing from the signal when 1614 * dropping the last external reference to the #GObject. Alternatively, a weak 1615 * reference may be used. 1616 * 1617 * It is guaranteed that if you unsubscribe from a signal using 1618 * g_dbus_connection_signal_unsubscribe() from the same thread which made the 1619 * corresponding g_dbus_connection_signal_subscribe() call, @callback will not 1620 * be invoked after g_dbus_connection_signal_unsubscribe() returns. 1621 * 1622 * The returned subscription identifier is an opaque value which is guaranteed 1623 * to never be zero. 1624 * 1625 * This function can never fail. 1626 * 1627 * Params: 1628 * sender = sender name to match on (unique or well-known name) 1629 * or %NULL to listen from all senders 1630 * interfaceName = D-Bus interface name to match on or %NULL to 1631 * match on all interfaces 1632 * member = D-Bus signal name to match on or %NULL to match on 1633 * all signals 1634 * objectPath = object path to match on or %NULL to match on 1635 * all object paths 1636 * arg0 = contents of first string argument to match on or %NULL 1637 * to match on all kinds of arguments 1638 * flags = #GDBusSignalFlags describing how arg0 is used in subscribing to the 1639 * signal 1640 * callback = callback to invoke when there is a signal matching the requested data 1641 * userData = user data to pass to @callback 1642 * userDataFreeFunc = function to free @user_data with when 1643 * subscription is removed or %NULL 1644 * 1645 * Returns: a subscription identifier that can be used with g_dbus_connection_signal_unsubscribe() 1646 * 1647 * Since: 2.26 1648 */ 1649 public uint signalSubscribe(string sender, string interfaceName, string member, string objectPath, string arg0, GDBusSignalFlags flags, GDBusSignalCallback callback, void* userData, GDestroyNotify userDataFreeFunc) 1650 { 1651 return g_dbus_connection_signal_subscribe(gDBusConnection, Str.toStringz(sender), Str.toStringz(interfaceName), Str.toStringz(member), Str.toStringz(objectPath), Str.toStringz(arg0), flags, callback, userData, userDataFreeFunc); 1652 } 1653 1654 /** 1655 * Unsubscribes from signals. 1656 * 1657 * Note that there may still be D-Bus traffic to process (relating to this 1658 * signal subscription) in the current thread-default #GMainContext after this 1659 * function has returned. You should continue to iterate the #GMainContext 1660 * until the #GDestroyNotify function passed to 1661 * g_dbus_connection_signal_subscribe() is called, in order to avoid memory 1662 * leaks through callbacks queued on the #GMainContext after it’s stopped being 1663 * iterated. 1664 * 1665 * Params: 1666 * subscriptionId = a subscription id obtained from 1667 * g_dbus_connection_signal_subscribe() 1668 * 1669 * Since: 2.26 1670 */ 1671 public void signalUnsubscribe(uint subscriptionId) 1672 { 1673 g_dbus_connection_signal_unsubscribe(gDBusConnection, subscriptionId); 1674 } 1675 1676 /** 1677 * If @connection was created with 1678 * %G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING, this method 1679 * starts processing messages. Does nothing on if @connection wasn't 1680 * created with this flag or if the method has already been called. 1681 * 1682 * Since: 2.26 1683 */ 1684 public void startMessageProcessing() 1685 { 1686 g_dbus_connection_start_message_processing(gDBusConnection); 1687 } 1688 1689 /** 1690 * Reverses the effect of a previous call to 1691 * g_dbus_connection_export_action_group(). 1692 * 1693 * It is an error to call this function with an ID that wasn't returned 1694 * from g_dbus_connection_export_action_group() or to call it with the 1695 * same ID more than once. 1696 * 1697 * Params: 1698 * exportId = the ID from g_dbus_connection_export_action_group() 1699 * 1700 * Since: 2.32 1701 */ 1702 public void unexportActionGroup(uint exportId) 1703 { 1704 g_dbus_connection_unexport_action_group(gDBusConnection, exportId); 1705 } 1706 1707 /** 1708 * Reverses the effect of a previous call to 1709 * g_dbus_connection_export_menu_model(). 1710 * 1711 * It is an error to call this function with an ID that wasn't returned 1712 * from g_dbus_connection_export_menu_model() or to call it with the 1713 * same ID more than once. 1714 * 1715 * Params: 1716 * exportId = the ID from g_dbus_connection_export_menu_model() 1717 * 1718 * Since: 2.32 1719 */ 1720 public void unexportMenuModel(uint exportId) 1721 { 1722 g_dbus_connection_unexport_menu_model(gDBusConnection, exportId); 1723 } 1724 1725 /** 1726 * Unregisters an object. 1727 * 1728 * Params: 1729 * registrationId = a registration id obtained from 1730 * g_dbus_connection_register_object() 1731 * 1732 * Returns: %TRUE if the object was unregistered, %FALSE otherwise 1733 * 1734 * Since: 2.26 1735 */ 1736 public bool unregisterObject(uint registrationId) 1737 { 1738 return g_dbus_connection_unregister_object(gDBusConnection, registrationId) != 0; 1739 } 1740 1741 /** 1742 * Unregisters a subtree. 1743 * 1744 * Params: 1745 * registrationId = a subtree registration id obtained from 1746 * g_dbus_connection_register_subtree() 1747 * 1748 * Returns: %TRUE if the subtree was unregistered, %FALSE otherwise 1749 * 1750 * Since: 2.26 1751 */ 1752 public bool unregisterSubtree(uint registrationId) 1753 { 1754 return g_dbus_connection_unregister_subtree(gDBusConnection, registrationId) != 0; 1755 } 1756 1757 /** 1758 * Emitted when the connection is closed. 1759 * 1760 * The cause of this event can be 1761 * 1762 * - If g_dbus_connection_close() is called. In this case 1763 * @remote_peer_vanished is set to %FALSE and @error is %NULL. 1764 * 1765 * - If the remote peer closes the connection. In this case 1766 * @remote_peer_vanished is set to %TRUE and @error is set. 1767 * 1768 * - If the remote peer sends invalid or malformed data. In this 1769 * case @remote_peer_vanished is set to %FALSE and @error is set. 1770 * 1771 * Upon receiving this signal, you should give up your reference to 1772 * @connection. You are guaranteed that this signal is emitted only 1773 * once. 1774 * 1775 * Params: 1776 * remotePeerVanished = %TRUE if @connection is closed because the 1777 * remote peer closed its end of the connection 1778 * error = a #GError with more details about the event or %NULL 1779 * 1780 * Since: 2.26 1781 */ 1782 gulong addOnClosed(void delegate(bool, ErrorG, DBusConnection) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1783 { 1784 return Signals.connect(this, "closed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1785 } 1786 1787 /** 1788 * Asynchronously connects to the message bus specified by @bus_type. 1789 * 1790 * When the operation is finished, @callback will be invoked. You can 1791 * then call g_bus_get_finish() to get the result of the operation. 1792 * 1793 * This is an asynchronous failable function. See g_bus_get_sync() for 1794 * the synchronous version. 1795 * 1796 * Params: 1797 * busType = a #GBusType 1798 * cancellable = a #GCancellable or %NULL 1799 * callback = a #GAsyncReadyCallback to call when the request is satisfied 1800 * userData = the data to pass to @callback 1801 * 1802 * Since: 2.26 1803 */ 1804 public static void get(GBusType busType, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1805 { 1806 g_bus_get(busType, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1807 } 1808 1809 /** 1810 * Finishes an operation started with g_bus_get(). 1811 * 1812 * The returned object is a singleton, that is, shared with other 1813 * callers of g_bus_get() and g_bus_get_sync() for @bus_type. In the 1814 * event that you need a private message bus connection, use 1815 * g_dbus_address_get_for_bus_sync() and 1816 * g_dbus_connection_new_for_address(). 1817 * 1818 * Note that the returned #GDBusConnection object will (usually) have 1819 * the #GDBusConnection:exit-on-close property set to %TRUE. 1820 * 1821 * Params: 1822 * res = a #GAsyncResult obtained from the #GAsyncReadyCallback passed 1823 * to g_bus_get() 1824 * 1825 * Returns: a #GDBusConnection or %NULL if @error is set. 1826 * Free with g_object_unref(). 1827 * 1828 * Since: 2.26 1829 * 1830 * Throws: GException on failure. 1831 */ 1832 public static DBusConnection getFinish(AsyncResultIF res) 1833 { 1834 GError* err = null; 1835 1836 auto __p = g_bus_get_finish((res is null) ? null : res.getAsyncResultStruct(), &err); 1837 1838 if (err !is null) 1839 { 1840 throw new GException( new ErrorG(err) ); 1841 } 1842 1843 if(__p is null) 1844 { 1845 return null; 1846 } 1847 1848 return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) __p, true); 1849 } 1850 1851 /** 1852 * Synchronously connects to the message bus specified by @bus_type. 1853 * Note that the returned object may shared with other callers, 1854 * e.g. if two separate parts of a process calls this function with 1855 * the same @bus_type, they will share the same object. 1856 * 1857 * This is a synchronous failable function. See g_bus_get() and 1858 * g_bus_get_finish() for the asynchronous version. 1859 * 1860 * The returned object is a singleton, that is, shared with other 1861 * callers of g_bus_get() and g_bus_get_sync() for @bus_type. In the 1862 * event that you need a private message bus connection, use 1863 * g_dbus_address_get_for_bus_sync() and 1864 * g_dbus_connection_new_for_address(). 1865 * 1866 * Note that the returned #GDBusConnection object will (usually) have 1867 * the #GDBusConnection:exit-on-close property set to %TRUE. 1868 * 1869 * Params: 1870 * busType = a #GBusType 1871 * cancellable = a #GCancellable or %NULL 1872 * 1873 * Returns: a #GDBusConnection or %NULL if @error is set. 1874 * Free with g_object_unref(). 1875 * 1876 * Since: 2.26 1877 * 1878 * Throws: GException on failure. 1879 */ 1880 public static DBusConnection getSync(GBusType busType, Cancellable cancellable) 1881 { 1882 GError* err = null; 1883 1884 auto __p = g_bus_get_sync(busType, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1885 1886 if (err !is null) 1887 { 1888 throw new GException( new ErrorG(err) ); 1889 } 1890 1891 if(__p is null) 1892 { 1893 return null; 1894 } 1895 1896 return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) __p, true); 1897 } 1898 }