{- |
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.TlsDatabase
    ( 

-- * Exported types
    TlsDatabase(..)                         ,
    TlsDatabaseK                            ,
    toTlsDatabase                           ,
    noTlsDatabase                           ,


 -- * Methods
-- ** tlsDatabaseCreateCertificateHandle
    tlsDatabaseCreateCertificateHandle      ,


-- ** tlsDatabaseLookupCertificateForHandle
    tlsDatabaseLookupCertificateForHandle   ,


-- ** tlsDatabaseLookupCertificateForHandleAsync
    tlsDatabaseLookupCertificateForHandleAsync,


-- ** tlsDatabaseLookupCertificateForHandleFinish
    tlsDatabaseLookupCertificateForHandleFinish,


-- ** tlsDatabaseLookupCertificateIssuer
    tlsDatabaseLookupCertificateIssuer      ,


-- ** tlsDatabaseLookupCertificateIssuerAsync
    tlsDatabaseLookupCertificateIssuerAsync ,


-- ** tlsDatabaseLookupCertificateIssuerFinish
    tlsDatabaseLookupCertificateIssuerFinish,


-- ** tlsDatabaseLookupCertificatesIssuedBy
    tlsDatabaseLookupCertificatesIssuedBy   ,


-- ** tlsDatabaseLookupCertificatesIssuedByAsync
    tlsDatabaseLookupCertificatesIssuedByAsync,


-- ** tlsDatabaseLookupCertificatesIssuedByFinish
    tlsDatabaseLookupCertificatesIssuedByFinish,


-- ** tlsDatabaseVerifyChain
    tlsDatabaseVerifyChain                  ,


-- ** tlsDatabaseVerifyChainAsync
    tlsDatabaseVerifyChainAsync             ,


-- ** tlsDatabaseVerifyChainFinish
    tlsDatabaseVerifyChainFinish            ,




    ) 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 TlsDatabase = TlsDatabase (ForeignPtr TlsDatabase)
foreign import ccall "g_tls_database_get_type"
    c_g_tls_database_get_type :: IO GType

type instance ParentTypes TlsDatabase = TlsDatabaseParentTypes
type TlsDatabaseParentTypes = '[GObject.Object]

instance GObject TlsDatabase where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_tls_database_get_type
    

class GObject o => TlsDatabaseK o
instance (GObject o, IsDescendantOf TlsDatabase o) => TlsDatabaseK o

toTlsDatabase :: TlsDatabaseK o => o -> IO TlsDatabase
toTlsDatabase = unsafeCastTo TlsDatabase

noTlsDatabase :: Maybe TlsDatabase
noTlsDatabase = Nothing

type instance AttributeList TlsDatabase = TlsDatabaseAttributeList
type TlsDatabaseAttributeList = ('[ ] :: [(Symbol, *)])

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

-- method TlsDatabase::create_certificate_handle
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "certificate", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "certificate", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "g_tls_database_create_certificate_handle" g_tls_database_create_certificate_handle :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    Ptr TlsCertificate ->                   -- certificate : TInterface "Gio" "TlsCertificate"
    IO CString


tlsDatabaseCreateCertificateHandle ::
    (MonadIO m, TlsDatabaseK a, TlsCertificateK b) =>
    a ->                                    -- _obj
    b ->                                    -- certificate
    m T.Text
tlsDatabaseCreateCertificateHandle _obj certificate = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let certificate' = unsafeManagedPtrCastPtr certificate
    result <- g_tls_database_create_certificate_handle _obj' certificate'
    checkUnexpectedReturnNULL "g_tls_database_create_certificate_handle" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    touchManagedPtr certificate
    return result'

-- method TlsDatabase::lookup_certificate_for_handle
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "handle", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "handle", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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" "TlsCertificate"
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_database_lookup_certificate_for_handle" g_tls_database_lookup_certificate_for_handle :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    CString ->                              -- handle : TBasicType TUTF8
    Ptr TlsInteraction ->                   -- interaction : TInterface "Gio" "TlsInteraction"
    CUInt ->                                -- flags : TInterface "Gio" "TlsDatabaseLookupFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr TlsCertificate)


tlsDatabaseLookupCertificateForHandle ::
    (MonadIO m, TlsDatabaseK a, TlsInteractionK b, CancellableK c) =>
    a ->                                    -- _obj
    T.Text ->                               -- handle
    Maybe (b) ->                            -- interaction
    TlsDatabaseLookupFlags ->               -- flags
    Maybe (c) ->                            -- cancellable
    m TlsCertificate
tlsDatabaseLookupCertificateForHandle _obj handle interaction flags cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    handle' <- textToCString handle
    maybeInteraction <- case interaction of
        Nothing -> return nullPtr
        Just jInteraction -> do
            let jInteraction' = unsafeManagedPtrCastPtr jInteraction
            return jInteraction'
    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_database_lookup_certificate_for_handle _obj' handle' maybeInteraction flags' maybeCancellable
        checkUnexpectedReturnNULL "g_tls_database_lookup_certificate_for_handle" result
        result' <- (wrapObject TlsCertificate) result
        touchManagedPtr _obj
        whenJust interaction touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem handle'
        return result'
     ) (do
        freeMem handle'
     )

-- method TlsDatabase::lookup_certificate_for_handle_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "handle", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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 = 6, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "handle", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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 = 6, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_tls_database_lookup_certificate_for_handle_async" g_tls_database_lookup_certificate_for_handle_async :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    CString ->                              -- handle : TBasicType TUTF8
    Ptr TlsInteraction ->                   -- interaction : TInterface "Gio" "TlsInteraction"
    CUInt ->                                -- flags : TInterface "Gio" "TlsDatabaseLookupFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


tlsDatabaseLookupCertificateForHandleAsync ::
    (MonadIO m, TlsDatabaseK a, TlsInteractionK b, CancellableK c) =>
    a ->                                    -- _obj
    T.Text ->                               -- handle
    Maybe (b) ->                            -- interaction
    TlsDatabaseLookupFlags ->               -- flags
    Maybe (c) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
tlsDatabaseLookupCertificateForHandleAsync _obj handle interaction flags cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    handle' <- textToCString handle
    maybeInteraction <- case interaction of
        Nothing -> return nullPtr
        Just jInteraction -> do
            let jInteraction' = unsafeManagedPtrCastPtr jInteraction
            return jInteraction'
    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_database_lookup_certificate_for_handle_async _obj' handle' maybeInteraction flags' maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust interaction touchManagedPtr
    whenJust cancellable touchManagedPtr
    freeMem handle'
    return ()

-- method TlsDatabase::lookup_certificate_for_handle_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", 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" "TlsDatabase", 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" "TlsCertificate"
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_database_lookup_certificate_for_handle_finish" g_tls_database_lookup_certificate_for_handle_finish :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr TlsCertificate)


tlsDatabaseLookupCertificateForHandleFinish ::
    (MonadIO m, TlsDatabaseK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m TlsCertificate
tlsDatabaseLookupCertificateForHandleFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_tls_database_lookup_certificate_for_handle_finish _obj' result_'
        checkUnexpectedReturnNULL "g_tls_database_lookup_certificate_for_handle_finish" result
        result' <- (wrapObject TlsCertificate) result
        touchManagedPtr _obj
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )

-- method TlsDatabase::lookup_certificate_issuer
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "certificate", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "certificate", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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" "TlsCertificate"
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_database_lookup_certificate_issuer" g_tls_database_lookup_certificate_issuer :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    Ptr TlsCertificate ->                   -- certificate : TInterface "Gio" "TlsCertificate"
    Ptr TlsInteraction ->                   -- interaction : TInterface "Gio" "TlsInteraction"
    CUInt ->                                -- flags : TInterface "Gio" "TlsDatabaseLookupFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr TlsCertificate)


tlsDatabaseLookupCertificateIssuer ::
    (MonadIO m, TlsDatabaseK a, TlsCertificateK b, TlsInteractionK c, CancellableK d) =>
    a ->                                    -- _obj
    b ->                                    -- certificate
    Maybe (c) ->                            -- interaction
    TlsDatabaseLookupFlags ->               -- flags
    Maybe (d) ->                            -- cancellable
    m TlsCertificate
tlsDatabaseLookupCertificateIssuer _obj certificate interaction flags cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let certificate' = unsafeManagedPtrCastPtr certificate
    maybeInteraction <- case interaction of
        Nothing -> return nullPtr
        Just jInteraction -> do
            let jInteraction' = unsafeManagedPtrCastPtr jInteraction
            return jInteraction'
    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_database_lookup_certificate_issuer _obj' certificate' maybeInteraction flags' maybeCancellable
        checkUnexpectedReturnNULL "g_tls_database_lookup_certificate_issuer" result
        result' <- (wrapObject TlsCertificate) result
        touchManagedPtr _obj
        touchManagedPtr certificate
        whenJust interaction touchManagedPtr
        whenJust cancellable touchManagedPtr
        return result'
     ) (do
        return ()
     )

