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