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 * Conversion parameters: 26 * inFile = GDBusConnection.html 27 * outPack = gio 28 * outFile = DBusConnection 29 * strct = GDBusConnection 30 * realStrct= 31 * ctorStrct= 32 * clss = DBusConnection 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = GObject 38 * implements: 39 * - InitableIF 40 * - AsyncInitableIF 41 * prefixes: 42 * - g_dbus_connection_ 43 * - g_dbus_ 44 * omit structs: 45 * omit prefixes: 46 * omit code: 47 * - g_dbus_connection_new_finish 48 * - g_dbus_connection_new_for_address_finish 49 * omit signals: 50 * imports: 51 * - glib.Str 52 * - glib.ErrorG 53 * - glib.GException 54 * - glib.Variant 55 * - glib.VariantType 56 * - gio.AsyncResultIF 57 * - gio.Cancellable 58 * - gio.Credentials 59 * - gio.DBusAuthObserver 60 * - gio.DBusMessage 61 * - gio.DBusMethodInvocation 62 * - gio.IOStream 63 * - gio.InitableT 64 * - gio.InitableIF 65 * - gio.AsyncInitableT 66 * - gio.AsyncInitableIF 67 * structWrap: 68 * - GAsyncResult* -> AsyncResultIF 69 * - GCancellable* -> Cancellable 70 * - GCredentials* -> Credentials 71 * - GDBusAuthObserver* -> DBusAuthObserver 72 * - GDBusConnection* -> DBusConnection 73 * - GDBusMessage* -> DBusMessage 74 * - GDBusMethodInvocation* -> DBusMethodInvocation 75 * - GIOStream* -> IOStream 76 * - GVariant* -> Variant 77 * - GVariantType* -> VariantType 78 * module aliases: 79 * local aliases: 80 * overrides: 81 */ 82 83 module gio.DBusConnection; 84 85 public import gtkc.giotypes; 86 87 private import gtkc.gio; 88 private import glib.ConstructionException; 89 private import gobject.ObjectG; 90 91 private import gobject.Signals; 92 public import gtkc.gdktypes; 93 94 private import glib.Str; 95 private import glib.ErrorG; 96 private import glib.GException; 97 private import glib.Variant; 98 private import glib.VariantType; 99 private import gio.AsyncResultIF; 100 private import gio.Cancellable; 101 private import gio.Credentials; 102 private import gio.DBusAuthObserver; 103 private import gio.DBusMessage; 104 private import gio.DBusMethodInvocation; 105 private import gio.IOStream; 106 private import gio.InitableT; 107 private import gio.InitableIF; 108 private import gio.AsyncInitableT; 109 private import gio.AsyncInitableIF; 110 111 112 113 private import gobject.ObjectG; 114 115 /** 116 * Description 117 * The GDBusConnection type is used for D-Bus connections to remote 118 * peers such as a message buses. It is a low-level API that offers a 119 * lot of flexibility. For instance, it lets you establish a connection 120 * over any transport that can by represented as an GIOStream. 121 * This class is rarely used directly in D-Bus clients. If you are writing 122 * an D-Bus client, it is often easier to use the g_bus_own_name(), 123 * g_bus_watch_name() or g_dbus_proxy_new_for_bus() APIs. 124 * $(DDOC_COMMENT example) 125 * $(DDOC_COMMENT example) 126 * $(DDOC_COMMENT example) 127 * $(DDOC_COMMENT example) 128 */ 129 public class DBusConnection : ObjectG, InitableIF, AsyncInitableIF 130 { 131 132 /** the main Gtk struct */ 133 protected GDBusConnection* gDBusConnection; 134 135 136 public GDBusConnection* getDBusConnectionStruct() 137 { 138 return gDBusConnection; 139 } 140 141 142 /** the main Gtk struct as a void* */ 143 protected override void* getStruct() 144 { 145 return cast(void*)gDBusConnection; 146 } 147 148 /** 149 * Sets our main struct and passes it to the parent class 150 */ 151 public this (GDBusConnection* gDBusConnection) 152 { 153 super(cast(GObject*)gDBusConnection); 154 this.gDBusConnection = gDBusConnection; 155 } 156 157 protected override void setStruct(GObject* obj) 158 { 159 super.setStruct(obj); 160 gDBusConnection = cast(GDBusConnection*)obj; 161 } 162 163 // add the Initable capabilities 164 mixin InitableT!(DBusConnection); 165 166 // add the AsyncInitable capabilities 167 mixin AsyncInitableT!(DBusConnection); 168 169 /** 170 * Finishes an operation started with g_dbus_connection_new(). 171 * Since 2.26 172 * Params: 173 * res = A GAsyncResult obtained from the GAsyncReadyCallback 174 * passed to g_dbus_connection_new(). 175 * address = If true finish an address. 176 * Throws: GException on failure. 177 * Throws: ConstructionException GTK+ fails to create the object. 178 */ 179 public this (AsyncResultIF res, bool address = false) 180 { 181 // GDBusConnection * g_dbus_connection_new_finish (GAsyncResult *res, GError **error); 182 GError* err = null; 183 GDBusConnection* p; 184 185 if ( address ) 186 { 187 p = g_dbus_connection_new_for_address_finish((res is null) ? null : res.getAsyncResultTStruct(), &err); 188 } 189 else 190 { 191 p = g_dbus_connection_new_finish((res is null) ? null : res.getAsyncResultTStruct(), &err); 192 } 193 194 if (err !is null) 195 { 196 throw new GException( new ErrorG(err) ); 197 } 198 199 if(p is null) 200 { 201 throw new ConstructionException("null returned by g_dbus_connection_new_finish((res is null) ? null : res.getAsyncResultTStruct(), &err)"); 202 } 203 this(cast(GDBusConnection*) p); 204 } 205 206 /** 207 */ 208 int[string] connectedSignals; 209 210 void delegate(gboolean, GError*, DBusConnection)[] onClosedListeners; 211 /** 212 * Emitted when the connection is closed. 213 * The cause of this event can be 214 * If g_dbus_connection_close() is called. In this case 215 * remote_peer_vanished is set to FALSE and error is NULL. 216 * If the remote peer closes the connection. In this case 217 * remote_peer_vanished is set to TRUE and error is set. 218 * If the remote peer sends invalid or malformed data. In this 219 * case remote_peer_vanished is set to FALSE and error 220 * is set. 221 * Upon receiving this signal, you should give up your reference to 222 * connection. You are guaranteed that this signal is emitted only 223 * once. 224 * TRUE if connection is closed because the 225 * remote peer closed its end of the connection. 226 * Since 2.26 227 */ 228 void addOnClosed(void delegate(gboolean, GError*, DBusConnection) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 229 { 230 if ( !("closed" in connectedSignals) ) 231 { 232 Signals.connectData( 233 getStruct(), 234 "closed", 235 cast(GCallback)&callBackClosed, 236 cast(void*)this, 237 null, 238 connectFlags); 239 connectedSignals["closed"] = 1; 240 } 241 onClosedListeners ~= dlg; 242 } 243 extern(C) static void callBackClosed(GDBusConnection* connectionStruct, gboolean remotePeerVanished, GError* error, DBusConnection _dBusConnection) 244 { 245 foreach ( void delegate(gboolean, GError*, DBusConnection) dlg ; _dBusConnection.onClosedListeners ) 246 { 247 dlg(remotePeerVanished, error, _dBusConnection); 248 } 249 } 250 251 252 /** 253 * Asynchronously connects to the message bus specified by bus_type. 254 * When the operation is finished, callback will be invoked. You can 255 * then call g_bus_get_finish() to get the result of the operation. 256 * This is a asynchronous failable function. See g_bus_get_sync() for 257 * the synchronous version. 258 * Since 2.26 259 * Params: 260 * busType = A GBusType. 261 * cancellable = A GCancellable or NULL. 262 * callback = A GAsyncReadyCallback to call when the request is satisfied. 263 * userData = The data to pass to callback. 264 */ 265 public static void gBusGet(GBusType busType, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 266 { 267 // void g_bus_get (GBusType bus_type, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 268 g_bus_get(busType, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 269 } 270 271 /** 272 * Finishes an operation started with g_bus_get(). 273 * The returned object is a singleton, that is, shared with other 274 * callers of g_bus_get() and g_bus_get_sync() for bus_type. In the 275 * event that you need a private message bus connection, use 276 * g_dbus_address_get_for_bus() and 277 * g_dbus_connection_new_for_address(). 278 * Note that the returned GDBusConnection object will (usually) have 279 * the "exit-on-close" property set to TRUE. 280 * Since 2.26 281 * Params: 282 * res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_bus_get(). 283 * Returns: A GDBusConnection or NULL if error is set. Free with g_object_unref(). [transfer full] 284 * Throws: GException on failure. 285 */ 286 public static DBusConnection gBusGetFinish(AsyncResultIF res) 287 { 288 // GDBusConnection * g_bus_get_finish (GAsyncResult *res, GError **error); 289 GError* err = null; 290 291 auto p = g_bus_get_finish((res is null) ? null : res.getAsyncResultTStruct(), &err); 292 293 if (err !is null) 294 { 295 throw new GException( new ErrorG(err) ); 296 } 297 298 299 if(p is null) 300 { 301 return null; 302 } 303 304 return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p); 305 } 306 307 /** 308 * Synchronously connects to the message bus specified by bus_type. 309 * Note that the returned object may shared with other callers, 310 * e.g. if two separate parts of a process calls this function with 311 * the same bus_type, they will share the same object. 312 * This is a synchronous failable function. See g_bus_get() and 313 * g_bus_get_finish() for the asynchronous version. 314 * The returned object is a singleton, that is, shared with other 315 * callers of g_bus_get() and g_bus_get_sync() for bus_type. In the 316 * event that you need a private message bus connection, use 317 * g_dbus_address_get_for_bus_sync() and 318 * g_dbus_connection_new_for_address(). 319 * Note that the returned GDBusConnection object will (usually) have 320 * the "exit-on-close" property set to TRUE. 321 * Since 2.26 322 * Params: 323 * busType = A GBusType. 324 * cancellable = A GCancellable or NULL. 325 * Returns: A GDBusConnection or NULL if error is set. Free with g_object_unref(). [transfer full] 326 * Throws: GException on failure. 327 */ 328 public static DBusConnection gBusGetSync(GBusType busType, Cancellable cancellable) 329 { 330 // GDBusConnection * g_bus_get_sync (GBusType bus_type, GCancellable *cancellable, GError **error); 331 GError* err = null; 332 333 auto p = g_bus_get_sync(busType, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 334 335 if (err !is null) 336 { 337 throw new GException( new ErrorG(err) ); 338 } 339 340 341 if(p is null) 342 { 343 return null; 344 } 345 346 return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p); 347 } 348 349 /** 350 * Asynchronously sets up a D-Bus connection for exchanging D-Bus messages 351 * with the end represented by stream. 352 * If observer is not NULL it may be used to control the 353 * authentication process. 354 * When the operation is finished, callback will be invoked. You can 355 * then call g_dbus_connection_new_finish() to get the result of the 356 * operation. 357 * This is a asynchronous failable constructor. See 358 * g_dbus_connection_new_sync() for the synchronous 359 * version. 360 * Since 2.26 361 * Params: 362 * stream = A GIOStream. 363 * guid = The GUID to use if a authenticating as a server or NULL. [allow-none] 364 * flags = Flags describing how to make the connection. 365 * observer = A GDBusAuthObserver or NULL. [allow-none] 366 * cancellable = A GCancellable or NULL. 367 * callback = A GAsyncReadyCallback to call when the request is satisfied. 368 * userData = The data to pass to callback. 369 */ 370 public static void newDBusConnection(IOStream stream, string guid, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 371 { 372 // void g_dbus_connection_new (GIOStream *stream, const gchar *guid, GDBusConnectionFlags flags, GDBusAuthObserver *observer, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 373 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); 374 } 375 376 /** 377 * Synchronously sets up a D-Bus connection for exchanging D-Bus messages 378 * with the end represented by stream. 379 * If observer is not NULL it may be used to control the 380 * authentication process. 381 * This is a synchronous failable constructor. See 382 * g_dbus_connection_new() for the asynchronous version. 383 * Since 2.26 384 * Params: 385 * stream = A GIOStream. 386 * guid = The GUID to use if a authenticating as a server or NULL. [allow-none] 387 * flags = Flags describing how to make the connection. 388 * observer = A GDBusAuthObserver or NULL. [allow-none] 389 * cancellable = A GCancellable or NULL. 390 * Throws: GException on failure. 391 * Throws: ConstructionException GTK+ fails to create the object. 392 */ 393 public this (IOStream stream, string guid, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable) 394 { 395 // GDBusConnection * g_dbus_connection_new_sync (GIOStream *stream, const gchar *guid, GDBusConnectionFlags flags, GDBusAuthObserver *observer, GCancellable *cancellable, GError **error); 396 GError* err = null; 397 398 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); 399 400 if (err !is null) 401 { 402 throw new GException( new ErrorG(err) ); 403 } 404 405 if(p is null) 406 { 407 throw new ConstructionException("null returned by 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)"); 408 } 409 this(cast(GDBusConnection*) p); 410 } 411 412 /** 413 * Asynchronously connects and sets up a D-Bus client connection for 414 * exchanging D-Bus messages with an endpoint specified by address 415 * which must be in the D-Bus address format. 416 * This constructor can only be used to initiate client-side 417 * connections - use g_dbus_connection_new() if you need to act as the 418 * server. In particular, flags cannot contain the 419 * G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER or 420 * G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS flags. 421 * When the operation is finished, callback will be invoked. You can 422 * then call g_dbus_connection_new_finish() to get the result of the 423 * operation. 424 * If observer is not NULL it may be used to control the 425 * authentication process. 426 * This is a asynchronous failable constructor. See 427 * g_dbus_connection_new_for_address_sync() for the synchronous 428 * version. 429 * Since 2.26 430 * Params: 431 * address = A D-Bus address. 432 * flags = Flags describing how to make the connection. 433 * observer = A GDBusAuthObserver or NULL. [allow-none] 434 * cancellable = A GCancellable or NULL. 435 * callback = A GAsyncReadyCallback to call when the request is satisfied. 436 * userData = The data to pass to callback. 437 */ 438 public static void newForAddress(string address, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 439 { 440 // void g_dbus_connection_new_for_address (const gchar *address, GDBusConnectionFlags flags, GDBusAuthObserver *observer, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 441 g_dbus_connection_new_for_address(Str.toStringz(address), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 442 } 443 444 /** 445 * Synchronously connects and sets up a D-Bus client connection for 446 * exchanging D-Bus messages with an endpoint specified by address 447 * which must be in the D-Bus address format. 448 * This constructor can only be used to initiate client-side 449 * connections - use g_dbus_connection_new_sync() if you need to act 450 * as the server. In particular, flags cannot contain the 451 * G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER or 452 * G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS flags. 453 * This is a synchronous failable constructor. See 454 * g_dbus_connection_new_for_address() for the asynchronous version. 455 * If observer is not NULL it may be used to control the 456 * authentication process. 457 * Since 2.26 458 * Params: 459 * address = A D-Bus address. 460 * flags = Flags describing how to make the connection. 461 * observer = A GDBusAuthObserver or NULL. [allow-none] 462 * cancellable = A GCancellable or NULL. 463 * Throws: GException on failure. 464 * Throws: ConstructionException GTK+ fails to create the object. 465 */ 466 public this (string address, GDBusConnectionFlags flags, DBusAuthObserver observer, Cancellable cancellable) 467 { 468 // GDBusConnection * g_dbus_connection_new_for_address_sync (const gchar *address, GDBusConnectionFlags flags, GDBusAuthObserver *observer, GCancellable *cancellable, GError **error); 469 GError* err = null; 470 471 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); 472 473 if (err !is null) 474 { 475 throw new GException( new ErrorG(err) ); 476 } 477 478 if(p is null) 479 { 480 throw new ConstructionException("null returned by g_dbus_connection_new_for_address_sync(Str.toStringz(address), flags, (observer is null) ? null : observer.getDBusAuthObserverStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err)"); 481 } 482 this(cast(GDBusConnection*) p); 483 } 484 485 /** 486 * If connection was created with 487 * G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING, this method 488 * starts processing messages. Does nothing on if connection wasn't 489 * created with this flag or if the method has already been called. 490 * Since 2.26 491 */ 492 public void startMessageProcessing() 493 { 494 // void g_dbus_connection_start_message_processing (GDBusConnection *connection); 495 g_dbus_connection_start_message_processing(gDBusConnection); 496 } 497 498 /** 499 * Closes connection. Note that this never causes the process to 500 * exit (this might only happen if the other end of a shared message 501 * bus connection disconnects, see "exit-on-close"). 502 * Once the connection is closed, operations such as sending a message 503 * will return with the error G_IO_ERROR_CLOSED. Closing a connection 504 * will not automatically flush the connection so queued messages may 505 * be lost. Use g_dbus_connection_flush() if you need such guarantees. 506 * If connection is already closed, this method fails with 507 * G_IO_ERROR_CLOSED. 508 * When connection has been closed, the "closed" 509 * signal is emitted in the thread-default main 510 * loop of the thread that connection was constructed in. 511 * This is an asynchronous method. When the operation is finished, 512 * callback will be invoked in the thread-default main 513 * loop of the thread you are calling this method from. You can 514 * then call g_dbus_connection_close_finish() to get the result of the 515 * operation. See g_dbus_connection_close_sync() for the synchronous 516 * version. 517 * Since 2.26 518 * Params: 519 * cancellable = A GCancellable or NULL. 520 * callback = A GAsyncReadyCallback to call when the request is 521 * satisfied or NULL if you don't care about the result. [allow-none] 522 * userData = The data to pass to callback. 523 */ 524 public void close(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 525 { 526 // void g_dbus_connection_close (GDBusConnection *connection, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 527 g_dbus_connection_close(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 528 } 529 530 /** 531 * Finishes an operation started with g_dbus_connection_close(). 532 * Since 2.26 533 * Params: 534 * res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_connection_close(). 535 * Returns: TRUE if the operation succeeded, FALSE if error is set. 536 * Throws: GException on failure. 537 */ 538 public int closeFinish(AsyncResultIF res) 539 { 540 // gboolean g_dbus_connection_close_finish (GDBusConnection *connection, GAsyncResult *res, GError **error); 541 GError* err = null; 542 543 auto p = g_dbus_connection_close_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultTStruct(), &err); 544 545 if (err !is null) 546 { 547 throw new GException( new ErrorG(err) ); 548 } 549 550 return p; 551 } 552 553 /** 554 * Synchronously closees connection. The calling thread is blocked 555 * until this is done. See g_dbus_connection_close() for the 556 * asynchronous version of this method and more details about what it 557 * does. 558 * Since 2.26 559 * Params: 560 * cancellable = A GCancellable or NULL. 561 * Returns: TRUE if the operation succeeded, FALSE if error is set. 562 * Throws: GException on failure. 563 */ 564 public int closeSync(Cancellable cancellable) 565 { 566 // gboolean g_dbus_connection_close_sync (GDBusConnection *connection, GCancellable *cancellable, GError **error); 567 GError* err = null; 568 569 auto p = g_dbus_connection_close_sync(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 570 571 if (err !is null) 572 { 573 throw new GException( new ErrorG(err) ); 574 } 575 576 return p; 577 } 578 579 /** 580 * Gets whether connection is closed. 581 * Since 2.26 582 * Returns: TRUE if the connection is closed, FALSE otherwise. 583 */ 584 public int isClosed() 585 { 586 // gboolean g_dbus_connection_is_closed (GDBusConnection *connection); 587 return g_dbus_connection_is_closed(gDBusConnection); 588 } 589 590 /** 591 * Asynchronously flushes connection, that is, writes all queued 592 * outgoing message to the transport and then flushes the transport 593 * (using g_output_stream_flush_async()). This is useful in programs 594 * that wants to emit a D-Bus signal and then exit 595 * immediately. Without flushing the connection, there is no guarantee 596 * that the message has been sent to the networking buffers in the OS 597 * kernel. 598 * This is an asynchronous method. When the operation is finished, 599 * callback will be invoked in the thread-default main 600 * loop of the thread you are calling this method from. You can 601 * then call g_dbus_connection_flush_finish() to get the result of the 602 * operation. See g_dbus_connection_flush_sync() for the synchronous 603 * version. 604 * Since 2.26 605 * Params: 606 * cancellable = A GCancellable or NULL. 607 * callback = A GAsyncReadyCallback to call when the request is 608 * satisfied or NULL if you don't care about the result. [allow-none] 609 * userData = The data to pass to callback. 610 */ 611 public void flush(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 612 { 613 // void g_dbus_connection_flush (GDBusConnection *connection, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 614 g_dbus_connection_flush(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 615 } 616 617 /** 618 * Finishes an operation started with g_dbus_connection_flush(). 619 * Since 2.26 620 * Params: 621 * res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_connection_flush(). 622 * Returns: TRUE if the operation succeeded, FALSE if error is set. 623 * Throws: GException on failure. 624 */ 625 public int flushFinish(AsyncResultIF res) 626 { 627 // gboolean g_dbus_connection_flush_finish (GDBusConnection *connection, GAsyncResult *res, GError **error); 628 GError* err = null; 629 630 auto p = g_dbus_connection_flush_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultTStruct(), &err); 631 632 if (err !is null) 633 { 634 throw new GException( new ErrorG(err) ); 635 } 636 637 return p; 638 } 639 640 /** 641 * Synchronously flushes connection. The calling thread is blocked 642 * until this is done. See g_dbus_connection_flush() for the 643 * asynchronous version of this method and more details about what it 644 * does. 645 * Since 2.26 646 * Params: 647 * cancellable = A GCancellable or NULL. 648 * Returns: TRUE if the operation succeeded, FALSE if error is set. 649 * Throws: GException on failure. 650 */ 651 public int flushSync(Cancellable cancellable) 652 { 653 // gboolean g_dbus_connection_flush_sync (GDBusConnection *connection, GCancellable *cancellable, GError **error); 654 GError* err = null; 655 656 auto p = g_dbus_connection_flush_sync(gDBusConnection, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 657 658 if (err !is null) 659 { 660 throw new GException( new ErrorG(err) ); 661 } 662 663 return p; 664 } 665 666 /** 667 * Gets whether the process is terminated when connection is 668 * closed by the remote peer. See 669 * "exit-on-close" for more details. 670 * Since 2.26 671 * Returns: Whether the process is terminated when connection is closed by the remote peer. 672 */ 673 public int getExitOnClose() 674 { 675 // gboolean g_dbus_connection_get_exit_on_close (GDBusConnection *connection); 676 return g_dbus_connection_get_exit_on_close(gDBusConnection); 677 } 678 679 /** 680 * Sets whether the process should be terminated when connection is 681 * closed by the remote peer. See "exit-on-close" for 682 * more details. 683 * Note that this function should be used with care. Most modern UNIX 684 * desktops tie the notion of a user session the session bus, and expect 685 * all of a users applications to quit when their bus connection goes away. 686 * If you are setting exit_on_close to FALSE for the shared session 687 * bus connection, you should make sure that your application exits 688 * when the user session ends. 689 * Since 2.26 690 * Params: 691 * exitOnClose = Whether the process should be terminated 692 * when connection is closed by the remote peer. 693 */ 694 public void setExitOnClose(int exitOnClose) 695 { 696 // void g_dbus_connection_set_exit_on_close (GDBusConnection *connection, gboolean exit_on_close); 697 g_dbus_connection_set_exit_on_close(gDBusConnection, exitOnClose); 698 } 699 700 /** 701 * Gets the underlying stream used for IO. 702 * Since 2.26 703 * Returns: the stream used for IO. [transfer none] 704 */ 705 public IOStream getStream() 706 { 707 // GIOStream * g_dbus_connection_get_stream (GDBusConnection *connection); 708 auto p = g_dbus_connection_get_stream(gDBusConnection); 709 710 if(p is null) 711 { 712 return null; 713 } 714 715 return ObjectG.getDObject!(IOStream)(cast(GIOStream*) p); 716 } 717 718 /** 719 * The GUID of the peer performing the role of server when 720 * authenticating. See "guid" for more details. 721 * Since 2.26 722 * Returns: The GUID. Do not free this string, it is owned by connection. 723 */ 724 public string getGuid() 725 { 726 // const gchar * g_dbus_connection_get_guid (GDBusConnection *connection); 727 return Str.toString(g_dbus_connection_get_guid(gDBusConnection)); 728 } 729 730 /** 731 * Gets the unique name of connection as assigned by the message 732 * bus. This can also be used to figure out if connection is a 733 * message bus connection. 734 * Since 2.26 735 * Returns: The unique name or NULL if connection is not a message bus connection. Do not free this string, it is owned by connection. 736 */ 737 public string getUniqueName() 738 { 739 // const gchar * g_dbus_connection_get_unique_name (GDBusConnection *connection); 740 return Str.toString(g_dbus_connection_get_unique_name(gDBusConnection)); 741 } 742 743 /** 744 * Gets the capabilities negotiated with the remote peer 745 * Since 2.26 746 * Returns: Zero or more flags from the GDBusCapabilityFlags enumeration. 747 */ 748 public GDBusCapabilityFlags getCapabilities() 749 { 750 // GDBusCapabilityFlags g_dbus_connection_get_capabilities (GDBusConnection *connection); 751 return g_dbus_connection_get_capabilities(gDBusConnection); 752 } 753 754 /** 755 * Gets the credentials of the authenticated peer. This will always 756 * return NULL unless connection acted as a server 757 * (e.g. G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER was passed) 758 * when set up and the client passed credentials as part of the 759 * authentication process. 760 * In a message bus setup, the message bus is always the server and 761 * each application is a client. So this method will always return 762 * NULL for message bus clients. 763 * Since 2.26 764 * Returns: A GCredentials or NULL if not available. Do not free this object, it is owned by connection. [transfer none] 765 */ 766 public Credentials getPeerCredentials() 767 { 768 // GCredentials * g_dbus_connection_get_peer_credentials (GDBusConnection *connection); 769 auto p = g_dbus_connection_get_peer_credentials(gDBusConnection); 770 771 if(p is null) 772 { 773 return null; 774 } 775 776 return ObjectG.getDObject!(Credentials)(cast(GCredentials*) p); 777 } 778 779 /** 780 * Asynchronously invokes the method_name method on the 781 * interface_name D-Bus interface on the remote object at 782 * object_path owned by bus_name. 783 * If connection is closed then the operation will fail with 784 * G_IO_ERROR_CLOSED. If cancellable is canceled, the operation will 785 * fail with G_IO_ERROR_CANCELLED. If parameters contains a value 786 * not compatible with the D-Bus protocol, the operation fails with 787 * G_IO_ERROR_INVALID_ARGUMENT. 788 * If reply_type is non-NULL then the reply will be checked for having this type and an 789 * error will be raised if it does not match. Said another way, if you give a reply_type 790 * then any non-NULL return value will be of this type. 791 * If the parameters GVariant is floating, it is consumed. This allows 792 * Since 2.26 793 * Params: 794 * busName = A unique or well-known bus name or NULL if 795 * connection is not a message bus connection. [allow-none] 796 * objectPath = Path of remote object. 797 * interfaceName = D-Bus interface to invoke method on. 798 * methodName = The name of the method to invoke. 799 * parameters = A GVariant tuple with parameters for the method 800 * or NULL if not passing parameters. [allow-none] 801 * replyType = The expected type of the reply, or NULL. [allow-none] 802 * flags = Flags from the GDBusCallFlags enumeration. 803 * timeoutMsec = The timeout in milliseconds, -1 to use the default 804 * timeout or G_MAXINT for no timeout. 805 * cancellable = A GCancellable or NULL. 806 * callback = A GAsyncReadyCallback to call when the request is 807 * satisfied or NULL if you don't * care about the result of the 808 * method invocation. [allow-none] 809 * userData = The data to pass to callback. 810 */ 811 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) 812 { 813 // void g_dbus_connection_call (GDBusConnection *connection, const gchar *bus_name, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags, gint timeout_msec, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 814 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); 815 } 816 817 /** 818 * Finishes an operation started with g_dbus_connection_call(). 819 * Since 2.26 820 * Params: 821 * res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_connection_call(). 822 * Returns: NULL if error is set. Otherwise a GVariant tuple with return values. Free with g_variant_unref(). 823 * Throws: GException on failure. 824 */ 825 public Variant callFinish(AsyncResultIF res) 826 { 827 // GVariant * g_dbus_connection_call_finish (GDBusConnection *connection, GAsyncResult *res, GError **error); 828 GError* err = null; 829 830 auto p = g_dbus_connection_call_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultTStruct(), &err); 831 832 if (err !is null) 833 { 834 throw new GException( new ErrorG(err) ); 835 } 836 837 838 if(p is null) 839 { 840 return null; 841 } 842 843 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 844 } 845 846 /** 847 * Synchronously invokes the method_name method on the 848 * interface_name D-Bus interface on the remote object at 849 * object_path owned by bus_name. 850 * If connection is closed then the operation will fail with 851 * G_IO_ERROR_CLOSED. If cancellable is canceled, the 852 * operation will fail with G_IO_ERROR_CANCELLED. If parameters 853 * contains a value not compatible with the D-Bus protocol, the operation 854 * fails with G_IO_ERROR_INVALID_ARGUMENT. 855 * If reply_type is non-NULL then the reply will be checked for having 856 * this type and an error will be raised if it does not match. Said 857 * another way, if you give a reply_type then any non-NULL return 858 * value will be of this type. 859 * If the parameters GVariant is floating, it is consumed. 860 * Since 2.26 861 * Params: 862 * busName = A unique or well-known bus name. 863 * objectPath = Path of remote object. 864 * interfaceName = D-Bus interface to invoke method on. 865 * methodName = The name of the method to invoke. 866 * parameters = A GVariant tuple with parameters for the method 867 * or NULL if not passing parameters. [allow-none] 868 * replyType = The expected type of the reply, or NULL. [allow-none] 869 * flags = Flags from the GDBusCallFlags enumeration. 870 * timeoutMsec = The timeout in milliseconds, -1 to use the default 871 * timeout or G_MAXINT for no timeout. 872 * cancellable = A GCancellable or NULL. 873 * Returns: NULL if error is set. Otherwise a GVariant tuple with return values. Free with g_variant_unref(). 874 * Throws: GException on failure. 875 */ 876 public Variant callSync(string busName, string objectPath, string interfaceName, string methodName, Variant parameters, VariantType replyType, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable) 877 { 878 // GVariant * g_dbus_connection_call_sync (GDBusConnection *connection, const gchar *bus_name, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags, gint timeout_msec, GCancellable *cancellable, GError **error); 879 GError* err = null; 880 881 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); 882 883 if (err !is null) 884 { 885 throw new GException( new ErrorG(err) ); 886 } 887 888 889 if(p is null) 890 { 891 return null; 892 } 893 894 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 895 } 896 897 /** 898 * Emits a signal. 899 * If the parameters GVariant is floating, it is consumed. 900 * This can only fail if parameters is not compatible with the D-Bus protocol. 901 * Since 2.26 902 * Params: 903 * destinationBusName = The unique bus name for the destination 904 * for the signal or NULL to emit to all listeners. [allow-none] 905 * objectPath = Path of remote object. 906 * interfaceName = D-Bus interface to emit a signal on. 907 * signalName = The name of the signal to emit. 908 * parameters = A GVariant tuple with parameters for the signal 909 * or NULL if not passing parameters. [allow-none] 910 * Returns: TRUE unless error is set. 911 * Throws: GException on failure. 912 */ 913 public int emitSignal(string destinationBusName, string objectPath, string interfaceName, string signalName, Variant parameters) 914 { 915 // gboolean g_dbus_connection_emit_signal (GDBusConnection *connection, const gchar *destination_bus_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, GError **error); 916 GError* err = null; 917 918 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); 919 920 if (err !is null) 921 { 922 throw new GException( new ErrorG(err) ); 923 } 924 925 return p; 926 } 927 928 /** 929 * Subscribes to signals on connection and invokes callback with a 930 * whenever the signal is received. Note that callback 931 * will be invoked in the thread-default main 932 * loop of the thread you are calling this method from. 933 * If connection is not a message bus connection, sender must be 934 * NULL. 935 * If sender is a well-known name note that callback is invoked with 936 * the unique name for the owner of sender, not the well-known name 937 * as one would expect. This is because the message bus rewrites the 938 * name. As such, to avoid certain race conditions, users should be 939 * tracking the name owner of the well-known name and use that when 940 * processing the received signal. 941 * Since 2.26 942 * Params: 943 * sender = Sender name to match on (unique or well-known name) 944 * or NULL to listen from all senders. [allow-none] 945 * interfaceName = D-Bus interface name to match on or NULL to 946 * match on all interfaces. [allow-none] 947 * member = D-Bus signal name to match on or NULL to match on all signals. [allow-none] 948 * objectPath = Object path to match on or NULL to match on all object paths. [allow-none] 949 * arg0 = Contents of first string argument to match on or NULL 950 * to match on all kinds of arguments. [allow-none] 951 * flags = Flags describing how to subscribe to the signal (currently unused). 952 * callback = Callback to invoke when there is a signal matching the requested data. 953 * userData = User data to pass to callback. 954 * userDataFreeFunc = Function to free user_data with when subscription is removed or NULL. 955 * Returns: A subscription identifier that can be used with g_dbus_connection_signal_unsubscribe(). 956 */ 957 public uint signalSubscribe(string sender, string interfaceName, string member, string objectPath, string arg0, GDBusSignalFlags flags, GDBusSignalCallback callback, void* userData, GDestroyNotify userDataFreeFunc) 958 { 959 // guint g_dbus_connection_signal_subscribe (GDBusConnection *connection, const gchar *sender, const gchar *interface_name, const gchar *member, const gchar *object_path, const gchar *arg0, GDBusSignalFlags flags, GDBusSignalCallback callback, gpointer user_data, GDestroyNotify user_data_free_func); 960 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); 961 } 962 963 /** 964 * Unsubscribes from signals. 965 * Since 2.26 966 * Params: 967 * subscriptionId = A subscription id obtained from g_dbus_connection_signal_subscribe(). 968 */ 969 public void signalUnsubscribe(uint subscriptionId) 970 { 971 // void g_dbus_connection_signal_unsubscribe (GDBusConnection *connection, guint subscription_id); 972 g_dbus_connection_signal_unsubscribe(gDBusConnection, subscriptionId); 973 } 974 975 /** 976 * Asynchronously sends message to the peer represented by connection. 977 * Unless flags contain the 978 * G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number 979 * will be assigned by connection and set on message via 980 * g_dbus_message_set_serial(). If out_serial is not NULL, then the 981 * serial number used will be written to this location prior to 982 * submitting the message to the underlying transport. 983 * If connection is closed then the operation will fail with 984 * G_IO_ERROR_CLOSED. If message is not well-formed, 985 * the operation fails with G_IO_ERROR_INVALID_ARGUMENT. 986 * See Example 2, “D-Bus server example” and Example 4, “D-Bus UNIX File Descriptor example” for an example of how to use this 987 * low-level API to send and receive UNIX file descriptors. 988 * Note that message must be unlocked, unless flags contain the 989 * G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. 990 * Since 2.26 991 * Params: 992 * message = A GDBusMessage 993 * flags = Flags affecting how the message is sent. 994 * outSerial = Return location for serial number assigned 995 * to message when sending it or NULL. [out][allow-none] 996 * Returns: TRUE if the message was well-formed and queued for transmission, FALSE if error is set. 997 * Throws: GException on failure. 998 */ 999 public int sendMessage(DBusMessage message, GDBusSendMessageFlags flags, out uint outSerial) 1000 { 1001 // gboolean g_dbus_connection_send_message (GDBusConnection *connection, GDBusMessage *message, GDBusSendMessageFlags flags, volatile guint32 *out_serial, GError **error); 1002 GError* err = null; 1003 1004 auto p = g_dbus_connection_send_message(gDBusConnection, (message is null) ? null : message.getDBusMessageStruct(), flags, &outSerial, &err); 1005 1006 if (err !is null) 1007 { 1008 throw new GException( new ErrorG(err) ); 1009 } 1010 1011 return p; 1012 } 1013 1014 /** 1015 * Asynchronously sends message to the peer represented by connection. 1016 * Unless flags contain the 1017 * G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number 1018 * will be assigned by connection and set on message via 1019 * g_dbus_message_set_serial(). If out_serial is not NULL, then the 1020 * serial number used will be written to this location prior to 1021 * submitting the message to the underlying transport. 1022 * If connection is closed then the operation will fail with 1023 * G_IO_ERROR_CLOSED. If cancellable is canceled, the operation will 1024 * fail with G_IO_ERROR_CANCELLED. If message is not well-formed, 1025 * the operation fails with G_IO_ERROR_INVALID_ARGUMENT. 1026 * This is an asynchronous method. When the operation is finished, callback will be invoked 1027 * in the thread-default main loop 1028 * of the thread you are calling this method from. You can then call 1029 * g_dbus_connection_send_message_with_reply_finish() to get the result of the operation. 1030 * See g_dbus_connection_send_message_with_reply_sync() for the synchronous version. 1031 * Note that message must be unlocked, unless flags contain the 1032 * G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. 1033 * See Example 2, “D-Bus server example” and Example 4, “D-Bus UNIX File Descriptor example” for an example of how to use this 1034 * low-level API to send and receive UNIX file descriptors. 1035 * Since 2.26 1036 * Params: 1037 * message = A GDBusMessage. 1038 * flags = Flags affecting how the message is sent. 1039 * timeoutMsec = The timeout in milliseconds, -1 to use the default 1040 * timeout or G_MAXINT for no timeout. 1041 * outSerial = Return location for serial number assigned 1042 * to message when sending it or NULL. [out][allow-none] 1043 * cancellable = A GCancellable or NULL. 1044 * callback = A GAsyncReadyCallback to call when the request is 1045 * satisfied or NULL if you don't care about the result. [allow-none] 1046 * userData = The data to pass to callback. 1047 */ 1048 public void sendMessageWithReply(DBusMessage message, GDBusSendMessageFlags flags, int timeoutMsec, out uint outSerial, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1049 { 1050 // void g_dbus_connection_send_message_with_reply (GDBusConnection *connection, GDBusMessage *message, GDBusSendMessageFlags flags, gint timeout_msec, volatile guint32 *out_serial, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 1051 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); 1052 } 1053 1054 /** 1055 * Finishes an operation started with g_dbus_connection_send_message_with_reply(). 1056 * Note that error is only set if a local in-process error 1057 * occured. That is to say that the returned GDBusMessage object may 1058 * be of type G_DBUS_MESSAGE_TYPE_ERROR. Use 1059 * g_dbus_message_to_gerror() to transcode this to a GError. 1060 * See Example 2, “D-Bus server example” and Example 4, “D-Bus UNIX File Descriptor example” for an example of how to use this 1061 * low-level API to send and receive UNIX file descriptors. 1062 * Since 2.26 1063 * Params: 1064 * res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_connection_send_message_with_reply(). 1065 * Returns: A locked GDBusMessage or NULL if error is set. [transfer full] 1066 * Throws: GException on failure. 1067 */ 1068 public DBusMessage sendMessageWithReplyFinish(AsyncResultIF res) 1069 { 1070 // GDBusMessage * g_dbus_connection_send_message_with_reply_finish (GDBusConnection *connection, GAsyncResult *res, GError **error); 1071 GError* err = null; 1072 1073 auto p = g_dbus_connection_send_message_with_reply_finish(gDBusConnection, (res is null) ? null : res.getAsyncResultTStruct(), &err); 1074 1075 if (err !is null) 1076 { 1077 throw new GException( new ErrorG(err) ); 1078 } 1079 1080 1081 if(p is null) 1082 { 1083 return null; 1084 } 1085 1086 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p); 1087 } 1088 1089 /** 1090 * Synchronously sends message to the peer represented by connection 1091 * and blocks the calling thread until a reply is received or the 1092 * timeout is reached. See g_dbus_connection_send_message_with_reply() 1093 * for the asynchronous version of this method. 1094 * Unless flags contain the 1095 * G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number 1096 * will be assigned by connection and set on message via 1097 * g_dbus_message_set_serial(). If out_serial is not NULL, then the 1098 * serial number used will be written to this location prior to 1099 * submitting the message to the underlying transport. 1100 * If connection is closed then the operation will fail with 1101 * G_IO_ERROR_CLOSED. If cancellable is canceled, the operation will 1102 * fail with G_IO_ERROR_CANCELLED. If message is not well-formed, 1103 * the operation fails with G_IO_ERROR_INVALID_ARGUMENT. 1104 * Note that error is only set if a local in-process error 1105 * occured. That is to say that the returned GDBusMessage object may 1106 * be of type G_DBUS_MESSAGE_TYPE_ERROR. Use 1107 * g_dbus_message_to_gerror() to transcode this to a GError. 1108 * See Example 2, “D-Bus server example” and Example 4, “D-Bus UNIX File Descriptor example” for an example of how to use this 1109 * low-level API to send and receive UNIX file descriptors. 1110 * Note that message must be unlocked, unless flags contain the 1111 * G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag. 1112 * Since 2.26 1113 * Params: 1114 * message = A GDBusMessage. 1115 * flags = Flags affecting how the message is sent. 1116 * timeoutMsec = The timeout in milliseconds, -1 to use the default 1117 * timeout or G_MAXINT for no timeout. 1118 * outSerial = Return location for serial number assigned 1119 * to message when sending it or NULL. [out][allow-none] 1120 * cancellable = A GCancellable or NULL. 1121 * Returns: A locked GDBusMessage that is the reply to message or NULL if error is set. [transfer full] 1122 * Throws: GException on failure. 1123 */ 1124 public DBusMessage sendMessageWithReplySync(DBusMessage message, GDBusSendMessageFlags flags, int timeoutMsec, out uint outSerial, Cancellable cancellable) 1125 { 1126 // GDBusMessage * g_dbus_connection_send_message_with_reply_sync (GDBusConnection *connection, GDBusMessage *message, GDBusSendMessageFlags flags, gint timeout_msec, volatile guint32 *out_serial, GCancellable *cancellable, GError **error); 1127 GError* err = null; 1128 1129 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); 1130 1131 if (err !is null) 1132 { 1133 throw new GException( new ErrorG(err) ); 1134 } 1135 1136 1137 if(p is null) 1138 { 1139 return null; 1140 } 1141 1142 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p); 1143 } 1144 1145 /** 1146 * Adds a message filter. Filters are handlers that are run on all 1147 * incoming and outgoing messages, prior to standard dispatch. Filters 1148 * are run in the order that they were added. The same handler can be 1149 * added as a filter more than once, in which case it will be run more 1150 * than once. Filters added during a filter callback won't be run on 1151 * the message being processed. Filter functions are allowed to modify 1152 * and even drop messages - see the GDBusMessageFilterResult 1153 * enumeration for details. 1154 * Note that filters are run in a dedicated message handling thread so 1155 * they can't block and, generally, can't do anything but signal a 1156 * worker thread. Also note that filters are rarely needed - use API 1157 * such as g_dbus_connection_send_message_with_reply(), 1158 * g_dbus_connection_signal_subscribe() or 1159 * g_dbus_connection_call() instead. 1160 * If a filter consumes an incoming message the message is not 1161 * dispatched anywhere else - not even the standard dispatch machinery 1162 * (that API such as g_dbus_connection_signal_subscribe() and 1163 * g_dbus_connection_send_message_with_reply() relies on) will see the 1164 * message. Similary, if a filter consumes an outgoing message, the 1165 * message will not be sent to the other peer. 1166 * Since 2.26 1167 * Params: 1168 * filterFunction = A filter function. 1169 * userData = User data to pass to filter_function. 1170 * userDataFreeFunc = Function to free user_data with when filter 1171 * is removed or NULL. 1172 * Returns: A filter identifier that can be used with g_dbus_connection_remove_filter(). 1173 */ 1174 public uint addFilter(GDBusMessageFilterFunction filterFunction, void* userData, GDestroyNotify userDataFreeFunc) 1175 { 1176 // guint g_dbus_connection_add_filter (GDBusConnection *connection, GDBusMessageFilterFunction filter_function, gpointer user_data, GDestroyNotify user_data_free_func); 1177 return g_dbus_connection_add_filter(gDBusConnection, filterFunction, userData, userDataFreeFunc); 1178 } 1179 1180 /** 1181 * Removes a filter. 1182 * Since 2.26 1183 * Params: 1184 * filterId = an identifier obtained from g_dbus_connection_add_filter() 1185 */ 1186 public void removeFilter(uint filterId) 1187 { 1188 // void g_dbus_connection_remove_filter (GDBusConnection *connection, guint filter_id); 1189 g_dbus_connection_remove_filter(gDBusConnection, filterId); 1190 } 1191 1192 /** 1193 * Registers callbacks for exported objects at object_path with the 1194 * D-Bus interface that is described in interface_info. 1195 * Calls to functions in vtable (and user_data_free_func) will 1196 * happen in the thread-default main 1197 * loop of the thread you are calling this method from. 1198 * Note that all GVariant values passed to functions in vtable will match 1199 * the signature given in interface_info - if a remote caller passes 1200 * incorrect values, the org.freedesktop.DBus.Error.InvalidArgs 1201 * is returned to the remote caller. 1202 * Additionally, if the remote caller attempts to invoke methods or 1203 * access properties not mentioned in interface_info the 1204 * org.freedesktop.DBus.Error.UnknownMethod resp. 1205 * org.freedesktop.DBus.Error.InvalidArgs errors 1206 * are returned to the caller. 1207 * It is considered a programming error if the 1208 * GDBusInterfaceGetPropertyFunc function in vtable returns a 1209 * GVariant of incorrect type. 1210 * If an existing callback is already registered at object_path and 1211 * interface_name, then error is set to G_IO_ERROR_EXISTS. 1212 * GDBus automatically implements the standard D-Bus interfaces 1213 * org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable 1214 * and org.freedesktop.Peer, so you don't have to implement those for 1215 * the objects you export. You can implement 1216 * org.freedesktop.DBus.Properties yourself, e.g. to handle getting 1217 * and setting of properties asynchronously. 1218 * Note that the reference count on interface_info will be 1219 * incremented by 1 (unless allocated statically, e.g. if the 1220 * reference count is -1, see g_dbus_interface_info_ref()) for as long 1221 * as the object is exported. Also note that vtable will be copied. 1222 * A NULL vtable can be used for 1223 * marker 1224 * interfaces. 1225 * See Example 2, “D-Bus server example” for an example of how to use this 1226 * method. 1227 * Since 2.26 1228 * Params: 1229 * objectPath = The object path to register at 1230 * interfaceInfo = Introspection data for the interface 1231 * vtable = A GDBusInterfaceVTable to call into, or NULL. [allow-none] 1232 * userData = Data to pass to functions in vtable 1233 * userDataFreeFunc = Function to call when the object path is unregistered 1234 * Returns: 0 if error is set, otherwise a registration id (never 0) that can be used with g_dbus_connection_unregister_object() . 1235 * Throws: GException on failure. 1236 */ 1237 public uint registerObject(string objectPath, GDBusInterfaceInfo* interfaceInfo, GDBusInterfaceVTable* vtable, void* userData, GDestroyNotify userDataFreeFunc) 1238 { 1239 // guint g_dbus_connection_register_object (GDBusConnection *connection, const gchar *object_path, GDBusInterfaceInfo *interface_info, const GDBusInterfaceVTable *vtable, gpointer user_data, GDestroyNotify user_data_free_func, GError **error); 1240 GError* err = null; 1241 1242 auto p = g_dbus_connection_register_object(gDBusConnection, Str.toStringz(objectPath), interfaceInfo, vtable, userData, userDataFreeFunc, &err); 1243 1244 if (err !is null) 1245 { 1246 throw new GException( new ErrorG(err) ); 1247 } 1248 1249 return p; 1250 } 1251 1252 /** 1253 * Unregisters an object. 1254 * Since 2.26 1255 * Params: 1256 * registrationId = A registration id obtained from g_dbus_connection_register_object(). 1257 * Returns: TRUE if the object was unregistered, FALSE otherwise. 1258 */ 1259 public int unregisterObject(uint registrationId) 1260 { 1261 // gboolean g_dbus_connection_unregister_object (GDBusConnection *connection, guint registration_id); 1262 return g_dbus_connection_unregister_object(gDBusConnection, registrationId); 1263 } 1264 1265 /** 1266 * Registers a whole subtree of “dynamic” objects. 1267 * The enumerate and introspection functions in vtable are used to 1268 * convey, to remote callers, what nodes exist in the subtree rooted 1269 * by object_path. 1270 * When handling remote calls into any node in the subtree, first the 1271 * enumerate function is used to check if the node exists. If the node exists 1272 * or the G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES flag is set 1273 * the introspection function is used to check if the node supports the 1274 * requested method. If so, the dispatch function is used to determine 1275 * where to dispatch the call. The collected GDBusInterfaceVTable and 1276 * gpointer will be used to call into the interface vtable for processing 1277 * the request. 1278 * All calls into user-provided code will be invoked in the thread-default main 1279 * loop of the thread you are calling this method from. 1280 * If an existing subtree is already registered at object_path or 1281 * then error is set to G_IO_ERROR_EXISTS. 1282 * Note that it is valid to register regular objects (using 1283 * g_dbus_connection_register_object()) in a subtree registered with 1284 * g_dbus_connection_register_subtree() - if so, the subtree handler 1285 * is tried as the last resort. One way to think about a subtree 1286 * handler is to consider it a “fallback handler” 1287 * for object paths not registered via g_dbus_connection_register_object() 1288 * or other bindings. 1289 * Note that vtable will be copied so you cannot change it after 1290 * registration. 1291 * See Example 3, “D-Bus subtree example” for an example of how to use this method. 1292 * Since 2.26 1293 * Params: 1294 * objectPath = The object path to register the subtree at. 1295 * vtable = A GDBusSubtreeVTable to enumerate, introspect and dispatch nodes in the subtree. 1296 * flags = Flags used to fine tune the behavior of the subtree. 1297 * userData = Data to pass to functions in vtable. 1298 * userDataFreeFunc = Function to call when the subtree is unregistered. 1299 * Returns: 0 if error is set, otherwise a subtree registration id (never 0) that can be used with g_dbus_connection_unregister_subtree() . 1300 * Throws: GException on failure. 1301 */ 1302 public uint registerSubtree(string objectPath, GDBusSubtreeVTable* vtable, GDBusSubtreeFlags flags, void* userData, GDestroyNotify userDataFreeFunc) 1303 { 1304 // guint g_dbus_connection_register_subtree (GDBusConnection *connection, const gchar *object_path, const GDBusSubtreeVTable *vtable, GDBusSubtreeFlags flags, gpointer user_data, GDestroyNotify user_data_free_func, GError **error); 1305 GError* err = null; 1306 1307 auto p = g_dbus_connection_register_subtree(gDBusConnection, Str.toStringz(objectPath), vtable, flags, userData, userDataFreeFunc, &err); 1308 1309 if (err !is null) 1310 { 1311 throw new GException( new ErrorG(err) ); 1312 } 1313 1314 return p; 1315 } 1316 1317 /** 1318 * Unregisters a subtree. 1319 * Since 2.26 1320 * Params: 1321 * registrationId = A subtree registration id obtained from g_dbus_connection_register_subtree(). 1322 * Returns: TRUE if the subtree was unregistered, FALSE otherwise. 1323 */ 1324 public int unregisterSubtree(uint registrationId) 1325 { 1326 // gboolean g_dbus_connection_unregister_subtree (GDBusConnection *connection, guint registration_id); 1327 return g_dbus_connection_unregister_subtree(gDBusConnection, registrationId); 1328 } 1329 }