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

/No description available in the introspection data./
-}

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

module GI.WebKit2.Objects.WebResource
    (

-- * Exported types
    WebResource(..)                         ,
    IsWebResource                           ,
    toWebResource                           ,
    noWebResource                           ,


 -- * Methods
-- ** getData #method:getData#

#if ENABLE_OVERLOADING
    WebResourceGetDataMethodInfo            ,
#endif
    webResourceGetData                      ,


-- ** getDataFinish #method:getDataFinish#

#if ENABLE_OVERLOADING
    WebResourceGetDataFinishMethodInfo      ,
#endif
    webResourceGetDataFinish                ,


-- ** getResponse #method:getResponse#

#if ENABLE_OVERLOADING
    WebResourceGetResponseMethodInfo        ,
#endif
    webResourceGetResponse                  ,


-- ** getUri #method:getUri#

#if ENABLE_OVERLOADING
    WebResourceGetUriMethodInfo             ,
#endif
    webResourceGetUri                       ,




 -- * Properties
-- ** response #attr:response#
{- | The 'GI.WebKit2.Objects.URIResponse.URIResponse' associated with this resource.
-}
#if ENABLE_OVERLOADING
    WebResourceResponsePropertyInfo         ,
#endif
    getWebResourceResponse                  ,
#if ENABLE_OVERLOADING
    webResourceResponse                     ,
#endif


-- ** uri #attr:uri#
{- | The current active URI of the 'GI.WebKit2.Objects.WebResource.WebResource'.
See 'GI.WebKit2.Objects.WebResource.webResourceGetUri' for more details.
-}
#if ENABLE_OVERLOADING
    WebResourceUriPropertyInfo              ,
#endif
    getWebResourceUri                       ,
#if ENABLE_OVERLOADING
    webResourceUri                          ,
#endif




 -- * Signals
-- ** failed #signal:failed#

    C_WebResourceFailedCallback             ,
    WebResourceFailedCallback               ,
#if ENABLE_OVERLOADING
    WebResourceFailedSignalInfo             ,
#endif
    afterWebResourceFailed                  ,
    genClosure_WebResourceFailed            ,
    mk_WebResourceFailedCallback            ,
    noWebResourceFailedCallback             ,
    onWebResourceFailed                     ,
    wrap_WebResourceFailedCallback          ,


-- ** failedWithTlsErrors #signal:failedWithTlsErrors#

    C_WebResourceFailedWithTlsErrorsCallback,
    WebResourceFailedWithTlsErrorsCallback  ,
#if ENABLE_OVERLOADING
    WebResourceFailedWithTlsErrorsSignalInfo,
#endif
    afterWebResourceFailedWithTlsErrors     ,
    genClosure_WebResourceFailedWithTlsErrors,
    mk_WebResourceFailedWithTlsErrorsCallback,
    noWebResourceFailedWithTlsErrorsCallback,
    onWebResourceFailedWithTlsErrors        ,
    wrap_WebResourceFailedWithTlsErrorsCallback,


-- ** finished #signal:finished#

    C_WebResourceFinishedCallback           ,
    WebResourceFinishedCallback             ,
#if ENABLE_OVERLOADING
    WebResourceFinishedSignalInfo           ,
#endif
    afterWebResourceFinished                ,
    genClosure_WebResourceFinished          ,
    mk_WebResourceFinishedCallback          ,
    noWebResourceFinishedCallback           ,
    onWebResourceFinished                   ,
    wrap_WebResourceFinishedCallback        ,


-- ** receivedData #signal:receivedData#

    C_WebResourceReceivedDataCallback       ,
    WebResourceReceivedDataCallback         ,
#if ENABLE_OVERLOADING
    WebResourceReceivedDataSignalInfo       ,
#endif
    afterWebResourceReceivedData            ,
    genClosure_WebResourceReceivedData      ,
    mk_WebResourceReceivedDataCallback      ,
    noWebResourceReceivedDataCallback       ,
    onWebResourceReceivedData               ,
    wrap_WebResourceReceivedDataCallback    ,


-- ** sentRequest #signal:sentRequest#

    C_WebResourceSentRequestCallback        ,
    WebResourceSentRequestCallback          ,
#if ENABLE_OVERLOADING
    WebResourceSentRequestSignalInfo        ,
#endif
    afterWebResourceSentRequest             ,
    genClosure_WebResourceSentRequest       ,
    mk_WebResourceSentRequestCallback       ,
    noWebResourceSentRequestCallback        ,
    onWebResourceSentRequest                ,
    wrap_WebResourceSentRequestCallback     ,




    ) 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.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Flags as Gio.Flags
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gio.Objects.TlsCertificate as Gio.TlsCertificate
import {-# SOURCE #-} qualified GI.WebKit2.Objects.URIRequest as WebKit2.URIRequest
import {-# SOURCE #-} qualified GI.WebKit2.Objects.URIResponse as WebKit2.URIResponse

-- | Memory-managed wrapper type.
newtype WebResource = WebResource (ManagedPtr WebResource)
foreign import ccall "webkit_web_resource_get_type"
    c_webkit_web_resource_get_type :: IO GType

instance GObject WebResource where
    gobjectType = c_webkit_web_resource_get_type


-- | Type class for types which can be safely cast to `WebResource`, for instance with `toWebResource`.
class (GObject o, O.IsDescendantOf WebResource o) => IsWebResource o
instance (GObject o, O.IsDescendantOf WebResource o) => IsWebResource o

instance O.HasParentTypes WebResource
type instance O.ParentTypes WebResource = '[GObject.Object.Object]

-- | Cast to `WebResource`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toWebResource :: (MonadIO m, IsWebResource o) => o -> m WebResource
toWebResource = liftIO . unsafeCastTo WebResource

-- | A convenience alias for `Nothing` :: `Maybe` `WebResource`.
noWebResource :: Maybe WebResource
noWebResource = Nothing

#if ENABLE_OVERLOADING
type family ResolveWebResourceMethod (t :: Symbol) (o :: *) :: * where
    ResolveWebResourceMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveWebResourceMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveWebResourceMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveWebResourceMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveWebResourceMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveWebResourceMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveWebResourceMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveWebResourceMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveWebResourceMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveWebResourceMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveWebResourceMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveWebResourceMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveWebResourceMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveWebResourceMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveWebResourceMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveWebResourceMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveWebResourceMethod "getData" o = WebResourceGetDataMethodInfo
    ResolveWebResourceMethod "getDataFinish" o = WebResourceGetDataFinishMethodInfo
    ResolveWebResourceMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveWebResourceMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveWebResourceMethod "getResponse" o = WebResourceGetResponseMethodInfo
    ResolveWebResourceMethod "getUri" o = WebResourceGetUriMethodInfo
    ResolveWebResourceMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveWebResourceMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveWebResourceMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveWebResourceMethod t WebResource, O.MethodInfo info WebResource p) => OL.IsLabel t (WebResource -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif

-- signal WebResource::failed
{- |
This signal is emitted when an error occurs during the resource
load operation.
-}
type WebResourceFailedCallback =
    GError
    {- ^ /@error@/: the 'GError' that was triggered -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `WebResourceFailedCallback`@.
noWebResourceFailedCallback :: Maybe WebResourceFailedCallback
noWebResourceFailedCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_WebResourceFailedCallback =
    Ptr () ->                               -- object
    Ptr GError ->
    Ptr () ->                               -- user_data
    IO ()

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

-- | Wrap the callback into a `GClosure`.
genClosure_WebResourceFailed :: MonadIO m => WebResourceFailedCallback -> m (GClosure C_WebResourceFailedCallback)
genClosure_WebResourceFailed cb = liftIO $ do
    let cb' = wrap_WebResourceFailedCallback cb
    mk_WebResourceFailedCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `WebResourceFailedCallback` into a `C_WebResourceFailedCallback`.
wrap_WebResourceFailedCallback ::
    WebResourceFailedCallback ->
    C_WebResourceFailedCallback
wrap_WebResourceFailedCallback _cb _ error_ _ = do
    error_' <- (newBoxed GError) error_
    _cb  error_'


{- |
Connect a signal handler for the “@failed@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' webResource #failed callback
@
-}
onWebResourceFailed :: (IsWebResource a, MonadIO m) => a -> WebResourceFailedCallback -> m SignalHandlerId
onWebResourceFailed obj cb = liftIO $ do
    let cb' = wrap_WebResourceFailedCallback cb
    cb'' <- mk_WebResourceFailedCallback cb'
    connectSignalFunPtr obj "failed" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@failed@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' webResource #failed callback
@
-}
afterWebResourceFailed :: (IsWebResource a, MonadIO m) => a -> WebResourceFailedCallback -> m SignalHandlerId
afterWebResourceFailed obj cb = liftIO $ do
    let cb' = wrap_WebResourceFailedCallback cb
    cb'' <- mk_WebResourceFailedCallback cb'
    connectSignalFunPtr obj "failed" cb'' SignalConnectAfter


-- signal WebResource::failed-with-tls-errors
{- |
This signal is emitted when a TLS error occurs during the resource load operation.

/Since: 2.8/
-}
type WebResourceFailedWithTlsErrorsCallback =
    Gio.TlsCertificate.TlsCertificate
    {- ^ /@certificate@/: a 'GI.Gio.Objects.TlsCertificate.TlsCertificate' -}
    -> [Gio.Flags.TlsCertificateFlags]
    {- ^ /@errors@/: a 'GI.Gio.Flags.TlsCertificateFlags' with the verification status of /@certificate@/ -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `WebResourceFailedWithTlsErrorsCallback`@.
noWebResourceFailedWithTlsErrorsCallback :: Maybe WebResourceFailedWithTlsErrorsCallback
noWebResourceFailedWithTlsErrorsCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_WebResourceFailedWithTlsErrorsCallback =
    Ptr () ->                               -- object
    Ptr Gio.TlsCertificate.TlsCertificate ->
    CUInt ->
    Ptr () ->                               -- user_data
    IO ()

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

-- | Wrap the callback into a `GClosure`.
genClosure_WebResourceFailedWithTlsErrors :: MonadIO m => WebResourceFailedWithTlsErrorsCallback -> m (GClosure C_WebResourceFailedWithTlsErrorsCallback)
genClosure_WebResourceFailedWithTlsErrors cb = liftIO $ do
    let cb' = wrap_WebResourceFailedWithTlsErrorsCallback cb
    mk_WebResourceFailedWithTlsErrorsCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `WebResourceFailedWithTlsErrorsCallback` into a `C_WebResourceFailedWithTlsErrorsCallback`.
wrap_WebResourceFailedWithTlsErrorsCallback ::
    WebResourceFailedWithTlsErrorsCallback ->
    C_WebResourceFailedWithTlsErrorsCallback
wrap_WebResourceFailedWithTlsErrorsCallback _cb _ certificate errors _ = do
    certificate' <- (newObject Gio.TlsCertificate.TlsCertificate) certificate
    let errors' = wordToGFlags errors
    _cb  certificate' errors'


{- |
Connect a signal handler for the “@failed-with-tls-errors@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' webResource #failedWithTlsErrors callback
@
-}
onWebResourceFailedWithTlsErrors :: (IsWebResource a, MonadIO m) => a -> WebResourceFailedWithTlsErrorsCallback -> m SignalHandlerId
onWebResourceFailedWithTlsErrors obj cb = liftIO $ do
    let cb' = wrap_WebResourceFailedWithTlsErrorsCallback cb
    cb'' <- mk_WebResourceFailedWithTlsErrorsCallback cb'
    connectSignalFunPtr obj "failed-with-tls-errors" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@failed-with-tls-errors@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' webResource #failedWithTlsErrors callback
@
-}
afterWebResourceFailedWithTlsErrors :: (IsWebResource a, MonadIO m) => a -> WebResourceFailedWithTlsErrorsCallback -> m SignalHandlerId
afterWebResourceFailedWithTlsErrors obj cb = liftIO $ do
    let cb' = wrap_WebResourceFailedWithTlsErrorsCallback cb
    cb'' <- mk_WebResourceFailedWithTlsErrorsCallback cb'
    connectSignalFunPtr obj "failed-with-tls-errors" cb'' SignalConnectAfter


-- signal WebResource::finished
{- |
This signal is emitted when the resource load finishes successfully
or due to an error. In case of errors 'GI.WebKit2.Objects.WebResource.WebResource'::@/failed/@ signal
is emitted before this one.
-}
type WebResourceFinishedCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `WebResourceFinishedCallback`@.
noWebResourceFinishedCallback :: Maybe WebResourceFinishedCallback
noWebResourceFinishedCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_WebResourceFinishedCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

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

-- | Wrap the callback into a `GClosure`.
genClosure_WebResourceFinished :: MonadIO m => WebResourceFinishedCallback -> m (GClosure C_WebResourceFinishedCallback)
genClosure_WebResourceFinished cb = liftIO $ do
    let cb' = wrap_WebResourceFinishedCallback cb
    mk_WebResourceFinishedCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `WebResourceFinishedCallback` into a `C_WebResourceFinishedCallback`.
wrap_WebResourceFinishedCallback ::
    WebResourceFinishedCallback ->
    C_WebResourceFinishedCallback
wrap_WebResourceFinishedCallback _cb _ _ = do
    _cb


{- |
Connect a signal handler for the “@finished@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' webResource #finished callback
@
-}
onWebResourceFinished :: (IsWebResource a, MonadIO m) => a -> WebResourceFinishedCallback -> m SignalHandlerId
onWebResourceFinished obj cb = liftIO $ do
    let cb' = wrap_WebResourceFinishedCallback cb
    cb'' <- mk_WebResourceFinishedCallback cb'
    connectSignalFunPtr obj "finished" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@finished@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' webResource #finished callback
@
-}
afterWebResourceFinished :: (IsWebResource a, MonadIO m) => a -> WebResourceFinishedCallback -> m SignalHandlerId
afterWebResourceFinished obj cb = liftIO $ do
    let cb' = wrap_WebResourceFinishedCallback cb
    cb'' <- mk_WebResourceFinishedCallback cb'
    connectSignalFunPtr obj "finished" cb'' SignalConnectAfter


-- signal WebResource::received-data
{- |
This signal is emitted after response is received,
every time new data has been received. It\'s
useful to know the progress of the resource load operation.
-}
type WebResourceReceivedDataCallback =
    Word64
    {- ^ /@dataLength@/: the length of data received in bytes -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `WebResourceReceivedDataCallback`@.
noWebResourceReceivedDataCallback :: Maybe WebResourceReceivedDataCallback
noWebResourceReceivedDataCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_WebResourceReceivedDataCallback =
    Ptr () ->                               -- object
    Word64 ->
    Ptr () ->                               -- user_data
    IO ()

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

-- | Wrap the callback into a `GClosure`.
genClosure_WebResourceReceivedData :: MonadIO m => WebResourceReceivedDataCallback -> m (GClosure C_WebResourceReceivedDataCallback)
genClosure_WebResourceReceivedData cb = liftIO $ do
    let cb' = wrap_WebResourceReceivedDataCallback cb
    mk_WebResourceReceivedDataCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `WebResourceReceivedDataCallback` into a `C_WebResourceReceivedDataCallback`.
wrap_WebResourceReceivedDataCallback ::
    WebResourceReceivedDataCallback ->
    C_WebResourceReceivedDataCallback
wrap_WebResourceReceivedDataCallback _cb _ dataLength _ = do
    _cb  dataLength


{- |
Connect a signal handler for the “@received-data@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' webResource #receivedData callback
@
-}
onWebResourceReceivedData :: (IsWebResource a, MonadIO m) => a -> WebResourceReceivedDataCallback -> m SignalHandlerId
onWebResourceReceivedData obj cb = liftIO $ do
    let cb' = wrap_WebResourceReceivedDataCallback cb
    cb'' <- mk_WebResourceReceivedDataCallback cb'
    connectSignalFunPtr obj "received-data" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@received-data@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' webResource #receivedData callback
@
-}
afterWebResourceReceivedData :: (IsWebResource a, MonadIO m) => a -> WebResourceReceivedDataCallback -> m SignalHandlerId
afterWebResourceReceivedData obj cb = liftIO $ do
    let cb' = wrap_WebResourceReceivedDataCallback cb
    cb'' <- mk_WebResourceReceivedDataCallback cb'
    connectSignalFunPtr obj "received-data" cb'' SignalConnectAfter


-- signal WebResource::sent-request
{- |
This signal is emitted when /@request@/ has been sent to the
server. In case of a server redirection this signal is
emitted again with the /@request@/ argument containing the new
request sent to the server due to the redirection and the
/@redirectedResponse@/ parameter containing the response
received by the server for the initial request.
-}
type WebResourceSentRequestCallback =
    WebKit2.URIRequest.URIRequest
    {- ^ /@request@/: a 'GI.WebKit2.Objects.URIRequest.URIRequest' -}
    -> WebKit2.URIResponse.URIResponse
    {- ^ /@redirectedResponse@/: a 'GI.WebKit2.Objects.URIResponse.URIResponse', or 'Nothing' -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `WebResourceSentRequestCallback`@.
noWebResourceSentRequestCallback :: Maybe WebResourceSentRequestCallback
noWebResourceSentRequestCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_WebResourceSentRequestCallback =
    Ptr () ->                               -- object
    Ptr WebKit2.URIRequest.URIRequest ->
    Ptr WebKit2.URIResponse.URIResponse ->
    Ptr () ->                               -- user_data
    IO ()

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

-- | Wrap the callback into a `GClosure`.
genClosure_WebResourceSentRequest :: MonadIO m => WebResourceSentRequestCallback -> m (GClosure C_WebResourceSentRequestCallback)
genClosure_WebResourceSentRequest cb = liftIO $ do
    let cb' = wrap_WebResourceSentRequestCallback cb
    mk_WebResourceSentRequestCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `WebResourceSentRequestCallback` into a `C_WebResourceSentRequestCallback`.
wrap_WebResourceSentRequestCallback ::
    WebResourceSentRequestCallback ->
    C_WebResourceSentRequestCallback
wrap_WebResourceSentRequestCallback _cb _ request redirectedResponse _ = do
    request' <- (newObject WebKit2.URIRequest.URIRequest) request
    redirectedResponse' <- (newObject WebKit2.URIResponse.URIResponse) redirectedResponse
    _cb  request' redirectedResponse'


{- |
Connect a signal handler for the “@sent-request@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' webResource #sentRequest callback
@
-}
onWebResourceSentRequest :: (IsWebResource a, MonadIO m) => a -> WebResourceSentRequestCallback -> m SignalHandlerId
onWebResourceSentRequest obj cb = liftIO $ do
    let cb' = wrap_WebResourceSentRequestCallback cb
    cb'' <- mk_WebResourceSentRequestCallback cb'
    connectSignalFunPtr obj "sent-request" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@sent-request@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' webResource #sentRequest callback
@
-}
afterWebResourceSentRequest :: (IsWebResource a, MonadIO m) => a -> WebResourceSentRequestCallback -> m SignalHandlerId
afterWebResourceSentRequest obj cb = liftIO $ do
    let cb' = wrap_WebResourceSentRequestCallback cb
    cb'' <- mk_WebResourceSentRequestCallback cb'
    connectSignalFunPtr obj "sent-request" cb'' SignalConnectAfter


-- VVV Prop "response"
   -- Type: TInterface (Name {namespace = "WebKit2", name = "URIResponse"})
   -- Flags: [PropertyReadable]
   -- Nullable: (Just True,Nothing)

{- |
Get the value of the “@response@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' webResource #response
@
-}
getWebResourceResponse :: (MonadIO m, IsWebResource o) => o -> m (Maybe WebKit2.URIResponse.URIResponse)
getWebResourceResponse obj = liftIO $ B.Properties.getObjectPropertyObject obj "response" WebKit2.URIResponse.URIResponse

#if ENABLE_OVERLOADING
data WebResourceResponsePropertyInfo
instance AttrInfo WebResourceResponsePropertyInfo where
    type AttrAllowedOps WebResourceResponsePropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint WebResourceResponsePropertyInfo = (~) ()
    type AttrBaseTypeConstraint WebResourceResponsePropertyInfo = IsWebResource
    type AttrGetType WebResourceResponsePropertyInfo = (Maybe WebKit2.URIResponse.URIResponse)
    type AttrLabel WebResourceResponsePropertyInfo = "response"
    type AttrOrigin WebResourceResponsePropertyInfo = WebResource
    attrGet _ = getWebResourceResponse
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

-- VVV Prop "uri"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

{- |
Get the value of the “@uri@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' webResource #uri
@
-}
getWebResourceUri :: (MonadIO m, IsWebResource o) => o -> m T.Text
getWebResourceUri obj = liftIO $ checkUnexpectedNothing "getWebResourceUri" $ B.Properties.getObjectPropertyString obj "uri"

#if ENABLE_OVERLOADING
data WebResourceUriPropertyInfo
instance AttrInfo WebResourceUriPropertyInfo where
    type AttrAllowedOps WebResourceUriPropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint WebResourceUriPropertyInfo = (~) ()
    type AttrBaseTypeConstraint WebResourceUriPropertyInfo = IsWebResource
    type AttrGetType WebResourceUriPropertyInfo = T.Text
    type AttrLabel WebResourceUriPropertyInfo = "uri"
    type AttrOrigin WebResourceUriPropertyInfo = WebResource
    attrGet _ = getWebResourceUri
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList WebResource
type instance O.AttributeList WebResource = WebResourceAttributeList
type WebResourceAttributeList = ('[ '("response", WebResourceResponsePropertyInfo), '("uri", WebResourceUriPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
webResourceResponse :: AttrLabelProxy "response"
webResourceResponse = AttrLabelProxy

webResourceUri :: AttrLabelProxy "uri"
webResourceUri = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
data WebResourceFailedSignalInfo
instance SignalInfo WebResourceFailedSignalInfo where
    type HaskellCallbackType WebResourceFailedSignalInfo = WebResourceFailedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_WebResourceFailedCallback cb
        cb'' <- mk_WebResourceFailedCallback cb'
        connectSignalFunPtr obj "failed" cb'' connectMode

data WebResourceFailedWithTlsErrorsSignalInfo
instance SignalInfo WebResourceFailedWithTlsErrorsSignalInfo where
    type HaskellCallbackType WebResourceFailedWithTlsErrorsSignalInfo = WebResourceFailedWithTlsErrorsCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_WebResourceFailedWithTlsErrorsCallback cb
        cb'' <- mk_WebResourceFailedWithTlsErrorsCallback cb'
        connectSignalFunPtr obj "failed-with-tls-errors" cb'' connectMode

data WebResourceFinishedSignalInfo
instance SignalInfo WebResourceFinishedSignalInfo where
    type HaskellCallbackType WebResourceFinishedSignalInfo = WebResourceFinishedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_WebResourceFinishedCallback cb
        cb'' <- mk_WebResourceFinishedCallback cb'
        connectSignalFunPtr obj "finished" cb'' connectMode

data WebResourceReceivedDataSignalInfo
instance SignalInfo WebResourceReceivedDataSignalInfo where
    type HaskellCallbackType WebResourceReceivedDataSignalInfo = WebResourceReceivedDataCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_WebResourceReceivedDataCallback cb
        cb'' <- mk_WebResourceReceivedDataCallback cb'
        connectSignalFunPtr obj "received-data" cb'' connectMode

data WebResourceSentRequestSignalInfo
instance SignalInfo WebResourceSentRequestSignalInfo where
    type HaskellCallbackType WebResourceSentRequestSignalInfo = WebResourceSentRequestCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_WebResourceSentRequestCallback cb
        cb'' <- mk_WebResourceSentRequestCallback cb'
        connectSignalFunPtr obj "sent-request" cb'' connectMode

type instance O.SignalList WebResource = WebResourceSignalList
type WebResourceSignalList = ('[ '("failed", WebResourceFailedSignalInfo), '("failedWithTlsErrors", WebResourceFailedWithTlsErrorsSignalInfo), '("finished", WebResourceFinishedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("receivedData", WebResourceReceivedDataSignalInfo), '("sentRequest", WebResourceSentRequestSignalInfo)] :: [(Symbol, *)])

#endif

-- method WebResource::get_data
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "resource", argType = TInterface (Name {namespace = "WebKit2", name = "WebResource"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebResource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable or %NULL to ignore", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call when the request is satisfied", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the data to pass to callback function", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_resource_get_data" webkit_web_resource_get_data ::
    Ptr WebResource ->                      -- resource : TInterface (Name {namespace = "WebKit2", name = "WebResource"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously get the raw data for /@resource@/.

When the operation is finished, /@callback@/ will be called. You can then call
'GI.WebKit2.Objects.WebResource.webResourceGetDataFinish' to get the result of the operation.
-}
webResourceGetData ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebResource a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@resource@/: a 'GI.WebKit2.Objects.WebResource.WebResource' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing' to ignore -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the request is satisfied -}
    -> m ()
webResourceGetData resource cancellable callback = liftIO $ do
    resource' <- unsafeManagedPtrCastPtr resource
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    webkit_web_resource_get_data resource' maybeCancellable maybeCallback userData
    touchManagedPtr resource
    whenJust cancellable touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data WebResourceGetDataMethodInfo
instance (signature ~ (Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsWebResource a, Gio.Cancellable.IsCancellable b) => O.MethodInfo WebResourceGetDataMethodInfo a signature where
    overloadedMethod _ = webResourceGetData

#endif

-- method WebResource::get_data_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "resource", argType = TInterface (Name {namespace = "WebKit2", name = "WebResource"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebResource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GAsyncResult", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the length of the resource data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the length of the resource data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- returnType : Just (TCArray False (-1) 2 (TBasicType TUInt8))
-- throws : True
-- Skip return : False

foreign import ccall "webkit_web_resource_get_data_finish" webkit_web_resource_get_data_finish ::
    Ptr WebResource ->                      -- resource : TInterface (Name {namespace = "WebKit2", name = "WebResource"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr Word64 ->                           -- length : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Word8)

{- |
Finish an asynchronous operation started with 'GI.WebKit2.Objects.WebResource.webResourceGetData'.
-}
webResourceGetDataFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebResource a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@resource@/: a 'GI.WebKit2.Objects.WebResource.WebResource' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m ByteString
    {- ^ __Returns:__ a
   string with the data of /@resource@/, or 'Nothing' in case of error. if /@length@/
   is not 'Nothing', the size of the data will be assigned to it. /(Can throw 'Data.GI.Base.GError.GError')/ -}
webResourceGetDataFinish resource result_ = liftIO $ do
    resource' <- unsafeManagedPtrCastPtr resource
    result_' <- unsafeManagedPtrCastPtr result_
    length_ <- allocMem :: IO (Ptr Word64)
    onException (do
        result <- propagateGError $ webkit_web_resource_get_data_finish resource' result_' length_
        length_' <- peek length_
        checkUnexpectedReturnNULL "webResourceGetDataFinish" result
        result' <- (unpackByteStringWithLength length_') result
        freeMem result
        touchManagedPtr resource
        touchManagedPtr result_
        freeMem length_
        return result'
     ) (do
        freeMem length_
     )

#if ENABLE_OVERLOADING
data WebResourceGetDataFinishMethodInfo
instance (signature ~ (b -> m ByteString), MonadIO m, IsWebResource a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo WebResourceGetDataFinishMethodInfo a signature where
    overloadedMethod _ = webResourceGetDataFinish

#endif

-- method WebResource::get_response
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "resource", argType = TInterface (Name {namespace = "WebKit2", name = "WebResource"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebResource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit2", name = "URIResponse"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_resource_get_response" webkit_web_resource_get_response ::
    Ptr WebResource ->                      -- resource : TInterface (Name {namespace = "WebKit2", name = "WebResource"})
    IO (Ptr WebKit2.URIResponse.URIResponse)

{- |
Retrieves the 'GI.WebKit2.Objects.URIResponse.URIResponse' of the resource load operation.
This method returns 'Nothing' if called before the response
is received from the server. You can connect to notify::response
signal to be notified when the response is received.
-}
webResourceGetResponse ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebResource a) =>
    a
    {- ^ /@resource@/: a 'GI.WebKit2.Objects.WebResource.WebResource' -}
    -> m (Maybe WebKit2.URIResponse.URIResponse)
    {- ^ __Returns:__ the 'GI.WebKit2.Objects.URIResponse.URIResponse', or 'Nothing' if
    the response hasn\'t been received yet. -}
webResourceGetResponse resource = liftIO $ do
    resource' <- unsafeManagedPtrCastPtr resource
    result <- webkit_web_resource_get_response resource'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject WebKit2.URIResponse.URIResponse) result'
        return result''
    touchManagedPtr resource
    return maybeResult

#if ENABLE_OVERLOADING
data WebResourceGetResponseMethodInfo
instance (signature ~ (m (Maybe WebKit2.URIResponse.URIResponse)), MonadIO m, IsWebResource a) => O.MethodInfo WebResourceGetResponseMethodInfo a signature where
    overloadedMethod _ = webResourceGetResponse

#endif

-- method WebResource::get_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "resource", argType = TInterface (Name {namespace = "WebKit2", name = "WebResource"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebResource", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_resource_get_uri" webkit_web_resource_get_uri ::
    Ptr WebResource ->                      -- resource : TInterface (Name {namespace = "WebKit2", name = "WebResource"})
    IO CString

{- |
Returns the current active URI of /@resource@/. The active URI might change during
a load operation:

\<orderedlist>
\<listitem>\<para>
  When the resource load starts, the active URI is the requested URI
\<\/para>\<\/listitem>
\<listitem>\<para>
  When the initial request is sent to the server, 'GI.WebKit2.Objects.WebResource.WebResource'::@/sent-request/@
  signal is emitted without a redirected response, the active URI is the URI of
  the request sent to the server.
\<\/para>\<\/listitem>
\<listitem>\<para>
  In case of a server redirection, 'GI.WebKit2.Objects.WebResource.WebResource'::@/sent-request/@ signal
  is emitted again with a redirected response, the active URI is the URI the request
  was redirected to.
\<\/para>\<\/listitem>
\<listitem>\<para>
  When the response is received from the server, the active URI is the final
  one and it will not change again.
\<\/para>\<\/listitem>
\<\/orderedlist>

You can monitor the active URI by connecting to the notify::uri
signal of /@resource@/.
-}
webResourceGetUri ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebResource a) =>
    a
    {- ^ /@resource@/: a 'GI.WebKit2.Objects.WebResource.WebResource' -}
    -> m T.Text
    {- ^ __Returns:__ the current active URI of /@resource@/ -}
webResourceGetUri resource = liftIO $ do
    resource' <- unsafeManagedPtrCastPtr resource
    result <- webkit_web_resource_get_uri resource'
    checkUnexpectedReturnNULL "webResourceGetUri" result
    result' <- cstringToText result
    touchManagedPtr resource
    return result'

#if ENABLE_OVERLOADING
data WebResourceGetUriMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsWebResource a) => O.MethodInfo WebResourceGetUriMethodInfo a signature where
    overloadedMethod _ = webResourceGetUri

#endif