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

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

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            ,


-- ** ProxyResolverCallback #signal:ProxyResolverCallback#

    C_ProxyResolverCallback                 ,
    ProxyResolverCallback                   ,
    ProxyResolverCallback_WithClosures      ,
    drop_closures_ProxyResolverCallback     ,
    dynamic_ProxyResolverCallback           ,
    genClosure_ProxyResolverCallback        ,
    mk_ProxyResolverCallback                ,
    noProxyResolverCallback                 ,
    noProxyResolverCallback_WithClosures    ,
    wrap_ProxyResolverCallback              ,


-- ** 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                    ,


-- ** SessionConnectProgressCallback #signal:SessionConnectProgressCallback#

    C_SessionConnectProgressCallback        ,
    SessionConnectProgressCallback          ,
    SessionConnectProgressCallback_WithClosures,
    drop_closures_SessionConnectProgressCallback,
    dynamic_SessionConnectProgressCallback  ,
    genClosure_SessionConnectProgressCallback,
    mk_SessionConnectProgressCallback       ,
    noSessionConnectProgressCallback        ,
    noSessionConnectProgressCallback_WithClosures,
    wrap_SessionConnectProgressCallback     ,


-- ** 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.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.Gio.Enums as Gio.Enums
import qualified GI.Gio.Objects.IOStream as Gio.IOStream
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.ProxyResolver as Soup.ProxyResolver
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.AuthDomainBasic as Soup.AuthDomainBasic
import {-# SOURCE #-} qualified GI.Soup.Objects.AuthDomainDigest as Soup.AuthDomainDigest
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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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 ()

-- | Generate a function pointer callable from C code, from a `C_SocketCallback`.
foreign import ccall "wrapper"
    mk_SocketCallback :: C_SocketCallback -> IO (FunPtr C_SocketCallback)

{- |
The callback function passed to 'GI.Soup.Objects.Socket.socketConnectAsync'.
-}
type SocketCallback =
    Soup.Socket.Socket
    {- ^ /@sock@/: the 'GI.Soup.Objects.Socket.Socket' -}
    -> Word32
    {- ^ /@status@/: an HTTP status code indicating success or failure -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `SocketCallback`@.
noSocketCallback :: Maybe SocketCallback
noSocketCallback = Nothing

{- |
The callback function passed to 'GI.Soup.Objects.Socket.socketConnectAsync'.
-}
type SocketCallback_WithClosures =
    Soup.Socket.Socket
    {- ^ /@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' -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `SocketCallback_WithClosures`@.
noSocketCallback_WithClosures :: Maybe SocketCallback_WithClosures
noSocketCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_SocketCallback :: SocketCallback -> SocketCallback_WithClosures
drop_closures_SocketCallback _f sock status _ = _f sock status

-- | Wrap the callback into a `GClosure`.
genClosure_SocketCallback :: MonadIO m => SocketCallback -> m (GClosure C_SocketCallback)
genClosure_SocketCallback cb = liftIO $ do
    let cb' = drop_closures_SocketCallback cb
    let cb'' = wrap_SocketCallback Nothing cb'
    mk_SocketCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `SocketCallback` into a `C_SocketCallback`.
wrap_SocketCallback ::
    Maybe (Ptr (FunPtr C_SocketCallback)) ->
    SocketCallback_WithClosures ->
    C_SocketCallback
wrap_SocketCallback funptrptr _cb sock status userData = do
    sock' <- (newObject Soup.Socket.Socket) sock
    _cb  sock' status userData
    maybeReleaseFunPtr funptrptr


-- callback SessionConnectProgressCallback
--          -> 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 #SoupSession", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "event", argType = TInterface (Name {namespace = "Gio", name = "SocketClientEvent"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSocketClientEvent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "connection", argType = TInterface (Name {namespace = "Gio", name = "IOStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the current state of the network connection", 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_connect_async().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Prototype for the progress callback passed to soup_session_connect_async().", sinceVersion = Just "2.62"}}
-- | Type for the callback on the (unwrapped) C side.
type C_SessionConnectProgressCallback =
    Ptr Soup.Session.Session ->
    CUInt ->
    Ptr Gio.IOStream.IOStream ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "session", argType = TInterface (Name {namespace = "Soup", name = "Session"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupSession", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "event", argType = TInterface (Name {namespace = "Gio", name = "SocketClientEvent"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSocketClientEvent", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "connection", argType = TInterface (Name {namespace = "Gio", name = "IOStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the current state of the network connection", 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_connect_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_SessionConnectProgressCallback :: FunPtr C_SessionConnectProgressCallback -> C_SessionConnectProgressCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_SessionConnectProgressCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Session.IsSession a, Gio.IOStream.IsIOStream b) =>
    FunPtr C_SessionConnectProgressCallback
    -> a
    {- ^ /@session@/: the 'GI.Soup.Objects.Session.Session' -}
    -> Gio.Enums.SocketClientEvent
    {- ^ /@event@/: a 'GI.Gio.Enums.SocketClientEvent' -}
    -> b
    {- ^ /@connection@/: the current state of the network connection -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.Session.sessionConnectAsync'. -}
    -> m ()
dynamic_SessionConnectProgressCallback __funPtr session event connection userData = liftIO $ do
    session' <- unsafeManagedPtrCastPtr session
    let event' = (fromIntegral . fromEnum) event
    connection' <- unsafeManagedPtrCastPtr connection
    (__dynamic_C_SessionConnectProgressCallback __funPtr) session' event' connection' userData
    touchManagedPtr session
    touchManagedPtr connection
    return ()

-- | Generate a function pointer callable from C code, from a `C_SessionConnectProgressCallback`.
foreign import ccall "wrapper"
    mk_SessionConnectProgressCallback :: C_SessionConnectProgressCallback -> IO (FunPtr C_SessionConnectProgressCallback)

{- |
Prototype for the progress callback passed to 'GI.Soup.Objects.Session.sessionConnectAsync'.

/Since: 2.62/
-}
type SessionConnectProgressCallback =
    Soup.Session.Session
    {- ^ /@session@/: the 'GI.Soup.Objects.Session.Session' -}
    -> Gio.Enums.SocketClientEvent
    {- ^ /@event@/: a 'GI.Gio.Enums.SocketClientEvent' -}
    -> Gio.IOStream.IOStream
    {- ^ /@connection@/: the current state of the network connection -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `SessionConnectProgressCallback`@.
noSessionConnectProgressCallback :: Maybe SessionConnectProgressCallback
noSessionConnectProgressCallback = Nothing

{- |
Prototype for the progress callback passed to 'GI.Soup.Objects.Session.sessionConnectAsync'.

/Since: 2.62/
-}
type SessionConnectProgressCallback_WithClosures =
    Soup.Session.Session
    {- ^ /@session@/: the 'GI.Soup.Objects.Session.Session' -}
    -> Gio.Enums.SocketClientEvent
    {- ^ /@event@/: a 'GI.Gio.Enums.SocketClientEvent' -}
    -> Gio.IOStream.IOStream
    {- ^ /@connection@/: the current state of the network connection -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.Session.sessionConnectAsync'. -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `SessionConnectProgressCallback_WithClosures`@.
noSessionConnectProgressCallback_WithClosures :: Maybe SessionConnectProgressCallback_WithClosures
noSessionConnectProgressCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_SessionConnectProgressCallback :: SessionConnectProgressCallback -> SessionConnectProgressCallback_WithClosures
drop_closures_SessionConnectProgressCallback _f session event connection _ = _f session event connection

-- | Wrap the callback into a `GClosure`.
genClosure_SessionConnectProgressCallback :: MonadIO m => SessionConnectProgressCallback -> m (GClosure C_SessionConnectProgressCallback)
genClosure_SessionConnectProgressCallback cb = liftIO $ do
    let cb' = drop_closures_SessionConnectProgressCallback cb
    let cb'' = wrap_SessionConnectProgressCallback Nothing cb'
    mk_SessionConnectProgressCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `SessionConnectProgressCallback` into a `C_SessionConnectProgressCallback`.
wrap_SessionConnectProgressCallback ::
    Maybe (Ptr (FunPtr C_SessionConnectProgressCallback)) ->
    SessionConnectProgressCallback_WithClosures ->
    C_SessionConnectProgressCallback
wrap_SessionConnectProgressCallback funptrptr _cb session event connection userData = do
    session' <- (newObject Soup.Session.Session) session
    let event' = (toEnum . fromIntegral) event
    connection' <- (newObject Gio.IOStream.IOStream) connection
    _cb  session' event' connection' 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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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 ()

-- | Generate a function pointer callable from C code, from a `C_SessionCallback`.
foreign import ccall "wrapper"
    mk_SessionCallback :: C_SessionCallback -> IO (FunPtr C_SessionCallback)

{- |
Prototype for the callback passed to 'GI.Soup.Objects.Session.sessionQueueMessage',
qv.
-}
type SessionCallback =
    Soup.Session.Session
    {- ^ /@session@/: the session -}
    -> Soup.Message.Message
    {- ^ /@msg@/: the message that has finished -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `SessionCallback`@.
noSessionCallback :: Maybe SessionCallback
noSessionCallback = Nothing

{- |
Prototype for the callback passed to 'GI.Soup.Objects.Session.sessionQueueMessage',
qv.
-}
type SessionCallback_WithClosures =
    Soup.Session.Session
    {- ^ /@session@/: the session -}
    -> Soup.Message.Message
    {- ^ /@msg@/: the message that has finished -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to soup_session_queue_message -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `SessionCallback_WithClosures`@.
noSessionCallback_WithClosures :: Maybe SessionCallback_WithClosures
noSessionCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_SessionCallback :: SessionCallback -> SessionCallback_WithClosures
drop_closures_SessionCallback _f session msg _ = _f session msg

-- | Wrap the callback into a `GClosure`.
genClosure_SessionCallback :: MonadIO m => SessionCallback -> m (GClosure C_SessionCallback)
genClosure_SessionCallback cb = liftIO $ do
    let cb' = drop_closures_SessionCallback cb
    let cb'' = wrap_SessionCallback Nothing cb'
    mk_SessionCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `SessionCallback` into a `C_SessionCallback`.
wrap_SessionCallback ::
    Maybe (Ptr (FunPtr C_SessionCallback)) ->
    SessionCallback_WithClosures ->
    C_SessionCallback
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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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 ()

-- | Generate a function pointer callable from C code, from a `C_ServerWebsocketCallback`.
foreign import ccall "wrapper"
    mk_ServerWebsocketCallback :: C_ServerWebsocketCallback -> IO (FunPtr C_ServerWebsocketCallback)

{- |
A callback used to handle WebSocket requests to a 'GI.Soup.Objects.Server.Server'. The
callback will be invoked after sending the handshake response back
to the client (and is only invoked if the handshake was
successful).

/@path@/ contains the path of the Request-URI, subject to the same
rules as 'GI.Soup.Callbacks.ServerCallback' (qv).
-}
type ServerWebsocketCallback =
    Soup.Server.Server
    {- ^ /@server@/: the 'GI.Soup.Objects.Server.Server' -}
    -> Soup.WebsocketConnection.WebsocketConnection
    {- ^ /@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 -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ServerWebsocketCallback`@.
noServerWebsocketCallback :: Maybe ServerWebsocketCallback
noServerWebsocketCallback = Nothing

{- |
A callback used to handle WebSocket requests to a 'GI.Soup.Objects.Server.Server'. The
callback will be invoked after sending the handshake response back
to the client (and is only invoked if the handshake was
successful).

/@path@/ contains the path of the Request-URI, subject to the same
rules as 'GI.Soup.Callbacks.ServerCallback' (qv).
-}
type ServerWebsocketCallback_WithClosures =
    Soup.Server.Server
    {- ^ /@server@/: the 'GI.Soup.Objects.Server.Server' -}
    -> Soup.WebsocketConnection.WebsocketConnection
    {- ^ /@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@/ -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ServerWebsocketCallback_WithClosures`@.
noServerWebsocketCallback_WithClosures :: Maybe ServerWebsocketCallback_WithClosures
noServerWebsocketCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_ServerWebsocketCallback :: ServerWebsocketCallback -> ServerWebsocketCallback_WithClosures
drop_closures_ServerWebsocketCallback _f server connection path client _ = _f server connection path client

-- | Wrap the callback into a `GClosure`.
genClosure_ServerWebsocketCallback :: MonadIO m => ServerWebsocketCallback -> m (GClosure C_ServerWebsocketCallback)
genClosure_ServerWebsocketCallback cb = liftIO $ do
    let cb' = drop_closures_ServerWebsocketCallback cb
    let cb'' = wrap_ServerWebsocketCallback Nothing cb'
    mk_ServerWebsocketCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `ServerWebsocketCallback` into a `C_ServerWebsocketCallback`.
wrap_ServerWebsocketCallback ::
    Maybe (Ptr (FunPtr C_ServerWebsocketCallback)) ->
    ServerWebsocketCallback_WithClosures ->
    C_ServerWebsocketCallback
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
    B.ManagedPtr.withTransient Soup.ClientContext.ClientContext client $ \client' -> do
        _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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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 ()

-- | Generate a function pointer callable from C code, from a `C_ServerCallback`.
foreign import ccall "wrapper"
    mk_ServerCallback :: C_ServerCallback -> IO (FunPtr C_ServerCallback)

{- |
A callback used to handle requests to a 'GI.Soup.Objects.Server.Server'.

/@path@/ and /@query@/ contain the likewise-named components of the
Request-URI, subject to certain assumptions. By default,
'GI.Soup.Objects.Server.Server' decodes all percent-encoding in the URI path, such that
\"\/foo%\<!-- -->2Fbar\" is treated the same as \"\/foo\/bar\". If your
server is serving resources in some non-POSIX-filesystem namespace,
you may want to distinguish those as two distinct paths. In that
case, you can set the 'GI.Soup.Constants.SERVER_RAW_PATHS' property when creating
the 'GI.Soup.Objects.Server.Server', and it will leave those characters undecoded. (You
may want to call 'GI.Soup.Functions.uriNormalize' to decode any percent-encoded
characters that you aren\'t handling specially.)

/@query@/ contains the query component of the Request-URI parsed
according to the rules for HTML form handling. Although this is the
only commonly-used query string format in HTTP, there is nothing
that actually requires that HTTP URIs use that format; if your
server needs to use some other format, you can just ignore /@query@/,
and call 'GI.Soup.Objects.Message.messageGetUri' and parse the URI\'s query field
yourself.

See 'GI.Soup.Objects.Server.serverAddHandler' and 'GI.Soup.Objects.Server.serverAddEarlyHandler'
for details of what handlers can\/should do.
-}
type ServerCallback =
    Soup.Server.Server
    {- ^ /@server@/: the 'GI.Soup.Objects.Server.Server' -}
    -> Soup.Message.Message
    {- ^ /@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 -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ServerCallback`@.
noServerCallback :: Maybe ServerCallback
noServerCallback = Nothing

{- |
A callback used to handle requests to a 'GI.Soup.Objects.Server.Server'.

/@path@/ and /@query@/ contain the likewise-named components of the
Request-URI, subject to certain assumptions. By default,
'GI.Soup.Objects.Server.Server' decodes all percent-encoding in the URI path, such that
\"\/foo%\<!-- -->2Fbar\" is treated the same as \"\/foo\/bar\". If your
server is serving resources in some non-POSIX-filesystem namespace,
you may want to distinguish those as two distinct paths. In that
case, you can set the 'GI.Soup.Constants.SERVER_RAW_PATHS' property when creating
the 'GI.Soup.Objects.Server.Server', and it will leave those characters undecoded. (You
may want to call 'GI.Soup.Functions.uriNormalize' to decode any percent-encoded
characters that you aren\'t handling specially.)

/@query@/ contains the query component of the Request-URI parsed
according to the rules for HTML form handling. Although this is the
only commonly-used query string format in HTTP, there is nothing
that actually requires that HTTP URIs use that format; if your
server needs to use some other format, you can just ignore /@query@/,
and call 'GI.Soup.Objects.Message.messageGetUri' and parse the URI\'s query field
yourself.

See 'GI.Soup.Objects.Server.serverAddHandler' and 'GI.Soup.Objects.Server.serverAddEarlyHandler'
for details of what handlers can\/should do.
-}
type ServerCallback_WithClosures =
    Soup.Server.Server
    {- ^ /@server@/: the 'GI.Soup.Objects.Server.Server' -}
    -> Soup.Message.Message
    {- ^ /@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'. -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ServerCallback_WithClosures`@.
noServerCallback_WithClosures :: Maybe ServerCallback_WithClosures
noServerCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_ServerCallback :: ServerCallback -> ServerCallback_WithClosures
drop_closures_ServerCallback _f server msg path query client _ = _f server msg path query client

-- | Wrap the callback into a `GClosure`.
genClosure_ServerCallback :: MonadIO m => ServerCallback -> m (GClosure C_ServerCallback)
genClosure_ServerCallback cb = liftIO $ do
    let cb' = drop_closures_ServerCallback cb
    let cb'' = wrap_ServerCallback Nothing cb'
    mk_ServerCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `ServerCallback` into a `C_ServerCallback`.
wrap_ServerCallback ::
    Maybe (Ptr (FunPtr C_ServerCallback)) ->
    ServerCallback_WithClosures ->
    C_ServerCallback
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''''''
    B.ManagedPtr.withTransient Soup.ClientContext.ClientContext client $ \client' -> do
        _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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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 ()

-- | Generate a function pointer callable from C code, from a `C_ProxyURIResolverCallback`.
foreign import ccall "wrapper"
    mk_ProxyURIResolverCallback :: C_ProxyURIResolverCallback -> IO (FunPtr C_ProxyURIResolverCallback)

{- |
Callback for 'GI.Soup.Interfaces.ProxyURIResolver.proxyURIResolverGetProxyUriAsync'
-}
type ProxyURIResolverCallback =
    Soup.ProxyURIResolver.ProxyURIResolver
    {- ^ /@resolver@/: the 'GI.Soup.Interfaces.ProxyURIResolver.ProxyURIResolver' -}
    -> Word32
    {- ^ /@status@/: a 'GI.Soup.Enums.Status' -}
    -> Soup.URI.URI
    {- ^ /@proxyUri@/: the resolved proxy URI, or 'Nothing' -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ProxyURIResolverCallback`@.
noProxyURIResolverCallback :: Maybe ProxyURIResolverCallback
noProxyURIResolverCallback = Nothing

{- |
Callback for 'GI.Soup.Interfaces.ProxyURIResolver.proxyURIResolverGetProxyUriAsync'
-}
type ProxyURIResolverCallback_WithClosures =
    Soup.ProxyURIResolver.ProxyURIResolver
    {- ^ /@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' -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ProxyURIResolverCallback_WithClosures`@.
noProxyURIResolverCallback_WithClosures :: Maybe ProxyURIResolverCallback_WithClosures
noProxyURIResolverCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_ProxyURIResolverCallback :: ProxyURIResolverCallback -> ProxyURIResolverCallback_WithClosures
drop_closures_ProxyURIResolverCallback _f resolver status proxyUri _ = _f resolver status proxyUri

-- | Wrap the callback into a `GClosure`.
genClosure_ProxyURIResolverCallback :: MonadIO m => ProxyURIResolverCallback -> m (GClosure C_ProxyURIResolverCallback)
genClosure_ProxyURIResolverCallback cb = liftIO $ do
    let cb' = drop_closures_ProxyURIResolverCallback cb
    let cb'' = wrap_ProxyURIResolverCallback Nothing cb'
    mk_ProxyURIResolverCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `ProxyURIResolverCallback` into a `C_ProxyURIResolverCallback`.
wrap_ProxyURIResolverCallback ::
    Maybe (Ptr (FunPtr C_ProxyURIResolverCallback)) ->
    ProxyURIResolverCallback_WithClosures ->
    C_ProxyURIResolverCallback
wrap_ProxyURIResolverCallback funptrptr _cb resolver status proxyUri userData = do
    resolver' <- (newObject Soup.ProxyURIResolver.ProxyURIResolver) resolver
    B.ManagedPtr.withTransient Soup.URI.URI proxyUri $ \proxyUri' -> do
        _cb  resolver' status proxyUri' userData
        maybeReleaseFunPtr funptrptr


-- callback ProxyResolverCallback
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "proxy_resolver", argType = TInterface (Name {namespace = "Soup", name = "ProxyResolver"}), 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 = "arg", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), 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 = Just (DeprecationInfo {deprecatedSinceVersion = Just "2.28", deprecationMessage = Just "Use SoupProxyURIResolver instead"}), callableDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_ProxyResolverCallback =
    Ptr Soup.ProxyResolver.ProxyResolver ->
    Ptr Soup.Message.Message ->
    Word32 ->
    Ptr Soup.Address.Address ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "proxy_resolver", argType = TInterface (Name {namespace = "Soup", name = "ProxyResolver"}), 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 = "arg", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "addr", argType = TInterface (Name {namespace = "Soup", name = "Address"}), 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_ProxyResolverCallback :: FunPtr C_ProxyResolverCallback -> C_ProxyResolverCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_ProxyResolverCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.ProxyResolver.IsProxyResolver a, Soup.Message.IsMessage b, Soup.Address.IsAddress c) =>
    FunPtr C_ProxyResolverCallback
    -> a
    -> b
    -> Word32
    -> c
    -> Ptr ()
    -> m ()
dynamic_ProxyResolverCallback __funPtr proxyResolver msg arg addr userData = liftIO $ do
    proxyResolver' <- unsafeManagedPtrCastPtr proxyResolver
    msg' <- unsafeManagedPtrCastPtr msg
    addr' <- unsafeManagedPtrCastPtr addr
    (__dynamic_C_ProxyResolverCallback __funPtr) proxyResolver' msg' arg addr' userData
    touchManagedPtr proxyResolver
    touchManagedPtr msg
    touchManagedPtr addr
    return ()

-- | Generate a function pointer callable from C code, from a `C_ProxyResolverCallback`.
foreign import ccall "wrapper"
    mk_ProxyResolverCallback :: C_ProxyResolverCallback -> IO (FunPtr C_ProxyResolverCallback)

{-# DEPRECATED ProxyResolverCallback ["(Since version 2.28)","Use SoupProxyURIResolver instead"] #-}
{- |
/No description available in the introspection data./
-}
type ProxyResolverCallback =
    Soup.ProxyResolver.ProxyResolver
    -> Soup.Message.Message
    -> Word32
    -> Soup.Address.Address
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ProxyResolverCallback`@.
noProxyResolverCallback :: Maybe ProxyResolverCallback
noProxyResolverCallback = Nothing

{- |
/No description available in the introspection data./
-}
type ProxyResolverCallback_WithClosures =
    Soup.ProxyResolver.ProxyResolver
    -> Soup.Message.Message
    -> Word32
    -> Soup.Address.Address
    -> Ptr ()
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ProxyResolverCallback_WithClosures`@.
noProxyResolverCallback_WithClosures :: Maybe ProxyResolverCallback_WithClosures
noProxyResolverCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_ProxyResolverCallback :: ProxyResolverCallback -> ProxyResolverCallback_WithClosures
drop_closures_ProxyResolverCallback _f proxyResolver msg arg addr _ = _f proxyResolver msg arg addr

-- | Wrap the callback into a `GClosure`.
genClosure_ProxyResolverCallback :: MonadIO m => ProxyResolverCallback -> m (GClosure C_ProxyResolverCallback)
genClosure_ProxyResolverCallback cb = liftIO $ do
    let cb' = drop_closures_ProxyResolverCallback cb
    let cb'' = wrap_ProxyResolverCallback Nothing cb'
    mk_ProxyResolverCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `ProxyResolverCallback` into a `C_ProxyResolverCallback`.
wrap_ProxyResolverCallback ::
    Maybe (Ptr (FunPtr C_ProxyResolverCallback)) ->
    ProxyResolverCallback_WithClosures ->
    C_ProxyResolverCallback
wrap_ProxyResolverCallback funptrptr _cb proxyResolver msg arg addr userData = do
    proxyResolver' <- (newObject Soup.ProxyResolver.ProxyResolver) proxyResolver
    msg' <- (newObject Soup.Message.Message) msg
    addr' <- (newObject Soup.Address.Address) addr
    _cb  proxyResolver' msg' arg addr' 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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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 ()

-- | Generate a function pointer callable from C code, from a `C_PasswordManagerCallback`.
foreign import ccall "wrapper"
    mk_PasswordManagerCallback :: C_PasswordManagerCallback -> IO (FunPtr C_PasswordManagerCallback)

{- |
/No description available in the introspection data./
-}
type PasswordManagerCallback =
    Soup.PasswordManager.PasswordManager
    -> Soup.Message.Message
    -> Soup.Auth.Auth
    -> Bool
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `PasswordManagerCallback`@.
noPasswordManagerCallback :: Maybe PasswordManagerCallback
noPasswordManagerCallback = Nothing

{- |
/No description available in the introspection data./
-}
type PasswordManagerCallback_WithClosures =
    Soup.PasswordManager.PasswordManager
    -> Soup.Message.Message
    -> Soup.Auth.Auth
    -> Bool
    -> Ptr ()
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `PasswordManagerCallback_WithClosures`@.
noPasswordManagerCallback_WithClosures :: Maybe PasswordManagerCallback_WithClosures
noPasswordManagerCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_PasswordManagerCallback :: PasswordManagerCallback -> PasswordManagerCallback_WithClosures
drop_closures_PasswordManagerCallback _f passwordManager msg auth retrying _ = _f passwordManager msg auth retrying

-- | Wrap the callback into a `GClosure`.
genClosure_PasswordManagerCallback :: MonadIO m => PasswordManagerCallback -> m (GClosure C_PasswordManagerCallback)
genClosure_PasswordManagerCallback cb = liftIO $ do
    let cb' = drop_closures_PasswordManagerCallback cb
    let cb'' = wrap_PasswordManagerCallback Nothing cb'
    mk_PasswordManagerCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `PasswordManagerCallback` into a `C_PasswordManagerCallback`.
wrap_PasswordManagerCallback ::
    Maybe (Ptr (FunPtr C_PasswordManagerCallback)) ->
    PasswordManagerCallback_WithClosures ->
    C_PasswordManagerCallback
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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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 ()

-- | Generate a function pointer callable from C code, from a `C_MessageHeadersForeachFunc`.
foreign import ccall "wrapper"
    mk_MessageHeadersForeachFunc :: C_MessageHeadersForeachFunc -> IO (FunPtr C_MessageHeadersForeachFunc)

{- |
The callback passed to 'GI.Soup.Structs.MessageHeaders.messageHeadersForeach'.
-}
type MessageHeadersForeachFunc =
    T.Text
    {- ^ /@name@/: the header name -}
    -> T.Text
    {- ^ /@value@/: the header value -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `MessageHeadersForeachFunc`@.
noMessageHeadersForeachFunc :: Maybe MessageHeadersForeachFunc
noMessageHeadersForeachFunc = Nothing

{- |
The callback passed to 'GI.Soup.Structs.MessageHeaders.messageHeadersForeach'.
-}
type MessageHeadersForeachFunc_WithClosures =
    T.Text
    {- ^ /@name@/: the header name -}
    -> T.Text
    {- ^ /@value@/: the header value -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Structs.MessageHeaders.messageHeadersForeach' -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `MessageHeadersForeachFunc_WithClosures`@.
noMessageHeadersForeachFunc_WithClosures :: Maybe MessageHeadersForeachFunc_WithClosures
noMessageHeadersForeachFunc_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_MessageHeadersForeachFunc :: MessageHeadersForeachFunc -> MessageHeadersForeachFunc_WithClosures
drop_closures_MessageHeadersForeachFunc _f name value _ = _f name value

-- | Wrap the callback into a `GClosure`.
genClosure_MessageHeadersForeachFunc :: MonadIO m => MessageHeadersForeachFunc -> m (GClosure C_MessageHeadersForeachFunc)
genClosure_MessageHeadersForeachFunc cb = liftIO $ do
    let cb' = drop_closures_MessageHeadersForeachFunc cb
    let cb'' = wrap_MessageHeadersForeachFunc Nothing cb'
    mk_MessageHeadersForeachFunc cb'' >>= B.GClosure.newGClosure


-- | Wrap a `MessageHeadersForeachFunc` into a `C_MessageHeadersForeachFunc`.
wrap_MessageHeadersForeachFunc ::
    Maybe (Ptr (FunPtr C_MessageHeadersForeachFunc)) ->
    MessageHeadersForeachFunc_WithClosures ->
    C_MessageHeadersForeachFunc
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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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 ()

-- | Generate a function pointer callable from C code, from a `C_LoggerPrinter`.
foreign import ccall "wrapper"
    mk_LoggerPrinter :: C_LoggerPrinter -> IO (FunPtr C_LoggerPrinter)

{- |
The prototype for a custom printing callback.

/@level@/ indicates what kind of information is being printed. Eg, it
will be 'GI.Soup.Enums.LoggerLogLevelHeaders' if /@data@/ is header data.

/@direction@/ is either \'\<\', \'>\', or \' \', and /@data@/ is the single line
to print; the printer is expected to add a terminating newline.

To get the effect of the default printer, you would do:

\<informalexample>\<programlisting>
printf (\"@/c/@ @/s/@\\n\", direction, data);
\<\/programlisting>\<\/informalexample>
-}
type LoggerPrinter =
    Soup.Logger.Logger
    {- ^ /@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 -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `LoggerPrinter`@.
noLoggerPrinter :: Maybe LoggerPrinter
noLoggerPrinter = Nothing

{- |
The prototype for a custom printing callback.

/@level@/ indicates what kind of information is being printed. Eg, it
will be 'GI.Soup.Enums.LoggerLogLevelHeaders' if /@data@/ is header data.

/@direction@/ is either \'\<\', \'>\', or \' \', and /@data@/ is the single line
to print; the printer is expected to add a terminating newline.

To get the effect of the default printer, you would do:

\<informalexample>\<programlisting>
printf (\"@/c/@ @/s/@\\n\", direction, data);
\<\/programlisting>\<\/informalexample>
-}
type LoggerPrinter_WithClosures =
    Soup.Logger.Logger
    {- ^ /@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' -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `LoggerPrinter_WithClosures`@.
noLoggerPrinter_WithClosures :: Maybe LoggerPrinter_WithClosures
noLoggerPrinter_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_LoggerPrinter :: LoggerPrinter -> LoggerPrinter_WithClosures
drop_closures_LoggerPrinter _f logger level direction data_ _ = _f logger level direction data_

-- | Wrap the callback into a `GClosure`.
genClosure_LoggerPrinter :: MonadIO m => LoggerPrinter -> m (GClosure C_LoggerPrinter)
genClosure_LoggerPrinter cb = liftIO $ do
    let cb' = drop_closures_LoggerPrinter cb
    let cb'' = wrap_LoggerPrinter Nothing cb'
    mk_LoggerPrinter cb'' >>= B.GClosure.newGClosure


-- | Wrap a `LoggerPrinter` into a `C_LoggerPrinter`.
wrap_LoggerPrinter ::
    Maybe (Ptr (FunPtr C_LoggerPrinter)) ->
    LoggerPrinter_WithClosures ->
    C_LoggerPrinter
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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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'

-- | Generate a function pointer callable from C code, from a `C_LoggerFilter`.
foreign import ccall "wrapper"
    mk_LoggerFilter :: C_LoggerFilter -> IO (FunPtr C_LoggerFilter)

{- |
The prototype for a logging filter. The filter callback will be
invoked for each request or response, and should analyze it and
return a 'GI.Soup.Enums.LoggerLogLevel' value indicating how much of the
message to log. Eg, it might choose between 'GI.Soup.Enums.LoggerLogLevelBody'
and 'GI.Soup.Enums.LoggerLogLevelHeaders' depending on the Content-Type.
-}
type LoggerFilter =
    Soup.Logger.Logger
    {- ^ /@logger@/: the 'GI.Soup.Objects.Logger.Logger' -}
    -> Soup.Message.Message
    {- ^ /@msg@/: the message being logged -}
    -> IO Soup.Enums.LoggerLogLevel
    {- ^ __Returns:__ a 'GI.Soup.Enums.LoggerLogLevel' value indicating how much of
the message to log -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `LoggerFilter`@.
noLoggerFilter :: Maybe LoggerFilter
noLoggerFilter = Nothing

{- |
The prototype for a logging filter. The filter callback will be
invoked for each request or response, and should analyze it and
return a 'GI.Soup.Enums.LoggerLogLevel' value indicating how much of the
message to log. Eg, it might choose between 'GI.Soup.Enums.LoggerLogLevelBody'
and 'GI.Soup.Enums.LoggerLogLevelHeaders' depending on the Content-Type.
-}
type LoggerFilter_WithClosures =
    Soup.Logger.Logger
    {- ^ /@logger@/: the 'GI.Soup.Objects.Logger.Logger' -}
    -> Soup.Message.Message
    {- ^ /@msg@/: the message being logged -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.Logger.loggerSetRequestFilter'
or 'GI.Soup.Objects.Logger.loggerSetResponseFilter' -}
    -> IO Soup.Enums.LoggerLogLevel
    {- ^ __Returns:__ a 'GI.Soup.Enums.LoggerLogLevel' value indicating how much of
the message to log -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `LoggerFilter_WithClosures`@.
noLoggerFilter_WithClosures :: Maybe LoggerFilter_WithClosures
noLoggerFilter_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_LoggerFilter :: LoggerFilter -> LoggerFilter_WithClosures
drop_closures_LoggerFilter _f logger msg _ = _f logger msg

-- | Wrap the callback into a `GClosure`.
genClosure_LoggerFilter :: MonadIO m => LoggerFilter -> m (GClosure C_LoggerFilter)
genClosure_LoggerFilter cb = liftIO $ do
    let cb' = drop_closures_LoggerFilter cb
    let cb'' = wrap_LoggerFilter Nothing cb'
    mk_LoggerFilter cb'' >>= B.GClosure.newGClosure


-- | Wrap a `LoggerFilter` into a `C_LoggerFilter`.
wrap_LoggerFilter ::
    Maybe (Ptr (FunPtr C_LoggerFilter)) ->
    LoggerFilter_WithClosures ->
    C_LoggerFilter
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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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

-- | Generate a function pointer callable from C code, from a `C_ChunkAllocator`.
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."] #-}
{- |
The prototype for a chunk allocation callback. This should allocate
a new 'GI.Soup.Structs.Buffer.Buffer' and return it for the I\/O layer to read message
body data off the network into.

If /@maxLen@/ is non-0, it indicates the maximum number of bytes that
could be read, based on what is known about the message size. Note
that this might be a very large number, and you should not simply
try to allocate that many bytes blindly. If /@maxLen@/ is 0, that
means that libsoup does not know how many bytes remain to be read,
and the allocator should return a buffer of a size that it finds
convenient.

If the allocator returns 'Nothing', the message will be paused. It is
up to the application to make sure that it gets unpaused when it
becomes possible to allocate a new buffer.
-}
type ChunkAllocator =
    Soup.Message.Message
    {- ^ /@msg@/: the 'GI.Soup.Objects.Message.Message' the chunk is being allocated for -}
    -> Word64
    {- ^ /@maxLen@/: the maximum length that will be read, or 0. -}
    -> IO (Maybe Soup.Buffer.Buffer)
    {- ^ __Returns:__ the new buffer (or 'Nothing') -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `ChunkAllocator`@.
noChunkAllocator :: Maybe ChunkAllocator
noChunkAllocator = Nothing

{- |
The prototype for a chunk allocation callback. This should allocate
a new 'GI.Soup.Structs.Buffer.Buffer' and return it for the I\/O layer to read message
body data off the network into.

If /@maxLen@/ is non-0, it indicates the maximum number of bytes that
could be read, based on what is known about the message size. Note
that this might be a very large number, and you should not simply
try to allocate that many bytes blindly. If /@maxLen@/ is 0, that
means that libsoup does not know how many bytes remain to be read,
and the allocator should return a buffer of a size that it finds
convenient.

If the allocator returns 'Nothing', the message will be paused. It is
up to the application to make sure that it gets unpaused when it
becomes possible to allocate a new buffer.
-}
type ChunkAllocator_WithClosures =
    Soup.Message.Message
    {- ^ /@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' -}
    -> IO (Maybe Soup.Buffer.Buffer)
    {- ^ __Returns:__ the new buffer (or 'Nothing') -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `ChunkAllocator_WithClosures`@.
noChunkAllocator_WithClosures :: Maybe ChunkAllocator_WithClosures
noChunkAllocator_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_ChunkAllocator :: ChunkAllocator -> ChunkAllocator_WithClosures
drop_closures_ChunkAllocator _f msg maxLen _ = _f msg maxLen

-- | Wrap the callback into a `GClosure`.
genClosure_ChunkAllocator :: MonadIO m => ChunkAllocator -> m (GClosure C_ChunkAllocator)
genClosure_ChunkAllocator cb = liftIO $ do
    let cb' = drop_closures_ChunkAllocator cb
    let cb'' = wrap_ChunkAllocator Nothing cb'
    mk_ChunkAllocator cb'' >>= B.GClosure.newGClosure


-- | Wrap a `ChunkAllocator` into a `C_ChunkAllocator`.
wrap_ChunkAllocator ::
    Maybe (Ptr (FunPtr C_ChunkAllocator)) ->
    ChunkAllocator_WithClosures ->
    C_ChunkAllocator
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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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'

-- | Generate a function pointer callable from C code, from a `C_AuthDomainGenericAuthCallback`.
foreign import ccall "wrapper"
    mk_AuthDomainGenericAuthCallback :: C_AuthDomainGenericAuthCallback -> IO (FunPtr C_AuthDomainGenericAuthCallback)

{- |
The prototype for a 'GI.Soup.Objects.AuthDomain.AuthDomain' generic authentication callback.

The callback should look up the user\'s password, call
'GI.Soup.Objects.AuthDomain.authDomainCheckPassword', and use the return value from
that method as its own return value.

In general, for security reasons, it is preferable to use the
auth-domain-specific auth callbacks (eg,
'GI.Soup.Callbacks.AuthDomainBasicAuthCallback' and
'GI.Soup.Callbacks.AuthDomainDigestAuthCallback'), because they don\'t require
keeping a cleartext password database. Most users will use the same
password for many different sites, meaning if any site with a
cleartext password database is compromised, accounts on other
servers might be compromised as well. For many of the cases where
'GI.Soup.Objects.Server.Server' is used, this is not really relevant, but it may still
be worth considering.
-}
type AuthDomainGenericAuthCallback =
    Soup.AuthDomain.AuthDomain
    {- ^ /@domain@/: a 'GI.Soup.Objects.AuthDomain.AuthDomain' -}
    -> Soup.Message.Message
    {- ^ /@msg@/: the 'GI.Soup.Objects.Message.Message' being authenticated -}
    -> T.Text
    {- ^ /@username@/: the username from /@msg@/ -}
    -> IO Bool
    {- ^ __Returns:__ 'True' if /@msg@/ is authenticated, 'False' if not. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `AuthDomainGenericAuthCallback`@.
noAuthDomainGenericAuthCallback :: Maybe AuthDomainGenericAuthCallback
noAuthDomainGenericAuthCallback = Nothing

{- |
The prototype for a 'GI.Soup.Objects.AuthDomain.AuthDomain' generic authentication callback.

The callback should look up the user\'s password, call
'GI.Soup.Objects.AuthDomain.authDomainCheckPassword', and use the return value from
that method as its own return value.

In general, for security reasons, it is preferable to use the
auth-domain-specific auth callbacks (eg,
'GI.Soup.Callbacks.AuthDomainBasicAuthCallback' and
'GI.Soup.Callbacks.AuthDomainDigestAuthCallback'), because they don\'t require
keeping a cleartext password database. Most users will use the same
password for many different sites, meaning if any site with a
cleartext password database is compromised, accounts on other
servers might be compromised as well. For many of the cases where
'GI.Soup.Objects.Server.Server' is used, this is not really relevant, but it may still
be worth considering.
-}
type AuthDomainGenericAuthCallback_WithClosures =
    Soup.AuthDomain.AuthDomain
    {- ^ /@domain@/: a 'GI.Soup.Objects.AuthDomain.AuthDomain' -}
    -> Soup.Message.Message
    {- ^ /@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' -}
    -> IO Bool
    {- ^ __Returns:__ 'True' if /@msg@/ is authenticated, 'False' if not. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `AuthDomainGenericAuthCallback_WithClosures`@.
noAuthDomainGenericAuthCallback_WithClosures :: Maybe AuthDomainGenericAuthCallback_WithClosures
noAuthDomainGenericAuthCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_AuthDomainGenericAuthCallback :: AuthDomainGenericAuthCallback -> AuthDomainGenericAuthCallback_WithClosures
drop_closures_AuthDomainGenericAuthCallback _f domain msg username _ = _f domain msg username

-- | Wrap the callback into a `GClosure`.
genClosure_AuthDomainGenericAuthCallback :: MonadIO m => AuthDomainGenericAuthCallback -> m (GClosure C_AuthDomainGenericAuthCallback)
genClosure_AuthDomainGenericAuthCallback cb = liftIO $ do
    let cb' = drop_closures_AuthDomainGenericAuthCallback cb
    let cb'' = wrap_AuthDomainGenericAuthCallback Nothing cb'
    mk_AuthDomainGenericAuthCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `AuthDomainGenericAuthCallback` into a `C_AuthDomainGenericAuthCallback`.
wrap_AuthDomainGenericAuthCallback ::
    Maybe (Ptr (FunPtr C_AuthDomainGenericAuthCallback)) ->
    AuthDomainGenericAuthCallback_WithClosures ->
    C_AuthDomainGenericAuthCallback
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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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'

-- | Generate a function pointer callable from C code, from a `C_AuthDomainFilter`.
foreign import ccall "wrapper"
    mk_AuthDomainFilter :: C_AuthDomainFilter -> IO (FunPtr C_AuthDomainFilter)

{- |
The prototype for a 'GI.Soup.Objects.AuthDomain.AuthDomain' filter; see
'GI.Soup.Objects.AuthDomain.authDomainSetFilter' for details.
-}
type AuthDomainFilter =
    Soup.AuthDomain.AuthDomain
    {- ^ /@domain@/: a 'GI.Soup.Objects.AuthDomain.AuthDomain' -}
    -> Soup.Message.Message
    {- ^ /@msg@/: a 'GI.Soup.Objects.Message.Message' -}
    -> IO Bool
    {- ^ __Returns:__ 'True' if /@msg@/ requires authentication, 'False' if not. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `AuthDomainFilter`@.
noAuthDomainFilter :: Maybe AuthDomainFilter
noAuthDomainFilter = Nothing

{- |
The prototype for a 'GI.Soup.Objects.AuthDomain.AuthDomain' filter; see
'GI.Soup.Objects.AuthDomain.authDomainSetFilter' for details.
-}
type AuthDomainFilter_WithClosures =
    Soup.AuthDomain.AuthDomain
    {- ^ /@domain@/: a 'GI.Soup.Objects.AuthDomain.AuthDomain' -}
    -> Soup.Message.Message
    {- ^ /@msg@/: a 'GI.Soup.Objects.Message.Message' -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.AuthDomain.authDomainSetFilter' -}
    -> IO Bool
    {- ^ __Returns:__ 'True' if /@msg@/ requires authentication, 'False' if not. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `AuthDomainFilter_WithClosures`@.
noAuthDomainFilter_WithClosures :: Maybe AuthDomainFilter_WithClosures
noAuthDomainFilter_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_AuthDomainFilter :: AuthDomainFilter -> AuthDomainFilter_WithClosures
drop_closures_AuthDomainFilter _f domain msg _ = _f domain msg

-- | Wrap the callback into a `GClosure`.
genClosure_AuthDomainFilter :: MonadIO m => AuthDomainFilter -> m (GClosure C_AuthDomainFilter)
genClosure_AuthDomainFilter cb = liftIO $ do
    let cb' = drop_closures_AuthDomainFilter cb
    let cb'' = wrap_AuthDomainFilter Nothing cb'
    mk_AuthDomainFilter cb'' >>= B.GClosure.newGClosure


-- | Wrap a `AuthDomainFilter` into a `C_AuthDomainFilter`.
wrap_AuthDomainFilter ::
    Maybe (Ptr (FunPtr C_AuthDomainFilter)) ->
    AuthDomainFilter_WithClosures ->
    C_AuthDomainFilter
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 = "AuthDomainDigest"}), 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 for the callback on the (unwrapped) C side.
type C_AuthDomainDigestAuthCallback =
    Ptr Soup.AuthDomainDigest.AuthDomainDigest ->
    Ptr Soup.Message.Message ->
    CString ->
    Ptr () ->
    IO CString

-- Args : [Arg {argCName = "domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomainDigest"}), 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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_AuthDomainDigestAuthCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.AuthDomainDigest.IsAuthDomainDigest 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.AuthDomainDigest.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

-- | Generate a function pointer callable from C code, from a `C_AuthDomainDigestAuthCallback`.
foreign import ccall "wrapper"
    mk_AuthDomainDigestAuthCallback :: C_AuthDomainDigestAuthCallback -> IO (FunPtr C_AuthDomainDigestAuthCallback)

{- |
Callback used by 'GI.Soup.Objects.AuthDomainDigest.AuthDomainDigest' for authentication purposes.
The application should look up /@username@/ in its password database,
and return the corresponding encoded password (see
'GI.Soup.Objects.AuthDomainDigest.authDomainDigestEncodePassword').
-}
type AuthDomainDigestAuthCallback =
    Soup.AuthDomainDigest.AuthDomainDigest
    {- ^ /@domain@/: the domain -}
    -> Soup.Message.Message
    {- ^ /@msg@/: the message being authenticated -}
    -> T.Text
    {- ^ /@username@/: the username provided by the client -}
    -> IO (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. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `AuthDomainDigestAuthCallback`@.
noAuthDomainDigestAuthCallback :: Maybe AuthDomainDigestAuthCallback
noAuthDomainDigestAuthCallback = Nothing

{- |
Callback used by 'GI.Soup.Objects.AuthDomainDigest.AuthDomainDigest' for authentication purposes.
The application should look up /@username@/ in its password database,
and return the corresponding encoded password (see
'GI.Soup.Objects.AuthDomainDigest.authDomainDigestEncodePassword').
-}
type AuthDomainDigestAuthCallback_WithClosures =
    Soup.AuthDomainDigest.AuthDomainDigest
    {- ^ /@domain@/: the domain -}
    -> Soup.Message.Message
    {- ^ /@msg@/: the message being authenticated -}
    -> T.Text
    {- ^ /@username@/: the username provided by the client -}
    -> Ptr ()
    {- ^ /@userData@/: the data passed to 'GI.Soup.Objects.AuthDomainDigest.authDomainDigestSetAuthCallback' -}
    -> IO (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. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `AuthDomainDigestAuthCallback_WithClosures`@.
noAuthDomainDigestAuthCallback_WithClosures :: Maybe AuthDomainDigestAuthCallback_WithClosures
noAuthDomainDigestAuthCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_AuthDomainDigestAuthCallback :: AuthDomainDigestAuthCallback -> AuthDomainDigestAuthCallback_WithClosures
drop_closures_AuthDomainDigestAuthCallback _f domain msg username _ = _f domain msg username

-- | Wrap the callback into a `GClosure`.
genClosure_AuthDomainDigestAuthCallback :: MonadIO m => AuthDomainDigestAuthCallback -> m (GClosure C_AuthDomainDigestAuthCallback)
genClosure_AuthDomainDigestAuthCallback cb = liftIO $ do
    let cb' = drop_closures_AuthDomainDigestAuthCallback cb
    let cb'' = wrap_AuthDomainDigestAuthCallback Nothing cb'
    mk_AuthDomainDigestAuthCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `AuthDomainDigestAuthCallback` into a `C_AuthDomainDigestAuthCallback`.
wrap_AuthDomainDigestAuthCallback ::
    Maybe (Ptr (FunPtr C_AuthDomainDigestAuthCallback)) ->
    AuthDomainDigestAuthCallback_WithClosures ->
    C_AuthDomainDigestAuthCallback
wrap_AuthDomainDigestAuthCallback funptrptr _cb domain msg username userData = do
    domain' <- (newObject Soup.AuthDomainDigest.AuthDomainDigest) 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 = "AuthDomainBasic"}), 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 for the callback on the (unwrapped) C side.
type C_AuthDomainBasicAuthCallback =
    Ptr Soup.AuthDomainBasic.AuthDomainBasic ->
    Ptr Soup.Message.Message ->
    CString ->
    CString ->
    Ptr () ->
    IO CInt

-- Args : [Arg {argCName = "domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomainBasic"}), 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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_AuthDomainBasicAuthCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.AuthDomainBasic.IsAuthDomainBasic 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.AuthDomainBasic.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'

-- | Generate a function pointer callable from C code, from a `C_AuthDomainBasicAuthCallback`.
foreign import ccall "wrapper"
    mk_AuthDomainBasicAuthCallback :: C_AuthDomainBasicAuthCallback -> IO (FunPtr C_AuthDomainBasicAuthCallback)

{- |
Callback used by 'GI.Soup.Objects.AuthDomainBasic.AuthDomainBasic' for authentication purposes.
The application should verify that /@username@/ and /@password@/ and valid
and return 'True' or 'False'.

If you are maintaining your own password database (rather than
using the password to authenticate against some other system like
PAM or a remote server), you should make sure you know what you are
doing. In particular, don\'t store cleartext passwords, or
easily-computed hashes of cleartext passwords, even if you don\'t
care that much about the security of your server, because users
will frequently use the same password for multiple sites, and so
compromising any site with a cleartext (or easily-cracked) password
database may give attackers access to other more-interesting sites
as well.
-}
type AuthDomainBasicAuthCallback =
    Soup.AuthDomainBasic.AuthDomainBasic
    {- ^ /@domain@/: the domain -}
    -> Soup.Message.Message
    {- ^ /@msg@/: the message being authenticated -}
    -> T.Text
    {- ^ /@username@/: the username provided by the client -}
    -> T.Text
    {- ^ /@password@/: the password provided by the client -}
    -> IO Bool
    {- ^ __Returns:__ 'True' if /@username@/ and /@password@/ are valid -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `AuthDomainBasicAuthCallback`@.
noAuthDomainBasicAuthCallback :: Maybe AuthDomainBasicAuthCallback
noAuthDomainBasicAuthCallback = Nothing

{- |
Callback used by 'GI.Soup.Objects.AuthDomainBasic.AuthDomainBasic' for authentication purposes.
The application should verify that /@username@/ and /@password@/ and valid
and return 'True' or 'False'.

If you are maintaining your own password database (rather than
using the password to authenticate against some other system like
PAM or a remote server), you should make sure you know what you are
doing. In particular, don\'t store cleartext passwords, or
easily-computed hashes of cleartext passwords, even if you don\'t
care that much about the security of your server, because users
will frequently use the same password for multiple sites, and so
compromising any site with a cleartext (or easily-cracked) password
database may give attackers access to other more-interesting sites
as well.
-}
type AuthDomainBasicAuthCallback_WithClosures =
    Soup.AuthDomainBasic.AuthDomainBasic
    {- ^ /@domain@/: the domain -}
    -> Soup.Message.Message
    {- ^ /@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.AuthDomainBasic.authDomainBasicSetAuthCallback' -}
    -> IO Bool
    {- ^ __Returns:__ 'True' if /@username@/ and /@password@/ are valid -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `AuthDomainBasicAuthCallback_WithClosures`@.
noAuthDomainBasicAuthCallback_WithClosures :: Maybe AuthDomainBasicAuthCallback_WithClosures
noAuthDomainBasicAuthCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_AuthDomainBasicAuthCallback :: AuthDomainBasicAuthCallback -> AuthDomainBasicAuthCallback_WithClosures
drop_closures_AuthDomainBasicAuthCallback _f domain msg username password _ = _f domain msg username password

-- | Wrap the callback into a `GClosure`.
genClosure_AuthDomainBasicAuthCallback :: MonadIO m => AuthDomainBasicAuthCallback -> m (GClosure C_AuthDomainBasicAuthCallback)
genClosure_AuthDomainBasicAuthCallback cb = liftIO $ do
    let cb' = drop_closures_AuthDomainBasicAuthCallback cb
    let cb'' = wrap_AuthDomainBasicAuthCallback Nothing cb'
    mk_AuthDomainBasicAuthCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `AuthDomainBasicAuthCallback` into a `C_AuthDomainBasicAuthCallback`.
wrap_AuthDomainBasicAuthCallback ::
    Maybe (Ptr (FunPtr C_AuthDomainBasicAuthCallback)) ->
    AuthDomainBasicAuthCallback_WithClosures ->
    C_AuthDomainBasicAuthCallback
wrap_AuthDomainBasicAuthCallback funptrptr _cb domain msg username password userData = do
    domain' <- (newObject Soup.AuthDomainBasic.AuthDomainBasic) 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 for the callback on the (unwrapped) C side.
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

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
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 ()

-- | Generate a function pointer callable from C code, from a `C_AddressCallback`.
foreign import ccall "wrapper"
    mk_AddressCallback :: C_AddressCallback -> IO (FunPtr C_AddressCallback)

{- |
The callback function passed to 'GI.Soup.Objects.Address.addressResolveAsync'.
-}
type AddressCallback =
    Soup.Address.Address
    {- ^ /@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' -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `AddressCallback`@.
noAddressCallback :: Maybe AddressCallback
noAddressCallback = Nothing

{- |
The callback function passed to 'GI.Soup.Objects.Address.addressResolveAsync'.
-}
type AddressCallback_WithClosures =
    Soup.Address.Address
    {- ^ /@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' -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `AddressCallback_WithClosures`@.
noAddressCallback_WithClosures :: Maybe AddressCallback_WithClosures
noAddressCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_AddressCallback :: AddressCallback -> AddressCallback_WithClosures
drop_closures_AddressCallback _f addr status _ = _f addr status

-- | Wrap the callback into a `GClosure`.
genClosure_AddressCallback :: MonadIO m => AddressCallback -> m (GClosure C_AddressCallback)
genClosure_AddressCallback cb = liftIO $ do
    let cb' = drop_closures_AddressCallback cb
    let cb'' = wrap_AddressCallback Nothing cb'
    mk_AddressCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `AddressCallback` into a `C_AddressCallback`.
wrap_AddressCallback ::
    Maybe (Ptr (FunPtr C_AddressCallback)) ->
    AddressCallback_WithClosures ->
    C_AddressCallback
wrap_AddressCallback funptrptr _cb addr status userData = do
    addr' <- (newObject Soup.Address.Address) addr
    _cb  addr' status userData
    maybeReleaseFunPtr funptrptr