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

/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.CookieManager
    (

-- * Exported types
    CookieManager(..)                       ,
    IsCookieManager                         ,
    toCookieManager                         ,
    noCookieManager                         ,


 -- * Methods
-- ** deleteAllCookies #method:deleteAllCookies#

#if ENABLE_OVERLOADING
    CookieManagerDeleteAllCookiesMethodInfo ,
#endif
    cookieManagerDeleteAllCookies           ,


-- ** deleteCookiesForDomain #method:deleteCookiesForDomain#

#if ENABLE_OVERLOADING
    CookieManagerDeleteCookiesForDomainMethodInfo,
#endif
    cookieManagerDeleteCookiesForDomain     ,


-- ** getAcceptPolicy #method:getAcceptPolicy#

#if ENABLE_OVERLOADING
    CookieManagerGetAcceptPolicyMethodInfo  ,
#endif
    cookieManagerGetAcceptPolicy            ,


-- ** getAcceptPolicyFinish #method:getAcceptPolicyFinish#

#if ENABLE_OVERLOADING
    CookieManagerGetAcceptPolicyFinishMethodInfo,
#endif
    cookieManagerGetAcceptPolicyFinish      ,


-- ** getDomainsWithCookies #method:getDomainsWithCookies#

#if ENABLE_OVERLOADING
    CookieManagerGetDomainsWithCookiesMethodInfo,
#endif
    cookieManagerGetDomainsWithCookies      ,


-- ** getDomainsWithCookiesFinish #method:getDomainsWithCookiesFinish#

#if ENABLE_OVERLOADING
    CookieManagerGetDomainsWithCookiesFinishMethodInfo,
#endif
    cookieManagerGetDomainsWithCookiesFinish,


-- ** setAcceptPolicy #method:setAcceptPolicy#

#if ENABLE_OVERLOADING
    CookieManagerSetAcceptPolicyMethodInfo  ,
#endif
    cookieManagerSetAcceptPolicy            ,


-- ** setPersistentStorage #method:setPersistentStorage#

#if ENABLE_OVERLOADING
    CookieManagerSetPersistentStorageMethodInfo,
#endif
    cookieManagerSetPersistentStorage       ,




 -- * Signals
-- ** changed #signal:changed#

    C_CookieManagerChangedCallback          ,
    CookieManagerChangedCallback            ,
#if ENABLE_OVERLOADING
    CookieManagerChangedSignalInfo          ,
#endif
    afterCookieManagerChanged               ,
    genClosure_CookieManagerChanged         ,
    mk_CookieManagerChangedCallback         ,
    noCookieManagerChangedCallback          ,
    onCookieManagerChanged                  ,
    wrap_CookieManagerChangedCallback       ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.WebKit2.Enums as WebKit2.Enums

-- | Memory-managed wrapper type.
newtype CookieManager = CookieManager (ManagedPtr CookieManager)
foreign import ccall "webkit_cookie_manager_get_type"
    c_webkit_cookie_manager_get_type :: IO GType

instance GObject CookieManager where
    gobjectType _ = c_webkit_cookie_manager_get_type


-- | Type class for types which can be safely cast to `CookieManager`, for instance with `toCookieManager`.
class GObject o => IsCookieManager o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError CookieManager a) =>
    IsCookieManager a
#endif
instance IsCookieManager CookieManager
instance GObject.Object.IsObject CookieManager

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

-- | A convenience alias for `Nothing` :: `Maybe` `CookieManager`.
noCookieManager :: Maybe CookieManager
noCookieManager = Nothing

