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.DBusInterfaceInfo;
26 
27 private import gio.DBusAnnotationInfo;
28 private import gio.DBusMethodInfo;
29 private import gio.DBusPropertyInfo;
30 private import gio.DBusSignalInfo;
31 private import gio.c.functions;
32 public  import gio.c.types;
33 private import glib.MemorySlice;
34 private import glib.Str;
35 private import glib.StringG;
36 private import gobject.ObjectG;
37 public  import gtkc.giotypes;
38 private import gtkd.Loader;
39 
40 
41 /**
42  * Information about a D-Bus interface.
43  *
44  * Since: 2.26
45  */
46 public final class DBusInterfaceInfo
47 {
48 	/** the main Gtk struct */
49 	protected GDBusInterfaceInfo* gDBusInterfaceInfo;
50 	protected bool ownedRef;
51 
52 	/** Get the main Gtk struct */
53 	public GDBusInterfaceInfo* getDBusInterfaceInfoStruct(bool transferOwnership = false)
54 	{
55 		if (transferOwnership)
56 			ownedRef = false;
57 		return gDBusInterfaceInfo;
58 	}
59 
60 	/** the main Gtk struct as a void* */
61 	protected void* getStruct()
62 	{
63 		return cast(void*)gDBusInterfaceInfo;
64 	}
65 
66 	/**
67 	 * Sets our main struct and passes it to the parent class.
68 	 */
69 	public this (GDBusInterfaceInfo* gDBusInterfaceInfo, bool ownedRef = false)
70 	{
71 		this.gDBusInterfaceInfo = gDBusInterfaceInfo;
72 		this.ownedRef = ownedRef;
73 	}
74 
75 	~this ()
76 	{
77 		if ( Linker.isLoaded(LIBRARY_GIO) && ownedRef )
78 			g_dbus_interface_info_unref(gDBusInterfaceInfo);
79 	}
80 
81 
82 	/**
83 	 * The reference count or -1 if statically allocated.
84 	 */
85 	public @property int refCount()
86 	{
87 		return gDBusInterfaceInfo.refCount;
88 	}
89 
90 	/** Ditto */
91 	public @property void refCount(int value)
92 	{
93 		gDBusInterfaceInfo.refCount = value;
94 	}
95 
96 	/**
97 	 * The name of the D-Bus interface, e.g. "org.freedesktop.DBus.Properties".
98 	 */
99 	public @property string name()
100 	{
101 		return Str.toString(gDBusInterfaceInfo.name);
102 	}
103 
104 	/** Ditto */
105 	public @property void name(string value)
106 	{
107 		gDBusInterfaceInfo.name = Str.toStringz(value);
108 	}
109 
110 	/**
111 	 * A pointer to a %NULL-terminated array of pointers to #GDBusMethodInfo structures or %NULL if there are no methods.
112 	 */
113 	public @property DBusMethodInfo[] methods()
114 	{
115 		DBusMethodInfo[] arr = new DBusMethodInfo[getArrayLength(gDBusInterfaceInfo.methods)];
116 		for ( int i = 0; i < arr.length; i++ )
117 		{
118 			arr[i] = ObjectG.getDObject!(DBusMethodInfo)(gDBusInterfaceInfo.methods[i], false);
119 		}
120 
121 		return arr;
122 	}
123 
124 	/** Ditto */
125 	public @property void methods(DBusMethodInfo[] value)
126 	{
127 		GDBusMethodInfo*[] arr = new GDBusMethodInfo*[value.length+1];
128 		for ( int i = 0; i < value.length; i++ )
129 		{
130 			arr[i] = value[i].getDBusMethodInfoStruct();
131 		}
132 		arr[value.length] = null;
133 
134 		gDBusInterfaceInfo.methods = arr.ptr;
135 	}
136 
137 	/**
138 	 * A pointer to a %NULL-terminated array of pointers to #GDBusSignalInfo structures or %NULL if there are no signals.
139 	 */
140 	public @property DBusSignalInfo[] signals()
141 	{
142 		DBusSignalInfo[] arr = new DBusSignalInfo[getArrayLength(gDBusInterfaceInfo.signals)];
143 		for ( int i = 0; i < arr.length; i++ )
144 		{
145 			arr[i] = ObjectG.getDObject!(DBusSignalInfo)(gDBusInterfaceInfo.signals[i], false);
146 		}
147 
148 		return arr;
149 	}
150 
151 	/** Ditto */
152 	public @property void signals(DBusSignalInfo[] value)
153 	{
154 		GDBusSignalInfo*[] arr = new GDBusSignalInfo*[value.length+1];
155 		for ( int i = 0; i < value.length; i++ )
156 		{
157 			arr[i] = value[i].getDBusSignalInfoStruct();
158 		}
159 		arr[value.length] = null;
160 
161 		gDBusInterfaceInfo.signals = arr.ptr;
162 	}
163 
164 	/**
165 	 * A pointer to a %NULL-terminated array of pointers to #GDBusPropertyInfo structures or %NULL if there are no properties.
166 	 */
167 	public @property DBusPropertyInfo[] properties()
168 	{
169 		DBusPropertyInfo[] arr = new DBusPropertyInfo[getArrayLength(gDBusInterfaceInfo.properties)];
170 		for ( int i = 0; i < arr.length; i++ )
171 		{
172 			arr[i] = ObjectG.getDObject!(DBusPropertyInfo)(gDBusInterfaceInfo.properties[i], false);
173 		}
174 
175 		return arr;
176 	}
177 
178 	/** Ditto */
179 	public @property void properties(DBusPropertyInfo[] value)
180 	{
181 		GDBusPropertyInfo*[] arr = new GDBusPropertyInfo*[value.length+1];
182 		for ( int i = 0; i < value.length; i++ )
183 		{
184 			arr[i] = value[i].getDBusPropertyInfoStruct();
185 		}
186 		arr[value.length] = null;
187 
188 		gDBusInterfaceInfo.properties = arr.ptr;
189 	}
190 
191 	/**
192 	 * A pointer to a %NULL-terminated array of pointers to #GDBusAnnotationInfo structures or %NULL if there are no annotations.
193 	 */
194 	public @property DBusAnnotationInfo[] annotations()
195 	{
196 		DBusAnnotationInfo[] arr = new DBusAnnotationInfo[getArrayLength(gDBusInterfaceInfo.annotations)];
197 		for ( int i = 0; i < arr.length; i++ )
198 		{
199 			arr[i] = ObjectG.getDObject!(DBusAnnotationInfo)(gDBusInterfaceInfo.annotations[i], false);
200 		}
201 
202 		return arr;
203 	}
204 
205 	/** Ditto */
206 	public @property void annotations(DBusAnnotationInfo[] value)
207 	{
208 		GDBusAnnotationInfo*[] arr = new GDBusAnnotationInfo*[value.length+1];
209 		for ( int i = 0; i < value.length; i++ )
210 		{
211 			arr[i] = value[i].getDBusAnnotationInfoStruct();
212 		}
213 		arr[value.length] = null;
214 
215 		gDBusInterfaceInfo.annotations = arr.ptr;
216 	}
217 
218 	/** */
219 	public static GType getType()
220 	{
221 		return g_dbus_interface_info_get_type();
222 	}
223 
224 	/**
225 	 * Builds a lookup-cache to speed up
226 	 * g_dbus_interface_info_lookup_method(),
227 	 * g_dbus_interface_info_lookup_signal() and
228 	 * g_dbus_interface_info_lookup_property().
229 	 *
230 	 * If this has already been called with @info, the existing cache is
231 	 * used and its use count is increased.
232 	 *
233 	 * Note that @info cannot be modified until
234 	 * g_dbus_interface_info_cache_release() is called.
235 	 *
236 	 * Since: 2.30
237 	 */
238 	public void cacheBuild()
239 	{
240 		g_dbus_interface_info_cache_build(gDBusInterfaceInfo);
241 	}
242 
243 	/**
244 	 * Decrements the usage count for the cache for @info built by
245 	 * g_dbus_interface_info_cache_build() (if any) and frees the
246 	 * resources used by the cache if the usage count drops to zero.
247 	 *
248 	 * Since: 2.30
249 	 */
250 	public void cacheRelease()
251 	{
252 		g_dbus_interface_info_cache_release(gDBusInterfaceInfo);
253 	}
254 
255 	/**
256 	 * Appends an XML representation of @info (and its children) to @string_builder.
257 	 *
258 	 * This function is typically used for generating introspection XML
259 	 * documents at run-time for handling the
260 	 * `org.freedesktop.DBus.Introspectable.Introspect`
261 	 * method.
262 	 *
263 	 * Params:
264 	 *     indent = Indentation level.
265 	 *     stringBuilder = A #GString to to append XML data to.
266 	 *
267 	 * Since: 2.26
268 	 */
269 	public void generateXml(uint indent, StringG stringBuilder)
270 	{
271 		g_dbus_interface_info_generate_xml(gDBusInterfaceInfo, indent, (stringBuilder is null) ? null : stringBuilder.getStringGStruct());
272 	}
273 
274 	/**
275 	 * Looks up information about a method.
276 	 *
277 	 * The cost of this function is O(n) in number of methods unless
278 	 * g_dbus_interface_info_cache_build() has been used on @info.
279 	 *
280 	 * Params:
281 	 *     name = A D-Bus method name (typically in CamelCase)
282 	 *
283 	 * Returns: A #GDBusMethodInfo or %NULL if not found. Do not free, it is owned by @info.
284 	 *
285 	 * Since: 2.26
286 	 */
287 	public DBusMethodInfo lookupMethod(string name)
288 	{
289 		auto __p = g_dbus_interface_info_lookup_method(gDBusInterfaceInfo, Str.toStringz(name));
290 
291 		if(__p is null)
292 		{
293 			return null;
294 		}
295 
296 		return ObjectG.getDObject!(DBusMethodInfo)(cast(GDBusMethodInfo*) __p);
297 	}
298 
299 	/**
300 	 * Looks up information about a property.
301 	 *
302 	 * The cost of this function is O(n) in number of properties unless
303 	 * g_dbus_interface_info_cache_build() has been used on @info.
304 	 *
305 	 * Params:
306 	 *     name = A D-Bus property name (typically in CamelCase).
307 	 *
308 	 * Returns: A #GDBusPropertyInfo or %NULL if not found. Do not free, it is owned by @info.
309 	 *
310 	 * Since: 2.26
311 	 */
312 	public DBusPropertyInfo lookupProperty(string name)
313 	{
314 		auto __p = g_dbus_interface_info_lookup_property(gDBusInterfaceInfo, Str.toStringz(name));
315 
316 		if(__p is null)
317 		{
318 			return null;
319 		}
320 
321 		return ObjectG.getDObject!(DBusPropertyInfo)(cast(GDBusPropertyInfo*) __p);
322 	}
323 
324 	/**
325 	 * Looks up information about a signal.
326 	 *
327 	 * The cost of this function is O(n) in number of signals unless
328 	 * g_dbus_interface_info_cache_build() has been used on @info.
329 	 *
330 	 * Params:
331 	 *     name = A D-Bus signal name (typically in CamelCase)
332 	 *
333 	 * Returns: A #GDBusSignalInfo or %NULL if not found. Do not free, it is owned by @info.
334 	 *
335 	 * Since: 2.26
336 	 */
337 	public DBusSignalInfo lookupSignal(string name)
338 	{
339 		auto __p = g_dbus_interface_info_lookup_signal(gDBusInterfaceInfo, Str.toStringz(name));
340 
341 		if(__p is null)
342 		{
343 			return null;
344 		}
345 
346 		return ObjectG.getDObject!(DBusSignalInfo)(cast(GDBusSignalInfo*) __p);
347 	}
348 
349 	alias doref = ref_;
350 	/**
351 	 * If @info is statically allocated does nothing. Otherwise increases
352 	 * the reference count.
353 	 *
354 	 * Returns: The same @info.
355 	 *
356 	 * Since: 2.26
357 	 */
358 	public DBusInterfaceInfo ref_()
359 	{
360 		auto __p = g_dbus_interface_info_ref(gDBusInterfaceInfo);
361 
362 		if(__p is null)
363 		{
364 			return null;
365 		}
366 
367 		return ObjectG.getDObject!(DBusInterfaceInfo)(cast(GDBusInterfaceInfo*) __p, true);
368 	}
369 
370 	/**
371 	 * If @info is statically allocated, does nothing. Otherwise decreases
372 	 * the reference count of @info. When its reference count drops to 0,
373 	 * the memory used is freed.
374 	 *
375 	 * Since: 2.26
376 	 */
377 	public void unref()
378 	{
379 		g_dbus_interface_info_unref(gDBusInterfaceInfo);
380 	}
381 }