{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- WpConf allows accessing the different sections of the wireplumber configuration.

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

module GI.Wp.Objects.Conf
    ( 

-- * Exported types
    Conf(..)                                ,
    IsConf                                  ,
    toConf                                  ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [close]("GI.Wp.Objects.Conf#g:method:close"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [isOpen]("GI.Wp.Objects.Conf#g:method:isOpen"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [open]("GI.Wp.Objects.Conf#g:method:open"), [parsePwContextSections]("GI.Wp.Objects.Conf#g:method:parsePwContextSections"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [sectionUpdateProps]("GI.Wp.Objects.Conf#g:method:sectionUpdateProps"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getData]("GI.GObject.Objects.Object#g:method:getData"), [getName]("GI.Wp.Objects.Conf#g:method:getName"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata"), [getSection]("GI.Wp.Objects.Conf#g:method:getSection").
-- 
-- ==== Setters
-- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").

#if defined(ENABLE_OVERLOADING)
    ResolveConfMethod                       ,
#endif

-- ** close #method:close#

#if defined(ENABLE_OVERLOADING)
    ConfCloseMethodInfo                     ,
#endif
    confClose                               ,


-- ** getName #method:getName#

#if defined(ENABLE_OVERLOADING)
    ConfGetNameMethodInfo                   ,
#endif
    confGetName                             ,


-- ** getSection #method:getSection#

#if defined(ENABLE_OVERLOADING)
    ConfGetSectionMethodInfo                ,
#endif
    confGetSection                          ,


-- ** isOpen #method:isOpen#

#if defined(ENABLE_OVERLOADING)
    ConfIsOpenMethodInfo                    ,
#endif
    confIsOpen                              ,


-- ** new #method:new#

    confNew                                 ,


-- ** newOpen #method:newOpen#

    confNewOpen                             ,


-- ** open #method:open#

#if defined(ENABLE_OVERLOADING)
    ConfOpenMethodInfo                      ,
#endif
    confOpen                                ,


-- ** parsePwContextSections #method:parsePwContextSections#

#if defined(ENABLE_OVERLOADING)
    ConfParsePwContextSectionsMethodInfo    ,
#endif
    confParsePwContextSections              ,


-- ** sectionUpdateProps #method:sectionUpdateProps#

#if defined(ENABLE_OVERLOADING)
    ConfSectionUpdatePropsMethodInfo        ,
#endif
    confSectionUpdateProps                  ,




 -- * Properties


-- ** name #attr:name#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    ConfNamePropertyInfo                    ,
#endif
#if defined(ENABLE_OVERLOADING)
    confName                                ,
#endif
    constructConfName                       ,
    getConfName                             ,


-- ** properties #attr:properties#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    ConfPropertiesPropertyInfo              ,
#endif
#if defined(ENABLE_OVERLOADING)
    confProperties                          ,
#endif
    constructConfProperties                 ,
    getConfProperties                       ,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Wp.Callbacks as Wp.Callbacks
import {-# SOURCE #-} qualified GI.Wp.Structs.Iterator as Wp.Iterator
import {-# SOURCE #-} qualified GI.Wp.Structs.IteratorMethods as Wp.IteratorMethods
import {-# SOURCE #-} qualified GI.Wp.Structs.Properties as Wp.Properties
import {-# SOURCE #-} qualified GI.Wp.Structs.SpaJson as Wp.SpaJson

#else
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Wp.Structs.Properties as Wp.Properties
import {-# SOURCE #-} qualified GI.Wp.Structs.SpaJson as Wp.SpaJson

#endif

-- | Memory-managed wrapper type.
newtype Conf = Conf (SP.ManagedPtr Conf)
    deriving (Eq)

instance SP.ManagedPtrNewtype Conf where
    toManagedPtr (Conf p) = p

foreign import ccall "wp_conf_get_type"
    c_wp_conf_get_type :: IO B.Types.GType

instance B.Types.TypedObject Conf where
    glibType = c_wp_conf_get_type

instance B.Types.GObject Conf

-- | Type class for types which can be safely cast to t'Conf', for instance with `toConf`.
class (SP.GObject o, O.IsDescendantOf Conf o) => IsConf o
instance (SP.GObject o, O.IsDescendantOf Conf o) => IsConf o

instance O.HasParentTypes Conf
type instance O.ParentTypes Conf = '[GObject.Object.Object]

-- | Cast to t'Conf', for types for which this is known to be safe. For general casts, use 'Data.GI.Base.ManagedPtr.castTo'.
toConf :: (MIO.MonadIO m, IsConf o) => o -> m Conf
toConf = MIO.liftIO . B.ManagedPtr.unsafeCastTo Conf

-- | Convert t'Conf' to and from t'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe Conf) where
    gvalueGType_ = c_wp_conf_get_type
    gvalueSet_ gv P.Nothing = B.GValue.set_object gv (FP.nullPtr :: FP.Ptr Conf)
    gvalueSet_ gv (P.Just obj) = B.ManagedPtr.withManagedPtr obj (B.GValue.set_object gv)
    gvalueGet_ gv = do
        ptr <- B.GValue.get_object gv :: IO (FP.Ptr Conf)
        if ptr /= FP.nullPtr
        then P.Just <$> B.ManagedPtr.newObject Conf ptr
        else return P.Nothing
        
    

#if defined(ENABLE_OVERLOADING)
type family ResolveConfMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveConfMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveConfMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveConfMethod "close" o = ConfCloseMethodInfo
    ResolveConfMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveConfMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveConfMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveConfMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveConfMethod "isOpen" o = ConfIsOpenMethodInfo
    ResolveConfMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveConfMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveConfMethod "open" o = ConfOpenMethodInfo
    ResolveConfMethod "parsePwContextSections" o = ConfParsePwContextSectionsMethodInfo
    ResolveConfMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveConfMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveConfMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveConfMethod "sectionUpdateProps" o = ConfSectionUpdatePropsMethodInfo
    ResolveConfMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveConfMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveConfMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveConfMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveConfMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveConfMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveConfMethod "getName" o = ConfGetNameMethodInfo
    ResolveConfMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveConfMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveConfMethod "getSection" o = ConfGetSectionMethodInfo
    ResolveConfMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveConfMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveConfMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveConfMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveConfMethod t Conf, O.OverloadedMethod info Conf p) => OL.IsLabel t (Conf -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveConfMethod t Conf, O.OverloadedMethod info Conf p, R.HasField t Conf p) => R.HasField t Conf p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveConfMethod t Conf, O.OverloadedMethodInfo info Conf) => OL.IsLabel t (O.MethodProxy info Conf) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif

-- VVV Prop "name"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

-- | Get the value of the “@name@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' conf #name
-- @
getConfName :: (MonadIO m, IsConf o) => o -> m T.Text
getConfName obj = MIO.liftIO $ checkUnexpectedNothing "getConfName" $ B.Properties.getObjectPropertyString obj "name"

-- | Construct a t'GValueConstruct' with valid value for the “@name@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructConfName :: (IsConf o, MIO.MonadIO m) => T.Text -> m (GValueConstruct o)
constructConfName val = MIO.liftIO $ do
    MIO.liftIO $ B.Properties.constructObjectPropertyString "name" (P.Just val)

#if defined(ENABLE_OVERLOADING)
data ConfNamePropertyInfo
instance AttrInfo ConfNamePropertyInfo where
    type AttrAllowedOps ConfNamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint ConfNamePropertyInfo = IsConf
    type AttrSetTypeConstraint ConfNamePropertyInfo = (~) T.Text
    type AttrTransferTypeConstraint ConfNamePropertyInfo = (~) T.Text
    type AttrTransferType ConfNamePropertyInfo = T.Text
    type AttrGetType ConfNamePropertyInfo = T.Text
    type AttrLabel ConfNamePropertyInfo = "name"
    type AttrOrigin ConfNamePropertyInfo = Conf
    attrGet = getConfName
    attrSet = undefined
    attrPut = undefined
    attrTransfer _ v = do
        return v
    attrConstruct = constructConfName
    attrClear = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.Conf.name"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-Conf.html#g:attr:name"
        })
#endif

-- VVV Prop "properties"
   -- Type: TInterface (Name {namespace = "Wp", name = "Properties"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

-- | Get the value of the “@properties@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' conf #properties
-- @
getConfProperties :: (MonadIO m, IsConf o) => o -> m (Maybe Wp.Properties.Properties)
getConfProperties obj = MIO.liftIO $ B.Properties.getObjectPropertyBoxed obj "properties" Wp.Properties.Properties

-- | Construct a t'GValueConstruct' with valid value for the “@properties@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructConfProperties :: (IsConf o, MIO.MonadIO m) => Wp.Properties.Properties -> m (GValueConstruct o)
constructConfProperties val = MIO.liftIO $ do
    MIO.liftIO $ B.Properties.constructObjectPropertyBoxed "properties" (P.Just val)

#if defined(ENABLE_OVERLOADING)
data ConfPropertiesPropertyInfo
instance AttrInfo ConfPropertiesPropertyInfo where
    type AttrAllowedOps ConfPropertiesPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint ConfPropertiesPropertyInfo = IsConf
    type AttrSetTypeConstraint ConfPropertiesPropertyInfo = (~) Wp.Properties.Properties
    type AttrTransferTypeConstraint ConfPropertiesPropertyInfo = (~) Wp.Properties.Properties
    type AttrTransferType ConfPropertiesPropertyInfo = Wp.Properties.Properties
    type AttrGetType ConfPropertiesPropertyInfo = (Maybe Wp.Properties.Properties)
    type AttrLabel ConfPropertiesPropertyInfo = "properties"
    type AttrOrigin ConfPropertiesPropertyInfo = Conf
    attrGet = getConfProperties
    attrSet = undefined
    attrPut = undefined
    attrTransfer _ v = do
        return v
    attrConstruct = constructConfProperties
    attrClear = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.Conf.properties"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-Conf.html#g:attr:properties"
        })
#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Conf
type instance O.AttributeList Conf = ConfAttributeList
type ConfAttributeList = ('[ '("name", ConfNamePropertyInfo), '("properties", ConfPropertiesPropertyInfo)] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
confName :: AttrLabelProxy "name"
confName = AttrLabelProxy

confProperties :: AttrLabelProxy "properties"
confProperties = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Conf = ConfSignalList
type ConfSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])

#endif

-- method Conf::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of the configuration file"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "properties"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "Properties" }
--           , argCType = Just "WpProperties*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a WpProperties with keys specifying how to load the WpConf object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "Conf" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_conf_new" wp_conf_new :: 
    CString ->                              -- name : TBasicType TUTF8
    Ptr Wp.Properties.Properties ->         -- properties : TInterface (Name {namespace = "Wp", name = "Properties"})
    IO (Ptr Conf)

-- | Creates a new WpConf object.
-- 
-- 
-- This does not open the files, it only creates the object. For most use cases, you should use 'GI.Wp.Objects.Conf.confNewOpen' instead.
confNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@name@/: the name of the configuration file
    -> Maybe (Wp.Properties.Properties)
    -- ^ /@properties@/: a WpProperties with keys specifying how to load the WpConf object
    -> m Conf
    -- ^ __Returns:__ a new WpConf object
confNew name properties = liftIO $ do
    name' <- textToCString name
    maybeProperties <- case properties of
        Nothing -> return FP.nullPtr
        Just jProperties -> do
            jProperties' <- B.ManagedPtr.disownBoxed jProperties
            return jProperties'
    result <- wp_conf_new name' maybeProperties
    checkUnexpectedReturnNULL "confNew" result
    result' <- (wrapObject Conf) result
    whenJust properties touchManagedPtr
    freeMem name'
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method Conf::new_open
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of the configuration file"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "properties"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "Properties" }
--           , argCType = Just "WpProperties*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a WpProperties with keys specifying how to load the WpConf object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "Conf" })
-- throws : True
-- Skip return : False

foreign import ccall "wp_conf_new_open" wp_conf_new_open :: 
    CString ->                              -- name : TBasicType TUTF8
    Ptr Wp.Properties.Properties ->         -- properties : TInterface (Name {namespace = "Wp", name = "Properties"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Conf)

-- | Creates a new WpConf object and opens the configuration file and its fragments, keeping them mapped in memory for further access.
confNewOpen ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@name@/: the name of the configuration file
    -> Maybe (Wp.Properties.Properties)
    -- ^ /@properties@/: a WpProperties with keys specifying how to load the WpConf object
    -> m (Maybe Conf)
    -- ^ __Returns:__ a new WpConf object, or NULL if an error occurred /(Can throw 'Data.GI.Base.GError.GError')/
confNewOpen name properties = liftIO $ do
    name' <- textToCString name
    maybeProperties <- case properties of
        Nothing -> return FP.nullPtr
        Just jProperties -> do
            jProperties' <- B.ManagedPtr.disownBoxed jProperties
            return jProperties'
    onException (do
        result <- propagateGError $ wp_conf_new_open name' maybeProperties
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- (wrapObject Conf) result'
            return result''
        whenJust properties touchManagedPtr
        freeMem name'
        return maybeResult
     ) (do
        freeMem name'
     )

#if defined(ENABLE_OVERLOADING)
#endif

-- method Conf::close
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Conf" }
--           , argCType = Just "WpConf*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the configuration" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "wp_conf_close" wp_conf_close :: 
    Ptr Conf ->                             -- self : TInterface (Name {namespace = "Wp", name = "Conf"})
    IO ()

-- | Closes the configuration file and its fragments.
confClose ::
    (B.CallStack.HasCallStack, MonadIO m, IsConf a) =>
    a
    -- ^ /@self@/: the configuration
    -> m ()
confClose self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    wp_conf_close self'
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data ConfCloseMethodInfo
instance (signature ~ (m ()), MonadIO m, IsConf a) => O.OverloadedMethod ConfCloseMethodInfo a signature where
    overloadedMethod = confClose

instance O.OverloadedMethodInfo ConfCloseMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.Conf.confClose",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-Conf.html#v:confClose"
        })


#endif

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

foreign import ccall "wp_conf_get_name" wp_conf_get_name :: 
    Ptr Conf ->                             -- self : TInterface (Name {namespace = "Wp", name = "Conf"})
    IO CString

-- | Gets the name of the configuration file.
confGetName ::
    (B.CallStack.HasCallStack, MonadIO m, IsConf a) =>
    a
    -- ^ /@self@/: the configuration
    -> m T.Text
    -- ^ __Returns:__ the name of the configuration file
confGetName self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- wp_conf_get_name self'
    checkUnexpectedReturnNULL "confGetName" result
    result' <- cstringToText result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data ConfGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsConf a) => O.OverloadedMethod ConfGetNameMethodInfo a signature where
    overloadedMethod = confGetName

instance O.OverloadedMethodInfo ConfGetNameMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.Conf.confGetName",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-Conf.html#v:confGetName"
        })


#endif

-- method Conf::get_section
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Conf" }
--           , argCType = Just "WpConf*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the configuration" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "section"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the section name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "SpaJson" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_conf_get_section" wp_conf_get_section :: 
    Ptr Conf ->                             -- self : TInterface (Name {namespace = "Wp", name = "Conf"})
    CString ->                              -- section : TBasicType TUTF8
    IO (Ptr Wp.SpaJson.SpaJson)

-- | This method will get the JSON value of a specific section from the configuration. If the same section is defined in multiple locations, the sections with the same name will be either merged in case of arrays and objects, or overridden in case of boolean, int, double and strings.
confGetSection ::
    (B.CallStack.HasCallStack, MonadIO m, IsConf a) =>
    a
    -- ^ /@self@/: the configuration
    -> T.Text
    -- ^ /@section@/: the section name
    -> m (Maybe Wp.SpaJson.SpaJson)
    -- ^ __Returns:__ the JSON value of the section or NULL if the section does not exist
confGetSection self section = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    section' <- textToCString section
    result <- wp_conf_get_section self' section'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Wp.SpaJson.SpaJson) result'
        return result''
    touchManagedPtr self
    freeMem section'
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data ConfGetSectionMethodInfo
instance (signature ~ (T.Text -> m (Maybe Wp.SpaJson.SpaJson)), MonadIO m, IsConf a) => O.OverloadedMethod ConfGetSectionMethodInfo a signature where
    overloadedMethod = confGetSection

instance O.OverloadedMethodInfo ConfGetSectionMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.Conf.confGetSection",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-Conf.html#v:confGetSection"
        })