#if ENABLE_OVERLOADING
type family ResolveCookieManagerMethod (t :: Symbol) (o :: *) :: * where
    ResolveCookieManagerMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveCookieManagerMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveCookieManagerMethod "deleteAllCookies" o = CookieManagerDeleteAllCookiesMethodInfo
    ResolveCookieManagerMethod "deleteCookiesForDomain" o = CookieManagerDeleteCookiesForDomainMethodInfo
    ResolveCookieManagerMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveCookieManagerMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveCookieManagerMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveCookieManagerMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveCookieManagerMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveCookieManagerMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveCookieManagerMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveCookieManagerMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveCookieManagerMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveCookieManagerMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveCookieManagerMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveCookieManagerMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveCookieManagerMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveCookieManagerMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveCookieManagerMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveCookieManagerMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveCookieManagerMethod "getAcceptPolicy" o = CookieManagerGetAcceptPolicyMethodInfo
    ResolveCookieManagerMethod "getAcceptPolicyFinish" o = CookieManagerGetAcceptPolicyFinishMethodInfo
    ResolveCookieManagerMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveCookieManagerMethod "getDomainsWithCookies" o = CookieManagerGetDomainsWithCookiesMethodInfo
    ResolveCookieManagerMethod "getDomainsWithCookiesFinish" o = CookieManagerGetDomainsWithCookiesFinishMethodInfo
    ResolveCookieManagerMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveCookieManagerMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveCookieManagerMethod "setAcceptPolicy" o = CookieManagerSetAcceptPolicyMethodInfo
    ResolveCookieManagerMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveCookieManagerMethod "setPersistentStorage" o = CookieManagerSetPersistentStorageMethodInfo
    ResolveCookieManagerMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveCookieManagerMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveCookieManagerMethod t CookieManager, O.MethodInfo info CookieManager p) => O.IsLabelProxy t (CookieManager -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveCookieManagerMethod t CookieManager, O.MethodInfo info CookieManager p) => O.IsLabel t (CookieManager -> 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

#endif

-- signal CookieManager::changed
{- |
This signal is emitted when cookies are added, removed or modified.
-}
type CookieManagerChangedCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `CookieManagerChangedCallback`@.
noCookieManagerChangedCallback :: Maybe CookieManagerChangedCallback
noCookieManagerChangedCallback = Nothing

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

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

-- | Wrap the callback into a `Closure`.
genClosure_CookieManagerChanged :: CookieManagerChangedCallback -> IO Closure
genClosure_CookieManagerChanged cb = do
    let cb' = wrap_CookieManagerChangedCallback cb
    mk_CookieManagerChangedCallback cb' >>= newCClosure


-- | Wrap a `CookieManagerChangedCallback` into a `C_CookieManagerChangedCallback`.
wrap_CookieManagerChangedCallback ::
    CookieManagerChangedCallback ->
    C_CookieManagerChangedCallback
wrap_CookieManagerChangedCallback _cb _ _ = do
    _cb


{- |
Connect a signal handler for the “@changed@” 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' cookieManager #changed callback
@
-}
onCookieManagerChanged :: (IsCookieManager a, MonadIO m) => a -> CookieManagerChangedCallback -> m SignalHandlerId
onCookieManagerChanged obj cb = liftIO $ do
    let cb' = wrap_CookieManagerChangedCallback cb
    cb'' <- mk_CookieManagerChangedCallback cb'
    connectSignalFunPtr obj "changed" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@changed@” 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' cookieManager #changed callback
@
-}
afterCookieManagerChanged :: (IsCookieManager a, MonadIO m) => a -> CookieManagerChangedCallback -> m SignalHandlerId
afterCookieManagerChanged obj cb = liftIO $ do
    let cb' = wrap_CookieManagerChangedCallback cb
    cb'' <- mk_CookieManagerChangedCallback cb'
    connectSignalFunPtr obj "changed" cb'' SignalConnectAfter


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

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
data CookieManagerChangedSignalInfo
instance SignalInfo CookieManagerChangedSignalInfo where
    type HaskellCallbackType CookieManagerChangedSignalInfo = CookieManagerChangedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_CookieManagerChangedCallback cb
        cb'' <- mk_CookieManagerChangedCallback cb'
        connectSignalFunPtr obj "changed" cb'' connectMode

