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.DBusObjectManagerServer; 26 27 private import gio.DBusConnection; 28 private import gio.DBusObjectManagerIF; 29 private import gio.DBusObjectManagerT; 30 private import gio.DBusObjectSkeleton; 31 private import glib.ConstructionException; 32 private import glib.Str; 33 private import gobject.ObjectG; 34 private import gtkc.gio; 35 public import gtkc.giotypes; 36 37 38 /** 39 * #GDBusObjectManagerServer is used to export #GDBusObject instances using 40 * the standardized 41 * [org.freedesktop.DBus.ObjectManager](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager) 42 * interface. For example, remote D-Bus clients can get all objects 43 * and properties in a single call. Additionally, any change in the 44 * object hierarchy is broadcast using signals. This means that D-Bus 45 * clients can keep caches up to date by only listening to D-Bus 46 * signals. 47 * 48 * The recommended path to export an object manager at is the path form of the 49 * well-known name of a D-Bus service, or below. For example, if a D-Bus service 50 * is available at the well-known name `net.example.ExampleService1`, the object 51 * manager should typically be exported at `/net/example/ExampleService1`, or 52 * below (to allow for multiple object managers in a service). 53 * 54 * It is supported, but not recommended, to export an object manager at the root 55 * path, `/`. 56 * 57 * See #GDBusObjectManagerClient for the client-side code that is 58 * intended to be used with #GDBusObjectManagerServer or any D-Bus 59 * object implementing the org.freedesktop.DBus.ObjectManager 60 * interface. 61 * 62 * Since: 2.30 63 */ 64 public class DBusObjectManagerServer : ObjectG, DBusObjectManagerIF 65 { 66 /** the main Gtk struct */ 67 protected GDBusObjectManagerServer* gDBusObjectManagerServer; 68 69 /** Get the main Gtk struct */ 70 public GDBusObjectManagerServer* getDBusObjectManagerServerStruct(bool transferOwnership = false) 71 { 72 if (transferOwnership) 73 ownedRef = false; 74 return gDBusObjectManagerServer; 75 } 76 77 /** the main Gtk struct as a void* */ 78 protected override void* getStruct() 79 { 80 return cast(void*)gDBusObjectManagerServer; 81 } 82 83 protected override void setStruct(GObject* obj) 84 { 85 gDBusObjectManagerServer = cast(GDBusObjectManagerServer*)obj; 86 super.setStruct(obj); 87 } 88 89 /** 90 * Sets our main struct and passes it to the parent class. 91 */ 92 public this (GDBusObjectManagerServer* gDBusObjectManagerServer, bool ownedRef = false) 93 { 94 this.gDBusObjectManagerServer = gDBusObjectManagerServer; 95 super(cast(GObject*)gDBusObjectManagerServer, ownedRef); 96 } 97 98 // add the DBusObjectManager capabilities 99 mixin DBusObjectManagerT!(GDBusObjectManagerServer); 100 101 102 /** */ 103 public static GType getType() 104 { 105 return g_dbus_object_manager_server_get_type(); 106 } 107 108 /** 109 * Creates a new #GDBusObjectManagerServer object. 110 * 111 * The returned server isn't yet exported on any connection. To do so, 112 * use g_dbus_object_manager_server_set_connection(). Normally you 113 * want to export all of your objects before doing so to avoid 114 * [InterfacesAdded](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager) 115 * signals being emitted. 116 * 117 * Params: 118 * objectPath = The object path to export the manager object at. 119 * 120 * Returns: A #GDBusObjectManagerServer object. Free with g_object_unref(). 121 * 122 * Since: 2.30 123 * 124 * Throws: ConstructionException GTK+ fails to create the object. 125 */ 126 public this(string objectPath) 127 { 128 auto p = g_dbus_object_manager_server_new(Str.toStringz(objectPath)); 129 130 if(p is null) 131 { 132 throw new ConstructionException("null returned by new"); 133 } 134 135 this(cast(GDBusObjectManagerServer*) p, true); 136 } 137 138 /** 139 * Exports @object on @manager. 140 * 141 * If there is already a #GDBusObject exported at the object path, 142 * then the old object is removed. 143 * 144 * The object path for @object must be in the hierarchy rooted by the 145 * object path for @manager. 146 * 147 * Note that @manager will take a reference on @object for as long as 148 * it is exported. 149 * 150 * Params: 151 * object = A #GDBusObjectSkeleton. 152 * 153 * Since: 2.30 154 */ 155 public void expor(DBusObjectSkeleton object) 156 { 157 g_dbus_object_manager_server_export(gDBusObjectManagerServer, (object is null) ? null : object.getDBusObjectSkeletonStruct()); 158 } 159 160 /** 161 * Like g_dbus_object_manager_server_export() but appends a string of 162 * the form _N (with N being a natural number) to @object's object path 163 * if an object with the given path already exists. As such, the 164 * #GDBusObjectProxy:g-object-path property of @object may be modified. 165 * 166 * Params: 167 * object = An object. 168 * 169 * Since: 2.30 170 */ 171 public void exportUniquely(DBusObjectSkeleton object) 172 { 173 g_dbus_object_manager_server_export_uniquely(gDBusObjectManagerServer, (object is null) ? null : object.getDBusObjectSkeletonStruct()); 174 } 175 176 /** 177 * Gets the #GDBusConnection used by @manager. 178 * 179 * Returns: A #GDBusConnection object or %NULL if 180 * @manager isn't exported on a connection. The returned object should 181 * be freed with g_object_unref(). 182 * 183 * Since: 2.30 184 */ 185 public DBusConnection getConnection() 186 { 187 auto p = g_dbus_object_manager_server_get_connection(gDBusObjectManagerServer); 188 189 if(p is null) 190 { 191 return null; 192 } 193 194 return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p, true); 195 } 196 197 /** 198 * Returns whether @object is currently exported on @manager. 199 * 200 * Params: 201 * object = An object. 202 * 203 * Returns: %TRUE if @object is exported 204 * 205 * Since: 2.34 206 */ 207 public bool isExported(DBusObjectSkeleton object) 208 { 209 return g_dbus_object_manager_server_is_exported(gDBusObjectManagerServer, (object is null) ? null : object.getDBusObjectSkeletonStruct()) != 0; 210 } 211 212 /** 213 * Exports all objects managed by @manager on @connection. If 214 * @connection is %NULL, stops exporting objects. 215 * 216 * Params: 217 * connection = A #GDBusConnection or %NULL. 218 */ 219 public void setConnection(DBusConnection connection) 220 { 221 g_dbus_object_manager_server_set_connection(gDBusObjectManagerServer, (connection is null) ? null : connection.getDBusConnectionStruct()); 222 } 223 224 /** 225 * If @manager has an object at @path, removes the object. Otherwise 226 * does nothing. 227 * 228 * Note that @object_path must be in the hierarchy rooted by the 229 * object path for @manager. 230 * 231 * Params: 232 * objectPath = An object path. 233 * 234 * Returns: %TRUE if object at @object_path was removed, %FALSE otherwise. 235 * 236 * Since: 2.30 237 */ 238 public bool unexport(string objectPath) 239 { 240 return g_dbus_object_manager_server_unexport(gDBusObjectManagerServer, Str.toStringz(objectPath)) != 0; 241 } 242 }