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

-- * Exported types
    PolicyDecision(..)                      ,
    IsPolicyDecision                        ,
    toPolicyDecision                        ,
    noPolicyDecision                        ,


 -- * Methods
-- ** download #method:download#

#if ENABLE_OVERLOADING
    PolicyDecisionDownloadMethodInfo        ,
#endif
    policyDecisionDownload                  ,


-- ** ignore #method:ignore#

#if ENABLE_OVERLOADING
    PolicyDecisionIgnoreMethodInfo          ,
#endif
    policyDecisionIgnore                    ,


-- ** use #method:use#

#if ENABLE_OVERLOADING
    PolicyDecisionUseMethodInfo             ,
#endif
    policyDecisionUse                       ,




    ) 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

-- | Memory-managed wrapper type.
newtype PolicyDecision = PolicyDecision (ManagedPtr PolicyDecision)
foreign import ccall "webkit_policy_decision_get_type"
    c_webkit_policy_decision_get_type :: IO GType

instance GObject PolicyDecision where
    gobjectType = c_webkit_policy_decision_get_type


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

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

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

-- | A convenience alias for `Nothing` :: `Maybe` `PolicyDecision`.
noPolicyDecision :: Maybe PolicyDecision
noPolicyDecision = Nothing

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

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

#if ENABLE_OVERLOADING
instance O.HasAttributeList PolicyDecision
type instance O.AttributeList PolicyDecision = PolicyDecisionAttributeList
type PolicyDecisionAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

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

#endif

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

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

{- |
Spawn a download from this decision.
-}
policyDecisionDownload ::
    (B.CallStack.HasCallStack, MonadIO m, IsPolicyDecision a) =>
    a
    {- ^ /@decision@/: a 'GI.WebKit2.Objects.PolicyDecision.PolicyDecision' -}
    -> m ()
policyDecisionDownload decision = liftIO $ do
    decision' <- unsafeManagedPtrCastPtr decision
    webkit_policy_decision_download decision'
    touchManagedPtr decision
    return ()

#if ENABLE_OVERLOADING
data PolicyDecisionDownloadMethodInfo
instance (signature ~ (m ()), MonadIO m, IsPolicyDecision a) => O.MethodInfo PolicyDecisionDownloadMethodInfo a signature where
    overloadedMethod _ = policyDecisionDownload

#endif

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

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

{- |
Ignore the action which triggered this decision. For instance, for a
'GI.WebKit2.Objects.ResponsePolicyDecision.ResponsePolicyDecision', this would cancel the request.
-}
policyDecisionIgnore ::
    (B.CallStack.HasCallStack, MonadIO m, IsPolicyDecision a) =>
    a
    {- ^ /@decision@/: a 'GI.WebKit2.Objects.PolicyDecision.PolicyDecision' -}
    -> m ()
policyDecisionIgnore decision = liftIO $ do
    decision' <- unsafeManagedPtrCastPtr decision
    webkit_policy_decision_ignore decision'
    touchManagedPtr decision
    return ()

#if ENABLE_OVERLOADING
data PolicyDecisionIgnoreMethodInfo
instance (signature ~ (m ()), MonadIO m, IsPolicyDecision a) => O.MethodInfo PolicyDecisionIgnoreMethodInfo a signature where
    overloadedMethod _ = policyDecisionIgnore

#endif

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

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

{- |
Accept the action which triggered this decision.
-}
policyDecisionUse ::
    (B.CallStack.HasCallStack, MonadIO m, IsPolicyDecision a) =>
    a
    {- ^ /@decision@/: a 'GI.WebKit2.Objects.PolicyDecision.PolicyDecision' -}
    -> m ()
policyDecisionUse decision = liftIO $ do
    decision' <- unsafeManagedPtrCastPtr decision
    webkit_policy_decision_use decision'
    touchManagedPtr decision
    return ()

#if ENABLE_OVERLOADING
data PolicyDecisionUseMethodInfo
instance (signature ~ (m ()), MonadIO m, IsPolicyDecision a) => O.MethodInfo PolicyDecisionUseMethodInfo a signature where
    overloadedMethod _ = policyDecisionUse

#endif