{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Objects.Permission
    ( 
    Permission(..)                          ,
    IsPermission                            ,
    toPermission                            ,
    noPermission                            ,
 
#if defined(ENABLE_OVERLOADING)
    ResolvePermissionMethod                 ,
#endif
#if defined(ENABLE_OVERLOADING)
    PermissionAcquireMethodInfo             ,
#endif
    permissionAcquire                       ,
#if defined(ENABLE_OVERLOADING)
    PermissionAcquireAsyncMethodInfo        ,
#endif
    permissionAcquireAsync                  ,
#if defined(ENABLE_OVERLOADING)
    PermissionAcquireFinishMethodInfo       ,
#endif
    permissionAcquireFinish                 ,
#if defined(ENABLE_OVERLOADING)
    PermissionGetAllowedMethodInfo          ,
#endif
    permissionGetAllowed                    ,
#if defined(ENABLE_OVERLOADING)
    PermissionGetCanAcquireMethodInfo       ,
#endif
    permissionGetCanAcquire                 ,
#if defined(ENABLE_OVERLOADING)
    PermissionGetCanReleaseMethodInfo       ,
#endif
    permissionGetCanRelease                 ,
#if defined(ENABLE_OVERLOADING)
    PermissionImplUpdateMethodInfo          ,
#endif
    permissionImplUpdate                    ,
#if defined(ENABLE_OVERLOADING)
    PermissionReleaseMethodInfo             ,
#endif
    permissionRelease                       ,
#if defined(ENABLE_OVERLOADING)
    PermissionReleaseAsyncMethodInfo        ,
#endif
    permissionReleaseAsync                  ,
#if defined(ENABLE_OVERLOADING)
    PermissionReleaseFinishMethodInfo       ,
#endif
    permissionReleaseFinish                 ,
 
#if defined(ENABLE_OVERLOADING)
    PermissionAllowedPropertyInfo           ,
#endif
    getPermissionAllowed                    ,
#if defined(ENABLE_OVERLOADING)
    permissionAllowed                       ,
#endif
#if defined(ENABLE_OVERLOADING)
    PermissionCanAcquirePropertyInfo        ,
#endif
    getPermissionCanAcquire                 ,
#if defined(ENABLE_OVERLOADING)
    permissionCanAcquire                    ,
#endif
#if defined(ENABLE_OVERLOADING)
    PermissionCanReleasePropertyInfo        ,
#endif
    getPermissionCanRelease                 ,
#if defined(ENABLE_OVERLOADING)
    permissionCanRelease                    ,
#endif
    ) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
newtype Permission = Permission (ManagedPtr Permission)
    deriving (Permission -> Permission -> Bool
(Permission -> Permission -> Bool)
-> (Permission -> Permission -> Bool) -> Eq Permission
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Permission -> Permission -> Bool
$c/= :: Permission -> Permission -> Bool
== :: Permission -> Permission -> Bool
$c== :: Permission -> Permission -> Bool
Eq)
foreign import ccall "g_permission_get_type"
    c_g_permission_get_type :: IO GType
instance GObject Permission where
    gobjectType :: IO GType
gobjectType = IO GType
c_g_permission_get_type
    
instance B.GValue.IsGValue Permission where
    toGValue :: Permission -> IO GValue
toGValue o :: Permission
o = do
        GType
gtype <- IO GType
c_g_permission_get_type
        Permission -> (Ptr Permission -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Permission
o (GType
-> (GValue -> Ptr Permission -> IO ())
-> Ptr Permission
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Permission -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO Permission
fromGValue gv :: GValue
gv = do
        Ptr Permission
ptr <- GValue -> IO (Ptr Permission)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr Permission)
        (ManagedPtr Permission -> Permission)
-> Ptr Permission -> IO Permission
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Permission -> Permission
Permission Ptr Permission
ptr
        
    
class (GObject o, O.IsDescendantOf Permission o) => IsPermission o
instance (GObject o, O.IsDescendantOf Permission o) => IsPermission o
instance O.HasParentTypes Permission
type instance O.ParentTypes Permission = '[GObject.Object.Object]
toPermission :: (MonadIO m, IsPermission o) => o -> m Permission
toPermission :: o -> m Permission
toPermission = IO Permission -> m Permission
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Permission -> m Permission)
-> (o -> IO Permission) -> o -> m Permission
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Permission -> Permission) -> o -> IO Permission
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Permission -> Permission
Permission
noPermission :: Maybe Permission
noPermission :: Maybe Permission
noPermission = Maybe Permission
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolvePermissionMethod (t :: Symbol) (o :: *) :: * where
    ResolvePermissionMethod "acquire" o = PermissionAcquireMethodInfo
    ResolvePermissionMethod "acquireAsync" o = PermissionAcquireAsyncMethodInfo
    ResolvePermissionMethod "acquireFinish" o = PermissionAcquireFinishMethodInfo
    ResolvePermissionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolvePermissionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolvePermissionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolvePermissionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolvePermissionMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolvePermissionMethod "implUpdate" o = PermissionImplUpdateMethodInfo
    ResolvePermissionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolvePermissionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolvePermissionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolvePermissionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolvePermissionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolvePermissionMethod "release" o = PermissionReleaseMethodInfo
    ResolvePermissionMethod "releaseAsync" o = PermissionReleaseAsyncMethodInfo
    ResolvePermissionMethod "releaseFinish" o = PermissionReleaseFinishMethodInfo
    ResolvePermissionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolvePermissionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolvePermissionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolvePermissionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolvePermissionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolvePermissionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolvePermissionMethod "getAllowed" o = PermissionGetAllowedMethodInfo
    ResolvePermissionMethod "getCanAcquire" o = PermissionGetCanAcquireMethodInfo
    ResolvePermissionMethod "getCanRelease" o = PermissionGetCanReleaseMethodInfo
    ResolvePermissionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolvePermissionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolvePermissionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolvePermissionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolvePermissionMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolvePermissionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolvePermissionMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolvePermissionMethod t Permission, O.MethodInfo info Permission p) => OL.IsLabel t (Permission -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif
#endif
   
   
   
getPermissionAllowed :: (MonadIO m, IsPermission o) => o -> m Bool
getPermissionAllowed :: o -> m Bool
getPermissionAllowed obj :: o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj "allowed"
#if defined(ENABLE_OVERLOADING)
data PermissionAllowedPropertyInfo
instance AttrInfo PermissionAllowedPropertyInfo where
    type AttrAllowedOps PermissionAllowedPropertyInfo = '[ 'AttrGet]
    type AttrBaseTypeConstraint PermissionAllowedPropertyInfo = IsPermission
    type AttrSetTypeConstraint PermissionAllowedPropertyInfo = (~) ()
    type AttrTransferTypeConstraint PermissionAllowedPropertyInfo = (~) ()
    type AttrTransferType PermissionAllowedPropertyInfo = ()
    type AttrGetType PermissionAllowedPropertyInfo = Bool
    type AttrLabel PermissionAllowedPropertyInfo = "allowed"
    type AttrOrigin PermissionAllowedPropertyInfo = Permission
    attrGet = getPermissionAllowed
    attrSet = undefined
    attrTransfer _ = undefined
    attrConstruct = undefined
    attrClear = undefined
