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.DBusInterfaceSkeleton;
26 
27 private import gio.DBusConnection;
28 private import gio.DBusInterfaceIF;
29 private import gio.DBusInterfaceInfo;
30 private import gio.DBusInterfaceT;
31 private import gio.DBusMethodInvocation;
32 private import gio.c.functions;
33 public  import gio.c.types;
34 private import glib.ErrorG;
35 private import glib.GException;
36 private import glib.ListG;
37 private import glib.Str;
38 private import glib.Variant;
39 private import gobject.ObjectG;
40 private import gobject.Signals;
41 public  import gtkc.giotypes;
42 private import std.algorithm;
43 
44 
45 /**
46  * Abstract base class for D-Bus interfaces on the service side.
47  *
48  * Since: 2.30
49  */
50 public class DBusInterfaceSkeleton : ObjectG, DBusInterfaceIF
51 {
52 	/** the main Gtk struct */
53 	protected GDBusInterfaceSkeleton* gDBusInterfaceSkeleton;
54 
55 	/** Get the main Gtk struct */
56 	public GDBusInterfaceSkeleton* getDBusInterfaceSkeletonStruct(bool transferOwnership = false)
57 	{
58 		if (transferOwnership)
59 			ownedRef = false;
60 		return gDBusInterfaceSkeleton;
61 	}
62 
63 	/** the main Gtk struct as a void* */
64 	protected override void* getStruct()
65 	{
66 		return cast(void*)gDBusInterfaceSkeleton;
67 	}
68 
69 	/**
70 	 * Sets our main struct and passes it to the parent class.
71 	 */
72 	public this (GDBusInterfaceSkeleton* gDBusInterfaceSkeleton, bool ownedRef = false)
73 	{
74 		this.gDBusInterfaceSkeleton = gDBusInterfaceSkeleton;
75 		super(cast(GObject*)gDBusInterfaceSkeleton, ownedRef);
76 	}
77 
78 	// add the DBusInterface capabilities
79 	mixin DBusInterfaceT!(GDBusInterfaceSkeleton);
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return g_dbus_interface_skeleton_get_type();
86 	}
87 
88 	/**
89 	 * Exports @interface_ at @object_path on @connection.
90 	 *
91 	 * This can be called multiple times to export the same @interface_
92 	 * onto multiple connections however the @object_path provided must be
93 	 * the same for all connections.
94 	 *
95 	 * Use g_dbus_interface_skeleton_unexport() to unexport the object.
96 	 *
97 	 * Params:
98 	 *     connection = A #GDBusConnection to export @interface_ on.
99 	 *     objectPath = The path to export the interface at.
100 	 *
101 	 * Returns: %TRUE if the interface was exported on @connection, otherwise %FALSE with
102 	 *     @error set.
103 	 *
104 	 * Since: 2.30
105 	 *
106 	 * Throws: GException on failure.
107 	 */
108 	public bool expor(DBusConnection connection, string objectPath)
109 	{
110 		GError* err = null;
111 
112 		auto p = g_dbus_interface_skeleton_export(gDBusInterfaceSkeleton, (connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(objectPath), &err) != 0;
113 
114 		if (err !is null)
115 		{
116 			throw new GException( new ErrorG(err) );
117 		}
118 
119 		return p;
120 	}
121 
122 	/**
123 	 * If @interface_ has outstanding changes, request for these changes to be
124 	 * emitted immediately.
125 	 *
126 	 * For example, an exported D-Bus interface may queue up property
127 	 * changes and emit the
128 	 * `org.freedesktop.DBus.Properties.PropertiesChanged`
129 	 * signal later (e.g. in an idle handler). This technique is useful
130 	 * for collapsing multiple property changes into one.
131 	 *
132 	 * Since: 2.30
133 	 */
134 	public void flush()
135 	{
136 		g_dbus_interface_skeleton_flush(gDBusInterfaceSkeleton);
137 	}
138 
139 	/**
140 	 * Gets the first connection that @interface_ is exported on, if any.
141 	 *
142 	 * Returns: A #GDBusConnection or %NULL if @interface_ is
143 	 *     not exported anywhere. Do not free, the object belongs to @interface_.
144 	 *
145 	 * Since: 2.30
146 	 */
147 	public DBusConnection getConnection()
148 	{
149 		auto p = g_dbus_interface_skeleton_get_connection(gDBusInterfaceSkeleton);
150 
151 		if(p is null)
152 		{
153 			return null;
154 		}
155 
156 		return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p);
157 	}
158 
159 	/**
160 	 * Gets a list of the connections that @interface_ is exported on.
161 	 *
162 	 * Returns: A list of
163 	 *     all the connections that @interface_ is exported on. The returned
164 	 *     list should be freed with g_list_free() after each element has
165 	 *     been freed with g_object_unref().
166 	 *
167 	 * Since: 2.32
168 	 */
169 	public ListG getConnections()
170 	{
171 		auto p = g_dbus_interface_skeleton_get_connections(gDBusInterfaceSkeleton);
172 
173 		if(p is null)
174 		{
175 			return null;
176 		}
177 
178 		return new ListG(cast(GList*) p, true);
179 	}
180 
181 	/**
182 	 * Gets the #GDBusInterfaceSkeletonFlags that describes what the behavior
183 	 * of @interface_
184 	 *
185 	 * Returns: One or more flags from the #GDBusInterfaceSkeletonFlags enumeration.
186 	 *
187 	 * Since: 2.30
188 	 */
189 	public GDBusInterfaceSkeletonFlags getFlags()
190 	{
191 		return g_dbus_interface_skeleton_get_flags(gDBusInterfaceSkeleton);
192 	}
193 
194 	/**
195 	 * Gets D-Bus introspection information for the D-Bus interface
196 	 * implemented by @interface_.
197 	 *
198 	 * Returns: A #GDBusInterfaceInfo (never %NULL). Do not free.
199 	 *
200 	 * Since: 2.30
201 	 */
202 	public DBusInterfaceInfo getInfo()
203 	{
204 		auto p = g_dbus_interface_skeleton_get_info(gDBusInterfaceSkeleton);
205 
206 		if(p is null)
207 		{
208 			return null;
209 		}
210 
211 		return ObjectG.getDObject!(DBusInterfaceInfo)(cast(GDBusInterfaceInfo*) p);
212 	}
213 
214 	/**
215 	 * Gets the object path that @interface_ is exported on, if any.
216 	 *
217 	 * Returns: A string owned by @interface_ or %NULL if @interface_ is not exported
218 	 *     anywhere. Do not free, the string belongs to @interface_.
219 	 *
220 	 * Since: 2.30
221 	 */
222 	public string getObjectPath()
223 	{
224 		return Str.toString(g_dbus_interface_skeleton_get_object_path(gDBusInterfaceSkeleton));
225 	}
226 
227 	/**
228 	 * Gets all D-Bus properties for @interface_.
229 	 *
230 	 * Returns: A #GVariant of type
231 	 *     ['a{sv}'][G-VARIANT-TYPE-VARDICT:CAPS].
232 	 *     Free with g_variant_unref().
233 	 *
234 	 * Since: 2.30
235 	 */
236 	public Variant getProperties()
237 	{
238 		auto p = g_dbus_interface_skeleton_get_properties(gDBusInterfaceSkeleton);
239 
240 		if(p is null)
241 		{
242 			return null;
243 		}
244 
245 		return new Variant(cast(GVariant*) p, true);
246 	}
247 
248 	/**
249 	 * Gets the interface vtable for the D-Bus interface implemented by
250 	 * @interface_. The returned function pointers should expect @interface_
251 	 * itself to be passed as @user_data.
252 	 *
253 	 * Returns: A #GDBusInterfaceVTable (never %NULL).
254 	 *
255 	 * Since: 2.30
256 	 */
257 	public GDBusInterfaceVTable* getVtable()
258 	{
259 		return g_dbus_interface_skeleton_get_vtable(gDBusInterfaceSkeleton);
260 	}
261 
262 	/**
263 	 * Checks if @interface_ is exported on @connection.
264 	 *
265 	 * Params:
266 	 *     connection = A #GDBusConnection.
267 	 *
268 	 * Returns: %TRUE if @interface_ is exported on @connection, %FALSE otherwise.
269 	 *
270 	 * Since: 2.32
271 	 */
272 	public bool hasConnection(DBusConnection connection)
273 	{
274 		return g_dbus_interface_skeleton_has_connection(gDBusInterfaceSkeleton, (connection is null) ? null : connection.getDBusConnectionStruct()) != 0;
275 	}
276 
277 	/**
278 	 * Sets flags describing what the behavior of @skeleton should be.
279 	 *
280 	 * Params:
281 	 *     flags = Flags from the #GDBusInterfaceSkeletonFlags enumeration.
282 	 *
283 	 * Since: 2.30
284 	 */
285 	public void setFlags(GDBusInterfaceSkeletonFlags flags)
286 	{
287 		g_dbus_interface_skeleton_set_flags(gDBusInterfaceSkeleton, flags);
288 	}
289 
290 	/**
291 	 * Stops exporting @interface_ on all connections it is exported on.
292 	 *
293 	 * To unexport @interface_ from only a single connection, use
294 	 * g_dbus_interface_skeleton_unexport_from_connection()
295 	 *
296 	 * Since: 2.30
297 	 */
298 	public void unexport()
299 	{
300 		g_dbus_interface_skeleton_unexport(gDBusInterfaceSkeleton);
301 	}
302 
303 	/**
304 	 * Stops exporting @interface_ on @connection.
305 	 *
306 	 * To stop exporting on all connections the interface is exported on,
307 	 * use g_dbus_interface_skeleton_unexport().
308 	 *
309 	 * Params:
310 	 *     connection = A #GDBusConnection.
311 	 *
312 	 * Since: 2.32
313 	 */
314 	public void unexportFromConnection(DBusConnection connection)
315 	{
316 		g_dbus_interface_skeleton_unexport_from_connection(gDBusInterfaceSkeleton, (connection is null) ? null : connection.getDBusConnectionStruct());
317 	}
318 
319 	/**
320 	 * Emitted when a method is invoked by a remote caller and used to
321 	 * determine if the method call is authorized.
322 	 *
323 	 * Note that this signal is emitted in a thread dedicated to
324 	 * handling the method call so handlers are allowed to perform
325 	 * blocking IO. This means that it is appropriate to call e.g.
326 	 * [polkit_authority_check_authorization_sync()](http://hal.freedesktop.org/docs/polkit/PolkitAuthority.html#polkit-authority-check-authorization-sync)
327 	 * with the
328 	 * [POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION](http://hal.freedesktop.org/docs/polkit/PolkitAuthority.html#POLKIT-CHECK-AUTHORIZATION-FLAGS-ALLOW-USER-INTERACTION:CAPS)
329 	 * flag set.
330 	 *
331 	 * If %FALSE is returned then no further handlers are run and the
332 	 * signal handler must take a reference to @invocation and finish
333 	 * handling the call (e.g. return an error via
334 	 * g_dbus_method_invocation_return_error()).
335 	 *
336 	 * Otherwise, if %TRUE is returned, signal emission continues. If no
337 	 * handlers return %FALSE, then the method is dispatched. If
338 	 * @interface has an enclosing #GDBusObjectSkeleton, then the
339 	 * #GDBusObjectSkeleton::authorize-method signal handlers run before
340 	 * the handlers for this signal.
341 	 *
342 	 * The default class handler just returns %TRUE.
343 	 *
344 	 * Please note that the common case is optimized: if no signals
345 	 * handlers are connected and the default class handler isn't
346 	 * overridden (for both @interface and the enclosing
347 	 * #GDBusObjectSkeleton, if any) and #GDBusInterfaceSkeleton:g-flags does
348 	 * not have the
349 	 * %G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD
350 	 * flags set, no dedicated thread is ever used and the call will be
351 	 * handled in the same thread as the object that @interface belongs
352 	 * to was exported in.
353 	 *
354 	 * Params:
355 	 *     invocation = A #GDBusMethodInvocation.
356 	 *
357 	 * Returns: %TRUE if the call is authorized, %FALSE otherwise.
358 	 *
359 	 * Since: 2.30
360 	 */
361 	gulong addOnGAuthorizeMethod(bool delegate(DBusMethodInvocation, DBusInterfaceSkeleton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
362 	{
363 		return Signals.connect(this, "g-authorize-method", dlg, connectFlags ^ ConnectFlags.SWAPPED);
364 	}
365 }