type instance O.SignalList CookieManager = CookieManagerSignalList
type CookieManagerSignalList = ('[ '("changed", CookieManagerChangedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

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

foreign import ccall "webkit_cookie_manager_delete_all_cookies" webkit_cookie_manager_delete_all_cookies ::
    Ptr CookieManager ->                    -- cookie_manager : TInterface (Name {namespace = "WebKit2", name = "CookieManager"})
    IO ()

{-# DEPRECATED cookieManagerDeleteAllCookies ["(Since version 2.16)","Use 'GI.WebKit2.Objects.WebsiteDataManager.websiteDataManagerClear' instead."] #-}
{- |
Delete all cookies of /@cookieManager@/
-}
cookieManagerDeleteAllCookies ::
    (B.CallStack.HasCallStack, MonadIO m, IsCookieManager a) =>
    a
    {- ^ /@cookieManager@/: a 'GI.WebKit2.Objects.CookieManager.CookieManager' -}
    -> m ()
cookieManagerDeleteAllCookies cookieManager = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    webkit_cookie_manager_delete_all_cookies cookieManager'
    touchManagedPtr cookieManager
    return ()

#if ENABLE_OVERLOADING
data CookieManagerDeleteAllCookiesMethodInfo
instance (signature ~ (m ()), MonadIO m, IsCookieManager a) => O.MethodInfo CookieManagerDeleteAllCookiesMethodInfo a signature where
    overloadedMethod _ = cookieManagerDeleteAllCookies

#endif

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

foreign import ccall "webkit_cookie_manager_delete_cookies_for_domain" webkit_cookie_manager_delete_cookies_for_domain ::
    Ptr CookieManager ->                    -- cookie_manager : TInterface (Name {namespace = "WebKit2", name = "CookieManager"})
    CString ->                              -- domain : TBasicType TUTF8
    IO ()

{-# DEPRECATED cookieManagerDeleteCookiesForDomain ["(Since version 2.16)","Use 'GI.WebKit2.Objects.WebsiteDataManager.websiteDataManagerRemove' instead."] #-}
{- |
Remove all cookies of /@cookieManager@/ for the given /@domain@/.
-}
cookieManagerDeleteCookiesForDomain ::
    (B.CallStack.HasCallStack, MonadIO m, IsCookieManager a) =>
    a
    {- ^ /@cookieManager@/: a 'GI.WebKit2.Objects.CookieManager.CookieManager' -}
    -> T.Text
    {- ^ /@domain@/: a domain name -}
    -> m ()
cookieManagerDeleteCookiesForDomain cookieManager domain = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    domain' <- textToCString domain
    webkit_cookie_manager_delete_cookies_for_domain cookieManager' domain'
    touchManagedPtr cookieManager
    freeMem domain'
    return ()

#if ENABLE_OVERLOADING
data CookieManagerDeleteCookiesForDomainMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsCookieManager a) => O.MethodInfo CookieManagerDeleteCookiesForDomainMethodInfo a signature where
    overloadedMethod _ = cookieManagerDeleteCookiesForDomain

#endif

-- method CookieManager::get_accept_policy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cookie_manager", argType = TInterface (Name {namespace = "WebKit2", name = "CookieManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitCookieManager", 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_cookie_manager_get_accept_policy" webkit_cookie_manager_get_accept_policy ::
    Ptr CookieManager ->                    -- cookie_manager : TInterface (Name {namespace = "WebKit2", name = "CookieManager"})
    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 cookie acceptance policy of /@cookieManager@/.

When the operation is finished, /@callback@/ will be called. You can then call
'GI.WebKit2.Objects.CookieManager.cookieManagerGetAcceptPolicyFinish' to get the result of the operation.
-}
cookieManagerGetAcceptPolicy ::
    (B.CallStack.HasCallStack, MonadIO m, IsCookieManager a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@cookieManager@/: a 'GI.WebKit2.Objects.CookieManager.CookieManager' -}
    -> 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 ()
cookieManagerGetAcceptPolicy cookieManager cancellable callback = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            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_cookie_manager_get_accept_policy cookieManager' maybeCancellable maybeCallback userData
    touchManagedPtr cookieManager
    whenJust cancellable touchManagedPtr
    return ()

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

#endif

-- method CookieManager::get_accept_policy_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cookie_manager", argType = TInterface (Name {namespace = "WebKit2", name = "CookieManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitCookieManager", 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}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit2", name = "CookieAcceptPolicy"}))
-- throws : True
-- Skip return : False

