{- |
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.Objects.TlsConnection.TlsConnection' is the base TLS connection class type, which wraps
a 'GI.Gio.Objects.IOStream.IOStream' and provides TLS encryption on top of it. Its
subclasses, 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' and 'GI.Gio.Interfaces.TlsServerConnection.TlsServerConnection',
implement client-side and server-side TLS, respectively.

For DTLS (Datagram TLS) support, see 'GI.Gio.Interfaces.DtlsConnection.DtlsConnection'.
-}

module GI.Gio.Objects.TlsConnection
    ( 

-- * Exported types
    TlsConnection(..)                       ,
    IsTlsConnection                         ,
    toTlsConnection                         ,
    noTlsConnection                         ,


 -- * Methods
-- ** emitAcceptCertificate #method:emitAcceptCertificate#
    TlsConnectionEmitAcceptCertificateMethodInfo,
    tlsConnectionEmitAcceptCertificate      ,


-- ** getCertificate #method:getCertificate#
    TlsConnectionGetCertificateMethodInfo   ,
    tlsConnectionGetCertificate             ,


-- ** getDatabase #method:getDatabase#
    TlsConnectionGetDatabaseMethodInfo      ,
    tlsConnectionGetDatabase                ,


-- ** getInteraction #method:getInteraction#
    TlsConnectionGetInteractionMethodInfo   ,
    tlsConnectionGetInteraction             ,


-- ** getPeerCertificate #method:getPeerCertificate#
    TlsConnectionGetPeerCertificateMethodInfo,
    tlsConnectionGetPeerCertificate         ,


-- ** getPeerCertificateErrors #method:getPeerCertificateErrors#
    TlsConnectionGetPeerCertificateErrorsMethodInfo,
    tlsConnectionGetPeerCertificateErrors   ,


-- ** getRehandshakeMode #method:getRehandshakeMode#
    TlsConnectionGetRehandshakeModeMethodInfo,
    tlsConnectionGetRehandshakeMode         ,


-- ** getRequireCloseNotify #method:getRequireCloseNotify#
    TlsConnectionGetRequireCloseNotifyMethodInfo,
    tlsConnectionGetRequireCloseNotify      ,


-- ** getUseSystemCertdb #method:getUseSystemCertdb#
    TlsConnectionGetUseSystemCertdbMethodInfo,
    tlsConnectionGetUseSystemCertdb         ,


-- ** handshake #method:handshake#
    TlsConnectionHandshakeMethodInfo        ,
    tlsConnectionHandshake                  ,


-- ** handshakeAsync #method:handshakeAsync#
    TlsConnectionHandshakeAsyncMethodInfo   ,
    tlsConnectionHandshakeAsync             ,


-- ** handshakeFinish #method:handshakeFinish#
    TlsConnectionHandshakeFinishMethodInfo  ,
    tlsConnectionHandshakeFinish            ,


-- ** setCertificate #method:setCertificate#
    TlsConnectionSetCertificateMethodInfo   ,
    tlsConnectionSetCertificate             ,


-- ** setDatabase #method:setDatabase#
    TlsConnectionSetDatabaseMethodInfo      ,
    tlsConnectionSetDatabase                ,


-- ** setInteraction #method:setInteraction#
    TlsConnectionSetInteractionMethodInfo   ,
    tlsConnectionSetInteraction             ,


-- ** setRehandshakeMode #method:setRehandshakeMode#
    TlsConnectionSetRehandshakeModeMethodInfo,
    tlsConnectionSetRehandshakeMode         ,


-- ** setRequireCloseNotify #method:setRequireCloseNotify#
    TlsConnectionSetRequireCloseNotifyMethodInfo,
    tlsConnectionSetRequireCloseNotify      ,


-- ** setUseSystemCertdb #method:setUseSystemCertdb#
    TlsConnectionSetUseSystemCertdbMethodInfo,
    tlsConnectionSetUseSystemCertdb         ,




 -- * Properties
-- ** baseIoStream #attr:baseIoStream#
    TlsConnectionBaseIoStreamPropertyInfo   ,
    constructTlsConnectionBaseIoStream      ,
    getTlsConnectionBaseIoStream            ,
    tlsConnectionBaseIoStream               ,


-- ** certificate #attr:certificate#
    TlsConnectionCertificatePropertyInfo    ,
    constructTlsConnectionCertificate       ,
    getTlsConnectionCertificate             ,
    setTlsConnectionCertificate             ,
    tlsConnectionCertificate                ,


-- ** database #attr:database#
    TlsConnectionDatabasePropertyInfo       ,
    constructTlsConnectionDatabase          ,
    getTlsConnectionDatabase                ,
    setTlsConnectionDatabase                ,
    tlsConnectionDatabase                   ,


-- ** interaction #attr:interaction#
    TlsConnectionInteractionPropertyInfo    ,
    clearTlsConnectionInteraction           ,
    constructTlsConnectionInteraction       ,
    getTlsConnectionInteraction             ,
    setTlsConnectionInteraction             ,
    tlsConnectionInteraction                ,


-- ** peerCertificate #attr:peerCertificate#
    TlsConnectionPeerCertificatePropertyInfo,
    getTlsConnectionPeerCertificate         ,
    tlsConnectionPeerCertificate            ,


-- ** peerCertificateErrors #attr:peerCertificateErrors#
    TlsConnectionPeerCertificateErrorsPropertyInfo,
    getTlsConnectionPeerCertificateErrors   ,
    tlsConnectionPeerCertificateErrors      ,


-- ** rehandshakeMode #attr:rehandshakeMode#
    TlsConnectionRehandshakeModePropertyInfo,
    constructTlsConnectionRehandshakeMode   ,
    getTlsConnectionRehandshakeMode         ,
    setTlsConnectionRehandshakeMode         ,
    tlsConnectionRehandshakeMode            ,


-- ** requireCloseNotify #attr:requireCloseNotify#
    TlsConnectionRequireCloseNotifyPropertyInfo,
    constructTlsConnectionRequireCloseNotify,
    getTlsConnectionRequireCloseNotify      ,
    setTlsConnectionRequireCloseNotify      ,
    tlsConnectionRequireCloseNotify         ,


-- ** useSystemCertdb #attr:useSystemCertdb#
    TlsConnectionUseSystemCertdbPropertyInfo,
    constructTlsConnectionUseSystemCertdb   ,
    getTlsConnectionUseSystemCertdb         ,
    setTlsConnectionUseSystemCertdb         ,
    tlsConnectionUseSystemCertdb            ,




 -- * Signals
-- ** acceptCertificate #signal:acceptCertificate#
    C_TlsConnectionAcceptCertificateCallback,
    TlsConnectionAcceptCertificateCallback  ,
    TlsConnectionAcceptCertificateSignalInfo,
    afterTlsConnectionAcceptCertificate     ,
    genClosure_TlsConnectionAcceptCertificate,
    mk_TlsConnectionAcceptCertificateCallback,
    noTlsConnectionAcceptCertificateCallback,
    onTlsConnectionAcceptCertificate        ,
    wrap_TlsConnectionAcceptCertificateCallback,




    ) 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.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.IOStream as Gio.IOStream
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

