{- |
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'.

/Since: 2.28/
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.Gio.Objects.TlsConnection
    ( 

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


 -- * Methods
-- ** emitAcceptCertificate #method:emitAcceptCertificate#

#if ENABLE_OVERLOADING
    TlsConnectionEmitAcceptCertificateMethodInfo,
#endif
    tlsConnectionEmitAcceptCertificate      ,


-- ** getCertificate #method:getCertificate#

#if ENABLE_OVERLOADING
    TlsConnectionGetCertificateMethodInfo   ,
#endif
    tlsConnectionGetCertificate             ,


-- ** getDatabase #method:getDatabase#

#if ENABLE_OVERLOADING
    TlsConnectionGetDatabaseMethodInfo      ,
#endif
    tlsConnectionGetDatabase                ,


-- ** getInteraction #method:getInteraction#

#if ENABLE_OVERLOADING
    TlsConnectionGetInteractionMethodInfo   ,
#endif
    tlsConnectionGetInteraction             ,


-- ** getNegotiatedProtocol #method:getNegotiatedProtocol#

#if ENABLE_OVERLOADING
    TlsConnectionGetNegotiatedProtocolMethodInfo,
#endif
    tlsConnectionGetNegotiatedProtocol      ,


-- ** getPeerCertificate #method:getPeerCertificate#

#if ENABLE_OVERLOADING
    TlsConnectionGetPeerCertificateMethodInfo,
#endif
    tlsConnectionGetPeerCertificate         ,


-- ** getPeerCertificateErrors #method:getPeerCertificateErrors#

#if ENABLE_OVERLOADING
    TlsConnectionGetPeerCertificateErrorsMethodInfo,
#endif
    tlsConnectionGetPeerCertificateErrors   ,


-- ** getRehandshakeMode #method:getRehandshakeMode#

#if ENABLE_OVERLOADING
    TlsConnectionGetRehandshakeModeMethodInfo,
#endif
    tlsConnectionGetRehandshakeMode         ,


-- ** getRequireCloseNotify #method:getRequireCloseNotify#

#if ENABLE_OVERLOADING
    TlsConnectionGetRequireCloseNotifyMethodInfo,
#endif
    tlsConnectionGetRequireCloseNotify      ,


-- ** getUseSystemCertdb #method:getUseSystemCertdb#

#if ENABLE_OVERLOADING
    TlsConnectionGetUseSystemCertdbMethodInfo,
#endif
    tlsConnectionGetUseSystemCertdb         ,


-- ** handshake #method:handshake#

#if ENABLE_OVERLOADING
    TlsConnectionHandshakeMethodInfo        ,
#endif
    tlsConnectionHandshake                  ,


-- ** handshakeAsync #method:handshakeAsync#

#if ENABLE_OVERLOADING
    TlsConnectionHandshakeAsyncMethodInfo   ,
#endif
    tlsConnectionHandshakeAsync             ,


-- ** handshakeFinish #method:handshakeFinish#

#if ENABLE_OVERLOADING
    TlsConnectionHandshakeFinishMethodInfo  ,
#endif
    tlsConnectionHandshakeFinish            ,


-- ** setAdvertisedProtocols #method:setAdvertisedProtocols#

#if ENABLE_OVERLOADING
    TlsConnectionSetAdvertisedProtocolsMethodInfo,
#endif
    tlsConnectionSetAdvertisedProtocols     ,


-- ** setCertificate #method:setCertificate#

#if ENABLE_OVERLOADING
    TlsConnectionSetCertificateMethodInfo   ,
#endif
    tlsConnectionSetCertificate             ,


-- ** setDatabase #method:setDatabase#

#if ENABLE_OVERLOADING
    TlsConnectionSetDatabaseMethodInfo      ,
#endif
    tlsConnectionSetDatabase                ,


-- ** setInteraction #method:setInteraction#

#if ENABLE_OVERLOADING
    TlsConnectionSetInteractionMethodInfo   ,
#endif
    tlsConnectionSetInteraction             ,


-- ** setRehandshakeMode #method:setRehandshakeMode#

#if ENABLE_OVERLOADING
    TlsConnectionSetRehandshakeModeMethodInfo,
#endif
    tlsConnectionSetRehandshakeMode         ,


-- ** setRequireCloseNotify #method:setRequireCloseNotify#

#if ENABLE_OVERLOADING
    TlsConnectionSetRequireCloseNotifyMethodInfo,
#endif
    tlsConnectionSetRequireCloseNotify      ,


-- ** setUseSystemCertdb #method:setUseSystemCertdb#

#if ENABLE_OVERLOADING
    TlsConnectionSetUseSystemCertdbMethodInfo,
#endif
    tlsConnectionSetUseSystemCertdb         ,




 -- * Properties
-- ** advertisedProtocols #attr:advertisedProtocols#
{- | The list of application-layer protocols that the connection
advertises that it is willing to speak. See
'GI.Gio.Objects.TlsConnection.tlsConnectionSetAdvertisedProtocols'.

/Since: 2.60/
-}
#if ENABLE_OVERLOADING
    TlsConnectionAdvertisedProtocolsPropertyInfo,
#endif
    clearTlsConnectionAdvertisedProtocols   ,
    constructTlsConnectionAdvertisedProtocols,
    getTlsConnectionAdvertisedProtocols     ,
    setTlsConnectionAdvertisedProtocols     ,
#if ENABLE_OVERLOADING
    tlsConnectionAdvertisedProtocols        ,
#endif


-- ** baseIoStream #attr:baseIoStream#
{- | The 'GI.Gio.Objects.IOStream.IOStream' that the connection wraps. The connection holds a reference
to this stream, and may run operations on the stream from other threads
throughout its lifetime. Consequently, after the 'GI.Gio.Objects.IOStream.IOStream' has been
constructed, application code may only run its own operations on this
stream when no 'GI.Gio.Objects.IOStream.IOStream' operations are running.

/Since: 2.28/
-}
#if ENABLE_OVERLOADING
    TlsConnectionBaseIoStreamPropertyInfo   ,
#endif
    constructTlsConnectionBaseIoStream      ,
    getTlsConnectionBaseIoStream            ,
#if ENABLE_OVERLOADING
    tlsConnectionBaseIoStream               ,
#endif


-- ** certificate #attr:certificate#
{- | The connection\'s certificate; see
'GI.Gio.Objects.TlsConnection.tlsConnectionSetCertificate'.

/Since: 2.28/
-}
#if ENABLE_OVERLOADING
    TlsConnectionCertificatePropertyInfo    ,
#endif
    constructTlsConnectionCertificate       ,
    getTlsConnectionCertificate             ,
    setTlsConnectionCertificate             ,
#if ENABLE_OVERLOADING
    tlsConnectionCertificate                ,
#endif


-- ** database #attr:database#
{- | The certificate database to use when verifying this TLS connection.
If no certificate database is set, then the default database will be
used. See 'GI.Gio.Interfaces.TlsBackend.tlsBackendGetDefaultDatabase'.

/Since: 2.30/
-}
#if ENABLE_OVERLOADING
    TlsConnectionDatabasePropertyInfo       ,
#endif
    constructTlsConnectionDatabase          ,
    getTlsConnectionDatabase                ,
    setTlsConnectionDatabase                ,
#if ENABLE_OVERLOADING
    tlsConnectionDatabase                   ,
#endif


-- ** interaction #attr:interaction#
{- | A 'GI.Gio.Objects.TlsInteraction.TlsInteraction' object to be used when the connection or certificate
database need to interact with the user. This will be used to prompt the
user for passwords where necessary.

/Since: 2.30/
-}
#if ENABLE_OVERLOADING
    TlsConnectionInteractionPropertyInfo    ,
#endif
    clearTlsConnectionInteraction           ,
    constructTlsConnectionInteraction       ,
    getTlsConnectionInteraction             ,
    setTlsConnectionInteraction             ,
#if ENABLE_OVERLOADING
    tlsConnectionInteraction                ,
#endif


-- ** negotiatedProtocol #attr:negotiatedProtocol#
{- | The application-layer protocol negotiated during the TLS
handshake. See 'GI.Gio.Objects.TlsConnection.tlsConnectionGetNegotiatedProtocol'.

/Since: 2.60/
-}
#if ENABLE_OVERLOADING
    TlsConnectionNegotiatedProtocolPropertyInfo,
#endif
    getTlsConnectionNegotiatedProtocol      ,
#if ENABLE_OVERLOADING
    tlsConnectionNegotiatedProtocol         ,
#endif


-- ** peerCertificate #attr:peerCertificate#
{- | The connection\'s peer\'s certificate, after the TLS handshake has
completed and the certificate has been accepted. Note in
particular that this is not yet set during the emission of
'GI.Gio.Objects.TlsConnection.TlsConnection'::@/accept-certificate/@.

(You can watch for a 'GI.GObject.Objects.Object.Object'::@/notify/@ signal on this property to
detect when a handshake has occurred.)

/Since: 2.28/
-}
#if ENABLE_OVERLOADING
    TlsConnectionPeerCertificatePropertyInfo,
#endif
    getTlsConnectionPeerCertificate         ,
#if ENABLE_OVERLOADING
    tlsConnectionPeerCertificate            ,
#endif


-- ** peerCertificateErrors #attr:peerCertificateErrors#
{- | The errors noticed-and-ignored while verifying
'GI.Gio.Objects.TlsConnection.TlsConnection':@/peer-certificate/@. Normally this should be 0, but
it may not be if 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection':@/validation-flags/@ is not
'GI.Gio.Flags.TlsCertificateFlagsValidateAll', or if
'GI.Gio.Objects.TlsConnection.TlsConnection'::@/accept-certificate/@ overrode the default
behavior.

/Since: 2.28/
-}
#if ENABLE_OVERLOADING
    TlsConnectionPeerCertificateErrorsPropertyInfo,
#endif
    getTlsConnectionPeerCertificateErrors   ,
#if ENABLE_OVERLOADING
    tlsConnectionPeerCertificateErrors      ,
#endif


-- ** rehandshakeMode #attr:rehandshakeMode#
{- | The rehandshaking mode. See
'GI.Gio.Objects.TlsConnection.tlsConnectionSetRehandshakeMode'.

/Since: 2.28/
-}
#if ENABLE_OVERLOADING
    TlsConnectionRehandshakeModePropertyInfo,
#endif
    constructTlsConnectionRehandshakeMode   ,
    getTlsConnectionRehandshakeMode         ,
    setTlsConnectionRehandshakeMode         ,
#if ENABLE_OVERLOADING
    tlsConnectionRehandshakeMode            ,
#endif


-- ** requireCloseNotify #attr:requireCloseNotify#
{- | Whether or not proper TLS close notification is required.
See 'GI.Gio.Objects.TlsConnection.tlsConnectionSetRequireCloseNotify'.

/Since: 2.28/
-}
#if ENABLE_OVERLOADING
    TlsConnectionRequireCloseNotifyPropertyInfo,
#endif
    constructTlsConnectionRequireCloseNotify,
    getTlsConnectionRequireCloseNotify      ,
    setTlsConnectionRequireCloseNotify      ,
#if ENABLE_OVERLOADING
    tlsConnectionRequireCloseNotify         ,
#endif


-- ** useSystemCertdb #attr:useSystemCertdb#
{- | Whether or not the system certificate database will be used to
verify peer certificates. See
'GI.Gio.Objects.TlsConnection.tlsConnectionSetUseSystemCertdb'.
-}
#if ENABLE_OVERLOADING
    TlsConnectionUseSystemCertdbPropertyInfo,
#endif
    constructTlsConnectionUseSystemCertdb   ,
    getTlsConnectionUseSystemCertdb         ,
    setTlsConnectionUseSystemCertdb         ,
#if ENABLE_OVERLOADING
    tlsConnectionUseSystemCertdb            ,
#endif




 -- * Signals
-- ** acceptCertificate #signal:acceptCertificate#

    C_TlsConnectionAcceptCertificateCallback,
    TlsConnectionAcceptCertificateCallback  ,
#if ENABLE_OVERLOADING
    TlsConnectionAcceptCertificateSignalInfo,
#endif
    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.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.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

-- | Memory-managed wrapper type.
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 :: TlsConnection -> IO GType
gobjectType _ = IO GType
c_g_tls_connection_get_type
    

-- | Type class for types which can be safely cast to `TlsConnection`, for instance with `toTlsConnection`.
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

-- | Cast to `TlsConnection`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toTlsConnection :: (MonadIO m, IsTlsConnection o) => o -> m TlsConnection
toTlsConnection :: o -> m TlsConnection
toTlsConnection = IO TlsConnection -> m TlsConnection
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsConnection -> m TlsConnection)
-> (o -> IO TlsConnection) -> o -> m TlsConnection
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr TlsConnection -> TlsConnection)
-> o -> IO TlsConnection
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr TlsConnection -> TlsConnection
TlsConnection

