{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The WpClient class allows accessing the properties and methods of a PipeWire client object (struct pw_client). A WpClient is constructed internally when a new client connects to PipeWire 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.Client
    ( 

-- * Exported types
    Client(..)                              ,
    IsClient                                ,
    toClient                                ,


 -- * 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"), [attachPermissionManager]("GI.Wp.Objects.Client#g:method:attachPermissionManager"), [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"), [sendError]("GI.Wp.Objects.Client#g:method:sendError"), [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"), [updateProperties]("GI.Wp.Objects.Client#g:method:updateProperties"), [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"), [getPermissionManager]("GI.Wp.Objects.Client#g:method:getPermissionManager"), [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)
    ResolveClientMethod                     ,
#endif

-- ** attachPermissionManager #method:attachPermissionManager#

#if defined(ENABLE_OVERLOADING)
    ClientAttachPermissionManagerMethodInfo ,
#endif
    clientAttachPermissionManager           ,


-- ** getPermissionManager #method:getPermissionManager#

#if defined(ENABLE_OVERLOADING)
    ClientGetPermissionManagerMethodInfo    ,
#endif
    clientGetPermissionManager              ,


-- ** sendError #method:sendError#

#if defined(ENABLE_OVERLOADING)
    ClientSendErrorMethodInfo               ,
#endif
    clientSendError                         ,


-- ** updateProperties #method:updateProperties#

#if defined(ENABLE_OVERLOADING)
    ClientUpdatePropertiesMethodInfo        ,
#endif
    clientUpdateProperties                  ,




    ) 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.PermissionManager as Wp.PermissionManager
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.PermissionManager as Wp.PermissionManager
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 Client = Client (SP.ManagedPtr Client)
    deriving (Eq)

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

foreign import ccall "wp_client_get_type"
    c_wp_client_get_type :: IO B.Types.GType

instance B.Types.TypedObject Client where
    glibType = c_wp_client_get_type

instance B.Types.GObject Client

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

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

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

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

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

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

#endif

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

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Client
type instance O.AttributeList Client = ClientAttributeList
type ClientAttributeList = ('[ '("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 Client = ClientSignalList
type ClientSignalList = ('[ '("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 Client::attach_permission_manager
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Client" }
--           , argCType = Just "WpClient*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the client" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "pm"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "PermissionManager" }
--           , argCType = Just "WpPermissionManager*"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the permission manager to attach, or NULL to detach the current permission manager."
--                 , 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_client_attach_permission_manager" wp_client_attach_permission_manager :: 
    Ptr Client ->                           -- self : TInterface (Name {namespace = "Wp", name = "Client"})
    Ptr Wp.PermissionManager.PermissionManager -> -- pm : TInterface (Name {namespace = "Wp", name = "PermissionManager"})
    IO ()

-- | Attaches a permission manager in the client to handle permissions automatically.
clientAttachPermissionManager ::
    (B.CallStack.HasCallStack, MonadIO m, IsClient a, Wp.PermissionManager.IsPermissionManager b) =>
    a
    -- ^ /@self@/: the client
    -> Maybe (b)
    -- ^ /@pm@/: the permission manager to attach, or NULL to detach the current permission manager.
    -> m ()
clientAttachPermissionManager self pm = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybePm <- case pm of
        Nothing -> return FP.nullPtr
        Just jPm -> do
            jPm' <- unsafeManagedPtrCastPtr jPm
            return jPm'
    wp_client_attach_permission_manager self' maybePm
    touchManagedPtr self
    whenJust pm touchManagedPtr
    return ()

#if defined(ENABLE_OVERLOADING)
data ClientAttachPermissionManagerMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsClient a, Wp.PermissionManager.IsPermissionManager b) => O.OverloadedMethod ClientAttachPermissionManagerMethodInfo a signature where
    overloadedMethod = clientAttachPermissionManager

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


#endif

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

foreign import ccall "wp_client_get_permission_manager" wp_client_get_permission_manager :: 
    Ptr Client ->                           -- self : TInterface (Name {namespace = "Wp", name = "Client"})
    IO (Ptr Wp.PermissionManager.PermissionManager)

-- | Gets the permission manager attached to this client, if any.
clientGetPermissionManager ::
    (B.CallStack.HasCallStack, MonadIO m, IsClient a) =>
    a
    -- ^ /@self@/: the client
    -> m (Maybe Wp.PermissionManager.PermissionManager)
    -- ^ __Returns:__ the attached permission manager, or NULL if no permission manager is attached
clientGetPermissionManager self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- wp_client_get_permission_manager self'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Wp.PermissionManager.PermissionManager) result'
        return result''
    touchManagedPtr self
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data ClientGetPermissionManagerMethodInfo
instance (signature ~ (m (Maybe Wp.PermissionManager.PermissionManager)), MonadIO m, IsClient a) => O.OverloadedMethod ClientGetPermissionManagerMethodInfo a signature where
    overloadedMethod = clientGetPermissionManager

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


#endif

-- method Client::send_error
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Client" }
--           , argCType = Just "WpClient*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the client" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "id"
--           , argType = TBasicType TUInt32
--           , argCType = Just "guint32"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the global id to report the error on"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "res"
--           , argType = TBasicType TInt
--           , argCType = Just "int"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an errno style error code"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "message"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the error message string"
--                 , 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_client_send_error" wp_client_send_error :: 
    Ptr Client ->                           -- self : TInterface (Name {namespace = "Wp", name = "Client"})
    Word32 ->                               -- id : TBasicType TUInt32
    Int32 ->                                -- res : TBasicType TInt
    CString ->                              -- message : TBasicType TUTF8
    IO ()

-- | Send an error to the client.
clientSendError ::
    (B.CallStack.HasCallStack, MonadIO m, IsClient a) =>
    a
    -- ^ /@self@/: the client
    -> Word32
    -- ^ /@id@/: the global id to report the error on
    -> Int32
    -- ^ /@res@/: an errno style error code
    -> T.Text
    -- ^ /@message@/: the error message string
    -> m ()
clientSendError self id res message = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    message' <- textToCString message
    wp_client_send_error self' id res message'
    touchManagedPtr self
    freeMem message'
    return ()

#if defined(ENABLE_OVERLOADING)
data ClientSendErrorMethodInfo
instance (signature ~ (Word32 -> Int32 -> T.Text -> m ()), MonadIO m, IsClient a) => O.OverloadedMethod ClientSendErrorMethodInfo a signature where
    overloadedMethod = clientSendError

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


#endif

-- method Client::update_properties
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TInterface Name { namespace = "Wp" , name = "Client" }
--           , argCType = Just "WpClient*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the client" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "updates"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "Properties" }
--           , argCType = Just "WpProperties*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "updates to apply to the properties of @self; this does not need to include properties that have not changed"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "wp_client_update_properties" wp_client_update_properties :: 
    Ptr Client ->                           -- self : TInterface (Name {namespace = "Wp", name = "Client"})
    Ptr Wp.Properties.Properties ->         -- updates : TInterface (Name {namespace = "Wp", name = "Properties"})
    IO ()

-- | Updates the properties of /@self@/.
-- 
-- 
-- This requires W and X permissions on the client.
clientUpdateProperties ::
    (B.CallStack.HasCallStack, MonadIO m, IsClient a) =>
    a
    -- ^ /@self@/: the client
    -> Wp.Properties.Properties
    -- ^ /@updates@/: updates to apply to the properties of /@self@/; this does not need to include properties that have not changed
    -> m ()
clientUpdateProperties self updates = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    updates' <- B.ManagedPtr.disownBoxed updates
    wp_client_update_properties self' updates'
    touchManagedPtr self
    touchManagedPtr updates
    return ()

#if defined(ENABLE_OVERLOADING)
data ClientUpdatePropertiesMethodInfo
instance (signature ~ (Wp.Properties.Properties -> m ()), MonadIO m, IsClient a) => O.OverloadedMethod ClientUpdatePropertiesMethodInfo a signature where
    overloadedMethod = clientUpdateProperties

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


#endif