newtype TlsConnection = TlsConnection (ManagedPtr TlsConnection)
foreign import ccall "g_tls_connection_get_type"
    c_g_tls_connection_get_type :: IO GType

instance GObject TlsConnection where
    gobjectType _ = c_g_tls_connection_get_type
    

class GObject o => IsTlsConnection o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError TlsConnection a) =>
    IsTlsConnection a
#endif
instance IsTlsConnection TlsConnection
instance Gio.IOStream.IsIOStream TlsConnection
instance GObject.Object.IsObject TlsConnection

toTlsConnection :: IsTlsConnection o => o -> IO TlsConnection
toTlsConnection = unsafeCastTo TlsConnection

noTlsConnection :: Maybe TlsConnection
noTlsConnection = Nothing

type family ResolveTlsConnectionMethod (t :: Symbol) (o :: *) :: * where
    ResolveTlsConnectionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveTlsConnectionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveTlsConnectionMethod "clearPending" o = Gio.IOStream.IOStreamClearPendingMethodInfo
    ResolveTlsConnectionMethod "close" o = Gio.IOStream.IOStreamCloseMethodInfo
    ResolveTlsConnectionMethod "closeAsync" o = Gio.IOStream.IOStreamCloseAsyncMethodInfo
    ResolveTlsConnectionMethod "closeFinish" o = Gio.IOStream.IOStreamCloseFinishMethodInfo
    ResolveTlsConnectionMethod "emitAcceptCertificate" o = TlsConnectionEmitAcceptCertificateMethodInfo
    ResolveTlsConnectionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveTlsConnectionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveTlsConnectionMethod "handshake" o = TlsConnectionHandshakeMethodInfo
    ResolveTlsConnectionMethod "handshakeAsync" o = TlsConnectionHandshakeAsyncMethodInfo
    ResolveTlsConnectionMethod "handshakeFinish" o = TlsConnectionHandshakeFinishMethodInfo
    ResolveTlsConnectionMethod "hasPending" o = Gio.IOStream.IOStreamHasPendingMethodInfo
    ResolveTlsConnectionMethod "isClosed" o = Gio.IOStream.IOStreamIsClosedMethodInfo
    ResolveTlsConnectionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveTlsConnectionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveTlsConnectionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveTlsConnectionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveTlsConnectionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveTlsConnectionMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveTlsConnectionMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveTlsConnectionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveTlsConnectionMethod "spliceAsync" o = Gio.IOStream.IOStreamSpliceAsyncMethodInfo
    ResolveTlsConnectionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveTlsConnectionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveTlsConnectionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveTlsConnectionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveTlsConnectionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveTlsConnectionMethod "getCertificate" o = TlsConnectionGetCertificateMethodInfo
    ResolveTlsConnectionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveTlsConnectionMethod "getDatabase" o = TlsConnectionGetDatabaseMethodInfo
    ResolveTlsConnectionMethod "getInputStream" o = Gio.IOStream.IOStreamGetInputStreamMethodInfo
    ResolveTlsConnectionMethod "getInteraction" o = TlsConnectionGetInteractionMethodInfo
    ResolveTlsConnectionMethod "getOutputStream" o = Gio.IOStream.IOStreamGetOutputStreamMethodInfo
    ResolveTlsConnectionMethod "getPeerCertificate" o = TlsConnectionGetPeerCertificateMethodInfo
    ResolveTlsConnectionMethod "getPeerCertificateErrors" o = TlsConnectionGetPeerCertificateErrorsMethodInfo
    ResolveTlsConnectionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveTlsConnectionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveTlsConnectionMethod "getRehandshakeMode" o = TlsConnectionGetRehandshakeModeMethodInfo
    ResolveTlsConnectionMethod "getRequireCloseNotify" o = TlsConnectionGetRequireCloseNotifyMethodInfo
    ResolveTlsConnectionMethod "getUseSystemCertdb" o = TlsConnectionGetUseSystemCertdbMethodInfo
    ResolveTlsConnectionMethod "setCertificate" o = TlsConnectionSetCertificateMethodInfo
    ResolveTlsConnectionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveTlsConnectionMethod "setDatabase" o = TlsConnectionSetDatabaseMethodInfo
    ResolveTlsConnectionMethod "setInteraction" o = TlsConnectionSetInteractionMethodInfo
    ResolveTlsConnectionMethod "setPending" o = Gio.IOStream.IOStreamSetPendingMethodInfo
    ResolveTlsConnectionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveTlsConnectionMethod "setRehandshakeMode" o = TlsConnectionSetRehandshakeModeMethodInfo
    ResolveTlsConnectionMethod "setRequireCloseNotify" o = TlsConnectionSetRequireCloseNotifyMethodInfo
    ResolveTlsConnectionMethod "setUseSystemCertdb" o = TlsConnectionSetUseSystemCertdbMethodInfo
    ResolveTlsConnectionMethod l o = O.MethodResolutionFailed l o

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

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

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