-- | A convenience alias for `Nothing` :: `Maybe` `TlsConnection`.
noTlsConnection :: Maybe TlsConnection
noTlsConnection :: Maybe TlsConnection
noTlsConnection = Maybe TlsConnection
forall a. Maybe a
Nothing

#if ENABLE_OVERLOADING
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 "getv" o = GObject.Object.ObjectGetvMethodInfo
    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 "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 "getNegotiatedProtocol" o = TlsConnectionGetNegotiatedProtocolMethodInfo
    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 "setAdvertisedProtocols" o = TlsConnectionSetAdvertisedProtocolsMethodInfo
    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
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif

-- signal TlsConnection::accept-certificate
{- |
Emitted during the TLS handshake after the peer certificate has
been received. You can examine /@peerCert@/\'s certification path by
calling 'GI.Gio.Objects.TlsCertificate.tlsCertificateGetIssuer' on it.

For a client-side connection, /@peerCert@/ is the server\'s
certificate, and the signal will only be emitted if the
certificate was not acceptable according to /@conn@/\'s
'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection':@/validation_flags/@. If you would like the
certificate to be accepted despite /@errors@/, return 'True' from the
signal handler. Otherwise, if no handler accepts the certificate,
the handshake will fail with 'GI.Gio.Enums.TlsErrorBadCertificate'.

For a server-side connection, /@peerCert@/ is the certificate
presented by the client, if this was requested via the server\'s
'GI.Gio.Interfaces.TlsServerConnection.TlsServerConnection':@/authentication_mode/@. On the server side,
the signal is always emitted when the client presents a
certificate, and the certificate will only be accepted if a
handler returns 'True'.

Note that if this signal is emitted as part of asynchronous I\/O
in the main thread, then you should not attempt to interact with
the user before returning from the signal handler. If you want to
let the user decide whether or not to accept the certificate, you
would have to return 'False' from the signal handler on the first
attempt, and then after the connection attempt returns a
'GI.Gio.Enums.TlsErrorBadCertificate', you can interact with the user, and
if the user decides to accept the certificate, remember that fact,
create a new connection, and return 'True' from the signal handler
the next time.

If you are doing I\/O in another thread, you do not
need to worry about this, and can simply block in the signal
handler until the UI thread returns an answer.

/Since: 2.28/
-}
type TlsConnectionAcceptCertificateCallback =
    Gio.TlsCertificate.TlsCertificate
    {- ^ /@peerCert@/: the peer\'s 'GI.Gio.Objects.TlsCertificate.TlsCertificate' -}
    -> [Gio.Flags.TlsCertificateFlags]
    {- ^ /@errors@/: the problems with /@peerCert@/. -}
    -> IO Bool
    {- ^ __Returns:__ 'True' to accept /@peerCert@/ (which will also
immediately end the signal emission). 'False' to allow the signal
emission to continue, which will cause the handshake to fail if
no one else overrides it. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `TlsConnectionAcceptCertificateCallback`@.
noTlsConnectionAcceptCertificateCallback :: Maybe TlsConnectionAcceptCertificateCallback
noTlsConnectionAcceptCertificateCallback :: Maybe TlsConnectionAcceptCertificateCallback
noTlsConnectionAcceptCertificateCallback = Maybe TlsConnectionAcceptCertificateCallback
forall a. Maybe a
Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_TlsConnectionAcceptCertificateCallback =
    Ptr () ->                               -- object
    Ptr Gio.TlsCertificate.TlsCertificate ->
    CUInt ->
    Ptr () ->                               -- user_data
    IO CInt

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

-- | Wrap the callback into a `Closure`.
genClosure_TlsConnectionAcceptCertificate :: TlsConnectionAcceptCertificateCallback -> IO Closure
genClosure_TlsConnectionAcceptCertificate :: TlsConnectionAcceptCertificateCallback -> IO Closure
genClosure_TlsConnectionAcceptCertificate cb :: TlsConnectionAcceptCertificateCallback
cb = do
    let cb' :: C_TlsConnectionAcceptCertificateCallback
cb' = TlsConnectionAcceptCertificateCallback
-> C_TlsConnectionAcceptCertificateCallback
wrap_TlsConnectionAcceptCertificateCallback TlsConnectionAcceptCertificateCallback
cb
    C_TlsConnectionAcceptCertificateCallback
-> IO (FunPtr C_TlsConnectionAcceptCertificateCallback)
mk_TlsConnectionAcceptCertificateCallback C_TlsConnectionAcceptCertificateCallback
cb' IO (FunPtr C_TlsConnectionAcceptCertificateCallback)
-> (FunPtr C_TlsConnectionAcceptCertificateCallback -> IO Closure)
-> IO Closure
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_TlsConnectionAcceptCertificateCallback -> IO Closure
forall a. FunPtr a -> IO Closure
newCClosure


-- | Wrap a `TlsConnectionAcceptCertificateCallback` into a `C_TlsConnectionAcceptCertificateCallback`.
wrap_TlsConnectionAcceptCertificateCallback ::
    TlsConnectionAcceptCertificateCallback ->
    C_TlsConnectionAcceptCertificateCallback
wrap_TlsConnectionAcceptCertificateCallback :: TlsConnectionAcceptCertificateCallback
-> C_TlsConnectionAcceptCertificateCallback
wrap_TlsConnectionAcceptCertificateCallback _cb :: TlsConnectionAcceptCertificateCallback
_cb _ peerCert :: Ptr TlsCertificate
peerCert errors :: CUInt
errors _ = do
    TlsCertificate
peerCert' <- ((ManagedPtr TlsCertificate -> TlsCertificate)
-> Ptr TlsCertificate -> IO TlsCertificate
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr TlsCertificate -> TlsCertificate
Gio.TlsCertificate.TlsCertificate) Ptr TlsCertificate
peerCert
    let errors' :: [TlsCertificateFlags]
errors' = CUInt -> [TlsCertificateFlags]
forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
wordToGFlags CUInt
errors
    Bool
result <- TlsConnectionAcceptCertificateCallback
_cb  TlsCertificate
peerCert' [TlsCertificateFlags]
errors'
    let result' :: CInt
result' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
result
    CInt -> IO CInt
forall (m :: * -> *) a. Monad m => a -> m a
return CInt
result'


{- |
Connect a signal handler for the “@accept-certificate@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' tlsConnection #acceptCertificate callback
@
-}
onTlsConnectionAcceptCertificate :: (IsTlsConnection a, MonadIO m) => a -> TlsConnectionAcceptCertificateCallback -> m SignalHandlerId
onTlsConnectionAcceptCertificate :: a -> TlsConnectionAcceptCertificateCallback -> m SignalHandlerId
onTlsConnectionAcceptCertificate obj :: a
obj cb :: TlsConnectionAcceptCertificateCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_TlsConnectionAcceptCertificateCallback
cb' = TlsConnectionAcceptCertificateCallback
-> C_TlsConnectionAcceptCertificateCallback
wrap_TlsConnectionAcceptCertificateCallback TlsConnectionAcceptCertificateCallback
cb
    FunPtr C_TlsConnectionAcceptCertificateCallback
cb'' <- C_TlsConnectionAcceptCertificateCallback
-> IO (FunPtr C_TlsConnectionAcceptCertificateCallback)
mk_TlsConnectionAcceptCertificateCallback C_TlsConnectionAcceptCertificateCallback
cb'
    a
-> String
-> FunPtr C_TlsConnectionAcceptCertificateCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "accept-certificate" FunPtr C_TlsConnectionAcceptCertificateCallback
cb'' SignalConnectMode
SignalConnectBefore

{- |
Connect a signal handler for the “@accept-certificate@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' tlsConnection #acceptCertificate callback
@
-}
afterTlsConnectionAcceptCertificate :: (IsTlsConnection a, MonadIO m) => a -> TlsConnectionAcceptCertificateCallback -> m SignalHandlerId
afterTlsConnectionAcceptCertificate :: a -> TlsConnectionAcceptCertificateCallback -> m SignalHandlerId
afterTlsConnectionAcceptCertificate obj :: a
obj cb :: TlsConnectionAcceptCertificateCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_TlsConnectionAcceptCertificateCallback
cb' = TlsConnectionAcceptCertificateCallback
-> C_TlsConnectionAcceptCertificateCallback
wrap_TlsConnectionAcceptCertificateCallback TlsConnectionAcceptCertificateCallback
cb
    FunPtr C_TlsConnectionAcceptCertificateCallback
cb'' <- C_TlsConnectionAcceptCertificateCallback
-> IO (FunPtr C_TlsConnectionAcceptCertificateCallback)
mk_TlsConnectionAcceptCertificateCallback C_TlsConnectionAcceptCertificateCallback
cb'
    a
-> String
-> FunPtr C_TlsConnectionAcceptCertificateCallback
-> SignalConnectMode
-> IO SignalHandlerId
forall o a.
GObject o =>
o -> String -> FunPtr a -> SignalConnectMode -> IO SignalHandlerId
connectSignalFunPtr a
obj "accept-certificate" FunPtr C_TlsConnectionAcceptCertificateCallback
cb'' SignalConnectMode
SignalConnectAfter


-- VVV Prop "advertised-protocols"
   -- Type: TCArray True (-1) (-1) (TBasicType TUTF8)
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Nothing,Just True)

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