#endif
   
   
   
getPermissionCanAcquire :: (MonadIO m, IsPermission o) => o -> m Bool
getPermissionCanAcquire :: o -> m Bool
getPermissionCanAcquire obj :: o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj "can-acquire"
#if defined(ENABLE_OVERLOADING)
data PermissionCanAcquirePropertyInfo
instance AttrInfo PermissionCanAcquirePropertyInfo where
    type AttrAllowedOps PermissionCanAcquirePropertyInfo = '[ 'AttrGet]
    type AttrBaseTypeConstraint PermissionCanAcquirePropertyInfo = IsPermission
    type AttrSetTypeConstraint PermissionCanAcquirePropertyInfo = (~) ()
    type AttrTransferTypeConstraint PermissionCanAcquirePropertyInfo = (~) ()
    type AttrTransferType PermissionCanAcquirePropertyInfo = ()
    type AttrGetType PermissionCanAcquirePropertyInfo = Bool
    type AttrLabel PermissionCanAcquirePropertyInfo = "can-acquire"
    type AttrOrigin PermissionCanAcquirePropertyInfo = Permission
    attrGet = getPermissionCanAcquire
    attrSet = undefined
    attrTransfer _ = undefined
    attrConstruct = undefined
    attrClear = undefined
#endif
   
   
   
