{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- t'GI.Gio.Objects.TlsInteraction.TlsInteraction' provides a mechanism for the TLS connection and database
-- code to interact with the user. It can be used to ask the user for passwords.
-- 
-- To use a t'GI.Gio.Objects.TlsInteraction.TlsInteraction' with a TLS connection use
-- 'GI.Gio.Objects.TlsConnection.tlsConnectionSetInteraction'.
-- 
-- Callers should instantiate a derived class that implements the various
-- interaction methods to show the required dialogs.
-- 
-- Callers should use the \'invoke\' functions like
-- 'GI.Gio.Objects.TlsInteraction.tlsInteractionInvokeAskPassword' to run interaction methods. These
-- functions make sure that the interaction is invoked in the main loop
-- and not in the current thread, if the current thread is not running the
-- main loop.
-- 
-- Derived classes can choose to implement whichever interactions methods they\'d
-- like to support by overriding those virtual methods in their class
-- initialization function. Any interactions not implemented will return
-- 'GI.Gio.Enums.TlsInteractionResultUnhandled'. If a derived class implements an async method,
-- it must also implement the corresponding finish method.
-- 
-- /Since: 2.30/

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

module GI.Gio.Objects.TlsInteraction
    ( 

-- * Exported types
    TlsInteraction(..)                      ,
    IsTlsInteraction                        ,
    toTlsInteraction                        ,
    noTlsInteraction                        ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveTlsInteractionMethod             ,
#endif


-- ** askPassword #method:askPassword#

#if defined(ENABLE_OVERLOADING)
    TlsInteractionAskPasswordMethodInfo     ,
#endif
    tlsInteractionAskPassword               ,


-- ** askPasswordAsync #method:askPasswordAsync#

#if defined(ENABLE_OVERLOADING)
    TlsInteractionAskPasswordAsyncMethodInfo,
#endif
    tlsInteractionAskPasswordAsync          ,


-- ** askPasswordFinish #method:askPasswordFinish#

#if defined(ENABLE_OVERLOADING)
    TlsInteractionAskPasswordFinishMethodInfo,
#endif
    tlsInteractionAskPasswordFinish         ,


-- ** invokeAskPassword #method:invokeAskPassword#

#if defined(ENABLE_OVERLOADING)
    TlsInteractionInvokeAskPasswordMethodInfo,
#endif
    tlsInteractionInvokeAskPassword         ,


-- ** invokeRequestCertificate #method:invokeRequestCertificate#

#if defined(ENABLE_OVERLOADING)
    TlsInteractionInvokeRequestCertificateMethodInfo,
#endif
    tlsInteractionInvokeRequestCertificate  ,


-- ** requestCertificate #method:requestCertificate#

#if defined(ENABLE_OVERLOADING)
    TlsInteractionRequestCertificateMethodInfo,
#endif
    tlsInteractionRequestCertificate        ,


-- ** requestCertificateAsync #method:requestCertificateAsync#

#if defined(ENABLE_OVERLOADING)
    TlsInteractionRequestCertificateAsyncMethodInfo,
#endif
    tlsInteractionRequestCertificateAsync   ,


-- ** requestCertificateFinish #method:requestCertificateFinish#

#if defined(ENABLE_OVERLOADING)
    TlsInteractionRequestCertificateFinishMethodInfo,
#endif
    tlsInteractionRequestCertificateFinish  ,




    ) where

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

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import 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.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.TlsConnection as Gio.TlsConnection
import {-# SOURCE #-} qualified GI.Gio.Objects.TlsPassword as Gio.TlsPassword

-- | Memory-managed wrapper type.
newtype TlsInteraction = TlsInteraction (ManagedPtr TlsInteraction)
    deriving (TlsInteraction -> TlsInteraction -> Bool
(TlsInteraction -> TlsInteraction -> Bool)
-> (TlsInteraction -> TlsInteraction -> Bool) -> Eq TlsInteraction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TlsInteraction -> TlsInteraction -> Bool
$c/= :: TlsInteraction -> TlsInteraction -> Bool
== :: TlsInteraction -> TlsInteraction -> Bool
$c== :: TlsInteraction -> TlsInteraction -> Bool
Eq)
foreign import ccall "g_tls_interaction_get_type"
    c_g_tls_interaction_get_type :: IO GType

instance GObject TlsInteraction where
    gobjectType :: IO GType
gobjectType = IO GType
c_g_tls_interaction_get_type
    

-- | Convert 'TlsInteraction' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue TlsInteraction where
    toGValue :: TlsInteraction -> IO GValue
toGValue o :: TlsInteraction
o = do
        GType
gtype <- IO GType
c_g_tls_interaction_get_type
        TlsInteraction -> (Ptr TlsInteraction -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr TlsInteraction
o (GType
-> (GValue -> Ptr TlsInteraction -> IO ())
-> Ptr TlsInteraction
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr TlsInteraction -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO TlsInteraction
fromGValue gv :: GValue
gv = do
        Ptr TlsInteraction
ptr <- GValue -> IO (Ptr TlsInteraction)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr TlsInteraction)
        (ManagedPtr TlsInteraction -> TlsInteraction)
-> Ptr TlsInteraction -> IO TlsInteraction
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr TlsInteraction -> TlsInteraction
TlsInteraction Ptr TlsInteraction
ptr
        
    

-- | Type class for types which can be safely cast to `TlsInteraction`, for instance with `toTlsInteraction`.
class (GObject o, O.IsDescendantOf TlsInteraction o) => IsTlsInteraction o
instance (GObject o, O.IsDescendantOf TlsInteraction o) => IsTlsInteraction o

instance O.HasParentTypes TlsInteraction
type instance O.ParentTypes TlsInteraction = '[GObject.Object.Object]

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

-- | A convenience alias for `Nothing` :: `Maybe` `TlsInteraction`.
noTlsInteraction :: Maybe TlsInteraction
noTlsInteraction :: Maybe TlsInteraction
noTlsInteraction = Maybe TlsInteraction
forall a. Maybe a
Nothing

#if defined(ENABLE_OVERLOADING)
type family ResolveTlsInteractionMethod (t :: Symbol) (o :: *) :: * where
    ResolveTlsInteractionMethod "askPassword" o = TlsInteractionAskPasswordMethodInfo
    ResolveTlsInteractionMethod "askPasswordAsync" o = TlsInteractionAskPasswordAsyncMethodInfo
    ResolveTlsInteractionMethod "askPasswordFinish" o = TlsInteractionAskPasswordFinishMethodInfo
    ResolveTlsInteractionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveTlsInteractionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveTlsInteractionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveTlsInteractionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveTlsInteractionMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveTlsInteractionMethod "invokeAskPassword" o = TlsInteractionInvokeAskPasswordMethodInfo
    ResolveTlsInteractionMethod "invokeRequestCertificate" o = TlsInteractionInvokeRequestCertificateMethodInfo
    ResolveTlsInteractionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveTlsInteractionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveTlsInteractionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveTlsInteractionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveTlsInteractionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveTlsInteractionMethod "requestCertificate" o = TlsInteractionRequestCertificateMethodInfo
    ResolveTlsInteractionMethod "requestCertificateAsync" o = TlsInteractionRequestCertificateAsyncMethodInfo
    ResolveTlsInteractionMethod "requestCertificateFinish" o = TlsInteractionRequestCertificateFinishMethodInfo
    ResolveTlsInteractionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveTlsInteractionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveTlsInteractionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveTlsInteractionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveTlsInteractionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveTlsInteractionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveTlsInteractionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveTlsInteractionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveTlsInteractionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveTlsInteractionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveTlsInteractionMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveTlsInteractionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveTlsInteractionMethod l o = O.MethodResolutionFailed l o

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

#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList TlsInteraction
type instance O.AttributeList TlsInteraction = TlsInteractionAttributeList
type TlsInteractionAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList TlsInteraction = TlsInteractionSignalList
type TlsInteractionSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method TlsInteraction::ask_password
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "interaction"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsInteraction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsInteraction object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "password"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsPassword" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsPassword object"
--                 , 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 "an optional #GCancellable cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gio" , name = "TlsInteractionResult" })
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_ask_password" g_tls_interaction_ask_password :: 
    Ptr TlsInteraction ->                   -- interaction : TInterface (Name {namespace = "Gio", name = "TlsInteraction"})
    Ptr Gio.TlsPassword.TlsPassword ->      -- password : TInterface (Name {namespace = "Gio", name = "TlsPassword"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CUInt

-- | Run synchronous interaction to ask the user for a password. In general,
-- 'GI.Gio.Objects.TlsInteraction.tlsInteractionInvokeAskPassword' should be used instead of this
-- function.
-- 
-- Derived subclasses usually implement a password prompt, although they may
-- also choose to provide a password from elsewhere. The /@password@/ value will
-- be filled in and then /@callback@/ will be called. Alternatively the user may
-- abort this password request, which will usually abort the TLS connection.
-- 
-- If the interaction is cancelled by the cancellation object, or by the
-- user then 'GI.Gio.Enums.TlsInteractionResultFailed' will be returned with an error that
-- contains a 'GI.Gio.Enums.IOErrorEnumCancelled' error code. Certain implementations may
-- not support immediate cancellation.
-- 
-- /Since: 2.30/
tlsInteractionAskPassword ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsInteraction a, Gio.TlsPassword.IsTlsPassword b, Gio.Cancellable.IsCancellable c) =>
    a
    -- ^ /@interaction@/: a t'GI.Gio.Objects.TlsInteraction.TlsInteraction' object
    -> b
    -- ^ /@password@/: a t'GI.Gio.Objects.TlsPassword.TlsPassword' object
    -> Maybe (c)
    -- ^ /@cancellable@/: an optional t'GI.Gio.Objects.Cancellable.Cancellable' cancellation object
    -> m Gio.Enums.TlsInteractionResult
    -- ^ __Returns:__ The status of the ask password interaction. /(Can throw 'Data.GI.Base.GError.GError')/
tlsInteractionAskPassword :: a -> b -> Maybe c -> m TlsInteractionResult
tlsInteractionAskPassword interaction :: a
interaction password :: b
password cancellable :: Maybe c
cancellable = IO TlsInteractionResult -> m TlsInteractionResult
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsInteractionResult -> m TlsInteractionResult)
-> IO TlsInteractionResult -> m TlsInteractionResult
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsInteraction
interaction' <- a -> IO (Ptr TlsInteraction)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
interaction
    Ptr TlsPassword
password' <- b -> IO (Ptr TlsPassword)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
password
    Ptr Cancellable
maybeCancellable <- case Maybe c
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 :: c
jCancellable -> do
            Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO TlsInteractionResult -> IO () -> IO TlsInteractionResult
forall a b. IO a -> IO b -> IO a
onException (do
        CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr TlsInteraction
-> Ptr TlsPassword
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CUInt
g_tls_interaction_ask_password Ptr TlsInteraction
interaction' Ptr TlsPassword
password' Ptr Cancellable
maybeCancellable
        let result' :: TlsInteractionResult
result' = (Int -> TlsInteractionResult
forall a. Enum a => Int -> a
toEnum (Int -> TlsInteractionResult)
-> (CUInt -> Int) -> CUInt -> TlsInteractionResult
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
interaction
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
password
        Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        TlsInteractionResult -> IO TlsInteractionResult
forall (m :: * -> *) a. Monad m => a -> m a
return TlsInteractionResult
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data TlsInteractionAskPasswordMethodInfo
instance (signature ~ (b -> Maybe (c) -> m Gio.Enums.TlsInteractionResult), MonadIO m, IsTlsInteraction a, Gio.TlsPassword.IsTlsPassword b, Gio.Cancellable.IsCancellable c) => O.MethodInfo TlsInteractionAskPasswordMethodInfo a signature where
    overloadedMethod = tlsInteractionAskPassword

#endif

-- method TlsInteraction::ask_password_async
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "interaction"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsInteraction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsInteraction object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "password"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsPassword" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsPassword object"
--                 , 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 "an optional #GCancellable cancellation object"
--                 , 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 "will be called when the interaction completes"
--                 , 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 "data to pass to the @callback"
--                 , 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_interaction_ask_password_async" g_tls_interaction_ask_password_async :: 
    Ptr TlsInteraction ->                   -- interaction : TInterface (Name {namespace = "Gio", name = "TlsInteraction"})
    Ptr Gio.TlsPassword.TlsPassword ->      -- password : TInterface (Name {namespace = "Gio", name = "TlsPassword"})
    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 ()

-- | Run asynchronous interaction to ask the user for a password. In general,
-- 'GI.Gio.Objects.TlsInteraction.tlsInteractionInvokeAskPassword' should be used instead of this
-- function.
-- 
-- Derived subclasses usually implement a password prompt, although they may
-- also choose to provide a password from elsewhere. The /@password@/ value will
-- be filled in and then /@callback@/ will be called. Alternatively the user may
-- abort this password request, which will usually abort the TLS connection.
-- 
-- If the interaction is cancelled by the cancellation object, or by the
-- user then 'GI.Gio.Enums.TlsInteractionResultFailed' will be returned with an error that
-- contains a 'GI.Gio.Enums.IOErrorEnumCancelled' error code. Certain implementations may
-- not support immediate cancellation.
-- 
-- Certain implementations may not support immediate cancellation.
-- 
-- /Since: 2.30/
tlsInteractionAskPasswordAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsInteraction a, Gio.TlsPassword.IsTlsPassword b, Gio.Cancellable.IsCancellable c) =>
    a
    -- ^ /@interaction@/: a t'GI.Gio.Objects.TlsInteraction.TlsInteraction' object
    -> b
    -- ^ /@password@/: a t'GI.Gio.Objects.TlsPassword.TlsPassword' object
    -> Maybe (c)
    -- ^ /@cancellable@/: an optional t'GI.Gio.Objects.Cancellable.Cancellable' cancellation object
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: will be called when the interaction completes
    -> m ()
tlsInteractionAskPasswordAsync :: a -> b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
tlsInteractionAskPasswordAsync interaction :: a
interaction password :: b
password cancellable :: Maybe c
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 TlsInteraction
interaction' <- a -> IO (Ptr TlsInteraction)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
interaction
    Ptr TlsPassword
password' <- b -> IO (Ptr TlsPassword)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
password
    Ptr Cancellable
maybeCancellable <- case Maybe c
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 :: c
jCancellable -> do
            Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
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 TlsInteraction
-> Ptr TlsPassword
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_tls_interaction_ask_password_async Ptr TlsInteraction
interaction' Ptr TlsPassword
password' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
interaction
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
password
    Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data TlsInteractionAskPasswordAsyncMethodInfo
instance (signature ~ (b -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsTlsInteraction a, Gio.TlsPassword.IsTlsPassword b, Gio.Cancellable.IsCancellable c) => O.MethodInfo TlsInteractionAskPasswordAsyncMethodInfo a signature where
    overloadedMethod = tlsInteractionAskPasswordAsync

#endif

-- method TlsInteraction::ask_password_finish
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "interaction"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsInteraction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsInteraction object"
--                 , 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 "the result passed to the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gio" , name = "TlsInteractionResult" })
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_ask_password_finish" g_tls_interaction_ask_password_finish :: 
    Ptr TlsInteraction ->                   -- interaction : TInterface (Name {namespace = "Gio", name = "TlsInteraction"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CUInt

-- | Complete an ask password user interaction request. This should be once
-- the 'GI.Gio.Objects.TlsInteraction.tlsInteractionAskPasswordAsync' completion callback is called.
-- 
-- If 'GI.Gio.Enums.TlsInteractionResultHandled' is returned, then the t'GI.Gio.Objects.TlsPassword.TlsPassword' passed
-- to 'GI.Gio.Objects.TlsInteraction.tlsInteractionAskPassword' will have its password filled in.
-- 
-- If the interaction is cancelled by the cancellation object, or by the
-- user then 'GI.Gio.Enums.TlsInteractionResultFailed' will be returned with an error that
-- contains a 'GI.Gio.Enums.IOErrorEnumCancelled' error code.
-- 
-- /Since: 2.30/
tlsInteractionAskPasswordFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsInteraction a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    -- ^ /@interaction@/: a t'GI.Gio.Objects.TlsInteraction.TlsInteraction' object
    -> b
    -- ^ /@result@/: the result passed to the callback
    -> m Gio.Enums.TlsInteractionResult
    -- ^ __Returns:__ The status of the ask password interaction. /(Can throw 'Data.GI.Base.GError.GError')/
tlsInteractionAskPasswordFinish :: a -> b -> m TlsInteractionResult
tlsInteractionAskPasswordFinish interaction :: a
interaction result_ :: b
result_ = IO TlsInteractionResult -> m TlsInteractionResult
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsInteractionResult -> m TlsInteractionResult)
-> IO TlsInteractionResult -> m TlsInteractionResult
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsInteraction
interaction' <- a -> IO (Ptr TlsInteraction)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
interaction
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO TlsInteractionResult -> IO () -> IO TlsInteractionResult
forall a b. IO a -> IO b -> IO a
onException (do
        CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr TlsInteraction
-> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CUInt
g_tls_interaction_ask_password_finish Ptr TlsInteraction
interaction' Ptr AsyncResult
result_'
        let result' :: TlsInteractionResult
result' = (Int -> TlsInteractionResult
forall a. Enum a => Int -> a
toEnum (Int -> TlsInteractionResult)
-> (CUInt -> Int) -> CUInt -> TlsInteractionResult
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
interaction
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        TlsInteractionResult -> IO TlsInteractionResult
forall (m :: * -> *) a. Monad m => a -> m a
return TlsInteractionResult
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data TlsInteractionAskPasswordFinishMethodInfo
instance (signature ~ (b -> m Gio.Enums.TlsInteractionResult), MonadIO m, IsTlsInteraction a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo TlsInteractionAskPasswordFinishMethodInfo a signature where
    overloadedMethod = tlsInteractionAskPasswordFinish

#endif

-- method TlsInteraction::invoke_ask_password
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "interaction"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsInteraction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsInteraction object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "password"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsPassword" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsPassword object"
--                 , 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 "an optional #GCancellable cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gio" , name = "TlsInteractionResult" })
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_invoke_ask_password" g_tls_interaction_invoke_ask_password :: 
    Ptr TlsInteraction ->                   -- interaction : TInterface (Name {namespace = "Gio", name = "TlsInteraction"})
    Ptr Gio.TlsPassword.TlsPassword ->      -- password : TInterface (Name {namespace = "Gio", name = "TlsPassword"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CUInt

-- | Invoke the interaction to ask the user for a password. It invokes this
-- interaction in the main loop, specifically the t'GI.GLib.Structs.MainContext.MainContext' returned by
-- 'GI.GLib.Functions.mainContextGetThreadDefault' when the interaction is created. This
-- is called by called by t'GI.Gio.Objects.TlsConnection.TlsConnection' or t'GI.Gio.Objects.TlsDatabase.TlsDatabase' to ask the user
-- for a password.
-- 
-- Derived subclasses usually implement a password prompt, although they may
-- also choose to provide a password from elsewhere. The /@password@/ value will
-- be filled in and then /@callback@/ will be called. Alternatively the user may
-- abort this password request, which will usually abort the TLS connection.
-- 
-- The implementation can either be a synchronous (eg: modal dialog) or an
-- asynchronous one (eg: modeless dialog). This function will take care of
-- calling which ever one correctly.
-- 
-- If the interaction is cancelled by the cancellation object, or by the
-- user then 'GI.Gio.Enums.TlsInteractionResultFailed' will be returned with an error that
-- contains a 'GI.Gio.Enums.IOErrorEnumCancelled' error code. Certain implementations may
-- not support immediate cancellation.
-- 
-- /Since: 2.30/
tlsInteractionInvokeAskPassword ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsInteraction a, Gio.TlsPassword.IsTlsPassword b, Gio.Cancellable.IsCancellable c) =>
    a
    -- ^ /@interaction@/: a t'GI.Gio.Objects.TlsInteraction.TlsInteraction' object
    -> b
    -- ^ /@password@/: a t'GI.Gio.Objects.TlsPassword.TlsPassword' object
    -> Maybe (c)
    -- ^ /@cancellable@/: an optional t'GI.Gio.Objects.Cancellable.Cancellable' cancellation object
    -> m Gio.Enums.TlsInteractionResult
    -- ^ __Returns:__ The status of the ask password interaction. /(Can throw 'Data.GI.Base.GError.GError')/
tlsInteractionInvokeAskPassword :: a -> b -> Maybe c -> m TlsInteractionResult
tlsInteractionInvokeAskPassword interaction :: a
interaction password :: b
password cancellable :: Maybe c
cancellable = IO TlsInteractionResult -> m TlsInteractionResult
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsInteractionResult -> m TlsInteractionResult)
-> IO TlsInteractionResult -> m TlsInteractionResult
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsInteraction
interaction' <- a -> IO (Ptr TlsInteraction)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
interaction
    Ptr TlsPassword
password' <- b -> IO (Ptr TlsPassword)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
password
    Ptr Cancellable
maybeCancellable <- case Maybe c
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 :: c
jCancellable -> do
            Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO TlsInteractionResult -> IO () -> IO TlsInteractionResult
forall a b. IO a -> IO b -> IO a
onException (do
        CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr TlsInteraction
-> Ptr TlsPassword
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CUInt
g_tls_interaction_invoke_ask_password Ptr TlsInteraction
interaction' Ptr TlsPassword
password' Ptr Cancellable
maybeCancellable
        let result' :: TlsInteractionResult
result' = (Int -> TlsInteractionResult
forall a. Enum a => Int -> a
toEnum (Int -> TlsInteractionResult)
-> (CUInt -> Int) -> CUInt -> TlsInteractionResult
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
interaction
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
password
        Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        TlsInteractionResult -> IO TlsInteractionResult
forall (m :: * -> *) a. Monad m => a -> m a
return TlsInteractionResult
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data TlsInteractionInvokeAskPasswordMethodInfo
instance (signature ~ (b -> Maybe (c) -> m Gio.Enums.TlsInteractionResult), MonadIO m, IsTlsInteraction a, Gio.TlsPassword.IsTlsPassword b, Gio.Cancellable.IsCancellable c) => O.MethodInfo TlsInteractionInvokeAskPasswordMethodInfo a signature where
    overloadedMethod = tlsInteractionInvokeAskPassword

#endif

-- method TlsInteraction::invoke_request_certificate
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "interaction"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsInteraction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsInteraction object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "connection"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsConnection" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsConnection object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "flags"
--           , argType =
--               TInterface
--                 Name { namespace = "Gio" , name = "TlsCertificateRequestFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "flags providing more information about 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 "an optional #GCancellable cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gio" , name = "TlsInteractionResult" })
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_invoke_request_certificate" g_tls_interaction_invoke_request_certificate :: 
    Ptr TlsInteraction ->                   -- interaction : TInterface (Name {namespace = "Gio", name = "TlsInteraction"})
    Ptr Gio.TlsConnection.TlsConnection ->  -- connection : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "TlsCertificateRequestFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CUInt

-- | Invoke the interaction to ask the user to choose a certificate to
-- use with the connection. It invokes this interaction in the main
-- loop, specifically the t'GI.GLib.Structs.MainContext.MainContext' returned by
-- 'GI.GLib.Functions.mainContextGetThreadDefault' when the interaction is
-- created. This is called by called by t'GI.Gio.Objects.TlsConnection.TlsConnection' when the peer
-- requests a certificate during the handshake.
-- 
-- Derived subclasses usually implement a certificate selector,
-- although they may also choose to provide a certificate from
-- elsewhere. Alternatively the user may abort this certificate
-- request, which may or may not abort the TLS connection.
-- 
-- The implementation can either be a synchronous (eg: modal dialog) or an
-- asynchronous one (eg: modeless dialog). This function will take care of
-- calling which ever one correctly.
-- 
-- If the interaction is cancelled by the cancellation object, or by the
-- user then 'GI.Gio.Enums.TlsInteractionResultFailed' will be returned with an error that
-- contains a 'GI.Gio.Enums.IOErrorEnumCancelled' error code. Certain implementations may
-- not support immediate cancellation.
-- 
-- /Since: 2.40/
tlsInteractionInvokeRequestCertificate ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsInteraction a, Gio.TlsConnection.IsTlsConnection b, Gio.Cancellable.IsCancellable c) =>
    a
    -- ^ /@interaction@/: a t'GI.Gio.Objects.TlsInteraction.TlsInteraction' object
    -> b
    -- ^ /@connection@/: a t'GI.Gio.Objects.TlsConnection.TlsConnection' object
    -> Gio.Enums.TlsCertificateRequestFlags
    -- ^ /@flags@/: flags providing more information about the request
    -> Maybe (c)
    -- ^ /@cancellable@/: an optional t'GI.Gio.Objects.Cancellable.Cancellable' cancellation object
    -> m Gio.Enums.TlsInteractionResult
    -- ^ __Returns:__ The status of the certificate request interaction. /(Can throw 'Data.GI.Base.GError.GError')/
