{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

Information about a signal on a D-Bus interface.

/Since: 2.26/
-}

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

module GI.Gio.Structs.DBusSignalInfo
    (

-- * Exported types
    DBusSignalInfo(..)                      ,
    newZeroDBusSignalInfo                   ,
    noDBusSignalInfo                        ,


 -- * Methods
-- ** ref #method:ref#

#if ENABLE_OVERLOADING
    DBusSignalInfoRefMethodInfo             ,
#endif
    dBusSignalInfoRef                       ,


-- ** unref #method:unref#

#if ENABLE_OVERLOADING
    DBusSignalInfoUnrefMethodInfo           ,
#endif
    dBusSignalInfoUnref                     ,




 -- * Properties
-- ** annotations #attr:annotations#
{- | A pointer to a 'Nothing'-terminated array of pointers to 'GI.Gio.Structs.DBusAnnotationInfo.DBusAnnotationInfo' structures or 'Nothing' if there are no annotations.
-}
    clearDBusSignalInfoAnnotations          ,
#if ENABLE_OVERLOADING
    dBusSignalInfo_annotations              ,
#endif
    getDBusSignalInfoAnnotations            ,
    setDBusSignalInfoAnnotations            ,


-- ** args #attr:args#
{- | A pointer to a 'Nothing'-terminated array of pointers to 'GI.Gio.Structs.DBusArgInfo.DBusArgInfo' structures or 'Nothing' if there are no arguments.
-}
    clearDBusSignalInfoArgs                 ,
#if ENABLE_OVERLOADING
    dBusSignalInfo_args                     ,
#endif
    getDBusSignalInfoArgs                   ,
    setDBusSignalInfoArgs                   ,


-- ** name #attr:name#
{- | The name of the D-Bus signal, e.g. \"NameOwnerChanged\".
-}
    clearDBusSignalInfoName                 ,
#if ENABLE_OVERLOADING
    dBusSignalInfo_name                     ,
#endif
    getDBusSignalInfoName                   ,
    setDBusSignalInfoName                   ,


-- ** refCount #attr:refCount#
{- | The reference count or -1 if statically allocated.
-}
#if ENABLE_OVERLOADING
    dBusSignalInfo_refCount                 ,
#endif
    getDBusSignalInfoRefCount               ,
    setDBusSignalInfoRefCount               ,




    ) 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.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
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.Text as T
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 {-# SOURCE #-} qualified GI.Gio.Structs.DBusAnnotationInfo as Gio.DBusAnnotationInfo
import {-# SOURCE #-} qualified GI.Gio.Structs.DBusArgInfo as Gio.DBusArgInfo

-- | Memory-managed wrapper type.
newtype DBusSignalInfo = DBusSignalInfo (ManagedPtr DBusSignalInfo)
foreign import ccall "g_dbus_signal_info_get_type" c_g_dbus_signal_info_get_type ::
    IO GType

instance BoxedObject DBusSignalInfo where
    boxedType _ = c_g_dbus_signal_info_get_type

-- | Construct a `DBusSignalInfo` struct initialized to zero.
newZeroDBusSignalInfo :: MonadIO m => m DBusSignalInfo
newZeroDBusSignalInfo = liftIO $ callocBoxedBytes 32 >>= wrapBoxed DBusSignalInfo

instance tag ~ 'AttrSet => Constructible DBusSignalInfo tag where
    new _ attrs = do
        o <- newZeroDBusSignalInfo
        GI.Attributes.set o attrs
        return o


-- | A convenience alias for `Nothing` :: `Maybe` `DBusSignalInfo`.
noDBusSignalInfo :: Maybe DBusSignalInfo
noDBusSignalInfo = Nothing

{- |
Get the value of the “@ref_count@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' dBusSignalInfo #refCount
@
-}
getDBusSignalInfoRefCount :: MonadIO m => DBusSignalInfo -> m Int32
getDBusSignalInfoRefCount s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Int32
    return val

{- |
Set the value of the “@ref_count@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' dBusSignalInfo [ #refCount 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDBusSignalInfoRefCount :: MonadIO m => DBusSignalInfo -> Int32 -> m ()
setDBusSignalInfoRefCount s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 0) (val :: Int32)

#if ENABLE_OVERLOADING
data DBusSignalInfoRefCountFieldInfo
instance AttrInfo DBusSignalInfoRefCountFieldInfo where
    type AttrAllowedOps DBusSignalInfoRefCountFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint DBusSignalInfoRefCountFieldInfo = (~) Int32
    type AttrBaseTypeConstraint DBusSignalInfoRefCountFieldInfo = (~) DBusSignalInfo
    type AttrGetType DBusSignalInfoRefCountFieldInfo = Int32
    type AttrLabel DBusSignalInfoRefCountFieldInfo = "ref_count"
    type AttrOrigin DBusSignalInfoRefCountFieldInfo = DBusSignalInfo
    attrGet _ = getDBusSignalInfoRefCount
    attrSet _ = setDBusSignalInfoRefCount
    attrConstruct = undefined
    attrClear _ = undefined

dBusSignalInfo_refCount :: AttrLabelProxy "refCount"
dBusSignalInfo_refCount = AttrLabelProxy

#endif


{- |
Get the value of the “@name@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' dBusSignalInfo #name
@
-}
getDBusSignalInfoName :: MonadIO m => DBusSignalInfo -> m (Maybe T.Text)
getDBusSignalInfoName s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO CString
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- cstringToText val'
        return val''
    return result

{- |
Set the value of the “@name@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' dBusSignalInfo [ #name 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDBusSignalInfoName :: MonadIO m => DBusSignalInfo -> CString -> m ()
setDBusSignalInfoName s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (val :: CString)

{- |
Set the value of the “@name@” field to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #name
@
-}
clearDBusSignalInfoName :: MonadIO m => DBusSignalInfo -> m ()
clearDBusSignalInfoName s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (FP.nullPtr :: CString)

#if ENABLE_OVERLOADING
data DBusSignalInfoNameFieldInfo
instance AttrInfo DBusSignalInfoNameFieldInfo where
    type AttrAllowedOps DBusSignalInfoNameFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusSignalInfoNameFieldInfo = (~) CString
    type AttrBaseTypeConstraint DBusSignalInfoNameFieldInfo = (~) DBusSignalInfo
    type AttrGetType DBusSignalInfoNameFieldInfo = Maybe T.Text
    type AttrLabel DBusSignalInfoNameFieldInfo = "name"
    type AttrOrigin DBusSignalInfoNameFieldInfo = DBusSignalInfo
    attrGet _ = getDBusSignalInfoName
    attrSet _ = setDBusSignalInfoName
    attrConstruct = undefined
    attrClear _ = clearDBusSignalInfoName

dBusSignalInfo_name :: AttrLabelProxy "name"
dBusSignalInfo_name = AttrLabelProxy

#endif


{- |
Get the value of the “@args@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' dBusSignalInfo #args
@
-}
getDBusSignalInfoArgs :: MonadIO m => DBusSignalInfo -> m (Maybe [Gio.DBusArgInfo.DBusArgInfo])
getDBusSignalInfoArgs s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO (Ptr (Ptr Gio.DBusArgInfo.DBusArgInfo))
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- unpackZeroTerminatedPtrArray val'
        val''' <- mapM (newBoxed Gio.DBusArgInfo.DBusArgInfo) val''
        return val'''
    return result

{- |
Set the value of the “@args@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' dBusSignalInfo [ #args 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDBusSignalInfoArgs :: MonadIO m => DBusSignalInfo -> Ptr (Ptr Gio.DBusArgInfo.DBusArgInfo) -> m ()
setDBusSignalInfoArgs s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (val :: Ptr (Ptr Gio.DBusArgInfo.DBusArgInfo))

{- |
Set the value of the “@args@” field to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #args
@
-}
clearDBusSignalInfoArgs :: MonadIO m => DBusSignalInfo -> m ()
clearDBusSignalInfoArgs s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 16) (FP.nullPtr :: Ptr (Ptr Gio.DBusArgInfo.DBusArgInfo))

#if ENABLE_OVERLOADING
data DBusSignalInfoArgsFieldInfo
instance AttrInfo DBusSignalInfoArgsFieldInfo where
    type AttrAllowedOps DBusSignalInfoArgsFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusSignalInfoArgsFieldInfo = (~) (Ptr (Ptr Gio.DBusArgInfo.DBusArgInfo))
    type AttrBaseTypeConstraint DBusSignalInfoArgsFieldInfo = (~) DBusSignalInfo
    type AttrGetType DBusSignalInfoArgsFieldInfo = Maybe [Gio.DBusArgInfo.DBusArgInfo]
    type AttrLabel DBusSignalInfoArgsFieldInfo = "args"
    type AttrOrigin DBusSignalInfoArgsFieldInfo = DBusSignalInfo
    attrGet _ = getDBusSignalInfoArgs
    attrSet _ = setDBusSignalInfoArgs
    attrConstruct = undefined
    attrClear _ = clearDBusSignalInfoArgs

dBusSignalInfo_args :: AttrLabelProxy "args"
dBusSignalInfo_args = AttrLabelProxy

#endif


{- |
Get the value of the “@annotations@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' dBusSignalInfo #annotations
@
-}
getDBusSignalInfoAnnotations :: MonadIO m => DBusSignalInfo -> m (Maybe [Gio.DBusAnnotationInfo.DBusAnnotationInfo])
getDBusSignalInfoAnnotations s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 24) :: IO (Ptr (Ptr Gio.DBusAnnotationInfo.DBusAnnotationInfo))
    result <- SP.convertIfNonNull val $ \val' -> do
        val'' <- unpackZeroTerminatedPtrArray val'
        val''' <- mapM (newBoxed Gio.DBusAnnotationInfo.DBusAnnotationInfo) val''
        return val'''
    return result

{- |
Set the value of the “@annotations@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' dBusSignalInfo [ #annotations 'Data.GI.Base.Attributes.:=' value ]
@
-}
setDBusSignalInfoAnnotations :: MonadIO m => DBusSignalInfo -> Ptr (Ptr Gio.DBusAnnotationInfo.DBusAnnotationInfo) -> m ()
setDBusSignalInfoAnnotations s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 24) (val :: Ptr (Ptr Gio.DBusAnnotationInfo.DBusAnnotationInfo))

{- |
Set the value of the “@annotations@” field to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #annotations
@
-}
clearDBusSignalInfoAnnotations :: MonadIO m => DBusSignalInfo -> m ()
clearDBusSignalInfoAnnotations s = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 24) (FP.nullPtr :: Ptr (Ptr Gio.DBusAnnotationInfo.DBusAnnotationInfo))

