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