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.DBusInterfaceInfo;
28 private import glib.ConstructionException;
29 private import glib.ErrorG;
30 private import glib.GException;
31 private import glib.Str;
32 private import glib.StringG;
33 private import gobject.ObjectG;
34 private import gtkc.gio;
35 public  import gtkc.giotypes;
36 
37 
38 /**
39  * Information about nodes in a remote object hierarchy.
40  *
41  * Since: 2.26
42  */
43 public class DBusNodeInfo
44 {
45 	/** the main Gtk struct */
46 	protected GDBusNodeInfo* gDBusNodeInfo;
47 
48 	/** Get the main Gtk struct */
49 	public GDBusNodeInfo* getDBusNodeInfoStruct()
50 	{
51 		return gDBusNodeInfo;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected void* getStruct()
56 	{
57 		return cast(void*)gDBusNodeInfo;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GDBusNodeInfo* gDBusNodeInfo)
64 	{
65 		this.gDBusNodeInfo = gDBusNodeInfo;
66 	}
67 
68 	/**
69 	 */
70 
71 	public static GType getType()
72 	{
73 		return g_dbus_node_info_get_type();
74 	}
75 
76 	/**
77 	 * Parses @xml_data and returns a #GDBusNodeInfo representing the data.
78 	 *
79 	 * The introspection XML must contain exactly one top-level
80 	 * <node> element.
81 	 *
82 	 * Note that this routine is using a
83 	 * [GMarkup][glib-Simple-XML-Subset-Parser.description]-based
84 	 * parser that only accepts a subset of valid XML documents.
85 	 *
86 	 * Params:
87 	 *     xmlData = Valid D-Bus introspection XML.
88 	 *
89 	 * Return: A #GDBusNodeInfo structure or %NULL if @error is set. Free
90 	 *     with g_dbus_node_info_unref().
91 	 *
92 	 * Since: 2.26
93 	 *
94 	 * Throws: GException on failure.
95 	 * Throws: ConstructionException GTK+ fails to create the object.
96 	 */
97 	public this(string xmlData)
98 	{
99 		GError* err = null;
100 		
101 		auto p = g_dbus_node_info_new_for_xml(Str.toStringz(xmlData), &err);
102 		
103 		if(p is null)
104 		{
105 			throw new ConstructionException("null returned by new_for_xml");
106 		}
107 		
108 		if (err !is null)
109 		{
110 			throw new GException( new ErrorG(err) );
111 		}
112 		
113 		this(cast(GDBusNodeInfo*) p);
114 	}
115 
116 	/**
117 	 * Appends an XML representation of @info (and its children) to @string_builder.
118 	 *
119 	 * This function is typically used for generating introspection XML documents at run-time for
120 	 * handling the `org.freedesktop.DBus.Introspectable.Introspect`  method.
121 	 *
122 	 * Params:
123 	 *     indent = Indentation level.
124 	 *     stringBuilder = A #GString to to append XML data to.
125 	 *
126 	 * Since: 2.26
127 	 */
128 	public void generateXml(uint indent, out StringG stringBuilder)
129 	{
130 		GString* outstringBuilder = new GString;
131 		
132 		g_dbus_node_info_generate_xml(gDBusNodeInfo, indent, outstringBuilder);
133 		
134 		stringBuilder = new StringG(outstringBuilder);
135 	}
136 
137 	/**
138 	 * Looks up information about an interface.
139 	 *
140 	 * The cost of this function is O(n) in number of interfaces.
141 	 *
142 	 * Params:
143 	 *     name = A D-Bus interface name.
144 	 *
145 	 * Return: A #GDBusInterfaceInfo or %NULL if not found. Do not free, it is owned by @info.
146 	 *
147 	 * Since: 2.26
148 	 */
149 	public DBusInterfaceInfo lookupInterface(string name)
150 	{
151 		auto p = g_dbus_node_info_lookup_interface(gDBusNodeInfo, Str.toStringz(name));
152 		
153 		if(p is null)
154 		{
155 			return null;
156 		}
157 		
158 		return ObjectG.getDObject!(DBusInterfaceInfo)(cast(GDBusInterfaceInfo*) p);
159 	}
160 
161 	/**
162 	 * If @info is statically allocated does nothing. Otherwise increases
163 	 * the reference count.
164 	 *
165 	 * Return: The same @info.
166 	 *
167 	 * Since: 2.26
168 	 */
169 	public DBusNodeInfo doref()
170 	{
171 		auto p = g_dbus_node_info_ref(gDBusNodeInfo);
172 		
173 		if(p is null)
174 		{
175 			return null;
176 		}
177 		
178 		return ObjectG.getDObject!(DBusNodeInfo)(cast(GDBusNodeInfo*) p);
179 	}
180 
181 	/**
182 	 * If @info is statically allocated, does nothing. Otherwise decreases
183 	 * the reference count of @info. When its reference count drops to 0,
184 	 * the memory used is freed.
185 	 *
186 	 * Since: 2.26
187 	 */
188 	public void unref()
189 	{
190 		g_dbus_node_info_unref(gDBusNodeInfo);
191 	}
192 }