@
'Data.GI.Base.Attributes.get' tlsConnection #advertisedProtocols
@
-}
getTlsConnectionAdvertisedProtocols :: (MonadIO m, IsTlsConnection o) => o -> m (Maybe [T.Text])
getTlsConnectionAdvertisedProtocols :: o -> m (Maybe [Text])
getTlsConnectionAdvertisedProtocols obj :: o
obj = IO (Maybe [Text]) -> m (Maybe [Text])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe [Text]) -> m (Maybe [Text]))
-> IO (Maybe [Text]) -> m (Maybe [Text])
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Maybe [Text])
forall a. GObject a => a -> String -> IO (Maybe [Text])
getObjectPropertyStringArray o
obj "advertised-protocols"

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

@
'Data.GI.Base.Attributes.set' tlsConnection [ #advertisedProtocols 'Data.GI.Base.Attributes.:=' value ]
@
-}
setTlsConnectionAdvertisedProtocols :: (MonadIO m, IsTlsConnection o) => o -> [T.Text] -> m ()
setTlsConnectionAdvertisedProtocols :: o -> [Text] -> m ()
setTlsConnectionAdvertisedProtocols obj :: o
obj val :: [Text]
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Maybe [Text] -> IO ()
forall a. GObject a => a -> String -> Maybe [Text] -> IO ()
setObjectPropertyStringArray o
obj "advertised-protocols" ([Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text]
val)