-- method TlsDatabase::lookup_certificate_issuer_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "certificate", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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 = 6, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "certificate", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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 = 6, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_tls_database_lookup_certificate_issuer_async" g_tls_database_lookup_certificate_issuer_async :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    Ptr TlsCertificate ->                   -- certificate : TInterface "Gio" "TlsCertificate"
    Ptr TlsInteraction ->                   -- interaction : TInterface "Gio" "TlsInteraction"
    CUInt ->                                -- flags : TInterface "Gio" "TlsDatabaseLookupFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


tlsDatabaseLookupCertificateIssuerAsync ::
    (MonadIO m, TlsDatabaseK a, TlsCertificateK b, TlsInteractionK c, CancellableK d) =>
    a ->                                    -- _obj
    b ->                                    -- certificate
    Maybe (c) ->                            -- interaction
    TlsDatabaseLookupFlags ->               -- flags
    Maybe (d) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
tlsDatabaseLookupCertificateIssuerAsync _obj certificate interaction flags cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let certificate' = unsafeManagedPtrCastPtr certificate
    maybeInteraction <- case interaction of
        Nothing -> return nullPtr
        Just jInteraction -> do
            let jInteraction' = unsafeManagedPtrCastPtr jInteraction
            return jInteraction'
    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_database_lookup_certificate_issuer_async _obj' certificate' maybeInteraction flags' maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    touchManagedPtr certificate
    whenJust interaction touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

