{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The WpStateMetadata class saves and loads properties from a file and reflects the state in a metadata object.

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

module GI.Wp.Objects.StateMetadata
    ( 

-- * Exported types
    StateMetadata(..)                       ,
    IsStateMetadata                         ,
    toStateMetadata                         ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [abortActivation]("GI.Wp.Objects.Object#g:method:abortActivation"), [activate]("GI.Wp.Objects.Object#g:method:activate"), [activateClosure]("GI.Wp.Objects.Object#g:method:activateClosure"), [activateFinish]("GI.Wp.Objects.Object#g:method:activateFinish"), [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [clear]("GI.Wp.Objects.StateMetadata#g:method:clear"), [deactivate]("GI.Wp.Objects.Object#g:method:deactivate"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [get]("GI.Wp.Objects.StateMetadata#g:method:get"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [set]("GI.Wp.Objects.StateMetadata#g:method:set"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [testActiveFeatures]("GI.Wp.Objects.Object#g:method:testActiveFeatures"), [testSupportedFeatures]("GI.Wp.Objects.Object#g:method:testSupportedFeatures"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [updateFeatures]("GI.Wp.Objects.Object#g:method:updateFeatures"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getActiveFeatures]("GI.Wp.Objects.Object#g:method:getActiveFeatures"), [getCore]("GI.Wp.Objects.Object#g:method:getCore"), [getData]("GI.GObject.Objects.Object#g:method:getData"), [getId]("GI.Wp.Objects.Object#g:method:getId"), [getLocation]("GI.Wp.Objects.StateMetadata#g:method:getLocation"), [getName]("GI.Wp.Objects.StateMetadata#g:method:getName"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata"), [getSupportedFeatures]("GI.Wp.Objects.Object#g:method:getSupportedFeatures").
-- 
-- ==== 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)
    ResolveStateMetadataMethod              ,
#endif

-- ** clear #method:clear#

#if defined(ENABLE_OVERLOADING)
    StateMetadataClearMethodInfo            ,
#endif
    stateMetadataClear                      ,


-- ** get #method:get#

#if defined(ENABLE_OVERLOADING)
    StateMetadataGetMethodInfo              ,
#endif
    stateMetadataGet                        ,


-- ** getLocation #method:getLocation#

#if defined(ENABLE_OVERLOADING)
    StateMetadataGetLocationMethodInfo      ,
#endif
    stateMetadataGetLocation                ,


-- ** getName #method:getName#

#if defined(ENABLE_OVERLOADING)
    StateMetadataGetNameMethodInfo          ,
#endif
    stateMetadataGetName                    ,


-- ** new #method:new#

    stateMetadataNew                        ,


-- ** set #method:set#

#if defined(ENABLE_OVERLOADING)
    StateMetadataSetMethodInfo              ,
#endif
    stateMetadataSet                        ,




 -- * Properties


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

#if defined(ENABLE_OVERLOADING)
    StateMetadataNamePropertyInfo           ,
#endif
    constructStateMetadataName              ,
    getStateMetadataName                    ,
#if defined(ENABLE_OVERLOADING)
    stateMetadataName                       ,
#endif


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

#if defined(ENABLE_OVERLOADING)
    StateMetadataTimeoutPropertyInfo        ,
#endif
    constructStateMetadataTimeout           ,
    getStateMetadataTimeout                 ,
    setStateMetadataTimeout                 ,
#if defined(ENABLE_OVERLOADING)
    stateMetadataTimeout                    ,
#endif




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.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.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.MainContext as GLib.MainContext
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Wp.Callbacks as Wp.Callbacks
import {-# SOURCE #-} qualified GI.Wp.Enums as Wp.Enums
import {-# SOURCE #-} qualified GI.Wp.Flags as Wp.Flags
import {-# SOURCE #-} qualified GI.Wp.Objects.Conf as Wp.Conf
import {-# SOURCE #-} qualified GI.Wp.Objects.Core as Wp.Core
import {-# SOURCE #-} qualified GI.Wp.Objects.Object as Wp.Object
import {-# SOURCE #-} qualified GI.Wp.Objects.ObjectManager as Wp.ObjectManager
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.ObjectInterest as Wp.ObjectInterest
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.Objects.Core as Wp.Core
import {-# SOURCE #-} qualified GI.Wp.Objects.Object as Wp.Object

#endif

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

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

foreign import ccall "wp_state_metadata_get_type"
    c_wp_state_metadata_get_type :: IO B.Types.GType

instance B.Types.TypedObject StateMetadata where
    glibType = c_wp_state_metadata_get_type

instance B.Types.GObject StateMetadata

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

instance O.HasParentTypes StateMetadata
type instance O.ParentTypes StateMetadata = '[Wp.Object.Object, GObject.Object.Object]

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

-- | Convert t'StateMetadata' 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 StateMetadata) where
    gvalueGType_ = c_wp_state_metadata_get_type
    gvalueSet_ gv P.Nothing = B.GValue.set_object gv (FP.nullPtr :: FP.Ptr StateMetadata)
    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 StateMetadata)
        if ptr /= FP.nullPtr
        then P.Just <$> B.ManagedPtr.newObject StateMetadata ptr
        else return P.Nothing
        
    

#if defined(ENABLE_OVERLOADING)
type family ResolveStateMetadataMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveStateMetadataMethod "abortActivation" o = Wp.Object.ObjectAbortActivationMethodInfo
    ResolveStateMetadataMethod "activate" o = Wp.Object.ObjectActivateMethodInfo
    ResolveStateMetadataMethod "activateClosure" o = Wp.Object.ObjectActivateClosureMethodInfo
    ResolveStateMetadataMethod "activateFinish" o = Wp.Object.ObjectActivateFinishMethodInfo
    ResolveStateMetadataMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveStateMetadataMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveStateMetadataMethod "clear" o = StateMetadataClearMethodInfo
    ResolveStateMetadataMethod "deactivate" o = Wp.Object.ObjectDeactivateMethodInfo
    ResolveStateMetadataMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveStateMetadataMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveStateMetadataMethod "get" o = StateMetadataGetMethodInfo
    ResolveStateMetadataMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveStateMetadataMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveStateMetadataMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveStateMetadataMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveStateMetadataMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveStateMetadataMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveStateMetadataMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveStateMetadataMethod "set" o = StateMetadataSetMethodInfo
    ResolveStateMetadataMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveStateMetadataMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveStateMetadataMethod "testActiveFeatures" o = Wp.Object.ObjectTestActiveFeaturesMethodInfo
    ResolveStateMetadataMethod "testSupportedFeatures" o = Wp.Object.ObjectTestSupportedFeaturesMethodInfo
    ResolveStateMetadataMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveStateMetadataMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveStateMetadataMethod "updateFeatures" o = Wp.Object.ObjectUpdateFeaturesMethodInfo
    ResolveStateMetadataMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveStateMetadataMethod "getActiveFeatures" o = Wp.Object.ObjectGetActiveFeaturesMethodInfo
    ResolveStateMetadataMethod "getCore" o = Wp.Object.ObjectGetCoreMethodInfo
    ResolveStateMetadataMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveStateMetadataMethod "getId" o = Wp.Object.ObjectGetIdMethodInfo
    ResolveStateMetadataMethod "getLocation" o = StateMetadataGetLocationMethodInfo
    ResolveStateMetadataMethod "getName" o = StateMetadataGetNameMethodInfo
    ResolveStateMetadataMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveStateMetadataMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveStateMetadataMethod "getSupportedFeatures" o = Wp.Object.ObjectGetSupportedFeaturesMethodInfo
    ResolveStateMetadataMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveStateMetadataMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveStateMetadataMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveStateMetadataMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveStateMetadataMethod t StateMetadata, O.OverloadedMethod info StateMetadata p) => OL.IsLabel t (StateMetadata -> 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 ~ ResolveStateMetadataMethod t StateMetadata, O.OverloadedMethod info StateMetadata p, R.HasField t StateMetadata p) => R.HasField t StateMetadata p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveStateMetadataMethod t StateMetadata, O.OverloadedMethodInfo info StateMetadata) => OL.IsLabel t (O.MethodProxy info StateMetadata) 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' stateMetadata #name
-- @
getStateMetadataName :: (MonadIO m, IsStateMetadata o) => o -> m T.Text
getStateMetadataName obj = MIO.liftIO $ checkUnexpectedNothing "getStateMetadataName" $ 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`.
constructStateMetadataName :: (IsStateMetadata o, MIO.MonadIO m) => T.Text -> m (GValueConstruct o)
constructStateMetadataName val = MIO.liftIO $ do
    MIO.liftIO $ B.Properties.constructObjectPropertyString "name" (P.Just val)

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

-- VVV Prop "timeout"
   -- Type: TBasicType TUInt
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Nothing,Nothing)

-- | Get the value of the “@timeout@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' stateMetadata #timeout
-- @
getStateMetadataTimeout :: (MonadIO m, IsStateMetadata o) => o -> m Word32
getStateMetadataTimeout obj = MIO.liftIO $ B.Properties.getObjectPropertyUInt32 obj "timeout"

-- | Set the value of the “@timeout@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' stateMetadata [ #timeout 'Data.GI.Base.Attributes.:=' value ]
-- @
setStateMetadataTimeout :: (MonadIO m, IsStateMetadata o) => o -> Word32 -> m ()
setStateMetadataTimeout obj val = MIO.liftIO $ do
    B.Properties.setObjectPropertyUInt32 obj "timeout" val

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

#if defined(ENABLE_OVERLOADING)
data StateMetadataTimeoutPropertyInfo
instance AttrInfo StateMetadataTimeoutPropertyInfo where
    type AttrAllowedOps StateMetadataTimeoutPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrPut]
    type AttrBaseTypeConstraint StateMetadataTimeoutPropertyInfo = IsStateMetadata
    type AttrSetTypeConstraint StateMetadataTimeoutPropertyInfo = (~) Word32
    type AttrTransferTypeConstraint StateMetadataTimeoutPropertyInfo = (~) Word32
    type AttrTransferType StateMetadataTimeoutPropertyInfo = Word32
    type AttrGetType StateMetadataTimeoutPropertyInfo = Word32
    type AttrLabel StateMetadataTimeoutPropertyInfo = "timeout"
    type AttrOrigin StateMetadataTimeoutPropertyInfo = StateMetadata
    attrGet = getStateMetadataTimeout
    attrSet = setStateMetadataTimeout
    attrPut = setStateMetadataTimeout
    attrTransfer _ v = do
        return v
    attrConstruct = constructStateMetadataTimeout
    attrClear = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.StateMetadata.timeout"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-StateMetadata.html#g:attr:timeout"
        })
#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList StateMetadata
type instance O.AttributeList StateMetadata = StateMetadataAttributeList
type StateMetadataAttributeList = ('[ '("activeFeatures", Wp.Object.ObjectActiveFeaturesPropertyInfo), '("core", Wp.Object.ObjectCorePropertyInfo), '("id", Wp.Object.ObjectIdPropertyInfo), '("name", StateMetadataNamePropertyInfo), '("supportedFeatures", Wp.Object.ObjectSupportedFeaturesPropertyInfo), '("timeout", StateMetadataTimeoutPropertyInfo)] :: [(Symbol, DK.Type)])
#endif

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

stateMetadataTimeout :: AttrLabelProxy "timeout"
stateMetadataTimeout = AttrLabelProxy

#endif

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

#endif

-- method StateMetadata::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "core"
--           , argType = TInterface Name { namespace = "Wp" , name = "Core" }
--           , argCType = Just "WpCore*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the core associated with the state metadata"
--                 , 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 state metadata name"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Wp" , name = "StateMetadata" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_state_metadata_new" wp_state_metadata_new :: 
    Ptr Wp.Core.Core ->                     -- core : TInterface (Name {namespace = "Wp", name = "Core"})
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr StateMetadata)

-- | Constructs a new state metadata object.
stateMetadataNew ::
    (B.CallStack.HasCallStack, MonadIO m, Wp.Core.IsCore a) =>
    a
    -- ^ /@core@/: the core associated with the state metadata
    -> T.Text
    -- ^ /@name@/: the state metadata name
    -> m StateMetadata
    -- ^ __Returns:__ the new WpStateMetadata
stateMetadataNew core name = liftIO $ do
    core' <- unsafeManagedPtrCastPtr core
    name' <- textToCString name
    result <- wp_state_metadata_new core' name'
    checkUnexpectedReturnNULL "stateMetadataNew" result
    result' <- (wrapObject StateMetadata) result
    touchManagedPtr core
    freeMem name'
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method StateMetadata::clear
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "StateMetadata" }
--           , argCType = Just "WpStateMetadata*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the state metadata" , 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_state_metadata_clear" wp_state_metadata_clear :: 
    Ptr StateMetadata ->                    -- self : TInterface (Name {namespace = "Wp", name = "StateMetadata"})
    IO ()

-- | Clears the state metadata and removes its file.
-- 
-- 
-- If the state metadata has not been loaded, this won\'t do anything.
stateMetadataClear ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateMetadata a) =>
    a
    -- ^ /@self@/: the state metadata
    -> m ()
stateMetadataClear self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    wp_state_metadata_clear self'
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data StateMetadataClearMethodInfo
instance (signature ~ (m ()), MonadIO m, IsStateMetadata a) => O.OverloadedMethod StateMetadataClearMethodInfo a signature where
    overloadedMethod = stateMetadataClear

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


#endif

-- method StateMetadata::get
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "StateMetadata" }
--           , argCType = Just "WpStateMetadata*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the state metadata" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "key"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the key of the 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_state_metadata_get" wp_state_metadata_get :: 
    Ptr StateMetadata ->                    -- self : TInterface (Name {namespace = "Wp", name = "StateMetadata"})
    CString ->                              -- key : TBasicType TUTF8
    IO CString

-- | Gets a value from the state metadata.
-- 
-- 
-- If the state metadata has not been loaded, this won\'t do anything.
stateMetadataGet ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateMetadata a) =>
    a
    -- ^ /@self@/: the state metadata
    -> T.Text
    -- ^ /@key@/: the key of the value
    -> m T.Text
    -- ^ __Returns:__ the value from the state metadata, or NULL if not found.
stateMetadataGet self key = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    key' <- textToCString key
    result <- wp_state_metadata_get self' key'
    checkUnexpectedReturnNULL "stateMetadataGet" result
    result' <- cstringToText result
    touchManagedPtr self
    freeMem key'
    return result'

#if defined(ENABLE_OVERLOADING)
data StateMetadataGetMethodInfo
instance (signature ~ (T.Text -> m T.Text), MonadIO m, IsStateMetadata a) => O.OverloadedMethod StateMetadataGetMethodInfo a signature where
    overloadedMethod = stateMetadataGet

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


#endif

-- method StateMetadata::get_location
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "StateMetadata" }
--           , argCType = Just "WpStateMetadata*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the state metadata" , 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_state_metadata_get_location" wp_state_metadata_get_location :: 
    Ptr StateMetadata ->                    -- self : TInterface (Name {namespace = "Wp", name = "StateMetadata"})
    IO CString

-- | Gets the location of a state metadata object.
stateMetadataGetLocation ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateMetadata a) =>
    a
    -- ^ /@self@/: the state metadata
    -> m T.Text
    -- ^ __Returns:__ the location of this state metadata
stateMetadataGetLocation self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- wp_state_metadata_get_location self'
    checkUnexpectedReturnNULL "stateMetadataGetLocation" result
    result' <- cstringToText result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data StateMetadataGetLocationMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsStateMetadata a) => O.OverloadedMethod StateMetadataGetLocationMethodInfo a signature where
    overloadedMethod = stateMetadataGetLocation

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


#endif

-- method StateMetadata::get_name
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "StateMetadata" }
--           , argCType = Just "WpStateMetadata*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the state metadata" , 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_state_metadata_get_name" wp_state_metadata_get_name :: 
    Ptr StateMetadata ->                    -- self : TInterface (Name {namespace = "Wp", name = "StateMetadata"})
    IO CString

-- | Gets the name of a state metadata object.
stateMetadataGetName ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateMetadata a) =>
    a
    -- ^ /@self@/: the state metadata
    -> m T.Text
    -- ^ __Returns:__ the name of this state metadata
stateMetadataGetName self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- wp_state_metadata_get_name self'
    checkUnexpectedReturnNULL "stateMetadataGetName" result
    result' <- cstringToText result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data StateMetadataGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsStateMetadata a) => O.OverloadedMethod StateMetadataGetNameMethodInfo a signature where
    overloadedMethod = stateMetadataGetName

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


#endif

-- method StateMetadata::set
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "StateMetadata" }
--           , argCType = Just "WpStateMetadata*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the metadata object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "key"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the key to set." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the value to set, or NULL to unset the given @key"
--                 , 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_state_metadata_set" wp_state_metadata_set :: 
    Ptr StateMetadata ->                    -- self : TInterface (Name {namespace = "Wp", name = "StateMetadata"})
    CString ->                              -- key : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    IO ()

-- | Sets a value into the state metadata.
-- 
-- 
-- If value is NULL, it will unset the given /@key@/. Note that this will also save the state after the timeout has elapsed.
-- If the state metadata has not been loaded, this won\'t do anything.
stateMetadataSet ::
    (B.CallStack.HasCallStack, MonadIO m, IsStateMetadata a) =>
    a
    -- ^ /@self@/: the metadata object
    -> T.Text
    -- ^ /@key@/: the key to set.
    -> Maybe (T.Text)
    -- ^ /@value@/: the value to set, or NULL to unset the given /@key@/
    -> m ()
stateMetadataSet self key value = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    key' <- textToCString key
    maybeValue <- case value of
        Nothing -> return FP.nullPtr
        Just jValue -> do
            jValue' <- textToCString jValue
            return jValue'
    wp_state_metadata_set self' key' maybeValue
    touchManagedPtr self
    freeMem key'
    freeMem maybeValue
    return ()

#if defined(ENABLE_OVERLOADING)
data StateMetadataSetMethodInfo
instance (signature ~ (T.Text -> Maybe (T.Text) -> m ()), MonadIO m, IsStateMetadata a) => O.OverloadedMethod StateMetadataSetMethodInfo a signature where
    overloadedMethod = stateMetadataSet

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


#endif


