1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.DBusProxy;
26 
27 private import gio.AsyncInitableIF;
28 private import gio.AsyncInitableT;
29 private import gio.AsyncResultIF;
30 private import gio.Cancellable;
31 private import gio.DBusConnection;
32 private import gio.DBusInterfaceIF;
33 private import gio.DBusInterfaceInfo;
34 private import gio.DBusInterfaceT;
35 private import gio.InitableIF;
36 private import gio.InitableT;
37 private import gio.UnixFDList;
38 private import glib.ConstructionException;
39 private import glib.ErrorG;
40 private import glib.GException;
41 private import glib.Str;
42 private import glib.Variant;
43 private import gobject.ObjectG;
44 private import gobject.Signals;
45 public  import gtkc.gdktypes;
46 private import gtkc.gio;
47 public  import gtkc.giotypes;
48 private import std.algorithm;
49 
50 
51 /**
52  * #GDBusProxy is a base class used for proxies to access a D-Bus
53  * interface on a remote object. A #GDBusProxy can be constructed for
54  * both well-known and unique names.
55  * 
56  * By default, #GDBusProxy will cache all properties (and listen to
57  * changes) of the remote object, and proxy all signals that gets
58  * emitted. This behaviour can be changed by passing suitable
59  * #GDBusProxyFlags when the proxy is created. If the proxy is for a
60  * well-known name, the property cache is flushed when the name owner
61  * vanishes and reloaded when a name owner appears.
62  * 
63  * If a #GDBusProxy is used for a well-known name, the owner of the
64  * name is tracked and can be read from
65  * #GDBusProxy:g-name-owner. Connect to the #GObject::notify signal to
66  * get notified of changes. Additionally, only signals and property
67  * changes emitted from the current name owner are considered and
68  * calls are always sent to the current name owner. This avoids a
69  * number of race conditions when the name is lost by one owner and
70  * claimed by another. However, if no name owner currently exists,
71  * then calls will be sent to the well-known name which may result in
72  * the message bus launching an owner (unless
73  * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START is set).
74  * 
75  * The generic #GDBusProxy::g-properties-changed and
76  * #GDBusProxy::g-signal signals are not very convenient to work with.
77  * Therefore, the recommended way of working with proxies is to subclass
78  * #GDBusProxy, and have more natural properties and signals in your derived
79  * class. This [example][gdbus-example-gdbus-codegen] shows how this can
80  * easily be done using the [gdbus-codegen][gdbus-codegen] tool.
81  * 
82  * A #GDBusProxy instance can be used from multiple threads but note
83  * that all signals (e.g. #GDBusProxy::g-signal, #GDBusProxy::g-properties-changed
84  * and #GObject::notify) are emitted in the
85  * [thread-default main context][g-main-context-push-thread-default]
86  * of the thread where the instance was constructed.
87  * 
88  * An example using a proxy for a well-known name can be found in
89  * [gdbus-example-watch-proxy.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-watch-proxy.c)
90  *
91  * Since: 2.26
92  */
93 public class DBusProxy : ObjectG, AsyncInitableIF, DBusInterfaceIF, InitableIF
94 {
95 	/** the main Gtk struct */
96 	protected GDBusProxy* gDBusProxy;
97 
98 	/** Get the main Gtk struct */
99 	public GDBusProxy* getDBusProxyStruct()
100 	{
101 		return gDBusProxy;
102 	}
103 
104 	/** the main Gtk struct as a void* */
105 	protected override void* getStruct()
106 	{
107 		return cast(void*)gDBusProxy;
108 	}
109 
110 	protected override void setStruct(GObject* obj)
111 	{
112 		gDBusProxy = cast(GDBusProxy*)obj;
113 		super.setStruct(obj);
114 	}
115 
116 	/**
117 	 * Sets our main struct and passes it to the parent class.
118 	 */
119 	public this (GDBusProxy* gDBusProxy, bool ownedRef = false)
120 	{
121 		this.gDBusProxy = gDBusProxy;
122 		super(cast(GObject*)gDBusProxy, ownedRef);
123 	}
124 
125 	// add the AsyncInitable capabilities
126 	mixin AsyncInitableT!(GDBusProxy);
127 
128 	// add the DBusInterface capabilities
129 	mixin DBusInterfaceT!(GDBusProxy);
130 
131 	// add the Initable capabilities
132 	mixin InitableT!(GDBusProxy);
133 
134 	/**
135 	 * Finishes creating a GDBusProxy.
136 	 *
137 	 * Params:
138 	 *     res    = A GAsyncResult obtained from the GAsyncReadyCallback
139 	 *              function passed to g_dbus_proxy_new().
140 	 *     forBus = If true finish an address.
141 	 *
142 	 * Throws: GException on failure.
143 	 * Throws: ConstructionException GTK+ fails to create the object.
144 	 *
145 	 * Since: 2.26
146 	 */
147 	public this (AsyncResultIF res, bool forBus = false)
148 	{
149 		GError* err = null;
150 		GDBusProxy* p;
151 		
152 		if ( forBus )
153 		{
154 			p = g_dbus_proxy_new_for_bus_finish((res is null) ? null : res.getAsyncResultStruct(), &err);
155 		}
156 		else
157 		{
158 			p = g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err);
159 		}
160 		
161 		if (err !is null)
162 		{
163 			throw new GException( new ErrorG(err) );
164 		}
165 		
166 		if(p is null)
167 		{
168 			throw new ConstructionException("null returned by g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err)");
169 		}
170 		this(p, true);
171 	}
172 
173 	/**
174 	 */
175 
176 	/** */
177 	public static GType getType()
178 	{
179 		return g_dbus_proxy_get_type();
180 	}
181 
182 	/**
183 	 * Like g_dbus_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
184 	 *
185 	 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy].
186 	 *
187 	 * Params:
188 	 *     busType = A #GBusType.
189 	 *     flags = Flags used when constructing the proxy.
190 	 *     info = A #GDBusInterfaceInfo specifying the minimal interface
191 	 *         that @proxy conforms to or %NULL.
192 	 *     name = A bus name (well-known or unique).
193 	 *     objectPath = An object path.
194 	 *     interfaceName = A D-Bus interface name.
195 	 *     cancellable = A #GCancellable or %NULL.
196 	 *
197 	 * Return: A #GDBusProxy or %NULL if error is set. Free with g_object_unref().
198 	 *
199 	 * Since: 2.26
200 	 *
201 	 * Throws: GException on failure.
202 	 * Throws: ConstructionException GTK+ fails to create the object.
203 	 */
204 	public this(GBusType busType, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable)
205 	{
206 		GError* err = null;
207 		
208 		auto p = g_dbus_proxy_new_for_bus_sync(busType, flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
209 		
210 		if (err !is null)
211 		{
212 			throw new GException( new ErrorG(err) );
213 		}
214 		
215 		if(p is null)
216 		{
217 			throw new ConstructionException("null returned by new_for_bus_sync");
218 		}
219 		
220 		this(cast(GDBusProxy*) p, true);
221 	}
222 
223 	/**
224 	 * Creates a proxy for accessing @interface_name on the remote object
225 	 * at @object_path owned by @name at @connection and synchronously
226 	 * loads D-Bus properties unless the
227 	 * %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used.
228 	 *
229 	 * If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up
230 	 * match rules for signals. Connect to the #GDBusProxy::g-signal signal
231 	 * to handle signals from the remote object.
232 	 *
233 	 * If @name is a well-known name and the
234 	 * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION
235 	 * flags aren't set and no name owner currently exists, the message bus
236 	 * will be requested to launch a name owner for the name.
237 	 *
238 	 * This is a synchronous failable constructor. See g_dbus_proxy_new()
239 	 * and g_dbus_proxy_new_finish() for the asynchronous version.
240 	 *
241 	 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy].
242 	 *
243 	 * Params:
244 	 *     connection = A #GDBusConnection.
245 	 *     flags = Flags used when constructing the proxy.
246 	 *     info = A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.
247 	 *     name = A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
248 	 *     objectPath = An object path.
249 	 *     interfaceName = A D-Bus interface name.
250 	 *     cancellable = A #GCancellable or %NULL.
251 	 *
252 	 * Return: A #GDBusProxy or %NULL if error is set. Free with g_object_unref().
253 	 *
254 	 * Since: 2.26
255 	 *
256 	 * Throws: GException on failure.
257 	 * Throws: ConstructionException GTK+ fails to create the object.
258 	 */
259 	public this(DBusConnection connection, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable)
260 	{
261 		GError* err = null;
262 		
263 		auto p = g_dbus_proxy_new_sync((connection is null) ? null : connection.getDBusConnectionStruct(), flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
264 		
265 		if (err !is null)
266 		{
267 			throw new GException( new ErrorG(err) );
268 		}
269 		
270 		if(p is null)
271 		{
272 			throw new ConstructionException("null returned by new_sync");
273 		}
274 		
275 		this(cast(GDBusProxy*) p, true);
276 	}
277 
278 	/**
279 	 * Creates a proxy for accessing @interface_name on the remote object
280 	 * at @object_path owned by @name at @connection and asynchronously
281 	 * loads D-Bus properties unless the
282 	 * %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used. Connect to
283 	 * the #GDBusProxy::g-properties-changed signal to get notified about
284 	 * property changes.
285 	 *
286 	 * If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up
287 	 * match rules for signals. Connect to the #GDBusProxy::g-signal signal
288 	 * to handle signals from the remote object.
289 	 *
290 	 * If @name is a well-known name and the
291 	 * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION
292 	 * flags aren't set and no name owner currently exists, the message bus
293 	 * will be requested to launch a name owner for the name.
294 	 *
295 	 * This is a failable asynchronous constructor - when the proxy is
296 	 * ready, @callback will be invoked and you can use
297 	 * g_dbus_proxy_new_finish() to get the result.
298 	 *
299 	 * See g_dbus_proxy_new_sync() and for a synchronous version of this constructor.
300 	 *
301 	 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy].
302 	 *
303 	 * Params:
304 	 *     connection = A #GDBusConnection.
305 	 *     flags = Flags used when constructing the proxy.
306 	 *     info = A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.
307 	 *     name = A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
308 	 *     objectPath = An object path.
309 	 *     interfaceName = A D-Bus interface name.
310 	 *     cancellable = A #GCancellable or %NULL.
311 	 *     callback = Callback function to invoke when the proxy is ready.
312 	 *     userData = User data to pass to @callback.
313 	 *
314 	 * Since: 2.26
315 	 */
316 	public static void newProxy(DBusConnection connection, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
317 	{
318 		g_dbus_proxy_new((connection is null) ? null : connection.getDBusConnectionStruct(), flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
319 	}
320 
321 	/**
322 	 * Like g_dbus_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
323 	 *
324 	 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy].
325 	 *
326 	 * Params:
327 	 *     busType = A #GBusType.
328 	 *     flags = Flags used when constructing the proxy.
329 	 *     info = A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.
330 	 *     name = A bus name (well-known or unique).
331 	 *     objectPath = An object path.
332 	 *     interfaceName = A D-Bus interface name.
333 	 *     cancellable = A #GCancellable or %NULL.
334 	 *     callback = Callback function to invoke when the proxy is ready.
335 	 *     userData = User data to pass to @callback.
336 	 *
337 	 * Since: 2.26
338 	 */
339 	public static void newForBus(GBusType busType, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
340 	{
341 		g_dbus_proxy_new_for_bus(busType, flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
342 	}
343 
344 	/**
345 	 * Asynchronously invokes the @method_name method on @proxy.
346 	 *
347 	 * If @method_name contains any dots, then @name is split into interface and
348 	 * method name parts. This allows using @proxy for invoking methods on
349 	 * other interfaces.
350 	 *
351 	 * If the #GDBusConnection associated with @proxy is closed then
352 	 * the operation will fail with %G_IO_ERROR_CLOSED. If
353 	 * @cancellable is canceled, the operation will fail with
354 	 * %G_IO_ERROR_CANCELLED. If @parameters contains a value not
355 	 * compatible with the D-Bus protocol, the operation fails with
356 	 * %G_IO_ERROR_INVALID_ARGUMENT.
357 	 *
358 	 * If the @parameters #GVariant is floating, it is consumed. This allows
359 	 * convenient 'inline' use of g_variant_new(), e.g.:
360 	 * |[<!-- language="C" -->
361 	 * g_dbus_proxy_call (proxy,
362 	 * "TwoStrings",
363 	 * g_variant_new ("(ss)",
364 	 * "Thing One",
365 	 * "Thing Two"),
366 	 * G_DBUS_CALL_FLAGS_NONE,
367 	 * -1,
368 	 * NULL,
369 	 * (GAsyncReadyCallback) two_strings_done,
370 	 * &data);
371 	 * ]|
372 	 *
373 	 * If @proxy has an expected interface (see
374 	 * #GDBusProxy:g-interface-info) and @method_name is referenced by it,
375 	 * then the return value is checked against the return type.
376 	 *
377 	 * This is an asynchronous method. When the operation is finished,
378 	 * @callback will be invoked in the
379 	 * [thread-default main context][g-main-context-push-thread-default]
380 	 * of the thread you are calling this method from.
381 	 * You can then call g_dbus_proxy_call_finish() to get the result of
382 	 * the operation. See g_dbus_proxy_call_sync() for the synchronous
383 	 * version of this method.
384 	 *
385 	 * If @callback is %NULL then the D-Bus method call message will be sent with
386 	 * the %G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED flag set.
387 	 *
388 	 * Params:
389 	 *     methodName = Name of method to invoke.
390 	 *     parameters = A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.
391 	 *     flags = Flags from the #GDBusCallFlags enumeration.
392 	 *     timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning
393 	 *         "infinite") or -1 to use the proxy default timeout.
394 	 *     cancellable = A #GCancellable or %NULL.
395 	 *     callback = A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't
396 	 *         care about the result of the method invocation.
397 	 *     userData = The data to pass to @callback.
398 	 *
399 	 * Since: 2.26
400 	 */
401 	public void call(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
402 	{
403 		g_dbus_proxy_call(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
404 	}
405 
406 	/**
407 	 * Finishes an operation started with g_dbus_proxy_call().
408 	 *
409 	 * Params:
410 	 *     res = A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_proxy_call().
411 	 *
412 	 * Return: %NULL if @error is set. Otherwise a #GVariant tuple with
413 	 *     return values. Free with g_variant_unref().
414 	 *
415 	 * Since: 2.26
416 	 *
417 	 * Throws: GException on failure.
418 	 */
419 	public Variant callFinish(AsyncResultIF res)
420 	{
421 		GError* err = null;
422 		
423 		auto p = g_dbus_proxy_call_finish(gDBusProxy, (res is null) ? null : res.getAsyncResultStruct(), &err);
424 		
425 		if (err !is null)
426 		{
427 			throw new GException( new ErrorG(err) );
428 		}
429 		
430 		if(p is null)
431 		{
432 			return null;
433 		}
434 		
435 		return new Variant(cast(GVariant*) p, true);
436 	}
437 
438 	/**
439 	 * Synchronously invokes the @method_name method on @proxy.
440 	 *
441 	 * If @method_name contains any dots, then @name is split into interface and
442 	 * method name parts. This allows using @proxy for invoking methods on
443 	 * other interfaces.
444 	 *
445 	 * If the #GDBusConnection associated with @proxy is disconnected then
446 	 * the operation will fail with %G_IO_ERROR_CLOSED. If
447 	 * @cancellable is canceled, the operation will fail with
448 	 * %G_IO_ERROR_CANCELLED. If @parameters contains a value not
449 	 * compatible with the D-Bus protocol, the operation fails with
450 	 * %G_IO_ERROR_INVALID_ARGUMENT.
451 	 *
452 	 * If the @parameters #GVariant is floating, it is consumed. This allows
453 	 * convenient 'inline' use of g_variant_new(), e.g.:
454 	 * |[<!-- language="C" -->
455 	 * g_dbus_proxy_call_sync (proxy,
456 	 * "TwoStrings",
457 	 * g_variant_new ("(ss)",
458 	 * "Thing One",
459 	 * "Thing Two"),
460 	 * G_DBUS_CALL_FLAGS_NONE,
461 	 * -1,
462 	 * NULL,
463 	 * &error);
464 	 * ]|
465 	 *
466 	 * The calling thread is blocked until a reply is received. See
467 	 * g_dbus_proxy_call() for the asynchronous version of this
468 	 * method.
469 	 *
470 	 * If @proxy has an expected interface (see
471 	 * #GDBusProxy:g-interface-info) and @method_name is referenced by it,
472 	 * then the return value is checked against the return type.
473 	 *
474 	 * Params:
475 	 *     methodName = Name of method to invoke.
476 	 *     parameters = A #GVariant tuple with parameters for the signal
477 	 *         or %NULL if not passing parameters.
478 	 *     flags = Flags from the #GDBusCallFlags enumeration.
479 	 *     timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning
480 	 *         "infinite") or -1 to use the proxy default timeout.
481 	 *     cancellable = A #GCancellable or %NULL.
482 	 *
483 	 * Return: %NULL if @error is set. Otherwise a #GVariant tuple with
484 	 *     return values. Free with g_variant_unref().
485 	 *
486 	 * Since: 2.26
487 	 *
488 	 * Throws: GException on failure.
489 	 */
490 	public Variant callSync(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable)
491 	{
492 		GError* err = null;
493 		
494 		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);
495 		
496 		if (err !is null)
497 		{
498 			throw new GException( new ErrorG(err) );
499 		}
500 		
501 		if(p is null)
502 		{
503 			return null;
504 		}
505 		
506 		return new Variant(cast(GVariant*) p, true);
507 	}
508 
509 	/**
510 	 * Like g_dbus_proxy_call() but also takes a #GUnixFDList object.
511 	 *
512 	 * This method is only available on UNIX.
513 	 *
514 	 * Params:
515 	 *     methodName = Name of method to invoke.
516 	 *     parameters = A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.
517 	 *     flags = Flags from the #GDBusCallFlags enumeration.
518 	 *     timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning
519 	 *         "infinite") or -1 to use the proxy default timeout.
520 	 *     fdList = A #GUnixFDList or %NULL.
521 	 *     cancellable = A #GCancellable or %NULL.
522 	 *     callback = A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't
523 	 *         care about the result of the method invocation.
524 	 *     userData = The data to pass to @callback.
525 	 *
526 	 * Since: 2.30
527 	 */
528 	public void callWithUnixFdList(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, UnixFDList fdList, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
529 	{
530 		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);
531 	}
532 
533 	/**
534 	 * Finishes an operation started with g_dbus_proxy_call_with_unix_fd_list().
535 	 *
536 	 * Params:
537 	 *     outFdList = Return location for a #GUnixFDList or %NULL.
538 	 *     res = A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_proxy_call_with_unix_fd_list().
539 	 *
540 	 * Return: %NULL if @error is set. Otherwise a #GVariant tuple with
541 	 *     return values. Free with g_variant_unref().
542 	 *
543 	 * Since: 2.30
544 	 *
545 	 * Throws: GException on failure.
546 	 */
547 	public Variant callWithUnixFdListFinish(out UnixFDList outFdList, AsyncResultIF res)
548 	{
549 		GUnixFDList* outoutFdList = null;
550 		GError* err = null;
551 		
552 		auto p = g_dbus_proxy_call_with_unix_fd_list_finish(gDBusProxy, &outoutFdList, (res is null) ? null : res.getAsyncResultStruct(), &err);
553 		
554 		if (err !is null)
555 		{
556 			throw new GException( new ErrorG(err) );
557 		}
558 		
559 		outFdList = ObjectG.getDObject!(UnixFDList)(outoutFdList);
560 		
561 		if(p is null)
562 		{
563 			return null;
564 		}
565 		
566 		return new Variant(cast(GVariant*) p, true);
567 	}
568 
569 	/**
570 	 * Like g_dbus_proxy_call_sync() but also takes and returns #GUnixFDList objects.
571 	 *
572 	 * This method is only available on UNIX.
573 	 *
574 	 * Params:
575 	 *     methodName = Name of method to invoke.
576 	 *     parameters = A #GVariant tuple with parameters for the signal
577 	 *         or %NULL if not passing parameters.
578 	 *     flags = Flags from the #GDBusCallFlags enumeration.
579 	 *     timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning
580 	 *         "infinite") or -1 to use the proxy default timeout.
581 	 *     fdList = A #GUnixFDList or %NULL.
582 	 *     outFdList = Return location for a #GUnixFDList or %NULL.
583 	 *     cancellable = A #GCancellable or %NULL.
584 	 *
585 	 * Return: %NULL if @error is set. Otherwise a #GVariant tuple with
586 	 *     return values. Free with g_variant_unref().
587 	 *
588 	 * Since: 2.30
589 	 *
590 	 * Throws: GException on failure.
591 	 */
592 	public Variant callWithUnixFdListSync(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, UnixFDList fdList, out UnixFDList outFdList, Cancellable cancellable)
593 	{
594 		GUnixFDList* outoutFdList = null;
595 		GError* err = null;
596 		
597 		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);
598 		
599 		if (err !is null)
600 		{
601 			throw new GException( new ErrorG(err) );
602 		}
603 		
604 		outFdList = ObjectG.getDObject!(UnixFDList)(outoutFdList);
605 		
606 		if(p is null)
607 		{
608 			return null;
609 		}
610 		
611 		return new Variant(cast(GVariant*) p, true);
612 	}
613 
614 	/**
615 	 * Looks up the value for a property from the cache. This call does no
616 	 * blocking IO.
617 	 *
618 	 * If @proxy has an expected interface (see
619 	 * #GDBusProxy:g-interface-info) and @property_name is referenced by
620 	 * it, then @value is checked against the type of the property.
621 	 *
622 	 * Params:
623 	 *     propertyName = Property name.
624 	 *
625 	 * Return: A reference to the #GVariant instance that holds the value
626 	 *     for @property_name or %NULL if the value is not in the cache. The
627 	 *     returned reference must be freed with g_variant_unref().
628 	 *
629 	 * Since: 2.26
630 	 */
631 	public Variant getCachedProperty(string propertyName)
632 	{
633 		auto p = g_dbus_proxy_get_cached_property(gDBusProxy, Str.toStringz(propertyName));
634 		
635 		if(p is null)
636 		{
637 			return null;
638 		}
639 		
640 		return new Variant(cast(GVariant*) p, true);
641 	}
642 
643 	/**
644 	 * Gets the names of all cached properties on @proxy.
645 	 *
646 	 * Return: A %NULL-terminated array of strings or %NULL if
647 	 *     @proxy has no cached properties. Free the returned array with
648 	 *     g_strfreev().
649 	 *
650 	 * Since: 2.26
651 	 */
652 	public string[] getCachedPropertyNames()
653 	{
654 		auto retStr = g_dbus_proxy_get_cached_property_names(gDBusProxy);
655 		
656 		scope(exit) Str.freeStringArray(retStr);
657 		return Str.toStringArray(retStr);
658 	}
659 
660 	/**
661 	 * Gets the connection @proxy is for.
662 	 *
663 	 * Return: A #GDBusConnection owned by @proxy. Do not free.
664 	 *
665 	 * Since: 2.26
666 	 */
667 	public DBusConnection getConnection()
668 	{
669 		auto p = g_dbus_proxy_get_connection(gDBusProxy);
670 		
671 		if(p is null)
672 		{
673 			return null;
674 		}
675 		
676 		return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p);
677 	}
678 
679 	/**
680 	 * Gets the timeout to use if -1 (specifying default timeout) is
681 	 * passed as @timeout_msec in the g_dbus_proxy_call() and
682 	 * g_dbus_proxy_call_sync() functions.
683 	 *
684 	 * See the #GDBusProxy:g-default-timeout property for more details.
685 	 *
686 	 * Return: Timeout to use for @proxy.
687 	 *
688 	 * Since: 2.26
689 	 */
690 	public int getDefaultTimeout()
691 	{
692 		return g_dbus_proxy_get_default_timeout(gDBusProxy);
693 	}
694 
695 	/**
696 	 * Gets the flags that @proxy was constructed with.
697 	 *
698 	 * Return: Flags from the #GDBusProxyFlags enumeration.
699 	 *
700 	 * Since: 2.26
701 	 */
702 	public GDBusProxyFlags getFlags()
703 	{
704 		return g_dbus_proxy_get_flags(gDBusProxy);
705 	}
706 
707 	/**
708 	 * Returns the #GDBusInterfaceInfo, if any, specifying the interface
709 	 * that @proxy conforms to. See the #GDBusProxy:g-interface-info
710 	 * property for more details.
711 	 *
712 	 * Return: A #GDBusInterfaceInfo or %NULL. Do not unref the returned
713 	 *     object, it is owned by @proxy.
714 	 *
715 	 * Since: 2.26
716 	 */
717 	public DBusInterfaceInfo getInterfaceInfo()
718 	{
719 		auto p = g_dbus_proxy_get_interface_info(gDBusProxy);
720 		
721 		if(p is null)
722 		{
723 			return null;
724 		}
725 		
726 		return ObjectG.getDObject!(DBusInterfaceInfo)(cast(GDBusInterfaceInfo*) p, true);
727 	}
728 
729 	/**
730 	 * Gets the D-Bus interface name @proxy is for.
731 	 *
732 	 * Return: A string owned by @proxy. Do not free.
733 	 *
734 	 * Since: 2.26
735 	 */
736 	public string getInterfaceName()
737 	{
738 		return Str.toString(g_dbus_proxy_get_interface_name(gDBusProxy));
739 	}
740 
741 	/**
742 	 * Gets the name that @proxy was constructed for.
743 	 *
744 	 * Return: A string owned by @proxy. Do not free.
745 	 *
746 	 * Since: 2.26
747 	 */
748 	public string getName()
749 	{
750 		return Str.toString(g_dbus_proxy_get_name(gDBusProxy));
751 	}
752 
753 	/**
754 	 * The unique name that owns the name that @proxy is for or %NULL if
755 	 * no-one currently owns that name. You may connect to the
756 	 * #GObject::notify signal to track changes to the
757 	 * #GDBusProxy:g-name-owner property.
758 	 *
759 	 * Return: The name owner or %NULL if no name owner exists. Free with g_free().
760 	 *
761 	 * Since: 2.26
762 	 */
763 	public string getNameOwner()
764 	{
765 		auto retStr = g_dbus_proxy_get_name_owner(gDBusProxy);
766 		
767 		scope(exit) Str.freeString(retStr);
768 		return Str.toString(retStr);
769 	}
770 
771 	/**
772 	 * Gets the object path @proxy is for.
773 	 *
774 	 * Return: A string owned by @proxy. Do not free.
775 	 *
776 	 * Since: 2.26
777 	 */
778 	public string getObjectPath()
779 	{
780 		return Str.toString(g_dbus_proxy_get_object_path(gDBusProxy));
781 	}
782 
783 	/**
784 	 * If @value is not %NULL, sets the cached value for the property with
785 	 * name @property_name to the value in @value.
786 	 *
787 	 * If @value is %NULL, then the cached value is removed from the
788 	 * property cache.
789 	 *
790 	 * If @proxy has an expected interface (see
791 	 * #GDBusProxy:g-interface-info) and @property_name is referenced by
792 	 * it, then @value is checked against the type of the property.
793 	 *
794 	 * If the @value #GVariant is floating, it is consumed. This allows
795 	 * convenient 'inline' use of g_variant_new(), e.g.
796 	 * |[<!-- language="C" -->
797 	 * g_dbus_proxy_set_cached_property (proxy,
798 	 * "SomeProperty",
799 	 * g_variant_new ("(si)",
800 	 * "A String",
801 	 * 42));
802 	 * ]|
803 	 *
804 	 * Normally you will not need to use this method since @proxy
805 	 * is tracking changes using the
806 	 * `org.freedesktop.DBus.Properties.PropertiesChanged`
807 	 * D-Bus signal. However, for performance reasons an object may
808 	 * decide to not use this signal for some properties and instead
809 	 * use a proprietary out-of-band mechanism to transmit changes.
810 	 *
811 	 * As a concrete example, consider an object with a property
812 	 * `ChatroomParticipants` which is an array of strings. Instead of
813 	 * transmitting the same (long) array every time the property changes,
814 	 * it is more efficient to only transmit the delta using e.g. signals
815 	 * `ChatroomParticipantJoined(String name)` and
816 	 * `ChatroomParticipantParted(String name)`.
817 	 *
818 	 * Params:
819 	 *     propertyName = Property name.
820 	 *     value = Value for the property or %NULL to remove it from the cache.
821 	 *
822 	 * Since: 2.26
823 	 */
824 	public void setCachedProperty(string propertyName, Variant value)
825 	{
826 		g_dbus_proxy_set_cached_property(gDBusProxy, Str.toStringz(propertyName), (value is null) ? null : value.getVariantStruct());
827 	}
828 
829 	/**
830 	 * Sets the timeout to use if -1 (specifying default timeout) is
831 	 * passed as @timeout_msec in the g_dbus_proxy_call() and
832 	 * g_dbus_proxy_call_sync() functions.
833 	 *
834 	 * See the #GDBusProxy:g-default-timeout property for more details.
835 	 *
836 	 * Params:
837 	 *     timeoutMsec = Timeout in milliseconds.
838 	 *
839 	 * Since: 2.26
840 	 */
841 	public void setDefaultTimeout(int timeoutMsec)
842 	{
843 		g_dbus_proxy_set_default_timeout(gDBusProxy, timeoutMsec);
844 	}
845 
846 	/**
847 	 * Ensure that interactions with @proxy conform to the given
848 	 * interface. See the #GDBusProxy:g-interface-info property for more
849 	 * details.
850 	 *
851 	 * Params:
852 	 *     info = Minimum interface this proxy conforms to or %NULL to unset.
853 	 *
854 	 * Since: 2.26
855 	 */
856 	public void setInterfaceInfo(DBusInterfaceInfo info)
857 	{
858 		g_dbus_proxy_set_interface_info(gDBusProxy, (info is null) ? null : info.getDBusInterfaceInfoStruct());
859 	}
860 
861 	protected class OnGPropertiesChangedDelegateWrapper
862 	{
863 		void delegate(Variant, string[], DBusProxy) dlg;
864 		gulong handlerId;
865 		ConnectFlags flags;
866 		this(void delegate(Variant, string[], DBusProxy) dlg, gulong handlerId, ConnectFlags flags)
867 		{
868 			this.dlg = dlg;
869 			this.handlerId = handlerId;
870 			this.flags = flags;
871 		}
872 	}
873 	protected OnGPropertiesChangedDelegateWrapper[] onGPropertiesChangedListeners;
874 
875 	/**
876 	 * Emitted when one or more D-Bus properties on @proxy changes. The
877 	 * local cache has already been updated when this signal fires. Note
878 	 * that both @changed_properties and @invalidated_properties are
879 	 * guaranteed to never be %NULL (either may be empty though).
880 	 *
881 	 * If the proxy has the flag
882 	 * %G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES set, then
883 	 * @invalidated_properties will always be empty.
884 	 *
885 	 * This signal corresponds to the
886 	 * `PropertiesChanged` D-Bus signal on the
887 	 * `org.freedesktop.DBus.Properties` interface.
888 	 *
889 	 * Params:
890 	 *     changedProperties = A #GVariant containing the properties that changed
891 	 *     invalidatedProperties = A %NULL terminated array of properties that was invalidated
892 	 *
893 	 * Since: 2.26
894 	 */
895 	gulong addOnGPropertiesChanged(void delegate(Variant, string[], DBusProxy) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
896 	{
897 		onGPropertiesChangedListeners ~= new OnGPropertiesChangedDelegateWrapper(dlg, 0, connectFlags);
898 		onGPropertiesChangedListeners[onGPropertiesChangedListeners.length - 1].handlerId = Signals.connectData(
899 			this,
900 			"g-properties-changed",
901 			cast(GCallback)&callBackGPropertiesChanged,
902 			cast(void*)onGPropertiesChangedListeners[onGPropertiesChangedListeners.length - 1],
903 			cast(GClosureNotify)&callBackGPropertiesChangedDestroy,
904 			connectFlags);
905 		return onGPropertiesChangedListeners[onGPropertiesChangedListeners.length - 1].handlerId;
906 	}
907 	
908 	extern(C) static void callBackGPropertiesChanged(GDBusProxy* dbusproxyStruct, GVariant* changedProperties, char** invalidatedProperties,OnGPropertiesChangedDelegateWrapper wrapper)
909 	{
910 		wrapper.dlg(new Variant(changedProperties), Str.toStringArray(invalidatedProperties), wrapper.outer);
911 	}
912 	
913 	extern(C) static void callBackGPropertiesChangedDestroy(OnGPropertiesChangedDelegateWrapper wrapper, GClosure* closure)
914 	{
915 		wrapper.outer.internalRemoveOnGPropertiesChanged(wrapper);
916 	}
917 
918 	protected void internalRemoveOnGPropertiesChanged(OnGPropertiesChangedDelegateWrapper source)
919 	{
920 		foreach(index, wrapper; onGPropertiesChangedListeners)
921 		{
922 			if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId)
923 			{
924 				onGPropertiesChangedListeners[index] = null;
925 				onGPropertiesChangedListeners = std.algorithm.remove(onGPropertiesChangedListeners, index);
926 				break;
927 			}
928 		}
929 	}
930 	
931 
932 	protected class OnGSignalDelegateWrapper
933 	{
934 		void delegate(string, string, Variant, DBusProxy) dlg;
935 		gulong handlerId;
936 		ConnectFlags flags;
937 		this(void delegate(string, string, Variant, DBusProxy) dlg, gulong handlerId, ConnectFlags flags)
938 		{
939 			this.dlg = dlg;
940 			this.handlerId = handlerId;
941 			this.flags = flags;
942 		}
943 	}
944 	protected OnGSignalDelegateWrapper[] onGSignalListeners;
945 
946 	/**
947 	 * Emitted when a signal from the remote object and interface that @proxy is for, has been received.
948 	 *
949 	 * Params:
950 	 *     senderName = The sender of the signal or %NULL if the connection is not a bus connection.
951 	 *     signalName = The name of the signal.
952 	 *     parameters = A #GVariant tuple with parameters for the signal.
953 	 *
954 	 * Since: 2.26
955 	 */
956 	gulong addOnGSignal(void delegate(string, string, Variant, DBusProxy) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
957 	{
958 		onGSignalListeners ~= new OnGSignalDelegateWrapper(dlg, 0, connectFlags);
959 		onGSignalListeners[onGSignalListeners.length - 1].handlerId = Signals.connectData(
960 			this,
961 			"g-signal",
962 			cast(GCallback)&callBackGSignal,
963 			cast(void*)onGSignalListeners[onGSignalListeners.length - 1],
964 			cast(GClosureNotify)&callBackGSignalDestroy,
965 			connectFlags);
966 		return onGSignalListeners[onGSignalListeners.length - 1].handlerId;
967 	}
968 	
969 	extern(C) static void callBackGSignal(GDBusProxy* dbusproxyStruct, char* senderName, char* signalName, GVariant* parameters,OnGSignalDelegateWrapper wrapper)
970 	{
971 		wrapper.dlg(Str.toString(senderName), Str.toString(signalName), new Variant(parameters), wrapper.outer);
972 	}
973 	
974 	extern(C) static void callBackGSignalDestroy(OnGSignalDelegateWrapper wrapper, GClosure* closure)
975 	{
976 		wrapper.outer.internalRemoveOnGSignal(wrapper);
977 	}
978 
979 	protected void internalRemoveOnGSignal(OnGSignalDelegateWrapper source)
980 	{
981 		foreach(index, wrapper; onGSignalListeners)
982 		{
983 			if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId)
984 			{
985 				onGSignalListeners[index] = null;
986 				onGSignalListeners = std.algorithm.remove(onGSignalListeners, index);
987 				break;
988 			}
989 		}
990 	}
991 	
992 }