packages feed

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

{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The WpFactory class allows accessing the properties and methods of PipeWire Factory objects (struct pw_factory).
-- A WpFactory is constructed internally by wireplumber, when the pipewire constructed factory objects are reported in by PipeWire registry and it is made available for wireplumber clients through the WpObjectManager API.
-- 
-- /Since: 0.4.5/

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

module GI.Wp.Objects.Factory
    ( 

-- * Exported types
    Factory(..)                             ,
    IsFactory                               ,
    toFactory                               ,


 -- * 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"), [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"), [requestDestroy]("GI.Wp.Objects.GlobalProxy#g:method:requestDestroy"), [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"), [getGlobalProperties]("GI.Wp.Objects.GlobalProxy#g:method:getGlobalProperties"), [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"), [getPermissions]("GI.Wp.Objects.GlobalProxy#g:method:getPermissions"), [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)
    ResolveFactoryMethod                    ,
#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.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.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.GlobalProxy as Wp.GlobalProxy
import {-# SOURCE #-} qualified GI.Wp.Objects.Object as Wp.Object
import {-# SOURCE #-} qualified GI.Wp.Objects.Proxy as Wp.Proxy

#endif

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

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

foreign import ccall "wp_factory_get_type"
    c_wp_factory_get_type :: IO B.Types.GType

instance B.Types.TypedObject Factory where
    glibType = c_wp_factory_get_type

instance B.Types.GObject Factory

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

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

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

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

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

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

#endif

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

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Factory
type instance O.AttributeList Factory = FactoryAttributeList
type FactoryAttributeList = ('[ '("activeFeatures", Wp.Object.ObjectActiveFeaturesPropertyInfo), '("boundId", Wp.Proxy.ProxyBoundIdPropertyInfo), '("core", Wp.Object.ObjectCorePropertyInfo), '("factoryName", Wp.GlobalProxy.GlobalProxyFactoryNamePropertyInfo), '("globalProperties", Wp.GlobalProxy.GlobalProxyGlobalPropertiesPropertyInfo), '("id", Wp.Object.ObjectIdPropertyInfo), '("nativeInfo", Wp.PipewireObject.PipewireObjectNativeInfoPropertyInfo), '("paramInfo", Wp.PipewireObject.PipewireObjectParamInfoPropertyInfo), '("permissions", Wp.GlobalProxy.GlobalProxyPermissionsPropertyInfo), '("properties", Wp.PipewireObject.PipewireObjectPropertiesPropertyInfo), '("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 Factory = FactorySignalList
type FactorySignalList = ('[ '("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