tlsInteractionInvokeRequestCertificate :: a
-> b
-> TlsCertificateRequestFlags
-> Maybe c
-> m TlsInteractionResult
tlsInteractionInvokeRequestCertificate interaction :: a
interaction connection :: b
connection flags :: TlsCertificateRequestFlags
flags cancellable :: Maybe c
cancellable = IO TlsInteractionResult -> m TlsInteractionResult
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsInteractionResult -> m TlsInteractionResult)
-> IO TlsInteractionResult -> m TlsInteractionResult
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsInteraction
interaction' <- a -> IO (Ptr TlsInteraction)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
interaction
    Ptr TlsConnection
connection' <- b -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
connection
    let flags' :: CUInt
flags' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (TlsCertificateRequestFlags -> Int)
-> TlsCertificateRequestFlags
-> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TlsCertificateRequestFlags -> Int
forall a. Enum a => a -> Int
fromEnum) TlsCertificateRequestFlags
flags
    Ptr Cancellable
maybeCancellable <- case Maybe c
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 :: c
jCancellable -> do
            Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO TlsInteractionResult -> IO () -> IO TlsInteractionResult
forall a b. IO a -> IO b -> IO a
onException (do
        CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr TlsInteraction
-> Ptr TlsConnection
-> CUInt
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CUInt
g_tls_interaction_invoke_request_certificate Ptr TlsInteraction
interaction' Ptr TlsConnection
connection' CUInt
flags' Ptr Cancellable
maybeCancellable
        let result' :: TlsInteractionResult
result' = (Int -> TlsInteractionResult
forall a. Enum a => Int -> a
toEnum (Int -> TlsInteractionResult)
-> (CUInt -> Int) -> CUInt -> TlsInteractionResult
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
interaction
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
connection
        Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        TlsInteractionResult -> IO TlsInteractionResult
forall (m :: * -> *) a. Monad m => a -> m a
return TlsInteractionResult
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data TlsInteractionInvokeRequestCertificateMethodInfo
instance (signature ~ (b -> Gio.Enums.TlsCertificateRequestFlags -> Maybe (c) -> m Gio.Enums.TlsInteractionResult), MonadIO m, IsTlsInteraction a, Gio.TlsConnection.IsTlsConnection b, Gio.Cancellable.IsCancellable c) => O.MethodInfo TlsInteractionInvokeRequestCertificateMethodInfo a signature where
    overloadedMethod = tlsInteractionInvokeRequestCertificate

#endif

-- method TlsInteraction::request_certificate
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "interaction"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsInteraction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsInteraction object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "connection"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsConnection" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsConnection object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "flags"
--           , argType =
--               TInterface
--                 Name { namespace = "Gio" , name = "TlsCertificateRequestFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "flags providing more information about 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 "an optional #GCancellable cancellation object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gio" , name = "TlsInteractionResult" })
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_request_certificate" g_tls_interaction_request_certificate :: 
    Ptr TlsInteraction ->                   -- interaction : TInterface (Name {namespace = "Gio", name = "TlsInteraction"})
    Ptr Gio.TlsConnection.TlsConnection ->  -- connection : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "TlsCertificateRequestFlags"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CUInt

