root/trunk/src/gio/DBusUtilities.d

Revision 938, 20.3 kB (checked in by Mike Wey, 3 months ago)

Update Gio to 2.28.

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  = gio-D-Bus-Utilities.html
27  * outPack = gio
28  * outFile = DBusUtilities
29  * strct   =
30  * realStrct=
31  * ctorStrct=
32  * clss    = DBusUtilities
33  * interf  =
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  =
38  * implements:
39  * prefixes:
40  *  - g_dbus_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  *  - glib.Str
47  *  - glib.ErrorG
48  *  - glib.GException
49  *  - glib.StringG
50  *  - gio.AsyncResultIF
51  *  - gio.Cancellable
52  *  - gio.IOStream
53  * structWrap:
54  * module aliases:
55  * local aliases:
56  * overrides:
57  */
58
59 module gio.DBusUtilities;
60
61 public  import gtkc.giotypes;
62
63 private import gtkc.gio;
64 private import glib.ConstructionException;
65
66
67 private import glib.Str;
68 private import glib.ErrorG;
69 private import glib.GException;
70 private import glib.StringG;
71 private import gio.AsyncResultIF;
72 private import gio.Cancellable;
73 private import gio.IOStream;
74
75
76
77
78 /**
79  * Description
80  * Various utility routines related to D-Bus.
81  */
82 public class DBusUtilities
83 {
84    
85     /**
86      * Description
87      * Routines for working with D-Bus addresses. A D-Bus address is a string
88      * like "unix:tmpdir=/tmp/my-app-name". The exact format of addresses
89      * is explained in detail in the D-Bus specification.
90      */
91    
92     /**
93      * Description
94      * Various data structures and convenience routines to parse and
95      * generate D-Bus introspection XML. Introspection information is
96      * used when registering objects with g_dbus_connection_register_object().
97      * The format of D-Bus introspection XML is specified in the
98      * D-Bus specification.
99      */
100    
101     /**
102      * Generate a D-Bus GUID that can be used with
103      * e.g. g_dbus_connection_new().
104      * See the D-Bus specification regarding what strings are valid D-Bus
105      * GUID (for example, D-Bus GUIDs are not RFC-4122 compliant).
106      * Since 2.26
107      * Returns: A valid D-Bus GUID. Free with g_free().
108      */
109     public static string generateGuid()
110     {
111         // gchar * g_dbus_generate_guid (void);
112         return Str.toString(g_dbus_generate_guid());
113     }
114    
115     /**
116      * Checks if string is a D-Bus GUID.
117      * See the D-Bus specification regarding what strings are valid D-Bus
118      * GUID (for example, D-Bus GUIDs are not RFC-4122 compliant).
119      * Since 2.26
120      * Params:
121      * string = The string to check.
122      * Returns: TRUE if string is a guid, FALSE otherwise.
123      */
124     public static int isGuid(string string)
125     {
126         // gboolean g_dbus_is_guid (const gchar *string);
127         return g_dbus_is_guid(Str.toStringz(string));
128     }
129    
130     /**
131      * Checks if string is a valid D-Bus bus name (either unique or well-known).
132      * Since 2.26
133      * Params:
134      * string = The string to check.
135      * Returns: TRUE if valid, FALSE otherwise.
136      */
137     public static int isName(string string)
138     {
139         // gboolean g_dbus_is_name (const gchar *string);
140         return g_dbus_is_name(Str.toStringz(string));
141     }
142    
143     /**
144      * Checks if string is a valid D-Bus unique bus name.
145      * Since 2.26
146      * Params:
147      * string = The string to check.
148      * Returns: TRUE if valid, FALSE otherwise.
149      */
150     public static int isUniqueName(string string)
151     {
152         // gboolean g_dbus_is_unique_name (const gchar *string);
153         return g_dbus_is_unique_name(Str.toStringz(string));
154     }
155    
156     /**
157      * Checks if string is a valid D-Bus member (e.g. signal or method) name.
158      * Since 2.26
159      * Params:
160      * string = The string to check.
161      * Returns: TRUE if valid, FALSE otherwise.
162      */
163     public static int isMemberName(string string)
164     {
165         // gboolean g_dbus_is_member_name (const gchar *string);
166         return g_dbus_is_member_name(Str.toStringz(string));
167     }
168    
169     /**
170      * Checks if string is a valid D-Bus interface name.
171      * Since 2.26
172      * Params:
173      * string = The string to check.
174      * Returns: TRUE if valid, FALSE otherwise.
175      */
176     public static int isInterfaceName(string string)
177     {
178         // gboolean g_dbus_is_interface_name (const gchar *string);
179         return g_dbus_is_interface_name(Str.toStringz(string));
180     }
181    
182     /**
183      * Checks if string is a D-Bus address.
184      * This doesn't check if string is actually supported by GDBusServer
185      * or GDBusConnection - use g_dbus_is_supported_address() to do more
186      * checks.
187      * Since 2.26
188      * Params:
189      * string = A string.
190      * Returns: TRUE if string is a valid D-Bus address, FALSE otherwise.
191      */
192     public static int isAddress(string string)
193     {
194         // gboolean g_dbus_is_address (const gchar *string);
195         return g_dbus_is_address(Str.toStringz(string));
196     }
197    
198     /**
199      * Like g_dbus_is_address() but also checks if the library suppors the
200      * transports in string and that key/value pairs for each transport
201      * are valid.
202      * Since 2.26
203      * Params:
204      * string = A string.
205      * Returns: TRUE if string is a valid D-Bus address that is supported by this library, FALSE if error is set.
206      * Throws: GException on failure.
207      */
208     public static int isSupportedAddress(string string)
209     {
210         // gboolean g_dbus_is_supported_address (const gchar *string,  GError **error);
211         GError* err = null;
212        
213         auto p = g_dbus_is_supported_address(Str.toStringz(string), &err);
214        
215         if (err !is null)
216         {
217             throw new GException( new ErrorG(err) );
218         }
219        
220         return p;
221     }
222    
223     /**
224      * Asynchronously connects to an endpoint specified by address and
225      * sets up the connection so it is in a state to run the client-side
226      * of the D-Bus authentication conversation.
227      * When the operation is finished, callback will be invoked. You can
228      * then call g_dbus_address_get_stream_finish() to get the result of
229      * the operation.
230      * This is an asynchronous failable function. See
231      * g_dbus_address_get_stream_sync() for the synchronous version.
232      * Since 2.26
233      * Params:
234      * address = A valid D-Bus address.
235      * cancellable = A GCancellable or NULL.
236      * callback = A GAsyncReadyCallback to call when the request is satisfied.
237      * userData = Data to pass to callback.
238      */
239     public static void addressGetStream(string address, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
240     {
241         // void g_dbus_address_get_stream (const gchar *address,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
242         g_dbus_address_get_stream(Str.toStringz(address), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
243     }
244    
245     /**
246      * Finishes an operation started with g_dbus_address_get_stream().
247      * Since 2.26
248      * Params:
249      * res = A GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_address_get_stream().
250      * outGuid = NULL or return location to store the GUID extracted from address, if any.
251      * Returns: A GIOStream or NULL if error is set. [transfer full]
252      * Throws: GException on failure.
253      */
254     public static IOStream addressGetStreamFinish(AsyncResultIF res, out string outGuid)
255     {
256         // GIOStream * g_dbus_address_get_stream_finish (GAsyncResult *res,  gchar **out_guid,  GError **error);
257         char* outoutGuid = null;
258         GError* err = null;
259        
260         auto p = g_dbus_address_get_stream_finish((res is null) ? null : res.getAsyncResultTStruct(), &outoutGuid, &err);
261        
262         if (err !is null)
263         {
264             throw new GException( new ErrorG(err) );
265         }
266        
267         outGuid = Str.toString(outoutGuid);
268         if(p is null)
269         {
270             return null;
271         }
272         return new IOStream(cast(GIOStream*) p);
273     }
274    
275     /**
276      * Synchronously connects to an endpoint specified by address and
277      * sets up the connection so it is in a state to run the client-side
278      * of the D-Bus authentication conversation.
279      * This is a synchronous failable function. See
280      * g_dbus_address_get_stream() for the asynchronous version.
281      * Since 2.26
282      * Params:
283      * address = A valid D-Bus address.
284      * outGuid = NULL or return location to store the GUID extracted from address, if any.
285      * cancellable = A GCancellable or NULL.
286      * Returns: A GIOStream or NULL if error is set. [transfer full]
287      * Throws: GException on failure.
288      */
289     public static IOStream addressGetStreamSync(string address, out string outGuid, Cancellable cancellable)
290     {
291         // GIOStream * g_dbus_address_get_stream_sync (const gchar *address,  gchar **out_guid,  GCancellable *cancellable,  GError **error);
292         char* outoutGuid = null;
293         GError* err = null;
294        
295         auto p = g_dbus_address_get_stream_sync(Str.toStringz(address), &outoutGuid, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
296        
297         if (err !is null)
298         {
299             throw new GException( new ErrorG(err) );
300         }
301        
302         outGuid = Str.toString(outoutGuid);
303         if(p is null)
304         {
305             return null;
306         }
307         return new IOStream(cast(GIOStream*) p);
308     }
309    
310     /**
311      * Synchronously looks up the D-Bus address for the well-known message
312      * bus instance specified by bus_type. This may involve using various
313      * platform specific mechanisms.
314      * Since 2.26
315      * Params:
316      * busType = A GBusType.
317      * cancellable = A GCancellable or NULL.
318      * Returns: A valid D-Bus address string for bus_type or NULL if error is set.
319      * Throws: GException on failure.
320      */
321     public static string addressGetForBusSync(GBusType busType, Cancellable cancellable)
322     {
323         // gchar * g_dbus_address_get_for_bus_sync (GBusType bus_type,  GCancellable *cancellable,  GError **error);
324         GError* err = null;
325        
326         auto p = g_dbus_address_get_for_bus_sync(busType, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
327        
328         if (err !is null)
329         {
330             throw new GException( new ErrorG(err) );
331         }
332        
333         return Str.toString(p);
334     }
335    
336     /**
337      * Looks up the value of an annotation.
338      * This cost of this function is O(n) in number of annotations.
339      * Since 2.26
340      * Params:
341      * annotations = A NULL-terminated array of annotations or NULL.
342      * name = The name of the annotation to look up.
343      * Returns: The value or NULL if not found. Do not free, it is owned by annotations.
344      */
345     public static string annotationInfoLookup(GDBusAnnotationInfo** annotations, string name)
346     {
347         // const gchar * g_dbus_annotation_info_lookup (GDBusAnnotationInfo **annotations,  const gchar *name);
348         return Str.toString(g_dbus_annotation_info_lookup(annotations, Str.toStringz(name)));
349     }
350    
351     /**
352      * Looks up information about a method.
353      * This cost of this function is O(n) in number of methods.
354      * Since 2.26
355      * Params:
356      * info = A GDBusInterfaceInfo.
357      * name = A D-Bus method name (typically in CamelCase)
358      * Returns: A GDBusMethodInfo or NULL if not found. Do not free, it is owned by info.
359      */
360     public static GDBusMethodInfo* interfaceInfoLookupMethod(GDBusInterfaceInfo* info, string name)
361     {
362         // GDBusMethodInfo * g_dbus_interface_info_lookup_method (GDBusInterfaceInfo *info,  const gchar *name);
363         return g_dbus_interface_info_lookup_method(info, Str.toStringz(name));
364     }
365    
366     /**
367      * Looks up information about a signal.
368      * This cost of this function is O(n) in number of signals.
369      * Since 2.26
370      * Params:
371      * info = A GDBusInterfaceInfo.
372      * name = A D-Bus signal name (typically in CamelCase)
373      * Returns: A GDBusSignalInfo or NULL if not found. Do not free, it is owned by info.
374      */
375     public static GDBusSignalInfo* interfaceInfoLookupSignal(GDBusInterfaceInfo* info, string name)
376     {
377         // GDBusSignalInfo * g_dbus_interface_info_lookup_signal (GDBusInterfaceInfo *info,  const gchar *name);
378         return g_dbus_interface_info_lookup_signal(info, Str.toStringz(name));
379     }
380    
381     /**
382      * Looks up information about a property.
383      * This cost of this function is O(n) in number of properties.
384      * Since 2.26
385      * Params:
386      * info = A GDBusInterfaceInfo.
387      * name = A D-Bus property name (typically in CamelCase).
388      * Returns: A GDBusPropertyInfo or NULL if not found. Do not free, it is owned by info.
389      */
390     public static GDBusPropertyInfo* interfaceInfoLookupProperty(GDBusInterfaceInfo* info, string name)
391     {
392         // GDBusPropertyInfo * g_dbus_interface_info_lookup_property  (GDBusInterfaceInfo *info,  const gchar *name);
393         return g_dbus_interface_info_lookup_property(info, Str.toStringz(name));
394     }
395    
396     /**
397      * Appends an XML representation of info (and its children) to string_builder.
398      * This function is typically used for generating introspection XML
399      * documents at run-time for handling the
400      * org.freedesktop.DBus.Introspectable.Introspect
401      * method.
402      * Since 2.26
403      * Params:
404      * info = A GDBusNodeInfo
405      * indent = Indentation level.
406      * stringBuilder = A GString to to append XML data to.
407      */
408     public static void interfaceInfoGenerateXml(GDBusInterfaceInfo* info, uint indent, StringG stringBuilder)
409     {
410         // void g_dbus_interface_info_generate_xml (GDBusInterfaceInfo *info,  guint indent,  GString *string_builder);
411         g_dbus_interface_info_generate_xml(info, indent, (stringBuilder is null) ? null : stringBuilder.getStringGStruct());
412     }
413    
414     /**
415      * Parses xml_data and returns a GDBusNodeInfo representing the data.
416      * Since 2.26
417      * Params:
418      * xmlData = Valid D-Bus introspection XML.
419      * Returns: A GDBusNodeInfo structure or NULL if error is set. Free with g_dbus_node_info_unref().
420      * Throws: GException on failure.
421      */
422     public static GDBusNodeInfo* nodeInfoNewForXml(string xmlData)
423     {
424         // GDBusNodeInfo * g_dbus_node_info_new_for_xml (const gchar *xml_data,  GError **error);
425         GError* err = null;
426        
427         auto p = g_dbus_node_info_new_for_xml(Str.toStringz(xmlData), &err);
428        
429         if (err !is null)
430         {
431             throw new GException( new ErrorG(err) );
432         }
433        
434         return p;
435     }
436    
437     /**
438      * Looks up information about an interface.
439      * This cost of this function is O(n) in number of interfaces.
440      * Since 2.26
441      * Params:
442      * info = A GDBusNodeInfo.
443      * name = A D-Bus interface name.
444      * Returns: A GDBusInterfaceInfo or NULL if not found. Do not free, it is owned by info.
445      */
446     public static GDBusInterfaceInfo* nodeInfoLookupInterface(GDBusNodeInfo* info, string name)
447     {
448         // GDBusInterfaceInfo * g_dbus_node_info_lookup_interface (GDBusNodeInfo *info,  const gchar *name);
449         return g_dbus_node_info_lookup_interface(info, Str.toStringz(name));
450     }
451    
452     /**
453      * Appends an XML representation of info (and its children) to string_builder.
454      * This function is typically used for generating introspection XML documents at run-time for
455      * handling the org.freedesktop.DBus.Introspectable.Introspect method.
456      * Since 2.26
457      * Params:
458      * info = A GDBusNodeInfo.
459      * indent = Indentation level.
460      * stringBuilder = A GString to to append XML data to.
461      */
462     public static void nodeInfoGenerateXml(GDBusNodeInfo* info, uint indent, StringG stringBuilder)
463     {
464         // void g_dbus_node_info_generate_xml (GDBusNodeInfo *info,  guint indent,  GString *string_builder);
465         g_dbus_node_info_generate_xml(info, indent, (stringBuilder is null) ? null : stringBuilder.getStringGStruct());
466     }
467    
468     /**
469      * If info is statically allocated does nothing. Otherwise increases
470      * the reference count.
471      * Since 2.26
472      * Params:
473      * info = A GDBusNodeInfo
474      * Returns: The same info.
475      */
476     public static GDBusNodeInfo* nodeInfoRef(GDBusNodeInfo* info)
477     {
478         // GDBusNodeInfo * g_dbus_node_info_ref (GDBusNodeInfo *info);
479         return g_dbus_node_info_ref(info);
480     }
481    
482     /**
483      * If info is statically allocated does nothing. Otherwise increases
484      * the reference count.
485      * Since 2.26
486      * Params:
487      * info = A GDBusInterfaceInfo
488      * Returns: The same info.
489      */
490     public static GDBusInterfaceInfo* interfaceInfoRef(GDBusInterfaceInfo* info)
491     {
492         // GDBusInterfaceInfo * g_dbus_interface_info_ref (GDBusInterfaceInfo *info);
493         return g_dbus_interface_info_ref(info);
494     }
495    
496     /**
497      * If info is statically allocated does nothing. Otherwise increases
498      * the reference count.
499      * Since 2.26
500      * Params:
501      * info = A GDBusMethodInfo
502      * Returns: The same info.
503      */
504     public static GDBusMethodInfo* methodInfoRef(GDBusMethodInfo* info)
505     {
506         // GDBusMethodInfo * g_dbus_method_info_ref (GDBusMethodInfo *info);
507         return g_dbus_method_info_ref(info);
508     }
509    
510     /**
511      * If info is statically allocated does nothing. Otherwise increases
512      * the reference count.
513      * Since 2.26
514      * Params:
515      * info = A GDBusSignalInfo
516      * Returns: The same info.
517      */
518     public static GDBusSignalInfo* signalInfoRef(GDBusSignalInfo* info)
519     {
520         // GDBusSignalInfo * g_dbus_signal_info_ref (GDBusSignalInfo *info);
521         return g_dbus_signal_info_ref(info);
522     }
523    
524     /**
525      * If info is statically allocated does nothing. Otherwise increases
526      * the reference count.
527      * Since 2.26
528      * Params:
529      * info = A GDBusPropertyInfo
530      * Returns: The same info.
531      */
532     public static GDBusPropertyInfo* propertyInfoRef(GDBusPropertyInfo* info)
533     {
534         // GDBusPropertyInfo * g_dbus_property_info_ref (GDBusPropertyInfo *info);
535         return g_dbus_property_info_ref(info);
536     }
537    
538     /**
539      * If info is statically allocated does nothing. Otherwise increases
540      * the reference count.
541      * Since 2.26
542      * Params:
543      * info = A GDBusArgInfo
544      * Returns: The same info.
545      */
546     public static GDBusArgInfo* argInfoRef(GDBusArgInfo* info)
547     {
548         // GDBusArgInfo * g_dbus_arg_info_ref (GDBusArgInfo *info);
549         return g_dbus_arg_info_ref(info);
550     }
551    
552     /**
553      * If info is statically allocated does nothing. Otherwise increases
554      * the reference count.
555      * Since 2.26
556      * Params:
557      * info = A GDBusNodeInfo
558      * Returns: The same info.
559      */
560     public static GDBusAnnotationInfo* annotationInfoRef(GDBusAnnotationInfo* info)
561     {
562         // GDBusAnnotationInfo * g_dbus_annotation_info_ref (GDBusAnnotationInfo *info);
563         return g_dbus_annotation_info_ref(info);
564     }
565    
566     /**
567      * If info is statically allocated, does nothing. Otherwise decreases
568      * the reference count of info. When its reference count drops to 0,
569      * the memory used is freed.
570      * Since 2.26
571      * Params:
572      * info = A GDBusNodeInfo.
573      */
574     public static void nodeInfoUnref(GDBusNodeInfo* info)
575     {
576         // void g_dbus_node_info_unref (GDBusNodeInfo *info);
577         g_dbus_node_info_unref(info);
578     }
579    
580     /**
581      * If info is statically allocated, does nothing. Otherwise decreases
582      * the reference count of info. When its reference count drops to 0,
583      * the memory used is freed.
584      * Since 2.26
585      * Params:
586      * info = A GDBusInterfaceInfo.
587      */
588     public static void interfaceInfoUnref(GDBusInterfaceInfo* info)
589     {
590         // void g_dbus_interface_info_unref (GDBusInterfaceInfo *info);
591         g_dbus_interface_info_unref(info);
592     }
593    
594     /**
595      * If info is statically allocated, does nothing. Otherwise decreases
596      * the reference count of info. When its reference count drops to 0,
597      * the memory used is freed.
598      * Since 2.26
599      * Params:
600      * info = A GDBusMethodInfo.
601      */
602     public static void methodInfoUnref(GDBusMethodInfo* info)
603     {
604         // void g_dbus_method_info_unref (GDBusMethodInfo *info);
605         g_dbus_method_info_unref(info);
606     }
607    
608     /**
609      * If info is statically allocated, does nothing. Otherwise decreases
610      * the reference count of info. When its reference count drops to 0,
611      * the memory used is freed.
612      * Since 2.26
613      * Params:
614      * info = A GDBusSignalInfo.
615      */
616     public static void signalInfoUnref(GDBusSignalInfo* info)
617     {
618         // void g_dbus_signal_info_unref (GDBusSignalInfo *info);
619         g_dbus_signal_info_unref(info);
620     }
621    
622     /**
623      * If info is statically allocated, does nothing. Otherwise decreases
624      * the reference count of info. When its reference count drops to 0,
625      * the memory used is freed.
626      * Since 2.26
627      * Params:
628      * info = A GDBusPropertyInfo.
629      */
630     public static void propertyInfoUnref(GDBusPropertyInfo* info)
631     {
632         // void g_dbus_property_info_unref (GDBusPropertyInfo *info);
633         g_dbus_property_info_unref(info);
634     }
635    
636     /**
637      * If info is statically allocated, does nothing. Otherwise decreases
638      * the reference count of info. When its reference count drops to 0,
639      * the memory used is freed.
640      * Since 2.26
641      * Params:
642      * info = A GDBusArgInfo.
643      */
644     public static void argInfoUnref(GDBusArgInfo* info)
645     {
646         // void g_dbus_arg_info_unref (GDBusArgInfo *info);
647         g_dbus_arg_info_unref(info);
648     }
649    
650     /**
651      * If info is statically allocated, does nothing. Otherwise decreases
652      * the reference count of info. When its reference count drops to 0,
653      * the memory used is freed.
654      * Since 2.26
655      * Params:
656      * info = A GDBusAnnotationInfo.
657      */
658     public static void annotationInfoUnref(GDBusAnnotationInfo* info)
659     {
660         // void g_dbus_annotation_info_unref (GDBusAnnotationInfo *info);
661         g_dbus_annotation_info_unref(info);
662     }
663 }
Note: See TracBrowser for help on using the browser.