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

'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' is the client-side subclass of
'GI.Gio.Objects.TlsConnection.TlsConnection', representing a client-side TLS connection.
-}

module GI.Gio.Interfaces.TlsClientConnection
    ( 

-- * Exported types
    TlsClientConnection(..)                 ,
    noTlsClientConnection                   ,
    IsTlsClientConnection                   ,
    toTlsClientConnection                   ,


 -- * Methods
-- ** copySessionState #method:copySessionState#
    TlsClientConnectionCopySessionStateMethodInfo,
    tlsClientConnectionCopySessionState     ,


-- ** getAcceptedCas #method:getAcceptedCas#
    TlsClientConnectionGetAcceptedCasMethodInfo,
    tlsClientConnectionGetAcceptedCas       ,


-- ** getServerIdentity #method:getServerIdentity#
    TlsClientConnectionGetServerIdentityMethodInfo,
    tlsClientConnectionGetServerIdentity    ,


-- ** getUseSsl3 #method:getUseSsl3#
    TlsClientConnectionGetUseSsl3MethodInfo ,
    tlsClientConnectionGetUseSsl3           ,


-- ** getValidationFlags #method:getValidationFlags#
    TlsClientConnectionGetValidationFlagsMethodInfo,
    tlsClientConnectionGetValidationFlags   ,


-- ** new #method:new#
    tlsClientConnectionNew                  ,


-- ** setServerIdentity #method:setServerIdentity#
    TlsClientConnectionSetServerIdentityMethodInfo,
    tlsClientConnectionSetServerIdentity    ,


-- ** setUseSsl3 #method:setUseSsl3#
    TlsClientConnectionSetUseSsl3MethodInfo ,
    tlsClientConnectionSetUseSsl3           ,


-- ** setValidationFlags #method:setValidationFlags#
    TlsClientConnectionSetValidationFlagsMethodInfo,
    tlsClientConnectionSetValidationFlags   ,




 -- * Properties
-- ** acceptedCas #attr:acceptedCas#
    TlsClientConnectionAcceptedCasPropertyInfo,
    getTlsClientConnectionAcceptedCas       ,
    tlsClientConnectionAcceptedCas          ,


-- ** serverIdentity #attr:serverIdentity#
    TlsClientConnectionServerIdentityPropertyInfo,
    constructTlsClientConnectionServerIdentity,
    getTlsClientConnectionServerIdentity    ,
    setTlsClientConnectionServerIdentity    ,
    tlsClientConnectionServerIdentity       ,


-- ** useSsl3 #attr:useSsl3#
    TlsClientConnectionUseSsl3PropertyInfo  ,
    constructTlsClientConnectionUseSsl3     ,
    getTlsClientConnectionUseSsl3           ,
    setTlsClientConnectionUseSsl3           ,
    tlsClientConnectionUseSsl3              ,


-- ** validationFlags #attr:validationFlags#
    TlsClientConnectionValidationFlagsPropertyInfo,
    constructTlsClientConnectionValidationFlags,
    getTlsClientConnectionValidationFlags   ,
    setTlsClientConnectionValidationFlags   ,
    tlsClientConnectionValidationFlags      ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Interfaces.SocketConnectable as Gio.SocketConnectable
import {-# SOURCE #-} qualified GI.Gio.Objects.IOStream as Gio.IOStream
import {-# SOURCE #-} qualified GI.Gio.Objects.TlsConnection as Gio.TlsConnection

-- interface TlsClientConnection 
newtype TlsClientConnection = TlsClientConnection (ManagedPtr TlsClientConnection)
noTlsClientConnection :: Maybe TlsClientConnection
noTlsClientConnection = Nothing

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

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

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

-- VVV Prop "accepted-cas"
   -- Type: TGList (TBasicType TPtr)
   -- Flags: [PropertyReadable]
   -- Nullable: (Nothing,Nothing)

getTlsClientConnectionAcceptedCas :: (MonadIO m, IsTlsClientConnection o) => o -> m [Ptr ()]
getTlsClientConnectionAcceptedCas obj = liftIO $ getObjectPropertyPtrGList obj "accepted-cas"

data TlsClientConnectionAcceptedCasPropertyInfo
instance AttrInfo TlsClientConnectionAcceptedCasPropertyInfo where
    type AttrAllowedOps TlsClientConnectionAcceptedCasPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint TlsClientConnectionAcceptedCasPropertyInfo = (~) ()
    type AttrBaseTypeConstraint TlsClientConnectionAcceptedCasPropertyInfo = IsTlsClientConnection
    type AttrGetType TlsClientConnectionAcceptedCasPropertyInfo = ([Ptr ()])
    type AttrLabel TlsClientConnectionAcceptedCasPropertyInfo = "accepted-cas"
    type AttrOrigin TlsClientConnectionAcceptedCasPropertyInfo = TlsClientConnection
    attrGet _ = getTlsClientConnectionAcceptedCas
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

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

getTlsClientConnectionServerIdentity :: (MonadIO m, IsTlsClientConnection o) => o -> m Gio.SocketConnectable.SocketConnectable
getTlsClientConnectionServerIdentity obj = liftIO $ checkUnexpectedNothing "getTlsClientConnectionServerIdentity" $ getObjectPropertyObject obj "server-identity" Gio.SocketConnectable.SocketConnectable

setTlsClientConnectionServerIdentity :: (MonadIO m, IsTlsClientConnection o, Gio.SocketConnectable.IsSocketConnectable a) => o -> a -> m ()
setTlsClientConnectionServerIdentity obj val = liftIO $ setObjectPropertyObject obj "server-identity" (Just val)

constructTlsClientConnectionServerIdentity :: (IsTlsClientConnection o, Gio.SocketConnectable.IsSocketConnectable a) => a -> IO (GValueConstruct o)
constructTlsClientConnectionServerIdentity val = constructObjectPropertyObject "server-identity" (Just val)

data TlsClientConnectionServerIdentityPropertyInfo
instance AttrInfo TlsClientConnectionServerIdentityPropertyInfo where
    type AttrAllowedOps TlsClientConnectionServerIdentityPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint TlsClientConnectionServerIdentityPropertyInfo = Gio.SocketConnectable.IsSocketConnectable
    type AttrBaseTypeConstraint TlsClientConnectionServerIdentityPropertyInfo = IsTlsClientConnection
    type AttrGetType TlsClientConnectionServerIdentityPropertyInfo = Gio.SocketConnectable.SocketConnectable
    type AttrLabel TlsClientConnectionServerIdentityPropertyInfo = "server-identity"
    type AttrOrigin TlsClientConnectionServerIdentityPropertyInfo = TlsClientConnection
    attrGet _ = getTlsClientConnectionServerIdentity
    attrSet _ = setTlsClientConnectionServerIdentity
    attrConstruct _ = constructTlsClientConnectionServerIdentity
    attrClear _ = undefined

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

getTlsClientConnectionUseSsl3 :: (MonadIO m, IsTlsClientConnection o) => o -> m Bool
getTlsClientConnectionUseSsl3 obj = liftIO $ getObjectPropertyBool obj "use-ssl3"

setTlsClientConnectionUseSsl3 :: (MonadIO m, IsTlsClientConnection o) => o -> Bool -> m ()
setTlsClientConnectionUseSsl3 obj val = liftIO $ setObjectPropertyBool obj "use-ssl3" val

constructTlsClientConnectionUseSsl3 :: (IsTlsClientConnection o) => Bool -> IO (GValueConstruct o)
constructTlsClientConnectionUseSsl3 val = constructObjectPropertyBool "use-ssl3" val

data TlsClientConnectionUseSsl3PropertyInfo
instance AttrInfo TlsClientConnectionUseSsl3PropertyInfo where
    type AttrAllowedOps TlsClientConnectionUseSsl3PropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint TlsClientConnectionUseSsl3PropertyInfo = (~) Bool
    type AttrBaseTypeConstraint TlsClientConnectionUseSsl3PropertyInfo = IsTlsClientConnection
    type AttrGetType TlsClientConnectionUseSsl3PropertyInfo = Bool
    type AttrLabel TlsClientConnectionUseSsl3PropertyInfo = "use-ssl3"
    type AttrOrigin TlsClientConnectionUseSsl3PropertyInfo = TlsClientConnection
    attrGet _ = getTlsClientConnectionUseSsl3
    attrSet _ = setTlsClientConnectionUseSsl3
    attrConstruct _ = constructTlsClientConnectionUseSsl3
    attrClear _ = undefined

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

getTlsClientConnectionValidationFlags :: (MonadIO m, IsTlsClientConnection o) => o -> m [Gio.Flags.TlsCertificateFlags]
getTlsClientConnectionValidationFlags obj = liftIO $ getObjectPropertyFlags obj "validation-flags"

setTlsClientConnectionValidationFlags :: (MonadIO m, IsTlsClientConnection o) => o -> [Gio.Flags.TlsCertificateFlags] -> m ()
setTlsClientConnectionValidationFlags obj val = liftIO $ setObjectPropertyFlags obj "validation-flags" val

constructTlsClientConnectionValidationFlags :: (IsTlsClientConnection o) => [Gio.Flags.TlsCertificateFlags] -> IO (GValueConstruct o)
constructTlsClientConnectionValidationFlags val = constructObjectPropertyFlags "validation-flags" val

data TlsClientConnectionValidationFlagsPropertyInfo
instance AttrInfo TlsClientConnectionValidationFlagsPropertyInfo where
    type AttrAllowedOps TlsClientConnectionValidationFlagsPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint TlsClientConnectionValidationFlagsPropertyInfo = (~) [Gio.Flags.TlsCertificateFlags]
    type AttrBaseTypeConstraint TlsClientConnectionValidationFlagsPropertyInfo = IsTlsClientConnection
    type AttrGetType TlsClientConnectionValidationFlagsPropertyInfo = [Gio.Flags.TlsCertificateFlags]
    type AttrLabel TlsClientConnectionValidationFlagsPropertyInfo = "validation-flags"
    type AttrOrigin TlsClientConnectionValidationFlagsPropertyInfo = TlsClientConnection
    attrGet _ = getTlsClientConnectionValidationFlags
    attrSet _ = setTlsClientConnectionValidationFlags
    attrConstruct _ = constructTlsClientConnectionValidationFlags
    attrClear _ = undefined

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

tlsClientConnectionAcceptedCas :: AttrLabelProxy "acceptedCas"
tlsClientConnectionAcceptedCas = AttrLabelProxy

tlsClientConnectionServerIdentity :: AttrLabelProxy "serverIdentity"
tlsClientConnectionServerIdentity = AttrLabelProxy

tlsClientConnectionUseSsl3 :: AttrLabelProxy "useSsl3"
tlsClientConnectionUseSsl3 = AttrLabelProxy

tlsClientConnectionValidationFlags :: AttrLabelProxy "validationFlags"
tlsClientConnectionValidationFlags = AttrLabelProxy

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

foreign import ccall "g_tls_client_connection_get_type"
    c_g_tls_client_connection_get_type :: IO GType

instance GObject TlsClientConnection where
    gobjectType _ = c_g_tls_client_connection_get_type
    

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

toTlsClientConnection :: IsTlsClientConnection o => o -> IO TlsClientConnection
toTlsClientConnection = unsafeCastTo TlsClientConnection

-- method TlsClientConnection::copy_session_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsClientConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsClientConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "source", argType = TInterface (Name {namespace = "Gio", name = "TlsClientConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GTlsClientConnection", 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_client_connection_copy_session_state" g_tls_client_connection_copy_session_state :: 
    Ptr TlsClientConnection ->              -- conn : TInterface (Name {namespace = "Gio", name = "TlsClientConnection"})
    Ptr TlsClientConnection ->              -- source : TInterface (Name {namespace = "Gio", name = "TlsClientConnection"})
    IO ()

{- |
Copies session state from one connection to another. This is
not normally needed, but may be used when the same session
needs to be used between different endpoints as is required
by some protocols such as FTP over TLS. /@source@/ should have
already completed a handshake, and /@conn@/ should not have
completed a handshake.

@since 2.46
-}
tlsClientConnectionCopySessionState ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsClientConnection a, IsTlsClientConnection b) =>
    a
    {- ^ /@conn@/: a 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' -}
    -> b
    {- ^ /@source@/: a 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' -}
    -> m ()
tlsClientConnectionCopySessionState conn source = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    source' <- unsafeManagedPtrCastPtr source
    g_tls_client_connection_copy_session_state conn' source'
    touchManagedPtr conn
    touchManagedPtr source
    return ()

data TlsClientConnectionCopySessionStateMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsTlsClientConnection a, IsTlsClientConnection b) => O.MethodInfo TlsClientConnectionCopySessionStateMethodInfo a signature where
    overloadedMethod _ = tlsClientConnectionCopySessionState

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

foreign import ccall "g_tls_client_connection_get_accepted_cas" g_tls_client_connection_get_accepted_cas :: 
    Ptr TlsClientConnection ->              -- conn : TInterface (Name {namespace = "Gio", name = "TlsClientConnection"})
    IO (Ptr (GList (Ptr GByteArray)))

{- |
Gets the list of distinguished names of the Certificate Authorities
that the server will accept certificates from. This will be set
during the TLS handshake if the server requests a certificate.
Otherwise, it will be 'Nothing'.

Each item in the list is a 'GI.GLib.Structs.ByteArray.ByteArray' which contains the complete
subject DN of the certificate authority.

@since 2.28
-}
tlsClientConnectionGetAcceptedCas ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsClientConnection a) =>
    a
    {- ^ /@conn@/: the 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' -}
    -> m [ByteString]
    {- ^ __Returns:__ the list of
CA DNs. You should unref each element with 'GI.GLib.Functions.byteArrayUnref' and then
the free the list with @/g_list_free()/@. -}
tlsClientConnectionGetAcceptedCas conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_client_connection_get_accepted_cas conn'
    result' <- unpackGList result
    result'' <- mapM unpackGByteArray result'
    mapGList unrefGByteArray result
    g_list_free result
    touchManagedPtr conn
    return result''

data TlsClientConnectionGetAcceptedCasMethodInfo
instance (signature ~ (m [ByteString]), MonadIO m, IsTlsClientConnection a) => O.MethodInfo TlsClientConnectionGetAcceptedCasMethodInfo a signature where
    overloadedMethod _ = tlsClientConnectionGetAcceptedCas

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

foreign import ccall "g_tls_client_connection_get_server_identity" g_tls_client_connection_get_server_identity :: 
    Ptr TlsClientConnection ->              -- conn : TInterface (Name {namespace = "Gio", name = "TlsClientConnection"})
    IO (Ptr Gio.SocketConnectable.SocketConnectable)

{- |
Gets /@conn@/\'s expected server identity

@since 2.28
-}
tlsClientConnectionGetServerIdentity ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsClientConnection a) =>
    a
    {- ^ /@conn@/: the 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' -}
    -> m Gio.SocketConnectable.SocketConnectable
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.SocketConnectable.SocketConnectable' describing the
expected server identity, or 'Nothing' if the expected identity is not
known. -}
tlsClientConnectionGetServerIdentity conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_client_connection_get_server_identity conn'
    checkUnexpectedReturnNULL "tlsClientConnectionGetServerIdentity" result
    result' <- (newObject Gio.SocketConnectable.SocketConnectable) result
    touchManagedPtr conn
    return result'

data TlsClientConnectionGetServerIdentityMethodInfo
instance (signature ~ (m Gio.SocketConnectable.SocketConnectable), MonadIO m, IsTlsClientConnection a) => O.MethodInfo TlsClientConnectionGetServerIdentityMethodInfo a signature where
    overloadedMethod _ = tlsClientConnectionGetServerIdentity

-- method TlsClientConnection::get_use_ssl3
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsClientConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTlsClientConnection", 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_client_connection_get_use_ssl3" g_tls_client_connection_get_use_ssl3 :: 
    Ptr TlsClientConnection ->              -- conn : TInterface (Name {namespace = "Gio", name = "TlsClientConnection"})
    IO CInt

{- |
Gets whether /@conn@/ will use SSL 3.0 rather than the
highest-supported version of TLS; see
'GI.Gio.Interfaces.TlsClientConnection.tlsClientConnectionSetUseSsl3'.

@since 2.28
-}
tlsClientConnectionGetUseSsl3 ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsClientConnection a) =>
    a
    {- ^ /@conn@/: the 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' -}
    -> m Bool
    {- ^ __Returns:__ whether /@conn@/ will use SSL 3.0 -}
tlsClientConnectionGetUseSsl3 conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_client_connection_get_use_ssl3 conn'
    let result' = (/= 0) result
    touchManagedPtr conn
    return result'

data TlsClientConnectionGetUseSsl3MethodInfo
instance (signature ~ (m Bool), MonadIO m, IsTlsClientConnection a) => O.MethodInfo TlsClientConnectionGetUseSsl3MethodInfo a signature where
    overloadedMethod _ = tlsClientConnectionGetUseSsl3

-- method TlsClientConnection::get_validation_flags
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsClientConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTlsClientConnection", 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_client_connection_get_validation_flags" g_tls_client_connection_get_validation_flags :: 
    Ptr TlsClientConnection ->              -- conn : TInterface (Name {namespace = "Gio", name = "TlsClientConnection"})
    IO CUInt

{- |
Gets /@conn@/\'s validation flags

@since 2.28
-}
tlsClientConnectionGetValidationFlags ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsClientConnection a) =>
    a
    {- ^ /@conn@/: the 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' -}
    -> m [Gio.Flags.TlsCertificateFlags]
    {- ^ __Returns:__ the validation flags -}
tlsClientConnectionGetValidationFlags conn = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    result <- g_tls_client_connection_get_validation_flags conn'
    let result' = wordToGFlags result
    touchManagedPtr conn
    return result'

data TlsClientConnectionGetValidationFlagsMethodInfo
instance (signature ~ (m [Gio.Flags.TlsCertificateFlags]), MonadIO m, IsTlsClientConnection a) => O.MethodInfo TlsClientConnectionGetValidationFlagsMethodInfo a signature where
    overloadedMethod _ = tlsClientConnectionGetValidationFlags

-- method TlsClientConnection::set_server_identity
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsClientConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTlsClientConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "identity", argType = TInterface (Name {namespace = "Gio", name = "SocketConnectable"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSocketConnectable describing the expected server identity", 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_client_connection_set_server_identity" g_tls_client_connection_set_server_identity :: 
    Ptr TlsClientConnection ->              -- conn : TInterface (Name {namespace = "Gio", name = "TlsClientConnection"})
    Ptr Gio.SocketConnectable.SocketConnectable -> -- identity : TInterface (Name {namespace = "Gio", name = "SocketConnectable"})
    IO ()

{- |
Sets /@conn@/\'s expected server identity, which is used both to tell
servers on virtual hosts which certificate to present, and also
to let /@conn@/ know what name to look for in the certificate when
performing 'GI.Gio.Flags.TlsCertificateFlagsBadIdentity' validation, if enabled.

@since 2.28
-}
tlsClientConnectionSetServerIdentity ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsClientConnection a, Gio.SocketConnectable.IsSocketConnectable b) =>
    a
    {- ^ /@conn@/: the 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' -}
    -> b
    {- ^ /@identity@/: a 'GI.Gio.Interfaces.SocketConnectable.SocketConnectable' describing the expected server identity -}
    -> m ()
tlsClientConnectionSetServerIdentity conn identity = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    identity' <- unsafeManagedPtrCastPtr identity
    g_tls_client_connection_set_server_identity conn' identity'
    touchManagedPtr conn
    touchManagedPtr identity
    return ()

data TlsClientConnectionSetServerIdentityMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsTlsClientConnection a, Gio.SocketConnectable.IsSocketConnectable b) => O.MethodInfo TlsClientConnectionSetServerIdentityMethodInfo a signature where
    overloadedMethod _ = tlsClientConnectionSetServerIdentity

-- method TlsClientConnection::set_use_ssl3
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsClientConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTlsClientConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "use_ssl3", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to use SSL 3.0", 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_client_connection_set_use_ssl3" g_tls_client_connection_set_use_ssl3 :: 
    Ptr TlsClientConnection ->              -- conn : TInterface (Name {namespace = "Gio", name = "TlsClientConnection"})
    CInt ->                                 -- use_ssl3 : TBasicType TBoolean
    IO ()

{- |
If /@useSsl3@/ is 'True', this forces /@conn@/ to use SSL 3.0 rather than
trying to properly negotiate the right version of TLS or SSL to use.
This can be used when talking to servers that do not implement the
fallbacks correctly and which will therefore fail to handshake with
a \"modern\" TLS handshake attempt.

@since 2.28
-}
tlsClientConnectionSetUseSsl3 ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsClientConnection a) =>
    a
    {- ^ /@conn@/: the 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' -}
    -> Bool
    {- ^ /@useSsl3@/: whether to use SSL 3.0 -}
    -> m ()
tlsClientConnectionSetUseSsl3 conn useSsl3 = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    let useSsl3' = (fromIntegral . fromEnum) useSsl3
    g_tls_client_connection_set_use_ssl3 conn' useSsl3'
    touchManagedPtr conn
    return ()

data TlsClientConnectionSetUseSsl3MethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsTlsClientConnection a) => O.MethodInfo TlsClientConnectionSetUseSsl3MethodInfo a signature where
    overloadedMethod _ = tlsClientConnectionSetUseSsl3

-- method TlsClientConnection::set_validation_flags
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "conn", argType = TInterface (Name {namespace = "Gio", name = "TlsClientConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTlsClientConnection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "TlsCertificateFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GTlsCertificateFlags to use", 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_client_connection_set_validation_flags" g_tls_client_connection_set_validation_flags :: 
    Ptr TlsClientConnection ->              -- conn : TInterface (Name {namespace = "Gio", name = "TlsClientConnection"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "TlsCertificateFlags"})
    IO ()

{- |
Sets /@conn@/\'s validation flags, to override the default set of
checks performed when validating a server certificate. By default,
'GI.Gio.Flags.TlsCertificateFlagsValidateAll' is used.

@since 2.28
-}
tlsClientConnectionSetValidationFlags ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsClientConnection a) =>
    a
    {- ^ /@conn@/: the 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' -}
    -> [Gio.Flags.TlsCertificateFlags]
    {- ^ /@flags@/: the 'GI.Gio.Flags.TlsCertificateFlags' to use -}
    -> m ()
tlsClientConnectionSetValidationFlags conn flags = liftIO $ do
    conn' <- unsafeManagedPtrCastPtr conn
    let flags' = gflagsToWord flags
    g_tls_client_connection_set_validation_flags conn' flags'
    touchManagedPtr conn
    return ()

data TlsClientConnectionSetValidationFlagsMethodInfo
instance (signature ~ ([Gio.Flags.TlsCertificateFlags] -> m ()), MonadIO m, IsTlsClientConnection a) => O.MethodInfo TlsClientConnectionSetValidationFlagsMethodInfo a signature where
    overloadedMethod _ = tlsClientConnectionSetValidationFlags

-- method TlsClientConnection::new
-- method type : MemberFunction
-- Args : [Arg {argCName = "base_io_stream", argType = TInterface (Name {namespace = "Gio", name = "IOStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GIOStream to wrap", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "server_identity", argType = TInterface (Name {namespace = "Gio", name = "SocketConnectable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the expected identity of the server", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "TlsClientConnection"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_client_connection_new" g_tls_client_connection_new :: 
    Ptr Gio.IOStream.IOStream ->            -- base_io_stream : TInterface (Name {namespace = "Gio", name = "IOStream"})
    Ptr Gio.SocketConnectable.SocketConnectable -> -- server_identity : TInterface (Name {namespace = "Gio", name = "SocketConnectable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr TlsClientConnection)

{- |
Creates a new 'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection' wrapping /@baseIoStream@/ (which
must have pollable input and output streams) which is assumed to
communicate with the server identified by /@serverIdentity@/.

See the documentation for 'GI.Gio.Objects.TlsConnection.TlsConnection':@/base-io-stream/@ for restrictions
on when application code can run operations on the /@baseIoStream@/ after
this function has returned.

@since 2.28
-}
tlsClientConnectionNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.IOStream.IsIOStream a, Gio.SocketConnectable.IsSocketConnectable b) =>
    a
    {- ^ /@baseIoStream@/: the 'GI.Gio.Objects.IOStream.IOStream' to wrap -}
    -> Maybe (b)
    {- ^ /@serverIdentity@/: the expected identity of the server -}
    -> m TlsClientConnection
    {- ^ __Returns:__ the new
'GI.Gio.Interfaces.TlsClientConnection.TlsClientConnection', or 'Nothing' on error /(Can throw 'Data.GI.Base.GError.GError')/ -}
tlsClientConnectionNew baseIoStream serverIdentity = liftIO $ do
    baseIoStream' <- unsafeManagedPtrCastPtr baseIoStream
    maybeServerIdentity <- case serverIdentity of
        Nothing -> return nullPtr
        Just jServerIdentity -> do
            jServerIdentity' <- unsafeManagedPtrCastPtr jServerIdentity
            return jServerIdentity'
    onException (do
        result <- propagateGError $ g_tls_client_connection_new baseIoStream' maybeServerIdentity
        checkUnexpectedReturnNULL "tlsClientConnectionNew" result
        result' <- (wrapObject TlsClientConnection) result
        touchManagedPtr baseIoStream
        whenJust serverIdentity touchManagedPtr
        return result'
     ) (do
        return ()
     )