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