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