{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A WpImplNode allows running a node implementation (struct pw_impl_node) locally, loading the implementation from factory or wrapping a manually constructed pw_impl_node. This object can then be exported to PipeWire by requesting WP_PROXY_FEATURE_BOUND.
-- When the \"client-context\" component is loaded, which is the case in the default daemon configuration, 'GI.Wp.Objects.ImplNode.implNodeNewFromPwFactory' creates the node in a secondary pw_context that runs on its own thread, so that the node is not affected by anything that blocks WirePlumber\'s main loop, and exports it on that context\'s connection. The WpImplNode itself stays on the thread that created it: its features, signals and the rest of its API are unchanged. Nodes wrapped with 'GI.Wp.Objects.ImplNode.implNodeNewWrap' belong to whichever context the given pw_impl_node was created in, which is the core\'s own pw_context in most cases, and are exported on the core\'s connection.

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

module GI.Wp.Objects.ImplNode
    ( 

-- * Exported types
    ImplNode(..)                            ,
    IsImplNode                              ,
    toImplNode                              ,


 -- * 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"), [deactivate]("GI.Wp.Objects.Object#g:method:deactivate"), [enumParams]("GI.Wp.Interfaces.PipewireObject#g:method:enumParams"), [enumParamsFinish]("GI.Wp.Interfaces.PipewireObject#g:method:enumParamsFinish"), [enumParamsSync]("GI.Wp.Interfaces.PipewireObject#g:method:enumParamsSync"), [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"), [newPropertiesIterator]("GI.Wp.Interfaces.PipewireObject#g:method:newPropertiesIterator"), [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"), [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"), [getId]("GI.Wp.Objects.Object#g:method:getId"), [getInterfaceType]("GI.Wp.Objects.Proxy#g:method:getInterfaceType"), [getNativeInfo]("GI.Wp.Interfaces.PipewireObject#g:method:getNativeInfo"), [getParamInfo]("GI.Wp.Interfaces.PipewireObject#g:method:getParamInfo"), [getProperties]("GI.Wp.Interfaces.PipewireObject#g:method:getProperties"), [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"), [setParam]("GI.Wp.Interfaces.PipewireObject#g:method:setParam"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty"), [setPwProxy]("GI.Wp.Objects.Proxy#g:method:setPwProxy").

#if defined(ENABLE_OVERLOADING)
    ResolveImplNodeMethod                   ,
#endif

-- ** newFromPwFactory #method:newFromPwFactory#

    implNodeNewFromPwFactory                ,


-- ** newWrap #method:newWrap#

    implNodeNewWrap                         ,




 -- * Properties


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

#if defined(ENABLE_OVERLOADING)
    ImplNodePwImplNodePropertyInfo          ,
#endif
    constructImplNodePwImplNode             ,
    getImplNodePwImplNode                   ,
#if defined(ENABLE_OVERLOADING)
    implNodePwImplNode                      ,
#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.Interfaces.PipewireObject as Wp.PipewireObject
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.Objects.Proxy as Wp.Proxy
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.ObjectInterest as Wp.ObjectInterest
import {-# SOURCE #-} qualified GI.Wp.Structs.Properties as Wp.Properties
import {-# SOURCE #-} qualified GI.Wp.Structs.SpaJson as Wp.SpaJson
import {-# SOURCE #-} qualified GI.Wp.Structs.SpaPod as Wp.SpaPod

#else
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Wp.Interfaces.PipewireObject as Wp.PipewireObject
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.Proxy as Wp.Proxy
import {-# SOURCE #-} qualified GI.Wp.Structs.Properties as Wp.Properties

#endif

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

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

foreign import ccall "wp_impl_node_get_type"
    c_wp_impl_node_get_type :: IO B.Types.GType

instance B.Types.TypedObject ImplNode where
    glibType = c_wp_impl_node_get_type

instance B.Types.GObject ImplNode

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

instance O.HasParentTypes ImplNode
type instance O.ParentTypes ImplNode = '[Wp.Proxy.Proxy, Wp.Object.Object, GObject.Object.Object, Wp.PipewireObject.PipewireObject]

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

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

#if defined(ENABLE_OVERLOADING)
type family ResolveImplNodeMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveImplNodeMethod "abortActivation" o = Wp.Object.ObjectAbortActivationMethodInfo
    ResolveImplNodeMethod "activate" o = Wp.Object.ObjectActivateMethodInfo
    ResolveImplNodeMethod "activateClosure" o = Wp.Object.ObjectActivateClosureMethodInfo
    ResolveImplNodeMethod "activateFinish" o = Wp.Object.ObjectActivateFinishMethodInfo
    ResolveImplNodeMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveImplNodeMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveImplNodeMethod "deactivate" o = Wp.Object.ObjectDeactivateMethodInfo
    ResolveImplNodeMethod "enumParams" o = Wp.PipewireObject.PipewireObjectEnumParamsMethodInfo
    ResolveImplNodeMethod "enumParamsFinish" o = Wp.PipewireObject.PipewireObjectEnumParamsFinishMethodInfo
    ResolveImplNodeMethod "enumParamsSync" o = Wp.PipewireObject.PipewireObjectEnumParamsSyncMethodInfo
    ResolveImplNodeMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveImplNodeMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveImplNodeMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveImplNodeMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveImplNodeMethod "newPropertiesIterator" o = Wp.PipewireObject.PipewireObjectNewPropertiesIteratorMethodInfo
    ResolveImplNodeMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveImplNodeMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveImplNodeMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveImplNodeMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveImplNodeMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveImplNodeMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveImplNodeMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveImplNodeMethod "testActiveFeatures" o = Wp.Object.ObjectTestActiveFeaturesMethodInfo
    ResolveImplNodeMethod "testSupportedFeatures" o = Wp.Object.ObjectTestSupportedFeaturesMethodInfo
    ResolveImplNodeMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveImplNodeMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveImplNodeMethod "updateFeatures" o = Wp.Object.ObjectUpdateFeaturesMethodInfo
    ResolveImplNodeMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveImplNodeMethod "getActiveFeatures" o = Wp.Object.ObjectGetActiveFeaturesMethodInfo
    ResolveImplNodeMethod "getBoundId" o = Wp.Proxy.ProxyGetBoundIdMethodInfo
    ResolveImplNodeMethod "getCore" o = Wp.Object.ObjectGetCoreMethodInfo
    ResolveImplNodeMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveImplNodeMethod "getId" o = Wp.Object.ObjectGetIdMethodInfo
    ResolveImplNodeMethod "getInterfaceType" o = Wp.Proxy.ProxyGetInterfaceTypeMethodInfo
    ResolveImplNodeMethod "getNativeInfo" o = Wp.PipewireObject.PipewireObjectGetNativeInfoMethodInfo
    ResolveImplNodeMethod "getParamInfo" o = Wp.PipewireObject.PipewireObjectGetParamInfoMethodInfo
    ResolveImplNodeMethod "getProperties" o = Wp.PipewireObject.PipewireObjectGetPropertiesMethodInfo
    ResolveImplNodeMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveImplNodeMethod "getPwProxy" o = Wp.Proxy.ProxyGetPwProxyMethodInfo
    ResolveImplNodeMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveImplNodeMethod "getSupportedFeatures" o = Wp.Object.ObjectGetSupportedFeaturesMethodInfo
    ResolveImplNodeMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveImplNodeMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveImplNodeMethod "setParam" o = Wp.PipewireObject.PipewireObjectSetParamMethodInfo
    ResolveImplNodeMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveImplNodeMethod "setPwProxy" o = Wp.Proxy.ProxySetPwProxyMethodInfo
    ResolveImplNodeMethod l o = O.MethodResolutionFailed l o

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

#endif

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

#endif

-- VVV Prop "pw-impl-node"
   -- Type: TBasicType TPtr
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

-- | Get the value of the “@pw-impl-node@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' implNode #pwImplNode
-- @
getImplNodePwImplNode :: (MonadIO m, IsImplNode o) => o -> m (Ptr ())
getImplNodePwImplNode obj = MIO.liftIO $ B.Properties.getObjectPropertyPtr obj "pw-impl-node"

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

#if defined(ENABLE_OVERLOADING)
data ImplNodePwImplNodePropertyInfo
instance AttrInfo ImplNodePwImplNodePropertyInfo where
    type AttrAllowedOps ImplNodePwImplNodePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrBaseTypeConstraint ImplNodePwImplNodePropertyInfo = IsImplNode
    type AttrSetTypeConstraint ImplNodePwImplNodePropertyInfo = (~) (Ptr ())
    type AttrTransferTypeConstraint ImplNodePwImplNodePropertyInfo = (~) (Ptr ())
    type AttrTransferType ImplNodePwImplNodePropertyInfo = Ptr ()
    type AttrGetType ImplNodePwImplNodePropertyInfo = (Ptr ())
    type AttrLabel ImplNodePwImplNodePropertyInfo = "pw-impl-node"
    type AttrOrigin ImplNodePwImplNodePropertyInfo = ImplNode
    attrGet = getImplNodePwImplNode
    attrSet = undefined
    attrPut = undefined
    attrTransfer _ v = do
        return v
    attrConstruct = constructImplNodePwImplNode
    attrClear = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.ImplNode.pwImplNode"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-ImplNode.html#g:attr:pwImplNode"
        })
#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList ImplNode
type instance O.AttributeList ImplNode = ImplNodeAttributeList
type ImplNodeAttributeList = ('[ '("activeFeatures", Wp.Object.ObjectActiveFeaturesPropertyInfo), '("boundId", Wp.Proxy.ProxyBoundIdPropertyInfo), '("core", Wp.Object.ObjectCorePropertyInfo), '("id", Wp.Object.ObjectIdPropertyInfo), '("nativeInfo", Wp.PipewireObject.PipewireObjectNativeInfoPropertyInfo), '("paramInfo", Wp.PipewireObject.PipewireObjectParamInfoPropertyInfo), '("properties", Wp.PipewireObject.PipewireObjectPropertiesPropertyInfo), '("pwImplNode", ImplNodePwImplNodePropertyInfo), '("pwProxy", Wp.Proxy.ProxyPwProxyPropertyInfo), '("supportedFeatures", Wp.Object.ObjectSupportedFeaturesPropertyInfo)] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
implNodePwImplNode :: AttrLabelProxy "pwImplNode"
implNodePwImplNode = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList ImplNode = ImplNodeSignalList
type ImplNodeSignalList = ('[ '("bound", Wp.Proxy.ProxyBoundSignalInfo), '("error", Wp.Proxy.ProxyErrorSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("paramsChanged", Wp.PipewireObject.PipewireObjectParamsChangedSignalInfo), '("pwProxyCreated", Wp.Proxy.ProxyPwProxyCreatedSignalInfo), '("pwProxyDestroyed", Wp.Proxy.ProxyPwProxyDestroyedSignalInfo)] :: [(Symbol, DK.Type)])

#endif

-- method ImplNode::new_from_pw_factory
-- 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 wireplumber core"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "factory_name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of the pipewire factory"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "properties"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "Properties" }
--           , argCType = Just "WpProperties*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "properties to be passed to node constructor"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "ImplNode" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_impl_node_new_from_pw_factory" wp_impl_node_new_from_pw_factory :: 
    Ptr Wp.Core.Core ->                     -- core : TInterface (Name {namespace = "Wp", name = "Core"})
    CString ->                              -- factory_name : TBasicType TUTF8
    Ptr Wp.Properties.Properties ->         -- properties : TInterface (Name {namespace = "Wp", name = "Properties"})
    IO (Ptr ImplNode)

-- | Constructs a new node, locally on this process, using the specified /@factoryName@/.
-- 
-- 
-- To export this node to the PipeWire server, you need to call 'GI.Wp.Objects.Object.objectActivate' requesting WP_PROXY_FEATURE_BOUND and wait for the operation to complete.
implNodeNewFromPwFactory ::
    (B.CallStack.HasCallStack, MonadIO m, Wp.Core.IsCore a) =>
    a
    -- ^ /@core@/: the wireplumber core
    -> T.Text
    -- ^ /@factoryName@/: the name of the pipewire factory
    -> Maybe (Wp.Properties.Properties)
    -- ^ /@properties@/: properties to be passed to node constructor
    -> m (Maybe ImplNode)
    -- ^ __Returns:__ A new WpImplNode wrapping the node that was constructed by the factory, or NULL if the factory does not exist or was unable to construct the node
implNodeNewFromPwFactory core factoryName properties = liftIO $ do
    core' <- unsafeManagedPtrCastPtr core
    factoryName' <- textToCString factoryName
    maybeProperties <- case properties of
        Nothing -> return FP.nullPtr
        Just jProperties -> do
            jProperties' <- B.ManagedPtr.disownBoxed jProperties
            return jProperties'
    result <- wp_impl_node_new_from_pw_factory core' factoryName' maybeProperties
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject ImplNode) result'
        return result''
    touchManagedPtr core
    whenJust properties touchManagedPtr
    freeMem factoryName'
    return maybeResult

#if defined(ENABLE_OVERLOADING)
#endif

-- method ImplNode::new_wrap
-- 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 wireplumber core"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "node"
--           , argType = TBasicType TPtr
--           , argCType = Just "pw_impl_node*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an existing pw_impl_node to wrap"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "ImplNode" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_impl_node_new_wrap" wp_impl_node_new_wrap :: 
    Ptr Wp.Core.Core ->                     -- core : TInterface (Name {namespace = "Wp", name = "Core"})
    Ptr () ->                               -- node : TBasicType TPtr
    IO (Ptr ImplNode)

-- | Constructs a node object from an existing pw_impl_node.
implNodeNewWrap ::
    (B.CallStack.HasCallStack, MonadIO m, Wp.Core.IsCore a) =>
    a
    -- ^ /@core@/: the wireplumber core
    -> Ptr ()
    -- ^ /@node@/: an existing pw_impl_node to wrap
    -> m ImplNode
    -- ^ __Returns:__ A new WpImplNode wrapping /@node@/
implNodeNewWrap core node = liftIO $ do
    core' <- unsafeManagedPtrCastPtr core
    result <- wp_impl_node_new_wrap core' node
    checkUnexpectedReturnNULL "implNodeNewWrap" result
    result' <- (wrapObject ImplNode) result
    touchManagedPtr core
    return result'

#if defined(ENABLE_OVERLOADING)
#endif


