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