{- |
Construct a `GValueConstruct` with valid value for the “@advertised-protocols@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructTlsConnectionAdvertisedProtocols :: (IsTlsConnection o) => [T.Text] -> IO (GValueConstruct o)
constructTlsConnectionAdvertisedProtocols :: [Text] -> IO (GValueConstruct o)
constructTlsConnectionAdvertisedProtocols val :: [Text]
val = String -> Maybe [Text] -> IO (GValueConstruct o)
forall o. String -> Maybe [Text] -> IO (GValueConstruct o)
constructObjectPropertyStringArray "advertised-protocols" ([Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text]
val)

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

@
'Data.GI.Base.Attributes.clear' #advertisedProtocols
@
-}
clearTlsConnectionAdvertisedProtocols :: (MonadIO m, IsTlsConnection o) => o -> m ()
clearTlsConnectionAdvertisedProtocols :: o -> m ()
clearTlsConnectionAdvertisedProtocols obj :: o
obj = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Maybe [Text] -> IO ()
forall a. GObject a => a -> String -> Maybe [Text] -> IO ()
setObjectPropertyStringArray o
obj "advertised-protocols" (Maybe [Text]
forall a. Maybe a
Nothing :: Maybe [T.Text])

#if ENABLE_OVERLOADING
data TlsConnectionAdvertisedProtocolsPropertyInfo
instance AttrInfo TlsConnectionAdvertisedProtocolsPropertyInfo where
    type AttrAllowedOps TlsConnectionAdvertisedProtocolsPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint TlsConnectionAdvertisedProtocolsPropertyInfo = (~) [T.Text]
    type AttrBaseTypeConstraint TlsConnectionAdvertisedProtocolsPropertyInfo = IsTlsConnection
    type AttrGetType TlsConnectionAdvertisedProtocolsPropertyInfo = (Maybe [T.Text])
    type AttrLabel TlsConnectionAdvertisedProtocolsPropertyInfo = "advertised-protocols"
    type AttrOrigin TlsConnectionAdvertisedProtocolsPropertyInfo = TlsConnection
    attrGet _ = getTlsConnectionAdvertisedProtocols
    attrSet _ = setTlsConnectionAdvertisedProtocols
    attrConstruct _ = constructTlsConnectionAdvertisedProtocols
    attrClear _ = clearTlsConnectionAdvertisedProtocols
#endif

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

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

@
'Data.GI.Base.Attributes.get' tlsConnection #baseIoStream
@
-}
getTlsConnectionBaseIoStream :: (MonadIO m, IsTlsConnection o) => o -> m (Maybe Gio.IOStream.IOStream)
getTlsConnectionBaseIoStream :: o -> m (Maybe IOStream)
getTlsConnectionBaseIoStream obj :: o
obj = IO (Maybe IOStream) -> m (Maybe IOStream)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe IOStream) -> m (Maybe IOStream))
-> IO (Maybe IOStream) -> m (Maybe IOStream)
forall a b. (a -> b) -> a -> b
$ o
-> String
-> (ManagedPtr IOStream -> IOStream)
-> IO (Maybe IOStream)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
getObjectPropertyObject o
obj "base-io-stream" ManagedPtr IOStream -> IOStream
Gio.IOStream.IOStream

{- |
Construct a `GValueConstruct` with valid value for the “@base-io-stream@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructTlsConnectionBaseIoStream :: (IsTlsConnection o, Gio.IOStream.IsIOStream a) => a -> IO (GValueConstruct o)
constructTlsConnectionBaseIoStream :: a -> IO (GValueConstruct o)
constructTlsConnectionBaseIoStream val :: a
val = String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
constructObjectPropertyObject "base-io-stream" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

#if ENABLE_OVERLOADING
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
#endif

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

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

@
'Data.GI.Base.Attributes.get' tlsConnection #certificate
@
-}
getTlsConnectionCertificate :: (MonadIO m, IsTlsConnection o) => o -> m Gio.TlsCertificate.TlsCertificate
getTlsConnectionCertificate :: o -> m TlsCertificate
getTlsConnectionCertificate obj :: o
obj = IO TlsCertificate -> m TlsCertificate
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsCertificate -> m TlsCertificate)
-> IO TlsCertificate -> m TlsCertificate
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe TlsCertificate) -> IO TlsCertificate
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing "getTlsConnectionCertificate" (IO (Maybe TlsCertificate) -> IO TlsCertificate)
-> IO (Maybe TlsCertificate) -> IO TlsCertificate
forall a b. (a -> b) -> a -> b
$ o
-> String
-> (ManagedPtr TlsCertificate -> TlsCertificate)
-> IO (Maybe TlsCertificate)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
getObjectPropertyObject o
obj "certificate" ManagedPtr TlsCertificate -> TlsCertificate
Gio.TlsCertificate.TlsCertificate

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

@
'Data.GI.Base.Attributes.set' tlsConnection [ #certificate 'Data.GI.Base.Attributes.:=' value ]
@
-}
setTlsConnectionCertificate :: (MonadIO m, IsTlsConnection o, Gio.TlsCertificate.IsTlsCertificate a) => o -> a -> m ()
setTlsConnectionCertificate :: o -> a -> m ()
setTlsConnectionCertificate obj :: o
obj val :: a
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Maybe a -> IO ()
forall a b.
(GObject a, GObject b) =>
a -> String -> Maybe b -> IO ()
setObjectPropertyObject o
obj "certificate" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

{- |
Construct a `GValueConstruct` with valid value for the “@certificate@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructTlsConnectionCertificate :: (IsTlsConnection o, Gio.TlsCertificate.IsTlsCertificate a) => a -> IO (GValueConstruct o)
constructTlsConnectionCertificate :: a -> IO (GValueConstruct o)
constructTlsConnectionCertificate val :: a
val = String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
constructObjectPropertyObject "certificate" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

#if ENABLE_OVERLOADING
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
#endif

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

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

@
'Data.GI.Base.Attributes.get' tlsConnection #database
@
-}
getTlsConnectionDatabase :: (MonadIO m, IsTlsConnection o) => o -> m Gio.TlsDatabase.TlsDatabase
getTlsConnectionDatabase :: o -> m TlsDatabase
getTlsConnectionDatabase obj :: o
obj = IO TlsDatabase -> m TlsDatabase
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsDatabase -> m TlsDatabase)
-> IO TlsDatabase -> m TlsDatabase
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe TlsDatabase) -> IO TlsDatabase
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing "getTlsConnectionDatabase" (IO (Maybe TlsDatabase) -> IO TlsDatabase)
-> IO (Maybe TlsDatabase) -> IO TlsDatabase
forall a b. (a -> b) -> a -> b
$ o
-> String
-> (ManagedPtr TlsDatabase -> TlsDatabase)
-> IO (Maybe TlsDatabase)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
getObjectPropertyObject o
obj "database" ManagedPtr TlsDatabase -> TlsDatabase
Gio.TlsDatabase.TlsDatabase

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

@
'Data.GI.Base.Attributes.set' tlsConnection [ #database 'Data.GI.Base.Attributes.:=' value ]
@
-}
setTlsConnectionDatabase :: (MonadIO m, IsTlsConnection o, Gio.TlsDatabase.IsTlsDatabase a) => o -> a -> m ()
setTlsConnectionDatabase :: o -> a -> m ()
setTlsConnectionDatabase obj :: o
obj val :: a
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Maybe a -> IO ()
forall a b.
(GObject a, GObject b) =>
a -> String -> Maybe b -> IO ()
setObjectPropertyObject o
obj "database" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

