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