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

'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' is the base DTLS connection class type, which wraps
a 'GI.Gio.Interfaces.DatagramBased.DatagramBased' and provides DTLS encryption on top of it. Its
subclasses, 'GI.Gio.Interfaces.DtlsClientConnection.DtlsClientConnection' and 'GI.Gio.Interfaces.DtlsServerConnection.DtlsServerConnection',
implement client-side and server-side DTLS, respectively.

For TLS support, see 'GI.Gio.Objects.TlsConnection.TlsConnection'.

As DTLS is datagram based, 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' implements 'GI.Gio.Interfaces.DatagramBased.DatagramBased',
presenting a datagram-socket-like API for the encrypted connection. This
operates over a base datagram connection, which is also a 'GI.Gio.Interfaces.DatagramBased.DatagramBased'
('GI.Gio.Interfaces.DtlsConnection.DtlsConnection':@/base-socket/@).

To close a DTLS connection, use 'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionClose'.

Neither 'GI.Gio.Interfaces.DtlsServerConnection.DtlsServerConnection' or 'GI.Gio.Interfaces.DtlsClientConnection.DtlsClientConnection' set the peer address
on their base 'GI.Gio.Interfaces.DatagramBased.DatagramBased' if it is a 'GI.Gio.Objects.Socket.Socket' — it is up to the caller to
do that if they wish. If they do not, and 'GI.Gio.Objects.Socket.socketClose' is called on the
base socket, the 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' will not raise a 'GI.Gio.Enums.IOErrorEnumNotConnected'
error on further I\/O.
-}