{- |
Construct a `GValueConstruct` with valid value for the “@database@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructTlsConnectionDatabase :: (IsTlsConnection o, Gio.TlsDatabase.IsTlsDatabase a) => a -> IO (GValueConstruct o)
constructTlsConnectionDatabase :: a -> IO (GValueConstruct o)
constructTlsConnectionDatabase val :: a
val = String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
constructObjectPropertyObject "database" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

#if ENABLE_OVERLOADING
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
#endif

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

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

@
'Data.GI.Base.Attributes.get' tlsConnection #interaction
@
-}
getTlsConnectionInteraction :: (MonadIO m, IsTlsConnection o) => o -> m Gio.TlsInteraction.TlsInteraction
getTlsConnectionInteraction :: o -> m TlsInteraction
getTlsConnectionInteraction obj :: o
obj = IO TlsInteraction -> m TlsInteraction
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsInteraction -> m TlsInteraction)
-> IO TlsInteraction -> m TlsInteraction
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe TlsInteraction) -> IO TlsInteraction
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing "getTlsConnectionInteraction" (IO (Maybe TlsInteraction) -> IO TlsInteraction)
-> IO (Maybe TlsInteraction) -> IO TlsInteraction
forall a b. (a -> b) -> a -> b
$ o
-> String
-> (ManagedPtr TlsInteraction -> TlsInteraction)
-> IO (Maybe TlsInteraction)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
getObjectPropertyObject o
obj "interaction" ManagedPtr TlsInteraction -> TlsInteraction
Gio.TlsInteraction.TlsInteraction

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

@
'Data.GI.Base.Attributes.set' tlsConnection [ #interaction 'Data.GI.Base.Attributes.:=' value ]
@
-}
setTlsConnectionInteraction :: (MonadIO m, IsTlsConnection o, Gio.TlsInteraction.IsTlsInteraction a) => o -> a -> m ()
setTlsConnectionInteraction :: o -> a -> m ()
setTlsConnectionInteraction obj :: o
obj val :: a
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Maybe a -> IO ()
forall a b.
(GObject a, GObject b) =>
a -> String -> Maybe b -> IO ()
setObjectPropertyObject o
obj "interaction" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

{- |
Construct a `GValueConstruct` with valid value for the “@interaction@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructTlsConnectionInteraction :: (IsTlsConnection o, Gio.TlsInteraction.IsTlsInteraction a) => a -> IO (GValueConstruct o)
constructTlsConnectionInteraction :: a -> IO (GValueConstruct o)
constructTlsConnectionInteraction val :: a
val = String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
constructObjectPropertyObject "interaction" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

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

@
'Data.GI.Base.Attributes.clear' #interaction
@
-}
clearTlsConnectionInteraction :: (MonadIO m, IsTlsConnection o) => o -> m ()
clearTlsConnectionInteraction :: o -> m ()
clearTlsConnectionInteraction obj :: o
obj = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Maybe TlsInteraction -> IO ()
forall a b.
(GObject a, GObject b) =>
a -> String -> Maybe b -> IO ()
setObjectPropertyObject o
obj "interaction" (Maybe TlsInteraction
forall a. Maybe a
Nothing :: Maybe Gio.TlsInteraction.TlsInteraction)

#if ENABLE_OVERLOADING
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
#endif

-- VVV Prop "negotiated-protocol"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]
   -- Nullable: (Just True,Nothing)

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

@
'Data.GI.Base.Attributes.get' tlsConnection #negotiatedProtocol
@
-}
getTlsConnectionNegotiatedProtocol :: (MonadIO m, IsTlsConnection o) => o -> m (Maybe T.Text)
getTlsConnectionNegotiatedProtocol :: o -> m (Maybe Text)
getTlsConnectionNegotiatedProtocol obj :: o
obj = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Maybe Text)
forall a. GObject a => a -> String -> IO (Maybe Text)
getObjectPropertyString o
obj "negotiated-protocol"

#if ENABLE_OVERLOADING
data TlsConnectionNegotiatedProtocolPropertyInfo
instance AttrInfo TlsConnectionNegotiatedProtocolPropertyInfo where
    type AttrAllowedOps TlsConnectionNegotiatedProtocolPropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint TlsConnectionNegotiatedProtocolPropertyInfo = (~) ()
    type AttrBaseTypeConstraint TlsConnectionNegotiatedProtocolPropertyInfo = IsTlsConnection
    type AttrGetType TlsConnectionNegotiatedProtocolPropertyInfo = (Maybe T.Text)
    type AttrLabel TlsConnectionNegotiatedProtocolPropertyInfo = "negotiated-protocol"
    type AttrOrigin TlsConnectionNegotiatedProtocolPropertyInfo = TlsConnection
    attrGet _ = getTlsConnectionNegotiatedProtocol
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

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

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

@
'Data.GI.Base.Attributes.get' tlsConnection #peerCertificate
@
-}
getTlsConnectionPeerCertificate :: (MonadIO m, IsTlsConnection o) => o -> m Gio.TlsCertificate.TlsCertificate
getTlsConnectionPeerCertificate :: o -> m TlsCertificate
getTlsConnectionPeerCertificate obj :: o
obj = IO TlsCertificate -> m TlsCertificate
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsCertificate -> m TlsCertificate)
-> IO TlsCertificate -> m TlsCertificate
forall a b. (a -> b) -> a -> b
$ Text -> IO (Maybe TlsCertificate) -> IO TlsCertificate
forall a. HasCallStack => Text -> IO (Maybe a) -> IO a
checkUnexpectedNothing "getTlsConnectionPeerCertificate" (IO (Maybe TlsCertificate) -> IO TlsCertificate)
-> IO (Maybe TlsCertificate) -> IO TlsCertificate
forall a b. (a -> b) -> a -> b
$ o
-> String
-> (ManagedPtr TlsCertificate -> TlsCertificate)
-> IO (Maybe TlsCertificate)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
getObjectPropertyObject o
obj "peer-certificate" ManagedPtr TlsCertificate -> TlsCertificate
Gio.TlsCertificate.TlsCertificate

#if ENABLE_OVERLOADING
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
#endif

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

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

@
'Data.GI.Base.Attributes.get' tlsConnection #peerCertificateErrors
@
-}
getTlsConnectionPeerCertificateErrors :: (MonadIO m, IsTlsConnection o) => o -> m [Gio.Flags.TlsCertificateFlags]
getTlsConnectionPeerCertificateErrors :: o -> m [TlsCertificateFlags]
getTlsConnectionPeerCertificateErrors obj :: o
obj = IO [TlsCertificateFlags] -> m [TlsCertificateFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [TlsCertificateFlags] -> m [TlsCertificateFlags])
-> IO [TlsCertificateFlags] -> m [TlsCertificateFlags]
forall a b. (a -> b) -> a -> b
$ o -> String -> IO [TlsCertificateFlags]
forall a b.
(GObject a, IsGFlag b, BoxedFlags b) =>
a -> String -> IO [b]
getObjectPropertyFlags o
obj "peer-certificate-errors"

#if ENABLE_OVERLOADING
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
#endif

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

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

@
'Data.GI.Base.Attributes.get' tlsConnection #rehandshakeMode
@
-}
getTlsConnectionRehandshakeMode :: (MonadIO m, IsTlsConnection o) => o -> m Gio.Enums.TlsRehandshakeMode
getTlsConnectionRehandshakeMode :: o -> m TlsRehandshakeMode
getTlsConnectionRehandshakeMode obj :: o
obj = IO TlsRehandshakeMode -> m TlsRehandshakeMode
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsRehandshakeMode -> m TlsRehandshakeMode)
-> IO TlsRehandshakeMode -> m TlsRehandshakeMode
forall a b. (a -> b) -> a -> b
$ o -> String -> IO TlsRehandshakeMode
forall a b. (GObject a, Enum b, BoxedEnum b) => a -> String -> IO b
getObjectPropertyEnum o
obj "rehandshake-mode"

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