#if ENABLE_OVERLOADING
data DBusSignalInfoAnnotationsFieldInfo
instance AttrInfo DBusSignalInfoAnnotationsFieldInfo where
    type AttrAllowedOps DBusSignalInfoAnnotationsFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusSignalInfoAnnotationsFieldInfo = (~) (Ptr (Ptr Gio.DBusAnnotationInfo.DBusAnnotationInfo))
    type AttrBaseTypeConstraint DBusSignalInfoAnnotationsFieldInfo = (~) DBusSignalInfo
    type AttrGetType DBusSignalInfoAnnotationsFieldInfo = Maybe [Gio.DBusAnnotationInfo.DBusAnnotationInfo]
    type AttrLabel DBusSignalInfoAnnotationsFieldInfo = "annotations"
    type AttrOrigin DBusSignalInfoAnnotationsFieldInfo = DBusSignalInfo
    attrGet _ = getDBusSignalInfoAnnotations
    attrSet _ = setDBusSignalInfoAnnotations
    attrConstruct = undefined
    attrClear _ = clearDBusSignalInfoAnnotations

dBusSignalInfo_annotations :: AttrLabelProxy "annotations"
dBusSignalInfo_annotations = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList DBusSignalInfo
type instance O.AttributeList DBusSignalInfo = DBusSignalInfoAttributeList
type DBusSignalInfoAttributeList = ('[ '("refCount", DBusSignalInfoRefCountFieldInfo), '("name", DBusSignalInfoNameFieldInfo), '("args", DBusSignalInfoArgsFieldInfo), '("annotations", DBusSignalInfoAnnotationsFieldInfo)] :: [(Symbol, *)])
#endif

-- method DBusSignalInfo::ref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "DBusSignalInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusSignalInfo", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DBusSignalInfo"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_signal_info_ref" g_dbus_signal_info_ref ::
    Ptr DBusSignalInfo ->                   -- info : TInterface (Name {namespace = "Gio", name = "DBusSignalInfo"})
    IO (Ptr DBusSignalInfo)

{- |
If /@info@/ is statically allocated does nothing. Otherwise increases
the reference count.

/Since: 2.26/
-}
dBusSignalInfoRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DBusSignalInfo
    {- ^ /@info@/: A 'GI.Gio.Structs.DBusSignalInfo.DBusSignalInfo' -}
    -> m DBusSignalInfo
    {- ^ __Returns:__ The same /@info@/. -}
dBusSignalInfoRef info = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    result <- g_dbus_signal_info_ref info'
    checkUnexpectedReturnNULL "dBusSignalInfoRef" result
    result' <- (wrapBoxed DBusSignalInfo) result
    touchManagedPtr info
    return result'

#if ENABLE_OVERLOADING
data DBusSignalInfoRefMethodInfo
instance (signature ~ (m DBusSignalInfo), MonadIO m) => O.MethodInfo DBusSignalInfoRefMethodInfo DBusSignalInfo signature where
    overloadedMethod _ = dBusSignalInfoRef

#endif

-- method DBusSignalInfo::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "DBusSignalInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusSignalInfo.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_signal_info_unref" g_dbus_signal_info_unref ::
    Ptr DBusSignalInfo ->                   -- info : TInterface (Name {namespace = "Gio", name = "DBusSignalInfo"})
    IO ()

{- |
If /@info@/ is statically allocated, does nothing. Otherwise decreases
the reference count of /@info@/. When its reference count drops to 0,
the memory used is freed.

/Since: 2.26/
-}
dBusSignalInfoUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DBusSignalInfo
    {- ^ /@info@/: A 'GI.Gio.Structs.DBusSignalInfo.DBusSignalInfo'. -}
    -> m ()
dBusSignalInfoUnref info = liftIO $ do
    info' <- unsafeManagedPtrGetPtr info
    g_dbus_signal_info_unref info'
    touchManagedPtr info
    return ()

#if ENABLE_OVERLOADING
data DBusSignalInfoUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo DBusSignalInfoUnrefMethodInfo DBusSignalInfo signature where
    overloadedMethod _ = dBusSignalInfoUnref

#endif

#if ENABLE_OVERLOADING
type family ResolveDBusSignalInfoMethod (t :: Symbol) (o :: *) :: * where
    ResolveDBusSignalInfoMethod "ref" o = DBusSignalInfoRefMethodInfo
    ResolveDBusSignalInfoMethod "unref" o = DBusSignalInfoUnrefMethodInfo
    ResolveDBusSignalInfoMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDBusSignalInfoMethod t DBusSignalInfo, O.MethodInfo info DBusSignalInfo p) => OL.IsLabel t (DBusSignalInfo -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif