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

-- * Exported types
    ResponsePolicyDecision(..)              ,
    IsResponsePolicyDecision                ,
    toResponsePolicyDecision                ,
    noResponsePolicyDecision                ,


 -- * Methods
-- ** getRequest #method:getRequest#

#if ENABLE_OVERLOADING
    ResponsePolicyDecisionGetRequestMethodInfo,
#endif
    responsePolicyDecisionGetRequest        ,


-- ** getResponse #method:getResponse#

#if ENABLE_OVERLOADING
    ResponsePolicyDecisionGetResponseMethodInfo,
#endif
    responsePolicyDecisionGetResponse       ,


-- ** isMimeTypeSupported #method:isMimeTypeSupported#

#if ENABLE_OVERLOADING
    ResponsePolicyDecisionIsMimeTypeSupportedMethodInfo,
#endif
    responsePolicyDecisionIsMimeTypeSupported,




 -- * Properties
-- ** request #attr:request#
{- | This property contains the 'GI.WebKit2.Objects.URIRequest.URIRequest' associated with this
policy decision.
-}
#if ENABLE_OVERLOADING
    ResponsePolicyDecisionRequestPropertyInfo,
#endif
    getResponsePolicyDecisionRequest        ,
#if ENABLE_OVERLOADING
    responsePolicyDecisionRequest           ,
#endif


-- ** response #attr:response#
{- | This property contains the 'GI.WebKit2.Objects.URIResponse.URIResponse' associated with this
policy decision.
-}
#if ENABLE_OVERLOADING
    ResponsePolicyDecisionResponsePropertyInfo,
#endif
    getResponsePolicyDecisionResponse       ,
#if ENABLE_OVERLOADING
    responsePolicyDecisionResponse          ,
#endif




    ) 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 {-# SOURCE #-} qualified GI.WebKit2.Objects.PolicyDecision as WebKit2.PolicyDecision
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 ResponsePolicyDecision = ResponsePolicyDecision (ManagedPtr ResponsePolicyDecision)
foreign import ccall "webkit_response_policy_decision_get_type"
    c_webkit_response_policy_decision_get_type :: IO GType

instance GObject ResponsePolicyDecision where
    gobjectType = c_webkit_response_policy_decision_get_type


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

instance O.HasParentTypes ResponsePolicyDecision
type instance O.ParentTypes ResponsePolicyDecision = '[WebKit2.PolicyDecision.PolicyDecision, GObject.Object.Object]

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

-- | A convenience alias for `Nothing` :: `Maybe` `ResponsePolicyDecision`.
noResponsePolicyDecision :: Maybe ResponsePolicyDecision
noResponsePolicyDecision = Nothing

#if ENABLE_OVERLOADING
type family ResolveResponsePolicyDecisionMethod (t :: Symbol) (o :: *) :: * where
    ResolveResponsePolicyDecisionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveResponsePolicyDecisionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveResponsePolicyDecisionMethod "download" o = WebKit2.PolicyDecision.PolicyDecisionDownloadMethodInfo
    ResolveResponsePolicyDecisionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveResponsePolicyDecisionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveResponsePolicyDecisionMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveResponsePolicyDecisionMethod "ignore" o = WebKit2.PolicyDecision.PolicyDecisionIgnoreMethodInfo
    ResolveResponsePolicyDecisionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveResponsePolicyDecisionMethod "isMimeTypeSupported" o = ResponsePolicyDecisionIsMimeTypeSupportedMethodInfo
    ResolveResponsePolicyDecisionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveResponsePolicyDecisionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveResponsePolicyDecisionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveResponsePolicyDecisionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveResponsePolicyDecisionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveResponsePolicyDecisionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveResponsePolicyDecisionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveResponsePolicyDecisionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveResponsePolicyDecisionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveResponsePolicyDecisionMethod "use" o = WebKit2.PolicyDecision.PolicyDecisionUseMethodInfo
    ResolveResponsePolicyDecisionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveResponsePolicyDecisionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveResponsePolicyDecisionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveResponsePolicyDecisionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveResponsePolicyDecisionMethod "getRequest" o = ResponsePolicyDecisionGetRequestMethodInfo
    ResolveResponsePolicyDecisionMethod "getResponse" o = ResponsePolicyDecisionGetResponseMethodInfo
    ResolveResponsePolicyDecisionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveResponsePolicyDecisionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveResponsePolicyDecisionMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveResponsePolicyDecisionMethod t ResponsePolicyDecision, O.MethodInfo info ResponsePolicyDecision p) => OL.IsLabel t (ResponsePolicyDecision -> 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

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

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

@
'Data.GI.Base.Attributes.get' responsePolicyDecision #request
@
-}
getResponsePolicyDecisionRequest :: (MonadIO m, IsResponsePolicyDecision o) => o -> m WebKit2.URIRequest.URIRequest
getResponsePolicyDecisionRequest obj = liftIO $ checkUnexpectedNothing "getResponsePolicyDecisionRequest" $ B.Properties.getObjectPropertyObject obj "request" WebKit2.URIRequest.URIRequest