module GI.Gio.Interfaces.DtlsConnection
    ( 

-- * Exported types
    DtlsConnection(..)                      ,
    noDtlsConnection                        ,
    IsDtlsConnection                        ,
    toDtlsConnection                        ,


 -- * Methods
-- ** close #method:close#
    DtlsConnectionCloseMethodInfo           ,
    dtlsConnectionClose                     ,


-- ** closeAsync #method:closeAsync#
    DtlsConnectionCloseAsyncMethodInfo      ,
    dtlsConnectionCloseAsync                ,


-- ** closeFinish #method:closeFinish#
    DtlsConnectionCloseFinishMethodInfo     ,
    dtlsConnectionCloseFinish               ,


-- ** emitAcceptCertificate #method:emitAcceptCertificate#
    DtlsConnectionEmitAcceptCertificateMethodInfo,
    dtlsConnectionEmitAcceptCertificate     ,


-- ** getCertificate #method:getCertificate#
    DtlsConnectionGetCertificateMethodInfo  ,
    dtlsConnectionGetCertificate            ,


-- ** getDatabase #method:getDatabase#
    DtlsConnectionGetDatabaseMethodInfo     ,
    dtlsConnectionGetDatabase               ,


-- ** getInteraction #method:getInteraction#
    DtlsConnectionGetInteractionMethodInfo  ,
    dtlsConnectionGetInteraction            ,


-- ** getPeerCertificate #method:getPeerCertificate#
    DtlsConnectionGetPeerCertificateMethodInfo,
    dtlsConnectionGetPeerCertificate        ,


-- ** getPeerCertificateErrors #method:getPeerCertificateErrors#
    DtlsConnectionGetPeerCertificateErrorsMethodInfo,
    dtlsConnectionGetPeerCertificateErrors  ,


-- ** getRehandshakeMode #method:getRehandshakeMode#
    DtlsConnectionGetRehandshakeModeMethodInfo,
    dtlsConnectionGetRehandshakeMode        ,


-- ** getRequireCloseNotify #method:getRequireCloseNotify#
    DtlsConnectionGetRequireCloseNotifyMethodInfo,
    dtlsConnectionGetRequireCloseNotify     ,


-- ** handshake #method:handshake#
    DtlsConnectionHandshakeMethodInfo       ,
    dtlsConnectionHandshake                 ,


-- ** handshakeAsync #method:handshakeAsync#
    DtlsConnectionHandshakeAsyncMethodInfo  ,
    dtlsConnectionHandshakeAsync            ,


-- ** handshakeFinish #method:handshakeFinish#
    DtlsConnectionHandshakeFinishMethodInfo ,
    dtlsConnectionHandshakeFinish           ,


-- ** setCertificate #method:setCertificate#
    DtlsConnectionSetCertificateMethodInfo  ,
    dtlsConnectionSetCertificate            ,


-- ** setDatabase #method:setDatabase#
    DtlsConnectionSetDatabaseMethodInfo     ,
    dtlsConnectionSetDatabase               ,


-- ** setInteraction #method:setInteraction#
    DtlsConnectionSetInteractionMethodInfo  ,
    dtlsConnectionSetInteraction            ,


-- ** setRehandshakeMode #method:setRehandshakeMode#
    DtlsConnectionSetRehandshakeModeMethodInfo,
    dtlsConnectionSetRehandshakeMode        ,


-- ** setRequireCloseNotify #method:setRequireCloseNotify#
    DtlsConnectionSetRequireCloseNotifyMethodInfo,
    dtlsConnectionSetRequireCloseNotify     ,


-- ** shutdown #method:shutdown#
    DtlsConnectionShutdownMethodInfo        ,
    dtlsConnectionShutdown                  ,


-- ** shutdownAsync #method:shutdownAsync#
    DtlsConnectionShutdownAsyncMethodInfo   ,
    dtlsConnectionShutdownAsync             ,


-- ** shutdownFinish #method:shutdownFinish#
    DtlsConnectionShutdownFinishMethodInfo  ,
    dtlsConnectionShutdownFinish            ,




 -- * Properties
-- ** baseSocket #attr:baseSocket#
    DtlsConnectionBaseSocketPropertyInfo    ,
    constructDtlsConnectionBaseSocket       ,
    dtlsConnectionBaseSocket                ,
    getDtlsConnectionBaseSocket             ,


-- ** certificate #attr:certificate#
    DtlsConnectionCertificatePropertyInfo   ,
    constructDtlsConnectionCertificate      ,
    dtlsConnectionCertificate               ,
    getDtlsConnectionCertificate            ,
    setDtlsConnectionCertificate            ,


-- ** database #attr:database#
    DtlsConnectionDatabasePropertyInfo      ,
    constructDtlsConnectionDatabase         ,
    dtlsConnectionDatabase                  ,
    getDtlsConnectionDatabase               ,
    setDtlsConnectionDatabase               ,


-- ** interaction #attr:interaction#
    DtlsConnectionInteractionPropertyInfo   ,
    clearDtlsConnectionInteraction          ,
    constructDtlsConnectionInteraction      ,
    dtlsConnectionInteraction               ,
    getDtlsConnectionInteraction            ,
    setDtlsConnectionInteraction            ,


-- ** peerCertificate #attr:peerCertificate#
    DtlsConnectionPeerCertificatePropertyInfo,
    dtlsConnectionPeerCertificate           ,
    getDtlsConnectionPeerCertificate        ,


-- ** peerCertificateErrors #attr:peerCertificateErrors#
    DtlsConnectionPeerCertificateErrorsPropertyInfo,
    dtlsConnectionPeerCertificateErrors     ,
    getDtlsConnectionPeerCertificateErrors  ,


-- ** rehandshakeMode #attr:rehandshakeMode#
    DtlsConnectionRehandshakeModePropertyInfo,
    constructDtlsConnectionRehandshakeMode  ,
    dtlsConnectionRehandshakeMode           ,
    getDtlsConnectionRehandshakeMode        ,
    setDtlsConnectionRehandshakeMode        ,


-- ** requireCloseNotify #attr:requireCloseNotify#
    DtlsConnectionRequireCloseNotifyPropertyInfo,
    constructDtlsConnectionRequireCloseNotify,
    dtlsConnectionRequireCloseNotify        ,
    getDtlsConnectionRequireCloseNotify     ,
    setDtlsConnectionRequireCloseNotify     ,




 -- * Signals
-- ** acceptCertificate #signal:acceptCertificate#
    C_DtlsConnectionAcceptCertificateCallback,
    DtlsConnectionAcceptCertificateCallback ,
    DtlsConnectionAcceptCertificateSignalInfo,
    afterDtlsConnectionAcceptCertificate    ,
    genClosure_DtlsConnectionAcceptCertificate,
    mk_DtlsConnectionAcceptCertificateCallback,
    noDtlsConnectionAcceptCertificateCallback,
    onDtlsConnectionAcceptCertificate       ,
    wrap_DtlsConnectionAcceptCertificateCallback,




    ) 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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.DatagramBased as Gio.DatagramBased
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.TlsCertificate as Gio.TlsCertificate
import {-# SOURCE #-} qualified GI.Gio.Objects.TlsDatabase as Gio.TlsDatabase
import {-# SOURCE #-} qualified GI.Gio.Objects.TlsInteraction as Gio.TlsInteraction

-- interface DtlsConnection 
newtype DtlsConnection = DtlsConnection (ManagedPtr DtlsConnection)
noDtlsConnection :: Maybe DtlsConnection
noDtlsConnection = Nothing

-- signal DtlsConnection::accept-certificate
type DtlsConnectionAcceptCertificateCallback =
    Gio.TlsCertificate.TlsCertificate ->
    [Gio.Flags.TlsCertificateFlags] ->
    IO Bool

noDtlsConnectionAcceptCertificateCallback :: Maybe DtlsConnectionAcceptCertificateCallback
noDtlsConnectionAcceptCertificateCallback = Nothing

type C_DtlsConnectionAcceptCertificateCallback =
    Ptr () ->                               -- object
    Ptr Gio.TlsCertificate.TlsCertificate ->
    CUInt ->
    Ptr () ->                               -- user_data
    IO CInt

foreign import ccall "wrapper"
    mk_DtlsConnectionAcceptCertificateCallback :: C_DtlsConnectionAcceptCertificateCallback -> IO (FunPtr C_DtlsConnectionAcceptCertificateCallback)

genClosure_DtlsConnectionAcceptCertificate :: DtlsConnectionAcceptCertificateCallback -> IO Closure
genClosure_DtlsConnectionAcceptCertificate cb = do
    let cb' = wrap_DtlsConnectionAcceptCertificateCallback cb
    mk_DtlsConnectionAcceptCertificateCallback cb' >>= newCClosure


wrap_DtlsConnectionAcceptCertificateCallback ::
    DtlsConnectionAcceptCertificateCallback ->
    Ptr () ->
    Ptr Gio.TlsCertificate.TlsCertificate ->
    CUInt ->
    Ptr () ->
    IO CInt
wrap_DtlsConnectionAcceptCertificateCallback _cb _ peerCert errors _ = do
    peerCert' <- (newObject Gio.TlsCertificate.TlsCertificate) peerCert
    let errors' = wordToGFlags errors
    result <- _cb  peerCert' errors'
    let result' = (fromIntegral . fromEnum) result
    return result'


onDtlsConnectionAcceptCertificate :: (IsDtlsConnection a, MonadIO m) => a -> DtlsConnectionAcceptCertificateCallback -> m SignalHandlerId
onDtlsConnectionAcceptCertificate obj cb = liftIO $ do
    let cb' = wrap_DtlsConnectionAcceptCertificateCallback cb
    cb'' <- mk_DtlsConnectionAcceptCertificateCallback cb'
    connectSignalFunPtr obj "accept-certificate" cb'' SignalConnectBefore

afterDtlsConnectionAcceptCertificate :: (IsDtlsConnection a, MonadIO m) => a -> DtlsConnectionAcceptCertificateCallback -> m SignalHandlerId
afterDtlsConnectionAcceptCertificate obj cb = liftIO $ do
    let cb' = wrap_DtlsConnectionAcceptCertificateCallback cb
    cb'' <- mk_DtlsConnectionAcceptCertificateCallback cb'
    connectSignalFunPtr obj "accept-certificate" cb'' SignalConnectAfter


data DtlsConnectionAcceptCertificateSignalInfo
instance SignalInfo DtlsConnectionAcceptCertificateSignalInfo where
    type HaskellCallbackType DtlsConnectionAcceptCertificateSignalInfo = DtlsConnectionAcceptCertificateCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_DtlsConnectionAcceptCertificateCallback cb
        cb'' <- mk_DtlsConnectionAcceptCertificateCallback cb'
        connectSignalFunPtr obj "accept-certificate" cb'' connectMode

type instance O.SignalList DtlsConnection = DtlsConnectionSignalList
type DtlsConnectionSignalList = ('[ '("acceptCertificate", DtlsConnectionAcceptCertificateSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

foreign import ccall "g_dtls_connection_get_type"
    c_g_dtls_connection_get_type :: IO GType

instance GObject DtlsConnection where
    gobjectType _ = c_g_dtls_connection_get_type
    

class GObject o => IsDtlsConnection o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError DtlsConnection a) =>
    IsDtlsConnection a
#endif
instance IsDtlsConnection DtlsConnection
instance Gio.DatagramBased.IsDatagramBased DtlsConnection
instance GObject.Object.IsObject DtlsConnection

toDtlsConnection :: IsDtlsConnection o => o -> IO DtlsConnection
toDtlsConnection = unsafeCastTo DtlsConnection

-- VVV Prop "base-socket"
   -- Type: TInterface (Name {namespace = "Gio", name = "DatagramBased"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getDtlsConnectionBaseSocket :: (MonadIO m, IsDtlsConnection o) => o -> m (Maybe Gio.DatagramBased.DatagramBased)
getDtlsConnectionBaseSocket obj = liftIO $ getObjectPropertyObject obj "base-socket" Gio.DatagramBased.DatagramBased

constructDtlsConnectionBaseSocket :: (IsDtlsConnection o, Gio.DatagramBased.IsDatagramBased a) => a -> IO (GValueConstruct o)
constructDtlsConnectionBaseSocket val = constructObjectPropertyObject "base-socket" (Just val)

data DtlsConnectionBaseSocketPropertyInfo
instance AttrInfo DtlsConnectionBaseSocketPropertyInfo where
    type AttrAllowedOps DtlsConnectionBaseSocketPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DtlsConnectionBaseSocketPropertyInfo = Gio.DatagramBased.IsDatagramBased
    type AttrBaseTypeConstraint DtlsConnectionBaseSocketPropertyInfo = IsDtlsConnection
    type AttrGetType DtlsConnectionBaseSocketPropertyInfo = (Maybe Gio.DatagramBased.DatagramBased)
    type AttrLabel DtlsConnectionBaseSocketPropertyInfo = "base-socket"
    type AttrOrigin DtlsConnectionBaseSocketPropertyInfo = DtlsConnection
    attrGet _ = getDtlsConnectionBaseSocket
    attrSet _ = undefined
    attrConstruct _ = constructDtlsConnectionBaseSocket
    attrClear _ = undefined

-- VVV Prop "certificate"
   -- Type: TInterface (Name {namespace = "Gio", name = "TlsCertificate"})
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just False)

getDtlsConnectionCertificate :: (MonadIO m, IsDtlsConnection o) => o -> m Gio.TlsCertificate.TlsCertificate
getDtlsConnectionCertificate obj = liftIO $ checkUnexpectedNothing "getDtlsConnectionCertificate" $ getObjectPropertyObject obj "certificate" Gio.TlsCertificate.TlsCertificate

setDtlsConnectionCertificate :: (MonadIO m, IsDtlsConnection o, Gio.TlsCertificate.IsTlsCertificate a) => o -> a -> m ()
setDtlsConnectionCertificate obj val = liftIO $ setObjectPropertyObject obj "certificate" (Just val)

constructDtlsConnectionCertificate :: (IsDtlsConnection o, Gio.TlsCertificate.IsTlsCertificate a) => a -> IO (GValueConstruct o)
constructDtlsConnectionCertificate val = constructObjectPropertyObject "certificate" (Just val)

data DtlsConnectionCertificatePropertyInfo
instance AttrInfo DtlsConnectionCertificatePropertyInfo where
    type AttrAllowedOps DtlsConnectionCertificatePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DtlsConnectionCertificatePropertyInfo = Gio.TlsCertificate.IsTlsCertificate
    type AttrBaseTypeConstraint DtlsConnectionCertificatePropertyInfo = IsDtlsConnection
    type AttrGetType DtlsConnectionCertificatePropertyInfo = Gio.TlsCertificate.TlsCertificate
    type AttrLabel DtlsConnectionCertificatePropertyInfo = "certificate"
    type AttrOrigin DtlsConnectionCertificatePropertyInfo = DtlsConnection
    attrGet _ = getDtlsConnectionCertificate
    attrSet _ = setDtlsConnectionCertificate
    attrConstruct _ = constructDtlsConnectionCertificate
    attrClear _ = undefined

-- VVV Prop "database"
   -- Type: TInterface (Name {namespace = "Gio", name = "TlsDatabase"})
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just False)

getDtlsConnectionDatabase :: (MonadIO m, IsDtlsConnection o) => o -> m Gio.TlsDatabase.TlsDatabase
getDtlsConnectionDatabase obj = liftIO $ checkUnexpectedNothing "getDtlsConnectionDatabase" $ getObjectPropertyObject obj "database" Gio.TlsDatabase.TlsDatabase

setDtlsConnectionDatabase :: (MonadIO m, IsDtlsConnection o, Gio.TlsDatabase.IsTlsDatabase a) => o -> a -> m ()
setDtlsConnectionDatabase obj val = liftIO $ setObjectPropertyObject obj "database" (Just val)

constructDtlsConnectionDatabase :: (IsDtlsConnection o, Gio.TlsDatabase.IsTlsDatabase a) => a -> IO (GValueConstruct o)
constructDtlsConnectionDatabase val = constructObjectPropertyObject "database" (Just val)

data DtlsConnectionDatabasePropertyInfo
instance AttrInfo DtlsConnectionDatabasePropertyInfo where
    type AttrAllowedOps DtlsConnectionDatabasePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DtlsConnectionDatabasePropertyInfo = Gio.TlsDatabase.IsTlsDatabase
    type AttrBaseTypeConstraint DtlsConnectionDatabasePropertyInfo = IsDtlsConnection
    type AttrGetType DtlsConnectionDatabasePropertyInfo = Gio.TlsDatabase.TlsDatabase
    type AttrLabel DtlsConnectionDatabasePropertyInfo = "database"
    type AttrOrigin DtlsConnectionDatabasePropertyInfo = DtlsConnection
    attrGet _ = getDtlsConnectionDatabase
    attrSet _ = setDtlsConnectionDatabase
    attrConstruct _ = constructDtlsConnectionDatabase
    attrClear _ = undefined

-- VVV Prop "interaction"
   -- Type: TInterface (Name {namespace = "Gio", name = "TlsInteraction"})
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just True)

getDtlsConnectionInteraction :: (MonadIO m, IsDtlsConnection o) => o -> m Gio.TlsInteraction.TlsInteraction
getDtlsConnectionInteraction obj = liftIO $ checkUnexpectedNothing "getDtlsConnectionInteraction" $ getObjectPropertyObject obj "interaction" Gio.TlsInteraction.TlsInteraction

setDtlsConnectionInteraction :: (MonadIO m, IsDtlsConnection o, Gio.TlsInteraction.IsTlsInteraction a) => o -> a -> m ()
setDtlsConnectionInteraction obj val = liftIO $ setObjectPropertyObject obj "interaction" (Just val)

constructDtlsConnectionInteraction :: (IsDtlsConnection o, Gio.TlsInteraction.IsTlsInteraction a) => a -> IO (GValueConstruct o)
constructDtlsConnectionInteraction val = constructObjectPropertyObject "interaction" (Just val)

clearDtlsConnectionInteraction :: (MonadIO m, IsDtlsConnection o) => o -> m ()
clearDtlsConnectionInteraction obj = liftIO $ setObjectPropertyObject obj "interaction" (Nothing :: Maybe Gio.TlsInteraction.TlsInteraction)

data DtlsConnectionInteractionPropertyInfo
instance AttrInfo DtlsConnectionInteractionPropertyInfo where
    type AttrAllowedOps DtlsConnectionInteractionPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DtlsConnectionInteractionPropertyInfo = Gio.TlsInteraction.IsTlsInteraction
    type AttrBaseTypeConstraint DtlsConnectionInteractionPropertyInfo = IsDtlsConnection
    type AttrGetType DtlsConnectionInteractionPropertyInfo = Gio.TlsInteraction.TlsInteraction
    type AttrLabel DtlsConnectionInteractionPropertyInfo = "interaction"
    type AttrOrigin DtlsConnectionInteractionPropertyInfo = DtlsConnection
    attrGet _ = getDtlsConnectionInteraction
    attrSet _ = setDtlsConnectionInteraction
    attrConstruct _ = constructDtlsConnectionInteraction
    attrClear _ = clearDtlsConnectionInteraction

-- VVV Prop "peer-certificate"
   -- Type: TInterface (Name {namespace = "Gio", name = "TlsCertificate"})
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getDtlsConnectionPeerCertificate :: (MonadIO m, IsDtlsConnection o) => o -> m Gio.TlsCertificate.TlsCertificate
getDtlsConnectionPeerCertificate obj = liftIO $ checkUnexpectedNothing "getDtlsConnectionPeerCertificate" $ getObjectPropertyObject obj "peer-certificate" Gio.TlsCertificate.TlsCertificate

data DtlsConnectionPeerCertificatePropertyInfo
instance AttrInfo DtlsConnectionPeerCertificatePropertyInfo where
    type AttrAllowedOps DtlsConnectionPeerCertificatePropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DtlsConnectionPeerCertificatePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DtlsConnectionPeerCertificatePropertyInfo = IsDtlsConnection
    type AttrGetType DtlsConnectionPeerCertificatePropertyInfo = Gio.TlsCertificate.TlsCertificate
    type AttrLabel DtlsConnectionPeerCertificatePropertyInfo = "peer-certificate"
    type AttrOrigin DtlsConnectionPeerCertificatePropertyInfo = DtlsConnection
    attrGet _ = getDtlsConnectionPeerCertificate
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

-- VVV Prop "peer-certificate-errors"
   -- Type: TInterface (Name {namespace = "Gio", name = "TlsCertificateFlags"})
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getDtlsConnectionPeerCertificateErrors :: (MonadIO m, IsDtlsConnection o) => o -> m [Gio.Flags.TlsCertificateFlags]
getDtlsConnectionPeerCertificateErrors obj = liftIO $ getObjectPropertyFlags obj "peer-certificate-errors"

data DtlsConnectionPeerCertificateErrorsPropertyInfo
instance AttrInfo DtlsConnectionPeerCertificateErrorsPropertyInfo where
    type AttrAllowedOps DtlsConnectionPeerCertificateErrorsPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DtlsConnectionPeerCertificateErrorsPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DtlsConnectionPeerCertificateErrorsPropertyInfo = IsDtlsConnection
    type AttrGetType DtlsConnectionPeerCertificateErrorsPropertyInfo = [Gio.Flags.TlsCertificateFlags]
    type AttrLabel DtlsConnectionPeerCertificateErrorsPropertyInfo = "peer-certificate-errors"
    type AttrOrigin DtlsConnectionPeerCertificateErrorsPropertyInfo = DtlsConnection
    attrGet _ = getDtlsConnectionPeerCertificateErrors
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

-- VVV Prop "rehandshake-mode"
   -- Type: TInterface (Name {namespace = "Gio", name = "TlsRehandshakeMode"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Just False,Just False)

getDtlsConnectionRehandshakeMode :: (MonadIO m, IsDtlsConnection o) => o -> m Gio.Enums.TlsRehandshakeMode
getDtlsConnectionRehandshakeMode obj = liftIO $ getObjectPropertyEnum obj "rehandshake-mode"

setDtlsConnectionRehandshakeMode :: (MonadIO m, IsDtlsConnection o) => o -> Gio.Enums.TlsRehandshakeMode -> m ()
setDtlsConnectionRehandshakeMode obj val = liftIO $ setObjectPropertyEnum obj "rehandshake-mode" val

constructDtlsConnectionRehandshakeMode :: (IsDtlsConnection o) => Gio.Enums.TlsRehandshakeMode -> IO (GValueConstruct o)
constructDtlsConnectionRehandshakeMode val = constructObjectPropertyEnum "rehandshake-mode" val

data DtlsConnectionRehandshakeModePropertyInfo
instance AttrInfo DtlsConnectionRehandshakeModePropertyInfo where
    type AttrAllowedOps DtlsConnectionRehandshakeModePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DtlsConnectionRehandshakeModePropertyInfo = (~) Gio.Enums.TlsRehandshakeMode
    type AttrBaseTypeConstraint DtlsConnectionRehandshakeModePropertyInfo = IsDtlsConnection
    type AttrGetType DtlsConnectionRehandshakeModePropertyInfo = Gio.Enums.TlsRehandshakeMode
    type AttrLabel DtlsConnectionRehandshakeModePropertyInfo = "rehandshake-mode"
    type AttrOrigin DtlsConnectionRehandshakeModePropertyInfo = DtlsConnection
    attrGet _ = getDtlsConnectionRehandshakeMode
    attrSet _ = setDtlsConnectionRehandshakeMode
    attrConstruct _ = constructDtlsConnectionRehandshakeMode
    attrClear _ = undefined

-- VVV Prop "require-close-notify"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Just False,Just False)

getDtlsConnectionRequireCloseNotify :: (MonadIO m, IsDtlsConnection o) => o -> m Bool
getDtlsConnectionRequireCloseNotify obj = liftIO $ getObjectPropertyBool obj "require-close-notify"

setDtlsConnectionRequireCloseNotify :: (MonadIO m, IsDtlsConnection o) => o -> Bool -> m ()
setDtlsConnectionRequireCloseNotify obj val = liftIO $ setObjectPropertyBool obj "require-close-notify" val

constructDtlsConnectionRequireCloseNotify :: (IsDtlsConnection o) => Bool -> IO (GValueConstruct o)
constructDtlsConnectionRequireCloseNotify val = constructObjectPropertyBool "require-close-notify" val

data DtlsConnectionRequireCloseNotifyPropertyInfo
instance AttrInfo DtlsConnectionRequireCloseNotifyPropertyInfo where
    type AttrAllowedOps DtlsConnectionRequireCloseNotifyPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DtlsConnectionRequireCloseNotifyPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint DtlsConnectionRequireCloseNotifyPropertyInfo = IsDtlsConnection
    type AttrGetType DtlsConnectionRequireCloseNotifyPropertyInfo = Bool
    type AttrLabel DtlsConnectionRequireCloseNotifyPropertyInfo = "require-close-notify"
    type AttrOrigin DtlsConnectionRequireCloseNotifyPropertyInfo = DtlsConnection
    attrGet _ = getDtlsConnectionRequireCloseNotify
    attrSet _ = setDtlsConnectionRequireCloseNotify
    attrConstruct _ = constructDtlsConnectionRequireCloseNotify
    attrClear _ = undefined

instance O.HasAttributeList DtlsConnection
type instance O.AttributeList DtlsConnection = DtlsConnectionAttributeList
type DtlsConnectionAttributeList = ('[ '("baseSocket", DtlsConnectionBaseSocketPropertyInfo), '("certificate", DtlsConnectionCertificatePropertyInfo), '("database", DtlsConnectionDatabasePropertyInfo), '("interaction", DtlsConnectionInteractionPropertyInfo), '("peerCertificate", DtlsConnectionPeerCertificatePropertyInfo), '("peerCertificateErrors", DtlsConnectionPeerCertificateErrorsPropertyInfo), '("rehandshakeMode", DtlsConnectionRehandshakeModePropertyInfo), '("requireCloseNotify", DtlsConnectionRequireCloseNotifyPropertyInfo)] :: [(Symbol, *)])

dtlsConnectionBaseSocket :: AttrLabelProxy "baseSocket"
dtlsConnectionBaseSocket = AttrLabelProxy

dtlsConnectionCertificate :: AttrLabelProxy "certificate"
dtlsConnectionCertificate = AttrLabelProxy

dtlsConnectionDatabase :: AttrLabelProxy "database"
dtlsConnectionDatabase = AttrLabelProxy

dtlsConnectionInteraction :: AttrLabelProxy "interaction"
dtlsConnectionInteraction = AttrLabelProxy

dtlsConnectionPeerCertificate :: AttrLabelProxy "peerCertificate"
dtlsConnectionPeerCertificate = AttrLabelProxy

dtlsConnectionPeerCertificateErrors :: AttrLabelProxy "peerCertificateErrors"
dtlsConnectionPeerCertificateErrors = AttrLabelProxy

dtlsConnectionRehandshakeMode :: AttrLabelProxy "rehandshakeMode"
dtlsConnectionRehandshakeMode = AttrLabelProxy

dtlsConnectionRequireCloseNotify :: AttrLabelProxy "requireCloseNotify"
dtlsConnectionRequireCloseNotify = AttrLabelProxy

type family ResolveDtlsConnectionMethod (t :: Symbol) (o :: *) :: * where
    ResolveDtlsConnectionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDtlsConnectionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDtlsConnectionMethod "close" o = DtlsConnectionCloseMethodInfo
    ResolveDtlsConnectionMethod "closeAsync" o = DtlsConnectionCloseAsyncMethodInfo
    ResolveDtlsConnectionMethod "closeFinish" o = DtlsConnectionCloseFinishMethodInfo
    ResolveDtlsConnectionMethod "conditionCheck" o = Gio.DatagramBased.DatagramBasedConditionCheckMethodInfo
    ResolveDtlsConnectionMethod "conditionWait" o = Gio.DatagramBased.DatagramBasedConditionWaitMethodInfo
    ResolveDtlsConnectionMethod "createSource" o = Gio.DatagramBased.DatagramBasedCreateSourceMethodInfo
    ResolveDtlsConnectionMethod "emitAcceptCertificate" o = DtlsConnectionEmitAcceptCertificateMethodInfo
    ResolveDtlsConnectionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDtlsConnectionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDtlsConnectionMethod "handshake" o = DtlsConnectionHandshakeMethodInfo
    ResolveDtlsConnectionMethod "handshakeAsync" o = DtlsConnectionHandshakeAsyncMethodInfo
    ResolveDtlsConnectionMethod "handshakeFinish" o = DtlsConnectionHandshakeFinishMethodInfo
    ResolveDtlsConnectionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDtlsConnectionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDtlsConnectionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDtlsConnectionMethod "receiveMessages" o = Gio.DatagramBased.DatagramBasedReceiveMessagesMethodInfo
    ResolveDtlsConnectionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDtlsConnectionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDtlsConnectionMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveDtlsConnectionMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveDtlsConnectionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDtlsConnectionMethod "sendMessages" o = Gio.DatagramBased.DatagramBasedSendMessagesMethodInfo
    ResolveDtlsConnectionMethod "shutdown" o = DtlsConnectionShutdownMethodInfo
    ResolveDtlsConnectionMethod "shutdownAsync" o = DtlsConnectionShutdownAsyncMethodInfo
    ResolveDtlsConnectionMethod "shutdownFinish" o = DtlsConnectionShutdownFinishMethodInfo
    ResolveDtlsConnectionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDtlsConnectionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDtlsConnectionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDtlsConnectionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDtlsConnectionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDtlsConnectionMethod "getCertificate" o = DtlsConnectionGetCertificateMethodInfo
    ResolveDtlsConnectionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDtlsConnectionMethod "getDatabase" o = DtlsConnectionGetDatabaseMethodInfo
    ResolveDtlsConnectionMethod "getInteraction" o = DtlsConnectionGetInteractionMethodInfo
    ResolveDtlsConnectionMethod "getPeerCertificate" o = DtlsConnectionGetPeerCertificateMethodInfo
    ResolveDtlsConnectionMethod "getPeerCertificateErrors" o = DtlsConnectionGetPeerCertificateErrorsMethodInfo
    ResolveDtlsConnectionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDtlsConnectionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDtlsConnectionMethod "getRehandshakeMode" o = DtlsConnectionGetRehandshakeModeMethodInfo
    ResolveDtlsConnectionMethod "getRequireCloseNotify" o = DtlsConnectionGetRequireCloseNotifyMethodInfo
    ResolveDtlsConnectionMethod "setCertificate" o = DtlsConnectionSetCertificateMethodInfo
    ResolveDtlsConnectionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDtlsConnectionMethod "setDatabase" o = DtlsConnectionSetDatabaseMethodInfo
    ResolveDtlsConnectionMethod "setInteraction" o = DtlsConnectionSetInteractionMethodInfo
    ResolveDtlsConnectionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDtlsConnectionMethod "setRehandshakeMode" o = DtlsConnectionSetRehandshakeModeMethodInfo
    ResolveDtlsConnectionMethod "setRequireCloseNotify" o = DtlsConnectionSetRequireCloseNotifyMethodInfo
    ResolveDtlsConnectionMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDtlsConnectionMethod t DtlsConnection, O.MethodInfo info DtlsConnection p) => O.IsLabelProxy t (DtlsConnection -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDtlsConnectionMethod t DtlsConnection, O.MethodInfo info DtlsConnection p) => O.IsLabel t (DtlsConnection -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- method DtlsConnection::close
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_dtls_connection_close" g_dtls_connection_close :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Close the DTLS connection. This is equivalent to calling
'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionShutdown' to shut down both sides of the connection.

Closing a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' waits for all buffered but untransmitted data to
be sent before it completes. It then sends a @close_notify@ DTLS alert to the
peer and may wait for a @close_notify@ to be received from the peer. It does
not close the underlying 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection':@/base-socket/@; that must be closed
separately.

Once /@conn@/ is closed, all other operations will return 'GI.Gio.Enums.IOErrorEnumClosed'.
Closing a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' multiple times will not return an error.

@/GDtlsConnections/@ will be automatically closed when the last reference is
dropped, but you might want to call this function to make sure resources are
released as early as possible.

If /@cancellable@/ is cancelled, the 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' may be left
partially-closed and any pending untransmitted data may be lost. Call
'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionClose' again to complete closing the 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection'.

@since 2.48
-}
dtlsConnectionClose ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dtlsConnectionClose conn cancellable = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_dtls_connection_close conn' maybeCancellable
        touchManagedPtr conn
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data DtlsConnectionCloseMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DtlsConnectionCloseMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionClose

-- method DtlsConnection::close_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "callback to call when the close operation is complete", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to the callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dtls_connection_close_async" g_dtls_connection_close_async :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously close the DTLS connection. See 'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionClose' for
more information.

@since 2.48
-}
dtlsConnectionCloseAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: callback to call when the close operation is complete -}
    -> m ()
