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

module GI.Gio.Objects.TlsInteraction
    ( 

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


 -- * Methods
-- ** tlsInteractionAskPassword
    tlsInteractionAskPassword               ,


-- ** tlsInteractionAskPasswordAsync
    tlsInteractionAskPasswordAsync          ,


-- ** tlsInteractionAskPasswordFinish
    tlsInteractionAskPasswordFinish         ,


-- ** tlsInteractionInvokeAskPassword
    tlsInteractionInvokeAskPassword         ,


-- ** tlsInteractionInvokeRequestCertificate
    tlsInteractionInvokeRequestCertificate  ,


-- ** tlsInteractionRequestCertificate
    tlsInteractionRequestCertificate        ,


-- ** tlsInteractionRequestCertificateAsync
    tlsInteractionRequestCertificateAsync   ,


-- ** tlsInteractionRequestCertificateFinish
    tlsInteractionRequestCertificateFinish  ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Gio.Types
import GI.Gio.Callbacks
import qualified GI.GObject as GObject

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

type instance ParentTypes TlsInteraction = TlsInteractionParentTypes
type TlsInteractionParentTypes = '[GObject.Object]

instance GObject TlsInteraction where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_tls_interaction_get_type
    

class GObject o => TlsInteractionK o
instance (GObject o, IsDescendantOf TlsInteraction o) => TlsInteractionK o

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

noTlsInteraction :: Maybe TlsInteraction
noTlsInteraction = Nothing

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

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

-- method TlsInteraction::ask_password
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "password", argType = TInterface "Gio" "TlsPassword", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "password", argType = TInterface "Gio" "TlsPassword", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "TlsInteractionResult"
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_ask_password" g_tls_interaction_ask_password :: 
    Ptr TlsInteraction ->                   -- _obj : TInterface "Gio" "TlsInteraction"
    Ptr TlsPassword ->                      -- password : TInterface "Gio" "TlsPassword"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO CUInt


tlsInteractionAskPassword ::
    (MonadIO m, TlsInteractionK a, TlsPasswordK b, CancellableK c) =>
    a ->                                    -- _obj
    b ->                                    -- password
    Maybe (c) ->                            -- cancellable
    m TlsInteractionResult
tlsInteractionAskPassword _obj password cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let password' = unsafeManagedPtrCastPtr password
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_tls_interaction_ask_password _obj' password' maybeCancellable
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr _obj
        touchManagedPtr password
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

-- method TlsInteraction::ask_password_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "password", argType = TInterface "Gio" "TlsPassword", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "password", argType = TInterface "Gio" "TlsPassword", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_tls_interaction_ask_password_async" g_tls_interaction_ask_password_async :: 
    Ptr TlsInteraction ->                   -- _obj : TInterface "Gio" "TlsInteraction"
    Ptr TlsPassword ->                      -- password : TInterface "Gio" "TlsPassword"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


tlsInteractionAskPasswordAsync ::
    (MonadIO m, TlsInteractionK a, TlsPasswordK b, CancellableK c) =>
    a ->                                    -- _obj
    b ->                                    -- password
    Maybe (c) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
tlsInteractionAskPasswordAsync _obj password cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let password' = unsafeManagedPtrCastPtr password
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    g_tls_interaction_ask_password_async _obj' password' maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    touchManagedPtr password
    whenJust cancellable touchManagedPtr
    return ()

-- method TlsInteraction::ask_password_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "TlsInteractionResult"
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_ask_password_finish" g_tls_interaction_ask_password_finish :: 
    Ptr TlsInteraction ->                   -- _obj : TInterface "Gio" "TlsInteraction"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO CUInt


tlsInteractionAskPasswordFinish ::
    (MonadIO m, TlsInteractionK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m TlsInteractionResult
tlsInteractionAskPasswordFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_tls_interaction_ask_password_finish _obj' result_'
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr _obj
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )

-- method TlsInteraction::invoke_ask_password
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "password", argType = TInterface "Gio" "TlsPassword", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "password", argType = TInterface "Gio" "TlsPassword", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "TlsInteractionResult"
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_invoke_ask_password" g_tls_interaction_invoke_ask_password :: 
    Ptr TlsInteraction ->                   -- _obj : TInterface "Gio" "TlsInteraction"
    Ptr TlsPassword ->                      -- password : TInterface "Gio" "TlsPassword"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO CUInt


tlsInteractionInvokeAskPassword ::
    (MonadIO m, TlsInteractionK a, TlsPasswordK b, CancellableK c) =>
    a ->                                    -- _obj
    b ->                                    -- password
    Maybe (c) ->                            -- cancellable
    m TlsInteractionResult
tlsInteractionInvokeAskPassword _obj password cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let password' = unsafeManagedPtrCastPtr password
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_tls_interaction_invoke_ask_password _obj' password' maybeCancellable
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr _obj
        touchManagedPtr password
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

-- method TlsInteraction::invoke_request_certificate
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "connection", argType = TInterface "Gio" "TlsConnection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsCertificateRequestFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "connection", argType = TInterface "Gio" "TlsConnection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsCertificateRequestFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "TlsInteractionResult"
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_invoke_request_certificate" g_tls_interaction_invoke_request_certificate :: 
    Ptr TlsInteraction ->                   -- _obj : TInterface "Gio" "TlsInteraction"
    Ptr TlsConnection ->                    -- connection : TInterface "Gio" "TlsConnection"
    CUInt ->                                -- flags : TInterface "Gio" "TlsCertificateRequestFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO CUInt


tlsInteractionInvokeRequestCertificate ::
    (MonadIO m, TlsInteractionK a, TlsConnectionK b, CancellableK c) =>
    a ->                                    -- _obj
    b ->                                    -- connection
    TlsCertificateRequestFlags ->           -- flags
    Maybe (c) ->                            -- cancellable
    m TlsInteractionResult
tlsInteractionInvokeRequestCertificate _obj connection flags cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let connection' = unsafeManagedPtrCastPtr connection
    let flags' = (fromIntegral . fromEnum) flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_tls_interaction_invoke_request_certificate _obj' connection' flags' maybeCancellable
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr _obj
        touchManagedPtr connection
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

-- method TlsInteraction::request_certificate
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "connection", argType = TInterface "Gio" "TlsConnection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsCertificateRequestFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "connection", argType = TInterface "Gio" "TlsConnection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsCertificateRequestFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "TlsInteractionResult"
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_request_certificate" g_tls_interaction_request_certificate :: 
    Ptr TlsInteraction ->                   -- _obj : TInterface "Gio" "TlsInteraction"
    Ptr TlsConnection ->                    -- connection : TInterface "Gio" "TlsConnection"
    CUInt ->                                -- flags : TInterface "Gio" "TlsCertificateRequestFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO CUInt


tlsInteractionRequestCertificate ::
    (MonadIO m, TlsInteractionK a, TlsConnectionK b, CancellableK c) =>
    a ->                                    -- _obj
    b ->                                    -- connection
    TlsCertificateRequestFlags ->           -- flags
    Maybe (c) ->                            -- cancellable
    m TlsInteractionResult
tlsInteractionRequestCertificate _obj connection flags cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let connection' = unsafeManagedPtrCastPtr connection
    let flags' = (fromIntegral . fromEnum) flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_tls_interaction_request_certificate _obj' connection' flags' maybeCancellable
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr _obj
        touchManagedPtr connection
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

-- method TlsInteraction::request_certificate_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "connection", argType = TInterface "Gio" "TlsConnection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsCertificateRequestFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "connection", argType = TInterface "Gio" "TlsConnection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsCertificateRequestFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_tls_interaction_request_certificate_async" g_tls_interaction_request_certificate_async :: 
    Ptr TlsInteraction ->                   -- _obj : TInterface "Gio" "TlsInteraction"
    Ptr TlsConnection ->                    -- connection : TInterface "Gio" "TlsConnection"
    CUInt ->                                -- flags : TInterface "Gio" "TlsCertificateRequestFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


tlsInteractionRequestCertificateAsync ::
    (MonadIO m, TlsInteractionK a, TlsConnectionK b, CancellableK c) =>
    a ->                                    -- _obj
    b ->                                    -- connection
    TlsCertificateRequestFlags ->           -- flags
    Maybe (c) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
tlsInteractionRequestCertificateAsync _obj connection flags cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let connection' = unsafeManagedPtrCastPtr connection
    let flags' = (fromIntegral . fromEnum) flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    g_tls_interaction_request_certificate_async _obj' connection' flags' maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    touchManagedPtr connection
    whenJust cancellable touchManagedPtr
    return ()

-- method TlsInteraction::request_certificate_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "TlsInteractionResult"
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_interaction_request_certificate_finish" g_tls_interaction_request_certificate_finish :: 
    Ptr TlsInteraction ->                   -- _obj : TInterface "Gio" "TlsInteraction"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO CUInt


tlsInteractionRequestCertificateFinish ::
    (MonadIO m, TlsInteractionK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m TlsInteractionResult
tlsInteractionRequestCertificateFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_tls_interaction_request_certificate_finish _obj' result_'
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr _obj
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )