packages feed

gi-wireplumber-0.5.14: GI/Wp/Functions.hs


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

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

module GI.Wp.Functions
    ( 

 -- * Methods


-- ** baseDirsFindFile #method:baseDirsFindFile#

    baseDirsFindFile                        ,


-- ** baseDirsNewFilesIterator #method:baseDirsNewFilesIterator#

    baseDirsNewFilesIterator                ,


-- ** domainLibraryQuark #method:domainLibraryQuark#

    domainLibraryQuark                      ,


-- ** getLibraryApiVersion #method:getLibraryApiVersion#

    getLibraryApiVersion                    ,


-- ** getLibraryVersion #method:getLibraryVersion#

    getLibraryVersion                       ,


-- ** init #method:init#

    init                                    ,


-- ** jsonUtilsMatchRules #method:jsonUtilsMatchRules#

    jsonUtilsMatchRules                     ,


-- ** jsonUtilsMatchRulesUpdateProperties #method:jsonUtilsMatchRulesUpdateProperties#

    jsonUtilsMatchRulesUpdateProperties     ,


-- ** jsonUtilsMergeContainers #method:jsonUtilsMergeContainers#

    jsonUtilsMergeContainers                ,


-- ** logSetLevel #method:logSetLevel#

    logSetLevel                             ,


-- ** logWriterDefault #method:logWriterDefault#

    logWriterDefault                        ,


-- ** procUtilsGetProcInfo #method:procUtilsGetProcInfo#

    procUtilsGetProcInfo                    ,


-- ** spaDynamicIdTableRegister #method:spaDynamicIdTableRegister#

    spaDynamicIdTableRegister               ,


-- ** spaDynamicTypeDeinit #method:spaDynamicTypeDeinit#

    spaDynamicTypeDeinit                    ,


-- ** spaDynamicTypeInit #method:spaDynamicTypeInit#

    spaDynamicTypeInit                      ,


-- ** spaDynamicTypeRegister #method:spaDynamicTypeRegister#

    spaDynamicTypeRegister                  ,


-- ** spaIdTableFindValue #method:spaIdTableFindValue#

    spaIdTableFindValue                     ,


-- ** spaIdTableFindValueFromName #method:spaIdTableFindValueFromName#

    spaIdTableFindValueFromName             ,


-- ** spaIdTableFindValueFromShortName #method:spaIdTableFindValueFromShortName#

    spaIdTableFindValueFromShortName        ,


-- ** spaIdTableFromName #method:spaIdTableFromName#

    spaIdTableFromName                      ,


-- ** spaIdTableGetType #method:spaIdTableGetType#

    spaIdTableGetType                       ,


-- ** spaIdTableNewIterator #method:spaIdTableNewIterator#

    spaIdTableNewIterator                   ,


-- ** spaIdValueArrayGetItemType #method:spaIdValueArrayGetItemType#

    spaIdValueArrayGetItemType              ,


-- ** spaIdValueFromName #method:spaIdValueFromName#

    spaIdValueFromName                      ,


-- ** spaIdValueFromNumber #method:spaIdValueFromNumber#

    spaIdValueFromNumber                    ,


-- ** spaIdValueFromShortName #method:spaIdValueFromShortName#

    spaIdValueFromShortName                 ,


-- ** spaIdValueGetType #method:spaIdValueGetType#

    spaIdValueGetType                       ,


-- ** spaIdValueGetValueType #method:spaIdValueGetValueType#

    spaIdValueGetValueType                  ,


-- ** spaIdValueName #method:spaIdValueName#

    spaIdValueName                          ,


-- ** spaIdValueNumber #method:spaIdValueNumber#

    spaIdValueNumber                        ,


-- ** spaIdValueShortName #method:spaIdValueShortName#

    spaIdValueShortName                     ,


-- ** spaLogGetInstance #method:spaLogGetInstance#

    spaLogGetInstance                       ,




    ) 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.GLib.Enums as GLib.Enums
