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