{- |
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.Soup.Callbacks
    ( 

 -- * Signals
-- ** AddressCallback #signal:AddressCallback#
    AddressCallback                         ,
    AddressCallback_WithClosures            ,
    C_AddressCallback                       ,
    drop_closures_AddressCallback           ,
    dynamic_AddressCallback                 ,
    genClosure_AddressCallback              ,
    mk_AddressCallback                      ,
    noAddressCallback                       ,
    noAddressCallback_WithClosures          ,
    wrap_AddressCallback                    ,


-- ** AuthDomainBasicAuthCallback #signal:AuthDomainBasicAuthCallback#
    AuthDomainBasicAuthCallback             ,
    AuthDomainBasicAuthCallback_WithClosures,
    C_AuthDomainBasicAuthCallback           ,
    drop_closures_AuthDomainBasicAuthCallback,
    dynamic_AuthDomainBasicAuthCallback     ,
    genClosure_AuthDomainBasicAuthCallback  ,
    mk_AuthDomainBasicAuthCallback          ,
    noAuthDomainBasicAuthCallback           ,
    noAuthDomainBasicAuthCallback_WithClosures,
    wrap_AuthDomainBasicAuthCallback        ,


-- ** AuthDomainDigestAuthCallback #signal:AuthDomainDigestAuthCallback#
    AuthDomainDigestAuthCallback            ,
    AuthDomainDigestAuthCallback_WithClosures,
    C_AuthDomainDigestAuthCallback          ,
    drop_closures_AuthDomainDigestAuthCallback,
    dynamic_AuthDomainDigestAuthCallback    ,
    genClosure_AuthDomainDigestAuthCallback ,
    mk_AuthDomainDigestAuthCallback         ,
    noAuthDomainDigestAuthCallback          ,
    noAuthDomainDigestAuthCallback_WithClosures,
    wrap_AuthDomainDigestAuthCallback       ,


-- ** AuthDomainFilter #signal:AuthDomainFilter#
    AuthDomainFilter                        ,
    AuthDomainFilter_WithClosures           ,
    C_AuthDomainFilter                      ,
    drop_closures_AuthDomainFilter          ,
    dynamic_AuthDomainFilter                ,
    genClosure_AuthDomainFilter             ,
    mk_AuthDomainFilter                     ,
    noAuthDomainFilter                      ,
    noAuthDomainFilter_WithClosures         ,
    wrap_AuthDomainFilter                   ,


-- ** AuthDomainGenericAuthCallback #signal:AuthDomainGenericAuthCallback#
    AuthDomainGenericAuthCallback           ,
    AuthDomainGenericAuthCallback_WithClosures,
    C_AuthDomainGenericAuthCallback         ,
    drop_closures_AuthDomainGenericAuthCallback,
    dynamic_AuthDomainGenericAuthCallback   ,
    genClosure_AuthDomainGenericAuthCallback,
    mk_AuthDomainGenericAuthCallback        ,
    noAuthDomainGenericAuthCallback         ,
    noAuthDomainGenericAuthCallback_WithClosures,
    wrap_AuthDomainGenericAuthCallback      ,


-- ** ChunkAllocator #signal:ChunkAllocator#
    C_ChunkAllocator                        ,
    ChunkAllocator                          ,
    ChunkAllocator_WithClosures             ,
    drop_closures_ChunkAllocator            ,
    dynamic_ChunkAllocator                  ,
    genClosure_ChunkAllocator               ,
    mk_ChunkAllocator                       ,
    noChunkAllocator                        ,
    noChunkAllocator_WithClosures           ,
    wrap_ChunkAllocator                     ,


-- ** LoggerFilter #signal:LoggerFilter#
    C_LoggerFilter                          ,
    LoggerFilter                            ,
    LoggerFilter_WithClosures               ,
    drop_closures_LoggerFilter              ,
    dynamic_LoggerFilter                    ,
    genClosure_LoggerFilter                 ,
    mk_LoggerFilter                         ,
    noLoggerFilter                          ,
    noLoggerFilter_WithClosures             ,
    wrap_LoggerFilter                       ,


-- ** LoggerPrinter #signal:LoggerPrinter#
    C_LoggerPrinter                         ,
    LoggerPrinter                           ,
    LoggerPrinter_WithClosures              ,
    drop_closures_LoggerPrinter             ,
    dynamic_LoggerPrinter                   ,
    genClosure_LoggerPrinter                ,
    mk_LoggerPrinter                        ,
    noLoggerPrinter                         ,
    noLoggerPrinter_WithClosures            ,
    wrap_LoggerPrinter                      ,


-- ** MessageHeadersForeachFunc #signal:MessageHeadersForeachFunc#
    C_MessageHeadersForeachFunc             ,
    MessageHeadersForeachFunc               ,
    MessageHeadersForeachFunc_WithClosures  ,
    drop_closures_MessageHeadersForeachFunc ,
    dynamic_MessageHeadersForeachFunc       ,
    genClosure_MessageHeadersForeachFunc    ,
    mk_MessageHeadersForeachFunc            ,
    noMessageHeadersForeachFunc             ,
    noMessageHeadersForeachFunc_WithClosures,
    wrap_MessageHeadersForeachFunc          ,


-- ** PasswordManagerCallback #signal:PasswordManagerCallback#
    C_PasswordManagerCallback               ,
    PasswordManagerCallback                 ,
    PasswordManagerCallback_WithClosures    ,
    drop_closures_PasswordManagerCallback   ,
    dynamic_PasswordManagerCallback         ,
    genClosure_PasswordManagerCallback      ,
    mk_PasswordManagerCallback              ,
    noPasswordManagerCallback               ,
    noPasswordManagerCallback_WithClosures  ,
    wrap_PasswordManagerCallback            ,


-- ** ProxyURIResolverCallback #signal:ProxyURIResolverCallback#
    C_ProxyURIResolverCallback              ,
    ProxyURIResolverCallback                ,
    ProxyURIResolverCallback_WithClosures   ,
    drop_closures_ProxyURIResolverCallback  ,
    dynamic_ProxyURIResolverCallback        ,
    genClosure_ProxyURIResolverCallback     ,
    mk_ProxyURIResolverCallback             ,
    noProxyURIResolverCallback              ,
    noProxyURIResolverCallback_WithClosures ,
    wrap_ProxyURIResolverCallback           ,


-- ** ServerCallback #signal:ServerCallback#
    C_ServerCallback                        ,
    ServerCallback                          ,
    ServerCallback_WithClosures             ,
    drop_closures_ServerCallback            ,
    dynamic_ServerCallback                  ,
    genClosure_ServerCallback               ,
    mk_ServerCallback                       ,
    noServerCallback                        ,
    noServerCallback_WithClosures           ,
    wrap_ServerCallback                     ,


-- ** ServerWebsocketCallback #signal:ServerWebsocketCallback#
    C_ServerWebsocketCallback               ,
    ServerWebsocketCallback                 ,
    ServerWebsocketCallback_WithClosures    ,
    drop_closures_ServerWebsocketCallback   ,
    dynamic_ServerWebsocketCallback         ,
    genClosure_ServerWebsocketCallback      ,
    mk_ServerWebsocketCallback              ,
    noServerWebsocketCallback               ,
    noServerWebsocketCallback_WithClosures  ,
    wrap_ServerWebsocketCallback            ,


-- ** SessionCallback #signal:SessionCallback#
    C_SessionCallback                       ,
    SessionCallback                         ,
    SessionCallback_WithClosures            ,
    drop_closures_SessionCallback           ,
    dynamic_SessionCallback                 ,
    genClosure_SessionCallback              ,
    mk_SessionCallback                      ,
    noSessionCallback                       ,
    noSessionCallback_WithClosures          ,
    wrap_SessionCallback                    ,


-- ** SocketCallback #signal:SocketCallback#
    C_SocketCallback                        ,
    SocketCallback                          ,
    SocketCallback_WithClosures             ,
    drop_closures_SocketCallback            ,
    dynamic_SocketCallback                  ,
    genClosure_SocketCallback               ,
    mk_SocketCallback                       ,
    noSocketCallback                        ,
    noSocketCallback_WithClosures           ,
    wrap_SocketCallback                     ,




    ) 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 {-# SOURCE #-} qualified GI.Soup.Enums as Soup.Enums
import {-# SOURCE #-} qualified GI.Soup.Interfaces.PasswordManager as Soup.PasswordManager
import {-# SOURCE #-} qualified GI.Soup.Interfaces.ProxyURIResolver as Soup.ProxyURIResolver
import {-# SOURCE #-} qualified GI.Soup.Objects.Address as Soup.Address
import {-# SOURCE #-} qualified GI.Soup.Objects.Auth as Soup.Auth
import {-# SOURCE #-} qualified GI.Soup.Objects.AuthDomain as Soup.AuthDomain
import {-# SOURCE #-} qualified GI.Soup.Objects.Logger as Soup.Logger
import {-# SOURCE #-} qualified GI.Soup.Objects.Message as Soup.Message
import {-# SOURCE #-} qualified GI.Soup.Objects.Server as Soup.Server
import {-# SOURCE #-} qualified GI.Soup.Objects.Session as Soup.Session
import {-# SOURCE #-} qualified GI.Soup.Objects.Socket as Soup.Socket
import {-# SOURCE #-} qualified GI.Soup.Objects.WebsocketConnection as Soup.WebsocketConnection
import {-# SOURCE #-} qualified GI.Soup.Structs.Buffer as Soup.Buffer
import {-# SOURCE #-} qualified GI.Soup.Structs.ClientContext as Soup.ClientContext
import {-# SOURCE #-} qualified GI.Soup.Structs.URI as Soup.URI

-- callback SocketCallback
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "status", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an HTTP status code indicating success or failure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_socket_connect_async()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The callback function passed to soup_socket_connect_async().", sinceVersion = Nothing}}
type C_SocketCallback =
    Ptr Soup.Socket.Socket ->
    Word32 ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "sock", argType = TInterface (Name {namespace = "Soup", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "status", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an HTTP status code indicating success or failure", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_socket_connect_async()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_SocketCallback :: FunPtr C_SocketCallback -> C_SocketCallback

dynamic_SocketCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Socket.IsSocket a) =>
    FunPtr C_SocketCallback
    -> a
    {- ^ /@sock@/: the 'GI.Soup.Objects.Socket.Socket' -}
    -> Word32
    {- ^ /@status@/: an HTTP status code indicating success or failure -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.Socket.socketConnectAsync' -}
    -> m ()
dynamic_SocketCallback __funPtr sock status userData = liftIO $ do
    sock' <- unsafeManagedPtrCastPtr sock
    (__dynamic_C_SocketCallback __funPtr) sock' status userData
    touchManagedPtr sock
    return ()

foreign import ccall "wrapper"
    mk_SocketCallback :: C_SocketCallback -> IO (FunPtr C_SocketCallback)

type SocketCallback =
    Soup.Socket.Socket ->
    Word32 ->
    IO ()

noSocketCallback :: Maybe SocketCallback
noSocketCallback = Nothing

type SocketCallback_WithClosures =
    Soup.Socket.Socket ->
    Word32 ->
    Ptr () ->
    IO ()

noSocketCallback_WithClosures :: Maybe SocketCallback_WithClosures
noSocketCallback_WithClosures = Nothing

drop_closures_SocketCallback :: SocketCallback -> SocketCallback_WithClosures
drop_closures_SocketCallback _f sock status _ = _f sock status

genClosure_SocketCallback :: SocketCallback -> IO Closure
genClosure_SocketCallback cb = do
    let cb' = drop_closures_SocketCallback cb
    let cb'' = wrap_SocketCallback Nothing cb'
    mk_SocketCallback cb'' >>= newCClosure


wrap_SocketCallback ::
    Maybe (Ptr (FunPtr C_SocketCallback)) ->
    SocketCallback_WithClosures ->
    Ptr Soup.Socket.Socket ->
    Word32 ->
    Ptr () ->
    IO ()
wrap_SocketCallback funptrptr _cb sock status userData = do
    sock' <- (newObject Soup.Socket.Socket) sock
    _cb  sock' status userData
    maybeReleaseFunPtr funptrptr


-- callback SessionCallback
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "session", argType = TInterface (Name {namespace = "Soup", name = "Session"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the session", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message that has finished", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_session_queue_message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Prototype for the callback passed to soup_session_queue_message(),\nqv.", sinceVersion = Nothing}}
type C_SessionCallback =
    Ptr Soup.Session.Session ->
    Ptr Soup.Message.Message ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "session", argType = TInterface (Name {namespace = "Soup", name = "Session"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the session", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message that has finished", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_session_queue_message", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_SessionCallback :: FunPtr C_SessionCallback -> C_SessionCallback

dynamic_SessionCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Session.IsSession a, Soup.Message.IsMessage b) =>
    FunPtr C_SessionCallback
    -> a
    {- ^ /@session@/: the session -}
    -> b
    {- ^ /@msg@/: the message that has finished -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to soup_session_queue_message -}
    -> m ()
dynamic_SessionCallback __funPtr session msg userData = liftIO $ do
    session' <- unsafeManagedPtrCastPtr session
    msg' <- unsafeManagedPtrCastPtr msg
    (__dynamic_C_SessionCallback __funPtr) session' msg' userData
    touchManagedPtr session
    touchManagedPtr msg
    return ()

foreign import ccall "wrapper"
    mk_SessionCallback :: C_SessionCallback -> IO (FunPtr C_SessionCallback)

type SessionCallback =
    Soup.Session.Session ->
    Soup.Message.Message ->
    IO ()

noSessionCallback :: Maybe SessionCallback
noSessionCallback = Nothing

type SessionCallback_WithClosures =
    Soup.Session.Session ->
    Soup.Message.Message ->
    Ptr () ->
    IO ()

noSessionCallback_WithClosures :: Maybe SessionCallback_WithClosures
noSessionCallback_WithClosures = Nothing

drop_closures_SessionCallback :: SessionCallback -> SessionCallback_WithClosures
drop_closures_SessionCallback _f session msg _ = _f session msg

genClosure_SessionCallback :: SessionCallback -> IO Closure
genClosure_SessionCallback cb = do
    let cb' = drop_closures_SessionCallback cb
    let cb'' = wrap_SessionCallback Nothing cb'
    mk_SessionCallback cb'' >>= newCClosure


wrap_SessionCallback ::
    Maybe (Ptr (FunPtr C_SessionCallback)) ->
    SessionCallback_WithClosures ->
    Ptr Soup.Session.Session ->
    Ptr Soup.Message.Message ->
    Ptr () ->
    IO ()
wrap_SessionCallback funptrptr _cb session msg userData = do
    session' <- (newObject Soup.Session.Session) session
    msg' <- (newObject Soup.Message.Message) msg
    _cb  session' msg' userData
    maybeReleaseFunPtr funptrptr


-- callback ServerWebsocketCallback
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "connection", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the newly created WebSocket connection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the path component of @msg's Request-URI", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "client", argType = TInterface (Name {namespace = "Soup", name = "ClientContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "additional contextual information about the client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to @soup_server_add_handler", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A callback used to handle WebSocket requests to a #SoupServer. The\ncallback will be invoked after sending the handshake response back\nto the client (and is only invoked if the handshake was\nsuccessful).\n\n@path contains the path of the Request-URI, subject to the same\nrules as #SoupServerCallback (qv).", sinceVersion = Nothing}}
type C_ServerWebsocketCallback =
    Ptr Soup.Server.Server ->
    Ptr Soup.WebsocketConnection.WebsocketConnection ->
    CString ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "connection", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the newly created WebSocket connection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the path component of @msg's Request-URI", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "client", argType = TInterface (Name {namespace = "Soup", name = "ClientContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "additional contextual information about the client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to @soup_server_add_handler", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_ServerWebsocketCallback :: FunPtr C_ServerWebsocketCallback -> C_ServerWebsocketCallback

dynamic_ServerWebsocketCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Server.IsServer a, Soup.WebsocketConnection.IsWebsocketConnection b) =>
    FunPtr C_ServerWebsocketCallback
    -> a
    {- ^ /@server@/: the 'GI.Soup.Objects.Server.Server' -}
    -> b
    {- ^ /@connection@/: the newly created WebSocket connection -}
    -> T.Text
    {- ^ /@path@/: the path component of /@msg@/\'s Request-URI -}
    -> Soup.ClientContext.ClientContext
    {- ^ /@client@/: additional contextual information about the client -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to /@soupServerAddHandler@/ -}
    -> m ()
dynamic_ServerWebsocketCallback __funPtr server connection path client userData = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    connection' <- unsafeManagedPtrCastPtr connection
    path' <- textToCString path
    client' <- unsafeManagedPtrGetPtr client
    (__dynamic_C_ServerWebsocketCallback __funPtr) server' connection' path' client' userData
    touchManagedPtr server
    touchManagedPtr connection
    touchManagedPtr client
    freeMem path'
    return ()

foreign import ccall "wrapper"
    mk_ServerWebsocketCallback :: C_ServerWebsocketCallback -> IO (FunPtr C_ServerWebsocketCallback)

type ServerWebsocketCallback =
    Soup.Server.Server ->
    Soup.WebsocketConnection.WebsocketConnection ->
    T.Text ->
    Soup.ClientContext.ClientContext ->
    IO ()

noServerWebsocketCallback :: Maybe ServerWebsocketCallback
noServerWebsocketCallback = Nothing

type ServerWebsocketCallback_WithClosures =
    Soup.Server.Server ->
    Soup.WebsocketConnection.WebsocketConnection ->
    T.Text ->
    Soup.ClientContext.ClientContext ->
    Ptr () ->
    IO ()

noServerWebsocketCallback_WithClosures :: Maybe ServerWebsocketCallback_WithClosures
noServerWebsocketCallback_WithClosures = Nothing

drop_closures_ServerWebsocketCallback :: ServerWebsocketCallback -> ServerWebsocketCallback_WithClosures
drop_closures_ServerWebsocketCallback _f server connection path client _ = _f server connection path client

genClosure_ServerWebsocketCallback :: ServerWebsocketCallback -> IO Closure
genClosure_ServerWebsocketCallback cb = do
    let cb' = drop_closures_ServerWebsocketCallback cb
    let cb'' = wrap_ServerWebsocketCallback Nothing cb'
    mk_ServerWebsocketCallback cb'' >>= newCClosure


wrap_ServerWebsocketCallback ::
    Maybe (Ptr (FunPtr C_ServerWebsocketCallback)) ->
    ServerWebsocketCallback_WithClosures ->
    Ptr Soup.Server.Server ->
    Ptr Soup.WebsocketConnection.WebsocketConnection ->
    CString ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->
    IO ()
wrap_ServerWebsocketCallback funptrptr _cb server connection path client userData = do
    server' <- (newObject Soup.Server.Server) server
    connection' <- (newObject Soup.WebsocketConnection.WebsocketConnection) connection
    path' <- cstringToText path
    client' <- (newBoxed Soup.ClientContext.ClientContext) client
    _cb  server' connection' path' client' userData
    maybeReleaseFunPtr funptrptr


-- callback ServerCallback
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message being processed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the path component of @msg's Request-URI", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "query", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the parsed query\n  component of @msg's Request-URI", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "client", argType = TInterface (Name {namespace = "Soup", name = "ClientContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "additional contextual information about the client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_server_add_handler() or\n  soup_server_add_early_handler().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "A callback used to handle requests to a #SoupServer.\n\n@path and @query contain the likewise-named components of the\nRequest-URI, subject to certain assumptions. By default,\n#SoupServer decodes all percent-encoding in the URI path, such that\n\"/foo%<!-- -->2Fbar\" is treated the same as \"/foo/bar\". If your\nserver is serving resources in some non-POSIX-filesystem namespace,\nyou may want to distinguish those as two distinct paths. In that\ncase, you can set the %SOUP_SERVER_RAW_PATHS property when creating\nthe #SoupServer, and it will leave those characters undecoded. (You\nmay want to call soup_uri_normalize() to decode any percent-encoded\ncharacters that you aren't handling specially.)\n\n@query contains the query component of the Request-URI parsed\naccording to the rules for HTML form handling. Although this is the\nonly commonly-used query string format in HTTP, there is nothing\nthat actually requires that HTTP URIs use that format; if your\nserver needs to use some other format, you can just ignore @query,\nand call soup_message_get_uri() and parse the URI's query field\nyourself.\n\nSee soup_server_add_handler() and soup_server_add_early_handler()\nfor details of what handlers can/should do.", sinceVersion = Nothing}}
type C_ServerCallback =
    Ptr Soup.Server.Server ->
    Ptr Soup.Message.Message ->
    CString ->
    Ptr (GHashTable CString CString) ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message being processed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the path component of @msg's Request-URI", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "query", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the parsed query\n  component of @msg's Request-URI", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "client", argType = TInterface (Name {namespace = "Soup", name = "ClientContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "additional contextual information about the client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_server_add_handler() or\n  soup_server_add_early_handler().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 5, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_ServerCallback :: FunPtr C_ServerCallback -> C_ServerCallback

dynamic_ServerCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Server.IsServer a, Soup.Message.IsMessage b) =>
    FunPtr C_ServerCallback
    -> a
    {- ^ /@server@/: the 'GI.Soup.Objects.Server.Server' -}
    -> b
    {- ^ /@msg@/: the message being processed -}
    -> T.Text
    {- ^ /@path@/: the path component of /@msg@/\'s Request-URI -}
    -> Maybe (Map.Map T.Text T.Text)
    {- ^ /@query@/: the parsed query
  component of /@msg@/\'s Request-URI -}
    -> Soup.ClientContext.ClientContext
    {- ^ /@client@/: additional contextual information about the client -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.Server.serverAddHandler' or
  'GI.Soup.Objects.Server.serverAddEarlyHandler'. -}
    -> m ()
dynamic_ServerCallback __funPtr server msg path query client userData = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    msg' <- unsafeManagedPtrCastPtr msg
    path' <- textToCString path
    maybeQuery <- case query of
        Nothing -> return nullPtr
        Just jQuery -> do
            let jQuery' = Map.toList jQuery
            jQuery'' <- mapFirstA textToCString jQuery'
            jQuery''' <- mapSecondA textToCString jQuery''
            let jQuery'''' = mapFirst cstringPackPtr jQuery'''
            let jQuery''''' = mapSecond cstringPackPtr jQuery''''
            jQuery'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) jQuery'''''
            return jQuery''''''
    client' <- unsafeManagedPtrGetPtr client
    (__dynamic_C_ServerCallback __funPtr) server' msg' path' maybeQuery client' userData
    touchManagedPtr server
    touchManagedPtr msg
    touchManagedPtr client
    freeMem path'
    unrefGHashTable maybeQuery
    return ()

foreign import ccall "wrapper"
    mk_ServerCallback :: C_ServerCallback -> IO (FunPtr C_ServerCallback)

type ServerCallback =
    Soup.Server.Server ->
    Soup.Message.Message ->
    T.Text ->
    Maybe (Map.Map T.Text T.Text) ->
    Soup.ClientContext.ClientContext ->
    IO ()

noServerCallback :: Maybe ServerCallback
noServerCallback = Nothing

type ServerCallback_WithClosures =
    Soup.Server.Server ->
    Soup.Message.Message ->
    T.Text ->
    Maybe (Map.Map T.Text T.Text) ->
    Soup.ClientContext.ClientContext ->
    Ptr () ->
    IO ()

noServerCallback_WithClosures :: Maybe ServerCallback_WithClosures
noServerCallback_WithClosures = Nothing

drop_closures_ServerCallback :: ServerCallback -> ServerCallback_WithClosures
drop_closures_ServerCallback _f server msg path query client _ = _f server msg path query client

genClosure_ServerCallback :: ServerCallback -> IO Closure
genClosure_ServerCallback cb = do
    let cb' = drop_closures_ServerCallback cb
    let cb'' = wrap_ServerCallback Nothing cb'
    mk_ServerCallback cb'' >>= newCClosure


wrap_ServerCallback ::
    Maybe (Ptr (FunPtr C_ServerCallback)) ->
    ServerCallback_WithClosures ->
    Ptr Soup.Server.Server ->
    Ptr Soup.Message.Message ->
    CString ->
    Ptr (GHashTable CString CString) ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->
    IO ()
wrap_ServerCallback funptrptr _cb server msg path query client userData = do
    server' <- (newObject Soup.Server.Server) server
    msg' <- (newObject Soup.Message.Message) msg
    path' <- cstringToText path
    maybeQuery <-
        if query == nullPtr
        then return Nothing
        else do
            query' <- unpackGHashTable query
            let query'' = mapFirst cstringUnpackPtr query'
            query''' <- mapFirstA cstringToText query''
            let query'''' = mapSecond cstringUnpackPtr query'''
            query''''' <- mapSecondA cstringToText query''''
            let query'''''' = Map.fromList query'''''
            return $ Just query''''''
    client' <- (newBoxed Soup.ClientContext.ClientContext) client
    _cb  server' msg' path' maybeQuery client' userData
    maybeReleaseFunPtr funptrptr


-- callback ProxyURIResolverCallback
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "resolver", argType = TInterface (Name {namespace = "Soup", name = "ProxyURIResolver"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupProxyURIResolver", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "status", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupStatus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "proxy_uri", argType = TInterface (Name {namespace = "Soup", name = "URI"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the resolved proxy URI, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data passed to soup_proxy_uri_resolver_get_proxy_uri_async()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Callback for soup_proxy_uri_resolver_get_proxy_uri_async()", sinceVersion = Nothing}}
type C_ProxyURIResolverCallback =
    Ptr Soup.ProxyURIResolver.ProxyURIResolver ->
    Word32 ->
    Ptr Soup.URI.URI ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "resolver", argType = TInterface (Name {namespace = "Soup", name = "ProxyURIResolver"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupProxyURIResolver", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "status", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupStatus", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "proxy_uri", argType = TInterface (Name {namespace = "Soup", name = "URI"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the resolved proxy URI, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data passed to soup_proxy_uri_resolver_get_proxy_uri_async()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_ProxyURIResolverCallback :: FunPtr C_ProxyURIResolverCallback -> C_ProxyURIResolverCallback

dynamic_ProxyURIResolverCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.ProxyURIResolver.IsProxyURIResolver a) =>
    FunPtr C_ProxyURIResolverCallback
    -> a
    {- ^ /@resolver@/: the 'GI.Soup.Interfaces.ProxyURIResolver.ProxyURIResolver' -}
    -> Word32
    {- ^ /@status@/: a 'GI.Soup.Enums.Status' -}
    -> Soup.URI.URI
    {- ^ /@proxyUri@/: the resolved proxy URI, or 'Nothing' -}
    -> Ptr ()
    {- ^ /@userData@/: data passed to 'GI.Soup.Interfaces.ProxyURIResolver.proxyURIResolverGetProxyUriAsync' -}
    -> m ()
dynamic_ProxyURIResolverCallback __funPtr resolver status proxyUri userData = liftIO $ do
    resolver' <- unsafeManagedPtrCastPtr resolver
    proxyUri' <- unsafeManagedPtrGetPtr proxyUri
    (__dynamic_C_ProxyURIResolverCallback __funPtr) resolver' status proxyUri' userData
    touchManagedPtr resolver
    touchManagedPtr proxyUri
    return ()

foreign import ccall "wrapper"
    mk_ProxyURIResolverCallback :: C_ProxyURIResolverCallback -> IO (FunPtr C_ProxyURIResolverCallback)

type ProxyURIResolverCallback =
    Soup.ProxyURIResolver.ProxyURIResolver ->
    Word32 ->
    Soup.URI.URI ->
    IO ()

noProxyURIResolverCallback :: Maybe ProxyURIResolverCallback
noProxyURIResolverCallback = Nothing

type ProxyURIResolverCallback_WithClosures =
    Soup.ProxyURIResolver.ProxyURIResolver ->
    Word32 ->
    Soup.URI.URI ->
    Ptr () ->
    IO ()

noProxyURIResolverCallback_WithClosures :: Maybe ProxyURIResolverCallback_WithClosures
noProxyURIResolverCallback_WithClosures = Nothing

drop_closures_ProxyURIResolverCallback :: ProxyURIResolverCallback -> ProxyURIResolverCallback_WithClosures
drop_closures_ProxyURIResolverCallback _f resolver status proxyUri _ = _f resolver status proxyUri

genClosure_ProxyURIResolverCallback :: ProxyURIResolverCallback -> IO Closure
genClosure_ProxyURIResolverCallback cb = do
    let cb' = drop_closures_ProxyURIResolverCallback cb
    let cb'' = wrap_ProxyURIResolverCallback Nothing cb'
    mk_ProxyURIResolverCallback cb'' >>= newCClosure


wrap_ProxyURIResolverCallback ::
    Maybe (Ptr (FunPtr C_ProxyURIResolverCallback)) ->
    ProxyURIResolverCallback_WithClosures ->
    Ptr Soup.ProxyURIResolver.ProxyURIResolver ->
    Word32 ->
    Ptr Soup.URI.URI ->
    Ptr () ->
    IO ()
wrap_ProxyURIResolverCallback funptrptr _cb resolver status proxyUri userData = do
    resolver' <- (newObject Soup.ProxyURIResolver.ProxyURIResolver) resolver
    proxyUri' <- (newBoxed Soup.URI.URI) proxyUri
    _cb  resolver' status proxyUri' userData
    maybeReleaseFunPtr funptrptr


-- callback PasswordManagerCallback
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "password_manager", argType = TInterface (Name {namespace = "Soup", name = "PasswordManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "retrying", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}}
type C_PasswordManagerCallback =
    Ptr Soup.PasswordManager.PasswordManager ->
    Ptr Soup.Message.Message ->
    Ptr Soup.Auth.Auth ->
    CInt ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "password_manager", argType = TInterface (Name {namespace = "Soup", name = "PasswordManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "retrying", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_PasswordManagerCallback :: FunPtr C_PasswordManagerCallback -> C_PasswordManagerCallback

dynamic_PasswordManagerCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.PasswordManager.IsPasswordManager a, Soup.Message.IsMessage b, Soup.Auth.IsAuth c) =>
    FunPtr C_PasswordManagerCallback
    -> a
    -> b
    -> c
    -> Bool
    -> Ptr ()
    -> m ()
dynamic_PasswordManagerCallback __funPtr passwordManager msg auth retrying userData = liftIO $ do
    passwordManager' <- unsafeManagedPtrCastPtr passwordManager
    msg' <- unsafeManagedPtrCastPtr msg
    auth' <- unsafeManagedPtrCastPtr auth
    let retrying' = (fromIntegral . fromEnum) retrying
    (__dynamic_C_PasswordManagerCallback __funPtr) passwordManager' msg' auth' retrying' userData
    touchManagedPtr passwordManager
    touchManagedPtr msg
    touchManagedPtr auth
    return ()

foreign import ccall "wrapper"
    mk_PasswordManagerCallback :: C_PasswordManagerCallback -> IO (FunPtr C_PasswordManagerCallback)

type PasswordManagerCallback =
    Soup.PasswordManager.PasswordManager ->
    Soup.Message.Message ->
    Soup.Auth.Auth ->
    Bool ->
    IO ()

noPasswordManagerCallback :: Maybe PasswordManagerCallback
noPasswordManagerCallback = Nothing

type PasswordManagerCallback_WithClosures =
    Soup.PasswordManager.PasswordManager ->
    Soup.Message.Message ->
    Soup.Auth.Auth ->
    Bool ->
    Ptr () ->
    IO ()

noPasswordManagerCallback_WithClosures :: Maybe PasswordManagerCallback_WithClosures
noPasswordManagerCallback_WithClosures = Nothing

drop_closures_PasswordManagerCallback :: PasswordManagerCallback -> PasswordManagerCallback_WithClosures
drop_closures_PasswordManagerCallback _f passwordManager msg auth retrying _ = _f passwordManager msg auth retrying

genClosure_PasswordManagerCallback :: PasswordManagerCallback -> IO Closure
genClosure_PasswordManagerCallback cb = do
    let cb' = drop_closures_PasswordManagerCallback cb
    let cb'' = wrap_PasswordManagerCallback Nothing cb'
    mk_PasswordManagerCallback cb'' >>= newCClosure


wrap_PasswordManagerCallback ::
    Maybe (Ptr (FunPtr C_PasswordManagerCallback)) ->
    PasswordManagerCallback_WithClosures ->
    Ptr Soup.PasswordManager.PasswordManager ->
    Ptr Soup.Message.Message ->
    Ptr Soup.Auth.Auth ->
    CInt ->
    Ptr () ->
    IO ()
wrap_PasswordManagerCallback funptrptr _cb passwordManager msg auth retrying userData = do
    passwordManager' <- (newObject Soup.PasswordManager.PasswordManager) passwordManager
    msg' <- (newObject Soup.Message.Message) msg
    auth' <- (newObject Soup.Auth.Auth) auth
    let retrying' = (/= 0) retrying
    _cb  passwordManager' msg' auth' retrying' userData
    maybeReleaseFunPtr funptrptr


-- callback MessageHeadersForeachFunc
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the header name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the header value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_message_headers_foreach()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The callback passed to soup_message_headers_foreach().", sinceVersion = Nothing}}
type C_MessageHeadersForeachFunc =
    CString ->
    CString ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the header name", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the header value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_message_headers_foreach()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_MessageHeadersForeachFunc :: FunPtr C_MessageHeadersForeachFunc -> C_MessageHeadersForeachFunc

dynamic_MessageHeadersForeachFunc ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_MessageHeadersForeachFunc
    -> T.Text
    {- ^ /@name@/: the header name -}
    -> T.Text
    {- ^ /@value@/: the header value -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Structs.MessageHeaders.messageHeadersForeach' -}
    -> m ()
dynamic_MessageHeadersForeachFunc __funPtr name value userData = liftIO $ do
    name' <- textToCString name
    value' <- textToCString value
    (__dynamic_C_MessageHeadersForeachFunc __funPtr) name' value' userData
    freeMem name'
    freeMem value'
    return ()

foreign import ccall "wrapper"
    mk_MessageHeadersForeachFunc :: C_MessageHeadersForeachFunc -> IO (FunPtr C_MessageHeadersForeachFunc)

type MessageHeadersForeachFunc =
    T.Text ->
    T.Text ->
    IO ()

noMessageHeadersForeachFunc :: Maybe MessageHeadersForeachFunc
noMessageHeadersForeachFunc = Nothing

type MessageHeadersForeachFunc_WithClosures =
    T.Text ->
    T.Text ->
    Ptr () ->
    IO ()

noMessageHeadersForeachFunc_WithClosures :: Maybe MessageHeadersForeachFunc_WithClosures
noMessageHeadersForeachFunc_WithClosures = Nothing

drop_closures_MessageHeadersForeachFunc :: MessageHeadersForeachFunc -> MessageHeadersForeachFunc_WithClosures
drop_closures_MessageHeadersForeachFunc _f name value _ = _f name value

genClosure_MessageHeadersForeachFunc :: MessageHeadersForeachFunc -> IO Closure
genClosure_MessageHeadersForeachFunc cb = do
    let cb' = drop_closures_MessageHeadersForeachFunc cb
    let cb'' = wrap_MessageHeadersForeachFunc Nothing cb'
    mk_MessageHeadersForeachFunc cb'' >>= newCClosure


wrap_MessageHeadersForeachFunc ::
    Maybe (Ptr (FunPtr C_MessageHeadersForeachFunc)) ->
    MessageHeadersForeachFunc_WithClosures ->
    CString ->
    CString ->
    Ptr () ->
    IO ()
wrap_MessageHeadersForeachFunc funptrptr _cb name value userData = do
    name' <- cstringToText name
    value' <- cstringToText value
    _cb  name' value' userData
    maybeReleaseFunPtr funptrptr


-- callback LoggerPrinter
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "logger", argType = TInterface (Name {namespace = "Soup", name = "Logger"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupLogger", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "level", argType = TInterface (Name {namespace = "Soup", name = "LoggerLogLevel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the level of the information being printed.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "direction", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a single-character prefix to @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "data to print", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_logger_set_printer()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The prototype for a custom printing callback.\n\n@level indicates what kind of information is being printed. Eg, it\nwill be %SOUP_LOGGER_LOG_HEADERS if @data is header data.\n\n@direction is either '<', '>', or ' ', and @data is the single line\nto print; the printer is expected to add a terminating newline.\n\nTo get the effect of the default printer, you would do:\n\n<informalexample><programlisting>\nprintf (\"%c %s\\n\", direction, data);\n</programlisting></informalexample>", sinceVersion = Nothing}}
type C_LoggerPrinter =
    Ptr Soup.Logger.Logger ->
    CUInt ->
    Int8 ->
    CString ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "logger", argType = TInterface (Name {namespace = "Soup", name = "Logger"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupLogger", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "level", argType = TInterface (Name {namespace = "Soup", name = "LoggerLogLevel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the level of the information being printed.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "direction", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a single-character prefix to @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "data to print", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_logger_set_printer()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_LoggerPrinter :: FunPtr C_LoggerPrinter -> C_LoggerPrinter

dynamic_LoggerPrinter ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Logger.IsLogger a) =>
    FunPtr C_LoggerPrinter
    -> a
    {- ^ /@logger@/: the 'GI.Soup.Objects.Logger.Logger' -}
    -> Soup.Enums.LoggerLogLevel
    {- ^ /@level@/: the level of the information being printed. -}
    -> Int8
    {- ^ /@direction@/: a single-character prefix to /@data@/ -}
    -> T.Text
    {- ^ /@data@/: data to print -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.Logger.loggerSetPrinter' -}
    -> m ()
dynamic_LoggerPrinter __funPtr logger level direction data_ userData = liftIO $ do
    logger' <- unsafeManagedPtrCastPtr logger
    let level' = (fromIntegral . fromEnum) level
    data_' <- textToCString data_
    (__dynamic_C_LoggerPrinter __funPtr) logger' level' direction data_' userData
    touchManagedPtr logger
    freeMem data_'
    return ()

foreign import ccall "wrapper"
    mk_LoggerPrinter :: C_LoggerPrinter -> IO (FunPtr C_LoggerPrinter)

type LoggerPrinter =
    Soup.Logger.Logger ->
    Soup.Enums.LoggerLogLevel ->
    Int8 ->
    T.Text ->
    IO ()

noLoggerPrinter :: Maybe LoggerPrinter
noLoggerPrinter = Nothing

type LoggerPrinter_WithClosures =
    Soup.Logger.Logger ->
    Soup.Enums.LoggerLogLevel ->
    Int8 ->
    T.Text ->
    Ptr () ->
    IO ()

noLoggerPrinter_WithClosures :: Maybe LoggerPrinter_WithClosures
noLoggerPrinter_WithClosures = Nothing

drop_closures_LoggerPrinter :: LoggerPrinter -> LoggerPrinter_WithClosures
drop_closures_LoggerPrinter _f logger level direction data_ _ = _f logger level direction data_

genClosure_LoggerPrinter :: LoggerPrinter -> IO Closure
genClosure_LoggerPrinter cb = do
    let cb' = drop_closures_LoggerPrinter cb
    let cb'' = wrap_LoggerPrinter Nothing cb'
    mk_LoggerPrinter cb'' >>= newCClosure


wrap_LoggerPrinter ::
    Maybe (Ptr (FunPtr C_LoggerPrinter)) ->
    LoggerPrinter_WithClosures ->
    Ptr Soup.Logger.Logger ->
    CUInt ->
    Int8 ->
    CString ->
    Ptr () ->
    IO ()
wrap_LoggerPrinter funptrptr _cb logger level direction data_ userData = do
    logger' <- (newObject Soup.Logger.Logger) logger
    let level' = (toEnum . fromIntegral) level
    data_' <- cstringToText data_
    _cb  logger' level' direction data_' userData
    maybeReleaseFunPtr funptrptr


-- callback LoggerFilter
--          -> Callable {returnType = Just (TInterface (Name {namespace = "Soup", name = "LoggerLogLevel"})), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "a #SoupLoggerLogLevel value indicating how much of\nthe message to log", sinceVersion = Nothing}, args = [Arg {argCName = "logger", argType = TInterface (Name {namespace = "Soup", name = "Logger"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupLogger", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message being logged", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_logger_set_request_filter()\nor soup_logger_set_response_filter()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The prototype for a logging filter. The filter callback will be\ninvoked for each request or response, and should analyze it and\nreturn a #SoupLoggerLogLevel value indicating how much of the\nmessage to log. Eg, it might choose between %SOUP_LOGGER_LOG_BODY\nand %SOUP_LOGGER_LOG_HEADERS depending on the Content-Type.", sinceVersion = Nothing}}
type C_LoggerFilter =
    Ptr Soup.Logger.Logger ->
    Ptr Soup.Message.Message ->
    Ptr () ->
    IO CUInt

-- Args : [Arg {argCName = "logger", argType = TInterface (Name {namespace = "Soup", name = "Logger"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupLogger", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message being logged", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_logger_set_request_filter()\nor soup_logger_set_response_filter()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "LoggerLogLevel"}))
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_LoggerFilter :: FunPtr C_LoggerFilter -> C_LoggerFilter

dynamic_LoggerFilter ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Logger.IsLogger a, Soup.Message.IsMessage b) =>
    FunPtr C_LoggerFilter
    -> a
    {- ^ /@logger@/: the 'GI.Soup.Objects.Logger.Logger' -}
    -> b
    {- ^ /@msg@/: the message being logged -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.Logger.loggerSetRequestFilter'
or 'GI.Soup.Objects.Logger.loggerSetResponseFilter' -}
    -> m Soup.Enums.LoggerLogLevel
    {- ^ __Returns:__ a 'GI.Soup.Enums.LoggerLogLevel' value indicating how much of
the message to log -}
dynamic_LoggerFilter __funPtr logger msg userData = liftIO $ do
    logger' <- unsafeManagedPtrCastPtr logger
    msg' <- unsafeManagedPtrCastPtr msg
    result <- (__dynamic_C_LoggerFilter __funPtr) logger' msg' userData
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr logger
    touchManagedPtr msg
    return result'

foreign import ccall "wrapper"
    mk_LoggerFilter :: C_LoggerFilter -> IO (FunPtr C_LoggerFilter)

type LoggerFilter =
    Soup.Logger.Logger ->
    Soup.Message.Message ->
    IO Soup.Enums.LoggerLogLevel

noLoggerFilter :: Maybe LoggerFilter
noLoggerFilter = Nothing

type LoggerFilter_WithClosures =
    Soup.Logger.Logger ->
    Soup.Message.Message ->
    Ptr () ->
    IO Soup.Enums.LoggerLogLevel

noLoggerFilter_WithClosures :: Maybe LoggerFilter_WithClosures
noLoggerFilter_WithClosures = Nothing

drop_closures_LoggerFilter :: LoggerFilter -> LoggerFilter_WithClosures
drop_closures_LoggerFilter _f logger msg _ = _f logger msg

genClosure_LoggerFilter :: LoggerFilter -> IO Closure
genClosure_LoggerFilter cb = do
    let cb' = drop_closures_LoggerFilter cb
    let cb'' = wrap_LoggerFilter Nothing cb'
    mk_LoggerFilter cb'' >>= newCClosure


wrap_LoggerFilter ::
    Maybe (Ptr (FunPtr C_LoggerFilter)) ->
    LoggerFilter_WithClosures ->
    Ptr Soup.Logger.Logger ->
    Ptr Soup.Message.Message ->
    Ptr () ->
    IO CUInt
wrap_LoggerFilter funptrptr _cb logger msg userData = do
    logger' <- (newObject Soup.Logger.Logger) logger
    msg' <- (newObject Soup.Message.Message) msg
    result <- _cb  logger' msg' userData
    maybeReleaseFunPtr funptrptr
    let result' = (fromIntegral . fromEnum) result
    return result'


-- callback ChunkAllocator
--          -> Callable {returnType = Just (TInterface (Name {namespace = "Soup", name = "Buffer"})), returnMayBeNull = True, returnTransfer = TransferEverything, returnDocumentation = Documentation {rawDocText = Just "the new buffer (or %NULL)", sinceVersion = Nothing}, args = [Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupMessage the chunk is being allocated for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "max_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length that will be read, or 0.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_message_set_chunk_allocator()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Just (DeprecationInfo {deprecatedSinceVersion = Nothing, deprecationMessage = Just "Use #SoupRequest if you want to read into your\nown buffers."}), callableDocumentation = Documentation {rawDocText = Just "The prototype for a chunk allocation callback. This should allocate\na new #SoupBuffer and return it for the I/O layer to read message\nbody data off the network into.\n\nIf @max_len is non-0, it indicates the maximum number of bytes that\ncould be read, based on what is known about the message size. Note\nthat this might be a very large number, and you should not simply\ntry to allocate that many bytes blindly. If @max_len is 0, that\nmeans that libsoup does not know how many bytes remain to be read,\nand the allocator should return a buffer of a size that it finds\nconvenient.\n\nIf the allocator returns %NULL, the message will be paused. It is\nup to the application to make sure that it gets unpaused when it\nbecomes possible to allocate a new buffer.", sinceVersion = Nothing}}
type C_ChunkAllocator =
    Ptr Soup.Message.Message ->
    Word64 ->
    Ptr () ->
    IO (Ptr Soup.Buffer.Buffer)

-- Args : [Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupMessage the chunk is being allocated for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "max_len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum length that will be read, or 0.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_message_set_chunk_allocator()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Buffer"}))
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_ChunkAllocator :: FunPtr C_ChunkAllocator -> C_ChunkAllocator

dynamic_ChunkAllocator ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    FunPtr C_ChunkAllocator
    -> a
    {- ^ /@msg@/: the 'GI.Soup.Objects.Message.Message' the chunk is being allocated for -}
    -> Word64
    {- ^ /@maxLen@/: the maximum length that will be read, or 0. -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.Message.messageSetChunkAllocator' -}
    -> m (Maybe Soup.Buffer.Buffer)
    {- ^ __Returns:__ the new buffer (or 'Nothing') -}
dynamic_ChunkAllocator __funPtr msg maxLen userData = liftIO $ do
    msg' <- unsafeManagedPtrCastPtr msg
    result <- (__dynamic_C_ChunkAllocator __funPtr) msg' maxLen userData
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Soup.Buffer.Buffer) result'
        return result''
    touchManagedPtr msg
    return maybeResult

foreign import ccall "wrapper"
    mk_ChunkAllocator :: C_ChunkAllocator -> IO (FunPtr C_ChunkAllocator)

{-# DEPRECATED ChunkAllocator ["Use 'GI.Soup.Objects.Request.Request' if you want to read into your","own buffers."] #-}
type ChunkAllocator =
    Soup.Message.Message ->
    Word64 ->
    IO (Maybe Soup.Buffer.Buffer)

noChunkAllocator :: Maybe ChunkAllocator
noChunkAllocator = Nothing

type ChunkAllocator_WithClosures =
    Soup.Message.Message ->
    Word64 ->
    Ptr () ->
    IO (Maybe Soup.Buffer.Buffer)

noChunkAllocator_WithClosures :: Maybe ChunkAllocator_WithClosures
noChunkAllocator_WithClosures = Nothing

drop_closures_ChunkAllocator :: ChunkAllocator -> ChunkAllocator_WithClosures
drop_closures_ChunkAllocator _f msg maxLen _ = _f msg maxLen

genClosure_ChunkAllocator :: ChunkAllocator -> IO Closure
genClosure_ChunkAllocator cb = do
    let cb' = drop_closures_ChunkAllocator cb
    let cb'' = wrap_ChunkAllocator Nothing cb'
    mk_ChunkAllocator cb'' >>= newCClosure


wrap_ChunkAllocator ::
    Maybe (Ptr (FunPtr C_ChunkAllocator)) ->
    ChunkAllocator_WithClosures ->
    Ptr Soup.Message.Message ->
    Word64 ->
    Ptr () ->
    IO (Ptr Soup.Buffer.Buffer)
wrap_ChunkAllocator funptrptr _cb msg maxLen userData = do
    msg' <- (newObject Soup.Message.Message) msg
    result <- _cb  msg' maxLen userData
    maybeReleaseFunPtr funptrptr
    maybeM nullPtr result $ \result' -> do
        result'' <- B.ManagedPtr.disownBoxed result'
        return result''


-- callback AuthDomainGenericAuthCallback
--          -> Callable {returnType = Just (TBasicType TBoolean), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "%TRUE if @msg is authenticated, %FALSE if not.", sinceVersion = Nothing}, args = [Arg {argCName = "domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomain"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuthDomain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupMessage being authenticated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the username from @msg", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to\nsoup_auth_domain_set_generic_auth_callback()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The prototype for a #SoupAuthDomain generic authentication callback.\n\nThe callback should look up the user's password, call\nsoup_auth_domain_check_password(), and use the return value from\nthat method as its own return value.\n\nIn general, for security reasons, it is preferable to use the\nauth-domain-specific auth callbacks (eg,\n#SoupAuthDomainBasicAuthCallback and\n#SoupAuthDomainDigestAuthCallback), because they don't require\nkeeping a cleartext password database. Most users will use the same\npassword for many different sites, meaning if any site with a\ncleartext password database is compromised, accounts on other\nservers might be compromised as well. For many of the cases where\n#SoupServer is used, this is not really relevant, but it may still\nbe worth considering.", sinceVersion = Nothing}}
type C_AuthDomainGenericAuthCallback =
    Ptr Soup.AuthDomain.AuthDomain ->
    Ptr Soup.Message.Message ->
    CString ->
    Ptr () ->
    IO CInt

-- Args : [Arg {argCName = "domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomain"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuthDomain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupMessage being authenticated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the username from @msg", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to\nsoup_auth_domain_set_generic_auth_callback()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_AuthDomainGenericAuthCallback :: FunPtr C_AuthDomainGenericAuthCallback -> C_AuthDomainGenericAuthCallback

dynamic_AuthDomainGenericAuthCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.AuthDomain.IsAuthDomain a, Soup.Message.IsMessage b) =>
    FunPtr C_AuthDomainGenericAuthCallback
    -> a
    {- ^ /@domain@/: a 'GI.Soup.Objects.AuthDomain.AuthDomain' -}
    -> b
    {- ^ /@msg@/: the 'GI.Soup.Objects.Message.Message' being authenticated -}
    -> T.Text
    {- ^ /@username@/: the username from /@msg@/ -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to
'GI.Soup.Objects.AuthDomain.authDomainSetGenericAuthCallback' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@msg@/ is authenticated, 'False' if not. -}
dynamic_AuthDomainGenericAuthCallback __funPtr domain msg username userData = liftIO $ do
    domain' <- unsafeManagedPtrCastPtr domain
    msg' <- unsafeManagedPtrCastPtr msg
    username' <- textToCString username
    result <- (__dynamic_C_AuthDomainGenericAuthCallback __funPtr) domain' msg' username' userData
    let result' = (/= 0) result
    touchManagedPtr domain
    touchManagedPtr msg
    freeMem username'
    return result'

foreign import ccall "wrapper"
    mk_AuthDomainGenericAuthCallback :: C_AuthDomainGenericAuthCallback -> IO (FunPtr C_AuthDomainGenericAuthCallback)

type AuthDomainGenericAuthCallback =
    Soup.AuthDomain.AuthDomain ->
    Soup.Message.Message ->
    T.Text ->
    IO Bool

noAuthDomainGenericAuthCallback :: Maybe AuthDomainGenericAuthCallback
noAuthDomainGenericAuthCallback = Nothing

type AuthDomainGenericAuthCallback_WithClosures =
    Soup.AuthDomain.AuthDomain ->
    Soup.Message.Message ->
    T.Text ->
    Ptr () ->
    IO Bool

noAuthDomainGenericAuthCallback_WithClosures :: Maybe AuthDomainGenericAuthCallback_WithClosures
noAuthDomainGenericAuthCallback_WithClosures = Nothing

drop_closures_AuthDomainGenericAuthCallback :: AuthDomainGenericAuthCallback -> AuthDomainGenericAuthCallback_WithClosures
drop_closures_AuthDomainGenericAuthCallback _f domain msg username _ = _f domain msg username

genClosure_AuthDomainGenericAuthCallback :: AuthDomainGenericAuthCallback -> IO Closure
genClosure_AuthDomainGenericAuthCallback cb = do
    let cb' = drop_closures_AuthDomainGenericAuthCallback cb
    let cb'' = wrap_AuthDomainGenericAuthCallback Nothing cb'
    mk_AuthDomainGenericAuthCallback cb'' >>= newCClosure


wrap_AuthDomainGenericAuthCallback ::
    Maybe (Ptr (FunPtr C_AuthDomainGenericAuthCallback)) ->
    AuthDomainGenericAuthCallback_WithClosures ->
    Ptr Soup.AuthDomain.AuthDomain ->
    Ptr Soup.Message.Message ->
    CString ->
    Ptr () ->
    IO CInt
wrap_AuthDomainGenericAuthCallback funptrptr _cb domain msg username userData = do
    domain' <- (newObject Soup.AuthDomain.AuthDomain) domain
    msg' <- (newObject Soup.Message.Message) msg
    username' <- cstringToText username
    result <- _cb  domain' msg' username' userData
    maybeReleaseFunPtr funptrptr
    let result' = (fromIntegral . fromEnum) result
    return result'


-- callback AuthDomainFilter
--          -> Callable {returnType = Just (TBasicType TBoolean), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "%TRUE if @msg requires authentication, %FALSE if not.", sinceVersion = Nothing}, args = [Arg {argCName = "domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomain"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuthDomain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_auth_domain_set_filter()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The prototype for a #SoupAuthDomain filter; see\nsoup_auth_domain_set_filter() for details.", sinceVersion = Nothing}}
type C_AuthDomainFilter =
    Ptr Soup.AuthDomain.AuthDomain ->
    Ptr Soup.Message.Message ->
    Ptr () ->
    IO CInt

-- Args : [Arg {argCName = "domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomain"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuthDomain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_auth_domain_set_filter()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_AuthDomainFilter :: FunPtr C_AuthDomainFilter -> C_AuthDomainFilter

dynamic_AuthDomainFilter ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.AuthDomain.IsAuthDomain a, Soup.Message.IsMessage b) =>
    FunPtr C_AuthDomainFilter
    -> a
    {- ^ /@domain@/: a 'GI.Soup.Objects.AuthDomain.AuthDomain' -}
    -> b
    {- ^ /@msg@/: a 'GI.Soup.Objects.Message.Message' -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.AuthDomain.authDomainSetFilter' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@msg@/ requires authentication, 'False' if not. -}
dynamic_AuthDomainFilter __funPtr domain msg userData = liftIO $ do
    domain' <- unsafeManagedPtrCastPtr domain
    msg' <- unsafeManagedPtrCastPtr msg
    result <- (__dynamic_C_AuthDomainFilter __funPtr) domain' msg' userData
    let result' = (/= 0) result
    touchManagedPtr domain
    touchManagedPtr msg
    return result'

foreign import ccall "wrapper"
    mk_AuthDomainFilter :: C_AuthDomainFilter -> IO (FunPtr C_AuthDomainFilter)

type AuthDomainFilter =
    Soup.AuthDomain.AuthDomain ->
    Soup.Message.Message ->
    IO Bool

noAuthDomainFilter :: Maybe AuthDomainFilter
noAuthDomainFilter = Nothing

type AuthDomainFilter_WithClosures =
    Soup.AuthDomain.AuthDomain ->
    Soup.Message.Message ->
    Ptr () ->
    IO Bool

noAuthDomainFilter_WithClosures :: Maybe AuthDomainFilter_WithClosures
noAuthDomainFilter_WithClosures = Nothing

drop_closures_AuthDomainFilter :: AuthDomainFilter -> AuthDomainFilter_WithClosures
drop_closures_AuthDomainFilter _f domain msg _ = _f domain msg

genClosure_AuthDomainFilter :: AuthDomainFilter -> IO Closure
genClosure_AuthDomainFilter cb = do
    let cb' = drop_closures_AuthDomainFilter cb
    let cb'' = wrap_AuthDomainFilter Nothing cb'
    mk_AuthDomainFilter cb'' >>= newCClosure


wrap_AuthDomainFilter ::
    Maybe (Ptr (FunPtr C_AuthDomainFilter)) ->
    AuthDomainFilter_WithClosures ->
    Ptr Soup.AuthDomain.AuthDomain ->
    Ptr Soup.Message.Message ->
    Ptr () ->
    IO CInt
wrap_AuthDomainFilter funptrptr _cb domain msg userData = do
    domain' <- (newObject Soup.AuthDomain.AuthDomain) domain
    msg' <- (newObject Soup.Message.Message) msg
    result <- _cb  domain' msg' userData
    maybeReleaseFunPtr funptrptr
    let result' = (fromIntegral . fromEnum) result
    return result'


-- callback AuthDomainDigestAuthCallback
--          -> Callable {returnType = Just (TBasicType TUTF8), returnMayBeNull = True, returnTransfer = TransferEverything, returnDocumentation = Documentation {rawDocText = Just "the encoded password, or %NULL if\n@username is not a valid user. @domain will free the password when\nit is done with it.", sinceVersion = Nothing}, args = [Arg {argCName = "domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomain"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message being authenticated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the username provided by the client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_auth_domain_digest_set_auth_callback()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Callback used by #SoupAuthDomainDigest for authentication purposes.\nThe application should look up @username in its password database,\nand return the corresponding encoded password (see\nsoup_auth_domain_digest_encode_password()).", sinceVersion = Nothing}}
type C_AuthDomainDigestAuthCallback =
    Ptr Soup.AuthDomain.AuthDomain ->
    Ptr Soup.Message.Message ->
    CString ->
    Ptr () ->
    IO CString

-- Args : [Arg {argCName = "domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomain"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message being authenticated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the username provided by the client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_auth_domain_digest_set_auth_callback()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_AuthDomainDigestAuthCallback :: FunPtr C_AuthDomainDigestAuthCallback -> C_AuthDomainDigestAuthCallback

dynamic_AuthDomainDigestAuthCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.AuthDomain.IsAuthDomain a, Soup.Message.IsMessage b) =>
    FunPtr C_AuthDomainDigestAuthCallback
    -> a
    {- ^ /@domain@/: the domain -}
    -> b
    {- ^ /@msg@/: the message being authenticated -}
    -> T.Text
    {- ^ /@username@/: the username provided by the client -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.AuthDomain.authDomainDigestSetAuthCallback' -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the encoded password, or 'Nothing' if
/@username@/ is not a valid user. /@domain@/ will free the password when
it is done with it. -}
dynamic_AuthDomainDigestAuthCallback __funPtr domain msg username userData = liftIO $ do
    domain' <- unsafeManagedPtrCastPtr domain
    msg' <- unsafeManagedPtrCastPtr msg
    username' <- textToCString username
    result <- (__dynamic_C_AuthDomainDigestAuthCallback __funPtr) domain' msg' username' userData
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        freeMem result'
        return result''
    touchManagedPtr domain
    touchManagedPtr msg
    freeMem username'
    return maybeResult

foreign import ccall "wrapper"
    mk_AuthDomainDigestAuthCallback :: C_AuthDomainDigestAuthCallback -> IO (FunPtr C_AuthDomainDigestAuthCallback)

type AuthDomainDigestAuthCallback =
    Soup.AuthDomain.AuthDomain ->
    Soup.Message.Message ->
    T.Text ->
    IO (Maybe T.Text)

noAuthDomainDigestAuthCallback :: Maybe AuthDomainDigestAuthCallback
noAuthDomainDigestAuthCallback = Nothing

type AuthDomainDigestAuthCallback_WithClosures =
    Soup.AuthDomain.AuthDomain ->
    Soup.Message.Message ->
    T.Text ->
    Ptr () ->
    IO (Maybe T.Text)

noAuthDomainDigestAuthCallback_WithClosures :: Maybe AuthDomainDigestAuthCallback_WithClosures
noAuthDomainDigestAuthCallback_WithClosures = Nothing

drop_closures_AuthDomainDigestAuthCallback :: AuthDomainDigestAuthCallback -> AuthDomainDigestAuthCallback_WithClosures
drop_closures_AuthDomainDigestAuthCallback _f domain msg username _ = _f domain msg username

genClosure_AuthDomainDigestAuthCallback :: AuthDomainDigestAuthCallback -> IO Closure
genClosure_AuthDomainDigestAuthCallback cb = do
    let cb' = drop_closures_AuthDomainDigestAuthCallback cb
    let cb'' = wrap_AuthDomainDigestAuthCallback Nothing cb'
    mk_AuthDomainDigestAuthCallback cb'' >>= newCClosure


wrap_AuthDomainDigestAuthCallback ::
    Maybe (Ptr (FunPtr C_AuthDomainDigestAuthCallback)) ->
    AuthDomainDigestAuthCallback_WithClosures ->
    Ptr Soup.AuthDomain.AuthDomain ->
    Ptr Soup.Message.Message ->
    CString ->
    Ptr () ->
    IO CString
wrap_AuthDomainDigestAuthCallback funptrptr _cb domain msg username userData = do
    domain' <- (newObject Soup.AuthDomain.AuthDomain) domain
    msg' <- (newObject Soup.Message.Message) msg
    username' <- cstringToText username
    result <- _cb  domain' msg' username' userData
    maybeReleaseFunPtr funptrptr
    maybeM nullPtr result $ \result' -> do
        result'' <- textToCString result'
        return result''


-- callback AuthDomainBasicAuthCallback
--          -> Callable {returnType = Just (TBasicType TBoolean), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "%TRUE if @username and @password are valid", sinceVersion = Nothing}, args = [Arg {argCName = "domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomain"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message being authenticated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the username provided by the client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "password", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the password provided by the client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_auth_domain_basic_set_auth_callback()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Callback used by #SoupAuthDomainBasic for authentication purposes.\nThe application should verify that @username and @password and valid\nand return %TRUE or %FALSE.\n\nIf you are maintaining your own password database (rather than\nusing the password to authenticate against some other system like\nPAM or a remote server), you should make sure you know what you are\ndoing. In particular, don't store cleartext passwords, or\neasily-computed hashes of cleartext passwords, even if you don't\ncare that much about the security of your server, because users\nwill frequently use the same password for multiple sites, and so\ncompromising any site with a cleartext (or easily-cracked) password\ndatabase may give attackers access to other more-interesting sites\nas well.", sinceVersion = Nothing}}
type C_AuthDomainBasicAuthCallback =
    Ptr Soup.AuthDomain.AuthDomain ->
    Ptr Soup.Message.Message ->
    CString ->
    CString ->
    Ptr () ->
    IO CInt

-- Args : [Arg {argCName = "domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomain"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the domain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message being authenticated", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the username provided by the client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "password", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the password provided by the client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data passed to soup_auth_domain_basic_set_auth_callback()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_AuthDomainBasicAuthCallback :: FunPtr C_AuthDomainBasicAuthCallback -> C_AuthDomainBasicAuthCallback

dynamic_AuthDomainBasicAuthCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.AuthDomain.IsAuthDomain a, Soup.Message.IsMessage b) =>
    FunPtr C_AuthDomainBasicAuthCallback
    -> a
    {- ^ /@domain@/: the domain -}
    -> b
    {- ^ /@msg@/: the message being authenticated -}
    -> T.Text
    {- ^ /@username@/: the username provided by the client -}
    -> T.Text
    {- ^ /@password@/: the password provided by the client -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.AuthDomain.authDomainBasicSetAuthCallback' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@username@/ and /@password@/ are valid -}
dynamic_AuthDomainBasicAuthCallback __funPtr domain msg username password userData = liftIO $ do
    domain' <- unsafeManagedPtrCastPtr domain
    msg' <- unsafeManagedPtrCastPtr msg
    username' <- textToCString username
    password' <- textToCString password
    result <- (__dynamic_C_AuthDomainBasicAuthCallback __funPtr) domain' msg' username' password' userData
    let result' = (/= 0) result
    touchManagedPtr domain
    touchManagedPtr msg
    freeMem username'
    freeMem password'
    return result'

foreign import ccall "wrapper"
    mk_AuthDomainBasicAuthCallback :: C_AuthDomainBasicAuthCallback -> IO (FunPtr C_AuthDomainBasicAuthCallback)

type AuthDomainBasicAuthCallback =
    Soup.AuthDomain.AuthDomain ->
    Soup.Message.Message ->
    T.Text ->
    T.Text ->
    IO Bool

noAuthDomainBasicAuthCallback :: Maybe AuthDomainBasicAuthCallback
noAuthDomainBasicAuthCallback = Nothing

type AuthDomainBasicAuthCallback_WithClosures =
    Soup.AuthDomain.AuthDomain ->
    Soup.Message.Message ->
    T.Text ->
    T.Text ->
    Ptr () ->
    IO Bool

noAuthDomainBasicAuthCallback_WithClosures :: Maybe AuthDomainBasicAuthCallback_WithClosures
noAuthDomainBasicAuthCallback_WithClosures = Nothing

drop_closures_AuthDomainBasicAuthCallback :: AuthDomainBasicAuthCallback -> AuthDomainBasicAuthCallback_WithClosures
drop_closures_AuthDomainBasicAuthCallback _f domain msg username password _ = _f domain msg username password

genClosure_AuthDomainBasicAuthCallback :: AuthDomainBasicAuthCallback -> IO Closure
genClosure_AuthDomainBasicAuthCallback cb = do
    let cb' = drop_closures_AuthDomainBasicAuthCallback cb
    let cb'' = wrap_AuthDomainBasicAuthCallback Nothing cb'
    mk_AuthDomainBasicAuthCallback cb'' >>= newCClosure


wrap_AuthDomainBasicAuthCallback ::
    Maybe (Ptr (FunPtr C_AuthDomainBasicAuthCallback)) ->
    AuthDomainBasicAuthCallback_WithClosures ->
    Ptr Soup.AuthDomain.AuthDomain ->
    Ptr Soup.Message.Message ->
    CString ->
    CString ->
    Ptr () ->
    IO CInt
wrap_AuthDomainBasicAuthCallback funptrptr _cb domain msg username password userData = do
    domain' <- (newObject Soup.AuthDomain.AuthDomain) domain
    msg' <- (newObject Soup.Message.Message) msg
    username' <- cstringToText username
    password' <- cstringToText password
    result <- _cb  domain' msg' username' password' userData
    maybeReleaseFunPtr funptrptr
    let result' = (fromIntegral . fromEnum) result
    return result'


-- callback AddressCallback
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupAddress that was resolved", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "status", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%SOUP_STATUS_OK, %SOUP_STATUS_CANT_RESOLVE, or\n%SOUP_STATUS_CANCELLED", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the user data that was passed to\nsoup_address_resolve_async()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The callback function passed to soup_address_resolve_async().", sinceVersion = Nothing}}
type C_AddressCallback =
    Ptr Soup.Address.Address ->
    Word32 ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupAddress that was resolved", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "status", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%SOUP_STATUS_OK, %SOUP_STATUS_CANT_RESOLVE, or\n%SOUP_STATUS_CANCELLED", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the user data that was passed to\nsoup_address_resolve_async()", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_AddressCallback :: FunPtr C_AddressCallback -> C_AddressCallback

dynamic_AddressCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Address.IsAddress a) =>
    FunPtr C_AddressCallback
    -> a
    {- ^ /@addr@/: the 'GI.Soup.Objects.Address.Address' that was resolved -}
    -> Word32
    {- ^ /@status@/: 'GI.Soup.Enums.StatusOk', 'GI.Soup.Enums.StatusCantResolve', or
'GI.Soup.Enums.StatusCancelled' -}
    -> Ptr ()
    {- ^ /@userData@/: the user data that was passed to
'GI.Soup.Objects.Address.addressResolveAsync' -}
    -> m ()
dynamic_AddressCallback __funPtr addr status userData = liftIO $ do
    addr' <- unsafeManagedPtrCastPtr addr
    (__dynamic_C_AddressCallback __funPtr) addr' status userData
    touchManagedPtr addr
    return ()

foreign import ccall "wrapper"
    mk_AddressCallback :: C_AddressCallback -> IO (FunPtr C_AddressCallback)

type AddressCallback =
    Soup.Address.Address ->
    Word32 ->
    IO ()

noAddressCallback :: Maybe AddressCallback
noAddressCallback = Nothing

type AddressCallback_WithClosures =
    Soup.Address.Address ->
    Word32 ->
    Ptr () ->
    IO ()

noAddressCallback_WithClosures :: Maybe AddressCallback_WithClosures
noAddressCallback_WithClosures = Nothing

drop_closures_AddressCallback :: AddressCallback -> AddressCallback_WithClosures
drop_closures_AddressCallback _f addr status _ = _f addr status

genClosure_AddressCallback :: AddressCallback -> IO Closure
genClosure_AddressCallback cb = do
    let cb' = drop_closures_AddressCallback cb
    let cb'' = wrap_AddressCallback Nothing cb'
    mk_AddressCallback cb'' >>= newCClosure


wrap_AddressCallback ::
    Maybe (Ptr (FunPtr C_AddressCallback)) ->
    AddressCallback_WithClosures ->
    Ptr Soup.Address.Address ->
    Word32 ->
    Ptr () ->
    IO ()
wrap_AddressCallback funptrptr _cb addr status userData = do
    addr' <- (newObject Soup.Address.Address) addr
    _cb  addr' status userData
    maybeReleaseFunPtr funptrptr