{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

/No description available in the introspection data./
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.OSTree.Objects.SePolicy
    (

-- * Exported types
    SePolicy(..)                            ,
    IsSePolicy                              ,
    toSePolicy                              ,
    noSePolicy                              ,


 -- * Methods
-- ** fscreateconCleanup #method:fscreateconCleanup#

    sePolicyFscreateconCleanup              ,


-- ** getCsum #method:getCsum#

#if ENABLE_OVERLOADING
    SePolicyGetCsumMethodInfo               ,
#endif
    sePolicyGetCsum                         ,


-- ** getLabel #method:getLabel#

#if ENABLE_OVERLOADING
    SePolicyGetLabelMethodInfo              ,
#endif
    sePolicyGetLabel                        ,


-- ** getName #method:getName#

#if ENABLE_OVERLOADING
    SePolicyGetNameMethodInfo               ,
#endif
    sePolicyGetName                         ,


-- ** getPath #method:getPath#

#if ENABLE_OVERLOADING
    SePolicyGetPathMethodInfo               ,
#endif
    sePolicyGetPath                         ,


-- ** new #method:new#

    sePolicyNew                             ,


-- ** newAt #method:newAt#

    sePolicyNewAt                           ,


-- ** restorecon #method:restorecon#

#if ENABLE_OVERLOADING
    SePolicyRestoreconMethodInfo            ,
#endif
    sePolicyRestorecon                      ,


-- ** setfscreatecon #method:setfscreatecon#

#if ENABLE_OVERLOADING
    SePolicySetfscreateconMethodInfo        ,
#endif
    sePolicySetfscreatecon                  ,




 -- * Properties
-- ** path #attr:path#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    SePolicyPathPropertyInfo                ,
#endif
    constructSePolicyPath                   ,
    getSePolicyPath                         ,
#if ENABLE_OVERLOADING
    sePolicyPath                            ,
#endif


-- ** rootfsDfd #attr:rootfsDfd#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    SePolicyRootfsDfdPropertyInfo           ,
#endif
    constructSePolicyRootfsDfd              ,
    getSePolicyRootfsDfd                    ,
#if ENABLE_OVERLOADING
    sePolicyRootfsDfd                       ,
#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.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.Interfaces.File as Gio.File
import qualified GI.Gio.Interfaces.Initable as Gio.Initable
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gio.Objects.FileInfo as Gio.FileInfo
import {-# SOURCE #-} qualified GI.OSTree.Flags as OSTree.Flags

-- | Memory-managed wrapper type.
newtype SePolicy = SePolicy (ManagedPtr SePolicy)
foreign import ccall "ostree_sepolicy_get_type"
    c_ostree_sepolicy_get_type :: IO GType

instance GObject SePolicy where
    gobjectType = c_ostree_sepolicy_get_type


-- | Type class for types which can be safely cast to `SePolicy`, for instance with `toSePolicy`.
class (GObject o, O.IsDescendantOf SePolicy o) => IsSePolicy o
instance (GObject o, O.IsDescendantOf SePolicy o) => IsSePolicy o

instance O.HasParentTypes SePolicy
type instance O.ParentTypes SePolicy = '[GObject.Object.Object, Gio.Initable.Initable]

-- | Cast to `SePolicy`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toSePolicy :: (MonadIO m, IsSePolicy o) => o -> m SePolicy
toSePolicy = liftIO . unsafeCastTo SePolicy

-- | A convenience alias for `Nothing` :: `Maybe` `SePolicy`.
noSePolicy :: Maybe SePolicy
noSePolicy = Nothing

#if ENABLE_OVERLOADING
type family ResolveSePolicyMethod (t :: Symbol) (o :: *) :: * where
    ResolveSePolicyMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveSePolicyMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveSePolicyMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveSePolicyMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveSePolicyMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveSePolicyMethod "init" o = Gio.Initable.InitableInitMethodInfo
    ResolveSePolicyMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveSePolicyMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveSePolicyMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveSePolicyMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveSePolicyMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveSePolicyMethod "restorecon" o = SePolicyRestoreconMethodInfo
    ResolveSePolicyMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveSePolicyMethod "setfscreatecon" o = SePolicySetfscreateconMethodInfo
    ResolveSePolicyMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveSePolicyMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveSePolicyMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveSePolicyMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveSePolicyMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveSePolicyMethod "getCsum" o = SePolicyGetCsumMethodInfo
    ResolveSePolicyMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveSePolicyMethod "getLabel" o = SePolicyGetLabelMethodInfo
    ResolveSePolicyMethod "getName" o = SePolicyGetNameMethodInfo
    ResolveSePolicyMethod "getPath" o = SePolicyGetPathMethodInfo
    ResolveSePolicyMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveSePolicyMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveSePolicyMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveSePolicyMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveSePolicyMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveSePolicyMethod t SePolicy, O.MethodInfo info SePolicy p) => OL.IsLabel t (SePolicy -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif

-- VVV Prop "path"
   -- Type: TInterface (Name {namespace = "Gio", name = "File"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

{- |
Get the value of the “@path@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' sePolicy #path
@
-}
getSePolicyPath :: (MonadIO m, IsSePolicy o) => o -> m Gio.File.File
getSePolicyPath obj = liftIO $ checkUnexpectedNothing "getSePolicyPath" $ B.Properties.getObjectPropertyObject obj "path" Gio.File.File

{- |
Construct a `GValueConstruct` with valid value for the “@path@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSePolicyPath :: (IsSePolicy o, Gio.File.IsFile a) => a -> IO (GValueConstruct o)
constructSePolicyPath val = B.Properties.constructObjectPropertyObject "path" (Just val)

#if ENABLE_OVERLOADING
data SePolicyPathPropertyInfo
instance AttrInfo SePolicyPathPropertyInfo where
    type AttrAllowedOps SePolicyPathPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint SePolicyPathPropertyInfo = Gio.File.IsFile
    type AttrBaseTypeConstraint SePolicyPathPropertyInfo = IsSePolicy
    type AttrGetType SePolicyPathPropertyInfo = Gio.File.File
    type AttrLabel SePolicyPathPropertyInfo = "path"
    type AttrOrigin SePolicyPathPropertyInfo = SePolicy
    attrGet _ = getSePolicyPath
    attrSet _ = undefined
    attrConstruct _ = constructSePolicyPath
    attrClear _ = undefined
#endif

-- VVV Prop "rootfs-dfd"
   -- Type: TBasicType TInt
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@rootfs-dfd@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' sePolicy #rootfsDfd
@
-}
getSePolicyRootfsDfd :: (MonadIO m, IsSePolicy o) => o -> m Int32
getSePolicyRootfsDfd obj = liftIO $ B.Properties.getObjectPropertyInt32 obj "rootfs-dfd"

{- |
Construct a `GValueConstruct` with valid value for the “@rootfs-dfd@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSePolicyRootfsDfd :: (IsSePolicy o) => Int32 -> IO (GValueConstruct o)
constructSePolicyRootfsDfd val = B.Properties.constructObjectPropertyInt32 "rootfs-dfd" val

#if ENABLE_OVERLOADING
data SePolicyRootfsDfdPropertyInfo
instance AttrInfo SePolicyRootfsDfdPropertyInfo where
    type AttrAllowedOps SePolicyRootfsDfdPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint SePolicyRootfsDfdPropertyInfo = (~) Int32
    type AttrBaseTypeConstraint SePolicyRootfsDfdPropertyInfo = IsSePolicy
    type AttrGetType SePolicyRootfsDfdPropertyInfo = Int32
    type AttrLabel SePolicyRootfsDfdPropertyInfo = "rootfs-dfd"
    type AttrOrigin SePolicyRootfsDfdPropertyInfo = SePolicy
    attrGet _ = getSePolicyRootfsDfd
    attrSet _ = undefined
    attrConstruct _ = constructSePolicyRootfsDfd
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList SePolicy
type instance O.AttributeList SePolicy = SePolicyAttributeList
type SePolicyAttributeList = ('[ '("path", SePolicyPathPropertyInfo), '("rootfsDfd", SePolicyRootfsDfdPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
sePolicyPath :: AttrLabelProxy "path"
sePolicyPath = AttrLabelProxy

sePolicyRootfsDfd :: AttrLabelProxy "rootfsDfd"
sePolicyRootfsDfd = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
type instance O.SignalList SePolicy = SePolicySignalList
type SePolicySignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method SePolicy::new
-- method type : Constructor
-- Args : [Arg {argCName = "path", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Path to a root directory", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "OSTree", name = "SePolicy"}))
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sepolicy_new" ostree_sepolicy_new ::
    Ptr Gio.File.File ->                    -- path : TInterface (Name {namespace = "Gio", name = "File"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr SePolicy)

{- |
/No description available in the introspection data./
-}
sePolicyNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.File.IsFile a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@path@/: Path to a root directory -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m SePolicy
    {- ^ __Returns:__ An accessor object for SELinux policy in root located at /@path@/ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sePolicyNew path cancellable = liftIO $ do
    path' <- unsafeManagedPtrCastPtr path
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ ostree_sepolicy_new path' maybeCancellable
        checkUnexpectedReturnNULL "sePolicyNew" result
        result' <- (wrapObject SePolicy) result
        touchManagedPtr path
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
#endif

-- method SePolicy::new_at
-- method type : Constructor
-- Args : [Arg {argCName = "rootfs_dfd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Directory fd for rootfs (will not be cloned)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "OSTree", name = "SePolicy"}))
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sepolicy_new_at" ostree_sepolicy_new_at ::
    Int32 ->                                -- rootfs_dfd : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr SePolicy)

{- |
/No description available in the introspection data./
-}
sePolicyNewAt ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Int32
    {- ^ /@rootfsDfd@/: Directory fd for rootfs (will not be cloned) -}
    -> Maybe (a)
    {- ^ /@cancellable@/: Cancellable -}
    -> m SePolicy
    {- ^ __Returns:__ An accessor object for SELinux policy in root located at /@rootfsDfd@/ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sePolicyNewAt rootfsDfd cancellable = liftIO $ do
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ ostree_sepolicy_new_at rootfsDfd maybeCancellable
        checkUnexpectedReturnNULL "sePolicyNewAt" result
        result' <- (wrapObject SePolicy) result
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
#endif

-- method SePolicy::get_csum
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "SePolicy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sepolicy_get_csum" ostree_sepolicy_get_csum ::
    Ptr SePolicy ->                         -- self : TInterface (Name {namespace = "OSTree", name = "SePolicy"})
    IO CString

{- |
/No description available in the introspection data./
-}
sePolicyGetCsum ::
    (B.CallStack.HasCallStack, MonadIO m, IsSePolicy a) =>
    a
    -> m T.Text
    {- ^ __Returns:__ Checksum of current policy -}
sePolicyGetCsum self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- ostree_sepolicy_get_csum self'
    checkUnexpectedReturnNULL "sePolicyGetCsum" result
    result' <- cstringToText result
    touchManagedPtr self
    return result'

#if ENABLE_OVERLOADING
data SePolicyGetCsumMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsSePolicy a) => O.MethodInfo SePolicyGetCsumMethodInfo a signature where
    overloadedMethod _ = sePolicyGetCsum

#endif

-- method SePolicy::get_label
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "SePolicy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "relpath", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Path", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "unix_mode", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Unix mode", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_label", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Return location for security context", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sepolicy_get_label" ostree_sepolicy_get_label ::
    Ptr SePolicy ->                         -- self : TInterface (Name {namespace = "OSTree", name = "SePolicy"})
    CString ->                              -- relpath : TBasicType TUTF8
    Word32 ->                               -- unix_mode : TBasicType TUInt32
    Ptr CString ->                          -- out_label : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Store in /@outLabel@/ the security context for the given /@relpath@/ and
mode /@unixMode@/.  If the policy does not specify a label, 'Nothing'
will be returned.
-}
sePolicyGetLabel ::
    (B.CallStack.HasCallStack, MonadIO m, IsSePolicy a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@self@/: Self -}
    -> T.Text
    {- ^ /@relpath@/: Path -}
    -> Word32
    {- ^ /@unixMode@/: Unix mode -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (T.Text)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sePolicyGetLabel self relpath unixMode cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    relpath' <- textToCString relpath
    outLabel <- allocMem :: IO (Ptr CString)
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sepolicy_get_label self' relpath' unixMode outLabel maybeCancellable
        outLabel' <- peek outLabel
        outLabel'' <- cstringToText outLabel'
        freeMem outLabel'
        touchManagedPtr self
        whenJust cancellable touchManagedPtr
        freeMem relpath'
        freeMem outLabel
        return outLabel''
     ) (do
        freeMem relpath'
        freeMem outLabel
     )

#if ENABLE_OVERLOADING
data SePolicyGetLabelMethodInfo
instance (signature ~ (T.Text -> Word32 -> Maybe (b) -> m (T.Text)), MonadIO m, IsSePolicy a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SePolicyGetLabelMethodInfo a signature where
    overloadedMethod _ = sePolicyGetLabel

#endif

-- method SePolicy::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "SePolicy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sepolicy_get_name" ostree_sepolicy_get_name ::
    Ptr SePolicy ->                         -- self : TInterface (Name {namespace = "OSTree", name = "SePolicy"})
    IO CString

{- |
/No description available in the introspection data./
-}
sePolicyGetName ::
    (B.CallStack.HasCallStack, MonadIO m, IsSePolicy a) =>
    a
    -> m T.Text
    {- ^ __Returns:__ Type of current policy -}
sePolicyGetName self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- ostree_sepolicy_get_name self'
    checkUnexpectedReturnNULL "sePolicyGetName" result
    result' <- cstringToText result
    touchManagedPtr self
    return result'

#if ENABLE_OVERLOADING
data SePolicyGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsSePolicy a) => O.MethodInfo SePolicyGetNameMethodInfo a signature where
    overloadedMethod _ = sePolicyGetName

#endif

-- method SePolicy::get_path
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "SePolicy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sepolicy_get_path" ostree_sepolicy_get_path ::
    Ptr SePolicy ->                         -- self : TInterface (Name {namespace = "OSTree", name = "SePolicy"})
    IO (Ptr Gio.File.File)

{- |
/No description available in the introspection data./
-}
sePolicyGetPath ::
    (B.CallStack.HasCallStack, MonadIO m, IsSePolicy a) =>
    a
    -> m Gio.File.File
    {- ^ __Returns:__ Path to rootfs -}
sePolicyGetPath self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- ostree_sepolicy_get_path self'
    checkUnexpectedReturnNULL "sePolicyGetPath" result
    result' <- (newObject Gio.File.File) result
    touchManagedPtr self
    return result'

#if ENABLE_OVERLOADING
data SePolicyGetPathMethodInfo
instance (signature ~ (m Gio.File.File), MonadIO m, IsSePolicy a) => O.MethodInfo SePolicyGetPathMethodInfo a signature where
    overloadedMethod _ = sePolicyGetPath

#endif

-- method SePolicy::restorecon
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "SePolicy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Path string to use for policy lookup", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "FileInfo"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "File attributes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target", argType = TInterface (Name {namespace = "Gio", name = "File"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Physical path to target file", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "OSTree", name = "SePolicyRestoreconFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags controlling behavior", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_new_label", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "New label, or %NULL if unchanged", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sepolicy_restorecon" ostree_sepolicy_restorecon ::
    Ptr SePolicy ->                         -- self : TInterface (Name {namespace = "OSTree", name = "SePolicy"})
    CString ->                              -- path : TBasicType TUTF8
    Ptr Gio.FileInfo.FileInfo ->            -- info : TInterface (Name {namespace = "Gio", name = "FileInfo"})
    Ptr Gio.File.File ->                    -- target : TInterface (Name {namespace = "Gio", name = "File"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "OSTree", name = "SePolicyRestoreconFlags"})
    Ptr CString ->                          -- out_new_label : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Reset the security context of /@target@/ based on the SELinux policy.
-}
sePolicyRestorecon ::
    (B.CallStack.HasCallStack, MonadIO m, IsSePolicy a, Gio.FileInfo.IsFileInfo b, Gio.File.IsFile c, Gio.Cancellable.IsCancellable d) =>
    a
    {- ^ /@self@/: Self -}
    -> T.Text
    {- ^ /@path@/: Path string to use for policy lookup -}
    -> Maybe (b)
    {- ^ /@info@/: File attributes -}
    -> c
    {- ^ /@target@/: Physical path to target file -}
    -> [OSTree.Flags.SePolicyRestoreconFlags]
    {- ^ /@flags@/: Flags controlling behavior -}
    -> Maybe (d)
    {- ^ /@cancellable@/: Cancellable -}
    -> m (T.Text)
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sePolicyRestorecon self path info target flags cancellable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    path' <- textToCString path
    maybeInfo <- case info of
        Nothing -> return nullPtr
        Just jInfo -> do
            jInfo' <- unsafeManagedPtrCastPtr jInfo
            return jInfo'
    target' <- unsafeManagedPtrCastPtr target
    let flags' = gflagsToWord flags
    outNewLabel <- allocMem :: IO (Ptr CString)
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ ostree_sepolicy_restorecon self' path' maybeInfo target' flags' outNewLabel maybeCancellable
        outNewLabel' <- peek outNewLabel
        outNewLabel'' <- cstringToText outNewLabel'
        freeMem outNewLabel'
        touchManagedPtr self
        whenJust info touchManagedPtr
        touchManagedPtr target
        whenJust cancellable touchManagedPtr
        freeMem path'
        freeMem outNewLabel
        return outNewLabel''
     ) (do
        freeMem path'
        freeMem outNewLabel
     )

#if ENABLE_OVERLOADING
data SePolicyRestoreconMethodInfo
instance (signature ~ (T.Text -> Maybe (b) -> c -> [OSTree.Flags.SePolicyRestoreconFlags] -> Maybe (d) -> m (T.Text)), MonadIO m, IsSePolicy a, Gio.FileInfo.IsFileInfo b, Gio.File.IsFile c, Gio.Cancellable.IsCancellable d) => O.MethodInfo SePolicyRestoreconMethodInfo a signature where
    overloadedMethod _ = sePolicyRestorecon

#endif

-- method SePolicy::setfscreatecon
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "OSTree", name = "SePolicy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Policy", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Use this path to determine a label", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mode", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Used along with @path", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ostree_sepolicy_setfscreatecon" ostree_sepolicy_setfscreatecon ::
    Ptr SePolicy ->                         -- self : TInterface (Name {namespace = "OSTree", name = "SePolicy"})
    CString ->                              -- path : TBasicType TUTF8
    Word32 ->                               -- mode : TBasicType TUInt32
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
/No description available in the introspection data./
-}
sePolicySetfscreatecon ::
    (B.CallStack.HasCallStack, MonadIO m, IsSePolicy a) =>
    a
    {- ^ /@self@/: Policy -}
    -> T.Text
    {- ^ /@path@/: Use this path to determine a label -}
    -> Word32
    {- ^ /@mode@/: Used along with /@path@/ -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
sePolicySetfscreatecon self path mode = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    path' <- textToCString path
    onException (do
        _ <- propagateGError $ ostree_sepolicy_setfscreatecon self' path' mode
        touchManagedPtr self
        freeMem path'
        return ()
     ) (do
        freeMem path'
     )

#if ENABLE_OVERLOADING
data SePolicySetfscreateconMethodInfo
instance (signature ~ (T.Text -> Word32 -> m ()), MonadIO m, IsSePolicy a) => O.MethodInfo SePolicySetfscreateconMethodInfo a signature where
    overloadedMethod _ = sePolicySetfscreatecon

#endif

-- method SePolicy::fscreatecon_cleanup
-- method type : MemberFunction
-- Args : [Arg {argCName = "unused", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Not used, just in case you didn't infer that from the parameter name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ostree_sepolicy_fscreatecon_cleanup" ostree_sepolicy_fscreatecon_cleanup ::
    Ptr () ->                               -- unused : TBasicType TPtr
    IO ()

{- |
Cleanup function for 'GI.OSTree.Objects.SePolicy.sePolicySetfscreatecon'.
-}
sePolicyFscreateconCleanup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    {- ^ /@unused@/: Not used, just in case you didn\'t infer that from the parameter name -}
    -> m ()
sePolicyFscreateconCleanup unused = liftIO $ do
    ostree_sepolicy_fscreatecon_cleanup unused
    return ()

#if ENABLE_OVERLOADING
#endif