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