gi-gio-2.0.38: Gio bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gio.Objects.Permission

Contents

- Exported types
- Methods
  - acquire
  - acquireAsync
  - acquireFinish
  - getAllowed
  - getCanAcquire
  - getCanRelease
  - implUpdate
  - release
  - releaseAsync
  - releaseFinish
- Properties
  - allowed
  - canAcquire
  - canRelease

Description

A `GPermission` represents the status of the caller’s permission to perform a certain action.

You can query if the action is currently allowed and if it is possible to acquire the permission so that the action will be allowed in the future.

There is also an API to actually acquire the permission and one to release it.

As an example, a `GPermission` might represent the ability for the user to write to a `Settings` object. This `GPermission` object could then be used to decide if it is appropriate to show a “Click here to unlock” button in a dialog and to provide the mechanism to invoke when that button is clicked.

Synopsis

- newtype Permission = Permission (ManagedPtr Permission)
- class (GObject o, IsDescendantOf Permission o) => IsPermission o
- toPermission :: (MonadIO m, IsPermission o) => o -> m Permission
- permissionAcquire :: (HasCallStack, MonadIO m, IsPermission a, IsCancellable b) => a -> Maybe b -> m ()
- permissionAcquireAsync :: (HasCallStack, MonadIO m, IsPermission a, IsCancellable b) => a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- permissionAcquireFinish :: (HasCallStack, MonadIO m, IsPermission a, IsAsyncResult b) => a -> b -> m ()
- permissionGetAllowed :: (HasCallStack, MonadIO m, IsPermission a) => a -> m Bool
- permissionGetCanAcquire :: (HasCallStack, MonadIO m, IsPermission a) => a -> m Bool
- permissionGetCanRelease :: (HasCallStack, MonadIO m, IsPermission a) => a -> m Bool
- permissionImplUpdate :: (HasCallStack, MonadIO m, IsPermission a) => a -> Bool -> Bool -> Bool -> m ()
- permissionRelease :: (HasCallStack, MonadIO m, IsPermission a, IsCancellable b) => a -> Maybe b -> m ()
- permissionReleaseAsync :: (HasCallStack, MonadIO m, IsPermission a, IsCancellable b) => a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
- permissionReleaseFinish :: (HasCallStack, MonadIO m, IsPermission a, IsAsyncResult b) => a -> b -> m ()
- getPermissionAllowed :: (MonadIO m, IsPermission o) => o -> m Bool
- getPermissionCanAcquire :: (MonadIO m, IsPermission o) => o -> m Bool
- getPermissionCanRelease :: (MonadIO m, IsPermission o) => o -> m Bool

# Exported types

newtype Permission Source #

Memory-managed wrapper type.

Constructors

Permission (ManagedPtr Permission) |

#### Instances

Instances details

Eq Permission Source # |
Instance details Defined in GI.Gio.Objects.Permission Methods (==) :: Permission -> Permission -> Bool Source # (/=) :: Permission -> Permission -> Bool Source #
GObject Permission Source # |
Instance details Defined in GI.Gio.Objects.Permission
ManagedPtrNewtype Permission Source # |
Instance details Defined in GI.Gio.Objects.Permission Methods toManagedPtr :: Permission -> ManagedPtr Permission Source #
TypedObject Permission Source # |
Instance details Defined in GI.Gio.Objects.Permission Methods glibType :: IO GType Source #
HasParentTypes Permission Source # |
Instance details Defined in GI.Gio.Objects.Permission
IsGValue (Maybe Permission) Source # | Convert `Permission` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gio.Objects.Permission Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Permission -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Permission) Source #
type ParentTypes Permission Source # |
Instance details Defined in GI.Gio.Objects.Permission type ParentTypes Permission = '[Object]

class (GObject o, IsDescendantOf Permission o) => IsPermission o Source #

Type class for types which can be safely cast to `Permission`, for instance with `toPermission`.

#### Instances

Instances details

(GObject o, IsDescendantOf Permission o) => IsPermission o Source # |
Instance details Defined in GI.Gio.Objects.Permission

toPermission :: (MonadIO m, IsPermission o) => o -> m Permission Source #

Cast to `Permission`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

acquire, acquireAsync, acquireFinish, bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, implUpdate, isFloating, notify, notifyByPspec, ref, refSink, release, releaseAsync, releaseFinish, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.

#### Getters

getAllowed, getCanAcquire, getCanRelease, getData, getProperty, getQdata.

#### Setters

setData, setDataFull, setProperty.

## acquire

permissionAcquire Source #

Arguments

:: (HasCallStack, MonadIO m, IsPermission a, IsCancellable b) |
=> a | `permission`: a `Permission` instance
-> Maybe b | `cancellable`: a `Cancellable`, or `Nothing`
-> m () | (Can throw `GError`)

Attempts to acquire the permission represented by `permission`.

The precise method by which this happens depends on the permission and the underlying authentication mechanism. A simple example is that a dialog may appear asking the user to enter their password.

You should check with `permissionGetCanAcquire` before calling this function.

If the permission is acquired then `True` is returned. Otherwise, `False` is returned and `error` is set appropriately.

