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