getPermissionCanRelease :: (MonadIO m, IsPermission o) => o -> m Bool
getPermissionCanRelease :: o -> m Bool
getPermissionCanRelease obj :: o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj "can-release"
#if defined(ENABLE_OVERLOADING)
data PermissionCanReleasePropertyInfo
instance AttrInfo PermissionCanReleasePropertyInfo where
    type AttrAllowedOps PermissionCanReleasePropertyInfo = '[ 'AttrGet]
    type AttrBaseTypeConstraint PermissionCanReleasePropertyInfo = IsPermission
    type AttrSetTypeConstraint PermissionCanReleasePropertyInfo = (~) ()
    type AttrTransferTypeConstraint PermissionCanReleasePropertyInfo = (~) ()
    type AttrTransferType PermissionCanReleasePropertyInfo = ()
    type AttrGetType PermissionCanReleasePropertyInfo = Bool
    type AttrLabel PermissionCanReleasePropertyInfo = "can-release"
    type AttrOrigin PermissionCanReleasePropertyInfo = Permission
    attrGet = getPermissionCanRelease
    attrSet = undefined
    attrTransfer _ = undefined
    attrConstruct = undefined
    attrClear = undefined
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Permission
type instance O.AttributeList Permission = PermissionAttributeList
type PermissionAttributeList = ('[ '("allowed", PermissionAllowedPropertyInfo), '("canAcquire", PermissionCanAcquirePropertyInfo), '("canRelease", PermissionCanReleasePropertyInfo)] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
permissionAllowed :: AttrLabelProxy "allowed"
permissionAllowed = AttrLabelProxy
permissionCanAcquire :: AttrLabelProxy "canAcquire"
permissionCanAcquire = AttrLabelProxy
permissionCanRelease :: AttrLabelProxy "canRelease"
permissionCanRelease = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Permission = PermissionSignalList
type PermissionSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "g_permission_acquire" g_permission_acquire :: 
    Ptr Permission ->                       
    Ptr Gio.Cancellable.Cancellable ->      
    Ptr (Ptr GError) ->                     
    IO CInt
permissionAcquire ::
    (B.CallStack.HasCallStack, MonadIO m, IsPermission a, Gio.Cancellable.IsCancellable b) =>
    a
    
    -> Maybe (b)
    
    -> m ()
    
permissionAcquire :: a -> Maybe b -> m ()
permissionAcquire permission :: a
permission cancellable :: Maybe b
cancellable = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Permission
permission' <- a -> IO (Ptr Permission)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
permission
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Permission -> Ptr Cancellable -> Ptr (Ptr GError) -> IO CInt
g_permission_acquire Ptr Permission
permission' Ptr Cancellable
maybeCancellable
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
permission
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )
#if defined(ENABLE_OVERLOADING)
data PermissionAcquireMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsPermission a, Gio.Cancellable.IsCancellable b) => O.MethodInfo PermissionAcquireMethodInfo a signature where
    overloadedMethod = permissionAcquire
#endif
foreign import ccall "g_permission_acquire_async" g_permission_acquire_async :: 
    Ptr Permission ->                       
    Ptr Gio.Cancellable.Cancellable ->      
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> 
    Ptr () ->                               
    IO ()
permissionAcquireAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsPermission a, Gio.Cancellable.IsCancellable b) =>
    a
    
    -> Maybe (b)
    
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    
    -> m ()
