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.DBusObjectManagerT; 26 27 public import gio.DBusInterface; 28 public import gio.DBusInterfaceIF; 29 public import gio.DBusObject; 30 public import gio.DBusObjectIF; 31 public import glib.ListG; 32 public import glib.Str; 33 public import gobject.ObjectG; 34 public import gobject.Signals; 35 public import gtkc.gio; 36 public import gtkc.giotypes; 37 public import std.algorithm; 38 39 40 /** 41 * The #GDBusObjectManager type is the base type for service- and 42 * client-side implementations of the standardized 43 * [org.freedesktop.DBus.ObjectManager](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager) 44 * interface. 45 * 46 * See #GDBusObjectManagerClient for the client-side implementation 47 * and #GDBusObjectManagerServer for the service-side implementation. 48 */ 49 public template DBusObjectManagerT(TStruct) 50 { 51 /** Get the main Gtk struct */ 52 public GDBusObjectManager* getDBusObjectManagerStruct() 53 { 54 return cast(GDBusObjectManager*)getStruct(); 55 } 56 57 58 /** 59 * Gets the interface proxy for @interface_name at @object_path, if 60 * any. 61 * 62 * Params: 63 * objectPath = Object path to lookup. 64 * interfaceName = D-Bus interface name to lookup. 65 * 66 * Returns: A #GDBusInterface instance or %NULL. Free 67 * with g_object_unref(). 68 * 69 * Since: 2.30 70 */ 71 public DBusInterfaceIF getInterface(string objectPath, string interfaceName) 72 { 73 auto p = g_dbus_object_manager_get_interface(getDBusObjectManagerStruct(), Str.toStringz(objectPath), Str.toStringz(interfaceName)); 74 75 if(p is null) 76 { 77 return null; 78 } 79 80 return ObjectG.getDObject!(DBusInterface, DBusInterfaceIF)(cast(GDBusInterface*) p, true); 81 } 82 83 /** 84 * Gets the #GDBusObjectProxy at @object_path, if any. 85 * 86 * Params: 87 * objectPath = Object path to lookup. 88 * 89 * Returns: A #GDBusObject or %NULL. Free with 90 * g_object_unref(). 91 * 92 * Since: 2.30 93 */ 94 public DBusObjectIF getObject(string objectPath) 95 { 96 auto p = g_dbus_object_manager_get_object(getDBusObjectManagerStruct(), Str.toStringz(objectPath)); 97 98 if(p is null) 99 { 100 return null; 101 } 102 103 return ObjectG.getDObject!(DBusObject, DBusObjectIF)(cast(GDBusObject*) p, true); 104 } 105 106 /** 107 * Gets the object path that @manager is for. 108 * 109 * Returns: A string owned by @manager. Do not free. 110 * 111 * Since: 2.30 112 */ 113 public string getObjectPath() 114 { 115 return Str.toString(g_dbus_object_manager_get_object_path(getDBusObjectManagerStruct())); 116 } 117 118 /** 119 * Gets all #GDBusObject objects known to @manager. 120 * 121 * Returns: A list of 122 * #GDBusObject objects. The returned list should be freed with 123 * g_list_free() after each element has been freed with 124 * g_object_unref(). 125 * 126 * Since: 2.30 127 */ 128 public ListG getObjects() 129 { 130 auto p = g_dbus_object_manager_get_objects(getDBusObjectManagerStruct()); 131 132 if(p is null) 133 { 134 return null; 135 } 136 137 return new ListG(cast(GList*) p, true); 138 } 139 140 protected class OnInterfaceAddedDelegateWrapper 141 { 142 static OnInterfaceAddedDelegateWrapper[] listeners; 143 void delegate(DBusObjectIF, DBusInterfaceIF, DBusObjectManagerIF) dlg; 144 gulong handlerId; 145 146 this(void delegate(DBusObjectIF, DBusInterfaceIF, DBusObjectManagerIF) dlg) 147 { 148 this.dlg = dlg; 149 this.listeners ~= this; 150 } 151 152 void remove(OnInterfaceAddedDelegateWrapper source) 153 { 154 foreach(index, wrapper; listeners) 155 { 156 if (wrapper.handlerId == source.handlerId) 157 { 158 listeners[index] = null; 159 listeners = std.algorithm.remove(listeners, index); 160 break; 161 } 162 } 163 } 164 } 165 166 /** 167 * Emitted when @interface is added to @object. 168 * 169 * This signal exists purely as a convenience to avoid having to 170 * connect signals to all objects managed by @manager. 171 * 172 * Params: 173 * object = The #GDBusObject on which an interface was added. 174 * iface = The #GDBusInterface that was added. 175 * 176 * Since: 2.30 177 */ 178 gulong addOnInterfaceAdded(void delegate(DBusObjectIF, DBusInterfaceIF, DBusObjectManagerIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 179 { 180 auto wrapper = new OnInterfaceAddedDelegateWrapper(dlg); 181 wrapper.handlerId = Signals.connectData( 182 this, 183 "interface-added", 184 cast(GCallback)&callBackInterfaceAdded, 185 cast(void*)wrapper, 186 cast(GClosureNotify)&callBackInterfaceAddedDestroy, 187 connectFlags); 188 return wrapper.handlerId; 189 } 190 191 extern(C) static void callBackInterfaceAdded(GDBusObjectManager* dbusobjectmanagerStruct, GDBusObject* object, GDBusInterface* iface, OnInterfaceAddedDelegateWrapper wrapper) 192 { 193 wrapper.dlg(ObjectG.getDObject!(DBusObject, DBusObjectIF)(object), ObjectG.getDObject!(DBusInterface, DBusInterfaceIF)(iface), wrapper.outer); 194 } 195 196 extern(C) static void callBackInterfaceAddedDestroy(OnInterfaceAddedDelegateWrapper wrapper, GClosure* closure) 197 { 198 wrapper.remove(wrapper); 199 } 200 201 protected class OnInterfaceRemovedDelegateWrapper 202 { 203 static OnInterfaceRemovedDelegateWrapper[] listeners; 204 void delegate(DBusObjectIF, DBusInterfaceIF, DBusObjectManagerIF) dlg; 205 gulong handlerId; 206 207 this(void delegate(DBusObjectIF, DBusInterfaceIF, DBusObjectManagerIF) dlg) 208 { 209 this.dlg = dlg; 210 this.listeners ~= this; 211 } 212 213 void remove(OnInterfaceRemovedDelegateWrapper source) 214 { 215 foreach(index, wrapper; listeners) 216 { 217 if (wrapper.handlerId == source.handlerId) 218 { 219 listeners[index] = null; 220 listeners = std.algorithm.remove(listeners, index); 221 break; 222 } 223 } 224 } 225 } 226 227 /** 228 * Emitted when @interface has been removed from @object. 229 * 230 * This signal exists purely as a convenience to avoid having to 231 * connect signals to all objects managed by @manager. 232 * 233 * Params: 234 * object = The #GDBusObject on which an interface was removed. 235 * iface = The #GDBusInterface that was removed. 236 * 237 * Since: 2.30 238 */ 239 gulong addOnInterfaceRemoved(void delegate(DBusObjectIF, DBusInterfaceIF, DBusObjectManagerIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 240 { 241 auto wrapper = new OnInterfaceRemovedDelegateWrapper(dlg); 242 wrapper.handlerId = Signals.connectData( 243 this, 244 "interface-removed", 245 cast(GCallback)&callBackInterfaceRemoved, 246 cast(void*)wrapper, 247 cast(GClosureNotify)&callBackInterfaceRemovedDestroy, 248 connectFlags); 249 return wrapper.handlerId; 250 } 251 252 extern(C) static void callBackInterfaceRemoved(GDBusObjectManager* dbusobjectmanagerStruct, GDBusObject* object, GDBusInterface* iface, OnInterfaceRemovedDelegateWrapper wrapper) 253 { 254 wrapper.dlg(ObjectG.getDObject!(DBusObject, DBusObjectIF)(object), ObjectG.getDObject!(DBusInterface, DBusInterfaceIF)(iface), wrapper.outer); 255 } 256 257 extern(C) static void callBackInterfaceRemovedDestroy(OnInterfaceRemovedDelegateWrapper wrapper, GClosure* closure) 258 { 259 wrapper.remove(wrapper); 260 } 261 262 protected class OnObjectAddedDelegateWrapper 263 { 264 static OnObjectAddedDelegateWrapper[] listeners; 265 void delegate(DBusObjectIF, DBusObjectManagerIF) dlg; 266 gulong handlerId; 267 268 this(void delegate(DBusObjectIF, DBusObjectManagerIF) dlg) 269 { 270 this.dlg = dlg; 271 this.listeners ~= this; 272 } 273 274 void remove(OnObjectAddedDelegateWrapper source) 275 { 276 foreach(index, wrapper; listeners) 277 { 278 if (wrapper.handlerId == source.handlerId) 279 { 280 listeners[index] = null; 281 listeners = std.algorithm.remove(listeners, index); 282 break; 283 } 284 } 285 } 286 } 287 288 /** 289 * Emitted when @object is added to @manager. 290 * 291 * Params: 292 * object = The #GDBusObject that was added. 293 * 294 * Since: 2.30 295 */ 296 gulong addOnObjectAdded(void delegate(DBusObjectIF, DBusObjectManagerIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 297 { 298 auto wrapper = new OnObjectAddedDelegateWrapper(dlg); 299 wrapper.handlerId = Signals.connectData( 300 this, 301 "object-added", 302 cast(GCallback)&callBackObjectAdded, 303 cast(void*)wrapper, 304 cast(GClosureNotify)&callBackObjectAddedDestroy, 305 connectFlags); 306 return wrapper.handlerId; 307 } 308 309 extern(C) static void callBackObjectAdded(GDBusObjectManager* dbusobjectmanagerStruct, GDBusObject* object, OnObjectAddedDelegateWrapper wrapper) 310 { 311 wrapper.dlg(ObjectG.getDObject!(DBusObject, DBusObjectIF)(object), wrapper.outer); 312 } 313 314 extern(C) static void callBackObjectAddedDestroy(OnObjectAddedDelegateWrapper wrapper, GClosure* closure) 315 { 316 wrapper.remove(wrapper); 317 } 318 319 protected class OnObjectRemovedDelegateWrapper 320 { 321 static OnObjectRemovedDelegateWrapper[] listeners; 322 void delegate(DBusObjectIF, DBusObjectManagerIF) dlg; 323 gulong handlerId; 324 325 this(void delegate(DBusObjectIF, DBusObjectManagerIF) dlg) 326 { 327 this.dlg = dlg; 328 this.listeners ~= this; 329 } 330 331 void remove(OnObjectRemovedDelegateWrapper source) 332 { 333 foreach(index, wrapper; listeners) 334 { 335 if (wrapper.handlerId == source.handlerId) 336 { 337 listeners[index] = null; 338 listeners = std.algorithm.remove(listeners, index); 339 break; 340 } 341 } 342 } 343 } 344 345 /** 346 * Emitted when @object is removed from @manager. 347 * 348 * Params: 349 * object = The #GDBusObject that was removed. 350 * 351 * Since: 2.30 352 */ 353 gulong addOnObjectRemoved(void delegate(DBusObjectIF, DBusObjectManagerIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 354 { 355 auto wrapper = new OnObjectRemovedDelegateWrapper(dlg); 356 wrapper.handlerId = Signals.connectData( 357 this, 358 "object-removed", 359 cast(GCallback)&callBackObjectRemoved, 360 cast(void*)wrapper, 361 cast(GClosureNotify)&callBackObjectRemovedDestroy, 362 connectFlags); 363 return wrapper.handlerId; 364 } 365 366 extern(C) static void callBackObjectRemoved(GDBusObjectManager* dbusobjectmanagerStruct, GDBusObject* object, OnObjectRemovedDelegateWrapper wrapper) 367 { 368 wrapper.dlg(ObjectG.getDObject!(DBusObject, DBusObjectIF)(object), wrapper.outer); 369 } 370 371 extern(C) static void callBackObjectRemovedDestroy(OnObjectRemovedDelegateWrapper wrapper, GClosure* closure) 372 { 373 wrapper.remove(wrapper); 374 } 375 }