This call is blocking, likely for a very long time (in the case that user interaction is required). See `permissionAcquireAsync` for the non-blocking version.

Since: 2.26

## acquireAsync

permissionAcquireAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsPermission a, IsCancellable b) |
=> a | `permission`: a `Permission` instance
-> Maybe b | `cancellable`: a `Cancellable`, or `Nothing`
-> Maybe AsyncReadyCallback | `callback`: the `AsyncReadyCallback` to call when done
-> m () |

Attempts to acquire the permission represented by `permission`.

This is the first half of the asynchronous version of `permissionAcquire`.

Since: 2.26

## acquireFinish

permissionAcquireFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsPermission a, IsAsyncResult b) |
=> a | `permission`: a `Permission` instance
-> b | `result`: the `AsyncResult` given to the `AsyncReadyCallback`
-> m () | (Can throw `GError`)

Collects the result of attempting to acquire the permission represented by `permission`.

This is the second half of the asynchronous version of `permissionAcquire`.

Since: 2.26

## getAllowed

permissionGetAllowed Source #

Arguments

:: (HasCallStack, MonadIO m, IsPermission a) |
=> a | `permission`: a `Permission` instance
-> m Bool | Returns: the value of the 'allowed' property

Gets the value of the 'allowed' property. This property is `True` if the caller currently has permission to perform the action that `permission` represents the permission to perform.

Since: 2.26

## getCanAcquire

permissionGetCanAcquire Source #

Arguments

:: (HasCallStack, MonadIO m, IsPermission a) |
=> a | `permission`: a `Permission` instance
-> m Bool | Returns: the value of the 'can-acquire' property

Gets the value of the 'can-acquire' property. This property is `True` if it is generally possible to acquire the permission by calling `permissionAcquire`.

Since: 2.26

## getCanRelease

permissionGetCanRelease Source #

Arguments

:: (HasCallStack, MonadIO m, IsPermission a) |
=> a | `permission`: a `Permission` instance
-> m Bool | Returns: the value of the 'can-release' property

Gets the value of the 'can-release' property. This property is `True` if it is generally possible to release the permission by calling `permissionRelease`.

Since: 2.26

## implUpdate

permissionImplUpdate Source #

Arguments

:: (HasCallStack, MonadIO m, IsPermission a) |
=> a | `permission`: a `Permission` instance
-> Bool | `allowed`: the new value for the 'allowed' property
-> Bool | `canAcquire`: the new value for the 'can-acquire' property
-> Bool | `canRelease`: the new value for the 'can-release' property
-> m () |

This function is called by the `Permission` implementation to update the properties of the permission. You should never call this function except from a `Permission` implementation.

GObject notify signals are generated, as appropriate.

Since: 2.26

## release

permissionRelease Source #

Arguments

:: (HasCallStack, MonadIO m, IsPermission a, IsCancellable b) |
=> a | `permission`: a `Permission` instance
-> Maybe b | `cancellable`: a `Cancellable`, or `Nothing`
-> m () | (Can throw `GError`)

Attempts to release the permission represented by `permission`.

The precise method by which this happens depends on the permission and the underlying authentication mechanism. In most cases the permission will be dropped immediately without further action.

You should check with `permissionGetCanRelease` before calling this function.

If the permission is released then `True` is returned. Otherwise, `False` is returned and `error` is set appropriately.

This call is blocking, likely for a very long time (in the case that user interaction is required). See `permissionReleaseAsync` for the non-blocking version.

Since: 2.26

## releaseAsync

permissionReleaseAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsPermission a, IsCancellable b) |
=> a | `permission`: a `Permission` instance
-> Maybe b | `cancellable`: a `Cancellable`, or `Nothing`
-> Maybe AsyncReadyCallback | `callback`: the `AsyncReadyCallback` to call when done
-> m () |

Attempts to release the permission represented by `permission`.

This is the first half of the asynchronous version of `permissionRelease`.

Since: 2.26

## releaseFinish

permissionReleaseFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsPermission a, IsAsyncResult b) |
=> a | `permission`: a `Permission` instance
-> b | `result`: the `AsyncResult` given to the `AsyncReadyCallback`
-> m () | (Can throw `GError`)

Collects the result of attempting to release the permission represented by `permission`.

This is the second half of the asynchronous version of `permissionRelease`.

Since: 2.26

# Properties

## allowed

`True` if the caller currently has permission to perform the action that `permission` represents the permission to perform.

getPermissionAllowed :: (MonadIO m, IsPermission o) => o -> m Bool Source #

Get the value of the “`allowed`” property. When overloading is enabled, this is equivalent to

    get permission #allowed

## canAcquire

`True` if it is generally possible to acquire the permission by calling `permissionAcquire`.

getPermissionCanAcquire :: (MonadIO m, IsPermission o) => o -> m Bool Source #

Get the value of the “`can-acquire`” property. When overloading is enabled, this is equivalent to

    get permission #canAcquire

## canRelease

`True` if it is generally possible to release the permission by calling `permissionRelease`.

getPermissionCanRelease :: (MonadIO m, IsPermission o) => o -> m Bool Source #

Get the value of the “`can-release`” property. When overloading is enabled, this is equivalent to

    get permission #canRelease