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