-- method TlsDatabase::lookup_certificate_issuer_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", 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" "TlsDatabase", 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" "TlsCertificate"
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_database_lookup_certificate_issuer_finish" g_tls_database_lookup_certificate_issuer_finish :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr TlsCertificate)


tlsDatabaseLookupCertificateIssuerFinish ::
    (MonadIO m, TlsDatabaseK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m TlsCertificate
tlsDatabaseLookupCertificateIssuerFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_tls_database_lookup_certificate_issuer_finish _obj' result_'
        checkUnexpectedReturnNULL "g_tls_database_lookup_certificate_issuer_finish" result
        result' <- (wrapObject TlsCertificate) result
        touchManagedPtr _obj
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )

-- method TlsDatabase::lookup_certificates_issued_by
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "issuer_raw_dn", argType = TByteArray, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "issuer_raw_dn", argType = TByteArray, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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 : TGList (TInterface "Gio" "TlsCertificate")
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_database_lookup_certificates_issued_by" g_tls_database_lookup_certificates_issued_by :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    Ptr GByteArray ->                       -- issuer_raw_dn : TByteArray
    Ptr TlsInteraction ->                   -- interaction : TInterface "Gio" "TlsInteraction"
    CUInt ->                                -- flags : TInterface "Gio" "TlsDatabaseLookupFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr TlsCertificate)))


tlsDatabaseLookupCertificatesIssuedBy ::
    (MonadIO m, TlsDatabaseK a, TlsInteractionK b, CancellableK c) =>
    a ->                                    -- _obj
    ByteString ->                           -- issuer_raw_dn
    Maybe (b) ->                            -- interaction
    TlsDatabaseLookupFlags ->               -- flags
    Maybe (c) ->                            -- cancellable
    m [TlsCertificate]
tlsDatabaseLookupCertificatesIssuedBy _obj issuer_raw_dn interaction flags cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    issuer_raw_dn' <- packGByteArray issuer_raw_dn
    maybeInteraction <- case interaction of
        Nothing -> return nullPtr
        Just jInteraction -> do
            let jInteraction' = unsafeManagedPtrCastPtr jInteraction
            return jInteraction'
    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_database_lookup_certificates_issued_by _obj' issuer_raw_dn' maybeInteraction flags' maybeCancellable
        checkUnexpectedReturnNULL "g_tls_database_lookup_certificates_issued_by" result
        result' <- unpackGList result
        result'' <- mapM (wrapObject TlsCertificate) result'
        g_list_free result
        touchManagedPtr _obj
        whenJust interaction touchManagedPtr
        whenJust cancellable touchManagedPtr
        unrefGByteArray issuer_raw_dn'
        return result''
     ) (do
        unrefGByteArray issuer_raw_dn'
     )

