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