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