permissionAcquireAsync :: a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
permissionAcquireAsync permission :: a
permission cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Permission
permission' <- a -> IO (Ptr Permission)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
permission
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Permission
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_permission_acquire_async Ptr Permission
permission' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
permission
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data PermissionAcquireAsyncMethodInfo
instance (signature ~ (Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsPermission a, Gio.Cancellable.IsCancellable b) => O.MethodInfo PermissionAcquireAsyncMethodInfo a signature where
    overloadedMethod = permissionAcquireAsync
#endif
foreign import ccall "g_permission_acquire_finish" g_permission_acquire_finish :: 
    Ptr Permission ->                       
    Ptr Gio.AsyncResult.AsyncResult ->      
    Ptr (Ptr GError) ->                     
    IO CInt
permissionAcquireFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsPermission a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    
    -> b
    
    -> m ()
    
permissionAcquireFinish :: a -> b -> m ()
permissionAcquireFinish permission :: a
permission result_ :: b
result_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Permission
permission' <- a -> IO (Ptr Permission)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
permission
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Permission -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_permission_acquire_finish Ptr Permission
permission' Ptr AsyncResult
result_'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
permission
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )
#if defined(ENABLE_OVERLOADING)
data PermissionAcquireFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsPermission a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo PermissionAcquireFinishMethodInfo a signature where
    overloadedMethod = permissionAcquireFinish
#endif
foreign import ccall "g_permission_get_allowed" g_permission_get_allowed :: 
    Ptr Permission ->                       
    IO CInt
permissionGetAllowed ::
    (B.CallStack.HasCallStack, MonadIO m, IsPermission a) =>
    a
    
    -> m Bool
    
permissionGetAllowed :: a -> m Bool
permissionGetAllowed permission :: a
permission = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Permission
permission' <- a -> IO (Ptr Permission)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
permission
    CInt
result <- Ptr Permission -> IO CInt
g_permission_get_allowed Ptr Permission
permission'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
permission
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data PermissionGetAllowedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPermission a) => O.MethodInfo PermissionGetAllowedMethodInfo a signature where
    overloadedMethod = permissionGetAllowed
#endif
foreign import ccall "g_permission_get_can_acquire" g_permission_get_can_acquire :: 
    Ptr Permission ->                       
    IO CInt
permissionGetCanAcquire ::
    (B.CallStack.HasCallStack, MonadIO m, IsPermission a) =>
    a
    
    -> m Bool
    
permissionGetCanAcquire :: a -> m Bool
permissionGetCanAcquire permission :: a
permission = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Permission
permission' <- a -> IO (Ptr Permission)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
permission
    CInt
result <- Ptr Permission -> IO CInt
g_permission_get_can_acquire Ptr Permission
permission'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
permission
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data PermissionGetCanAcquireMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPermission a) => O.MethodInfo PermissionGetCanAcquireMethodInfo a signature where
    overloadedMethod = permissionGetCanAcquire
#endif
foreign import ccall "g_permission_get_can_release" g_permission_get_can_release :: 
    Ptr Permission ->                       
    IO CInt
permissionGetCanRelease ::
    (B.CallStack.HasCallStack, MonadIO m, IsPermission a) =>
    a
    
    -> m Bool
    
permissionGetCanRelease :: a -> m Bool
permissionGetCanRelease permission :: a
permission = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Permission
permission' <- a -> IO (Ptr Permission)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
permission
    CInt
result <- Ptr Permission -> IO CInt
g_permission_get_can_release Ptr Permission
permission'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
permission
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data PermissionGetCanReleaseMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPermission a) => O.MethodInfo PermissionGetCanReleaseMethodInfo a signature where
    overloadedMethod = permissionGetCanRelease
#endif
foreign import ccall "g_permission_impl_update" g_permission_impl_update :: 
    Ptr Permission ->                       
    CInt ->                                 
    CInt ->                                 
    CInt ->                                 
    IO ()