@
'Data.GI.Base.Attributes.set' tlsConnection [ #rehandshakeMode 'Data.GI.Base.Attributes.:=' value ]
@
-}
setTlsConnectionRehandshakeMode :: (MonadIO m, IsTlsConnection o) => o -> Gio.Enums.TlsRehandshakeMode -> m ()
setTlsConnectionRehandshakeMode :: o -> TlsRehandshakeMode -> m ()
setTlsConnectionRehandshakeMode obj :: o
obj val :: TlsRehandshakeMode
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> TlsRehandshakeMode -> IO ()
forall a b.
(GObject a, Enum b, BoxedEnum b) =>
a -> String -> b -> IO ()
setObjectPropertyEnum o
obj "rehandshake-mode" TlsRehandshakeMode
val

{- |
Construct a `GValueConstruct` with valid value for the “@rehandshake-mode@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructTlsConnectionRehandshakeMode :: (IsTlsConnection o) => Gio.Enums.TlsRehandshakeMode -> IO (GValueConstruct o)
constructTlsConnectionRehandshakeMode :: TlsRehandshakeMode -> IO (GValueConstruct o)
constructTlsConnectionRehandshakeMode val :: TlsRehandshakeMode
val = String -> TlsRehandshakeMode -> IO (GValueConstruct o)
forall a o.
(Enum a, BoxedEnum a) =>
String -> a -> IO (GValueConstruct o)
constructObjectPropertyEnum "rehandshake-mode" TlsRehandshakeMode
val

#if ENABLE_OVERLOADING
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
#endif

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

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

@
'Data.GI.Base.Attributes.get' tlsConnection #requireCloseNotify
@
-}
getTlsConnectionRequireCloseNotify :: (MonadIO m, IsTlsConnection o) => o -> m Bool
getTlsConnectionRequireCloseNotify :: o -> m Bool
getTlsConnectionRequireCloseNotify obj :: o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
getObjectPropertyBool o
obj "require-close-notify"

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

@
'Data.GI.Base.Attributes.set' tlsConnection [ #requireCloseNotify 'Data.GI.Base.Attributes.:=' value ]
@
-}
setTlsConnectionRequireCloseNotify :: (MonadIO m, IsTlsConnection o) => o -> Bool -> m ()
setTlsConnectionRequireCloseNotify :: o -> Bool -> m ()
setTlsConnectionRequireCloseNotify obj :: o
obj val :: Bool
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Bool -> IO ()
forall a. GObject a => a -> String -> Bool -> IO ()
setObjectPropertyBool o
obj "require-close-notify" Bool
val

{- |
Construct a `GValueConstruct` with valid value for the “@require-close-notify@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructTlsConnectionRequireCloseNotify :: (IsTlsConnection o) => Bool -> IO (GValueConstruct o)
constructTlsConnectionRequireCloseNotify :: Bool -> IO (GValueConstruct o)
constructTlsConnectionRequireCloseNotify val :: Bool
val = String -> Bool -> IO (GValueConstruct o)
forall o. String -> Bool -> IO (GValueConstruct o)
constructObjectPropertyBool "require-close-notify" Bool
val

#if ENABLE_OVERLOADING
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
#endif

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

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

@
'Data.GI.Base.Attributes.get' tlsConnection #useSystemCertdb
@
-}
getTlsConnectionUseSystemCertdb :: (MonadIO m, IsTlsConnection o) => o -> m Bool
getTlsConnectionUseSystemCertdb :: o -> m Bool
getTlsConnectionUseSystemCertdb obj :: o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
getObjectPropertyBool o
obj "use-system-certdb"

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

@
'Data.GI.Base.Attributes.set' tlsConnection [ #useSystemCertdb 'Data.GI.Base.Attributes.:=' value ]
@
-}
setTlsConnectionUseSystemCertdb :: (MonadIO m, IsTlsConnection o) => o -> Bool -> m ()
setTlsConnectionUseSystemCertdb :: o -> Bool -> m ()
setTlsConnectionUseSystemCertdb obj :: o
obj val :: Bool
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ o -> String -> Bool -> IO ()
forall a. GObject a => a -> String -> Bool -> IO ()
setObjectPropertyBool o
obj "use-system-certdb" Bool
val

{- |
Construct a `GValueConstruct` with valid value for the “@use-system-certdb@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructTlsConnectionUseSystemCertdb :: (IsTlsConnection o) => Bool -> IO (GValueConstruct o)
constructTlsConnectionUseSystemCertdb :: Bool -> IO (GValueConstruct o)
constructTlsConnectionUseSystemCertdb val :: Bool
val = String -> Bool -> IO (GValueConstruct o)
forall o. String -> Bool -> IO (GValueConstruct o)
constructObjectPropertyBool "use-system-certdb" Bool
val

#if ENABLE_OVERLOADING
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
#endif

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

#if ENABLE_OVERLOADING
tlsConnectionAdvertisedProtocols :: AttrLabelProxy "advertisedProtocols"
tlsConnectionAdvertisedProtocols = AttrLabelProxy

tlsConnectionBaseIoStream :: AttrLabelProxy "baseIoStream"
tlsConnectionBaseIoStream = AttrLabelProxy

tlsConnectionCertificate :: AttrLabelProxy "certificate"
tlsConnectionCertificate = AttrLabelProxy

tlsConnectionDatabase :: AttrLabelProxy "database"
tlsConnectionDatabase = AttrLabelProxy

tlsConnectionInteraction :: AttrLabelProxy "interaction"
tlsConnectionInteraction = AttrLabelProxy

tlsConnectionNegotiatedProtocol :: AttrLabelProxy "negotiatedProtocol"
tlsConnectionNegotiatedProtocol = 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

#endif

#if ENABLE_OVERLOADING
data TlsConnectionAcceptCertificateSignalInfo
instance SignalInfo TlsConnectionAcceptCertificateSignalInfo where
    type HaskellCallbackType TlsConnectionAcceptCertificateSignalInfo = TlsConnectionAcceptCertificateCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_TlsConnectionAcceptCertificateCallback cb
        cb'' <- mk_TlsConnectionAcceptCertificateCallback cb'
        connectSignalFunPtr obj "accept-certificate" cb'' connectMode

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

#endif

-- 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 :: a -> b -> [TlsCertificateFlags] -> m Bool
tlsConnectionEmitAcceptCertificate conn :: a
conn peerCert :: b
peerCert errors :: [TlsCertificateFlags]
errors = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr TlsCertificate
peerCert' <- b -> IO (Ptr TlsCertificate)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
peerCert
    let errors' :: CUInt
errors' = [TlsCertificateFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [TlsCertificateFlags]
errors
    CInt
result <- Ptr TlsConnection -> Ptr TlsCertificate -> CUInt -> IO CInt
g_tls_connection_emit_accept_certificate Ptr TlsConnection
conn' Ptr TlsCertificate
peerCert' CUInt
errors'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
peerCert
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
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

#endif

-- 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 :: a -> m TlsCertificate
tlsConnectionGetCertificate conn :: a
conn = IO TlsCertificate -> m TlsCertificate
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsCertificate -> m TlsCertificate)
-> IO TlsCertificate -> m TlsCertificate
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr TlsCertificate
result <- Ptr TlsConnection -> IO (Ptr TlsCertificate)
g_tls_connection_get_certificate Ptr TlsConnection
conn'
    Text -> Ptr TlsCertificate -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "tlsConnectionGetCertificate" Ptr TlsCertificate