dtlsConnectionCloseAsync conn ioPriority cancellable callback = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_dtls_connection_close_async conn' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr conn
    whenJust cancellable touchManagedPtr
    return ()

data DtlsConnectionCloseAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DtlsConnectionCloseAsyncMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionCloseAsync

-- method DtlsConnection::close_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_dtls_connection_close_finish" g_dtls_connection_close_finish :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finish an asynchronous TLS close operation. See 'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionClose'
for more information.

@since 2.48
-}
dtlsConnectionCloseFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dtlsConnectionCloseFinish conn result_ = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_dtls_connection_close_finish conn' result_'
        touchManagedPtr conn
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data DtlsConnectionCloseFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDtlsConnection a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DtlsConnectionCloseFinishMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionCloseFinish

-- method DtlsConnection::emit_accept_certificate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "peer_cert", argType = TInterface (Name {namespace = "Gio", name = "TlsCertificate"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the peer's #GTlsCertificate", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "errors", argType = TInterface (Name {namespace = "Gio", name = "TlsCertificateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the problems with @peer_cert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_dtls_connection_emit_accept_certificate" g_dtls_connection_emit_accept_certificate :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    Ptr Gio.TlsCertificate.TlsCertificate -> -- peer_cert : TInterface (Name {namespace = "Gio", name = "TlsCertificate"})
    CUInt ->                                -- errors : TInterface (Name {namespace = "Gio", name = "TlsCertificateFlags"})
    IO CInt

{- |
Used by 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' implementations to emit the
'GI.Gio.Interfaces.DtlsConnection.DtlsConnection'::@/accept-certificate/@ signal.

@since 2.48
-}
dtlsConnectionEmitAcceptCertificate ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.TlsCertificate.IsTlsCertificate b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> b
    {- ^ /@peerCert@/: the peer\'s 'GI.Gio.Objects.TlsCertificate.TlsCertificate' -}
    -> [Gio.Flags.TlsCertificateFlags]
    {- ^ /@errors@/: the problems with /@peerCert@/ -}
    -> m Bool
    {- ^ __Returns:__ 'True' if one of the signal handlers has returned
    'True' to accept /@peerCert@/ -}
dtlsConnectionEmitAcceptCertificate conn peerCert errors = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    peerCert' <- unsafeManagedPtrCastPtr peerCert
    let errors' = gflagsToWord errors
    result <- g_dtls_connection_emit_accept_certificate conn' peerCert' errors'
    let result' = (/= 0) result
    touchManagedPtr conn
    touchManagedPtr peerCert
    return result'

data DtlsConnectionEmitAcceptCertificateMethodInfo
instance (signature ~ (b -> [Gio.Flags.TlsCertificateFlags] -> m Bool), MonadIO m, IsDtlsConnection a, Gio.TlsCertificate.IsTlsCertificate b) => O.MethodInfo DtlsConnectionEmitAcceptCertificateMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionEmitAcceptCertificate

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

foreign import ccall "g_dtls_connection_get_certificate" g_dtls_connection_get_certificate :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    IO (Ptr Gio.TlsCertificate.TlsCertificate)

{- |
Gets /@conn@/\'s certificate, as set by
'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionSetCertificate'.

@since 2.48
-}
dtlsConnectionGetCertificate ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> m Gio.TlsCertificate.TlsCertificate
    {- ^ __Returns:__ /@conn@/\'s certificate, or 'Nothing' -}
dtlsConnectionGetCertificate conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_dtls_connection_get_certificate conn'
    checkUnexpectedReturnNULL "dtlsConnectionGetCertificate" result
    result' <- (newObject Gio.TlsCertificate.TlsCertificate) result
    touchManagedPtr conn
    return result'

data DtlsConnectionGetCertificateMethodInfo
instance (signature ~ (m Gio.TlsCertificate.TlsCertificate), MonadIO m, IsDtlsConnection a) => O.MethodInfo DtlsConnectionGetCertificateMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionGetCertificate

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

foreign import ccall "g_dtls_connection_get_database" g_dtls_connection_get_database :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    IO (Ptr Gio.TlsDatabase.TlsDatabase)

{- |
Gets the certificate database that /@conn@/ uses to verify
peer certificates. See 'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionSetDatabase'.

@since 2.48
-}
dtlsConnectionGetDatabase ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> m Gio.TlsDatabase.TlsDatabase
    {- ^ __Returns:__ the certificate database that /@conn@/ uses or 'Nothing' -}
dtlsConnectionGetDatabase conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_dtls_connection_get_database conn'
    checkUnexpectedReturnNULL "dtlsConnectionGetDatabase" result
    result' <- (newObject Gio.TlsDatabase.TlsDatabase) result
    touchManagedPtr conn
    return result'

data DtlsConnectionGetDatabaseMethodInfo
instance (signature ~ (m Gio.TlsDatabase.TlsDatabase), MonadIO m, IsDtlsConnection a) => O.MethodInfo DtlsConnectionGetDatabaseMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionGetDatabase

-- method DtlsConnection::get_interaction
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a connection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "TlsInteraction"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_dtls_connection_get_interaction" g_dtls_connection_get_interaction :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    IO (Ptr Gio.TlsInteraction.TlsInteraction)

{- |
Get the object that will be used to interact with the user. It will be used
for things like prompting the user for passwords. If 'Nothing' is returned, then
no user interaction will occur for this connection.

@since 2.48
-}
dtlsConnectionGetInteraction ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a) =>
    a
    {- ^ /@conn@/: a connection -}
    -> m Gio.TlsInteraction.TlsInteraction
    {- ^ __Returns:__ The interaction object. -}
dtlsConnectionGetInteraction conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_dtls_connection_get_interaction conn'
    checkUnexpectedReturnNULL "dtlsConnectionGetInteraction" result
    result' <- (newObject Gio.TlsInteraction.TlsInteraction) result
    touchManagedPtr conn
    return result'

data DtlsConnectionGetInteractionMethodInfo
instance (signature ~ (m Gio.TlsInteraction.TlsInteraction), MonadIO m, IsDtlsConnection a) => O.MethodInfo DtlsConnectionGetInteractionMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionGetInteraction

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

foreign import ccall "g_dtls_connection_get_peer_certificate" g_dtls_connection_get_peer_certificate :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    IO (Ptr Gio.TlsCertificate.TlsCertificate)

{- |
Gets /@conn@/\'s peer\'s certificate after the handshake has completed.
(It is not set during the emission of
'GI.Gio.Interfaces.DtlsConnection.DtlsConnection'::@/accept-certificate/@.)

@since 2.48
-}
dtlsConnectionGetPeerCertificate ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> m Gio.TlsCertificate.TlsCertificate
    {- ^ __Returns:__ /@conn@/\'s peer\'s certificate, or 'Nothing' -}
dtlsConnectionGetPeerCertificate conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_dtls_connection_get_peer_certificate conn'
    checkUnexpectedReturnNULL "dtlsConnectionGetPeerCertificate" result
    result' <- (newObject Gio.TlsCertificate.TlsCertificate) result
    touchManagedPtr conn
    return result'

data DtlsConnectionGetPeerCertificateMethodInfo
instance (signature ~ (m Gio.TlsCertificate.TlsCertificate), MonadIO m, IsDtlsConnection a) => O.MethodInfo DtlsConnectionGetPeerCertificateMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionGetPeerCertificate

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

foreign import ccall "g_dtls_connection_get_peer_certificate_errors" g_dtls_connection_get_peer_certificate_errors :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    IO CUInt

{- |
Gets the errors associated with validating /@conn@/\'s peer\'s
certificate, after the handshake has completed. (It is not set
during the emission of 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection'::@/accept-certificate/@.)

@since 2.48
-}
dtlsConnectionGetPeerCertificateErrors ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> m [Gio.Flags.TlsCertificateFlags]
    {- ^ __Returns:__ /@conn@/\'s peer\'s certificate errors -}
dtlsConnectionGetPeerCertificateErrors conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_dtls_connection_get_peer_certificate_errors conn'
    let result' = wordToGFlags result
    touchManagedPtr conn
    return result'

data DtlsConnectionGetPeerCertificateErrorsMethodInfo
instance (signature ~ (m [Gio.Flags.TlsCertificateFlags]), MonadIO m, IsDtlsConnection a) => O.MethodInfo DtlsConnectionGetPeerCertificateErrorsMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionGetPeerCertificateErrors

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

foreign import ccall "g_dtls_connection_get_rehandshake_mode" g_dtls_connection_get_rehandshake_mode :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    IO CUInt

{- |
Gets /@conn@/ rehandshaking mode. See
'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionSetRehandshakeMode' for details.

@since 2.48
-}
dtlsConnectionGetRehandshakeMode ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> m Gio.Enums.TlsRehandshakeMode
    {- ^ __Returns:__ /@conn@/\'s rehandshaking mode -}
dtlsConnectionGetRehandshakeMode conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_dtls_connection_get_rehandshake_mode conn'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr conn
    return result'

data DtlsConnectionGetRehandshakeModeMethodInfo
instance (signature ~ (m Gio.Enums.TlsRehandshakeMode), MonadIO m, IsDtlsConnection a) => O.MethodInfo DtlsConnectionGetRehandshakeModeMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionGetRehandshakeMode

-- method DtlsConnection::get_require_close_notify
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_dtls_connection_get_require_close_notify" g_dtls_connection_get_require_close_notify :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    IO CInt

{- |
Tests whether or not /@conn@/ expects a proper TLS close notification
when the connection is closed. See
'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionSetRequireCloseNotify' for details.

@since 2.48
-}
dtlsConnectionGetRequireCloseNotify ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@conn@/ requires a proper TLS close notification. -}
dtlsConnectionGetRequireCloseNotify conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_dtls_connection_get_require_close_notify conn'
    let result' = (/= 0) result
    touchManagedPtr conn
    return result'

data DtlsConnectionGetRequireCloseNotifyMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsDtlsConnection a) => O.MethodInfo DtlsConnectionGetRequireCloseNotifyMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionGetRequireCloseNotify

-- method DtlsConnection::handshake
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_dtls_connection_handshake" g_dtls_connection_handshake :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Attempts a TLS handshake on /@conn@/.

On the client side, it is never necessary to call this method;
although the connection needs to perform a handshake after
connecting (or after sending a \"STARTTLS\"-type command) and may
need to rehandshake later if the server requests it,
'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' will handle this for you automatically when you try
to send or receive data on the connection. However, you can call
'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionHandshake' manually if you want to know for sure
whether the initial handshake succeeded or failed (as opposed to
just immediately trying to write to /@conn@/, in which
case if it fails, it may not be possible to tell if it failed
before or after completing the handshake).

Likewise, on the server side, although a handshake is necessary at
the beginning of the communication, you do not need to call this
function explicitly unless you want clearer error reporting.
However, you may call 'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionHandshake' later on to
renegotiate parameters (encryption methods, etc) with the client.

'GI.Gio.Interfaces.DtlsConnection.DtlsConnection'::@/accept_certificate/@ may be emitted during the
handshake.

@since 2.48
-}
dtlsConnectionHandshake ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dtlsConnectionHandshake conn cancellable = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_dtls_connection_handshake conn' maybeCancellable
        touchManagedPtr conn
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data DtlsConnectionHandshakeMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DtlsConnectionHandshakeMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionHandshake

-- method DtlsConnection::handshake_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "callback to call when the handshake is complete", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to the callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dtls_connection_handshake_async" g_dtls_connection_handshake_async :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously performs a TLS handshake on /@conn@/. See
'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionHandshake' for more information.

@since 2.48
-}
dtlsConnectionHandshakeAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: callback to call when the handshake is complete -}
    -> m ()
dtlsConnectionHandshakeAsync conn ioPriority cancellable callback = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_dtls_connection_handshake_async conn' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr conn
    whenJust cancellable touchManagedPtr
    return ()

data DtlsConnectionHandshakeAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DtlsConnectionHandshakeAsyncMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionHandshakeAsync

-- method DtlsConnection::handshake_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_dtls_connection_handshake_finish" g_dtls_connection_handshake_finish :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finish an asynchronous TLS handshake operation. See
'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionHandshake' for more information.

@since 2.48
-}
dtlsConnectionHandshakeFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dtlsConnectionHandshakeFinish conn result_ = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_dtls_connection_handshake_finish conn' result_'
        touchManagedPtr conn
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data DtlsConnectionHandshakeFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDtlsConnection a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DtlsConnectionHandshakeFinishMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionHandshakeFinish

-- method DtlsConnection::set_certificate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "certificate", argType = TInterface (Name {namespace = "Gio", name = "TlsCertificate"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the certificate to use for @conn", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dtls_connection_set_certificate" g_dtls_connection_set_certificate :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    Ptr Gio.TlsCertificate.TlsCertificate -> -- certificate : TInterface (Name {namespace = "Gio", name = "TlsCertificate"})
    IO ()

{- |
This sets the certificate that /@conn@/ will present to its peer
during the TLS handshake. For a 'GI.Gio.Interfaces.DtlsServerConnection.DtlsServerConnection', it is
mandatory to set this, and that will normally be done at construct
time.

For a 'GI.Gio.Interfaces.DtlsClientConnection.DtlsClientConnection', this is optional. If a handshake fails
with 'GI.Gio.Enums.TlsErrorCertificateRequired', that means that the server
requires a certificate, and if you try connecting again, you should
call this method first. You can call
'GI.Gio.Interfaces.DtlsClientConnection.dtlsClientConnectionGetAcceptedCas' on the failed connection
to get a list of Certificate Authorities that the server will
accept certificates from.

(It is also possible that a server will allow the connection with
or without a certificate; in that case, if you don\'t provide a
certificate, you can tell that the server requested one by the fact
that 'GI.Gio.Interfaces.DtlsClientConnection.dtlsClientConnectionGetAcceptedCas' will return
non-'Nothing'.)

@since 2.48
-}
dtlsConnectionSetCertificate ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.TlsCertificate.IsTlsCertificate b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> b
    {- ^ /@certificate@/: the certificate to use for /@conn@/ -}
    -> m ()
dtlsConnectionSetCertificate conn certificate = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    certificate' <- unsafeManagedPtrCastPtr certificate
    g_dtls_connection_set_certificate conn' certificate'
    touchManagedPtr conn
    touchManagedPtr certificate
    return ()

data DtlsConnectionSetCertificateMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDtlsConnection a, Gio.TlsCertificate.IsTlsCertificate b) => O.MethodInfo DtlsConnectionSetCertificateMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionSetCertificate

-- method DtlsConnection::set_database
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "database", argType = TInterface (Name {namespace = "Gio", name = "TlsDatabase"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsDatabase", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dtls_connection_set_database" g_dtls_connection_set_database :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    Ptr Gio.TlsDatabase.TlsDatabase ->      -- database : TInterface (Name {namespace = "Gio", name = "TlsDatabase"})
    IO ()

{- |
Sets the certificate database that is used to verify peer certificates.
This is set to the default database by default. See
@/g_dtls_backend_get_default_database()/@. If set to 'Nothing', then
peer certificate validation will always set the
'GI.Gio.Flags.TlsCertificateFlagsUnknownCa' error (meaning
'GI.Gio.Interfaces.DtlsConnection.DtlsConnection'::@/accept-certificate/@ will always be emitted on
client-side connections, unless that bit is not set in
'GI.Gio.Interfaces.DtlsClientConnection.DtlsClientConnection':@/validation-flags/@).

@since 2.48
-}
dtlsConnectionSetDatabase ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.TlsDatabase.IsTlsDatabase b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> b
    {- ^ /@database@/: a 'GI.Gio.Objects.TlsDatabase.TlsDatabase' -}
    -> m ()
dtlsConnectionSetDatabase conn database = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    database' <- unsafeManagedPtrCastPtr database
    g_dtls_connection_set_database conn' database'
    touchManagedPtr conn
    touchManagedPtr database
    return ()

data DtlsConnectionSetDatabaseMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDtlsConnection a, Gio.TlsDatabase.IsTlsDatabase b) => O.MethodInfo DtlsConnectionSetDatabaseMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionSetDatabase

-- method DtlsConnection::set_interaction
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a connection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interaction", argType = TInterface (Name {namespace = "Gio", name = "TlsInteraction"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "an interaction object, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dtls_connection_set_interaction" g_dtls_connection_set_interaction :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    Ptr Gio.TlsInteraction.TlsInteraction -> -- interaction : TInterface (Name {namespace = "Gio", name = "TlsInteraction"})
    IO ()

{- |
Set the object that will be used to interact with the user. It will be used
for things like prompting the user for passwords.

The /@interaction@/ argument will normally be a derived subclass of
'GI.Gio.Objects.TlsInteraction.TlsInteraction'. 'Nothing' can also be provided if no user interaction
should occur for this connection.

@since 2.48
-}
dtlsConnectionSetInteraction ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.TlsInteraction.IsTlsInteraction b) =>
    a
    {- ^ /@conn@/: a connection -}
    -> Maybe (b)
    {- ^ /@interaction@/: an interaction object, or 'Nothing' -}
    -> m ()
dtlsConnectionSetInteraction conn interaction = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    maybeInteraction <- case interaction of
        Nothing -> return nullPtr
        Just jInteraction -> do
            jInteraction' <- unsafeManagedPtrCastPtr jInteraction
            return jInteraction'
    g_dtls_connection_set_interaction conn' maybeInteraction
    touchManagedPtr conn
    whenJust interaction touchManagedPtr
    return ()

data DtlsConnectionSetInteractionMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsDtlsConnection a, Gio.TlsInteraction.IsTlsInteraction b) => O.MethodInfo DtlsConnectionSetInteractionMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionSetInteraction

-- method DtlsConnection::set_rehandshake_mode
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "mode", argType = TInterface (Name {namespace = "Gio", name = "TlsRehandshakeMode"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the rehandshaking mode", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dtls_connection_set_rehandshake_mode" g_dtls_connection_set_rehandshake_mode :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    CUInt ->                                -- mode : TInterface (Name {namespace = "Gio", name = "TlsRehandshakeMode"})
    IO ()

{- |
Sets how /@conn@/ behaves with respect to rehandshaking requests.

'GI.Gio.Enums.TlsRehandshakeModeNever' means that it will never agree to
rehandshake after the initial handshake is complete. (For a client,
this means it will refuse rehandshake requests from the server, and
for a server, this means it will close the connection with an error
if the client attempts to rehandshake.)

'GI.Gio.Enums.TlsRehandshakeModeSafely' means that the connection will allow a
rehandshake only if the other end of the connection supports the
TLS @renegotiation_info@ extension. This is the default behavior,
but means that rehandshaking will not work against older
implementations that do not support that extension.

'GI.Gio.Enums.TlsRehandshakeModeUnsafely' means that the connection will allow
rehandshaking even without the @renegotiation_info@ extension. On
the server side in particular, this is not recommended, since it
leaves the server open to certain attacks. However, this mode is
necessary if you need to allow renegotiation with older client
software.

@since 2.48
-}
dtlsConnectionSetRehandshakeMode ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> Gio.Enums.TlsRehandshakeMode
    {- ^ /@mode@/: the rehandshaking mode -}
    -> m ()
dtlsConnectionSetRehandshakeMode conn mode = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    let mode' = (fromIntegral . fromEnum) mode
    g_dtls_connection_set_rehandshake_mode conn' mode'
    touchManagedPtr conn
    return ()

data DtlsConnectionSetRehandshakeModeMethodInfo
instance (signature ~ (Gio.Enums.TlsRehandshakeMode -> m ()), MonadIO m, IsDtlsConnection a) => O.MethodInfo DtlsConnectionSetRehandshakeModeMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionSetRehandshakeMode

-- method DtlsConnection::set_require_close_notify
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "require_close_notify", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether or not to require close notification", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dtls_connection_set_require_close_notify" g_dtls_connection_set_require_close_notify :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    CInt ->                                 -- require_close_notify : TBasicType TBoolean
    IO ()

{- |
Sets whether or not /@conn@/ expects a proper TLS close notification
before the connection is closed. If this is 'True' (the default),
then /@conn@/ will expect to receive a TLS close notification from its
peer before the connection is closed, and will return a
'GI.Gio.Enums.TlsErrorEof' error if the connection is closed without proper
notification (since this may indicate a network error, or
man-in-the-middle attack).

In some protocols, the application will know whether or not the
connection was closed cleanly based on application-level data
(because the application-level data includes a length field, or is
somehow self-delimiting); in this case, the close notify is
redundant and may be omitted. You
can use 'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionSetRequireCloseNotify' to tell /@conn@/
to allow an \"unannounced\" connection close, in which case the close
will show up as a 0-length read, as in a non-TLS
'GI.Gio.Interfaces.DatagramBased.DatagramBased', and it is up to the application to check that
the data has been fully received.

Note that this only affects the behavior when the peer closes the
connection; when the application calls 'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionCloseAsync' on
/@conn@/ itself, this will send a close notification regardless of the
setting of this property. If you explicitly want to do an unclean
close, you can close /@conn@/\'s 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection':@/base-socket/@ rather
than closing /@conn@/ itself.

@since 2.48
-}
dtlsConnectionSetRequireCloseNotify ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> Bool
    {- ^ /@requireCloseNotify@/: whether or not to require close notification -}
    -> m ()
dtlsConnectionSetRequireCloseNotify conn requireCloseNotify = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    let requireCloseNotify' = (fromIntegral . fromEnum) requireCloseNotify
    g_dtls_connection_set_require_close_notify conn' requireCloseNotify'
    touchManagedPtr conn
    return ()

data DtlsConnectionSetRequireCloseNotifyMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsDtlsConnection a) => O.MethodInfo DtlsConnectionSetRequireCloseNotifyMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionSetRequireCloseNotify

-- method DtlsConnection::shutdown
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "shutdown_read", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE to stop reception of incoming datagrams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "shutdown_write", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE to stop sending outgoing datagrams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_dtls_connection_shutdown" g_dtls_connection_shutdown :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    CInt ->                                 -- shutdown_read : TBasicType TBoolean
    CInt ->                                 -- shutdown_write : TBasicType TBoolean
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Shut down part or all of a DTLS connection.

If /@shutdownRead@/ is 'True' then the receiving side of the connection is shut
down, and further reading is disallowed. Subsequent calls to
'GI.Gio.Interfaces.DatagramBased.datagramBasedReceiveMessages' will return 'GI.Gio.Enums.IOErrorEnumClosed'.

If /@shutdownWrite@/ is 'True' then the sending side of the connection is shut
down, and further writing is disallowed. Subsequent calls to
'GI.Gio.Interfaces.DatagramBased.datagramBasedSendMessages' will return 'GI.Gio.Enums.IOErrorEnumClosed'.

It is allowed for both /@shutdownRead@/ and /@shutdownWrite@/ to be TRUE — this
is equivalent to calling 'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionClose'.

If /@cancellable@/ is cancelled, the 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' may be left
partially-closed and any pending untransmitted data may be lost. Call
'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionShutdown' again to complete closing the 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection'.

@since 2.48
-}
dtlsConnectionShutdown ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> Bool
    {- ^ /@shutdownRead@/: 'True' to stop reception of incoming datagrams -}
    -> Bool
    {- ^ /@shutdownWrite@/: 'True' to stop sending outgoing datagrams -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dtlsConnectionShutdown conn shutdownRead shutdownWrite cancellable = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    let shutdownRead' = (fromIntegral . fromEnum) shutdownRead
    let shutdownWrite' = (fromIntegral . fromEnum) shutdownWrite
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_dtls_connection_shutdown conn' shutdownRead' shutdownWrite' maybeCancellable
        touchManagedPtr conn
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

data DtlsConnectionShutdownMethodInfo
instance (signature ~ (Bool -> Bool -> Maybe (b) -> m ()), MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DtlsConnectionShutdownMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionShutdown

-- method DtlsConnection::shutdown_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "shutdown_read", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE to stop reception of incoming datagrams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "shutdown_write", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE to stop sending outgoing datagrams", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "io_priority", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the [I/O priority][io-priority] of the request", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "callback to call when the shutdown operation is complete", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 6, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to the callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dtls_connection_shutdown_async" g_dtls_connection_shutdown_async :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    CInt ->                                 -- shutdown_read : TBasicType TBoolean
    CInt ->                                 -- shutdown_write : TBasicType TBoolean
    Int32 ->                                -- io_priority : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously shut down part or all of the DTLS connection. See
'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionShutdown' for more information.

@since 2.48
-}
dtlsConnectionShutdownAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> Bool
    {- ^ /@shutdownRead@/: 'True' to stop reception of incoming datagrams -}
    -> Bool
    {- ^ /@shutdownWrite@/: 'True' to stop sending outgoing datagrams -}
    -> Int32
    {- ^ /@ioPriority@/: the [I\/O priority][io-priority] of the request -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: callback to call when the shutdown operation is complete -}
    -> m ()
dtlsConnectionShutdownAsync conn shutdownRead shutdownWrite ioPriority cancellable callback = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    let shutdownRead' = (fromIntegral . fromEnum) shutdownRead
    let shutdownWrite' = (fromIntegral . fromEnum) shutdownWrite
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_dtls_connection_shutdown_async conn' shutdownRead' shutdownWrite' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr conn
    whenJust cancellable touchManagedPtr
    return ()

data DtlsConnectionShutdownAsyncMethodInfo
instance (signature ~ (Bool -> Bool -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDtlsConnection a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DtlsConnectionShutdownAsyncMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionShutdownAsync

-- method DtlsConnection::shutdown_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "DtlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDtlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_dtls_connection_shutdown_finish" g_dtls_connection_shutdown_finish :: 
    Ptr DtlsConnection ->                   -- conn : TInterface (Name {namespace = "Gio", name = "DtlsConnection"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Finish an asynchronous TLS shutdown operation. See
'GI.Gio.Interfaces.DtlsConnection.dtlsConnectionShutdown' for more information.

@since 2.48
-}
dtlsConnectionShutdownFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDtlsConnection a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dtlsConnectionShutdownFinish conn result_ = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_dtls_connection_shutdown_finish conn' result_'
        touchManagedPtr conn
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

data DtlsConnectionShutdownFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsDtlsConnection a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DtlsConnectionShutdownFinishMethodInfo a signature where
    overloadedMethod _ = dtlsConnectionShutdownFinish