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


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- An interface for port adapters

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

module GI.Wp.Interfaces.SiAdapter
    ( 

-- * Exported types
    SiAdapter(..)                           ,
    IsSiAdapter                             ,
    toSiAdapter                             ,


 -- * 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"), [configure]("GI.Wp.Objects.SessionItem#g:method:configure"), [deactivate]("GI.Wp.Objects.Object#g:method:deactivate"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isConfigured]("GI.Wp.Objects.SessionItem#g:method:isConfigured"), [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"), [register]("GI.Wp.Objects.SessionItem#g:method:register"), [remove]("GI.Wp.Objects.SessionItem#g:method:remove"), [reset]("GI.Wp.Objects.SessionItem#g:method:reset"), [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"), [getAssociatedProxy]("GI.Wp.Objects.SessionItem#g:method:getAssociatedProxy"), [getAssociatedProxyId]("GI.Wp.Objects.SessionItem#g:method:getAssociatedProxyId"), [getCore]("GI.Wp.Objects.Object#g:method:getCore"), [getData]("GI.GObject.Objects.Object#g:method:getData"), [getId]("GI.Wp.Objects.Object#g:method:getId"), [getPortsFormat]("GI.Wp.Interfaces.SiAdapter#g:method:getPortsFormat"), [getPortsState]("GI.Wp.Interfaces.SiAdapter#g:method:getPortsState"), [getProperties]("GI.Wp.Objects.SessionItem#g:method:getProperties"), [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"), [setPortsFormat]("GI.Wp.Interfaces.SiAdapter#g:method:setPortsFormat"), [setPortsFormatFinish]("GI.Wp.Interfaces.SiAdapter#g:method:setPortsFormatFinish"), [setProperties]("GI.Wp.Objects.SessionItem#g:method:setProperties"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").

#if defined(ENABLE_OVERLOADING)
    ResolveSiAdapterMethod                  ,
#endif

-- ** getPortsFormat #method:getPortsFormat#

#if defined(ENABLE_OVERLOADING)
    SiAdapterGetPortsFormatMethodInfo       ,
#endif
    siAdapterGetPortsFormat                 ,


-- ** getPortsState #method:getPortsState#

#if defined(ENABLE_OVERLOADING)
    SiAdapterGetPortsStateMethodInfo        ,
#endif
    siAdapterGetPortsState                  ,


-- ** setPortsFormat #method:setPortsFormat#

#if defined(ENABLE_OVERLOADING)
    SiAdapterSetPortsFormatMethodInfo       ,
#endif
    siAdapterSetPortsFormat                 ,


-- ** setPortsFormatFinish #method:setPortsFormatFinish#

#if defined(ENABLE_OVERLOADING)
    SiAdapterSetPortsFormatFinishMethodInfo ,
#endif
    siAdapterSetPortsFormatFinish           ,




 -- * Signals


-- ** adapterPortsStateChanged #signal:adapterPortsStateChanged#

    SiAdapterAdapterPortsStateChangedCallback,
#if defined(ENABLE_OVERLOADING)
    SiAdapterAdapterPortsStateChangedSignalInfo,
#endif
    afterSiAdapterAdapterPortsStateChanged  ,
    onSiAdapterAdapterPortsStateChanged     ,




    ) 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.Objects.Proxy as Wp.Proxy