-- | Run synchronous interaction to ask the user to choose a certificate to use
-- with the connection. In general, 'GI.Gio.Objects.TlsInteraction.tlsInteractionInvokeRequestCertificate'
-- should be used instead of this function.
-- 
-- Derived subclasses usually implement a certificate selector, although they may
-- also choose to provide a certificate from elsewhere. Alternatively the user may
-- abort this certificate request, which will usually abort the TLS connection.
-- 
-- If 'GI.Gio.Enums.TlsInteractionResultHandled' is returned, then the t'GI.Gio.Objects.TlsConnection.TlsConnection'
-- passed to 'GI.Gio.Objects.TlsInteraction.tlsInteractionRequestCertificate' will have had its
-- t'GI.Gio.Objects.TlsConnection.TlsConnection':@/certificate/@ filled in.
-- 
-- If the interaction is cancelled by the cancellation object, or by the
-- user then 'GI.Gio.Enums.TlsInteractionResultFailed' will be returned with an error that
-- contains a 'GI.Gio.Enums.IOErrorEnumCancelled' error code. Certain implementations may
-- not support immediate cancellation.
-- 
-- /Since: 2.40/
tlsInteractionRequestCertificate ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsInteraction a, Gio.TlsConnection.IsTlsConnection b, Gio.Cancellable.IsCancellable c) =>
    a
    -- ^ /@interaction@/: a t'GI.Gio.Objects.TlsInteraction.TlsInteraction' object
    -> b
    -- ^ /@connection@/: a t'GI.Gio.Objects.TlsConnection.TlsConnection' object
    -> Gio.Enums.TlsCertificateRequestFlags
    -- ^ /@flags@/: flags providing more information about the request
    -> Maybe (c)
    -- ^ /@cancellable@/: an optional t'GI.Gio.Objects.Cancellable.Cancellable' cancellation object
    -> m Gio.Enums.TlsInteractionResult
    -- ^ __Returns:__ The status of the request certificate interaction. /(Can throw 'Data.GI.Base.GError.GError')/
