root/trunk/src/gio/DBusMethodInvocation.d

Revision 951, 10.4 kB (checked in by Mike Wey, 2 weeks ago)

Merge github pull request 7.

Line 
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  = GDBusMethodInvocation.html
27  * outPack = gio
28  * outFile = DBusMethodInvocation
29  * strct   = GDBusMethodInvocation
30  * realStrct=
31  * ctorStrct=
32  * clss    = DBusMethodInvocation
33  * interf  =
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  =
38  * implements:
39  * prefixes:
40  *  - g_dbus_method_invocation_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  *  - glib.Str
47  *  - glib.ErrorG
48  *  - glib.Variant
49  *  - gio.DBusConnection
50  *  - gio.DBusMessage
51  * structWrap:
52  *  - GDBusConnection* -> DBusConnection
53  *  - GDBusMessage* -> DBusMessage
54  *  - GError* -> ErrorG
55  *  - GVariant* -> Variant
56  * module aliases:
57  * local aliases:
58  * overrides:
59  */
60
61 module gio.DBusMethodInvocation;
62
63 public  import gtkc.giotypes;
64
65 private import gtkc.gio;
66 private import glib.ConstructionException;
67
68
69 private import glib.Str;
70 private import glib.ErrorG;
71 private import glib.Variant;
72 private import gio.DBusConnection;
73 private import gio.DBusMessage;
74
75
76
77 private import gobject.ObjectG;
78
79 /**
80  * Description
81  * Instances of the GDBusMethodInvocation class are used when
82  * handling D-Bus method calls. It provides a way to asynchronously
83  * return results and errors.
84  * The normal way to obtain a GDBusMethodInvocation object is to receive
85  * it as an argument to the handle_method_call() function in a
86  * GDBusInterfaceVTable that was passed to g_dbus_connection_register_object().
87  */
88 public class DBusMethodInvocation : ObjectG
89 {
90    
91     /** the main Gtk struct */
92     protected GDBusMethodInvocation* gDBusMethodInvocation;
93    
94    
95     public GDBusMethodInvocation* getDBusMethodInvocationStruct()
96     {
97         return gDBusMethodInvocation;
98     }
99    
100    
101     /** the main Gtk struct as a void* */
102     protected override void* getStruct()
103     {
104         return cast(void*)gDBusMethodInvocation;
105     }
106    
107     /**
108      * Sets our main struct and passes it to the parent class
109      */
110     public this (GDBusMethodInvocation* gDBusMethodInvocation)
111     {
112         if(gDBusMethodInvocation is null)
113         {
114             this = null;
115             return;
116         }
117         //Check if there already is a D object for this gtk struct
118         void* ptr = getDObject(cast(GObject*)gDBusMethodInvocation);
119         if( ptr !is null )
120         {
121             this = cast(DBusMethodInvocation)ptr;
122             return;
123         }
124         super(cast(GObject*)gDBusMethodInvocation);
125         this.gDBusMethodInvocation = gDBusMethodInvocation;
126     }
127    
128     protected override void setStruct(GObject* obj)
129     {
130         super.setStruct(obj);
131         gDBusMethodInvocation = cast(GDBusMethodInvocation*)obj;
132     }
133    
134     /**
135      */
136    
137     /**
138      * Gets the bus name that invoked the method.
139      * Since 2.26
140      * Returns: A string. Do not free, it is owned by invocation.
141      */
142     public string getSender()
143     {
144         // const gchar * g_dbus_method_invocation_get_sender (GDBusMethodInvocation *invocation);
145         return Str.toString(g_dbus_method_invocation_get_sender(gDBusMethodInvocation));
146     }
147    
148     /**
149      * Gets the object path the method was invoked on.
150      * Since 2.26
151      * Returns: A string. Do not free, it is owned by invocation.
152      */
153     public string getObjectPath()
154     {
155         // const gchar * g_dbus_method_invocation_get_object_path  (GDBusMethodInvocation *invocation);
156         return Str.toString(g_dbus_method_invocation_get_object_path(gDBusMethodInvocation));
157     }
158    
159     /**
160      * Gets the name of the D-Bus interface the method was invoked on.
161      * Since 2.26
162      * Returns: A string. Do not free, it is owned by invocation.
163      */
164     public string getInterfaceName()
165     {
166         // const gchar * g_dbus_method_invocation_get_interface_name  (GDBusMethodInvocation *invocation);
167         return Str.toString(g_dbus_method_invocation_get_interface_name(gDBusMethodInvocation));
168     }
169    
170     /**
171      * Gets the name of the method that was invoked.
172      * Since 2.26
173      * Returns: A string. Do not free, it is owned by invocation.
174      */
175     public string getMethodName()
176     {
177         // const gchar * g_dbus_method_invocation_get_method_name  (GDBusMethodInvocation *invocation);
178         return Str.toString(g_dbus_method_invocation_get_method_name(gDBusMethodInvocation));
179     }
180    
181     /**
182      * Gets information about the method call, if any.
183      * Since 2.26
184      * Returns: A GDBusMethodInfo or NULL. Do not free, it is owned by invocation.
185      */
186     public GDBusMethodInfo* getMethodInfo()
187     {
188         // const GDBusMethodInfo * g_dbus_method_invocation_get_method_info  (GDBusMethodInvocation *invocation);
189         return g_dbus_method_invocation_get_method_info(gDBusMethodInvocation);
190     }
191    
192     /**
193      * Gets the GDBusConnection the method was invoked on.
194      * Since 2.26
195      * Returns: A GDBusConnection. Do not free, it is owned by invocation. [transfer none]
196      */
197     public DBusConnection getConnection()
198     {
199         // GDBusConnection * g_dbus_method_invocation_get_connection  (GDBusMethodInvocation *invocation);
200         auto p = g_dbus_method_invocation_get_connection(gDBusMethodInvocation);
201         if(p is null)
202         {
203             return null;
204         }
205         return new DBusConnection(cast(GDBusConnection*) p);
206     }
207    
208     /**
209      * Gets the GDBusMessage for the method invocation. This is useful if
210      * you need to use low-level protocol features, such as UNIX file
211      * descriptor passing, that cannot be properly expressed in the
212      * GVariant API.
213      * See Example 2, “D-Bus server example” and Example 4, “D-Bus UNIX File Descriptor example” for an example of how to use this
214      * low-level API to send and receive UNIX file descriptors.
215      * Since 2.26
216      * Returns: GDBusMessage. Do not free, it is owned by invocation. [transfer none]
217      */
218     public DBusMessage getMessage()
219     {
220         // GDBusMessage * g_dbus_method_invocation_get_message  (GDBusMethodInvocation *invocation);
221         auto p = g_dbus_method_invocation_get_message(gDBusMethodInvocation);
222         if(p is null)
223         {
224             return null;
225         }
226         return new DBusMessage(cast(GDBusMessage*) p);
227     }
228    
229     /**
230      * Gets the parameters of the method invocation. If there are no input
231      * parameters then this will return a GVariant with 0 children rather than NULL.
232      * Since 2.26
233      * Returns: A GVariant tuple. Do not unref this because it is owned by invocation. [transfer none]
234      */
235     public Variant getParameters()
236     {
237         // GVariant * g_dbus_method_invocation_get_parameters  (GDBusMethodInvocation *invocation);
238         auto p = g_dbus_method_invocation_get_parameters(gDBusMethodInvocation);
239         if(p is null)
240         {
241             return null;
242         }
243         return new Variant(cast(GVariant*) p);
244     }
245    
246     /**
247      * Gets the user_data gpointer passed to g_dbus_connection_register_object().
248      * Since 2.26
249      * Returns: A gpointer.
250      */
251     public void* getUserData()
252     {
253         // gpointer g_dbus_method_invocation_get_user_data  (GDBusMethodInvocation *invocation);
254         return g_dbus_method_invocation_get_user_data(gDBusMethodInvocation);
255     }
256    
257     /**
258      * Finishes handling a D-Bus method call by returning parameters.
259      * If the parameters GVariant is floating, it is consumed.
260      * It is an error if parameters is not of the right format.
261      * This method will free invocation, you cannot use it afterwards.
262      * Since 2.26
263      * Params:
264      * parameters = A GVariant tuple with out parameters for the method or NULL if not passing any parameters.
265      */
266     public void returnValue(Variant parameters)
267     {
268         // void g_dbus_method_invocation_return_value  (GDBusMethodInvocation *invocation,  GVariant *parameters);
269         g_dbus_method_invocation_return_value(gDBusMethodInvocation, (parameters is null) ? null : parameters.getVariantStruct());
270     }
271    
272     /**
273      * Like g_dbus_method_invocation_return_error() but intended for
274      * language bindings.
275      * This method will free invocation, you cannot use it afterwards.
276      * Since 2.26
277      * Params:
278      * domain = A GQuark for the GError error domain.
279      * code = The error code.
280      * format = printf()-style format.
281      * varArgs = va_list of parameters for format.
282      */
283     public void returnErrorValist(GQuark domain, int code, string format, void* varArgs)
284     {
285         // void g_dbus_method_invocation_return_error_valist  (GDBusMethodInvocation *invocation,  GQuark domain,  gint code,  const gchar *format,  va_list var_args);
286         g_dbus_method_invocation_return_error_valist(gDBusMethodInvocation, domain, code, Str.toStringz(format), varArgs);
287     }
288    
289     /**
290      * Like g_dbus_method_invocation_return_error() but without printf()-style formatting.
291      * This method will free invocation, you cannot use it afterwards.
292      * Since 2.26
293      * Params:
294      * domain = A GQuark for the GError error domain.
295      * code = The error code.
296      * message = The error message.
297      */
298     public void returnErrorLiteral(GQuark domain, int code, string message)
299     {
300         // void g_dbus_method_invocation_return_error_literal  (GDBusMethodInvocation *invocation,  GQuark domain,  gint code,  const gchar *message);
301         g_dbus_method_invocation_return_error_literal(gDBusMethodInvocation, domain, code, Str.toStringz(message));
302     }
303    
304     /**
305      * Like g_dbus_method_invocation_return_error() but takes a GError
306      * instead of the error domain, error code and message.
307      * This method will free invocation, you cannot use it afterwards.
308      * Since 2.26
309      * Params:
310      * error = A GError.
311      */
312     public void returnGerror(ErrorG error)
313     {
314         // void g_dbus_method_invocation_return_gerror  (GDBusMethodInvocation *invocation,  const GError *error);
315         g_dbus_method_invocation_return_gerror(gDBusMethodInvocation, (error is null) ? null : error.getErrorGStruct());
316     }
317    
318     /**
319      * Finishes handling a D-Bus method call by returning an error.
320      * This method will free invocation, you cannot use it afterwards.
321      * Since 2.26
322      * Params:
323      * errorName = A valid D-Bus error name.
324      * errorMessage = A valid D-Bus error message.
325      */
326     public void returnDbusError(string errorName, string errorMessage)
327     {
328         // void g_dbus_method_invocation_return_dbus_error  (GDBusMethodInvocation *invocation,  const gchar *error_name,  const gchar *error_message);
329         g_dbus_method_invocation_return_dbus_error(gDBusMethodInvocation, Str.toStringz(errorName), Str.toStringz(errorMessage));
330     }
331 }
Note: See TracBrowser for help on using the browser.