noTlsConnectionAcceptCertificateCallback :: Maybe TlsConnectionAcceptCertificateCallback
noTlsConnectionAcceptCertificateCallback = Nothing

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

foreign import ccall "wrapper"
    mk_TlsConnectionAcceptCertificateCallback :: C_TlsConnectionAcceptCertificateCallback -> IO (FunPtr C_TlsConnectionAcceptCertificateCallback)

genClosure_TlsConnectionAcceptCertificate :: TlsConnectionAcceptCertificateCallback -> IO Closure
genClosure_TlsConnectionAcceptCertificate cb = do
    let cb' = wrap_TlsConnectionAcceptCertificateCallback cb
    mk_TlsConnectionAcceptCertificateCallback cb' >>= newCClosure


wrap_TlsConnectionAcceptCertificateCallback ::
    TlsConnectionAcceptCertificateCallback ->
    Ptr () ->
    Ptr Gio.TlsCertificate.TlsCertificate ->
    CUInt ->
    Ptr () ->
    IO CInt
wrap_TlsConnectionAcceptCertificateCallback _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'


onTlsConnectionAcceptCertificate :: (GObject a, MonadIO m) => a -> TlsConnectionAcceptCertificateCallback -> m SignalHandlerId
onTlsConnectionAcceptCertificate obj cb = liftIO $ connectTlsConnectionAcceptCertificate obj cb SignalConnectBefore
afterTlsConnectionAcceptCertificate :: (GObject a, MonadIO m) => a -> TlsConnectionAcceptCertificateCallback -> m SignalHandlerId
afterTlsConnectionAcceptCertificate obj cb = connectTlsConnectionAcceptCertificate obj cb SignalConnectAfter

connectTlsConnectionAcceptCertificate :: (GObject a, MonadIO m) =>
                                         a -> TlsConnectionAcceptCertificateCallback -> SignalConnectMode -> m SignalHandlerId
connectTlsConnectionAcceptCertificate obj cb after = liftIO $ do
    let cb' = wrap_TlsConnectionAcceptCertificateCallback cb
    cb'' <- mk_TlsConnectionAcceptCertificateCallback cb'
    connectSignalFunPtr obj "accept-certificate" cb'' after

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

getTlsConnectionBaseIoStream :: (MonadIO m, IsTlsConnection o) => o -> m (Maybe Gio.IOStream.IOStream)
getTlsConnectionBaseIoStream obj = liftIO $ getObjectPropertyObject obj "base-io-stream" Gio.IOStream.IOStream

constructTlsConnectionBaseIoStream :: (IsTlsConnection o, Gio.IOStream.IsIOStream a) => a -> IO (GValueConstruct o)
constructTlsConnectionBaseIoStream val = constructObjectPropertyObject "base-io-stream" (Just val)

data TlsConnectionBaseIoStreamPropertyInfo
instance AttrInfo TlsConnectionBaseIoStreamPropertyInfo where
    type AttrAllowedOps TlsConnectionBaseIoStreamPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint TlsConnectionBaseIoStreamPropertyInfo = Gio.IOStream.IsIOStream
    type AttrBaseTypeConstraint TlsConnectionBaseIoStreamPropertyInfo = IsTlsConnection
    type AttrGetType TlsConnectionBaseIoStreamPropertyInfo = (Maybe Gio.IOStream.IOStream)
    type AttrLabel TlsConnectionBaseIoStreamPropertyInfo = "base-io-stream"
    type AttrOrigin TlsConnectionBaseIoStreamPropertyInfo = TlsConnection
    attrGet _ = getTlsConnectionBaseIoStream
    attrSet _ = undefined
    attrConstruct _ = constructTlsConnectionBaseIoStream
    attrClear _ = undefined

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

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

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

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

