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

'GI.Gio.Objects.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 '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.
-}

module GI.Gio.Objects.TlsInteraction
    ( 

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


 -- * Methods
-- ** askPassword #method:askPassword#
    TlsInteractionAskPasswordMethodInfo     ,
    tlsInteractionAskPassword               ,


-- ** askPasswordAsync #method:askPasswordAsync#
    TlsInteractionAskPasswordAsyncMethodInfo,
    tlsInteractionAskPasswordAsync          ,


-- ** askPasswordFinish #method:askPasswordFinish#
    TlsInteractionAskPasswordFinishMethodInfo,
    tlsInteractionAskPasswordFinish         ,


-- ** invokeAskPassword #method:invokeAskPassword#
    TlsInteractionInvokeAskPasswordMethodInfo,
    tlsInteractionInvokeAskPassword         ,


-- ** invokeRequestCertificate #method:invokeRequestCertificate#
    TlsInteractionInvokeRequestCertificateMethodInfo,
    tlsInteractionInvokeRequestCertificate  ,


-- ** requestCertificate #method:requestCertificate#
    TlsInteractionRequestCertificateMethodInfo,
    tlsInteractionRequestCertificate        ,


-- ** requestCertificateAsync #method:requestCertificateAsync#
    TlsInteractionRequestCertificateAsyncMethodInfo,
    tlsInteractionRequestCertificateAsync   ,


-- ** requestCertificateFinish #method:requestCertificateFinish#
    TlsInteractionRequestCertificateFinishMethodInfo,
    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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.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

newtype TlsInteraction = TlsInteraction (ManagedPtr TlsInteraction)
foreign import ccall "g_tls_interaction_get_type"
    c_g_tls_interaction_get_type :: IO GType

instance GObject TlsInteraction where
    gobjectType _ = c_g_tls_interaction_get_type
    

class GObject o => IsTlsInteraction o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError TlsInteraction a) =>
    IsTlsInteraction a
#endif
instance IsTlsInteraction TlsInteraction
instance GObject.Object.IsObject TlsInteraction

toTlsInteraction :: IsTlsInteraction o => o -> IO TlsInteraction
toTlsInteraction = unsafeCastTo TlsInteraction

noTlsInteraction :: Maybe TlsInteraction
noTlsInteraction = Nothing

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 "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 "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveTlsInteractionMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    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 "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveTlsInteractionMethod l o = O.MethodResolutionFailed l o

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

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

instance O.HasAttributeList TlsInteraction
type instance O.AttributeList TlsInteraction = TlsInteractionAttributeList
type TlsInteractionAttributeList = ('[ ] :: [(Symbol, *)])

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

-- 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 'GI.Gio.Objects.TlsInteraction.TlsInteraction' object -}
    -> b
    {- ^ /@password@/: a 'GI.Gio.Objects.TlsPassword.TlsPassword' object -}
    -> Maybe (c)
    {- ^ /@cancellable@/: an optional '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 interaction password cancellable = liftIO $ do
    interaction' <- unsafeManagedPtrCastPtr interaction
    password' <- unsafeManagedPtrCastPtr password
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_tls_interaction_ask_password interaction' password' maybeCancellable
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr interaction
        touchManagedPtr password
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

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

-- 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 'GI.Gio.Objects.TlsInteraction.TlsInteraction' object -}
    -> b
    {- ^ /@password@/: a 'GI.Gio.Objects.TlsPassword.TlsPassword' object -}
    -> Maybe (c)
    {- ^ /@cancellable@/: an optional 'GI.Gio.Objects.Cancellable.Cancellable' cancellation object -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: will be called when the interaction completes -}
    -> m ()
tlsInteractionAskPasswordAsync interaction password cancellable callback = liftIO $ do
    interaction' <- unsafeManagedPtrCastPtr interaction
    password' <- unsafeManagedPtrCastPtr password
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_tls_interaction_ask_password_async interaction' password' maybeCancellable maybeCallback userData
    touchManagedPtr interaction
    touchManagedPtr password
    whenJust cancellable touchManagedPtr
    return ()

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

-- 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 '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 '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 interaction result_ = liftIO $ do
    interaction' <- unsafeManagedPtrCastPtr interaction
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_tls_interaction_ask_password_finish interaction' result_'
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr interaction
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )

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