#if ENABLE_OVERLOADING
data ResponsePolicyDecisionRequestPropertyInfo
instance AttrInfo ResponsePolicyDecisionRequestPropertyInfo where
    type AttrAllowedOps ResponsePolicyDecisionRequestPropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ResponsePolicyDecisionRequestPropertyInfo = (~) ()
    type AttrBaseTypeConstraint ResponsePolicyDecisionRequestPropertyInfo = IsResponsePolicyDecision
    type AttrGetType ResponsePolicyDecisionRequestPropertyInfo = WebKit2.URIRequest.URIRequest
    type AttrLabel ResponsePolicyDecisionRequestPropertyInfo = "request"
    type AttrOrigin ResponsePolicyDecisionRequestPropertyInfo = ResponsePolicyDecision
    attrGet _ = getResponsePolicyDecisionRequest
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

-- VVV Prop "response"
   -- Type: TInterface (Name {namespace = "WebKit2", name = "URIResponse"})
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,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' responsePolicyDecision #response
@
-}
getResponsePolicyDecisionResponse :: (MonadIO m, IsResponsePolicyDecision o) => o -> m WebKit2.URIResponse.URIResponse
getResponsePolicyDecisionResponse obj = liftIO $ checkUnexpectedNothing "getResponsePolicyDecisionResponse" $ B.Properties.getObjectPropertyObject obj "response" WebKit2.URIResponse.URIResponse

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