data TlsConnectionCertificatePropertyInfo
instance AttrInfo TlsConnectionCertificatePropertyInfo where
    type AttrAllowedOps TlsConnectionCertificatePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint TlsConnectionCertificatePropertyInfo = Gio.TlsCertificate.IsTlsCertificate
    type AttrBaseTypeConstraint TlsConnectionCertificatePropertyInfo = IsTlsConnection
    type AttrGetType TlsConnectionCertificatePropertyInfo = Gio.TlsCertificate.TlsCertificate
    type AttrLabel TlsConnectionCertificatePropertyInfo = "certificate"
    type AttrOrigin TlsConnectionCertificatePropertyInfo = TlsConnection
    attrGet _ = getTlsConnectionCertificate
    attrSet _ = setTlsConnectionCertificate
    attrConstruct _ = constructTlsConnectionCertificate
    attrClear _ = undefined

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

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

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

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

data TlsConnectionDatabasePropertyInfo
instance AttrInfo TlsConnectionDatabasePropertyInfo where
    type AttrAllowedOps TlsConnectionDatabasePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint TlsConnectionDatabasePropertyInfo = Gio.TlsDatabase.IsTlsDatabase
    type AttrBaseTypeConstraint TlsConnectionDatabasePropertyInfo = IsTlsConnection
    type AttrGetType TlsConnectionDatabasePropertyInfo = Gio.TlsDatabase.TlsDatabase
    type AttrLabel TlsConnectionDatabasePropertyInfo = "database"
    type AttrOrigin TlsConnectionDatabasePropertyInfo = TlsConnection
    attrGet _ = getTlsConnectionDatabase
    attrSet _ = setTlsConnectionDatabase
    attrConstruct _ = constructTlsConnectionDatabase
    attrClear _ = undefined

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

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

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

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

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

data TlsConnectionInteractionPropertyInfo
instance AttrInfo TlsConnectionInteractionPropertyInfo where
    type AttrAllowedOps TlsConnectionInteractionPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint TlsConnectionInteractionPropertyInfo = Gio.TlsInteraction.IsTlsInteraction
    type AttrBaseTypeConstraint TlsConnectionInteractionPropertyInfo = IsTlsConnection
    type AttrGetType TlsConnectionInteractionPropertyInfo = Gio.TlsInteraction.TlsInteraction
    type AttrLabel TlsConnectionInteractionPropertyInfo = "interaction"
    type AttrOrigin TlsConnectionInteractionPropertyInfo = TlsConnection
    attrGet _ = getTlsConnectionInteraction
    attrSet _ = setTlsConnectionInteraction
    attrConstruct _ = constructTlsConnectionInteraction
    attrClear _ = clearTlsConnectionInteraction

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

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

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

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

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

data TlsConnectionPeerCertificateErrorsPropertyInfo
instance AttrInfo TlsConnectionPeerCertificateErrorsPropertyInfo where
    type AttrAllowedOps TlsConnectionPeerCertificateErrorsPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint TlsConnectionPeerCertificateErrorsPropertyInfo = (~) ()
    type AttrBaseTypeConstraint TlsConnectionPeerCertificateErrorsPropertyInfo = IsTlsConnection
    type AttrGetType TlsConnectionPeerCertificateErrorsPropertyInfo = [Gio.Flags.TlsCertificateFlags]
    type AttrLabel TlsConnectionPeerCertificateErrorsPropertyInfo = "peer-certificate-errors"
    type AttrOrigin TlsConnectionPeerCertificateErrorsPropertyInfo = TlsConnection
    attrGet _ = getTlsConnectionPeerCertificateErrors
    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)

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

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

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

data TlsConnectionRehandshakeModePropertyInfo
instance AttrInfo TlsConnectionRehandshakeModePropertyInfo where
    type AttrAllowedOps TlsConnectionRehandshakeModePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint TlsConnectionRehandshakeModePropertyInfo = (~) Gio.Enums.TlsRehandshakeMode
    type AttrBaseTypeConstraint TlsConnectionRehandshakeModePropertyInfo = IsTlsConnection
    type AttrGetType TlsConnectionRehandshakeModePropertyInfo = Gio.Enums.TlsRehandshakeMode
    type AttrLabel TlsConnectionRehandshakeModePropertyInfo = "rehandshake-mode"
    type AttrOrigin TlsConnectionRehandshakeModePropertyInfo = TlsConnection
    attrGet _ = getTlsConnectionRehandshakeMode
    attrSet _ = setTlsConnectionRehandshakeMode
    attrConstruct _ = constructTlsConnectionRehandshakeMode
    attrClear _ = undefined

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

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

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

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

data TlsConnectionRequireCloseNotifyPropertyInfo
instance AttrInfo TlsConnectionRequireCloseNotifyPropertyInfo where
    type AttrAllowedOps TlsConnectionRequireCloseNotifyPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint TlsConnectionRequireCloseNotifyPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint TlsConnectionRequireCloseNotifyPropertyInfo = IsTlsConnection
    type AttrGetType TlsConnectionRequireCloseNotifyPropertyInfo = Bool
    type AttrLabel TlsConnectionRequireCloseNotifyPropertyInfo = "require-close-notify"
    type AttrOrigin TlsConnectionRequireCloseNotifyPropertyInfo = TlsConnection
    attrGet _ = getTlsConnectionRequireCloseNotify
    attrSet _ = setTlsConnectionRequireCloseNotify
    attrConstruct _ = constructTlsConnectionRequireCloseNotify
    attrClear _ = undefined

-- VVV Prop "use-system-certdb"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Just False,Just False)