tlsInteractionRequestCertificate :: a
-> b
-> TlsCertificateRequestFlags
-> Maybe c
-> m TlsInteractionResult
tlsInteractionRequestCertificate interaction :: a
interaction connection :: b
connection flags :: TlsCertificateRequestFlags
flags cancellable :: Maybe c
cancellable = IO TlsInteractionResult -> m TlsInteractionResult
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsInteractionResult -> m TlsInteractionResult)
-> IO TlsInteractionResult -> m TlsInteractionResult
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsInteraction
interaction' <- a -> IO (Ptr TlsInteraction)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
interaction
    Ptr TlsConnection
connection' <- b -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
connection
    let flags' :: CUInt
flags' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (TlsCertificateRequestFlags -> Int)
-> TlsCertificateRequestFlags
-> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TlsCertificateRequestFlags -> Int
forall a. Enum a => a -> Int
fromEnum) TlsCertificateRequestFlags
flags
    Ptr Cancellable
maybeCancellable <- case Maybe c
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 :: c
jCancellable -> do
            Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO TlsInteractionResult -> IO () -> IO TlsInteractionResult
forall a b. IO a -> IO b -> IO a
onException (do
        CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr TlsInteraction
-> Ptr TlsConnection
-> CUInt
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CUInt
g_tls_interaction_request_certificate Ptr TlsInteraction
interaction' Ptr TlsConnection
connection' CUInt
flags' Ptr Cancellable
maybeCancellable
        let result' :: TlsInteractionResult
result' = (Int -> TlsInteractionResult
forall a. Enum a => Int -> a
toEnum (Int -> TlsInteractionResult)
-> (CUInt -> Int) -> CUInt -> TlsInteractionResult
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
interaction
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
connection
        Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        TlsInteractionResult -> IO TlsInteractionResult
forall (m :: * -> *) a. Monad m => a -> m a
return TlsInteractionResult
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data TlsInteractionRequestCertificateMethodInfo
instance (signature ~ (b -> Gio.Enums.TlsCertificateRequestFlags -> Maybe (c) -> m Gio.Enums.TlsInteractionResult), MonadIO m, IsTlsInteraction a, Gio.TlsConnection.IsTlsConnection b, Gio.Cancellable.IsCancellable c) => O.MethodInfo TlsInteractionRequestCertificateMethodInfo a signature where
    overloadedMethod = tlsInteractionRequestCertificate

#endif

-- method TlsInteraction::request_certificate_async
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "interaction"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsInteraction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsInteraction object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "connection"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsConnection" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsConnection object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "flags"
--           , argType =
--               TInterface
--                 Name { namespace = "Gio" , name = "TlsCertificateRequestFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "flags providing more information about 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 "an optional #GCancellable cancellation object"
--                 , 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 "will be called when the interaction completes"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeAsync
--           , argClosure = 5
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "data to pass to the @callback"
--                 , 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_interaction_request_certificate_async" g_tls_interaction_request_certificate_async :: 
    Ptr TlsInteraction ->                   -- interaction : TInterface (Name {namespace = "Gio", name = "TlsInteraction"})
    Ptr Gio.TlsConnection.TlsConnection ->  -- connection : TInterface (Name {namespace = "Gio", name = "TlsConnection"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "TlsCertificateRequestFlags"})
    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 ()

-- | Run asynchronous interaction to ask the user for a certificate to use with
-- the connection. In general, 'GI.Gio.Objects.TlsInteraction.tlsInteractionInvokeRequestCertificate' should
-- be used instead of this function.
-- 
-- Derived subclasses usually implement a certificate selector, although they may
-- also choose to provide a certificate from elsewhere. /@callback@/ will be called
-- when the operation completes. Alternatively the user may abort this certificate
-- request, which will usually abort the TLS connection.
-- 
-- /Since: 2.40/
tlsInteractionRequestCertificateAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsInteraction a, Gio.TlsConnection.IsTlsConnection b, Gio.Cancellable.IsCancellable c) =>
    a
    -- ^ /@interaction@/: a t'GI.Gio.Objects.TlsInteraction.TlsInteraction' object
    -> b
    -- ^ /@connection@/: a t'GI.Gio.Objects.TlsConnection.TlsConnection' object
    -> Gio.Enums.TlsCertificateRequestFlags
    -- ^ /@flags@/: flags providing more information about the request
    -> Maybe (c)
    -- ^ /@cancellable@/: an optional t'GI.Gio.Objects.Cancellable.Cancellable' cancellation object
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: will be called when the interaction completes
    -> m ()
tlsInteractionRequestCertificateAsync :: a
-> b
-> TlsCertificateRequestFlags
-> Maybe c
-> Maybe AsyncReadyCallback
-> m ()
tlsInteractionRequestCertificateAsync interaction :: a
interaction connection :: b
connection flags :: TlsCertificateRequestFlags
flags cancellable :: Maybe c
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 TlsInteraction
interaction' <- a -> IO (Ptr TlsInteraction)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
interaction
    Ptr TlsConnection
connection' <- b -> IO (Ptr TlsConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
connection
    let flags' :: CUInt
flags' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (TlsCertificateRequestFlags -> Int)
-> TlsCertificateRequestFlags
-> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TlsCertificateRequestFlags -> Int
forall a. Enum a => a -> Int
fromEnum) TlsCertificateRequestFlags
flags
    Ptr Cancellable