foreign import ccall "webkit_cookie_manager_get_accept_policy_finish" webkit_cookie_manager_get_accept_policy_finish ::
    Ptr CookieManager ->                    -- cookie_manager : TInterface (Name {namespace = "WebKit2", name = "CookieManager"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CUInt

{- |
Finish an asynchronous operation started with 'GI.WebKit2.Objects.CookieManager.cookieManagerGetAcceptPolicy'.
-}
cookieManagerGetAcceptPolicyFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsCookieManager a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@cookieManager@/: a 'GI.WebKit2.Objects.CookieManager.CookieManager' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m WebKit2.Enums.CookieAcceptPolicy
    {- ^ __Returns:__ the cookie acceptance policy of /@cookieManager@/ as a 'GI.WebKit2.Enums.CookieAcceptPolicy'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
cookieManagerGetAcceptPolicyFinish cookieManager result_ = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ webkit_cookie_manager_get_accept_policy_finish cookieManager' result_'
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr cookieManager
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data CookieManagerGetAcceptPolicyFinishMethodInfo
instance (signature ~ (b -> m WebKit2.Enums.CookieAcceptPolicy), MonadIO m, IsCookieManager a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo CookieManagerGetAcceptPolicyFinishMethodInfo a signature where
    overloadedMethod _ = cookieManagerGetAcceptPolicyFinish

#endif

-- method CookieManager::get_domains_with_cookies
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cookie_manager", argType = TInterface (Name {namespace = "WebKit2", name = "CookieManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitCookieManager", 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_cookie_manager_get_domains_with_cookies" webkit_cookie_manager_get_domains_with_cookies ::
    Ptr CookieManager ->                    -- cookie_manager : TInterface (Name {namespace = "WebKit2", name = "CookieManager"})
    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 ()

{-# DEPRECATED cookieManagerGetDomainsWithCookies ["(Since version 2.16)","Use 'GI.WebKit2.Objects.WebsiteDataManager.websiteDataManagerFetch' instead."] #-}
{- |
Asynchronously get the list of domains for which /@cookieManager@/ contains cookies.

When the operation is finished, /@callback@/ will be called. You can then call
'GI.WebKit2.Objects.CookieManager.cookieManagerGetDomainsWithCookiesFinish' to get the result of the operation.
-}
cookieManagerGetDomainsWithCookies ::
    (B.CallStack.HasCallStack, MonadIO m, IsCookieManager a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@cookieManager@/: a 'GI.WebKit2.Objects.CookieManager.CookieManager' -}
    -> 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 ()
cookieManagerGetDomainsWithCookies cookieManager cancellable callback = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            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_cookie_manager_get_domains_with_cookies cookieManager' maybeCancellable maybeCallback userData
    touchManagedPtr cookieManager
    whenJust cancellable touchManagedPtr
    return ()

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

#endif

-- method CookieManager::get_domains_with_cookies_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cookie_manager", argType = TInterface (Name {namespace = "WebKit2", name = "CookieManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitCookieManager", 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}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : True
-- Skip return : False

foreign import ccall "webkit_cookie_manager_get_domains_with_cookies_finish" webkit_cookie_manager_get_domains_with_cookies_finish ::
    Ptr CookieManager ->                    -- cookie_manager : TInterface (Name {namespace = "WebKit2", name = "CookieManager"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr CString)

{-# DEPRECATED cookieManagerGetDomainsWithCookiesFinish ["(Since version 2.16)","Use 'GI.WebKit2.Objects.WebsiteDataManager.websiteDataManagerFetchFinish' instead."] #-}
{- |
Finish an asynchronous operation started with 'GI.WebKit2.Objects.CookieManager.cookieManagerGetDomainsWithCookies'.
The return value is a 'Nothing' terminated list of strings which should
be released with 'GI.GLib.Functions.strfreev'.
-}
cookieManagerGetDomainsWithCookiesFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsCookieManager a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@cookieManager@/: a 'GI.WebKit2.Objects.CookieManager.CookieManager' -}
    -> b
    {- ^ /@result@/: a 'GI.Gio.Interfaces.AsyncResult.AsyncResult' -}
    -> m [T.Text]
    {- ^ __Returns:__ A 'Nothing' terminated array of domain names
   or 'Nothing' in case of error. /(Can throw 'Data.GI.Base.GError.GError')/ -}
cookieManagerGetDomainsWithCookiesFinish cookieManager result_ = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ webkit_cookie_manager_get_domains_with_cookies_finish cookieManager' result_'
        checkUnexpectedReturnNULL "cookieManagerGetDomainsWithCookiesFinish" result
        result' <- unpackZeroTerminatedUTF8CArray result
        mapZeroTerminatedCArray freeMem result
        freeMem result
        touchManagedPtr cookieManager
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data CookieManagerGetDomainsWithCookiesFinishMethodInfo
instance (signature ~ (b -> m [T.Text]), MonadIO m, IsCookieManager a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo CookieManagerGetDomainsWithCookiesFinishMethodInfo a signature where
    overloadedMethod _ = cookieManagerGetDomainsWithCookiesFinish

#endif

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

foreign import ccall "webkit_cookie_manager_set_accept_policy" webkit_cookie_manager_set_accept_policy ::
    Ptr CookieManager ->                    -- cookie_manager : TInterface (Name {namespace = "WebKit2", name = "CookieManager"})
    CUInt ->                                -- policy : TInterface (Name {namespace = "WebKit2", name = "CookieAcceptPolicy"})
    IO ()

{- |
Set the cookie acceptance policy of /@cookieManager@/ as /@policy@/.
-}
cookieManagerSetAcceptPolicy ::
    (B.CallStack.HasCallStack, MonadIO m, IsCookieManager a) =>
    a
    {- ^ /@cookieManager@/: a 'GI.WebKit2.Objects.CookieManager.CookieManager' -}
    -> WebKit2.Enums.CookieAcceptPolicy
    {- ^ /@policy@/: a 'GI.WebKit2.Enums.CookieAcceptPolicy' -}
    -> m ()
cookieManagerSetAcceptPolicy cookieManager policy = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    let policy' = (fromIntegral . fromEnum) policy
    webkit_cookie_manager_set_accept_policy cookieManager' policy'
    touchManagedPtr cookieManager
    return ()

#if ENABLE_OVERLOADING
data CookieManagerSetAcceptPolicyMethodInfo
instance (signature ~ (WebKit2.Enums.CookieAcceptPolicy -> m ()), MonadIO m, IsCookieManager a) => O.MethodInfo CookieManagerSetAcceptPolicyMethodInfo a signature where
    overloadedMethod _ = cookieManagerSetAcceptPolicy

#endif

-- method CookieManager::set_persistent_storage
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cookie_manager", argType = TInterface (Name {namespace = "WebKit2", name = "CookieManager"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitCookieManager", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "filename", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the filename to read to/write from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "storage", argType = TInterface (Name {namespace = "WebKit2", name = "CookiePersistentStorage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitCookiePersistentStorage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_cookie_manager_set_persistent_storage" webkit_cookie_manager_set_persistent_storage ::
    Ptr CookieManager ->                    -- cookie_manager : TInterface (Name {namespace = "WebKit2", name = "CookieManager"})
    CString ->                              -- filename : TBasicType TUTF8
    CUInt ->                                -- storage : TInterface (Name {namespace = "WebKit2", name = "CookiePersistentStorage"})
    IO ()

{- |
Set the /@filename@/ where non-session cookies are stored persistently using
/@storage@/ as the format to read\/write the cookies.
Cookies are initially read from /@filename@/ to create an initial set of cookies.
Then, non-session cookies will be written to /@filename@/ when the WebKitCookieManager::changed
signal is emitted.
By default, /@cookieManager@/ doesn\'t store the cookies persistently, so you need to call this
method to keep cookies saved across sessions.

This method should never be called on a 'GI.WebKit2.Objects.CookieManager.CookieManager' associated to an ephemeral 'GI.WebKit2.Objects.WebsiteDataManager.WebsiteDataManager'.
-}
cookieManagerSetPersistentStorage ::
    (B.CallStack.HasCallStack, MonadIO m, IsCookieManager a) =>
    a
    {- ^ /@cookieManager@/: a 'GI.WebKit2.Objects.CookieManager.CookieManager' -}
    -> T.Text
    {- ^ /@filename@/: the filename to read to\/write from -}
    -> WebKit2.Enums.CookiePersistentStorage
    {- ^ /@storage@/: a 'GI.WebKit2.Enums.CookiePersistentStorage' -}
    -> m ()
cookieManagerSetPersistentStorage cookieManager filename storage = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    filename' <- textToCString filename
    let storage' = (fromIntegral . fromEnum) storage
    webkit_cookie_manager_set_persistent_storage cookieManager' filename' storage'
    touchManagedPtr cookieManager
    freeMem filename'
    return ()

#if ENABLE_OVERLOADING
data CookieManagerSetPersistentStorageMethodInfo
instance (signature ~ (T.Text -> WebKit2.Enums.CookiePersistentStorage -> m ()), MonadIO m, IsCookieManager a) => O.MethodInfo CookieManagerSetPersistentStorageMethodInfo a signature where
    overloadedMethod _ = cookieManagerSetPersistentStorage

#endif