getTlsConnectionUseSystemCertdb :: (MonadIO m, IsTlsConnection o) => o -> m Bool
getTlsConnectionUseSystemCertdb obj = liftIO $ getObjectPropertyBool obj "use-system-certdb"

setTlsConnectionUseSystemCertdb :: (MonadIO m, IsTlsConnection o) => o -> Bool -> m ()
setTlsConnectionUseSystemCertdb obj val = liftIO $ setObjectPropertyBool obj "use-system-certdb" val

constructTlsConnectionUseSystemCertdb :: (IsTlsConnection o) => Bool -> IO (GValueConstruct o)
constructTlsConnectionUseSystemCertdb val = constructObjectPropertyBool "use-system-certdb" val

data TlsConnectionUseSystemCertdbPropertyInfo
instance AttrInfo TlsConnectionUseSystemCertdbPropertyInfo where
    type AttrAllowedOps TlsConnectionUseSystemCertdbPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint TlsConnectionUseSystemCertdbPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint TlsConnectionUseSystemCertdbPropertyInfo = IsTlsConnection
    type AttrGetType TlsConnectionUseSystemCertdbPropertyInfo = Bool
    type AttrLabel TlsConnectionUseSystemCertdbPropertyInfo = "use-system-certdb"
    type AttrOrigin TlsConnectionUseSystemCertdbPropertyInfo = TlsConnection
    attrGet _ = getTlsConnectionUseSystemCertdb
    attrSet _ = setTlsConnectionUseSystemCertdb
    attrConstruct _ = constructTlsConnectionUseSystemCertdb
    attrClear _ = undefined

