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.DBusNodeInfo;
26 
27 private import gio.DBusAnnotationInfo;
28 private import gio.DBusInterfaceInfo;
29 private import gio.c.functions;
30 public  import gio.c.types;
31 private import glib.ConstructionException;
32 private import glib.ErrorG;
33 private import glib.GException;
34 private import glib.MemorySlice;
35 private import glib.Str;
36 private import glib.StringG;
37 private import glib.c.functions;
38 private import gobject.ObjectG;
39 private import gtkd.Loader;
40 
41 
42 /**
43  * Information about nodes in a remote object hierarchy.
44  *
45  * Since: 2.26
46  */
47 public final class DBusNodeInfo
48 {
49 	/** the main Gtk struct */
50 	protected GDBusNodeInfo* gDBusNodeInfo;
51 	protected bool ownedRef;
52 
53 	/** Get the main Gtk struct */
54 	public GDBusNodeInfo* getDBusNodeInfoStruct(bool transferOwnership = false)
55 	{
56 		if (transferOwnership)
57 			ownedRef = false;
58 		return gDBusNodeInfo;
59 	}
60 
61 	/** the main Gtk struct as a void* */
62 	protected void* getStruct()
63 	{
64 		return cast(void*)gDBusNodeInfo;
65 	}
66 
67 	/**
68 	 * Sets our main struct and passes it to the parent class.
69 	 */
70 	public this (GDBusNodeInfo* gDBusNodeInfo, bool ownedRef = false)
71 	{
72 		this.gDBusNodeInfo = gDBusNodeInfo;
73 		this.ownedRef = ownedRef;
74 	}
75 
76 	~this ()
77 	{
78 		if ( Linker.isLoaded(LIBRARY_GIO) && ownedRef )
79 			g_dbus_node_info_unref(gDBusNodeInfo);
80 	}
81 
82 
83 	/**
84 	 * The reference count or -1 if statically allocated.
85 	 */
86 	public @property int refCount()
87 	{
88 		return gDBusNodeInfo.refCount;
89 	}
90 
91 	/** Ditto */
92 	public @property void refCount(int value)
93 	{
94 		gDBusNodeInfo.refCount = value;
95 	}
96 
97 	/**
98 	 * The path of the node or %NULL if omitted. Note that this may be a relative path. See the D-Bus specification for more details.
99 	 */
100 	public @property string path()
101 	{
102 		return Str.toString(gDBusNodeInfo.path);
103 	}
104 
105 	/** Ditto */
106 	public @property void path(string value)
107 	{
108 		gDBusNodeInfo.path = Str.toStringz(value);
109 	}
110 
111 	/**
112 	 * A pointer to a %NULL-terminated array of pointers to #GDBusInterfaceInfo structures or %NULL if there are no interfaces.
113 	 */
114 	public @property DBusInterfaceInfo[] interfaces()
115 	{
116 		DBusInterfaceInfo[] arr = new DBusInterfaceInfo[getArrayLength(gDBusNodeInfo.interfaces)];
117 		for ( int i = 0; i < arr.length; i++ )
118 		{
119 			arr[i] = ObjectG.getDObject!(DBusInterfaceInfo)(gDBusNodeInfo.interfaces[i], false);
120 		}
121 
122 		return arr;
123 	}
124 
125 	/** Ditto */
126 	public @property void interfaces(DBusInterfaceInfo[] value)
127 	{
128 		GDBusInterfaceInfo*[] arr = new GDBusInterfaceInfo*[value.length+1];
129 		for ( int i = 0; i < value.length; i++ )
130 		{
131 			arr[i] = value[i].getDBusInterfaceInfoStruct();
132 		}
133 		arr[value.length] = null;
134 
135 		gDBusNodeInfo.interfaces = arr.ptr;
136 	}
137 
138 	/**
139 	 * A pointer to a %NULL-terminated array of pointers to #GDBusNodeInfo structures or %NULL if there are no nodes.
140 	 */
141 	public @property DBusNodeInfo[] nodes()
142 	{
143 		DBusNodeInfo[] arr = new DBusNodeInfo[getArrayLength(gDBusNodeInfo.nodes)];
144 		for ( int i = 0; i < arr.length; i++ )
145 		{
146 			arr[i] = ObjectG.getDObject!(DBusNodeInfo)(gDBusNodeInfo.nodes[i], false);
147 		}
148 
149 		return arr;
150 	}
151 
152 	/** Ditto */
153 	public @property void nodes(DBusNodeInfo[] value)
154 	{
155 		GDBusNodeInfo*[] arr = new GDBusNodeInfo*[value.length+1];
156 		for ( int i = 0; i < value.length; i++ )
157 		{
158 			arr[i] = value[i].getDBusNodeInfoStruct();
159 		}
160 		arr[value.length] = null;
161 
162 		gDBusNodeInfo.nodes = arr.ptr;
163 	}
164 
165 	/**
166 	 * A pointer to a %NULL-terminated array of pointers to #GDBusAnnotationInfo structures or %NULL if there are no annotations.
167 	 */
168 	public @property DBusAnnotationInfo[] annotations()
169 	{
170 		DBusAnnotationInfo[] arr = new DBusAnnotationInfo[getArrayLength(gDBusNodeInfo.annotations)];
171 		for ( int i = 0; i < arr.length; i++ )
172 		{
173 			arr[i] = ObjectG.getDObject!(DBusAnnotationInfo)(gDBusNodeInfo.annotations[i], false);
174 		}
175 
176 		return arr;
177 	}
178 
179 	/** Ditto */
180 	public @property void annotations(DBusAnnotationInfo[] value)
181 	{
182 		GDBusAnnotationInfo*[] arr = new GDBusAnnotationInfo*[value.length+1];
183 		for ( int i = 0; i < value.length; i++ )
184 		{
185 			arr[i] = value[i].getDBusAnnotationInfoStruct();
186 		}
187 		arr[value.length] = null;
188 
189 		gDBusNodeInfo.annotations = arr.ptr;
190 	}
191 
192 	/** */
193 	public static GType getType()
194 	{
195 		return g_dbus_node_info_get_type();
196 	}
197 
198 	/**
199 	 * Parses @xml_data and returns a #GDBusNodeInfo representing the data.
200 	 *
201 	 * The introspection XML must contain exactly one top-level
202 	 * <node> element.
203 	 *
204 	 * Note that this routine is using a
205 	 * [GMarkup][glib-Simple-XML-Subset-Parser.description]-based
206 	 * parser that only accepts a subset of valid XML documents.
207 	 *
208 	 * Params:
209 	 *     xmlData = Valid D-Bus introspection XML.
210 	 *
211 	 * Returns: A #GDBusNodeInfo structure or %NULL if @error is set. Free
212 	 *     with g_dbus_node_info_unref().
213 	 *
214 	 * Since: 2.26
215 	 *
216 	 * Throws: GException on failure.
217 	 * Throws: ConstructionException GTK+ fails to create the object.
218 	 */
219 	public this(string xmlData)
220 	{
221 		GError* err = null;
222 
223 		auto __p = g_dbus_node_info_new_for_xml(Str.toStringz(xmlData), &err);
224 
225 		if (err !is null)
226 		{
227 			throw new GException( new ErrorG(err) );
228 		}
229 
230 		if(__p is null)
231 		{
232 			throw new ConstructionException("null returned by new_for_xml");
233 		}
234 
235 		this(cast(GDBusNodeInfo*) __p);
236 	}
237 
238 	/**
239 	 * Appends an XML representation of @info (and its children) to @string_builder.
240 	 *
241 	 * This function is typically used for generating introspection XML documents at run-time for
242 	 * handling the `org.freedesktop.DBus.Introspectable.Introspect`  method.
243 	 *
244 	 * Params:
245 	 *     indent = Indentation level.
246 	 *     stringBuilder = A #GString to to append XML data to.
247 	 *
248 	 * Since: 2.26
249 	 */
250 	public void generateXml(uint indent, StringG stringBuilder)
251 	{
252 		g_dbus_node_info_generate_xml(gDBusNodeInfo, indent, (stringBuilder is null) ? null : stringBuilder.getStringGStruct());
253 	}
254 
255 	/**
256 	 * Looks up information about an interface.
257 	 *
258 	 * The cost of this function is O(n) in number of interfaces.
259 	 *
260 	 * Params:
261 	 *     name = A D-Bus interface name.
262 	 *
263 	 * Returns: A #GDBusInterfaceInfo or %NULL if not found. Do not free, it is owned by @info.
264 	 *
265 	 * Since: 2.26
266 	 */
267 	public DBusInterfaceInfo lookupInterface(string name)
268 	{
269 		auto __p = g_dbus_node_info_lookup_interface(gDBusNodeInfo, Str.toStringz(name));
270 
271 		if(__p is null)
272 		{
273 			return null;
274 		}
275 
276 		return ObjectG.getDObject!(DBusInterfaceInfo)(cast(GDBusInterfaceInfo*) __p);
277 	}
278 
279 	alias doref = ref_;
280 	/**
281 	 * If @info is statically allocated does nothing. Otherwise increases
282 	 * the reference count.
283 	 *
284 	 * Returns: The same @info.
285 	 *
286 	 * Since: 2.26
287 	 */
288 	public DBusNodeInfo ref_()
289 	{
290 		auto __p = g_dbus_node_info_ref(gDBusNodeInfo);
291 
292 		if(__p is null)
293 		{
294 			return null;
295 		}
296 
297 		return ObjectG.getDObject!(DBusNodeInfo)(cast(GDBusNodeInfo*) __p, true);
298 	}
299 
300 	/**
301 	 * If @info is statically allocated, does nothing. Otherwise decreases
302 	 * the reference count of @info. When its reference count drops to 0,
303 	 * the memory used is freed.
304 	 *
305 	 * Since: 2.26
306 	 */
307 	public void unref()
308 	{
309 		g_dbus_node_info_unref(gDBusNodeInfo);
310 	}
311 }