import {-# SOURCE #-} qualified GI.Wp.Objects.SessionItem as Wp.SessionItem
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 qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Wp.Enums as Wp.Enums
import {-# SOURCE #-} qualified GI.Wp.Objects.Object as Wp.Object
import {-# SOURCE #-} qualified GI.Wp.Objects.SessionItem as Wp.SessionItem
import {-# SOURCE #-} qualified GI.Wp.Structs.SpaPod as Wp.SpaPod

#endif

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

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

foreign import ccall "wp_si_adapter_get_type"
    c_wp_si_adapter_get_type :: IO B.Types.GType

instance B.Types.TypedObject SiAdapter where
    glibType = c_wp_si_adapter_get_type

instance B.Types.GObject SiAdapter

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

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

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

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

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList SiAdapter
type instance O.AttributeList SiAdapter = SiAdapterAttributeList
type SiAdapterAttributeList = ('[ '("activeFeatures", Wp.Object.ObjectActiveFeaturesPropertyInfo), '("core", Wp.Object.ObjectCorePropertyInfo), '("id", Wp.Object.ObjectIdPropertyInfo), '("properties", Wp.SessionItem.SessionItemPropertiesPropertyInfo), '("supportedFeatures", Wp.Object.ObjectSupportedFeaturesPropertyInfo)] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveSiAdapterMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveSiAdapterMethod "abortActivation" o = Wp.Object.ObjectAbortActivationMethodInfo
    ResolveSiAdapterMethod "activate" o = Wp.Object.ObjectActivateMethodInfo
    ResolveSiAdapterMethod "activateClosure" o = Wp.Object.ObjectActivateClosureMethodInfo
    ResolveSiAdapterMethod "activateFinish" o = Wp.Object.ObjectActivateFinishMethodInfo
    ResolveSiAdapterMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveSiAdapterMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveSiAdapterMethod "configure" o = Wp.SessionItem.SessionItemConfigureMethodInfo
    ResolveSiAdapterMethod "deactivate" o = Wp.Object.ObjectDeactivateMethodInfo
    ResolveSiAdapterMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveSiAdapterMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveSiAdapterMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveSiAdapterMethod "isConfigured" o = Wp.SessionItem.SessionItemIsConfiguredMethodInfo
    ResolveSiAdapterMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveSiAdapterMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveSiAdapterMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveSiAdapterMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveSiAdapterMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveSiAdapterMethod "register" o = Wp.SessionItem.SessionItemRegisterMethodInfo
    ResolveSiAdapterMethod "remove" o = Wp.SessionItem.SessionItemRemoveMethodInfo
    ResolveSiAdapterMethod "reset" o = Wp.SessionItem.SessionItemResetMethodInfo
    ResolveSiAdapterMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveSiAdapterMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveSiAdapterMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveSiAdapterMethod "testActiveFeatures" o = Wp.Object.ObjectTestActiveFeaturesMethodInfo
    ResolveSiAdapterMethod "testSupportedFeatures" o = Wp.Object.ObjectTestSupportedFeaturesMethodInfo
    ResolveSiAdapterMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveSiAdapterMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveSiAdapterMethod "updateFeatures" o = Wp.Object.ObjectUpdateFeaturesMethodInfo
    ResolveSiAdapterMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveSiAdapterMethod "getActiveFeatures" o = Wp.Object.ObjectGetActiveFeaturesMethodInfo
    ResolveSiAdapterMethod "getAssociatedProxy" o = Wp.SessionItem.SessionItemGetAssociatedProxyMethodInfo
    ResolveSiAdapterMethod "getAssociatedProxyId" o = Wp.SessionItem.SessionItemGetAssociatedProxyIdMethodInfo
    ResolveSiAdapterMethod "getCore" o = Wp.Object.ObjectGetCoreMethodInfo
    ResolveSiAdapterMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveSiAdapterMethod "getId" o = Wp.Object.ObjectGetIdMethodInfo
    ResolveSiAdapterMethod "getPortsFormat" o = SiAdapterGetPortsFormatMethodInfo
    ResolveSiAdapterMethod "getPortsState" o = SiAdapterGetPortsStateMethodInfo
    ResolveSiAdapterMethod "getProperties" o = Wp.SessionItem.SessionItemGetPropertiesMethodInfo
    ResolveSiAdapterMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveSiAdapterMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveSiAdapterMethod "getSupportedFeatures" o = Wp.Object.ObjectGetSupportedFeaturesMethodInfo
    ResolveSiAdapterMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveSiAdapterMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveSiAdapterMethod "setPortsFormat" o = SiAdapterSetPortsFormatMethodInfo
    ResolveSiAdapterMethod "setPortsFormatFinish" o = SiAdapterSetPortsFormatFinishMethodInfo
    ResolveSiAdapterMethod "setProperties" o = Wp.SessionItem.SessionItemSetPropertiesMethodInfo
    ResolveSiAdapterMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveSiAdapterMethod l o = O.MethodResolutionFailed l o

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

#endif

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

#endif

-- method SiAdapter::get_ports_format
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "SiAdapter" }
--           , argCType = Just "WpSiAdapter*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the session item" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "mode"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar**"
--           , direction = DirectionOut
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the mode" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "SpaPod" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_si_adapter_get_ports_format" wp_si_adapter_get_ports_format :: 
    Ptr SiAdapter ->                        -- self : TInterface (Name {namespace = "Wp", name = "SiAdapter"})
    Ptr CString ->                          -- mode : TBasicType TUTF8
    IO (Ptr Wp.SpaPod.SpaPod)

-- | Gets the format used to configure the adapter session item\'s ports.
siAdapterGetPortsFormat ::
    (B.CallStack.HasCallStack, MonadIO m, IsSiAdapter a) =>
    a
    -- ^ /@self@/: the session item
    -> m ((Wp.SpaPod.SpaPod, Maybe T.Text))
    -- ^ __Returns:__ The format used to configure the ports of the adapter session item. Some items automatically choose a format when being activated, others never set a format on activation and the user needs to manually set it externally with 'GI.Wp.Interfaces.SiAdapter.siAdapterSetPortsFormat'.
siAdapterGetPortsFormat self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    mode <- callocMem :: IO (Ptr CString)
    result <- wp_si_adapter_get_ports_format self' mode
    checkUnexpectedReturnNULL "siAdapterGetPortsFormat" result
    result' <- (wrapBoxed Wp.SpaPod.SpaPod) result
    mode' <- peek mode
    maybeMode' <- convertIfNonNull mode' $ \mode'' -> do
        mode''' <- cstringToText mode''
        return mode'''
    freeMem mode'
    touchManagedPtr self
    freeMem mode
    return (result', maybeMode')

#if defined(ENABLE_OVERLOADING)
data SiAdapterGetPortsFormatMethodInfo
instance (signature ~ (m ((Wp.SpaPod.SpaPod, Maybe T.Text))), MonadIO m, IsSiAdapter a) => O.OverloadedMethod SiAdapterGetPortsFormatMethodInfo a signature where
    overloadedMethod = siAdapterGetPortsFormat

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


#endif

-- method SiAdapter::get_ports_state
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "SiAdapter" }
--           , argCType = Just "WpSiAdapter*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the session item" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Wp" , name = "SiAdapterPortsState" })
-- throws : False
-- Skip return : False

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

-- | Gets the ports state.
-- 
-- /Since: 0.4.10/
siAdapterGetPortsState ::
    (B.CallStack.HasCallStack, MonadIO m, IsSiAdapter a) =>
    a
    -- ^ /@self@/: the session item
    -> m Wp.Enums.SiAdapterPortsState
    -- ^ __Returns:__ The state of the ports
siAdapterGetPortsState self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- wp_si_adapter_get_ports_state self'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data SiAdapterGetPortsStateMethodInfo
instance (signature ~ (m Wp.Enums.SiAdapterPortsState), MonadIO m, IsSiAdapter a) => O.OverloadedMethod SiAdapterGetPortsStateMethodInfo a signature where
    overloadedMethod = siAdapterGetPortsState

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


#endif

-- method SiAdapter::set_ports_format
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "SiAdapter" }
--           , argCType = Just "WpSiAdapter*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the session item" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "format"
--           , argType = TInterface Name { namespace = "Wp" , name = "SpaPod" }
--           , argCType = Just "WpSpaPod*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the format to be set"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "mode"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the mode" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "callback"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncReadyCallback" }
--           , argCType = Just "GAsyncReadyCallback"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the callback to call when the operation is done"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = 4
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "data"
--           , argType = TBasicType TPtr
--           , argCType = Just "gpointer"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data for @callback"
--                 , 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_si_adapter_set_ports_format" wp_si_adapter_set_ports_format :: 
    Ptr SiAdapter ->                        -- self : TInterface (Name {namespace = "Wp", name = "SiAdapter"})
    Ptr Wp.SpaPod.SpaPod ->                 -- format : TInterface (Name {namespace = "Wp", name = "SpaPod"})
    CString ->                              -- mode : TBasicType TUTF8
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- data : TBasicType TPtr
    IO ()