instance O.HasAttributeList TlsConnection
type instance O.AttributeList TlsConnection = TlsConnectionAttributeList
type TlsConnectionAttributeList = ('[ '("baseIoStream", TlsConnectionBaseIoStreamPropertyInfo), '("certificate", TlsConnectionCertificatePropertyInfo), '("closed", Gio.IOStream.IOStreamClosedPropertyInfo), '("database", TlsConnectionDatabasePropertyInfo), '("inputStream", Gio.IOStream.IOStreamInputStreamPropertyInfo), '("interaction", TlsConnectionInteractionPropertyInfo), '("outputStream", Gio.IOStream.IOStreamOutputStreamPropertyInfo), '("peerCertificate", TlsConnectionPeerCertificatePropertyInfo), '("peerCertificateErrors", TlsConnectionPeerCertificateErrorsPropertyInfo), '("rehandshakeMode", TlsConnectionRehandshakeModePropertyInfo), '("requireCloseNotify", TlsConnectionRequireCloseNotifyPropertyInfo), '("useSystemCertdb", TlsConnectionUseSystemCertdbPropertyInfo)] :: [(Symbol, *)])

tlsConnectionBaseIoStream :: AttrLabelProxy "baseIoStream"
tlsConnectionBaseIoStream = AttrLabelProxy

tlsConnectionCertificate :: AttrLabelProxy "certificate"
tlsConnectionCertificate = AttrLabelProxy

tlsConnectionDatabase :: AttrLabelProxy "database"
tlsConnectionDatabase = AttrLabelProxy

tlsConnectionInteraction :: AttrLabelProxy "interaction"
tlsConnectionInteraction = AttrLabelProxy

tlsConnectionPeerCertificate :: AttrLabelProxy "peerCertificate"
tlsConnectionPeerCertificate = AttrLabelProxy

tlsConnectionPeerCertificateErrors :: AttrLabelProxy "peerCertificateErrors"
tlsConnectionPeerCertificateErrors = AttrLabelProxy

tlsConnectionRehandshakeMode :: AttrLabelProxy "rehandshakeMode"
tlsConnectionRehandshakeMode = AttrLabelProxy

tlsConnectionRequireCloseNotify :: AttrLabelProxy "requireCloseNotify"
tlsConnectionRequireCloseNotify = AttrLabelProxy

tlsConnectionUseSystemCertdb :: AttrLabelProxy "useSystemCertdb"
tlsConnectionUseSystemCertdb = AttrLabelProxy

data TlsConnectionAcceptCertificateSignalInfo
instance SignalInfo TlsConnectionAcceptCertificateSignalInfo where
    type HaskellCallbackType TlsConnectionAcceptCertificateSignalInfo = TlsConnectionAcceptCertificateCallback
    connectSignal _ = connectTlsConnectionAcceptCertificate

type instance O.SignalList TlsConnection = TlsConnectionSignalList
type TlsConnectionSignalList = ('[ '("acceptCertificate", TlsConnectionAcceptCertificateSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method TlsConnection::emit_accept_certificate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_emit_accept_certificate" g_tls_connection_emit_accept_certificate :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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.Objects.TlsConnection.TlsConnection' implementations to emit the
'GI.Gio.Objects.TlsConnection.TlsConnection'::@/accept-certificate/@ signal.

@since 2.28
-}
tlsConnectionEmitAcceptCertificate ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a, Gio.TlsCertificate.IsTlsCertificate b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> 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@/ -}
tlsConnectionEmitAcceptCertificate conn peerCert errors = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    peerCert' <- unsafeManagedPtrCastPtr peerCert
    let errors' = gflagsToWord errors
    result <- g_tls_connection_emit_accept_certificate conn' peerCert' errors'
    let result' = (/= 0) result
    touchManagedPtr conn
    touchManagedPtr peerCert
    return result'

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

-- method TlsConnection::get_certificate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_get_certificate" g_tls_connection_get_certificate :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    IO (Ptr Gio.TlsCertificate.TlsCertificate)

{- |
Gets /@conn@/\'s certificate, as set by
'GI.Gio.Objects.TlsConnection.tlsConnectionSetCertificate'.

@since 2.28
-}
tlsConnectionGetCertificate ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> m Gio.TlsCertificate.TlsCertificate
    {- ^ __Returns:__ /@conn@/\'s certificate, or 'Nothing' -}
tlsConnectionGetCertificate conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_connection_get_certificate conn'
    checkUnexpectedReturnNULL "tlsConnectionGetCertificate" result
    result' <- (newObject Gio.TlsCertificate.TlsCertificate) result
    touchManagedPtr conn
    return result'

data TlsConnectionGetCertificateMethodInfo
instance (signature ~ (m Gio.TlsCertificate.TlsCertificate), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionGetCertificateMethodInfo a signature where
    overloadedMethod _ = tlsConnectionGetCertificate

-- method TlsConnection::get_database
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_get_database" g_tls_connection_get_database :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    IO (Ptr Gio.TlsDatabase.TlsDatabase)

{- |
Gets the certificate database that /@conn@/ uses to verify
peer certificates. See 'GI.Gio.Objects.TlsConnection.tlsConnectionSetDatabase'.

@since 2.30
-}
tlsConnectionGetDatabase ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> m Gio.TlsDatabase.TlsDatabase
    {- ^ __Returns:__ the certificate database that /@conn@/ uses or 'Nothing' -}
tlsConnectionGetDatabase conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_connection_get_database conn'
    checkUnexpectedReturnNULL "tlsConnectionGetDatabase" result
    result' <- (newObject Gio.TlsDatabase.TlsDatabase) result
    touchManagedPtr conn
    return result'

data TlsConnectionGetDatabaseMethodInfo
instance (signature ~ (m Gio.TlsDatabase.TlsDatabase), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionGetDatabaseMethodInfo a signature where
    overloadedMethod _ = tlsConnectionGetDatabase

-- method TlsConnection::get_interaction
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), 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_tls_connection_get_interaction" g_tls_connection_get_interaction :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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.30
-}
tlsConnectionGetInteraction ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a connection -}
    -> m Gio.TlsInteraction.TlsInteraction
    {- ^ __Returns:__ The interaction object. -}
tlsConnectionGetInteraction conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_connection_get_interaction conn'
    checkUnexpectedReturnNULL "tlsConnectionGetInteraction" result
    result' <- (newObject Gio.TlsInteraction.TlsInteraction) result
    touchManagedPtr conn
    return result'

data TlsConnectionGetInteractionMethodInfo
instance (signature ~ (m Gio.TlsInteraction.TlsInteraction), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionGetInteractionMethodInfo a signature where
    overloadedMethod _ = tlsConnectionGetInteraction

-- method TlsConnection::get_peer_certificate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_get_peer_certificate" g_tls_connection_get_peer_certificate :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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.Objects.TlsConnection.TlsConnection'::@/accept-certificate/@.)

@since 2.28
-}
tlsConnectionGetPeerCertificate ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> m Gio.TlsCertificate.TlsCertificate
    {- ^ __Returns:__ /@conn@/\'s peer\'s certificate, or 'Nothing' -}
tlsConnectionGetPeerCertificate conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_connection_get_peer_certificate conn'
    checkUnexpectedReturnNULL "tlsConnectionGetPeerCertificate" result
    result' <- (newObject Gio.TlsCertificate.TlsCertificate) result
    touchManagedPtr conn
    return result'

data TlsConnectionGetPeerCertificateMethodInfo
instance (signature ~ (m Gio.TlsCertificate.TlsCertificate), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionGetPeerCertificateMethodInfo a signature where
    overloadedMethod _ = tlsConnectionGetPeerCertificate

-- method TlsConnection::get_peer_certificate_errors
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_get_peer_certificate_errors" g_tls_connection_get_peer_certificate_errors :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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.Objects.TlsConnection.TlsConnection'::@/accept-certificate/@.)

@since 2.28
-}
tlsConnectionGetPeerCertificateErrors ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> m [Gio.Flags.TlsCertificateFlags]
    {- ^ __Returns:__ /@conn@/\'s peer\'s certificate errors -}
tlsConnectionGetPeerCertificateErrors conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_connection_get_peer_certificate_errors conn'
    let result' = wordToGFlags result
    touchManagedPtr conn
    return result'

data TlsConnectionGetPeerCertificateErrorsMethodInfo
instance (signature ~ (m [Gio.Flags.TlsCertificateFlags]), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionGetPeerCertificateErrorsMethodInfo a signature where
    overloadedMethod _ = tlsConnectionGetPeerCertificateErrors

-- method TlsConnection::get_rehandshake_mode
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_get_rehandshake_mode" g_tls_connection_get_rehandshake_mode :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    IO CUInt

{- |
Gets /@conn@/ rehandshaking mode. See
'GI.Gio.Objects.TlsConnection.tlsConnectionSetRehandshakeMode' for details.

@since 2.28
-}
tlsConnectionGetRehandshakeMode ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> m Gio.Enums.TlsRehandshakeMode
    {- ^ __Returns:__ /@conn@/\'s rehandshaking mode -}
tlsConnectionGetRehandshakeMode conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_connection_get_rehandshake_mode conn'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr conn
    return result'

data TlsConnectionGetRehandshakeModeMethodInfo
instance (signature ~ (m Gio.Enums.TlsRehandshakeMode), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionGetRehandshakeModeMethodInfo a signature where
    overloadedMethod _ = tlsConnectionGetRehandshakeMode

-- method TlsConnection::get_require_close_notify
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_get_require_close_notify" g_tls_connection_get_require_close_notify :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    IO CInt

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

@since 2.28
-}
tlsConnectionGetRequireCloseNotify ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@conn@/ requires a proper TLS close
notification. -}
tlsConnectionGetRequireCloseNotify conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_connection_get_require_close_notify conn'
    let result' = (/= 0) result
    touchManagedPtr conn
    return result'

data TlsConnectionGetRequireCloseNotifyMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionGetRequireCloseNotifyMethodInfo a signature where
    overloadedMethod _ = tlsConnectionGetRequireCloseNotify

-- method TlsConnection::get_use_system_certdb
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_get_use_system_certdb" g_tls_connection_get_use_system_certdb :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    IO CInt

{-# DEPRECATED tlsConnectionGetUseSystemCertdb ["(Since version 2.30)","Use 'GI.Gio.Objects.TlsConnection.tlsConnectionGetDatabase' instead"] #-}
{- |
Gets whether /@conn@/ uses the system certificate database to verify
peer certificates. See 'GI.Gio.Objects.TlsConnection.tlsConnectionSetUseSystemCertdb'.
-}
tlsConnectionGetUseSystemCertdb ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> m Bool
    {- ^ __Returns:__ whether /@conn@/ uses the system certificate database -}
tlsConnectionGetUseSystemCertdb conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_connection_get_use_system_certdb conn'
    let result' = (/= 0) result
    touchManagedPtr conn
    return result'

data TlsConnectionGetUseSystemCertdbMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionGetUseSystemCertdbMethodInfo a signature where
    overloadedMethod _ = tlsConnectionGetUseSystemCertdb

-- method TlsConnection::handshake
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_handshake" g_tls_connection_handshake :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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.Objects.TlsConnection.TlsConnection' will handle this for you automatically when you try
to send or receive data on the connection. However, you can call
'GI.Gio.Objects.TlsConnection.tlsConnectionHandshake' 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@/\'s output stream, 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.Objects.TlsConnection.tlsConnectionHandshake' later on to
renegotiate parameters (encryption methods, etc) with the client.

'GI.Gio.Objects.TlsConnection.TlsConnection'::@/accept_certificate/@ may be emitted during the
handshake.

@since 2.28
-}
tlsConnectionHandshake ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
tlsConnectionHandshake 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_tls_connection_handshake conn' maybeCancellable
        touchManagedPtr conn
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

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

-- method TlsConnection::handshake_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_handshake_async" g_tls_connection_handshake_async :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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.Objects.TlsConnection.tlsConnectionHandshake' for more information.

@since 2.28
-}
tlsConnectionHandshakeAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> 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 ()
tlsConnectionHandshakeAsync 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_tls_connection_handshake_async conn' ioPriority maybeCancellable maybeCallback userData
    touchManagedPtr conn
    whenJust cancellable touchManagedPtr
    return ()

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

-- method TlsConnection::handshake_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_handshake_finish" g_tls_connection_handshake_finish :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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.Objects.TlsConnection.tlsConnectionHandshake' for more information.

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

data TlsConnectionHandshakeFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsTlsConnection a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo TlsConnectionHandshakeFinishMethodInfo a signature where
    overloadedMethod _ = tlsConnectionHandshakeFinish

-- method TlsConnection::set_certificate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_set_certificate" g_tls_connection_set_certificate :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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.TlsServerConnection.TlsServerConnection', it is
mandatory to set this, and that will normally be done at construct
time.

For a 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection', 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.TlsClientConnection.tlsClientConnectionGetAcceptedCas' 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.TlsClientConnection.tlsClientConnectionGetAcceptedCas' will return
non-'Nothing'.)

@since 2.28
-}
tlsConnectionSetCertificate ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a, Gio.TlsCertificate.IsTlsCertificate b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> b
    {- ^ /@certificate@/: the certificate to use for /@conn@/ -}
    -> m ()
tlsConnectionSetCertificate conn certificate = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    certificate' <- unsafeManagedPtrCastPtr certificate
    g_tls_connection_set_certificate conn' certificate'
    touchManagedPtr conn
    touchManagedPtr certificate
    return ()

data TlsConnectionSetCertificateMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsTlsConnection a, Gio.TlsCertificate.IsTlsCertificate b) => O.MethodInfo TlsConnectionSetCertificateMethodInfo a signature where
    overloadedMethod _ = tlsConnectionSetCertificate