-- method TlsDatabase::lookup_certificates_issued_by_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "issuer_raw_dn", argType = TByteArray, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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 = 6, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "issuer_raw_dn", argType = TByteArray, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseLookupFlags", 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 = 6, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_tls_database_lookup_certificates_issued_by_async" g_tls_database_lookup_certificates_issued_by_async :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    Ptr GByteArray ->                       -- issuer_raw_dn : TByteArray
    Ptr TlsInteraction ->                   -- interaction : TInterface "Gio" "TlsInteraction"
    CUInt ->                                -- flags : TInterface "Gio" "TlsDatabaseLookupFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


tlsDatabaseLookupCertificatesIssuedByAsync ::
    (MonadIO m, TlsDatabaseK a, TlsInteractionK b, CancellableK c) =>
    a ->                                    -- _obj
    ByteString ->                           -- issuer_raw_dn
    Maybe (b) ->                            -- interaction
    TlsDatabaseLookupFlags ->               -- flags
    Maybe (c) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
tlsDatabaseLookupCertificatesIssuedByAsync _obj issuer_raw_dn interaction flags cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    issuer_raw_dn' <- packGByteArray issuer_raw_dn
    maybeInteraction <- case interaction of
        Nothing -> return nullPtr
        Just jInteraction -> do
            let jInteraction' = unsafeManagedPtrCastPtr jInteraction
            return jInteraction'
    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_database_lookup_certificates_issued_by_async _obj' issuer_raw_dn' maybeInteraction flags' maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust interaction touchManagedPtr
    whenJust cancellable touchManagedPtr
    unrefGByteArray issuer_raw_dn'
    return ()

-- method TlsDatabase::lookup_certificates_issued_by_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", 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" "TlsDatabase", 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 : TGList (TInterface "Gio" "TlsCertificate")
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_database_lookup_certificates_issued_by_finish" g_tls_database_lookup_certificates_issued_by_finish :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    Ptr AsyncResult ->                      -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr (GList (Ptr TlsCertificate)))


tlsDatabaseLookupCertificatesIssuedByFinish ::
    (MonadIO m, TlsDatabaseK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m [TlsCertificate]
tlsDatabaseLookupCertificatesIssuedByFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_tls_database_lookup_certificates_issued_by_finish _obj' result_'
        checkUnexpectedReturnNULL "g_tls_database_lookup_certificates_issued_by_finish" result
        result' <- unpackGList result
        result'' <- mapM (wrapObject TlsCertificate) result'
        g_list_free result
        touchManagedPtr _obj
        touchManagedPtr result_
        return result''
     ) (do
        return ()
     )

-- method TlsDatabase::verify_chain
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "chain", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "purpose", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "identity", argType = TInterface "Gio" "SocketConnectable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseVerifyFlags", 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" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "chain", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "purpose", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "identity", argType = TInterface "Gio" "SocketConnectable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseVerifyFlags", 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" "TlsCertificateFlags"
-- throws : True
-- Skip return : False

foreign import ccall "g_tls_database_verify_chain" g_tls_database_verify_chain :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    Ptr TlsCertificate ->                   -- chain : TInterface "Gio" "TlsCertificate"
    CString ->                              -- purpose : TBasicType TUTF8
    Ptr SocketConnectable ->                -- identity : TInterface "Gio" "SocketConnectable"
    Ptr TlsInteraction ->                   -- interaction : TInterface "Gio" "TlsInteraction"
    CUInt ->                                -- flags : TInterface "Gio" "TlsDatabaseVerifyFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    Ptr (Ptr GError) ->                     -- error
    IO CUInt


tlsDatabaseVerifyChain ::
    (MonadIO m, TlsDatabaseK a, TlsCertificateK b, SocketConnectableK c, TlsInteractionK d, CancellableK e) =>
    a ->                                    -- _obj
    b ->                                    -- chain
    T.Text ->                               -- purpose
    Maybe (c) ->                            -- identity
    Maybe (d) ->                            -- interaction
    [TlsDatabaseVerifyFlags] ->             -- flags
    Maybe (e) ->                            -- cancellable
    m [TlsCertificateFlags]