#endif

-- method Conf::is_open
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Conf" }
--           , argCType = Just "WpConf*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the configuration" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "wp_conf_is_open" wp_conf_is_open :: 
    Ptr Conf ->                             -- self : TInterface (Name {namespace = "Wp", name = "Conf"})
    IO CInt

-- | Tests if the configuration files are open.
confIsOpen ::
    (B.CallStack.HasCallStack, MonadIO m, IsConf a) =>
    a
    -- ^ /@self@/: the configuration
    -> m Bool
    -- ^ __Returns:__ TRUE if the configuration files are open, FALSE otherwise
confIsOpen self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- wp_conf_is_open self'
    let result' = (/= 0) result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data ConfIsOpenMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsConf a) => O.OverloadedMethod ConfIsOpenMethodInfo a signature where
    overloadedMethod = confIsOpen

instance O.OverloadedMethodInfo ConfIsOpenMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.Conf.confIsOpen",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-Conf.html#v:confIsOpen"
        })


#endif

-- method Conf::open
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Conf" }
--           , argCType = Just "WpConf*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the configuration" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "wp_conf_open" wp_conf_open :: 
    Ptr Conf ->                             -- self : TInterface (Name {namespace = "Wp", name = "Conf"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Opens the configuration file and its fragments and keeps them mapped in memory for further access.
confOpen ::
    (B.CallStack.HasCallStack, MonadIO m, IsConf a) =>
    a
    -- ^ /@self@/: the configuration
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
confOpen self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    onException (do
        _ <- propagateGError $ wp_conf_open self'
        touchManagedPtr self
        return ()
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING)
data ConfOpenMethodInfo
instance (signature ~ (m ()), MonadIO m, IsConf a) => O.OverloadedMethod ConfOpenMethodInfo a signature where
    overloadedMethod = confOpen

instance O.OverloadedMethodInfo ConfOpenMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.Conf.confOpen",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-Conf.html#v:confOpen"
        })