-- method TlsConnection::set_database
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_set_database" g_tls_connection_set_database :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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
'GI.Gio.Interfaces.TlsBackend.tlsBackendGetDefaultDatabase'. If set to 'Nothing', then
peer certificate validation will always set the
'GI.Gio.Flags.TlsCertificateFlagsUnknownCa' error (meaning
'GI.Gio.Objects.TlsConnection.TlsConnection'::@/accept-certificate/@ will always be emitted on
client-side connections, unless that bit is not set in
'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection':@/validation-flags/@).

@since 2.30
-}
tlsConnectionSetDatabase ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a, Gio.TlsDatabase.IsTlsDatabase b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> b
    {- ^ /@database@/: a 'GI.Gio.Objects.TlsDatabase.TlsDatabase' -}
    -> m ()
tlsConnectionSetDatabase conn database = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    database' <- unsafeManagedPtrCastPtr database
    g_tls_connection_set_database conn' database'
    touchManagedPtr conn
    touchManagedPtr database
    return ()

data TlsConnectionSetDatabaseMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsTlsConnection a, Gio.TlsDatabase.IsTlsDatabase b) => O.MethodInfo TlsConnectionSetDatabaseMethodInfo a signature where
    overloadedMethod _ = tlsConnectionSetDatabase

-- method TlsConnection::set_interaction
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), 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_tls_connection_set_interaction" g_tls_connection_set_interaction :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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.30
-}
tlsConnectionSetInteraction ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a, Gio.TlsInteraction.IsTlsInteraction b) =>
    a
    {- ^ /@conn@/: a connection -}
    -> Maybe (b)
    {- ^ /@interaction@/: an interaction object, or 'Nothing' -}
    -> m ()
