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 
87 	public static GType getType()
88 	{
89 		return g_dbus_object_skeleton_get_type();
90 	}
91 
92 	/**
93 	 * Creates a new #GDBusObjectSkeleton.
94 	 *
95 	 * Params:
96 	 *     objectPath = An object path.
97 	 *
98 	 * Return: A #GDBusObjectSkeleton. Free with g_object_unref().
99 	 *
100 	 * Since: 2.30
101 	 *
102 	 * Throws: ConstructionException GTK+ fails to create the object.
103 	 */
104 	public this(string objectPath)
105 	{
106 		auto p = g_dbus_object_skeleton_new(Str.toStringz(objectPath));
107 		
108 		if(p is null)
109 		{
110 			throw new ConstructionException("null returned by new");
111 		}
112 		
113 		this(cast(GDBusObjectSkeleton*) p, true);
114 	}
115 
116 	/**
117 	 * Adds @interface_ to @object.
118 	 *
119 	 * If @object already contains a #GDBusInterfaceSkeleton with the same
120 	 * interface name, it is removed before @interface_ is added.
121 	 *
122 	 * Note that @object takes its own reference on @interface_ and holds
123 	 * it until removed.
124 	 *
125 	 * Params:
126 	 *     iface = A #GDBusInterfaceSkeleton.
127 	 *
128 	 * Since: 2.30
129 	 */
130 	public void addInterface(DBusInterfaceSkeleton iface)
131 	{
132 		g_dbus_object_skeleton_add_interface(gDBusObjectSkeleton, (iface is null) ? null : iface.getDBusInterfaceSkeletonStruct());
133 	}
134 
135 	/**
136 	 * This method simply calls g_dbus_interface_skeleton_flush() on all
137 	 * interfaces belonging to @object. See that method for when flushing
138 	 * is useful.
139 	 *
140 	 * Since: 2.30
141 	 */
142 	public void flush()
143 	{
144 		g_dbus_object_skeleton_flush(gDBusObjectSkeleton);
145 	}
146 
147 	/**
148 	 * Removes @interface_ from @object.
149 	 *
150 	 * Params:
151 	 *     iface = A #GDBusInterfaceSkeleton.
152 	 *
153 	 * Since: 2.30
154 	 */
155 	public void removeInterface(DBusInterfaceSkeleton iface)
156 	{
157 		g_dbus_object_skeleton_remove_interface(gDBusObjectSkeleton, (iface is null) ? null : iface.getDBusInterfaceSkeletonStruct());
158 	}
159 
160 	/**
161 	 * Removes the #GDBusInterface with @interface_name from @object.
162 	 *
163 	 * If no D-Bus interface of the given interface exists, this function
164 	 * does nothing.
165 	 *
166 	 * Params:
167 	 *     interfaceName = A D-Bus interface name.
168 	 *
169 	 * Since: 2.30
170 	 */
171 	public void removeInterfaceByName(string interfaceName)
172 	{
173 		g_dbus_object_skeleton_remove_interface_by_name(gDBusObjectSkeleton, Str.toStringz(interfaceName));
174 	}
175 
176 	/**
177 	 * Sets the object path for @object.
178 	 *
179 	 * Params:
180 	 *     objectPath = A valid D-Bus object path.
181 	 *
182 	 * Since: 2.30
183 	 */
184 	public void setObjectPath(string objectPath)
185 	{
186 		g_dbus_object_skeleton_set_object_path(gDBusObjectSkeleton, Str.toStringz(objectPath));
187 	}
188 
189 	int[string] connectedSignals;
190 
191 	bool delegate(DBusInterfaceSkeleton, DBusMethodInvocation, DBusObjectSkeleton)[] onAuthorizeMethodListeners;
192 	/**
193 	 * Emitted when a method is invoked by a remote caller and used to
194 	 * determine if the method call is authorized.
195 	 *
196 	 * This signal is like #GDBusInterfaceSkeleton's
197 	 * #GDBusInterfaceSkeleton::g-authorize-method signal,
198 	 * except that it is for the enclosing object.
199 	 *
200 	 * The default class handler just returns %TRUE.
201 	 *
202 	 * Params:
203 	 *     iface = The #GDBusInterfaceSkeleton that @invocation is for.
204 	 *     invocation = A #GDBusMethodInvocation.
205 	 *
206 	 * Return: %TRUE if the call is authorized, %FALSE otherwise.
207 	 *
208 	 * Since: 2.30
209 	 */
210 	void addOnAuthorizeMethod(bool delegate(DBusInterfaceSkeleton, DBusMethodInvocation, DBusObjectSkeleton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
211 	{
212 		if ( "authorize-method" !in connectedSignals )
213 		{
214 			Signals.connectData(
215 				this,
216 				"authorize-method",
217 				cast(GCallback)&callBackAuthorizeMethod,
218 				cast(void*)this,
219 				null,
220 				connectFlags);
221 			connectedSignals["authorize-method"] = 1;
222 		}
223 		onAuthorizeMethodListeners ~= dlg;
224 	}
225 	extern(C) static int callBackAuthorizeMethod(GDBusObjectSkeleton* dbusobjectskeletonStruct, GDBusInterfaceSkeleton* iface, GDBusMethodInvocation* invocation, DBusObjectSkeleton _dbusobjectskeleton)
226 	{
227 		foreach ( bool delegate(DBusInterfaceSkeleton, DBusMethodInvocation, DBusObjectSkeleton) dlg; _dbusobjectskeleton.onAuthorizeMethodListeners )
228 		{
229 			if ( dlg(ObjectG.getDObject!(DBusInterfaceSkeleton)(iface), ObjectG.getDObject!(DBusMethodInvocation)(invocation), _dbusobjectskeleton) )
230 			{
231 				return 1;
232 			}
233 		}
234 		
235 		return 0;
236 	}
237 }