#endif

-- method Conf::parse_pw_context_sections
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Conf" }
--           , argCType = Just "WpConf*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the configuration" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "context"
--           , argType = TBasicType TPtr
--           , argCType = Just "pw_context*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the associated pw_context"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "wp_conf_parse_pw_context_sections" wp_conf_parse_pw_context_sections :: 
    Ptr Conf ->                             -- self : TInterface (Name {namespace = "Wp", name = "Conf"})
    Ptr () ->                               -- context : TBasicType TPtr
    IO ()

-- | Parses standard pw_context sections from /@conf@/.
confParsePwContextSections ::
    (B.CallStack.HasCallStack, MonadIO m, IsConf a) =>
    a
    -- ^ /@self@/: the configuration
    -> Ptr ()
    -- ^ /@context@/: the associated pw_context
    -> m ()
confParsePwContextSections self context = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    wp_conf_parse_pw_context_sections self' context
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data ConfParsePwContextSectionsMethodInfo
instance (signature ~ (Ptr () -> m ()), MonadIO m, IsConf a) => O.OverloadedMethod ConfParsePwContextSectionsMethodInfo a signature where
    overloadedMethod = confParsePwContextSections

instance O.OverloadedMethodInfo ConfParsePwContextSectionsMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.Conf.confParsePwContextSections",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-Conf.html#v:confParsePwContextSections"
        })