-- | Sets the format and configures the adapter session item ports using the given format.
-- 
-- 
-- The result of the operation can be checked using the 'GI.Wp.Interfaces.SiAdapter.siAdapterSetPortsFormatFinish' API. If format is NULL, the adapter will be configured with the default format. If mode is NULL, the adapter will use \"dsp\" mode.
siAdapterSetPortsFormat ::
    (B.CallStack.HasCallStack, MonadIO m, IsSiAdapter a) =>
    a
    -- ^ /@self@/: the session item
    -> Maybe (Wp.SpaPod.SpaPod)
    -- ^ /@format@/: the format to be set
    -> Maybe (T.Text)
    -- ^ /@mode@/: the mode
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: the callback to call when the operation is done
    -> m ()
siAdapterSetPortsFormat self format mode callback = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybeFormat <- case format of
        Nothing -> return FP.nullPtr
        Just jFormat -> do
            jFormat' <- B.ManagedPtr.disownBoxed jFormat
            return jFormat'
    maybeMode <- case mode of
        Nothing -> return FP.nullPtr
        Just jMode -> do
            jMode' <- textToCString jMode
            return jMode'
    maybeCallback <- case callback of
        Nothing -> return FP.nullFunPtr
        Just jCallback -> do
            ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let data_ = nullPtr
    wp_si_adapter_set_ports_format self' maybeFormat maybeMode maybeCallback data_
    touchManagedPtr self
    whenJust format touchManagedPtr
    freeMem maybeMode
    return ()

