packages feed

gi-wireplumber-0.5.14: GI/Wp/Objects/Metadata.hs

{-# LANGUAGE ImplicitParams, RankNTypes, TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The WpMetadata class allows accessing the properties and methods of PipeWire metadata object (struct pw_metadata).
-- A WpMetadata is constructed internally when a new metadata object appears on the PipeWire registry and it is made available through the WpObjectManager API.

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

module GI.Wp.Objects.Metadata
    ( 

-- * Exported types
    Metadata(..)                            ,
    IsMetadata                              ,
    toMetadata                              ,


 -- * 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"), [bind]("GI.Wp.Objects.GlobalProxy#g:method:bind"), [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [clear]("GI.Wp.Objects.Metadata#g:method:clear"), [deactivate]("GI.Wp.Objects.Object#g:method:deactivate"), [find]("GI.Wp.Objects.Metadata#g:method:find"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [newIterator]("GI.Wp.Objects.Metadata#g:method:newIterator"), [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"), [requestDestroy]("GI.Wp.Objects.GlobalProxy#g:method:requestDestroy"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [set]("GI.Wp.Objects.Metadata#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"), [getBoundId]("GI.Wp.Objects.Proxy#g:method:getBoundId"), [getCore]("GI.Wp.Objects.Object#g:method:getCore"), [getData]("GI.GObject.Objects.Object#g:method:getData"), [getGlobalProperties]("GI.Wp.Objects.GlobalProxy#g:method:getGlobalProperties"), [getId]("GI.Wp.Objects.Object#g:method:getId"), [getInterfaceType]("GI.Wp.Objects.Proxy#g:method:getInterfaceType"), [getPermissions]("GI.Wp.Objects.GlobalProxy#g:method:getPermissions"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getPwProxy]("GI.Wp.Objects.Proxy#g:method:getPwProxy"), [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"), [setPwProxy]("GI.Wp.Objects.Proxy#g:method:setPwProxy").

#if defined(ENABLE_OVERLOADING)
    ResolveMetadataMethod                   ,
#endif

-- ** clear #method:clear#

#if defined(ENABLE_OVERLOADING)
    MetadataClearMethodInfo                 ,
#endif
    metadataClear                           ,


-- ** find #method:find#

#if defined(ENABLE_OVERLOADING)
    MetadataFindMethodInfo                  ,
#endif
    metadataFind                            ,


-- ** newIterator #method:newIterator#

#if defined(ENABLE_OVERLOADING)
    MetadataNewIteratorMethodInfo           ,
#endif
    metadataNewIterator                     ,


-- ** set #method:set#

#if defined(ENABLE_OVERLOADING)
    MetadataSetMethodInfo                   ,
#endif
    metadataSet                             ,




 -- * Signals


-- ** changed #signal:changed#

    MetadataChangedCallback                 ,
#if defined(ENABLE_OVERLOADING)
    MetadataChangedSignalInfo               ,
#endif
    afterMetadataChanged                    ,
    onMetadataChanged                       ,




    ) 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.GlobalProxy as Wp.GlobalProxy
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.Objects.Proxy as Wp.Proxy
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.GlobalProxy as Wp.GlobalProxy
import {-# SOURCE #-} qualified GI.Wp.Objects.Object as Wp.Object
import {-# SOURCE #-} qualified GI.Wp.Objects.Proxy as Wp.Proxy
import {-# SOURCE #-} qualified GI.Wp.Structs.Iterator as Wp.Iterator

#endif

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

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

foreign import ccall "wp_metadata_get_type"
    c_wp_metadata_get_type :: IO B.Types.GType

instance B.Types.TypedObject Metadata where
    glibType = c_wp_metadata_get_type

instance B.Types.GObject Metadata

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

instance O.HasParentTypes Metadata
type instance O.ParentTypes Metadata = '[Wp.GlobalProxy.GlobalProxy, Wp.Proxy.Proxy, Wp.Object.Object, GObject.Object.Object]

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

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

#if defined(ENABLE_OVERLOADING)
type family ResolveMetadataMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveMetadataMethod "abortActivation" o = Wp.Object.ObjectAbortActivationMethodInfo
    ResolveMetadataMethod "activate" o = Wp.Object.ObjectActivateMethodInfo
    ResolveMetadataMethod "activateClosure" o = Wp.Object.ObjectActivateClosureMethodInfo
    ResolveMetadataMethod "activateFinish" o = Wp.Object.ObjectActivateFinishMethodInfo
    ResolveMetadataMethod "bind" o = Wp.GlobalProxy.GlobalProxyBindMethodInfo
    ResolveMetadataMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveMetadataMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveMetadataMethod "clear" o = MetadataClearMethodInfo
    ResolveMetadataMethod "deactivate" o = Wp.Object.ObjectDeactivateMethodInfo
    ResolveMetadataMethod "find" o = MetadataFindMethodInfo
    ResolveMetadataMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveMetadataMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveMetadataMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveMetadataMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveMetadataMethod "newIterator" o = MetadataNewIteratorMethodInfo
    ResolveMetadataMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveMetadataMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveMetadataMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveMetadataMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveMetadataMethod "requestDestroy" o = Wp.GlobalProxy.GlobalProxyRequestDestroyMethodInfo
    ResolveMetadataMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveMetadataMethod "set" o = MetadataSetMethodInfo
    ResolveMetadataMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveMetadataMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveMetadataMethod "testActiveFeatures" o = Wp.Object.ObjectTestActiveFeaturesMethodInfo
    ResolveMetadataMethod "testSupportedFeatures" o = Wp.Object.ObjectTestSupportedFeaturesMethodInfo
    ResolveMetadataMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveMetadataMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveMetadataMethod "updateFeatures" o = Wp.Object.ObjectUpdateFeaturesMethodInfo
    ResolveMetadataMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveMetadataMethod "getActiveFeatures" o = Wp.Object.ObjectGetActiveFeaturesMethodInfo
    ResolveMetadataMethod "getBoundId" o = Wp.Proxy.ProxyGetBoundIdMethodInfo
    ResolveMetadataMethod "getCore" o = Wp.Object.ObjectGetCoreMethodInfo
    ResolveMetadataMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveMetadataMethod "getGlobalProperties" o = Wp.GlobalProxy.GlobalProxyGetGlobalPropertiesMethodInfo
    ResolveMetadataMethod "getId" o = Wp.Object.ObjectGetIdMethodInfo
    ResolveMetadataMethod "getInterfaceType" o = Wp.Proxy.ProxyGetInterfaceTypeMethodInfo
    ResolveMetadataMethod "getPermissions" o = Wp.GlobalProxy.GlobalProxyGetPermissionsMethodInfo
    ResolveMetadataMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveMetadataMethod "getPwProxy" o = Wp.Proxy.ProxyGetPwProxyMethodInfo
    ResolveMetadataMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveMetadataMethod "getSupportedFeatures" o = Wp.Object.ObjectGetSupportedFeaturesMethodInfo
    ResolveMetadataMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveMetadataMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveMetadataMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveMetadataMethod "setPwProxy" o = Wp.Proxy.ProxySetPwProxyMethodInfo
    ResolveMetadataMethod l o = O.MethodResolutionFailed l o

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

#endif

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

#endif

-- signal Metadata::changed
-- | /No description available in the introspection data./
type MetadataChangedCallback =
    Word32
    -> T.Text
    -> T.Text
    -> T.Text
    -> IO ()

type C_MetadataChangedCallback =
    Ptr Metadata ->                         -- object
    Word32 ->
    CString ->
    CString ->
    CString ->
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_MetadataChangedCallback`.
foreign import ccall "wrapper"
    mk_MetadataChangedCallback :: C_MetadataChangedCallback -> IO (FunPtr C_MetadataChangedCallback)

wrap_MetadataChangedCallback :: 
    GObject a => (a -> MetadataChangedCallback) ->
    C_MetadataChangedCallback
wrap_MetadataChangedCallback gi'cb gi'selfPtr object p0 p1 p2 _ = do
    p0' <- cstringToText p0
    p1' <- cstringToText p1
    p2' <- cstringToText p2
    B.ManagedPtr.withNewObject gi'selfPtr $ \gi'self -> gi'cb (Coerce.coerce gi'self)  object p0' p1' p2'


-- | Connect a signal handler for the [changed](#signal:changed) signal, to be run before the default handler.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Signals.on' metadata #changed callback
-- @
-- 
-- 
onMetadataChanged :: (IsMetadata a, MonadIO m) => a -> ((?self :: a) => MetadataChangedCallback) -> m SignalHandlerId
onMetadataChanged obj cb = liftIO $ do
    let wrapped self = let ?self = self in cb
    let wrapped' = wrap_MetadataChangedCallback wrapped
    wrapped'' <- mk_MetadataChangedCallback wrapped'
    connectSignalFunPtr obj "changed" wrapped'' SignalConnectBefore Nothing

-- | Connect a signal handler for the [changed](#signal:changed) signal, to be run after the default handler.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Signals.after' metadata #changed callback
-- @
-- 
-- 
-- 
-- By default the object invoking the signal is not passed to the callback.
-- If you need to access it, you can use the implit @?self@ parameter.
-- Note that this requires activating the @ImplicitParams@ GHC extension.
-- 
afterMetadataChanged :: (IsMetadata a, MonadIO m) => a -> ((?self :: a) => MetadataChangedCallback) -> m SignalHandlerId
afterMetadataChanged obj cb = liftIO $ do
    let wrapped self = let ?self = self in cb
    let wrapped' = wrap_MetadataChangedCallback wrapped
    wrapped'' <- mk_MetadataChangedCallback wrapped'
    connectSignalFunPtr obj "changed" wrapped'' SignalConnectAfter Nothing


#if defined(ENABLE_OVERLOADING)
data MetadataChangedSignalInfo
instance SignalInfo MetadataChangedSignalInfo where
    type HaskellCallbackType MetadataChangedSignalInfo = MetadataChangedCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_MetadataChangedCallback cb
        cb'' <- mk_MetadataChangedCallback cb'
        connectSignalFunPtr obj "changed" cb'' connectMode detail
    dbgSignalInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.Metadata::changed"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Objects-Metadata.html#g:signal:changed"})

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Metadata
type instance O.AttributeList Metadata = MetadataAttributeList
type MetadataAttributeList = ('[ '("activeFeatures", Wp.Object.ObjectActiveFeaturesPropertyInfo), '("boundId", Wp.Proxy.ProxyBoundIdPropertyInfo), '("core", Wp.Object.ObjectCorePropertyInfo), '("factoryName", Wp.GlobalProxy.GlobalProxyFactoryNamePropertyInfo), '("globalProperties", Wp.GlobalProxy.GlobalProxyGlobalPropertiesPropertyInfo), '("id", Wp.Object.ObjectIdPropertyInfo), '("permissions", Wp.GlobalProxy.GlobalProxyPermissionsPropertyInfo), '("pwProxy", Wp.Proxy.ProxyPwProxyPropertyInfo), '("supportedFeatures", Wp.Object.ObjectSupportedFeaturesPropertyInfo)] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Metadata = MetadataSignalList
type MetadataSignalList = ('[ '("bound", Wp.Proxy.ProxyBoundSignalInfo), '("changed", MetadataChangedSignalInfo), '("error", Wp.Proxy.ProxyErrorSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("pwProxyCreated", Wp.Proxy.ProxyPwProxyCreatedSignalInfo), '("pwProxyDestroyed", Wp.Proxy.ProxyPwProxyDestroyedSignalInfo)] :: [(Symbol, DK.Type)])

#endif

-- method Metadata::clear
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "Metadata" }
--           , argCType = Just "WpMetadata*"
--           , 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
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

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

-- | Clears permanently all stored metadata.
metadataClear ::
    (B.CallStack.HasCallStack, MonadIO m, IsMetadata a) =>
    a
    -- ^ /@self@/: the metadata object
    -> m ()
metadataClear self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    wp_metadata_clear self'
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data MetadataClearMethodInfo
instance (signature ~ (m ()), MonadIO m, IsMetadata a) => O.OverloadedMethod MetadataClearMethodInfo a signature where
    overloadedMethod = metadataClear

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


#endif

-- method Metadata::find
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "Metadata" }
--           , argCType = Just "WpMetadata*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a metadata object" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "subject"
--           , argType = TBasicType TUInt32
--           , argCType = Just "guint32"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the metadata subject id"
--                 , 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 metadata key name"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "type"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar**"
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the metadata type name"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "wp_metadata_find" wp_metadata_find :: 
    Ptr Metadata ->                         -- self : TInterface (Name {namespace = "Wp", name = "Metadata"})
    Word32 ->                               -- subject : TBasicType TUInt32
    CString ->                              -- key : TBasicType TUTF8
    Ptr CString ->                          -- type : TBasicType TUTF8
    IO CString

-- | Finds the metadata value given its /@subject@/ and /@key@/.
metadataFind ::
    (B.CallStack.HasCallStack, MonadIO m, IsMetadata a) =>
    a
    -- ^ /@self@/: a metadata object
    -> Word32
    -- ^ /@subject@/: the metadata subject id
    -> T.Text
    -- ^ /@key@/: the metadata key name
    -> m ((T.Text, T.Text))
    -- ^ __Returns:__ the metadata string value, or NULL if not found.
metadataFind self subject key = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    key' <- textToCString key
    type_ <- callocMem :: IO (Ptr CString)
    result <- wp_metadata_find self' subject key' type_
    checkUnexpectedReturnNULL "metadataFind" result
    result' <- cstringToText result
    type_' <- peek type_
    type_'' <- cstringToText type_'
    freeMem type_'
    touchManagedPtr self
    freeMem key'
    freeMem type_
    return (result', type_'')

#if defined(ENABLE_OVERLOADING)
data MetadataFindMethodInfo
instance (signature ~ (Word32 -> T.Text -> m ((T.Text, T.Text))), MonadIO m, IsMetadata a) => O.OverloadedMethod MetadataFindMethodInfo a signature where
    overloadedMethod = metadataFind

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


#endif

-- method Metadata::new_iterator
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "Metadata" }
--           , argCType = Just "WpMetadata*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a metadata object" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "subject"
--           , argType = TBasicType TUInt32
--           , argCType = Just "guint32"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the metadata subject id, or -1 (PW_ID_ANY)"
--                 , 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_metadata_new_iterator" wp_metadata_new_iterator :: 
    Ptr Metadata ->                         -- self : TInterface (Name {namespace = "Wp", name = "Metadata"})
    Word32 ->                               -- subject : TBasicType TUInt32
    IO (Ptr Wp.Iterator.Iterator)

-- | Iterates over metadata items that matches the given /@subject@/.
-- 
-- 
-- If no constraints are specified, the returned iterator iterates over all the stored metadata.
-- Note that this method works on cached metadata. When you change metadata with 'GI.Wp.Objects.Metadata.metadataSet', this cache will be updated on the next round-trip with the pipewire server.
metadataNewIterator ::
    (B.CallStack.HasCallStack, MonadIO m, IsMetadata a) =>
    a
    -- ^ /@self@/: a metadata object
    -> Word32
    -- ^ /@subject@/: the metadata subject id, or -1 (PW_ID_ANY)
    -> m Wp.Iterator.Iterator
    -- ^ __Returns:__ an iterator that iterates over the found metadata. The type of the iterator item is WpMetadataItem.
metadataNewIterator self subject = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- wp_metadata_new_iterator self' subject
    checkUnexpectedReturnNULL "metadataNewIterator" result
    result' <- (wrapBoxed Wp.Iterator.Iterator) result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data MetadataNewIteratorMethodInfo
instance (signature ~ (Word32 -> m Wp.Iterator.Iterator), MonadIO m, IsMetadata a) => O.OverloadedMethod MetadataNewIteratorMethodInfo a signature where
    overloadedMethod = metadataNewIterator

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


#endif

-- method Metadata::set
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "Metadata" }
--           , argCType = Just "WpMetadata*"
--           , 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 = "subject"
--           , argType = TBasicType TUInt32
--           , argCType = Just "guint32"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the subject id for which this metadata property is being set"
--                 , 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 = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the key to set, or NULL to remove all metadata for @subject"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "type"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the type of the value; NULL is synonymous to \"string\""
--                 , 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_metadata_set" wp_metadata_set :: 
    Ptr Metadata ->                         -- self : TInterface (Name {namespace = "Wp", name = "Metadata"})
    Word32 ->                               -- subject : TBasicType TUInt32
    CString ->                              -- key : TBasicType TUTF8
    CString ->                              -- type : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    IO ()

-- | Sets the metadata associated with the given /@subject@/ and /@key@/. Use NULL as a value to unset the given /@key@/ and use NULL in both /@key@/ and /@value@/ to remove all metadata associated with the given /@subject@/.
metadataSet ::
    (B.CallStack.HasCallStack, MonadIO m, IsMetadata a) =>
    a
    -- ^ /@self@/: the metadata object
    -> Word32
    -- ^ /@subject@/: the subject id for which this metadata property is being set
    -> Maybe (T.Text)
    -- ^ /@key@/: the key to set, or NULL to remove all metadata for /@subject@/
    -> Maybe (T.Text)
    -- ^ /@type@/: the type of the value; NULL is synonymous to \"string\"
    -> Maybe (T.Text)
    -- ^ /@value@/: the value to set, or NULL to unset the given /@key@/
    -> m ()
metadataSet self subject key type_ value = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybeKey <- case key of
        Nothing -> return FP.nullPtr
        Just jKey -> do
            jKey' <- textToCString jKey
            return jKey'
    maybeType_ <- case type_ of
        Nothing -> return FP.nullPtr
        Just jType_ -> do
            jType_' <- textToCString jType_
            return jType_'
    maybeValue <- case value of
        Nothing -> return FP.nullPtr
        Just jValue -> do
            jValue' <- textToCString jValue
            return jValue'
    wp_metadata_set self' subject maybeKey maybeType_ maybeValue
    touchManagedPtr self
    freeMem maybeKey
    freeMem maybeType_
    freeMem maybeValue
    return ()

#if defined(ENABLE_OVERLOADING)
data MetadataSetMethodInfo
instance (signature ~ (Word32 -> Maybe (T.Text) -> Maybe (T.Text) -> Maybe (T.Text) -> m ()), MonadIO m, IsMetadata a) => O.OverloadedMethod MetadataSetMethodInfo a signature where
    overloadedMethod = metadataSet

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


#endif