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  = GPermission.html
27  * outPack = gio
28  * outFile = Permission
29  * strct   = GPermission
30  * realStrct=
31  * ctorStrct=
32  * clss    = Permission
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_permission_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ErrorG
48  * 	- glib.GException
49  * 	- gio.AsyncResultIF
50  * 	- gio.Cancellable
51  * structWrap:
52  * 	- GAsyncResult* -> AsyncResultIF
53  * 	- GCancellable* -> Cancellable
54  * module aliases:
55  * local aliases:
56  * overrides:
57  */
58 
59 module gio.Permission;
60 
61 public  import gtkc.giotypes;
62 
63 private import gtkc.gio;
64 private import glib.ConstructionException;
65 private import gobject.ObjectG;
66 
67 private import glib.Str;
68 private import glib.ErrorG;
69 private import glib.GException;
70 private import gio.AsyncResultIF;
71 private import gio.Cancellable;
72 
73 
74 private import gobject.ObjectG;
75 
76 /**
77  * A GPermission represents the status of the caller's permission to
78  * perform a certain action.
79  *
80  * You can query if the action is currently allowed and if it is
81  * possible to acquire the permission so that the action will be allowed
82  * in the future.
83  *
84  * There is also an API to actually acquire the permission and one to
85  * release it.
86  *
87  * As an example, a GPermission might represent the ability for the
88  * user to write to a GSettings object. This GPermission object could
89  * then be used to decide if it is appropriate to show a "Click here to
90  * unlock" button in a dialog and to provide the mechanism to invoke
91  * when that button is clicked.
92  */
93 public class Permission : ObjectG
94 {
95 	
96 	/** the main Gtk struct */
97 	protected GPermission* gPermission;
98 	
99 	
100 	/** Get the main Gtk struct */
101 	public GPermission* getPermissionStruct()
102 	{
103 		return gPermission;
104 	}
105 	
106 	
107 	/** the main Gtk struct as a void* */
108 	protected override void* getStruct()
109 	{
110 		return cast(void*)gPermission;
111 	}
112 	
113 	/**
114 	 * Sets our main struct and passes it to the parent class
115 	 */
116 	public this (GPermission* gPermission)
117 	{
118 		super(cast(GObject*)gPermission);
119 		this.gPermission = gPermission;
120 	}
121 	
122 	protected override void setStruct(GObject* obj)
123 	{
124 		super.setStruct(obj);
125 		gPermission = cast(GPermission*)obj;
126 	}
127 	
128 	/**
129 	 */
130 	
131 	/**
132 	 * Gets the value of the 'allowed' property. This property is TRUE if
133 	 * the caller currently has permission to perform the action that
134 	 * permission represents the permission to perform.
135 	 * Since 2.26
136 	 * Returns: the value of the 'allowed' property
137 	 */
138 	public int getAllowed()
139 	{
140 		// gboolean g_permission_get_allowed (GPermission *permission);
141 		return g_permission_get_allowed(gPermission);
142 	}
143 	
144 	/**
145 	 * Gets the value of the 'can-acquire' property. This property is TRUE
146 	 * if it is generally possible to acquire the permission by calling
147 	 * g_permission_acquire().
148 	 * Since 2.26
149 	 * Returns: the value of the 'can-acquire' property
150 	 */
151 	public int getCanAcquire()
152 	{
153 		// gboolean g_permission_get_can_acquire (GPermission *permission);
154 		return g_permission_get_can_acquire(gPermission);
155 	}
156 	
157 	/**
158 	 * Gets the value of the 'can-release' property. This property is TRUE
159 	 * if it is generally possible to release the permission by calling
160 	 * g_permission_release().
161 	 * Since 2.26
162 	 * Returns: the value of the 'can-release' property
163 	 */
164 	public int getCanRelease()
165 	{
166 		// gboolean g_permission_get_can_release (GPermission *permission);
167 		return g_permission_get_can_release(gPermission);
168 	}
169 	
170 	/**
171 	 * Attempts to acquire the permission represented by permission.
172 	 * The precise method by which this happens depends on the permission
173 	 * and the underlying authentication mechanism. A simple example is
174 	 * that a dialog may appear asking the user to enter their password.
175 	 * You should check with g_permission_get_can_acquire() before calling
176 	 * this function.
177 	 * If the permission is acquired then TRUE is returned. Otherwise,
178 	 * FALSE is returned and error is set appropriately.
179 	 * This call is blocking, likely for a very long time (in the case that
180 	 * user interaction is required). See g_permission_acquire_async() for
181 	 * the non-blocking version.
182 	 * Since 2.26
183 	 * Params:
184 	 * cancellable = a GCancellable, or NULL. [allow-none]
185 	 * Returns: TRUE if the permission was successfully acquired
186 	 * Throws: GException on failure.
187 	 */
188 	public int acquire(Cancellable cancellable)
189 	{
190 		// gboolean g_permission_acquire (GPermission *permission,  GCancellable *cancellable,  GError **error);
191 		GError* err = null;
192 		
193 		auto p = g_permission_acquire(gPermission, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
194 		
195 		if (err !is null)
196 		{
197 			throw new GException( new ErrorG(err) );
198 		}
199 		
200 		return p;
201 	}
202 	
203 	/**
204 	 * Attempts to acquire the permission represented by permission.
205 	 * This is the first half of the asynchronous version of
206 	 * g_permission_acquire().
207 	 * Since 2.26
208 	 * Params:
209 	 * cancellable = a GCancellable, or NULL. [allow-none]
210 	 * callback = the GAsyncReadyCallback to call when done
211 	 * userData = the user data to pass to callback
212 	 */
213 	public void acquireAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
214 	{
215 		// void g_permission_acquire_async (GPermission *permission,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
216 		g_permission_acquire_async(gPermission, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
217 	}
218 	
219 	/**
220 	 * Collects the result of attempting to acquire the permission
221 	 * represented by permission.
222 	 * This is the second half of the asynchronous version of
223 	 * g_permission_acquire().
224 	 * Since 2.26
225 	 * Params:
226 	 * result = the GAsyncResult given to the GAsyncReadyCallback
227 	 * Returns: TRUE if the permission was successfully acquired
228 	 * Throws: GException on failure.
229 	 */
230 	public int acquireFinish(AsyncResultIF result)
231 	{
232 		// gboolean g_permission_acquire_finish (GPermission *permission,  GAsyncResult *result,  GError **error);
233 		GError* err = null;
234 		
235 		auto p = g_permission_acquire_finish(gPermission, (result is null) ? null : result.getAsyncResultTStruct(), &err);
236 		
237 		if (err !is null)
238 		{
239 			throw new GException( new ErrorG(err) );
240 		}
241 		
242 		return p;
243 	}
244 	
245 	/**
246 	 * Attempts to release the permission represented by permission.
247 	 * The precise method by which this happens depends on the permission
248 	 * and the underlying authentication mechanism. In most cases the
249 	 * permission will be dropped immediately without further action.
250 	 * You should check with g_permission_get_can_release() before calling
251 	 * this function.
252 	 * If the permission is released then TRUE is returned. Otherwise,
253 	 * FALSE is returned and error is set appropriately.
254 	 * This call is blocking, likely for a very long time (in the case that
255 	 * user interaction is required). See g_permission_release_async() for
256 	 * the non-blocking version.
257 	 * Since 2.26
258 	 * Params:
259 	 * cancellable = a GCancellable, or NULL. [allow-none]
260 	 * Returns: TRUE if the permission was successfully released
261 	 * Throws: GException on failure.
262 	 */
263 	public int release(Cancellable cancellable)
264 	{
265 		// gboolean g_permission_release (GPermission *permission,  GCancellable *cancellable,  GError **error);
266 		GError* err = null;
267 		
268 		auto p = g_permission_release(gPermission, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
269 		
270 		if (err !is null)
271 		{
272 			throw new GException( new ErrorG(err) );
273 		}
274 		
275 		return p;
276 	}
277 	
278 	/**
279 	 * Attempts to release the permission represented by permission.
280 	 * This is the first half of the asynchronous version of
281 	 * g_permission_release().
282 	 * Since 2.26
283 	 * Params:
284 	 * cancellable = a GCancellable, or NULL. [allow-none]
285 	 * callback = the GAsyncReadyCallback to call when done
286 	 * userData = the user data to pass to callback
287 	 */
288 	public void releaseAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
289 	{
290 		// void g_permission_release_async (GPermission *permission,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
291 		g_permission_release_async(gPermission, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
292 	}
293 	
294 	/**
295 	 * Collects the result of attempting to release the permission
296 	 * represented by permission.
297 	 * This is the second half of the asynchronous version of
298 	 * g_permission_release().
299 	 * Since 2.26
300 	 * Params:
301 	 * result = the GAsyncResult given to the GAsyncReadyCallback
302 	 * Returns: TRUE if the permission was successfully released
303 	 * Throws: GException on failure.
304 	 */
305 	public int releaseFinish(AsyncResultIF result)
306 	{
307 		// gboolean g_permission_release_finish (GPermission *permission,  GAsyncResult *result,  GError **error);
308 		GError* err = null;
309 		
310 		auto p = g_permission_release_finish(gPermission, (result is null) ? null : result.getAsyncResultTStruct(), &err);
311 		
312 		if (err !is null)
313 		{
314 			throw new GException( new ErrorG(err) );
315 		}
316 		
317 		return p;
318 	}
319 	
320 	/**
321 	 * This function is called by the GPermission implementation to update
322 	 * the properties of the permission. You should never call this
323 	 * function except from a GPermission implementation.
324 	 * GObject notify signals are generated, as appropriate.
325 	 * Since 2.26
326 	 * Params:
327 	 * allowed = the new value for the 'allowed' property
328 	 * canAcquire = the new value for the 'can-acquire' property
329 	 * canRelease = the new value for the 'can-release' property
330 	 */
331 	public void implUpdate(int allowed, int canAcquire, int canRelease)
332 	{
333 		// void g_permission_impl_update (GPermission *permission,  gboolean allowed,  gboolean can_acquire,  gboolean can_release);
334 		g_permission_impl_update(gPermission, allowed, canAcquire, canRelease);
335 	}
336 }