tlsDatabaseVerifyChain _obj chain purpose identity interaction flags cancellable = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let chain' = unsafeManagedPtrCastPtr chain
    purpose' <- textToCString purpose
    maybeIdentity <- case identity of
        Nothing -> return nullPtr
        Just jIdentity -> do
            let jIdentity' = unsafeManagedPtrCastPtr jIdentity
            return jIdentity'
    maybeInteraction <- case interaction of
        Nothing -> return nullPtr
        Just jInteraction -> do
            let jInteraction' = unsafeManagedPtrCastPtr jInteraction
            return jInteraction'
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_tls_database_verify_chain _obj' chain' purpose' maybeIdentity maybeInteraction flags' maybeCancellable
        let result' = wordToGFlags result
        touchManagedPtr _obj
        touchManagedPtr chain
        whenJust identity touchManagedPtr
        whenJust interaction touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem purpose'
        return result'
     ) (do
        freeMem purpose'
     )

-- method TlsDatabase::verify_chain_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "chain", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "purpose", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "identity", argType = TInterface "Gio" "SocketConnectable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseVerifyFlags", 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 = 8, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "chain", argType = TInterface "Gio" "TlsCertificate", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "purpose", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "identity", argType = TInterface "Gio" "SocketConnectable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "interaction", argType = TInterface "Gio" "TlsInteraction", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gio" "TlsDatabaseVerifyFlags", 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 = 8, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_tls_database_verify_chain_async" g_tls_database_verify_chain_async :: 
    Ptr TlsDatabase ->                      -- _obj : TInterface "Gio" "TlsDatabase"
    Ptr TlsCertificate ->                   -- chain : TInterface "Gio" "TlsCertificate"
    CString ->                              -- purpose : TBasicType TUTF8
    Ptr SocketConnectable ->                -- identity : TInterface "Gio" "SocketConnectable"
    Ptr TlsInteraction ->                   -- interaction : TInterface "Gio" "TlsInteraction"
    CUInt ->                                -- flags : TInterface "Gio" "TlsDatabaseVerifyFlags"
    Ptr Cancellable ->                      -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr AsyncReadyCallbackC ->           -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


tlsDatabaseVerifyChainAsync ::
    (MonadIO m, TlsDatabaseK a, TlsCertificateK b, SocketConnectableK c, TlsInteractionK d, CancellableK e) =>
    a ->                                    -- _obj
    b ->                                    -- chain
    T.Text ->                               -- purpose
    Maybe (c) ->                            -- identity
    Maybe (d) ->                            -- interaction
    [TlsDatabaseVerifyFlags] ->             -- flags
    Maybe (e) ->                            -- cancellable
    Maybe (AsyncReadyCallback) ->           -- callback
    m ()
tlsDatabaseVerifyChainAsync _obj chain purpose identity interaction flags cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let chain' = unsafeManagedPtrCastPtr chain
    purpose' <- textToCString purpose
    maybeIdentity <- case identity of
        Nothing -> return nullPtr
        Just jIdentity -> do
            let jIdentity' = unsafeManagedPtrCastPtr jIdentity
            return jIdentity'
    maybeInteraction <- case interaction of
        Nothing -> return nullPtr
        Just jInteraction -> do
            let jInteraction' = unsafeManagedPtrCastPtr jInteraction
            return jInteraction'
    let flags' = gflagsToWord 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_database_verify_chain_async _obj' chain' purpose' maybeIdentity maybeInteraction flags' maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    touchManagedPtr chain
    whenJust identity touchManagedPtr
    whenJust interaction touchManagedPtr
    whenJust cancellable touchManagedPtr
    freeMem purpose'
    return ()

-- method TlsDatabase::verify_chain_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "TlsDatabase", 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" "TlsDatabase", 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" "TlsCertificateFlags"
-- throws : True
-- Skip return : False

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


tlsDatabaseVerifyChainFinish ::
    (MonadIO m, TlsDatabaseK a, AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m [TlsCertificateFlags]
tlsDatabaseVerifyChainFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ g_tls_database_verify_chain_finish _obj' result_'
        let result' = wordToGFlags result
        touchManagedPtr _obj
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )