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.DBusMethodInvocation;
26 
27 private import gio.DBusConnection;
28 private import gio.DBusMessage;
29 private import gio.DBusMethodInfo;
30 private import gio.DBusPropertyInfo;
31 private import gio.UnixFDList;
32 private import glib.ErrorG;
33 private import glib.Str;
34 private import glib.Variant;
35 private import gobject.ObjectG;
36 private import gtkc.gio;
37 public  import gtkc.giotypes;
38 
39 
40 /**
41  * Instances of the #GDBusMethodInvocation class are used when
42  * handling D-Bus method calls. It provides a way to asynchronously
43  * return results and errors.
44  * 
45  * The normal way to obtain a #GDBusMethodInvocation object is to receive
46  * it as an argument to the handle_method_call() function in a
47  * #GDBusInterfaceVTable that was passed to g_dbus_connection_register_object().
48  *
49  * Since: 2.26
50  */
51 public class DBusMethodInvocation : ObjectG
52 {
53 	/** the main Gtk struct */
54 	protected GDBusMethodInvocation* gDBusMethodInvocation;
55 
56 	/** Get the main Gtk struct */
57 	public GDBusMethodInvocation* getDBusMethodInvocationStruct()
58 	{
59 		return gDBusMethodInvocation;
60 	}
61 
62 	/** the main Gtk struct as a void* */
63 	protected override void* getStruct()
64 	{
65 		return cast(void*)gDBusMethodInvocation;
66 	}
67 
68 	protected override void setStruct(GObject* obj)
69 	{
70 		gDBusMethodInvocation = cast(GDBusMethodInvocation*)obj;
71 		super.setStruct(obj);
72 	}
73 
74 	/**
75 	 * Sets our main struct and passes it to the parent class.
76 	 */
77 	public this (GDBusMethodInvocation* gDBusMethodInvocation, bool ownedRef = false)
78 	{
79 		this.gDBusMethodInvocation = gDBusMethodInvocation;
80 		super(cast(GObject*)gDBusMethodInvocation, ownedRef);
81 	}
82 
83 
84 	/** */
85 	public static GType getType()
86 	{
87 		return g_dbus_method_invocation_get_type();
88 	}
89 
90 	/**
91 	 * Gets the #GDBusConnection the method was invoked on.
92 	 *
93 	 * Return: A #GDBusConnection. Do not free, it is owned by @invocation.
94 	 *
95 	 * Since: 2.26
96 	 */
97 	public DBusConnection getConnection()
98 	{
99 		auto p = g_dbus_method_invocation_get_connection(gDBusMethodInvocation);
100 		
101 		if(p is null)
102 		{
103 			return null;
104 		}
105 		
106 		return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p);
107 	}
108 
109 	/**
110 	 * Gets the name of the D-Bus interface the method was invoked on.
111 	 *
112 	 * If this method call is a property Get, Set or GetAll call that has
113 	 * been redirected to the method call handler then
114 	 * "org.freedesktop.DBus.Properties" will be returned.  See
115 	 * #GDBusInterfaceVTable for more information.
116 	 *
117 	 * Return: A string. Do not free, it is owned by @invocation.
118 	 *
119 	 * Since: 2.26
120 	 */
121 	public string getInterfaceName()
122 	{
123 		return Str.toString(g_dbus_method_invocation_get_interface_name(gDBusMethodInvocation));
124 	}
125 
126 	/**
127 	 * Gets the #GDBusMessage for the method invocation. This is useful if
128 	 * you need to use low-level protocol features, such as UNIX file
129 	 * descriptor passing, that cannot be properly expressed in the
130 	 * #GVariant API.
131 	 *
132 	 * See this [server][gdbus-server] and [client][gdbus-unix-fd-client]
133 	 * for an example of how to use this low-level API to send and receive
134 	 * UNIX file descriptors.
135 	 *
136 	 * Return: #GDBusMessage. Do not free, it is owned by @invocation.
137 	 *
138 	 * Since: 2.26
139 	 */
140 	public DBusMessage getMessage()
141 	{
142 		auto p = g_dbus_method_invocation_get_message(gDBusMethodInvocation);
143 		
144 		if(p is null)
145 		{
146 			return null;
147 		}
148 		
149 		return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p);
150 	}
151 
152 	/**
153 	 * Gets information about the method call, if any.
154 	 *
155 	 * If this method invocation is a property Get, Set or GetAll call that
156 	 * has been redirected to the method call handler then %NULL will be
157 	 * returned.  See g_dbus_method_invocation_get_property_info() and
158 	 * #GDBusInterfaceVTable for more information.
159 	 *
160 	 * Return: A #GDBusMethodInfo or %NULL. Do not free, it is owned by @invocation.
161 	 *
162 	 * Since: 2.26
163 	 */
164 	public DBusMethodInfo getMethodInfo()
165 	{
166 		auto p = g_dbus_method_invocation_get_method_info(gDBusMethodInvocation);
167 		
168 		if(p is null)
169 		{
170 			return null;
171 		}
172 		
173 		return ObjectG.getDObject!(DBusMethodInfo)(cast(GDBusMethodInfo*) p);
174 	}
175 
176 	/**
177 	 * Gets the name of the method that was invoked.
178 	 *
179 	 * Return: A string. Do not free, it is owned by @invocation.
180 	 *
181 	 * Since: 2.26
182 	 */
183 	public string getMethodName()
184 	{
185 		return Str.toString(g_dbus_method_invocation_get_method_name(gDBusMethodInvocation));
186 	}
187 
188 	/**
189 	 * Gets the object path the method was invoked on.
190 	 *
191 	 * Return: A string. Do not free, it is owned by @invocation.
192 	 *
193 	 * Since: 2.26
194 	 */
195 	public string getObjectPath()
196 	{
197 		return Str.toString(g_dbus_method_invocation_get_object_path(gDBusMethodInvocation));
198 	}
199 
200 	/**
201 	 * Gets the parameters of the method invocation. If there are no input
202 	 * parameters then this will return a GVariant with 0 children rather than NULL.
203 	 *
204 	 * Return: A #GVariant tuple. Do not unref this because it is owned by @invocation.
205 	 *
206 	 * Since: 2.26
207 	 */
208 	public Variant getParameters()
209 	{
210 		auto p = g_dbus_method_invocation_get_parameters(gDBusMethodInvocation);
211 		
212 		if(p is null)
213 		{
214 			return null;
215 		}
216 		
217 		return new Variant(cast(GVariant*) p);
218 	}
219 
220 	/**
221 	 * Gets information about the property that this method call is for, if
222 	 * any.
223 	 *
224 	 * This will only be set in the case of an invocation in response to a
225 	 * property Get or Set call that has been directed to the method call
226 	 * handler for an object on account of its property_get() or
227 	 * property_set() vtable pointers being unset.
228 	 *
229 	 * See #GDBusInterfaceVTable for more information.
230 	 *
231 	 * If the call was GetAll, %NULL will be returned.
232 	 *
233 	 * Return: a #GDBusPropertyInfo or %NULL
234 	 *
235 	 * Since: 2.38
236 	 */
237 	public DBusPropertyInfo getPropertyInfo()
238 	{
239 		auto p = g_dbus_method_invocation_get_property_info(gDBusMethodInvocation);
240 		
241 		if(p is null)
242 		{
243 			return null;
244 		}
245 		
246 		return ObjectG.getDObject!(DBusPropertyInfo)(cast(GDBusPropertyInfo*) p);
247 	}
248 
249 	/**
250 	 * Gets the bus name that invoked the method.
251 	 *
252 	 * Return: A string. Do not free, it is owned by @invocation.
253 	 *
254 	 * Since: 2.26
255 	 */
256 	public string getSender()
257 	{
258 		return Str.toString(g_dbus_method_invocation_get_sender(gDBusMethodInvocation));
259 	}
260 
261 	/**
262 	 * Gets the @user_data #gpointer passed to g_dbus_connection_register_object().
263 	 *
264 	 * Return: A #gpointer.
265 	 *
266 	 * Since: 2.26
267 	 */
268 	public void* getUserData()
269 	{
270 		return g_dbus_method_invocation_get_user_data(gDBusMethodInvocation);
271 	}
272 
273 	/**
274 	 * Finishes handling a D-Bus method call by returning an error.
275 	 *
276 	 * This method will free @invocation, you cannot use it afterwards.
277 	 *
278 	 * Params:
279 	 *     errorName = A valid D-Bus error name.
280 	 *     errorMessage = A valid D-Bus error message.
281 	 *
282 	 * Since: 2.26
283 	 */
284 	public void returnDbusError(string errorName, string errorMessage)
285 	{
286 		g_dbus_method_invocation_return_dbus_error(gDBusMethodInvocation, Str.toStringz(errorName), Str.toStringz(errorMessage));
287 	}
288 
289 	/**
290 	 * Like g_dbus_method_invocation_return_error() but without printf()-style formatting.
291 	 *
292 	 * This method will free @invocation, you cannot use it afterwards.
293 	 *
294 	 * Params:
295 	 *     domain = A #GQuark for the #GError error domain.
296 	 *     code = The error code.
297 	 *     message = The error message.
298 	 *
299 	 * Since: 2.26
300 	 */
301 	public void returnErrorLiteral(GQuark domain, int code, string message)
302 	{
303 		g_dbus_method_invocation_return_error_literal(gDBusMethodInvocation, domain, code, Str.toStringz(message));
304 	}
305 
306 	/**
307 	 * Like g_dbus_method_invocation_return_error() but intended for
308 	 * language bindings.
309 	 *
310 	 * This method will free @invocation, you cannot use it afterwards.
311 	 *
312 	 * Params:
313 	 *     domain = A #GQuark for the #GError error domain.
314 	 *     code = The error code.
315 	 *     format = printf()-style format.
316 	 *     varArgs = #va_list of parameters for @format.
317 	 *
318 	 * Since: 2.26
319 	 */
320 	public void returnErrorValist(GQuark domain, int code, string format, void* varArgs)
321 	{
322 		g_dbus_method_invocation_return_error_valist(gDBusMethodInvocation, domain, code, Str.toStringz(format), varArgs);
323 	}
324 
325 	/**
326 	 * Like g_dbus_method_invocation_return_error() but takes a #GError
327 	 * instead of the error domain, error code and message.
328 	 *
329 	 * This method will free @invocation, you cannot use it afterwards.
330 	 *
331 	 * Params:
332 	 *     error = A #GError.
333 	 *
334 	 * Since: 2.26
335 	 */
336 	public void returnGerror(ErrorG error)
337 	{
338 		g_dbus_method_invocation_return_gerror(gDBusMethodInvocation, (error is null) ? null : error.getErrorGStruct());
339 	}
340 
341 	/**
342 	 * Finishes handling a D-Bus method call by returning @parameters.
343 	 * If the @parameters GVariant is floating, it is consumed.
344 	 *
345 	 * It is an error if @parameters is not of the right format.
346 	 *
347 	 * This method will free @invocation, you cannot use it afterwards.
348 	 *
349 	 * Since 2.48, if the method call requested for a reply not to be sent
350 	 * then this call will sink @parameters and free @invocation, but
351 	 * otherwise do nothing (as per the recommendations of the D-Bus
352 	 * specification).
353 	 *
354 	 * Params:
355 	 *     parameters = A #GVariant tuple with out parameters for the method or %NULL if not passing any parameters.
356 	 *
357 	 * Since: 2.26
358 	 */
359 	public void returnValue(Variant parameters)
360 	{
361 		g_dbus_method_invocation_return_value(gDBusMethodInvocation, (parameters is null) ? null : parameters.getVariantStruct());
362 	}
363 
364 	/**
365 	 * Like g_dbus_method_invocation_return_value() but also takes a #GUnixFDList.
366 	 *
367 	 * This method is only available on UNIX.
368 	 *
369 	 * This method will free @invocation, you cannot use it afterwards.
370 	 *
371 	 * Params:
372 	 *     parameters = A #GVariant tuple with out parameters for the method or %NULL if not passing any parameters.
373 	 *     fdList = A #GUnixFDList or %NULL.
374 	 *
375 	 * Since: 2.30
376 	 */
377 	public void returnValueWithUnixFdList(Variant parameters, UnixFDList fdList)
378 	{
379 		g_dbus_method_invocation_return_value_with_unix_fd_list(gDBusMethodInvocation, (parameters is null) ? null : parameters.getVariantStruct(), (fdList is null) ? null : fdList.getUnixFDListStruct());
380 	}
381 
382 	/**
383 	 * Like g_dbus_method_invocation_return_gerror() but takes ownership
384 	 * of @error so the caller does not need to free it.
385 	 *
386 	 * This method will free @invocation, you cannot use it afterwards.
387 	 *
388 	 * Params:
389 	 *     error = A #GError.
390 	 *
391 	 * Since: 2.30
392 	 */
393 	public void takeError(ErrorG error)
394 	{
395 		g_dbus_method_invocation_take_error(gDBusMethodInvocation, (error is null) ? null : error.getErrorGStruct());
396 	}
397 }