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.DBusObjectSkeleton; 26 27 private import gio.DBusInterfaceSkeleton; 28 private import gio.DBusMethodInvocation; 29 private import gio.DBusObjectIF; 30 private import gio.DBusObjectT; 31 private import glib.ConstructionException; 32 private import glib.Str; 33 private import gobject.ObjectG; 34 private import gobject.Signals; 35 public import gtkc.gdktypes; 36 private import gtkc.gio; 37 public import gtkc.giotypes; 38 39 40 /** 41 * A #GDBusObjectSkeleton instance is essentially a group of D-Bus 42 * interfaces. The set of exported interfaces on the object may be 43 * dynamic and change at runtime. 44 * 45 * This type is intended to be used with #GDBusObjectManager. 46 * 47 * Since: 2.30 48 */ 49 public class DBusObjectSkeleton : ObjectG, DBusObjectIF 50 { 51 /** the main Gtk struct */ 52 protected GDBusObjectSkeleton* gDBusObjectSkeleton; 53 54 /** Get the main Gtk struct */ 55 public GDBusObjectSkeleton* getDBusObjectSkeletonStruct() 56 { 57 return gDBusObjectSkeleton; 58 } 59 60 /** the main Gtk struct as a void* */ 61 protected override void* getStruct() 62 { 63 return cast(void*)gDBusObjectSkeleton; 64 } 65 66 protected override void setStruct(GObject* obj) 67 { 68 gDBusObjectSkeleton = cast(GDBusObjectSkeleton*)obj; 69 super.setStruct(obj); 70 } 71 72 /** 73 * Sets our main struct and passes it to the parent class. 74 */ 75 public this (GDBusObjectSkeleton* gDBusObjectSkeleton, bool ownedRef = false) 76 { 77 this.gDBusObjectSkeleton = gDBusObjectSkeleton; 78 super(cast(GObject*)gDBusObjectSkeleton, ownedRef); 79 } 80 81 // add the DBusObject capabilities 82 mixin DBusObjectT!(GDBusObjectSkeleton); 83 84 85 /** */ 86 public static GType getType() 87 { 88 return g_dbus_object_skeleton_get_type(); 89 } 90 91 /** 92 * Creates a new #GDBusObjectSkeleton. 93 * 94 * Params: 95 * objectPath = An object path. 96 * 97 * Return: A #GDBusObjectSkeleton. Free with g_object_unref(). 98 * 99 * Since: 2.30 100 * 101 * Throws: ConstructionException GTK+ fails to create the object. 102 */ 103 public this(string objectPath) 104 { 105 auto p = g_dbus_object_skeleton_new(Str.toStringz(objectPath)); 106 107 if(p is null) 108 { 109 throw new ConstructionException("null returned by new"); 110 } 111 112 this(cast(GDBusObjectSkeleton*) p, true); 113 } 114 115 /** 116 * Adds @interface_ to @object. 117 * 118 * If @object already contains a #GDBusInterfaceSkeleton with the same 119 * interface name, it is removed before @interface_ is added. 120 * 121 * Note that @object takes its own reference on @interface_ and holds 122 * it until removed. 123 * 124 * Params: 125 * iface = A #GDBusInterfaceSkeleton. 126 * 127 * Since: 2.30 128 */ 129 public void addInterface(DBusInterfaceSkeleton iface) 130 { 131 g_dbus_object_skeleton_add_interface(gDBusObjectSkeleton, (iface is null) ? null : iface.getDBusInterfaceSkeletonStruct()); 132 } 133 134 /** 135 * This method simply calls g_dbus_interface_skeleton_flush() on all 136 * interfaces belonging to @object. See that method for when flushing 137 * is useful. 138 * 139 * Since: 2.30 140 */ 141 public void flush() 142 { 143 g_dbus_object_skeleton_flush(gDBusObjectSkeleton); 144 } 145 146 /** 147 * Removes @interface_ from @object. 148 * 149 * Params: 150 * iface = A #GDBusInterfaceSkeleton. 151 * 152 * Since: 2.30 153 */ 154 public void removeInterface(DBusInterfaceSkeleton iface) 155 { 156 g_dbus_object_skeleton_remove_interface(gDBusObjectSkeleton, (iface is null) ? null : iface.getDBusInterfaceSkeletonStruct()); 157 } 158 159 /** 160 * Removes the #GDBusInterface with @interface_name from @object. 161 * 162 * If no D-Bus interface of the given interface exists, this function 163 * does nothing. 164 * 165 * Params: 166 * interfaceName = A D-Bus interface name. 167 * 168 * Since: 2.30 169 */ 170 public void removeInterfaceByName(string interfaceName) 171 { 172 g_dbus_object_skeleton_remove_interface_by_name(gDBusObjectSkeleton, Str.toStringz(interfaceName)); 173 } 174 175 /** 176 * Sets the object path for @object. 177 * 178 * Params: 179 * objectPath = A valid D-Bus object path. 180 * 181 * Since: 2.30 182 */ 183 public void setObjectPath(string objectPath) 184 { 185 g_dbus_object_skeleton_set_object_path(gDBusObjectSkeleton, Str.toStringz(objectPath)); 186 } 187 188 int[string] connectedSignals; 189 190 bool delegate(DBusInterfaceSkeleton, DBusMethodInvocation, DBusObjectSkeleton)[] onAuthorizeMethodListeners; 191 /** 192 * Emitted when a method is invoked by a remote caller and used to 193 * determine if the method call is authorized. 194 * 195 * This signal is like #GDBusInterfaceSkeleton's 196 * #GDBusInterfaceSkeleton::g-authorize-method signal, 197 * except that it is for the enclosing object. 198 * 199 * The default class handler just returns %TRUE. 200 * 201 * Params: 202 * iface = The #GDBusInterfaceSkeleton that @invocation is for. 203 * invocation = A #GDBusMethodInvocation. 204 * 205 * Return: %TRUE if the call is authorized, %FALSE otherwise. 206 * 207 * Since: 2.30 208 */ 209 void addOnAuthorizeMethod(bool delegate(DBusInterfaceSkeleton, DBusMethodInvocation, DBusObjectSkeleton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 210 { 211 if ( "authorize-method" !in connectedSignals ) 212 { 213 Signals.connectData( 214 this, 215 "authorize-method", 216 cast(GCallback)&callBackAuthorizeMethod, 217 cast(void*)this, 218 null, 219 connectFlags); 220 connectedSignals["authorize-method"] = 1; 221 } 222 onAuthorizeMethodListeners ~= dlg; 223 } 224 extern(C) static int callBackAuthorizeMethod(GDBusObjectSkeleton* dbusobjectskeletonStruct, GDBusInterfaceSkeleton* iface, GDBusMethodInvocation* invocation, DBusObjectSkeleton _dbusobjectskeleton) 225 { 226 foreach ( bool delegate(DBusInterfaceSkeleton, DBusMethodInvocation, DBusObjectSkeleton) dlg; _dbusobjectskeleton.onAuthorizeMethodListeners ) 227 { 228 if ( dlg(ObjectG.getDObject!(DBusInterfaceSkeleton)(iface), ObjectG.getDObject!(DBusMethodInvocation)(invocation), _dbusobjectskeleton) ) 229 { 230 return 1; 231 } 232 } 233 234 return 0; 235 } 236 }