source: appstream-generator/build/girepo/gio/Permission.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 8.9 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.Permission;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.AsyncResultIF;
26private import gio.Cancellable;
27private import glib.ErrorG;
28private import glib.GException;
29private import gobject.ObjectG;
30
31
32/**
33 * A #GPermission represents the status of the caller's permission to
34 * perform a certain action.
35 *
36 * You can query if the action is currently allowed and if it is
37 * possible to acquire the permission so that the action will be allowed
38 * in the future.
39 *
40 * There is also an API to actually acquire the permission and one to
41 * release it.
42 *
43 * As an example, a #GPermission might represent the ability for the
44 * user to write to a #GSettings object.  This #GPermission object could
45 * then be used to decide if it is appropriate to show a "Click here to
46 * unlock" button in a dialog and to provide the mechanism to invoke
47 * when that button is clicked.
48 */
49public class Permission : ObjectG
50{
51        /** the main Gtk struct */
52        protected GPermission* gPermission;
53
54        /** Get the main Gtk struct */
55        public GPermission* getPermissionStruct()
56        {
57                return gPermission;
58        }
59
60        /** the main Gtk struct as a void* */
61        protected override void* getStruct()
62        {
63                return cast(void*)gPermission;
64        }
65
66        protected override void setStruct(GObject* obj)
67        {
68                gPermission = cast(GPermission*)obj;
69                super.setStruct(obj);
70        }
71
72        /**
73         * Sets our main struct and passes it to the parent class.
74         */
75        public this (GPermission* gPermission, bool ownedRef = false)
76        {
77                this.gPermission = gPermission;
78                super(cast(GObject*)gPermission, ownedRef);
79        }
80
81
82        /** */
83        public static GType getType()
84        {
85                return g_permission_get_type();
86        }
87
88        /**
89         * Attempts to acquire the permission represented by @permission.
90         *
91         * The precise method by which this happens depends on the permission
92         * and the underlying authentication mechanism.  A simple example is
93         * that a dialog may appear asking the user to enter their password.
94         *
95         * You should check with g_permission_get_can_acquire() before calling
96         * this function.
97         *
98         * If the permission is acquired then %TRUE is returned.  Otherwise,
99         * %FALSE is returned and @error is set appropriately.
100         *
101         * This call is blocking, likely for a very long time (in the case that
102         * user interaction is required).  See g_permission_acquire_async() for
103         * the non-blocking version.
104         *
105         * Params:
106         *     cancellable = a #GCancellable, or %NULL
107         *
108         * Returns: %TRUE if the permission was successfully acquired
109         *
110         * Since: 2.26
111         *
112         * Throws: GException on failure.
113         */
114        public bool acquire(Cancellable cancellable)
115        {
116                GError* err = null;
117               
118                auto p = g_permission_acquire(gPermission, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
119               
120                if (err !is null)
121                {
122                        throw new GException( new ErrorG(err) );
123                }
124               
125                return p;
126        }
127
128        /**
129         * Attempts to acquire the permission represented by @permission.
130         *
131         * This is the first half of the asynchronous version of
132         * g_permission_acquire().
133         *
134         * Params:
135         *     cancellable = a #GCancellable, or %NULL
136         *     callback = the #GAsyncReadyCallback to call when done
137         *     userData = the user data to pass to @callback
138         *
139         * Since: 2.26
140         */
141        public void acquireAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
142        {
143                g_permission_acquire_async(gPermission, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
144        }
145
146        /**
147         * Collects the result of attempting to acquire the permission
148         * represented by @permission.
149         *
150         * This is the second half of the asynchronous version of
151         * g_permission_acquire().
152         *
153         * Params:
154         *     result = the #GAsyncResult given to the #GAsyncReadyCallback
155         *
156         * Returns: %TRUE if the permission was successfully acquired
157         *
158         * Since: 2.26
159         *
160         * Throws: GException on failure.
161         */
162        public bool acquireFinish(AsyncResultIF result)
163        {
164                GError* err = null;
165               
166                auto p = g_permission_acquire_finish(gPermission, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
167               
168                if (err !is null)
169                {
170                        throw new GException( new ErrorG(err) );
171                }
172               
173                return p;
174        }
175
176        /**
177         * Gets the value of the 'allowed' property.  This property is %TRUE if
178         * the caller currently has permission to perform the action that
179         * @permission represents the permission to perform.
180         *
181         * Returns: the value of the 'allowed' property
182         *
183         * Since: 2.26
184         */
185        public bool getAllowed()
186        {
187                return g_permission_get_allowed(gPermission) != 0;
188        }
189
190        /**
191         * Gets the value of the 'can-acquire' property.  This property is %TRUE
192         * if it is generally possible to acquire the permission by calling
193         * g_permission_acquire().
194         *
195         * Returns: the value of the 'can-acquire' property
196         *
197         * Since: 2.26
198         */
199        public bool getCanAcquire()
200        {
201                return g_permission_get_can_acquire(gPermission) != 0;
202        }
203
204        /**
205         * Gets the value of the 'can-release' property.  This property is %TRUE
206         * if it is generally possible to release the permission by calling
207         * g_permission_release().
208         *
209         * Returns: the value of the 'can-release' property
210         *
211         * Since: 2.26
212         */
213        public bool getCanRelease()
214        {
215                return g_permission_get_can_release(gPermission) != 0;
216        }
217
218        /**
219         * This function is called by the #GPermission implementation to update
220         * the properties of the permission.  You should never call this
221         * function except from a #GPermission implementation.
222         *
223         * GObject notify signals are generated, as appropriate.
224         *
225         * Params:
226         *     allowed = the new value for the 'allowed' property
227         *     canAcquire = the new value for the 'can-acquire' property
228         *     canRelease = the new value for the 'can-release' property
229         *
230         * Since: 2.26
231         */
232        public void implUpdate(bool allowed, bool canAcquire, bool canRelease)
233        {
234                g_permission_impl_update(gPermission, allowed, canAcquire, canRelease);
235        }
236
237        /**
238         * Attempts to release the permission represented by @permission.
239         *
240         * The precise method by which this happens depends on the permission
241         * and the underlying authentication mechanism.  In most cases the
242         * permission will be dropped immediately without further action.
243         *
244         * You should check with g_permission_get_can_release() before calling
245         * this function.
246         *
247         * If the permission is released then %TRUE is returned.  Otherwise,
248         * %FALSE is returned and @error is set appropriately.
249         *
250         * This call is blocking, likely for a very long time (in the case that
251         * user interaction is required).  See g_permission_release_async() for
252         * the non-blocking version.
253         *
254         * Params:
255         *     cancellable = a #GCancellable, or %NULL
256         *
257         * Returns: %TRUE if the permission was successfully released
258         *
259         * Since: 2.26
260         *
261         * Throws: GException on failure.
262         */
263        public bool release(Cancellable cancellable)
264        {
265                GError* err = null;
266               
267                auto p = g_permission_release(gPermission, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0;
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         *
280         * This is the first half of the asynchronous version of
281         * g_permission_release().
282         *
283         * Params:
284         *     cancellable = a #GCancellable, or %NULL
285         *     callback = the #GAsyncReadyCallback to call when done
286         *     userData = the user data to pass to @callback
287         *
288         * Since: 2.26
289         */
290        public void releaseAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
291        {
292                g_permission_release_async(gPermission, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
293        }
294
295        /**
296         * Collects the result of attempting to release the permission
297         * represented by @permission.
298         *
299         * This is the second half of the asynchronous version of
300         * g_permission_release().
301         *
302         * Params:
303         *     result = the #GAsyncResult given to the #GAsyncReadyCallback
304         *
305         * Returns: %TRUE if the permission was successfully released
306         *
307         * Since: 2.26
308         *
309         * Throws: GException on failure.
310         */
311        public bool releaseFinish(AsyncResultIF result)
312        {
313                GError* err = null;
314               
315                auto p = g_permission_release_finish(gPermission, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0;
316               
317                if (err !is null)
318                {
319                        throw new GException( new ErrorG(err) );
320                }
321               
322                return p;
323        }
324}
Note: See TracBrowser for help on using the repository browser.