#endif

-- method Conf::section_update_props
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Conf" }
--           , argCType = Just "WpConf*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the configuration" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "section"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the section name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "props"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "Properties" }
--           , argCType = Just "WpProperties*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the properties to update"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "wp_conf_section_update_props" wp_conf_section_update_props :: 
    Ptr Conf ->                             -- self : TInterface (Name {namespace = "Wp", name = "Conf"})
    CString ->                              -- section : TBasicType TUTF8
    Ptr Wp.Properties.Properties ->         -- props : TInterface (Name {namespace = "Wp", name = "Properties"})
    IO Int32

-- | Updates the given properties with the values of a specific section from the configuration.
confSectionUpdateProps ::
    (B.CallStack.HasCallStack, MonadIO m, IsConf a) =>
    a
    -- ^ /@self@/: the configuration
    -> T.Text
    -- ^ /@section@/: the section name
    -> Wp.Properties.Properties
    -- ^ /@props@/: the properties to update
    -> m Int32
    -- ^ __Returns:__ the number of properties updated
confSectionUpdateProps self section props = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    section' <- textToCString section
    props' <- unsafeManagedPtrGetPtr props
    result <- wp_conf_section_update_props self' section' props'
    touchManagedPtr self
    touchManagedPtr props
    freeMem section'
    return result

#if defined(ENABLE_OVERLOADING)
data ConfSectionUpdatePropsMethodInfo
instance (signature ~ (T.Text -> Wp.Properties.Properties -> m Int32), MonadIO m, IsConf a) => O.OverloadedMethod ConfSectionUpdatePropsMethodInfo a signature where
    overloadedMethod = confSectionUpdateProps

instance O.OverloadedMethodInfo ConfSectionUpdatePropsMethodInfo a where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.Conf.confSectionUpdateProps",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-Conf.html#v:confSectionUpdateProps"
        })


#endif