-- 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 'GI.GLib.Structs.MainContext.MainContext' returned by
'GI.GLib.Functions.mainContextGetThreadDefault' when the interaction is created. This
is called by called by 'GI.Gio.Objects.TlsConnection.TlsConnection' or '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 'GI.Gio.Objects.TlsInteraction.TlsInteraction' object -}
    -> b
    {- ^ /@password@/: a 'GI.Gio.Objects.TlsPassword.TlsPassword' object -}
    -> Maybe (c)
    {- ^ /@cancellable@/: an optional '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 interaction password cancellable = liftIO $ do
    interaction' <- unsafeManagedPtrCastPtr interaction
    password' <- unsafeManagedPtrCastPtr password
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_tls_interaction_invoke_ask_password interaction' password' maybeCancellable
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr interaction
        touchManagedPtr password
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

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

-- 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 'GI.GLib.Structs.MainContext.MainContext' returned by
'GI.GLib.Functions.mainContextGetThreadDefault' when the interaction is
created. This is called by called by '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 'GI.Gio.Objects.TlsInteraction.TlsInteraction' object -}
    -> b
    {- ^ /@connection@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' object -}
    -> Gio.Enums.TlsCertificateRequestFlags
    {- ^ /@flags@/: flags providing more information about the request -}
    -> Maybe (c)
    {- ^ /@cancellable@/: an optional '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 interaction connection flags cancellable = liftIO $ do
    interaction' <- unsafeManagedPtrCastPtr interaction
    connection' <- unsafeManagedPtrCastPtr connection
    let flags' = (fromIntegral . fromEnum) flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_tls_interaction_invoke_request_certificate interaction' connection' flags' maybeCancellable
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr interaction
        touchManagedPtr connection
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

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

-- 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 'GI.Gio.Objects.TlsConnection.TlsConnection'
passed to 'GI.Gio.Objects.TlsInteraction.tlsInteractionRequestCertificate' will have had its
'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 'GI.Gio.Objects.TlsInteraction.TlsInteraction' object -}
    -> b
    {- ^ /@connection@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' object -}
    -> Gio.Enums.TlsCertificateRequestFlags
    {- ^ /@flags@/: flags providing more information about the request -}
    -> Maybe (c)
    {- ^ /@cancellable@/: an optional '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 interaction connection flags cancellable = liftIO $ do
    interaction' <- unsafeManagedPtrCastPtr interaction
    connection' <- unsafeManagedPtrCastPtr connection
    let flags' = (fromIntegral . fromEnum) flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_tls_interaction_request_certificate interaction' connection' flags' maybeCancellable
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr interaction
        touchManagedPtr connection
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

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

-- 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 'GI.Gio.Objects.TlsInteraction.TlsInteraction' object -}
    -> b
    {- ^ /@connection@/: a 'GI.Gio.Objects.TlsConnection.TlsConnection' object -}
    -> Gio.Enums.TlsCertificateRequestFlags
    {- ^ /@flags@/: flags providing more information about the request -}
    -> Maybe (c)
    {- ^ /@cancellable@/: an optional 'GI.Gio.Objects.Cancellable.Cancellable' cancellation object -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: will be called when the interaction completes -}
    -> m ()
tlsInteractionRequestCertificateAsync interaction connection flags cancellable callback = liftIO $ do
    interaction' <- unsafeManagedPtrCastPtr interaction
    connection' <- unsafeManagedPtrCastPtr connection
    let flags' = (fromIntegral . fromEnum) flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_tls_interaction_request_certificate_async interaction' connection' flags' maybeCancellable maybeCallback userData
    touchManagedPtr interaction
    touchManagedPtr connection
    whenJust cancellable touchManagedPtr
    return ()

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

-- 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 'GI.Gio.Objects.TlsConnection.TlsConnection'
passed to 'GI.Gio.Objects.TlsInteraction.tlsInteractionRequestCertificateAsync' will have had its
'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 '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 interaction result_ = liftIO $ do
    interaction' <- unsafeManagedPtrCastPtr interaction
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_tls_interaction_request_certificate_finish interaction' result_'
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr interaction
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )

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