maybeCancellable <- case Maybe c
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 :: c
jCancellable -> do
            Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
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 TlsInteraction
-> Ptr TlsConnection
-> CUInt
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_tls_interaction_request_certificate_async Ptr TlsInteraction
interaction' Ptr TlsConnection
connection' CUInt
flags' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
interaction
    b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
connection
    Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data TlsInteractionRequestCertificateAsyncMethodInfo
instance (signature ~ (b -> Gio.Enums.TlsCertificateRequestFlags -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsTlsInteraction a, Gio.TlsConnection.IsTlsConnection b, Gio.Cancellable.IsCancellable c) => O.MethodInfo TlsInteractionRequestCertificateAsyncMethodInfo a signature where
    overloadedMethod = tlsInteractionRequestCertificateAsync

#endif

-- method TlsInteraction::request_certificate_finish
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "interaction"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "TlsInteraction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTlsInteraction object"
--                 , 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 "the result passed to the callback"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gio" , name = "TlsInteractionResult" })
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_request_certificate_finish" g_tls_interaction_request_certificate_finish :: 
    Ptr TlsInteraction ->                   -- interaction : TInterface (Name {namespace = "Gio", name = "TlsInteraction"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CUInt

-- | Complete an request certificate user interaction request. This should be once
-- the 'GI.Gio.Objects.TlsInteraction.tlsInteractionRequestCertificateAsync' completion callback is called.
-- 
-- If 'GI.Gio.Enums.TlsInteractionResultHandled' is returned, then the t'GI.Gio.Objects.TlsConnection.TlsConnection'
-- passed to 'GI.Gio.Objects.TlsInteraction.tlsInteractionRequestCertificateAsync' will have had its
-- t'GI.Gio.Objects.TlsConnection.TlsConnection':@/certificate/@ filled in.
-- 
-- If the interaction is cancelled by the cancellation object, or by the
-- user then 'GI.Gio.Enums.TlsInteractionResultFailed' will be returned with an error that
-- contains a 'GI.Gio.Enums.IOErrorEnumCancelled' error code.
-- 
-- /Since: 2.40/
tlsInteractionRequestCertificateFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsTlsInteraction a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    -- ^ /@interaction@/: a t'GI.Gio.Objects.TlsInteraction.TlsInteraction' object
    -> b
    -- ^ /@result@/: the result passed to the callback
    -> m Gio.Enums.TlsInteractionResult
    -- ^ __Returns:__ The status of the request certificate interaction. /(Can throw 'Data.GI.Base.GError.GError')/
tlsInteractionRequestCertificateFinish :: a -> b -> m TlsInteractionResult
tlsInteractionRequestCertificateFinish interaction :: a
interaction result_ :: b
result_ = IO TlsInteractionResult -> m TlsInteractionResult
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TlsInteractionResult -> m TlsInteractionResult)
-> IO TlsInteractionResult -> m TlsInteractionResult
forall a b. (a -> b) -> a -> b
$ do
    Ptr TlsInteraction
interaction' <- a -> IO (Ptr TlsInteraction)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
interaction
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO TlsInteractionResult -> IO () -> IO TlsInteractionResult
forall a b. IO a -> IO b -> IO a
onException (do
        CUInt
result <- (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CUInt) -> IO CUInt)
-> (Ptr (Ptr GError) -> IO CUInt) -> IO CUInt
forall a b. (a -> b) -> a -> b
$ Ptr TlsInteraction
-> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CUInt
g_tls_interaction_request_certificate_finish Ptr TlsInteraction
interaction' Ptr AsyncResult
result_'
        let result' :: TlsInteractionResult
result' = (Int -> TlsInteractionResult
forall a. Enum a => Int -> a
toEnum (Int -> TlsInteractionResult)
-> (CUInt -> Int) -> CUInt -> TlsInteractionResult
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
interaction
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        TlsInteractionResult -> IO TlsInteractionResult
forall (m :: * -> *) a. Monad m => a -> m a
return TlsInteractionResult
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data TlsInteractionRequestCertificateFinishMethodInfo
instance (signature ~ (b -> m Gio.Enums.TlsInteractionResult), MonadIO m, IsTlsInteraction a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo TlsInteractionRequestCertificateFinishMethodInfo a signature where
    overloadedMethod = tlsInteractionRequestCertificateFinish

#endif