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.DBusMethodInfo;
28 private import gio.DBusPropertyInfo;
29 private import gio.DBusSignalInfo;
30 private import glib.Str;
31 private import glib.StringG;
32 private import gobject.ObjectG;
33 private import gtkc.gio;
34 public  import gtkc.giotypes;
35 private import gtkd.Loader;
36 
37 
38 /**
39  * Information about a D-Bus interface.
40  *
41  * Since: 2.26
42  */
43 public class DBusInterfaceInfo
44 {
45 	/** the main Gtk struct */
46 	protected GDBusInterfaceInfo* gDBusInterfaceInfo;
47 	protected bool ownedRef;
48 
49 	/** Get the main Gtk struct */
50 	public GDBusInterfaceInfo* getDBusInterfaceInfoStruct(bool transferOwnership = false)
51 	{
52 		if (transferOwnership)
53 			ownedRef = false;
54 		return gDBusInterfaceInfo;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected void* getStruct()
59 	{
60 		return cast(void*)gDBusInterfaceInfo;
61 	}
62 
63 	/**
64 	 * Sets our main struct and passes it to the parent class.
65 	 */
66 	public this (GDBusInterfaceInfo* gDBusInterfaceInfo, bool ownedRef = false)
67 	{
68 		this.gDBusInterfaceInfo = gDBusInterfaceInfo;
69 		this.ownedRef = ownedRef;
70 	}
71 
72 	~this ()
73 	{
74 		if (  Linker.isLoaded(LIBRARY_GIO) && ownedRef )
75 			g_dbus_interface_info_unref(gDBusInterfaceInfo);
76 	}
77 
78 
79 	/** */
80 	public static GType getType()
81 	{
82 		return g_dbus_interface_info_get_type();
83 	}
84 
85 	/**
86 	 * Builds a lookup-cache to speed up
87 	 * g_dbus_interface_info_lookup_method(),
88 	 * g_dbus_interface_info_lookup_signal() and
89 	 * g_dbus_interface_info_lookup_property().
90 	 *
91 	 * If this has already been called with @info, the existing cache is
92 	 * used and its use count is increased.
93 	 *
94 	 * Note that @info cannot be modified until
95 	 * g_dbus_interface_info_cache_release() is called.
96 	 *
97 	 * Since: 2.30
98 	 */
99 	public void cacheBuild()
100 	{
101 		g_dbus_interface_info_cache_build(gDBusInterfaceInfo);
102 	}
103 
104 	/**
105 	 * Decrements the usage count for the cache for @info built by
106 	 * g_dbus_interface_info_cache_build() (if any) and frees the
107 	 * resources used by the cache if the usage count drops to zero.
108 	 *
109 	 * Since: 2.30
110 	 */
111 	public void cacheRelease()
112 	{
113 		g_dbus_interface_info_cache_release(gDBusInterfaceInfo);
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
120 	 * documents at run-time for handling the
121 	 * `org.freedesktop.DBus.Introspectable.Introspect`
122 	 * method.
123 	 *
124 	 * Params:
125 	 *     indent = Indentation level.
126 	 *     stringBuilder = A #GString to to append XML data to.
127 	 *
128 	 * Since: 2.26
129 	 */
130 	public void generateXml(uint indent, out StringG stringBuilder)
131 	{
132 		GString* outstringBuilder = gMalloc!GString();
133 		
134 		g_dbus_interface_info_generate_xml(gDBusInterfaceInfo, indent, outstringBuilder);
135 		
136 		stringBuilder = new StringG(outstringBuilder, true);
137 	}
138 
139 	/**
140 	 * Looks up information about a method.
141 	 *
142 	 * The cost of this function is O(n) in number of methods unless
143 	 * g_dbus_interface_info_cache_build() has been used on @info.
144 	 *
145 	 * Params:
146 	 *     name = A D-Bus method name (typically in CamelCase)
147 	 *
148 	 * Returns: A #GDBusMethodInfo or %NULL if not found. Do not free, it is owned by @info.
149 	 *
150 	 * Since: 2.26
151 	 */
152 	public DBusMethodInfo lookupMethod(string name)
153 	{
154 		auto p = g_dbus_interface_info_lookup_method(gDBusInterfaceInfo, Str.toStringz(name));
155 		
156 		if(p is null)
157 		{
158 			return null;
159 		}
160 		
161 		return ObjectG.getDObject!(DBusMethodInfo)(cast(GDBusMethodInfo*) p);
162 	}
163 
164 	/**
165 	 * Looks up information about a property.
166 	 *
167 	 * The cost of this function is O(n) in number of properties unless
168 	 * g_dbus_interface_info_cache_build() has been used on @info.
169 	 *
170 	 * Params:
171 	 *     name = A D-Bus property name (typically in CamelCase).
172 	 *
173 	 * Returns: A #GDBusPropertyInfo or %NULL if not found. Do not free, it is owned by @info.
174 	 *
175 	 * Since: 2.26
176 	 */
177 	public DBusPropertyInfo lookupProperty(string name)
178 	{
179 		auto p = g_dbus_interface_info_lookup_property(gDBusInterfaceInfo, Str.toStringz(name));
180 		
181 		if(p is null)
182 		{
183 			return null;
184 		}
185 		
186 		return ObjectG.getDObject!(DBusPropertyInfo)(cast(GDBusPropertyInfo*) p);
187 	}
188 
189 	/**
190 	 * Looks up information about a signal.
191 	 *
192 	 * The cost of this function is O(n) in number of signals unless
193 	 * g_dbus_interface_info_cache_build() has been used on @info.
194 	 *
195 	 * Params:
196 	 *     name = A D-Bus signal name (typically in CamelCase)
197 	 *
198 	 * Returns: A #GDBusSignalInfo or %NULL if not found. Do not free, it is owned by @info.
199 	 *
200 	 * Since: 2.26
201 	 */
202 	public DBusSignalInfo lookupSignal(string name)
203 	{
204 		auto p = g_dbus_interface_info_lookup_signal(gDBusInterfaceInfo, Str.toStringz(name));
205 		
206 		if(p is null)
207 		{
208 			return null;
209 		}
210 		
211 		return ObjectG.getDObject!(DBusSignalInfo)(cast(GDBusSignalInfo*) p);
212 	}
213 
214 	/**
215 	 * If @info is statically allocated does nothing. Otherwise increases
216 	 * the reference count.
217 	 *
218 	 * Returns: The same @info.
219 	 *
220 	 * Since: 2.26
221 	 */
222 	public DBusInterfaceInfo doref()
223 	{
224 		auto p = g_dbus_interface_info_ref(gDBusInterfaceInfo);
225 		
226 		if(p is null)
227 		{
228 			return null;
229 		}
230 		
231 		return ObjectG.getDObject!(DBusInterfaceInfo)(cast(GDBusInterfaceInfo*) p, true);
232 	}
233 
234 	/**
235 	 * If @info is statically allocated, does nothing. Otherwise decreases
236 	 * the reference count of @info. When its reference count drops to 0,
237 	 * the memory used is freed.
238 	 *
239 	 * Since: 2.26
240 	 */
241 	public void unref()
242 	{
243 		g_dbus_interface_info_unref(gDBusInterfaceInfo);
244 	}
245 }