#if defined(ENABLE_OVERLOADING)
data SiAdapterSetPortsFormatMethodInfo
instance (signature ~ (Maybe (Wp.SpaPod.SpaPod) -> Maybe (T.Text) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsSiAdapter a) => O.OverloadedMethod SiAdapterSetPortsFormatMethodInfo a signature where
    overloadedMethod = siAdapterSetPortsFormat

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


#endif

-- method SiAdapter::set_ports_format_finish
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "SiAdapter" }
--           , argCType = Just "WpSiAdapter*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the session item" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "res"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "AsyncResult" }
--           , argCType = Just "GAsyncResult*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the async result" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "wp_si_adapter_set_ports_format_finish" wp_si_adapter_set_ports_format_finish :: 
    Ptr SiAdapter ->                        -- self : TInterface (Name {namespace = "Wp", name = "SiAdapter"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Finishes the operation started by @/wp_si_adapter_set_format()/@. This is meant to be called in the callback that was passed to that method.
siAdapterSetPortsFormatFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsSiAdapter a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    -- ^ /@self@/: the session item
    -> b
    -- ^ /@res@/: the async result
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
siAdapterSetPortsFormatFinish self res = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        _ <- propagateGError $ wp_si_adapter_set_ports_format_finish self' res'
        touchManagedPtr self
        touchManagedPtr res
        return ()
     ) (do
        return ()
     )

#if defined(ENABLE_OVERLOADING)
data SiAdapterSetPortsFormatFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsSiAdapter a, Gio.AsyncResult.IsAsyncResult b) => O.OverloadedMethod SiAdapterSetPortsFormatFinishMethodInfo a signature where
    overloadedMethod = siAdapterSetPortsFormatFinish

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


#endif

-- signal SiAdapter::adapter-ports-state-changed
-- | /No description available in the introspection data./
type SiAdapterAdapterPortsStateChangedCallback =
    Wp.Enums.SiAdapterPortsState
    -> Wp.Enums.SiAdapterPortsState
    -> IO ()

type C_SiAdapterAdapterPortsStateChangedCallback =
    Ptr SiAdapter ->                        -- object
    CUInt ->
    CUInt ->
    Ptr () ->                               -- user_data
    IO ()

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

wrap_SiAdapterAdapterPortsStateChangedCallback :: 
    GObject a => (a -> SiAdapterAdapterPortsStateChangedCallback) ->
    C_SiAdapterAdapterPortsStateChangedCallback
wrap_SiAdapterAdapterPortsStateChangedCallback gi'cb gi'selfPtr object p0 _ = do
    let object' = (toEnum . fromIntegral) object
    let p0' = (toEnum . fromIntegral) p0
    B.ManagedPtr.withNewObject gi'selfPtr $ \gi'self -> gi'cb (Coerce.coerce gi'self)  object' p0'


-- | Connect a signal handler for the [adapterPortsStateChanged](#signal:adapterPortsStateChanged) 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' siAdapter #adapterPortsStateChanged callback
-- @
-- 
-- 
onSiAdapterAdapterPortsStateChanged :: (IsSiAdapter a, MonadIO m) => a -> ((?self :: a) => SiAdapterAdapterPortsStateChangedCallback) -> m SignalHandlerId
onSiAdapterAdapterPortsStateChanged obj cb = liftIO $ do
    let wrapped self = let ?self = self in cb
    let wrapped' = wrap_SiAdapterAdapterPortsStateChangedCallback wrapped
    wrapped'' <- mk_SiAdapterAdapterPortsStateChangedCallback wrapped'
    connectSignalFunPtr obj "adapter-ports-state-changed" wrapped'' SignalConnectBefore Nothing

-- | Connect a signal handler for the [adapterPortsStateChanged](#signal:adapterPortsStateChanged) 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' siAdapter #adapterPortsStateChanged 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.
-- 
afterSiAdapterAdapterPortsStateChanged :: (IsSiAdapter a, MonadIO m) => a -> ((?self :: a) => SiAdapterAdapterPortsStateChangedCallback) -> m SignalHandlerId
afterSiAdapterAdapterPortsStateChanged obj cb = liftIO $ do
    let wrapped self = let ?self = self in cb
    let wrapped' = wrap_SiAdapterAdapterPortsStateChangedCallback wrapped
    wrapped'' <- mk_SiAdapterAdapterPortsStateChangedCallback wrapped'
    connectSignalFunPtr obj "adapter-ports-state-changed" wrapped'' SignalConnectAfter Nothing


#if defined(ENABLE_OVERLOADING)
data SiAdapterAdapterPortsStateChangedSignalInfo
instance SignalInfo SiAdapterAdapterPortsStateChangedSignalInfo where
    type HaskellCallbackType SiAdapterAdapterPortsStateChangedSignalInfo = SiAdapterAdapterPortsStateChangedCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_SiAdapterAdapterPortsStateChangedCallback cb
        cb'' <- mk_SiAdapterAdapterPortsStateChangedCallback cb'
        connectSignalFunPtr obj "adapter-ports-state-changed" cb'' connectMode detail
    dbgSignalInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Interfaces.SiAdapter::adapter-ports-state-changed"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Interfaces-SiAdapter.html#g:signal:adapterPortsStateChanged"})

#endif

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

#endif