permissionImplUpdate ::
    (B.CallStack.HasCallStack, MonadIO m, IsPermission a) =>
    a
    
    -> Bool
    
    -> Bool
    
    -> Bool
    
    -> m ()
permissionImplUpdate :: a -> Bool -> Bool -> Bool -> m ()
permissionImplUpdate permission :: a
permission allowed :: Bool
allowed canAcquire :: Bool
canAcquire canRelease :: Bool
canRelease = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Permission
permission' <- a -> IO (Ptr Permission)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
permission
    let allowed' :: CInt
allowed' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
allowed
    let canAcquire' :: CInt
canAcquire' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
canAcquire
    let canRelease' :: CInt
canRelease' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
canRelease
    Ptr Permission -> CInt -> CInt -> CInt -> IO ()
g_permission_impl_update Ptr Permission
permission' CInt
allowed' CInt
canAcquire' CInt
canRelease'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
permission
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data PermissionImplUpdateMethodInfo
instance (signature ~ (Bool -> Bool -> Bool -> m ()), MonadIO m, IsPermission a) => O.MethodInfo PermissionImplUpdateMethodInfo a signature where
    overloadedMethod = permissionImplUpdate
#endif
foreign import ccall "g_permission_release" g_permission_release :: 
    Ptr Permission ->                       
    Ptr Gio.Cancellable.Cancellable ->      
    Ptr (Ptr GError) ->                     
    IO CInt
permissionRelease ::
    (B.CallStack.HasCallStack, MonadIO m, IsPermission a, Gio.Cancellable.IsCancellable b) =>
    a
    
    -> Maybe (b)
    
    -> m ()
    
permissionRelease :: a -> Maybe b -> m ()
permissionRelease permission :: a
permission cancellable :: Maybe b
cancellable = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Permission
permission' <- a -> IO (Ptr Permission)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
permission
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Permission -> Ptr Cancellable -> Ptr (Ptr GError) -> IO CInt
g_permission_release Ptr Permission
permission' Ptr Cancellable
maybeCancellable
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
permission
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )
#if defined(ENABLE_OVERLOADING)
data PermissionReleaseMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsPermission a, Gio.Cancellable.IsCancellable b) => O.MethodInfo PermissionReleaseMethodInfo a signature where
    overloadedMethod = permissionRelease
#endif
foreign import ccall "g_permission_release_async" g_permission_release_async :: 
    Ptr Permission ->                       
    Ptr Gio.Cancellable.Cancellable ->      
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> 
    Ptr () ->                               
    IO ()
permissionReleaseAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsPermission a, Gio.Cancellable.IsCancellable b) =>
    a
    
    -> Maybe (b)
    
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    
    -> m ()
permissionReleaseAsync :: a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
permissionReleaseAsync permission :: a
permission cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Permission
permission' <- a -> IO (Ptr Permission)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
permission
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Permission
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_permission_release_async Ptr Permission
permission' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
permission
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data PermissionReleaseAsyncMethodInfo
instance (signature ~ (Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsPermission a, Gio.Cancellable.IsCancellable b) => O.MethodInfo PermissionReleaseAsyncMethodInfo a signature where
    overloadedMethod = permissionReleaseAsync
#endif
foreign import ccall "g_permission_release_finish" g_permission_release_finish :: 
    Ptr Permission ->                       
    Ptr Gio.AsyncResult.AsyncResult ->      
    Ptr (Ptr GError) ->                     
    IO CInt
permissionReleaseFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsPermission a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    
    -> b
    
    -> m ()
    
permissionReleaseFinish :: a -> b -> m ()
permissionReleaseFinish permission :: a
permission result_ :: b
result_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Permission
permission' <- a -> IO (Ptr Permission)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
permission
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Permission -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_permission_release_finish Ptr Permission
permission' Ptr AsyncResult
result_'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
permission
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )
#if defined(ENABLE_OVERLOADING)
data PermissionReleaseFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsPermission a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo PermissionReleaseFinishMethodInfo a signature where
    overloadedMethod = permissionReleaseFinish
#endif