#if ENABLE_OVERLOADING
instance O.HasAttributeList ResponsePolicyDecision
type instance O.AttributeList ResponsePolicyDecision = ResponsePolicyDecisionAttributeList
type ResponsePolicyDecisionAttributeList = ('[ '("request", ResponsePolicyDecisionRequestPropertyInfo), '("response", ResponsePolicyDecisionResponsePropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
responsePolicyDecisionRequest :: AttrLabelProxy "request"
responsePolicyDecisionRequest = AttrLabelProxy

responsePolicyDecisionResponse :: AttrLabelProxy "response"
responsePolicyDecisionResponse = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
type instance O.SignalList ResponsePolicyDecision = ResponsePolicyDecisionSignalList
type ResponsePolicyDecisionSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

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

foreign import ccall "webkit_response_policy_decision_get_request" webkit_response_policy_decision_get_request ::
    Ptr ResponsePolicyDecision ->           -- decision : TInterface (Name {namespace = "WebKit2", name = "ResponsePolicyDecision"})
    IO (Ptr WebKit2.URIRequest.URIRequest)

{- |
Return the 'GI.WebKit2.Objects.URIRequest.URIRequest' associated with the response decision.
Modifications to the returned object are \<emphasis>not\<\/emphasis> taken
into account when the request is sent over the network, and is intended
only to aid in evaluating whether a response decision should be taken or
not. To modify requests before they are sent over the network the
@/WebKitPage::send-request/@ signal can be used instead.
-}
responsePolicyDecisionGetRequest ::
    (B.CallStack.HasCallStack, MonadIO m, IsResponsePolicyDecision a) =>
    a
    {- ^ /@decision@/: a 'GI.WebKit2.Objects.ResponsePolicyDecision.ResponsePolicyDecision' -}
    -> m WebKit2.URIRequest.URIRequest
    {- ^ __Returns:__ The URI request that is associated with this policy decision. -}
responsePolicyDecisionGetRequest decision = liftIO $ do
    decision' <- unsafeManagedPtrCastPtr decision
    result <- webkit_response_policy_decision_get_request decision'
    checkUnexpectedReturnNULL "responsePolicyDecisionGetRequest" result
    result' <- (newObject WebKit2.URIRequest.URIRequest) result
    touchManagedPtr decision
    return result'

#if ENABLE_OVERLOADING
data ResponsePolicyDecisionGetRequestMethodInfo
instance (signature ~ (m WebKit2.URIRequest.URIRequest), MonadIO m, IsResponsePolicyDecision a) => O.MethodInfo ResponsePolicyDecisionGetRequestMethodInfo a signature where
    overloadedMethod _ = responsePolicyDecisionGetRequest

#endif

-- method ResponsePolicyDecision::get_response
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "decision", argType = TInterface (Name {namespace = "WebKit2", name = "ResponsePolicyDecision"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitResponsePolicyDecision", 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_response_policy_decision_get_response" webkit_response_policy_decision_get_response ::
    Ptr ResponsePolicyDecision ->           -- decision : TInterface (Name {namespace = "WebKit2", name = "ResponsePolicyDecision"})
    IO (Ptr WebKit2.URIResponse.URIResponse)

{- |
Gets the value of the 'GI.WebKit2.Objects.ResponsePolicyDecision.ResponsePolicyDecision':@/response/@ property.
-}
responsePolicyDecisionGetResponse ::
    (B.CallStack.HasCallStack, MonadIO m, IsResponsePolicyDecision a) =>
    a
    {- ^ /@decision@/: a 'GI.WebKit2.Objects.ResponsePolicyDecision.ResponsePolicyDecision' -}
    -> m WebKit2.URIResponse.URIResponse
    {- ^ __Returns:__ The URI response that is associated with this policy decision. -}
responsePolicyDecisionGetResponse decision = liftIO $ do
    decision' <- unsafeManagedPtrCastPtr decision
    result <- webkit_response_policy_decision_get_response decision'
    checkUnexpectedReturnNULL "responsePolicyDecisionGetResponse" result
    result' <- (newObject WebKit2.URIResponse.URIResponse) result
    touchManagedPtr decision
    return result'

#if ENABLE_OVERLOADING
data ResponsePolicyDecisionGetResponseMethodInfo
instance (signature ~ (m WebKit2.URIResponse.URIResponse), MonadIO m, IsResponsePolicyDecision a) => O.MethodInfo ResponsePolicyDecisionGetResponseMethodInfo a signature where
    overloadedMethod _ = responsePolicyDecisionGetResponse

#endif

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

foreign import ccall "webkit_response_policy_decision_is_mime_type_supported" webkit_response_policy_decision_is_mime_type_supported ::
    Ptr ResponsePolicyDecision ->           -- decision : TInterface (Name {namespace = "WebKit2", name = "ResponsePolicyDecision"})
    IO CInt

{- |
Gets whether the MIME type of the response can be displayed in the 'GI.WebKit2.Objects.WebView.WebView'
that triggered this policy decision request. See also 'GI.WebKit2.Objects.WebView.webViewCanShowMimeType'.

/Since: 2.4/
-}
responsePolicyDecisionIsMimeTypeSupported ::
    (B.CallStack.HasCallStack, MonadIO m, IsResponsePolicyDecision a) =>
    a
    {- ^ /@decision@/: a 'GI.WebKit2.Objects.ResponsePolicyDecision.ResponsePolicyDecision' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the MIME type of the response is supported or 'False' otherwise -}
responsePolicyDecisionIsMimeTypeSupported decision = liftIO $ do
    decision' <- unsafeManagedPtrCastPtr decision
    result <- webkit_response_policy_decision_is_mime_type_supported decision'
    let result' = (/= 0) result
    touchManagedPtr decision
    return result'

#if ENABLE_OVERLOADING
data ResponsePolicyDecisionIsMimeTypeSupportedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsResponsePolicyDecision a) => O.MethodInfo ResponsePolicyDecisionIsMimeTypeSupportedMethodInfo a signature where
    overloadedMethod _ = responsePolicyDecisionIsMimeTypeSupported

#endif