result
    TlsCertificate
result' <- ((ManagedPtr TlsCertificate -> TlsCertificate)
-> Ptr TlsCertificate -> IO TlsCertificate
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr TlsCertificate -> TlsCertificate
Gio.TlsCertificate.TlsCertificate) Ptr TlsCertificate
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    TlsCertificate -> IO TlsCertificate
forall (m :: * -> *) a. Monad m => a -> m a
return TlsCertificate
result'

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

#endif

-- 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 :: a -> m TlsDatabase
tlsConnectionGetDatabase conn :: a
conn = IO TlsDatabase -> m TlsDatabase
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsDatabase -> m TlsDatabase)
-> IO TlsDatabase -> m TlsDatabase
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr TlsDatabase
result <- Ptr TlsConnection -> IO (Ptr TlsDatabase)
g_tls_connection_get_database Ptr TlsConnection
conn'
    Text -> Ptr TlsDatabase -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "tlsConnectionGetDatabase" Ptr TlsDatabase
result
    TlsDatabase
result' <- ((ManagedPtr TlsDatabase -> TlsDatabase)
-> Ptr TlsDatabase -> IO TlsDatabase
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr TlsDatabase -> TlsDatabase
Gio.TlsDatabase.TlsDatabase) Ptr TlsDatabase
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    TlsDatabase -> IO TlsDatabase
forall (m :: * -> *) a. Monad m => a -> m a
return TlsDatabase
result'

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

#endif

-- 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 :: a -> m TlsInteraction
tlsConnectionGetInteraction conn :: a
conn = IO TlsInteraction -> m TlsInteraction
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsInteraction -> m TlsInteraction)
-> IO TlsInteraction -> m TlsInteraction
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr TlsInteraction
result <- Ptr TlsConnection -> IO (Ptr TlsInteraction)
g_tls_connection_get_interaction Ptr TlsConnection
conn'
    Text -> Ptr TlsInteraction -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "tlsConnectionGetInteraction" Ptr TlsInteraction
result
    TlsInteraction
result' <- ((ManagedPtr TlsInteraction -> TlsInteraction)
-> Ptr TlsInteraction -> IO TlsInteraction
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr TlsInteraction -> TlsInteraction
Gio.TlsInteraction.TlsInteraction) Ptr TlsInteraction
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    TlsInteraction -> IO TlsInteraction
forall (m :: * -> *) a. Monad m => a -> m a
return TlsInteraction
result'

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

#endif

-- method TlsConnection::get_negotiated_protocol
-- 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 TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_tls_connection_get_negotiated_protocol" g_tls_connection_get_negotiated_protocol :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    IO CString

{- |
Gets the name of the application-layer protocol negotiated during
the handshake.

If the peer did not use the ALPN extension, or did not advertise a
protocol that matched one of /@conn@/\'s protocols, or the TLS backend
does not support ALPN, then this will be 'Nothing'. See
'GI.Gio.Objects.TlsConnection.tlsConnectionSetAdvertisedProtocols'.

/Since: 2.60/
-}
tlsConnectionGetNegotiatedProtocol ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the negotiated protocol, or 'Nothing' -}
tlsConnectionGetNegotiatedProtocol :: a -> m (Maybe Text)
tlsConnectionGetNegotiatedProtocol conn :: a
conn = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    CString
result <- Ptr TlsConnection -> IO CString
g_tls_connection_get_negotiated_protocol Ptr TlsConnection
conn'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult

#if ENABLE_OVERLOADING
data TlsConnectionGetNegotiatedProtocolMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionGetNegotiatedProtocolMethodInfo a signature where
    overloadedMethod _ = tlsConnectionGetNegotiatedProtocol

#endif

-- 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 :: a -> m TlsCertificate
tlsConnectionGetPeerCertificate conn :: a
conn = IO TlsCertificate -> m TlsCertificate
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsCertificate -> m TlsCertificate)
-> IO TlsCertificate -> m TlsCertificate
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr TlsCertificate
result <- Ptr TlsConnection -> IO (Ptr TlsCertificate)
g_tls_connection_get_peer_certificate Ptr TlsConnection
conn'
    Text -> Ptr TlsCertificate -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "tlsConnectionGetPeerCertificate" Ptr TlsCertificate
result
    TlsCertificate
result' <- ((ManagedPtr TlsCertificate -> TlsCertificate)
-> Ptr TlsCertificate -> IO TlsCertificate
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr TlsCertificate -> TlsCertificate
Gio.TlsCertificate.TlsCertificate) Ptr TlsCertificate
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    TlsCertificate -> IO TlsCertificate
forall (m :: * -> *) a. Monad m => a -> m a
return TlsCertificate
result'

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

#endif

-- 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 :: a -> m [TlsCertificateFlags]
tlsConnectionGetPeerCertificateErrors conn :: a
conn = IO [TlsCertificateFlags] -> m [TlsCertificateFlags]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [TlsCertificateFlags] -> m [TlsCertificateFlags])
-> IO [TlsCertificateFlags] -> m [TlsCertificateFlags]
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    CUInt
result <- Ptr TlsConnection -> IO CUInt
g_tls_connection_get_peer_certificate_errors Ptr TlsConnection
conn'
    let result' :: [TlsCertificateFlags]
result' = CUInt -> [TlsCertificateFlags]
forall a b. (Storable a, Integral a, Bits a, IsGFlag b) => a -> [b]
wordToGFlags CUInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    [TlsCertificateFlags] -> IO [TlsCertificateFlags]
forall (m :: * -> *) a. Monad m => a -> m a
return [TlsCertificateFlags]
result'

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

#endif

-- 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

{-# DEPRECATED tlsConnectionGetRehandshakeMode ["(Since version 2.60.)","Changing the rehandshake mode is no longer","  required for compatibility. Also, rehandshaking has been removed","  from the TLS protocol in TLS 1.3."] #-}
{- |
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:__ 'GI.Gio.Enums.TlsRehandshakeModeSafely' -}
tlsConnectionGetRehandshakeMode :: a -> m TlsRehandshakeMode
tlsConnectionGetRehandshakeMode conn :: a
conn = IO TlsRehandshakeMode -> m TlsRehandshakeMode
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsRehandshakeMode -> m TlsRehandshakeMode)
-> IO TlsRehandshakeMode -> m TlsRehandshakeMode
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    CUInt
result <- Ptr TlsConnection -> IO CUInt
g_tls_connection_get_rehandshake_mode Ptr TlsConnection
conn'
    let result' :: TlsRehandshakeMode
result' = (Int -> TlsRehandshakeMode
forall a. Enum a => Int -> a
toEnum (Int -> TlsRehandshakeMode)
-> (CUInt -> Int) -> CUInt -> TlsRehandshakeMode
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    TlsRehandshakeMode -> IO TlsRehandshakeMode
forall (m :: * -> *) a. Monad m => a -> m a
return TlsRehandshakeMode
result'

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

#endif

-- 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 :: a -> m Bool
tlsConnectionGetRequireCloseNotify conn :: a
conn = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    CInt
result <- Ptr TlsConnection -> IO CInt
g_tls_connection_get_require_close_notify Ptr TlsConnection
conn'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

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

#endif

-- 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 :: a -> m Bool
tlsConnectionGetUseSystemCertdb conn :: a
conn = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    CInt
result <- Ptr TlsConnection -> IO CInt
g_tls_connection_get_use_system_certdb Ptr TlsConnection
conn'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

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

#endif