import qualified GI.GLib.Flags as GLib.Flags
import qualified GI.GLib.Structs.LogField as GLib.LogField
import qualified GI.Wp.Callbacks as Wp.Callbacks
import {-# SOURCE #-} qualified GI.Wp.Flags as Wp.Flags
import {-# SOURCE #-} qualified GI.Wp.Objects.SpaType as Wp.SpaType
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.ProcInfo as Wp.ProcInfo
import {-# SOURCE #-} qualified GI.Wp.Structs.Properties as Wp.Properties
import {-# SOURCE #-} qualified GI.Wp.Structs.SpaJson as Wp.SpaJson

#else
import qualified GI.GLib.Enums as GLib.Enums
import qualified GI.GLib.Flags as GLib.Flags
import qualified GI.GLib.Structs.LogField as GLib.LogField
import qualified GI.Wp.Callbacks as Wp.Callbacks
import {-# SOURCE #-} qualified GI.Wp.Flags as Wp.Flags
import {-# SOURCE #-} qualified GI.Wp.Objects.SpaType as Wp.SpaType
import {-# SOURCE #-} qualified GI.Wp.Structs.Iterator as Wp.Iterator
import {-# SOURCE #-} qualified GI.Wp.Structs.ProcInfo as Wp.ProcInfo
import {-# SOURCE #-} qualified GI.Wp.Structs.Properties as Wp.Properties
import {-# SOURCE #-} qualified GI.Wp.Structs.SpaJson as Wp.SpaJson

#endif

-- function spa_log_get_instance
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_log_get_instance" wp_spa_log_get_instance :: 
    IO (Ptr ())

-- | Gets WirePlumber\'s instance of spa_log.
spaLogGetInstance ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m (Ptr ())
    -- ^ __Returns:__ WirePlumber\'s instance of spa_log, which can be used to redirect PipeWire\'s log messages to the currently installed GLogWriterFunc. This is installed automatically when you call 'GI.Wp.Functions.init' with WP_INIT_SET_PW_LOG set in the flags
spaLogGetInstance  = liftIO $ do
    result <- wp_spa_log_get_instance
    return result


-- function spa_id_value_short_name
-- Args: [ Arg
--           { argCName = "id"
--           , argType = TBasicType TPtr
--           , argCType = Just "WpSpaIdValue"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an id value" , 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_spa_id_value_short_name" wp_spa_id_value_short_name :: 
    Ptr () ->                               -- id : TBasicType TPtr
    IO CString

-- | Gets the short name of an id value.
spaIdValueShortName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@id@/: an id value
    -> m T.Text
    -- ^ __Returns:__ the short name of this id value
spaIdValueShortName id = liftIO $ do
    result <- wp_spa_id_value_short_name id
    checkUnexpectedReturnNULL "spaIdValueShortName" result
    result' <- cstringToText result
    return result'


-- function spa_id_value_number
-- Args: [ Arg
--           { argCName = "id"
--           , argType = TBasicType TPtr
--           , argCType = Just "WpSpaIdValue"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an id value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_value_number" wp_spa_id_value_number :: 
    Ptr () ->                               -- id : TBasicType TPtr
    IO Word32

-- | Gets the numeric value of an id value.
spaIdValueNumber ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@id@/: an id value
    -> m Word32
    -- ^ __Returns:__ the numeric representation of this id value
spaIdValueNumber id = liftIO $ do
    result <- wp_spa_id_value_number id
    return result


-- function spa_id_value_name
-- Args: [ Arg
--           { argCName = "id"
--           , argType = TBasicType TPtr
--           , argCType = Just "WpSpaIdValue"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an id value" , 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_spa_id_value_name" wp_spa_id_value_name :: 
    Ptr () ->                               -- id : TBasicType TPtr
    IO CString

-- | Gets the name of an id value.
spaIdValueName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@id@/: an id value
    -> m T.Text
    -- ^ __Returns:__ the full name of this id value
spaIdValueName id = liftIO $ do
    result <- wp_spa_id_value_name id
    checkUnexpectedReturnNULL "spaIdValueName" result
    result' <- cstringToText result
    return result'


-- function spa_id_value_get_value_type
-- Args: [ Arg
--           { argCName = "id"
--           , argType = TBasicType TPtr
--           , argCType = Just "WpSpaIdValue"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an id value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "table"
--           , argType = TBasicType TPtr
--           , argCType = Just "WpSpaIdTable*"
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the associated WpSpaIdTable"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "SpaType" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_value_get_value_type" wp_spa_id_value_get_value_type :: 
    Ptr () ->                               -- id : TBasicType TPtr
    Ptr (Ptr ()) ->                         -- table : TBasicType TPtr
    IO (Ptr Wp.SpaType.SpaType)

-- | Returns the value type associated with this WpSpaIdValue.
-- 
-- 
-- This information is useful when /@id@/ represents an object field, which can take a value of an arbitrary type.
-- When the returned type is (or is derived from) SPA_TYPE_Id or SPA_TYPE_Object, /@table@/ is set to point to the WpSpaIdTable that contains the possible Id values \/ object fields.
spaIdValueGetValueType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@id@/: an id value
    -> m ((Wp.SpaType.SpaType, Ptr ()))
    -- ^ __Returns:__ the value type associated with /@id@/
spaIdValueGetValueType id = liftIO $ do
    table <- callocMem :: IO (Ptr (Ptr ()))
    result <- wp_spa_id_value_get_value_type id table
    checkUnexpectedReturnNULL "spaIdValueGetValueType" result
    result' <- (newPtr Wp.SpaType.SpaType) result
    table' <- peek table
    freeMem table
    return (result', table')


-- function spa_id_value_get_type
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TGType)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_value_get_type" wp_spa_id_value_get_type :: 
    IO CGType

-- | /No description available in the introspection data./
spaIdValueGetType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m GType
spaIdValueGetType  = liftIO $ do
    result <- wp_spa_id_value_get_type
    let result' = GType result
    return result'


-- function spa_id_value_from_short_name
-- Args: [ Arg
--           { argCName = "table_name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the name of the WpSpaIdTable to look up the value in"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "short_name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the short name of the value to look up"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_value_from_short_name" wp_spa_id_value_from_short_name :: 
    CString ->                              -- table_name : TBasicType TUTF8
    CString ->                              -- short_name : TBasicType TUTF8
    IO (Ptr ())

-- | Looks up an id value given its container /@tableName@/ and its /@shortName@/.
spaIdValueFromShortName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@tableName@/: the name of the WpSpaIdTable to look up the value in
    -> T.Text
    -- ^ /@shortName@/: the short name of the value to look up
    -> m (Ptr ())
    -- ^ __Returns:__ the id value or NULL if it was not found
spaIdValueFromShortName tableName shortName = liftIO $ do
    tableName' <- textToCString tableName
    shortName' <- textToCString shortName
    result <- wp_spa_id_value_from_short_name tableName' shortName'
    freeMem tableName'
    freeMem shortName'
    return result


-- function spa_id_value_from_number
-- Args: [ Arg
--           { argCName = "table_name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the name of the WpSpaIdTable to look up the value in"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "id"
--           , argType = TBasicType TUInt
--           , argCType = Just "guint"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the numeric representation of the value to look up"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_value_from_number" wp_spa_id_value_from_number :: 
    CString ->                              -- table_name : TBasicType TUTF8
    Word32 ->                               -- id : TBasicType TUInt
    IO (Ptr ())

-- | Looks up an id value given its container /@tableName@/ and its numeric representation, /@id@/.
spaIdValueFromNumber ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@tableName@/: the name of the WpSpaIdTable to look up the value in
    -> Word32
    -- ^ /@id@/: the numeric representation of the value to look up
    -> m (Ptr ())
    -- ^ __Returns:__ the id value or NULL if it was not found
spaIdValueFromNumber tableName id = liftIO $ do
    tableName' <- textToCString tableName
    result <- wp_spa_id_value_from_number tableName' id
    freeMem tableName'
    return result


-- function spa_id_value_from_name
-- Args: [ Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the full name of an id value"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_value_from_name" wp_spa_id_value_from_name :: 
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr ())

-- | Looks up an id value (enum, flag or object field) directly from its full name.
-- 
-- 
-- For instance, \"Spa:Enum:Direction:Input\" will resolve to the id value that represents \"Input\" in the \"Spa:Enum:Direction\" enum.
spaIdValueFromName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@name@/: the full name of an id value
    -> m (Ptr ())
    -- ^ __Returns:__ the id value for /@name@/, or NULL if no such id value was found
spaIdValueFromName name = liftIO $ do
    name' <- textToCString name
    result <- wp_spa_id_value_from_name name'
    freeMem name'
    return result


-- function spa_id_value_array_get_item_type
-- Args: [ Arg
--           { argCName = "id"
--           , argType = TBasicType TPtr
--           , argCType = Just "WpSpaIdValue"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an id value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "table"
--           , argType = TBasicType TPtr
--           , argCType = Just "WpSpaIdTable*"
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the associated WpSpaIdTable"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "SpaType" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_value_array_get_item_type" wp_spa_id_value_array_get_item_type :: 
    Ptr () ->                               -- id : TBasicType TPtr
    Ptr (Ptr ()) ->                         -- table : TBasicType TPtr
    IO (Ptr Wp.SpaType.SpaType)

-- | If the value type of /@id@/ is SPA_TYPE_Array, this function returns the type that is allowed to be contained inside the array.
-- 
-- 
-- When the returned type is (or is derived from) SPA_TYPE_Id or SPA_TYPE_Object, /@table@/ is set to point to the WpSpaIdTable that contains the possible Id values \/ object fields.
spaIdValueArrayGetItemType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@id@/: an id value
    -> m ((Wp.SpaType.SpaType, Ptr ()))
    -- ^ __Returns:__ the type that is allowed in the array, if /@id@/ represents an object field that takes an array as value
spaIdValueArrayGetItemType id = liftIO $ do
    table <- callocMem :: IO (Ptr (Ptr ()))
    result <- wp_spa_id_value_array_get_item_type id table
    checkUnexpectedReturnNULL "spaIdValueArrayGetItemType" result
    result' <- (newPtr Wp.SpaType.SpaType) result
    table' <- peek table
    freeMem table
    return (result', table')


-- function spa_id_table_new_iterator
-- Args: [ Arg
--           { argCName = "table"
--           , argType = TBasicType TPtr
--           , argCType = Just "WpSpaIdTable"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the id table" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "Iterator" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_table_new_iterator" wp_spa_id_table_new_iterator :: 
    Ptr () ->                               -- table : TBasicType TPtr
    IO (Ptr Wp.Iterator.Iterator)

-- | This function returns an iterator that allows you to iterate through the values associated with this table.
-- 
-- 
-- The items in the iterator are of type WpSpaIdValue.
spaIdTableNewIterator ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@table@/: the id table
    -> m Wp.Iterator.Iterator
    -- ^ __Returns:__ a WpIterator that iterates over WpSpaIdValue items
spaIdTableNewIterator table = liftIO $ do
    result <- wp_spa_id_table_new_iterator table
    checkUnexpectedReturnNULL "spaIdTableNewIterator" result
    result' <- (wrapBoxed Wp.Iterator.Iterator) result
    return result'


-- function spa_id_table_get_type
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TGType)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_table_get_type" wp_spa_id_table_get_type :: 
    IO CGType

-- | /No description available in the introspection data./
spaIdTableGetType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m GType
spaIdTableGetType  = liftIO $ do
    result <- wp_spa_id_table_get_type
    let result' = GType result
    return result'


-- function spa_id_table_from_name
-- Args: [ Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the full name of an id table"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_table_from_name" wp_spa_id_table_from_name :: 
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr ())

-- | Finds a WpSpaIdTable given its name.
-- 
-- 
-- This name can either be the full type name of an object type, or the name of an enum (which is (!!) a type). For example, \"Spa:Pod:Object:Param:Format\" and \"Spa:Enum:ParamId\" are both valid table names.
spaIdTableFromName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@name@/: the full name of an id table
    -> m (Ptr ())
    -- ^ __Returns:__ the associated table, or NULL
spaIdTableFromName name = liftIO $ do
    name' <- textToCString name
    result <- wp_spa_id_table_from_name name'
    freeMem name'
    return result


-- function spa_id_table_find_value_from_short_name
-- Args: [ Arg
--           { argCName = "table"
--           , argType = TBasicType TPtr
--           , argCType = Just "WpSpaIdTable"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the id table" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "short_name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the short name of a value that is contained in the table"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_table_find_value_from_short_name" wp_spa_id_table_find_value_from_short_name :: 
    Ptr () ->                               -- table : TBasicType TPtr
    CString ->                              -- short_name : TBasicType TUTF8
    IO (Ptr ())

-- | Finds a short named value in an SPA Id table.
spaIdTableFindValueFromShortName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@table@/: the id table
    -> T.Text
    -- ^ /@shortName@/: the short name of a value that is contained in the table
    -> m (Ptr ())
    -- ^ __Returns:__ the WpSpaIdValue associated with /@shortName@/, or NULL
spaIdTableFindValueFromShortName table shortName = liftIO $ do
    shortName' <- textToCString shortName
    result <- wp_spa_id_table_find_value_from_short_name table shortName'
    freeMem shortName'
    return result


-- function spa_id_table_find_value_from_name
-- Args: [ Arg
--           { argCName = "table"
--           , argType = TBasicType TPtr
--           , argCType = Just "WpSpaIdTable"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the id table" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the full name of a value that is contained in the table"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_table_find_value_from_name" wp_spa_id_table_find_value_from_name :: 
    Ptr () ->                               -- table : TBasicType TPtr
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr ())

-- | Finds a named value in an SPA Id table.
spaIdTableFindValueFromName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@table@/: the id table
    -> T.Text
    -- ^ /@name@/: the full name of a value that is contained in the table
    -> m (Ptr ())
    -- ^ __Returns:__ the WpSpaIdValue associated with /@name@/, or NULL
spaIdTableFindValueFromName table name = liftIO $ do
    name' <- textToCString name
    result <- wp_spa_id_table_find_value_from_name table name'
    freeMem name'
    return result


-- function spa_id_table_find_value
-- Args: [ Arg
--           { argCName = "table"
--           , argType = TBasicType TPtr
--           , argCType = Just "WpSpaIdTable"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the id table" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TBasicType TUInt
--           , argCType = Just "guint"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a numeric value that is contained in the table"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_id_table_find_value" wp_spa_id_table_find_value :: 
    Ptr () ->                               -- table : TBasicType TPtr
    Word32 ->                               -- value : TBasicType TUInt
    IO (Ptr ())

-- | Finds a value in an SPA Id table.
spaIdTableFindValue ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@table@/: the id table
    -> Word32
    -- ^ /@value@/: a numeric value that is contained in the table
    -> m (Ptr ())
    -- ^ __Returns:__ the WpSpaIdValue associated with /@value@/, or NULL
spaIdTableFindValue table value = liftIO $ do
    result <- wp_spa_id_table_find_value table value
    return result


-- function spa_dynamic_type_register
-- Args: [ Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of the type"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "parent"
--           , argType = TInterface Name { namespace = "Wp" , name = "SpaType" }
--           , argCType = Just "WpSpaType"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the parent type" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "values"
--           , argType = TBasicType TPtr
--           , argCType = Just "const spa_type_info*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "an array of spa_type_info that contains the values of the type, used only for Object types"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "SpaType" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_dynamic_type_register" wp_spa_dynamic_type_register :: 
    CString ->                              -- name : TBasicType TUTF8
    Ptr Wp.SpaType.SpaType ->               -- parent : TInterface (Name {namespace = "Wp", name = "SpaType"})
    Ptr () ->                               -- values : TBasicType TPtr
    IO (Ptr Wp.SpaType.SpaType)

-- | Registers an additional type in the spa type system.
-- 
-- 
-- This is useful to add a custom pod object type.
-- Note that both /@name@/ and /@values@/ must be statically allocated, or otherwise guaranteed to be kept in memory until 'GI.Wp.Functions.spaDynamicTypeDeinit' is called. No memory copy is done by this function.
spaDynamicTypeRegister ::
    (B.CallStack.HasCallStack, MonadIO m, Wp.SpaType.IsSpaType a) =>
    T.Text
    -- ^ /@name@/: the name of the type
    -> a
    -- ^ /@parent@/: the parent type
    -> Ptr ()
    -- ^ /@values@/: an array of spa_type_info that contains the values of the type, used only for Object types
    -> m Wp.SpaType.SpaType
    -- ^ __Returns:__ the new type
spaDynamicTypeRegister name parent values = liftIO $ do
    name' <- textToCString name
    parent' <- unsafeManagedPtrCastPtr parent
    result <- wp_spa_dynamic_type_register name' parent' values
    checkUnexpectedReturnNULL "spaDynamicTypeRegister" result
    result' <- (newPtr Wp.SpaType.SpaType) result
    touchManagedPtr parent
    freeMem name'
    return result'


-- function spa_dynamic_type_init
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_dynamic_type_init" wp_spa_dynamic_type_init :: 
    IO ()

-- | Initializes the spa dynamic type registry.
-- 
-- 
-- This allows registering new spa types at runtime. The spa type system still works if this function is not called.
-- Normally called by 'GI.Wp.Functions.init' when WP_INIT_SPA_TYPES is passed in its flags.
spaDynamicTypeInit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
spaDynamicTypeInit  = liftIO $ do
    wp_spa_dynamic_type_init
    return ()


-- function spa_dynamic_type_deinit
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_dynamic_type_deinit" wp_spa_dynamic_type_deinit :: 
    IO ()

-- | Deinitializes the spa type registry.
-- 
-- 
-- You do not need to ever call this, unless you want to free memory at the end of the execution of a test, so that it doesn\'t show as leaked in the memory profiler.
spaDynamicTypeDeinit ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
spaDynamicTypeDeinit  = liftIO $ do
    wp_spa_dynamic_type_deinit
    return ()


-- function spa_dynamic_id_table_register
-- Args: [ Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of the id table"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "values"
--           , argType = TBasicType TPtr
--           , argCType = Just "const spa_type_info*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "an array of spa_type_info that contains the values of the table"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TPtr)
-- throws : False
-- Skip return : False

foreign import ccall "wp_spa_dynamic_id_table_register" wp_spa_dynamic_id_table_register :: 
    CString ->                              -- name : TBasicType TUTF8
    Ptr () ->                               -- values : TBasicType TPtr
    IO (Ptr ())

-- | Registers an additional WpSpaIdTable in the spa type system.
-- 
-- 
-- This is useful to add custom enumeration types.
-- Note that both /@name@/ and /@values@/ must be statically allocated, or otherwise guaranteed to be kept in memory until 'GI.Wp.Functions.spaDynamicTypeDeinit' is called. No memory copy is done by this function.
spaDynamicIdTableRegister ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@name@/: the name of the id table
    -> Ptr ()
    -- ^ /@values@/: an array of spa_type_info that contains the values of the table
    -> m (Ptr ())
    -- ^ __Returns:__ the new table
spaDynamicIdTableRegister name values = liftIO $ do
    name' <- textToCString name
    result <- wp_spa_dynamic_id_table_register name' values
    freeMem name'
    return result


-- function proc_utils_get_proc_info
-- Args: [ Arg
--           { argCName = "pid"
--           , argType = TBasicType Tpid_t
--           , argCType = Just "pid_t"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the PID to get the process information from"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "ProcInfo" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_proc_utils_get_proc_info" wp_proc_utils_get_proc_info :: 
    DI.Int32 ->                             -- pid : TBasicType Tpid_t
    IO (Ptr Wp.ProcInfo.ProcInfo)

-- | Gets the process information of a given PID.
procUtilsGetProcInfo ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DI.Int32
    -- ^ /@pid@/: the PID to get the process information from
    -> m Wp.ProcInfo.ProcInfo
    -- ^ __Returns:__ (transfer full): the process information of the given PID
procUtilsGetProcInfo pid = liftIO $ do
    result <- wp_proc_utils_get_proc_info pid
    checkUnexpectedReturnNULL "procUtilsGetProcInfo" result
    result' <- (wrapBoxed Wp.ProcInfo.ProcInfo) result
    return result'


-- function log_writer_default
-- Args: [ Arg
--           { argCName = "log_level"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "LogLevelFlags" }
--           , argCType = Just "GLogLevelFlags"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "fields"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "LogField" }
--           , argCType = Just "const GLogField*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "n_fields"
--           , argType = TBasicType TSize
--           , argCType = Just "gsize"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , argCType = Just "gpointer"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GLib" , name = "LogWriterOutput" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_log_writer_default" wp_log_writer_default :: 
    CInt ->                                 -- log_level : TInterface (Name {namespace = "GLib", name = "LogLevelFlags"})
    Ptr GLib.LogField.LogField ->           -- fields : TInterface (Name {namespace = "GLib", name = "LogField"})
    FCT.CSize ->                            -- n_fields : TBasicType TSize
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO CUInt

-- | WirePlumber\'s GLogWriterFunc.
-- 
-- 
-- This is installed automatically when you call 'GI.Wp.Functions.init' with WP_INIT_SET_GLIB_LOG set in the flags
logWriterDefault ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [GLib.Flags.LogLevelFlags]
    -> GLib.LogField.LogField
    -> FCT.CSize
    -> Ptr ()
    -> m GLib.Enums.LogWriterOutput
logWriterDefault logLevel fields nFields userData = liftIO $ do
    let logLevel' = gflagsToWord logLevel
    fields' <- unsafeManagedPtrGetPtr fields
    result <- wp_log_writer_default logLevel' fields' nFields userData
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr fields
    return result'


-- function log_set_level
-- Args: [ Arg
--           { argCName = "log_level"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , 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_log_set_level" wp_log_set_level :: 
    CString ->                              -- log_level : TBasicType TUTF8
    IO CInt

-- | /No description available in the introspection data./
logSetLevel ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -> m Bool
logSetLevel logLevel = liftIO $ do
    logLevel' <- textToCString logLevel
    result <- wp_log_set_level logLevel'
    let result' = (/= 0) result
    freeMem logLevel'
    return result'


-- function json_utils_merge_containers
-- Args: [ Arg
--           { argCName = "a"
--           , argType = TInterface Name { namespace = "Wp" , name = "SpaJson" }
--           , argCType = Just "WpSpaJson*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a JSON container" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "b"
--           , argType = TInterface Name { namespace = "Wp" , name = "SpaJson" }
--           , argCType = Just "WpSpaJson*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a JSON container" , 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_json_utils_merge_containers" wp_json_utils_merge_containers :: 
    Ptr Wp.SpaJson.SpaJson ->               -- a : TInterface (Name {namespace = "Wp", name = "SpaJson"})
    Ptr Wp.SpaJson.SpaJson ->               -- b : TInterface (Name {namespace = "Wp", name = "SpaJson"})
    IO (Ptr Wp.SpaJson.SpaJson)

-- | Merges two JSON containers (objects or arrays) into one.
-- 
-- 
-- If both /@a@/ and /@b@/ are objects, the result will be a new object containing all properties from both /@a@/ and /@b@/. If a property exists in both /@a@/ and /@b@/, the values are recursively merged. If a property exists in both /@a@/ and /@b@/ and the property name starts with the \"override.\" prefix in either of those, the value from the key with the prefix is used.
-- If both /@a@/ and /@b@/ are arrays, the result will be a new array containing all elements from both /@a@/ and /@b@/.
-- If /@a@/ and /@b@/ are not of the same type, NULL is returned.
jsonUtilsMergeContainers ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Wp.SpaJson.SpaJson
    -- ^ /@a@/: a JSON container
    -> Wp.SpaJson.SpaJson
    -- ^ /@b@/: a JSON container
    -> m Wp.SpaJson.SpaJson
    -- ^ __Returns:__ a new JSON container containing the merged contents of /@a@/ and /@b@/ or NULL if /@a@/ and /@b@/ are not of the same type
jsonUtilsMergeContainers a b = liftIO $ do
    a' <- unsafeManagedPtrGetPtr a
    b' <- unsafeManagedPtrGetPtr b
    result <- wp_json_utils_merge_containers a' b'
    checkUnexpectedReturnNULL "jsonUtilsMergeContainers" result
    result' <- (wrapBoxed Wp.SpaJson.SpaJson) result
    touchManagedPtr a
    touchManagedPtr b
    return result'


-- function json_utils_match_rules_update_properties
-- Args: [ Arg
--           { argCName = "json"
--           , argType = TInterface Name { namespace = "Wp" , name = "SpaJson" }
--           , argCType = Just "WpSpaJson*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a JSON array containing rules in the format accepted by wp_json_utils_match_rules()"
--                 , 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 match against the rules and also update, acting on the \"update-props\" action"
--                 , 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_json_utils_match_rules_update_properties" wp_json_utils_match_rules_update_properties :: 
    Ptr Wp.SpaJson.SpaJson ->               -- json : TInterface (Name {namespace = "Wp", name = "SpaJson"})
    Ptr Wp.Properties.Properties ->         -- props : TInterface (Name {namespace = "Wp", name = "Properties"})
    IO Int32

-- | Matches the given properties against a set of rules described in JSON and updates the properties if the rule actions include the \"update-props\" action.
jsonUtilsMatchRulesUpdateProperties ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Wp.SpaJson.SpaJson
    -- ^ /@json@/: a JSON array containing rules in the format accepted by 'GI.Wp.Functions.jsonUtilsMatchRules'
    -> Wp.Properties.Properties
    -- ^ /@props@/: the properties to match against the rules and also update, acting on the \"update-props\" action
    -> m Int32
    -- ^ __Returns:__ the number of properties that were updated
jsonUtilsMatchRulesUpdateProperties json props = liftIO $ do
    json' <- unsafeManagedPtrGetPtr json
    props' <- unsafeManagedPtrGetPtr props
    result <- wp_json_utils_match_rules_update_properties json' props'
    touchManagedPtr json
    touchManagedPtr props
    return result


-- function json_utils_match_rules
-- Args: [ Arg
--           { argCName = "json"
--           , argType = TInterface Name { namespace = "Wp" , name = "SpaJson" }
--           , argCType = Just "WpSpaJson*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a JSON array containing rules in the described format"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "match_props"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "Properties" }
--           , argCType = Just "WpProperties*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the properties to match against the rules"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "callback"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "RuleMatchCallback" }
--           , argCType = Just "WpRuleMatchCallback"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a function to call for each action on a successful match"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeCall
--           , argClosure = 3
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TBasicType TPtr
--           , argCType = Just "gpointer"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "data to be passed to @callback"
--                 , 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_json_utils_match_rules" wp_json_utils_match_rules :: 
    Ptr Wp.SpaJson.SpaJson ->               -- json : TInterface (Name {namespace = "Wp", name = "SpaJson"})
    Ptr Wp.Properties.Properties ->         -- match_props : TInterface (Name {namespace = "Wp", name = "Properties"})
    FunPtr Wp.Callbacks.C_RuleMatchCallback -> -- callback : TInterface (Name {namespace = "Wp", name = "RuleMatchCallback"})
    Ptr () ->                               -- data : TBasicType TPtr
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Matches the given properties against a set of rules described in JSON and calls the given callback to perform actions on a successful match.
-- 
-- 
-- The given JSON should be an array of objects, where each object has a \"matches\" and an \"actions\" property. The \"matches\" value should also be an array of objects, where each object is a set of properties to match. Inside such an object, all properties must match to consider a successful match. However, if multiple objects are provided, only one object needs to match.
-- The \"actions\" value should be an object where the key is the action name and the value can be any valid JSON. Both the action name and the value are passed as-is on the /@callback@/.
jsonUtilsMatchRules ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Wp.SpaJson.SpaJson
    -- ^ /@json@/: a JSON array containing rules in the described format
    -> Wp.Properties.Properties
    -- ^ /@matchProps@/: the properties to match against the rules
    -> FunPtr Wp.Callbacks.C_RuleMatchCallback
    -- ^ /@callback@/: a function to call for each action on a successful match
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
jsonUtilsMatchRules json matchProps callback = liftIO $ do
    json' <- unsafeManagedPtrGetPtr json
    matchProps' <- unsafeManagedPtrGetPtr matchProps
    let data_ = nullPtr
    onException (do
        _ <- propagateGError $ wp_json_utils_match_rules json' matchProps' callback data_
        safeFreeFunPtr $ castFunPtrToPtr callback
        touchManagedPtr json
        touchManagedPtr matchProps
        return ()
     ) (do
        safeFreeFunPtr $ castFunPtrToPtr callback
        return ()
     )


-- function init
-- Args: [ Arg
--           { argCName = "flags"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "InitFlags" }
--           , argCType = Just "WpInitFlags"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "initialization flags"
--                 , 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_init" wp_init :: 
    CUInt ->                                -- flags : TInterface (Name {namespace = "Wp", name = "InitFlags"})
    IO ()

-- | Initializes WirePlumber and PipeWire underneath.
-- 
-- 
-- /@flags@/ can modify which parts are initialized, in cases where you want to handle part of this initialization externally.
init ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Wp.Flags.InitFlags]
    -- ^ /@flags@/: initialization flags
    -> m ()
init flags = liftIO $ do
    let flags' = gflagsToWord flags
    wp_init flags'
    return ()


-- function get_library_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "wp_get_library_version" wp_get_library_version :: 
    IO CString

-- | Gets the WirePlumber library version.
-- 
-- /Since: 0.4.12/
getLibraryVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    -- ^ __Returns:__ WirePlumber library version
getLibraryVersion  = liftIO $ do
    result <- wp_get_library_version
    checkUnexpectedReturnNULL "getLibraryVersion" result
    result' <- cstringToText result
    return result'


-- function get_library_api_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "wp_get_library_api_version" wp_get_library_api_version :: 
    IO CString

-- | Gets the WirePlumber library API version.
-- 
-- /Since: 0.4.12/
getLibraryApiVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    -- ^ __Returns:__ WirePlumber library API version
getLibraryApiVersion  = liftIO $ do
    result <- wp_get_library_api_version
    checkUnexpectedReturnNULL "getLibraryApiVersion" result
    result' <- cstringToText result
    return result'


-- function domain_library_quark
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "wp_domain_library_quark" wp_domain_library_quark :: 
    IO Word32

-- | /No description available in the introspection data./
domainLibraryQuark ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
domainLibraryQuark  = liftIO $ do
    result <- wp_domain_library_quark
    return result


-- function base_dirs_new_files_iterator
-- Args: [ Arg
--           { argCName = "flags"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "BaseDirsFlags" }
--           , argCType = Just "WpBaseDirsFlags"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "flags to specify the directories to look into and other options specific to the kind of file being looked up"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "subdir"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the name of the subdirectory to search in, inside the configuration directories"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "suffix"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The filename suffix, NULL matches all entries"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "Iterator" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_base_dirs_new_files_iterator" wp_base_dirs_new_files_iterator :: 
    CUInt ->                                -- flags : TInterface (Name {namespace = "Wp", name = "BaseDirsFlags"})
    CString ->                              -- subdir : TBasicType TUTF8
    CString ->                              -- suffix : TBasicType TUTF8
    IO (Ptr Wp.Iterator.Iterator)

-- | Creates an iterator to iterate over all files that match /@suffix@/ within the /@subdir@/ of the directories specified in /@flags@/.
-- 
-- 
-- The /@subdir@/ parameter is the name of the subdirectory to search in, inside the directories specified by /@flags@/. If /@subdir@/ is NULL, the base path of each directory is used. If /@subdir@/ is an absolute path, files are only looked up in that directory and the directories in /@flags@/ are ignored.
-- The /@suffix@/ parameter is the filename suffix to match. If /@suffix@/ is NULL, all files are matched.
-- The iterator will iterate over the absolute paths of all the files files found, in the order of priority of the directories, starting from the lowest priority directory (e.g. \/usr\/share\/wireplumber) and ending with the highest priority directory (e.g. $XDG_CONFIG_HOME\/wireplumber). Files within each directory are also sorted by filename.
-- 
-- /Since: 0.5.0/
baseDirsNewFilesIterator ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Wp.Flags.BaseDirsFlags]
    -- ^ /@flags@/: flags to specify the directories to look into and other options specific to the kind of file being looked up
    -> Maybe (T.Text)
    -- ^ /@subdir@/: the name of the subdirectory to search in, inside the configuration directories
    -> Maybe (T.Text)
    -- ^ /@suffix@/: The filename suffix, NULL matches all entries
    -> m Wp.Iterator.Iterator
    -- ^ __Returns:__ a new iterator iterating over strings which are absolute & canonicalized paths to the files found
baseDirsNewFilesIterator flags subdir suffix = liftIO $ do
    let flags' = gflagsToWord flags
    maybeSubdir <- case subdir of
        Nothing -> return FP.nullPtr
        Just jSubdir -> do
            jSubdir' <- textToCString jSubdir
            return jSubdir'
    maybeSuffix <- case suffix of
        Nothing -> return FP.nullPtr
        Just jSuffix -> do
            jSuffix' <- textToCString jSuffix
            return jSuffix'
    result <- wp_base_dirs_new_files_iterator flags' maybeSubdir maybeSuffix
    checkUnexpectedReturnNULL "baseDirsNewFilesIterator" result
    result' <- (wrapBoxed Wp.Iterator.Iterator) result
    freeMem maybeSubdir
    freeMem maybeSuffix
    return result'


-- function base_dirs_find_file
-- Args: [ Arg
--           { argCName = "flags"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "BaseDirsFlags" }
--           , argCType = Just "WpBaseDirsFlags"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "flags to specify the directories to look into and other options specific to the kind of file being looked up"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "subdir"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the name of the subdirectory to search in, inside the specified directories"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "filename"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of the file to search for"
--                 , 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_base_dirs_find_file" wp_base_dirs_find_file :: 
    CUInt ->                                -- flags : TInterface (Name {namespace = "Wp", name = "BaseDirsFlags"})
    CString ->                              -- subdir : TBasicType TUTF8
    CString ->                              -- filename : TBasicType TUTF8
    IO CString

-- | Searches for /@filename@/ in the hierarchy of directories specified by the /@flags@/ parameter.
-- 
-- 
-- Returns the highest priority file found in the hierarchy of directories specified by the /@flags@/ parameter. The /@subdir@/ parameter is the name of the subdirectory to search in, inside the specified directories. If /@subdir@/ is NULL, the base path of each directory is used.
-- The /@filename@/ parameter is the name of the file to search for. If the file is found, its full path is returned. If the file is not found, NULL is returned. The file is considered found if it is a regular file.
-- If the /@filename@/ is an absolute path, it is tested for existence and returned as is, ignoring the lookup directories in /@flags@/ as well as the /@subdir@/ parameter.
-- 
-- /Since: 0.5.0/
baseDirsFindFile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Wp.Flags.BaseDirsFlags]
    -- ^ /@flags@/: flags to specify the directories to look into and other options specific to the kind of file being looked up
    -> Maybe (T.Text)
    -- ^ /@subdir@/: the name of the subdirectory to search in, inside the specified directories
    -> T.Text
    -- ^ /@filename@/: the name of the file to search for
    -> m (Maybe T.Text)
    -- ^ __Returns:__ A newly allocated string with the absolute, canonicalized file path, or NULL if the file was not found.
baseDirsFindFile flags subdir filename = liftIO $ do
    let flags' = gflagsToWord flags
    maybeSubdir <- case subdir of
        Nothing -> return FP.nullPtr
        Just jSubdir -> do
            jSubdir' <- textToCString jSubdir
            return jSubdir'
    filename' <- textToCString filename
    result <- wp_base_dirs_find_file flags' maybeSubdir filename'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        freeMem result'
        return result''
    freeMem maybeSubdir
    freeMem filename'
    return maybeResult