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 = GDBusProxy.html 27 * outPack = gio 28 * outFile = DBusProxy 29 * strct = GDBusProxy 30 * realStrct= 31 * ctorStrct= 32 * clss = DBusProxy 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = GObject 38 * implements: 39 * - AsyncInitableIF 40 * - DBusInterfaceIF 41 * - InitableIF 42 * prefixes: 43 * - g_dbus_proxy_ 44 * omit structs: 45 * omit prefixes: 46 * omit code: 47 * - g_dbus_proxy_new_finish 48 * - g_dbus_proxy_new_for_bus_finish 49 * omit signals: 50 * imports: 51 * - glib.Str 52 * - glib.ErrorG 53 * - glib.GException 54 * - glib.Variant 55 * - gio.AsyncResultIF 56 * - gio.Cancellable 57 * - gio.DBusConnection 58 * - gio.UnixFDList 59 * - gio.AsyncInitableT 60 * - gio.AsyncInitableIF 61 * - gio.DBusInterfaceT 62 * - gio.DBusInterfaceIF 63 * - gio.InitableT 64 * - gio.InitableIF 65 * structWrap: 66 * - GAsyncResult* -> AsyncResultIF 67 * - GCancellable* -> Cancellable 68 * - GDBusConnection* -> DBusConnection 69 * - GUnixFDList* -> UnixFDList 70 * - GVariant* -> Variant 71 * module aliases: 72 * local aliases: 73 * overrides: 74 */ 75 76 module gio.DBusProxy; 77 78 public import gtkc.giotypes; 79 80 private import gtkc.gio; 81 private import glib.ConstructionException; 82 private import gobject.ObjectG; 83 84 private import gobject.Signals; 85 public import gtkc.gdktypes; 86 87 private import glib.Str; 88 private import glib.ErrorG; 89 private import glib.GException; 90 private import glib.Variant; 91 private import gio.AsyncResultIF; 92 private import gio.Cancellable; 93 private import gio.DBusConnection; 94 private import gio.UnixFDList; 95 private import gio.AsyncInitableT; 96 private import gio.AsyncInitableIF; 97 private import gio.DBusInterfaceT; 98 private import gio.DBusInterfaceIF; 99 private import gio.InitableT; 100 private import gio.InitableIF; 101 102 103 104 private import gobject.ObjectG; 105 106 /** 107 * GDBusProxy is a base class used for proxies to access a D-Bus 108 * interface on a remote object. A GDBusProxy can be constructed for 109 * both well-known and unique names. 110 * 111 * By default, GDBusProxy will cache all properties (and listen to 112 * changes) of the remote object, and proxy all signals that gets 113 * emitted. This behaviour can be changed by passing suitable 114 * GDBusProxyFlags when the proxy is created. If the proxy is for a 115 * well-known name, the property cache is flushed when the name owner 116 * vanishes and reloaded when a name owner appears. 117 * 118 * If a GDBusProxy is used for a well-known name, the owner of the 119 * name is tracked and can be read from 120 * "g-name-owner". Connect to the "notify" signal to 121 * get notified of changes. Additionally, only signals and property 122 * changes emitted from the current name owner are considered and 123 * calls are always sent to the current name owner. This avoids a 124 * number of race conditions when the name is lost by one owner and 125 * claimed by another. However, if no name owner currently exists, 126 * then calls will be sent to the well-known name which may result in 127 * the message bus launching an owner (unless 128 * G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START is set). 129 * 130 * The generic "g-properties-changed" and 131 * "g-signal" signals are not very convenient to work 132 * with. Therefore, the recommended way of working with proxies is to 133 * subclass GDBusProxy, and have more natural properties and signals 134 * in your derived class. See the section called “Using gdbus-codegen” 135 * for how this can easily be done using the 136 * gdbus-codegen 137 * tool. 138 * 139 * A GDBusProxy instance can be used from multiple threads but note 140 * that all signals (e.g. "g-signal", "g-properties-changed" 141 * and "notify") are emitted in the 142 * thread-default main loop 143 * of the thread where the instance was constructed. 144 * 145 * $(DDOC_COMMENT example) 146 */ 147 public class DBusProxy : ObjectG, AsyncInitableIF, DBusInterfaceIF, InitableIF 148 { 149 150 /** the main Gtk struct */ 151 protected GDBusProxy* gDBusProxy; 152 153 154 public GDBusProxy* getDBusProxyStruct() 155 { 156 return gDBusProxy; 157 } 158 159 160 /** the main Gtk struct as a void* */ 161 protected override void* getStruct() 162 { 163 return cast(void*)gDBusProxy; 164 } 165 166 /** 167 * Sets our main struct and passes it to the parent class 168 */ 169 public this (GDBusProxy* gDBusProxy) 170 { 171 super(cast(GObject*)gDBusProxy); 172 this.gDBusProxy = gDBusProxy; 173 } 174 175 protected override void setStruct(GObject* obj) 176 { 177 super.setStruct(obj); 178 gDBusProxy = cast(GDBusProxy*)obj; 179 } 180 181 // add the DBusInterface capabilities 182 mixin AsyncInitableT!(GDBusProxy); 183 184 // add the DBusInterface capabilities 185 mixin DBusInterfaceT!(GDBusProxy); 186 187 // add the Initable capabilities 188 mixin InitableT!(GDBusProxy); 189 190 /** 191 * Finishes creating a GDBusProxy. 192 * Since 2.26 193 * Params: 194 * res = A GAsyncResult obtained from the GAsyncReadyCallback 195 * function passed to g_dbus_proxy_new(). 196 * forBus = If true finish an address. 197 * Throws: GException on failure. 198 * Throws: ConstructionException GTK+ fails to create the object. 199 */ 200 public this (AsyncResultIF res, bool forBus = false) 201 { 202 // GDBusProxy * g_dbus_proxy_new_finish (GAsyncResult *res, GError **error); 203 GError* err = null; 204 GDBusProxy* p; 205 206 if ( forBus ) 207 { 208 p = g_dbus_proxy_new_for_bus_finish((res is null) ? null : res.getAsyncResultTStruct(), &err); 209 } 210 else 211 { 212 p = g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultTStruct(), &err); 213 } 214 215 if (err !is null) 216 { 217 throw new GException( new ErrorG(err) ); 218 } 219 220 if(p is null) 221 { 222 throw new ConstructionException("null returned by g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultTStruct(), &err)"); 223 } 224 this(cast(GDBusProxy*) p); 225 } 226 227 /** 228 */ 229 int[string] connectedSignals; 230 231 void delegate(Variant, GStrv, DBusProxy)[] onGPropertiesChangedListeners; 232 /** 233 * Emitted when one or more D-Bus properties on proxy changes. The 234 * local cache has already been updated when this signal fires. Note 235 * that both changed_properties and invalidated_properties are 236 * guaranteed to never be NULL (either may be empty though). 237 * If the proxy has the flag 238 * G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES set, then 239 * invalidated_properties will always be empty. 240 * This signal corresponds to the 241 * PropertiesChanged D-Bus signal on the 242 * org.freedesktop.DBus.Properties interface. 243 * Since 2.26 244 */ 245 void addOnGPropertiesChanged(void delegate(Variant, GStrv, DBusProxy) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 246 { 247 if ( !("g-properties-changed" in connectedSignals) ) 248 { 249 Signals.connectData( 250 getStruct(), 251 "g-properties-changed", 252 cast(GCallback)&callBackGPropertiesChanged, 253 cast(void*)this, 254 null, 255 connectFlags); 256 connectedSignals["g-properties-changed"] = 1; 257 } 258 onGPropertiesChangedListeners ~= dlg; 259 } 260 extern(C) static void callBackGPropertiesChanged(GDBusProxy* proxyStruct, GVariant* changedProperties, GStrv invalidatedProperties, DBusProxy _dBusProxy) 261 { 262 foreach ( void delegate(Variant, GStrv, DBusProxy) dlg ; _dBusProxy.onGPropertiesChangedListeners ) 263 { 264 dlg(ObjectG.getDObject!(Variant)(changedProperties), invalidatedProperties, _dBusProxy); 265 } 266 } 267 268 void delegate(string, string, Variant, DBusProxy)[] onGSignalListeners; 269 /** 270 * Emitted when a signal from the remote object and interface that proxy is for, has been received. 271 * Since 2.26 272 */ 273 void addOnGSignal(void delegate(string, string, Variant, DBusProxy) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 274 { 275 if ( !("g-signal" in connectedSignals) ) 276 { 277 Signals.connectData( 278 getStruct(), 279 "g-signal", 280 cast(GCallback)&callBackGSignal, 281 cast(void*)this, 282 null, 283 connectFlags); 284 connectedSignals["g-signal"] = 1; 285 } 286 onGSignalListeners ~= dlg; 287 } 288 extern(C) static void callBackGSignal(GDBusProxy* proxyStruct, gchar* senderName, gchar* signalName, GVariant* parameters, DBusProxy _dBusProxy) 289 { 290 foreach ( void delegate(string, string, Variant, DBusProxy) dlg ; _dBusProxy.onGSignalListeners ) 291 { 292 dlg(Str.toString(senderName), Str.toString(signalName), ObjectG.getDObject!(Variant)(parameters), _dBusProxy); 293 } 294 } 295 296 297 /** 298 * Creates a proxy for accessing interface_name on the remote object 299 * at object_path owned by name at connection and asynchronously 300 * loads D-Bus properties unless the 301 * G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used. Connect to 302 * the "g-properties-changed" signal to get notified about 303 * property changes. 304 * If the G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up 305 * match rules for signals. Connect to the "g-signal" signal 306 * to handle signals from the remote object. 307 * If name is a well-known name and the 308 * G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag isn't set and no name 309 * owner currently exists, the message bus will be requested to launch 310 * a name owner for the name. 311 * This is a failable asynchronous constructor - when the proxy is 312 * ready, callback will be invoked and you can use 313 * g_dbus_proxy_new_finish() to get the result. 314 * See g_dbus_proxy_new_sync() and for a synchronous version of this constructor. 315 * See Example 14, “GDBusProxy for a well-known-name” for an example of how GDBusProxy can be used. 316 * Since 2.26 317 * Params: 318 * connection = A GDBusConnection. 319 * flags = Flags used when constructing the proxy. 320 * info = A GDBusInterfaceInfo specifying the minimal interface that proxy conforms to or NULL. [allow-none] 321 * name = A bus name (well-known or unique) or NULL if connection is not a message bus connection. [allow-none] 322 * objectPath = An object path. 323 * interfaceName = A D-Bus interface name. 324 * cancellable = A GCancellable or NULL. [allow-none] 325 * callback = Callback function to invoke when the proxy is ready. 326 * userData = User data to pass to callback. 327 */ 328 public static void newDBusProxy(DBusConnection connection, GDBusProxyFlags flags, GDBusInterfaceInfo* info, string name, string objectPath, string interfaceName, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 329 { 330 // void g_dbus_proxy_new (GDBusConnection *connection, GDBusProxyFlags flags, GDBusInterfaceInfo *info, const gchar *name, const gchar *object_path, const gchar *interface_name, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 331 g_dbus_proxy_new((connection is null) ? null : connection.getDBusConnectionStruct(), flags, info, Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 332 } 333 334 /** 335 * Creates a proxy for accessing interface_name on the remote object 336 * at object_path owned by name at connection and synchronously 337 * loads D-Bus properties unless the 338 * G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used. 339 * If the G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up 340 * match rules for signals. Connect to the "g-signal" signal 341 * to handle signals from the remote object. 342 * If name is a well-known name and the 343 * G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag isn't set and no name 344 * owner currently exists, the message bus will be requested to launch 345 * a name owner for the name. 346 * This is a synchronous failable constructor. See g_dbus_proxy_new() 347 * and g_dbus_proxy_new_finish() for the asynchronous version. 348 * See Example 14, “GDBusProxy for a well-known-name” for an example of how GDBusProxy can be used. 349 * Since 2.26 350 * Params: 351 * connection = A GDBusConnection. 352 * flags = Flags used when constructing the proxy. 353 * info = A GDBusInterfaceInfo specifying the minimal interface that proxy conforms to or NULL. [allow-none] 354 * name = A bus name (well-known or unique) or NULL if connection is not a message bus connection. [allow-none] 355 * objectPath = An object path. 356 * interfaceName = A D-Bus interface name. 357 * cancellable = A GCancellable or NULL. [allow-none] 358 * Throws: GException on failure. 359 * Throws: ConstructionException GTK+ fails to create the object. 360 */ 361 public this (DBusConnection connection, GDBusProxyFlags flags, GDBusInterfaceInfo* info, string name, string objectPath, string interfaceName, Cancellable cancellable) 362 { 363 // GDBusProxy * g_dbus_proxy_new_sync (GDBusConnection *connection, GDBusProxyFlags flags, GDBusInterfaceInfo *info, const gchar *name, const gchar *object_path, const gchar *interface_name, GCancellable *cancellable, GError **error); 364 GError* err = null; 365 366 auto p = g_dbus_proxy_new_sync((connection is null) ? null : connection.getDBusConnectionStruct(), flags, info, Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 367 368 if (err !is null) 369 { 370 throw new GException( new ErrorG(err) ); 371 } 372 373 if(p is null) 374 { 375 throw new ConstructionException("null returned by g_dbus_proxy_new_sync((connection is null) ? null : connection.getDBusConnectionStruct(), flags, info, Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err)"); 376 } 377 this(cast(GDBusProxy*) p); 378 } 379 380 /** 381 * Like g_dbus_proxy_new() but takes a GBusType instead of a GDBusConnection. 382 * See Example 14, “GDBusProxy for a well-known-name” for an example of how GDBusProxy can be used. 383 * Since 2.26 384 * Params: 385 * busType = A GBusType. 386 * flags = Flags used when constructing the proxy. 387 * info = A GDBusInterfaceInfo specifying the minimal interface that proxy conforms to or NULL. [allow-none] 388 * name = A bus name (well-known or unique). 389 * objectPath = An object path. 390 * interfaceName = A D-Bus interface name. 391 * cancellable = A GCancellable or NULL. [allow-none] 392 * callback = Callback function to invoke when the proxy is ready. 393 * userData = User data to pass to callback. 394 */ 395 public static void newForBus(GBusType busType, GDBusProxyFlags flags, GDBusInterfaceInfo* info, string name, string objectPath, string interfaceName, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 396 { 397 // void g_dbus_proxy_new_for_bus (GBusType bus_type, GDBusProxyFlags flags, GDBusInterfaceInfo *info, const gchar *name, const gchar *object_path, const gchar *interface_name, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 398 g_dbus_proxy_new_for_bus(busType, flags, info, Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 399 } 400 401 /** 402 * Like g_dbus_proxy_new_sync() but takes a GBusType instead of a GDBusConnection. 403 * See Example 14, “GDBusProxy for a well-known-name” for an example of how GDBusProxy can be used. 404 * Since 2.26 405 * Params: 406 * busType = A GBusType. 407 * flags = Flags used when constructing the proxy. 408 * info = A GDBusInterfaceInfo specifying the minimal interface 409 * that proxy conforms to or NULL. [allow-none] 410 * name = A bus name (well-known or unique). 411 * objectPath = An object path. 412 * interfaceName = A D-Bus interface name. 413 * cancellable = A GCancellable or NULL. [allow-none] 414 * Throws: GException on failure. 415 * Throws: ConstructionException GTK+ fails to create the object. 416 */ 417 public this (GBusType busType, GDBusProxyFlags flags, GDBusInterfaceInfo* info, string name, string objectPath, string interfaceName, Cancellable cancellable) 418 { 419 // GDBusProxy * g_dbus_proxy_new_for_bus_sync (GBusType bus_type, GDBusProxyFlags flags, GDBusInterfaceInfo *info, const gchar *name, const gchar *object_path, const gchar *interface_name, GCancellable *cancellable, GError **error); 420 GError* err = null; 421 422 auto p = g_dbus_proxy_new_for_bus_sync(busType, flags, info, Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 423 424 if (err !is null) 425 { 426 throw new GException( new ErrorG(err) ); 427 } 428 429 if(p is null) 430 { 431 throw new ConstructionException("null returned by g_dbus_proxy_new_for_bus_sync(busType, flags, info, Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err)"); 432 } 433 this(cast(GDBusProxy*) p); 434 } 435 436 /** 437 * Gets the flags that proxy was constructed with. 438 * Since 2.26 439 * Returns: Flags from the GDBusProxyFlags enumeration. 440 */ 441 public GDBusProxyFlags getFlags() 442 { 443 // GDBusProxyFlags g_dbus_proxy_get_flags (GDBusProxy *proxy); 444 return g_dbus_proxy_get_flags(gDBusProxy); 445 } 446 447 /** 448 * Gets the connection proxy is for. 449 * Since 2.26 450 * Returns: A GDBusConnection owned by proxy. Do not free. [transfer none] 451 */ 452 public DBusConnection getConnection() 453 { 454 // GDBusConnection * g_dbus_proxy_get_connection (GDBusProxy *proxy); 455 auto p = g_dbus_proxy_get_connection(gDBusProxy); 456 457 if(p is null) 458 { 459 return null; 460 } 461 462 return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p); 463 } 464 465 /** 466 * Gets the name that proxy was constructed for. 467 * Since 2.26 468 * Returns: A string owned by proxy. Do not free. 469 */ 470 public string getName() 471 { 472 // const gchar * g_dbus_proxy_get_name (GDBusProxy *proxy); 473 return Str.toString(g_dbus_proxy_get_name(gDBusProxy)); 474 } 475 476 /** 477 * The unique name that owns the name that proxy is for or NULL if 478 * no-one currently owns that name. You may connect to the 479 * "notify" signal to track changes to the 480 * "g-name-owner" property. 481 * Since 2.26 482 * Returns: The name owner or NULL if no name owner exists. Free with g_free(). 483 */ 484 public string getNameOwner() 485 { 486 // gchar * g_dbus_proxy_get_name_owner (GDBusProxy *proxy); 487 return Str.toString(g_dbus_proxy_get_name_owner(gDBusProxy)); 488 } 489 490 /** 491 * Gets the object path proxy is for. 492 * Since 2.26 493 * Returns: A string owned by proxy. Do not free. 494 */ 495 public string getObjectPath() 496 { 497 // const gchar * g_dbus_proxy_get_object_path (GDBusProxy *proxy); 498 return Str.toString(g_dbus_proxy_get_object_path(gDBusProxy)); 499 } 500 501 /** 502 * Gets the D-Bus interface name proxy is for. 503 * Since 2.26 504 * Returns: A string owned by proxy. Do not free. 505 */ 506 public string getInterfaceName() 507 { 508 // const gchar * g_dbus_proxy_get_interface_name (GDBusProxy *proxy); 509 return Str.toString(g_dbus_proxy_get_interface_name(gDBusProxy)); 510 } 511 512 /** 513 * Gets the timeout to use if -1 (specifying default timeout) is 514 * passed as timeout_msec in the g_dbus_proxy_call() and 515 * g_dbus_proxy_call_sync() functions. 516 * See the "g-default-timeout" property for more details. 517 * Since 2.26 518 * Returns: Timeout to use for proxy. 519 */ 520 public int getDefaultTimeout() 521 { 522 // gint g_dbus_proxy_get_default_timeout (GDBusProxy *proxy); 523 return g_dbus_proxy_get_default_timeout(gDBusProxy); 524 } 525 526 /** 527 * Sets the timeout to use if -1 (specifying default timeout) is 528 * passed as timeout_msec in the g_dbus_proxy_call() and 529 * g_dbus_proxy_call_sync() functions. 530 * See the "g-default-timeout" property for more details. 531 * Since 2.26 532 * Params: 533 * timeoutMsec = Timeout in milliseconds. 534 */ 535 public void setDefaultTimeout(int timeoutMsec) 536 { 537 // void g_dbus_proxy_set_default_timeout (GDBusProxy *proxy, gint timeout_msec); 538 g_dbus_proxy_set_default_timeout(gDBusProxy, timeoutMsec); 539 } 540 541 /** 542 * Looks up the value for a property from the cache. This call does no 543 * blocking IO. 544 * If proxy has an expected interface (see 545 * "g-interface-info") and property_name is referenced by 546 * it, then value is checked against the type of the property. 547 * Since 2.26 548 * Params: 549 * propertyName = Property name. 550 * Returns: A reference to the GVariant instance that holds the value for property_name or NULL if the value is not in the cache. The returned reference must be freed with g_variant_unref(). 551 */ 552 public Variant getCachedProperty(string propertyName) 553 { 554 // GVariant * g_dbus_proxy_get_cached_property (GDBusProxy *proxy, const gchar *property_name); 555 auto p = g_dbus_proxy_get_cached_property(gDBusProxy, Str.toStringz(propertyName)); 556 557 if(p is null) 558 { 559 return null; 560 } 561 562 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 563 } 564 565 /** 566 * If value is not NULL, sets the cached value for the property with 567 * name property_name to the value in value. 568 * If value is NULL, then the cached value is removed from the 569 * property cache. 570 * If proxy has an expected interface (see 571 * "g-interface-info") and property_name is referenced by 572 * it, then value is checked against the type of the property. 573 * If the value GVariant is floating, it is consumed. This allows 574 * convenient 'inline' use of g_variant_new(), e.g. 575 * $(DDOC_COMMENT example) 576 * Normally you will not need to use this method since proxy is 577 * tracking changes using the 578 * org.freedesktop.DBus.Properties.PropertiesChanged 579 * D-Bus signal. However, for performance reasons an object may decide 580 * to not use this signal for some properties and instead use a 581 * proprietary out-of-band mechanism to transmit changes. 582 * As a concrete example, consider an object with a property 583 * ChatroomParticipants which is an array of 584 * strings. Instead of transmitting the same (long) array every time 585 * the property changes, it is more efficient to only transmit the 586 * delta using e.g. signals ChatroomParticipantJoined(String 587 * name) and ChatroomParticipantParted(String 588 * name). 589 * Since 2.26 590 * Params: 591 * propertyName = Property name. 592 * value = Value for the property or NULL to remove it from the cache. [allow-none] 593 */ 594 public void setCachedProperty(string propertyName, Variant value) 595 { 596 // void g_dbus_proxy_set_cached_property (GDBusProxy *proxy, const gchar *property_name, GVariant *value); 597 g_dbus_proxy_set_cached_property(gDBusProxy, Str.toStringz(propertyName), (value is null) ? null : value.getVariantStruct()); 598 } 599 600 /** 601 * Gets the names of all cached properties on proxy. 602 * Since 2.26 603 * Returns: A NULL-terminated array of strings or NULL if proxy has no cached properties. Free the returned array with g_strfreev(). [transfer full] 604 */ 605 public string[] getCachedPropertyNames() 606 { 607 // gchar ** g_dbus_proxy_get_cached_property_names (GDBusProxy *proxy); 608 return Str.toStringArray(g_dbus_proxy_get_cached_property_names(gDBusProxy)); 609 } 610 611 /** 612 * Ensure that interactions with proxy conform to the given 613 * interface. See the "g-interface-info" property for more 614 * details. 615 * Since 2.26 616 * Params: 617 * info = Minimum interface this proxy conforms to or NULL to unset. [allow-none] 618 */ 619 public void setInterfaceInfo(GDBusInterfaceInfo* info) 620 { 621 // void g_dbus_proxy_set_interface_info (GDBusProxy *proxy, GDBusInterfaceInfo *info); 622 g_dbus_proxy_set_interface_info(gDBusProxy, info); 623 } 624 625 /** 626 * Returns the GDBusInterfaceInfo, if any, specifying the interface 627 * that proxy conforms to. See the "g-interface-info" 628 * property for more details. 629 * Since 2.26 630 * Returns: A GDBusInterfaceInfo or NULL. Do not unref the returned object, it is owned by proxy. 631 */ 632 public GDBusInterfaceInfo* getInterfaceInfo() 633 { 634 // GDBusInterfaceInfo * g_dbus_proxy_get_interface_info (GDBusProxy *proxy); 635 return g_dbus_proxy_get_interface_info(gDBusProxy); 636 } 637 638 /** 639 * Asynchronously invokes the method_name method on proxy. 640 * If method_name contains any dots, then name is split into interface and 641 * method name parts. This allows using proxy for invoking methods on 642 * other interfaces. 643 * If the GDBusConnection associated with proxy is closed then 644 * the operation will fail with G_IO_ERROR_CLOSED. If 645 * cancellable is canceled, the operation will fail with 646 * G_IO_ERROR_CANCELLED. If parameters contains a value not 647 * compatible with the D-Bus protocol, the operation fails with 648 * G_IO_ERROR_INVALID_ARGUMENT. 649 * If the parameters GVariant is floating, it is consumed. This allows 650 * Since 2.26 651 * Params: 652 * methodName = Name of method to invoke. 653 * parameters = A GVariant tuple with parameters for the signal or NULL if not passing parameters. [allow-none] 654 * flags = Flags from the GDBusCallFlags enumeration. 655 * timeoutMsec = The timeout in milliseconds (with G_MAXINT meaning 656 * "infinite") or -1 to use the proxy default timeout. 657 * cancellable = A GCancellable or NULL. [allow-none] 658 * callback = A GAsyncReadyCallback to call when the request is satisfied or NULL if you don't 659 * care about the result of the method invocation. [allow-none] 660 * userData = The data to pass to callback. 661 */ 662 public void call(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 663 { 664 // void g_dbus_proxy_call (GDBusProxy *proxy, const gchar *method_name, GVariant *parameters, GDBusCallFlags flags, gint timeout_msec, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 665 g_dbus_proxy_call(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 666 } 667 668 /** 669 * Finishes an operation started with g_dbus_proxy_call(). 670 * Since 2.26 671 * Params: 672 * res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_proxy_call(). 673 * Returns: NULL if error is set. Otherwise a GVariant tuple with return values. Free with g_variant_unref(). 674 * Throws: GException on failure. 675 */ 676 public Variant callFinish(AsyncResultIF res) 677 { 678 // GVariant * g_dbus_proxy_call_finish (GDBusProxy *proxy, GAsyncResult *res, GError **error); 679 GError* err = null; 680 681 auto p = g_dbus_proxy_call_finish(gDBusProxy, (res is null) ? null : res.getAsyncResultTStruct(), &err); 682 683 if (err !is null) 684 { 685 throw new GException( new ErrorG(err) ); 686 } 687 688 689 if(p is null) 690 { 691 return null; 692 } 693 694 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 695 } 696 697 /** 698 * Synchronously invokes the method_name method on proxy. 699 * If method_name contains any dots, then name is split into interface and 700 * method name parts. This allows using proxy for invoking methods on 701 * other interfaces. 702 * If the GDBusConnection associated with proxy is disconnected then 703 * the operation will fail with G_IO_ERROR_CLOSED. If 704 * cancellable is canceled, the operation will fail with 705 * G_IO_ERROR_CANCELLED. If parameters contains a value not 706 * compatible with the D-Bus protocol, the operation fails with 707 * G_IO_ERROR_INVALID_ARGUMENT. 708 * If the parameters GVariant is floating, it is consumed. This allows 709 * Since 2.26 710 * Params: 711 * methodName = Name of method to invoke. 712 * parameters = A GVariant tuple with parameters for the signal 713 * or NULL if not passing parameters. [allow-none] 714 * flags = Flags from the GDBusCallFlags enumeration. 715 * timeoutMsec = The timeout in milliseconds (with G_MAXINT meaning 716 * "infinite") or -1 to use the proxy default timeout. 717 * cancellable = A GCancellable or NULL. [allow-none] 718 * Returns: NULL if error is set. Otherwise a GVariant tuple with return values. Free with g_variant_unref(). 719 * Throws: GException on failure. 720 */ 721 public Variant callSync(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable) 722 { 723 // GVariant * g_dbus_proxy_call_sync (GDBusProxy *proxy, const gchar *method_name, GVariant *parameters, GDBusCallFlags flags, gint timeout_msec, GCancellable *cancellable, GError **error); 724 GError* err = null; 725 726 auto p = g_dbus_proxy_call_sync(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 727 728 if (err !is null) 729 { 730 throw new GException( new ErrorG(err) ); 731 } 732 733 734 if(p is null) 735 { 736 return null; 737 } 738 739 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 740 } 741 742 /** 743 * Like g_dbus_proxy_call() but also takes a GUnixFDList object. 744 * This method is only available on UNIX. 745 * Since 2.30 746 * Params: 747 * methodName = Name of method to invoke. 748 * parameters = A GVariant tuple with parameters for the signal or NULL if not passing parameters. [allow-none] 749 * flags = Flags from the GDBusCallFlags enumeration. 750 * timeoutMsec = The timeout in milliseconds (with G_MAXINT meaning 751 * "infinite") or -1 to use the proxy default timeout. 752 * fdList = A GUnixFDList or NULL. [allow-none] 753 * cancellable = A GCancellable or NULL. [allow-none] 754 * callback = A GAsyncReadyCallback to call when the request is satisfied or NULL if you don't 755 * care about the result of the method invocation. [allow-none] 756 * userData = The data to pass to callback. 757 */ 758 public void callWithUnixFdList(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, UnixFDList fdList, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 759 { 760 // void g_dbus_proxy_call_with_unix_fd_list (GDBusProxy *proxy, const gchar *method_name, GVariant *parameters, GDBusCallFlags flags, gint timeout_msec, GUnixFDList *fd_list, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); 761 g_dbus_proxy_call_with_unix_fd_list(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (fdList is null) ? null : fdList.getUnixFDListStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 762 } 763 764 /** 765 * Finishes an operation started with g_dbus_proxy_call_with_unix_fd_list(). 766 * Since 2.30 767 * Params: 768 * outFdList = Return location for a GUnixFDList or NULL. [out][allow-none] 769 * res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_proxy_call_with_unix_fd_list(). 770 * Returns: NULL if error is set. Otherwise a GVariant tuple with return values. Free with g_variant_unref(). 771 * Throws: GException on failure. 772 */ 773 public Variant callWithUnixFdListFinish(out UnixFDList outFdList, AsyncResultIF res) 774 { 775 // GVariant * g_dbus_proxy_call_with_unix_fd_list_finish (GDBusProxy *proxy, GUnixFDList **out_fd_list, GAsyncResult *res, GError **error); 776 GUnixFDList* outoutFdList = null; 777 GError* err = null; 778 779 auto p = g_dbus_proxy_call_with_unix_fd_list_finish(gDBusProxy, &outoutFdList, (res is null) ? null : res.getAsyncResultTStruct(), &err); 780 781 if (err !is null) 782 { 783 throw new GException( new ErrorG(err) ); 784 } 785 786 outFdList = ObjectG.getDObject!(UnixFDList)(outoutFdList); 787 788 if(p is null) 789 { 790 return null; 791 } 792 793 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 794 } 795 796 /** 797 * Like g_dbus_proxy_call_sync() but also takes and returns GUnixFDList objects. 798 * This method is only available on UNIX. 799 * Since 2.30 800 * Params: 801 * methodName = Name of method to invoke. 802 * parameters = A GVariant tuple with parameters for the signal 803 * or NULL if not passing parameters. [allow-none] 804 * flags = Flags from the GDBusCallFlags enumeration. 805 * timeoutMsec = The timeout in milliseconds (with G_MAXINT meaning 806 * "infinite") or -1 to use the proxy default timeout. 807 * fdList = A GUnixFDList or NULL. [allow-none] 808 * outFdList = Return location for a GUnixFDList or NULL. [out][allow-none] 809 * cancellable = A GCancellable or NULL. [allow-none] 810 * Returns: NULL if error is set. Otherwise a GVariant tuple with return values. Free with g_variant_unref(). 811 * Throws: GException on failure. 812 */ 813 public Variant callWithUnixFdListSync(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, UnixFDList fdList, out UnixFDList outFdList, Cancellable cancellable) 814 { 815 // GVariant * g_dbus_proxy_call_with_unix_fd_list_sync (GDBusProxy *proxy, const gchar *method_name, GVariant *parameters, GDBusCallFlags flags, gint timeout_msec, GUnixFDList *fd_list, GUnixFDList **out_fd_list, GCancellable *cancellable, GError **error); 816 GUnixFDList* outoutFdList = null; 817 GError* err = null; 818 819 auto p = g_dbus_proxy_call_with_unix_fd_list_sync(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (fdList is null) ? null : fdList.getUnixFDListStruct(), &outoutFdList, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 820 821 if (err !is null) 822 { 823 throw new GException( new ErrorG(err) ); 824 } 825 826 outFdList = ObjectG.getDObject!(UnixFDList)(outoutFdList); 827 828 if(p is null) 829 { 830 return null; 831 } 832 833 return ObjectG.getDObject!(Variant)(cast(GVariant*) p); 834 } 835 }