-- 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),
'GI.Gio.Objects.TlsConnection.TlsConnection' will handle this for you automatically when you try
to send or receive data on the connection. You can call
'GI.Gio.Objects.TlsConnection.tlsConnectionHandshake' manually if you want to know whether
the initial handshake succeeded or failed (as opposed to just
immediately trying to use /@conn@/ to read or write, in which case,
if it fails, it may not be possible to tell if it failed before or
after completing the handshake), but beware that servers may reject
client authentication after the handshake has completed, so a
successful handshake does not indicate the connection will be usable.

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.

Previously, calling 'GI.Gio.Objects.TlsConnection.tlsConnectionHandshake' after the initial
handshake would trigger a rehandshake; however, this usage was
deprecated in GLib 2.60 because rehandshaking was removed from the
TLS protocol in TLS 1.3. Since GLib 2.64, calling this function after
the initial handshake will no longer do anything.

When using a 'GI.Gio.Objects.TlsConnection.TlsConnection' created by 'GI.Gio.Objects.SocketClient.SocketClient', the
'GI.Gio.Objects.SocketClient.SocketClient' performs the initial handshake, so calling this
function manually is not recommended.

'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 :: a -> Maybe b -> m ()
tlsConnectionHandshake conn :: a
conn cancellable :: Maybe b
cancellable = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr TlsConnection -> Ptr Cancellable -> Ptr (Ptr GError) -> IO CInt
g_tls_connection_handshake Ptr TlsConnection
conn' Ptr Cancellable
maybeCancellable
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

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

#endif

-- 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 :: a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
tlsConnectionHandshakeAsync conn :: a
conn ioPriority :: Int32
ioPriority cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr TlsConnection
-> Int32
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_tls_connection_handshake_async Ptr TlsConnection
conn' Int32
ioPriority Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
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

#endif

-- 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 :: a -> b -> m ()
tlsConnectionHandshakeFinish conn :: a
conn result_ :: b
result_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr TlsConnection -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_tls_connection_handshake_finish Ptr TlsConnection
conn' Ptr AsyncResult
result_'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

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

#endif

-- method TlsConnection::set_advertised_protocols
-- 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 = "protocols", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a %NULL-terminated\n  array of ALPN protocol names (eg, \"http/1.1\", \"h2\"), 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_advertised_protocols" g_tls_connection_set_advertised_protocols :: 
    Ptr TlsConnection ->                    -- conn : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    Ptr CString ->                          -- protocols : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO ()

{- |
Sets the list of application-layer protocols to advertise that the
caller is willing to speak on this connection. The
Application-Layer Protocol Negotiation (ALPN) extension will be
used to negotiate a compatible protocol with the peer; use
'GI.Gio.Objects.TlsConnection.tlsConnectionGetNegotiatedProtocol' to find the negotiated
protocol after the handshake.  Specifying 'Nothing' for the the value
of /@protocols@/ will disable ALPN negotiation.

See <https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids IANA TLS ALPN Protocol IDs>
for a list of registered protocol IDs.

/Since: 2.60/
-}
tlsConnectionSetAdvertisedProtocols ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsConnection a) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' -}
    -> Maybe ([T.Text])
    {- ^ /@protocols@/: a 'Nothing'-terminated
  array of ALPN protocol names (eg, \"http\/1.1\", \"h2\"), or 'Nothing' -}
    -> m ()
tlsConnectionSetAdvertisedProtocols :: a -> Maybe [Text] -> m ()
tlsConnectionSetAdvertisedProtocols conn :: a
conn protocols :: Maybe [Text]
protocols = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr CString
maybeProtocols <- case Maybe [Text]
protocols of
        Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just jProtocols :: [Text]
jProtocols -> do
            Ptr CString
jProtocols' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jProtocols
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jProtocols'
    Ptr TlsConnection -> Ptr CString -> IO ()
g_tls_connection_set_advertised_protocols Ptr TlsConnection
conn' Ptr CString
maybeProtocols
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data TlsConnectionSetAdvertisedProtocolsMethodInfo
instance (signature ~ (Maybe ([T.Text]) -> m ()), MonadIO m, IsTlsConnection a) => O.MethodInfo TlsConnectionSetAdvertisedProtocolsMethodInfo a signature where
    overloadedMethod _ = tlsConnectionSetAdvertisedProtocols

#endif

-- 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 :: a -> b -> m ()
tlsConnectionSetCertificate conn :: a
conn certificate :: b
certificate = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr TlsCertificate
certificate' <- b -> IO (Ptr TlsCertificate)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
certificate
    Ptr TlsConnection -> Ptr TlsCertificate -> IO ()
g_tls_connection_set_certificate Ptr TlsConnection
conn' Ptr TlsCertificate
certificate'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
certificate
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

#endif

-- 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 :: a -> b -> m ()
tlsConnectionSetDatabase conn :: a
conn database :: b
database = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr TlsDatabase
database' <- b -> IO (Ptr TlsDatabase)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
database
    Ptr TlsConnection -> Ptr TlsDatabase -> IO ()
g_tls_connection_set_database Ptr TlsConnection
conn' Ptr TlsDatabase
database'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
database
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

#endif

-- 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 :: a -> Maybe b -> m ()
tlsConnectionSetInteraction conn :: a
conn interaction :: Maybe b
interaction = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    Ptr TlsInteraction
maybeInteraction <- case Maybe b
interaction of
        Nothing -> Ptr TlsInteraction -> IO (Ptr TlsInteraction)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr TlsInteraction
forall a. Ptr a
nullPtr
        Just jInteraction :: b
jInteraction -> do
            Ptr TlsInteraction
jInteraction' <- b -> IO (Ptr TlsInteraction)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jInteraction
            Ptr TlsInteraction -> IO (Ptr TlsInteraction)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr TlsInteraction
jInteraction'
    Ptr TlsConnection -> Ptr TlsInteraction -> IO ()
g_tls_connection_set_interaction Ptr TlsConnection
conn' Ptr TlsInteraction
maybeInteraction
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
interaction b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

#endif

-- 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 ()

{-# DEPRECATED tlsConnectionSetRehandshakeMode ["(Since version 2.60.)","Changing the rehandshake mode is no longer","  required for compatibility. Also, rehandshaking has been removed","  from the TLS protocol in TLS 1.3."] #-}
{- |
Since GLib 2.64, changing the rehandshake mode is no longer supported
and will have no effect. With TLS 1.3, rehandshaking has been removed from
the TLS protocol, replaced by separate post-handshake authentication and
rekey operations.

/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 :: a -> TlsRehandshakeMode -> m ()
tlsConnectionSetRehandshakeMode conn :: a
conn mode :: TlsRehandshakeMode
mode = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    let mode' :: CUInt
mode' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (TlsRehandshakeMode -> Int) -> TlsRehandshakeMode -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TlsRehandshakeMode -> Int
forall a. Enum a => a -> Int
fromEnum) TlsRehandshakeMode
mode
    Ptr TlsConnection -> CUInt -> IO ()
g_tls_connection_set_rehandshake_mode Ptr TlsConnection
conn' CUInt
mode'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

#endif

-- 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 :: a -> Bool -> m ()
tlsConnectionSetRequireCloseNotify conn :: a
conn requireCloseNotify :: Bool
requireCloseNotify = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    let requireCloseNotify' :: CInt
requireCloseNotify' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
requireCloseNotify
    Ptr TlsConnection -> CInt -> IO ()
g_tls_connection_set_require_close_notify Ptr TlsConnection
conn' CInt
requireCloseNotify'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

#endif

-- 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 :: a -> Bool -> m ()
tlsConnectionSetUseSystemCertdb conn :: a
conn useSystemCertdb :: Bool
useSystemCertdb = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsConnection
conn' <- a -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
conn
    let useSystemCertdb' :: CInt
useSystemCertdb' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
useSystemCertdb
    Ptr TlsConnection -> CInt -> IO ()
g_tls_connection_set_use_system_certdb Ptr TlsConnection
conn' CInt
useSystemCertdb'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
conn
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

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

#endif