{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) A structure allowing control over commits. -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.OSTree.Structs.RepoCommitModifier ( -- * Exported types RepoCommitModifier(..) , noRepoCommitModifier , -- * Methods -- ** new #method:new# repoCommitModifierNew , -- ** ref #method:ref# #if ENABLE_OVERLOADING RepoCommitModifierRefMethodInfo , #endif repoCommitModifierRef , -- ** setDevinoCache #method:setDevinoCache# #if ENABLE_OVERLOADING RepoCommitModifierSetDevinoCacheMethodInfo, #endif repoCommitModifierSetDevinoCache , -- ** setSepolicy #method:setSepolicy# #if ENABLE_OVERLOADING RepoCommitModifierSetSepolicyMethodInfo , #endif repoCommitModifierSetSepolicy , -- ** setXattrCallback #method:setXattrCallback# #if ENABLE_OVERLOADING RepoCommitModifierSetXattrCallbackMethodInfo, #endif repoCommitModifierSetXattrCallback , -- ** unref #method:unref# #if ENABLE_OVERLOADING RepoCommitModifierUnrefMethodInfo , #endif repoCommitModifierUnref , ) 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.GLib.Callbacks as GLib.Callbacks import qualified GI.OSTree.Callbacks as OSTree.Callbacks import {-# SOURCE #-} qualified GI.OSTree.Flags as OSTree.Flags import {-# SOURCE #-} qualified GI.OSTree.Objects.SePolicy as OSTree.SePolicy import {-# SOURCE #-} qualified GI.OSTree.Structs.RepoDevInoCache as OSTree.RepoDevInoCache -- | Memory-managed wrapper type. newtype RepoCommitModifier = RepoCommitModifier (ManagedPtr RepoCommitModifier) foreign import ccall "ostree_repo_commit_modifier_get_type" c_ostree_repo_commit_modifier_get_type :: IO GType instance BoxedObject RepoCommitModifier where boxedType _ = c_ostree_repo_commit_modifier_get_type -- | A convenience alias for `Nothing` :: `Maybe` `RepoCommitModifier`. noRepoCommitModifier :: Maybe RepoCommitModifier noRepoCommitModifier = Nothing #if ENABLE_OVERLOADING instance O.HasAttributeList RepoCommitModifier type instance O.AttributeList RepoCommitModifier = RepoCommitModifierAttributeList type RepoCommitModifierAttributeList = ('[ ] :: [(Symbol, *)]) #endif -- method RepoCommitModifier::new -- method type : Constructor -- Args : [Arg {argCName = "flags", argType = TInterface (Name {namespace = "OSTree", name = "RepoCommitModifierFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Control options for filter", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "commit_filter", argType = TInterface (Name {namespace = "OSTree", name = "RepoCommitFilter"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Function that can inspect individual files", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 2, argDestroy = 3, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "User data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy_notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDestroyNotify", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "OSTree", name = "RepoCommitModifier"})) -- throws : False -- Skip return : False foreign import ccall "ostree_repo_commit_modifier_new" ostree_repo_commit_modifier_new :: CUInt -> -- flags : TInterface (Name {namespace = "OSTree", name = "RepoCommitModifierFlags"}) FunPtr OSTree.Callbacks.C_RepoCommitFilter -> -- commit_filter : TInterface (Name {namespace = "OSTree", name = "RepoCommitFilter"}) Ptr () -> -- user_data : TBasicType TPtr FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy_notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) IO (Ptr RepoCommitModifier) {- | /No description available in the introspection data./ -} repoCommitModifierNew :: (B.CallStack.HasCallStack, MonadIO m) => [OSTree.Flags.RepoCommitModifierFlags] {- ^ /@flags@/: Control options for filter -} -> Maybe (OSTree.Callbacks.RepoCommitFilter) {- ^ /@commitFilter@/: Function that can inspect individual files -} -> m RepoCommitModifier {- ^ __Returns:__ A new commit modifier. -} repoCommitModifierNew flags commitFilter = liftIO $ do let flags' = gflagsToWord flags maybeCommitFilter <- case commitFilter of Nothing -> return (castPtrToFunPtr nullPtr) Just jCommitFilter -> do jCommitFilter' <- OSTree.Callbacks.mk_RepoCommitFilter (OSTree.Callbacks.wrap_RepoCommitFilter Nothing (OSTree.Callbacks.drop_closures_RepoCommitFilter jCommitFilter)) return jCommitFilter' let userData = castFunPtrToPtr maybeCommitFilter let destroyNotify = safeFreeFunPtrPtr result <- ostree_repo_commit_modifier_new flags' maybeCommitFilter userData destroyNotify checkUnexpectedReturnNULL "repoCommitModifierNew" result result' <- (wrapBoxed RepoCommitModifier) result return result' #if ENABLE_OVERLOADING #endif -- method RepoCommitModifier::ref -- method type : OrdinaryMethod -- Args : [Arg {argCName = "modifier", argType = TInterface (Name {namespace = "OSTree", name = "RepoCommitModifier"}), 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 = "OSTree", name = "RepoCommitModifier"})) -- throws : False -- Skip return : False foreign import ccall "ostree_repo_commit_modifier_ref" ostree_repo_commit_modifier_ref :: Ptr RepoCommitModifier -> -- modifier : TInterface (Name {namespace = "OSTree", name = "RepoCommitModifier"}) IO (Ptr RepoCommitModifier) {- | /No description available in the introspection data./ -} repoCommitModifierRef :: (B.CallStack.HasCallStack, MonadIO m) => RepoCommitModifier -> m RepoCommitModifier repoCommitModifierRef modifier = liftIO $ do modifier' <- unsafeManagedPtrGetPtr modifier result <- ostree_repo_commit_modifier_ref modifier' checkUnexpectedReturnNULL "repoCommitModifierRef" result result' <- (wrapBoxed RepoCommitModifier) result touchManagedPtr modifier return result' #if ENABLE_OVERLOADING data RepoCommitModifierRefMethodInfo instance (signature ~ (m RepoCommitModifier), MonadIO m) => O.MethodInfo RepoCommitModifierRefMethodInfo RepoCommitModifier signature where overloadedMethod _ = repoCommitModifierRef #endif -- method RepoCommitModifier::set_devino_cache -- method type : OrdinaryMethod -- Args : [Arg {argCName = "modifier", argType = TInterface (Name {namespace = "OSTree", name = "RepoCommitModifier"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Modifier", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cache", argType = TInterface (Name {namespace = "OSTree", name = "RepoDevInoCache"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A hash table caching device,inode to checksums", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "ostree_repo_commit_modifier_set_devino_cache" ostree_repo_commit_modifier_set_devino_cache :: Ptr RepoCommitModifier -> -- modifier : TInterface (Name {namespace = "OSTree", name = "RepoCommitModifier"}) Ptr OSTree.RepoDevInoCache.RepoDevInoCache -> -- cache : TInterface (Name {namespace = "OSTree", name = "RepoDevInoCache"}) IO () {- | See the documentation for @ostree_repo_devino_cache_new()@. This function can then be used for later calls to @ostree_repo_write_directory_to_mtree()@ to optimize commits. Note if your process has multiple writers, you should use separate @OSTreeRepo@ instances if you want to also use this API. This function will add a reference to /@cache@/ without copying - you should avoid further mutation of the cache. /Since: 2017.13/ -} repoCommitModifierSetDevinoCache :: (B.CallStack.HasCallStack, MonadIO m) => RepoCommitModifier {- ^ /@modifier@/: Modifier -} -> OSTree.RepoDevInoCache.RepoDevInoCache {- ^ /@cache@/: A hash table caching device,inode to checksums -} -> m () repoCommitModifierSetDevinoCache modifier cache = liftIO $ do modifier' <- unsafeManagedPtrGetPtr modifier cache' <- unsafeManagedPtrGetPtr cache ostree_repo_commit_modifier_set_devino_cache modifier' cache' touchManagedPtr modifier touchManagedPtr cache return () #if ENABLE_OVERLOADING data RepoCommitModifierSetDevinoCacheMethodInfo instance (signature ~ (OSTree.RepoDevInoCache.RepoDevInoCache -> m ()), MonadIO m) => O.MethodInfo RepoCommitModifierSetDevinoCacheMethodInfo RepoCommitModifier signature where overloadedMethod _ = repoCommitModifierSetDevinoCache #endif -- method RepoCommitModifier::set_sepolicy -- method type : OrdinaryMethod -- Args : [Arg {argCName = "modifier", argType = TInterface (Name {namespace = "OSTree", name = "RepoCommitModifier"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An #OstreeRepoCommitModifier", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sepolicy", argType = TInterface (Name {namespace = "OSTree", name = "SePolicy"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Policy to use for labeling", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "ostree_repo_commit_modifier_set_sepolicy" ostree_repo_commit_modifier_set_sepolicy :: Ptr RepoCommitModifier -> -- modifier : TInterface (Name {namespace = "OSTree", name = "RepoCommitModifier"}) Ptr OSTree.SePolicy.SePolicy -> -- sepolicy : TInterface (Name {namespace = "OSTree", name = "SePolicy"}) IO () {- | If /@policy@/ is non-'Nothing', use it to look up labels to use for \"security.selinux\" extended attributes. Note that any policy specified this way operates in addition to any extended attributes provided via 'GI.OSTree.Structs.RepoCommitModifier.repoCommitModifierSetXattrCallback'. However if both specify a value for \"security.selinux\", then the one from the policy wins. -} repoCommitModifierSetSepolicy :: (B.CallStack.HasCallStack, MonadIO m, OSTree.SePolicy.IsSePolicy a) => RepoCommitModifier {- ^ /@modifier@/: An 'GI.OSTree.Structs.RepoCommitModifier.RepoCommitModifier' -} -> Maybe (a) {- ^ /@sepolicy@/: Policy to use for labeling -} -> m () repoCommitModifierSetSepolicy modifier sepolicy = liftIO $ do modifier' <- unsafeManagedPtrGetPtr modifier maybeSepolicy <- case sepolicy of Nothing -> return nullPtr Just jSepolicy -> do jSepolicy' <- unsafeManagedPtrCastPtr jSepolicy return jSepolicy' ostree_repo_commit_modifier_set_sepolicy modifier' maybeSepolicy touchManagedPtr modifier whenJust sepolicy touchManagedPtr return () #if ENABLE_OVERLOADING data RepoCommitModifierSetSepolicyMethodInfo instance (signature ~ (Maybe (a) -> m ()), MonadIO m, OSTree.SePolicy.IsSePolicy a) => O.MethodInfo RepoCommitModifierSetSepolicyMethodInfo RepoCommitModifier signature where overloadedMethod _ = repoCommitModifierSetSepolicy #endif -- method RepoCommitModifier::set_xattr_callback -- method type : OrdinaryMethod -- Args : [Arg {argCName = "modifier", argType = TInterface (Name {namespace = "OSTree", name = "RepoCommitModifier"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "An #OstreeRepoCommitModifier", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "OSTree", name = "RepoCommitModifierXattrCallback"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Function to be invoked, should return extended attributes for path", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 2, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Destroy notification", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Data for @callback:", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "ostree_repo_commit_modifier_set_xattr_callback" ostree_repo_commit_modifier_set_xattr_callback :: Ptr RepoCommitModifier -> -- modifier : TInterface (Name {namespace = "OSTree", name = "RepoCommitModifier"}) FunPtr OSTree.Callbacks.C_RepoCommitModifierXattrCallback -> -- callback : TInterface (Name {namespace = "OSTree", name = "RepoCommitModifierXattrCallback"}) FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"}) Ptr () -> -- user_data : TBasicType TPtr IO () {- | If set, this function should return extended attributes to use for the given path. This is useful for things like ACLs and SELinux, where a build system can label the files as it\'s committing to the repository. -} repoCommitModifierSetXattrCallback :: (B.CallStack.HasCallStack, MonadIO m) => RepoCommitModifier {- ^ /@modifier@/: An 'GI.OSTree.Structs.RepoCommitModifier.RepoCommitModifier' -} -> OSTree.Callbacks.RepoCommitModifierXattrCallback {- ^ /@callback@/: Function to be invoked, should return extended attributes for path -} -> m () repoCommitModifierSetXattrCallback modifier callback = liftIO $ do modifier' <- unsafeManagedPtrGetPtr modifier callback' <- OSTree.Callbacks.mk_RepoCommitModifierXattrCallback (OSTree.Callbacks.wrap_RepoCommitModifierXattrCallback Nothing (OSTree.Callbacks.drop_closures_RepoCommitModifierXattrCallback callback)) let userData = castFunPtrToPtr callback' let destroy = safeFreeFunPtrPtr ostree_repo_commit_modifier_set_xattr_callback modifier' callback' destroy userData touchManagedPtr modifier return () #if ENABLE_OVERLOADING data RepoCommitModifierSetXattrCallbackMethodInfo instance (signature ~ (OSTree.Callbacks.RepoCommitModifierXattrCallback -> m ()), MonadIO m) => O.MethodInfo RepoCommitModifierSetXattrCallbackMethodInfo RepoCommitModifier signature where overloadedMethod _ = repoCommitModifierSetXattrCallback #endif -- method RepoCommitModifier::unref -- method type : OrdinaryMethod -- Args : [Arg {argCName = "modifier", argType = TInterface (Name {namespace = "OSTree", name = "RepoCommitModifier"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "ostree_repo_commit_modifier_unref" ostree_repo_commit_modifier_unref :: Ptr RepoCommitModifier -> -- modifier : TInterface (Name {namespace = "OSTree", name = "RepoCommitModifier"}) IO () {- | /No description available in the introspection data./ -} repoCommitModifierUnref :: (B.CallStack.HasCallStack, MonadIO m) => RepoCommitModifier -> m () repoCommitModifierUnref modifier = liftIO $ do modifier' <- unsafeManagedPtrGetPtr modifier ostree_repo_commit_modifier_unref modifier' touchManagedPtr modifier return () #if ENABLE_OVERLOADING data RepoCommitModifierUnrefMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RepoCommitModifierUnrefMethodInfo RepoCommitModifier signature where overloadedMethod _ = repoCommitModifierUnref #endif #if ENABLE_OVERLOADING type family ResolveRepoCommitModifierMethod (t :: Symbol) (o :: *) :: * where ResolveRepoCommitModifierMethod "ref" o = RepoCommitModifierRefMethodInfo ResolveRepoCommitModifierMethod "unref" o = RepoCommitModifierUnrefMethodInfo ResolveRepoCommitModifierMethod "setDevinoCache" o = RepoCommitModifierSetDevinoCacheMethodInfo ResolveRepoCommitModifierMethod "setSepolicy" o = RepoCommitModifierSetSepolicyMethodInfo ResolveRepoCommitModifierMethod "setXattrCallback" o = RepoCommitModifierSetXattrCallbackMethodInfo ResolveRepoCommitModifierMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveRepoCommitModifierMethod t RepoCommitModifier, O.MethodInfo info RepoCommitModifier p) => OL.IsLabel t (RepoCommitModifier -> 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