tlsConnectionSetInteraction conn interaction = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    maybeInteraction <- case interaction of
        Nothing -> return nullPtr
        Just jInteraction -> do
            jInteraction' <- unsafeManagedPtrCastPtr jInteraction
            return jInteraction'
    g_tls_connection_set_interaction conn' maybeInteraction
    touchManagedPtr conn
    whenJust interaction touchManagedPtr
    return ()

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

-- method TlsConnection::set_rehandshake_mode
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_set_rehandshake_mode" g_tls_connection_set_rehandshake_mode :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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.28
-}
tlsConnectionSetRehandshakeMode ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> Gio.Enums.TlsRehandshakeMode
    {- ^ /@mode@/: the rehandshaking mode -}
    -> m ()
tlsConnectionSetRehandshakeMode conn mode = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    let mode' = (fromIntegral . fromEnum) mode
    g_tls_connection_set_rehandshake_mode conn' mode'
    touchManagedPtr conn
    return ()

data TlsConnectionSetRehandshakeModeMethodInfo
instance (signature ~ (Gio.Enums.TlsRehandshakeMode -> m ()), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionSetRehandshakeModeMethodInfo a signature where
    overloadedMethod _ = tlsConnectionSetRehandshakeMode

-- method TlsConnection::set_require_close_notify
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", 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_tls_connection_set_require_close_notify" g_tls_connection_set_require_close_notify :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    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 sometimes omitted. (TLS 1.1 explicitly allows this;
in TLS 1.0 it is technically an error, but often done anyway.) You
can use 'GI.Gio.Objects.TlsConnection.tlsConnectionSetRequireCloseNotify' 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.Objects.SocketConnection.SocketConnection', 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.Objects.IOStream.iOStreamClose' itself
on /@conn@/, 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.Objects.TlsConnection.TlsConnection':@/base-io-stream/@ rather
than closing /@conn@/ itself, but note that this may only be done when no other
operations are pending on /@conn@/ or the base I\/O stream.

@since 2.28
-}
tlsConnectionSetRequireCloseNotify ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> Bool
    {- ^ /@requireCloseNotify@/: whether or not to require close notification -}
    -> m ()
tlsConnectionSetRequireCloseNotify conn requireCloseNotify = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    let requireCloseNotify' = (fromIntegral . fromEnum) requireCloseNotify
    g_tls_connection_set_require_close_notify conn' requireCloseNotify'
    touchManagedPtr conn
    return ()

data TlsConnectionSetRequireCloseNotifyMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionSetRequireCloseNotifyMethodInfo a signature where
    overloadedMethod _ = tlsConnectionSetRequireCloseNotify

-- method TlsConnection::set_use_system_certdb
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "use_system_certdb", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to use the system certificate database", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

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

{-# DEPRECATED tlsConnectionSetUseSystemCertdb ["(Since version 2.30)","Use 'GI.Gio.Objects.TlsConnection.tlsConnectionSetDatabase' instead"] #-}
{- |
Sets whether /@conn@/ uses the system certificate database to verify
peer certificates. This is 'True' by default. If set to 'False', then
peer certificate validation will always set the
'GI.Gio.Flags.TlsCertificateFlagsUnknownCa' error (meaning
'GI.Gio.Objects.TlsConnection.TlsConnection'::@/accept-certificate/@ will always be emitted on
client-side connections, unless that bit is not set in
'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection':@/validation-flags/@).
-}
tlsConnectionSetUseSystemCertdb ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> Bool
    {- ^ /@useSystemCertdb@/: whether to use the system certificate database -}
    -> m ()
tlsConnectionSetUseSystemCertdb conn useSystemCertdb = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    let useSystemCertdb' = (fromIntegral . fromEnum) useSystemCertdb
    g_tls_connection_set_use_system_certdb conn' useSystemCertdb'
    touchManagedPtr conn
    return ()

data TlsConnectionSetUseSystemCertdbMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionSetUseSystemCertdbMethodInfo a signature where
    overloadedMethod _ = tlsConnectionSetUseSystemCertdb