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

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


 -- * Methods
-- ** addCookie #method:addCookie#

#if ENABLE_OVERLOADING
    CookieManagerAddCookieMethodInfo        ,
#endif
    cookieManagerAddCookie                  ,


-- ** addCookieFinish #method:addCookieFinish#

#if ENABLE_OVERLOADING
    CookieManagerAddCookieFinishMethodInfo  ,
#endif
    cookieManagerAddCookieFinish            ,


-- ** deleteAllCookies #method:deleteAllCookies#

#if ENABLE_OVERLOADING
    CookieManagerDeleteAllCookiesMethodInfo ,
#endif
    cookieManagerDeleteAllCookies           ,


-- ** deleteCookie #method:deleteCookie#

#if ENABLE_OVERLOADING
    CookieManagerDeleteCookieMethodInfo     ,
#endif
    cookieManagerDeleteCookie               ,


-- ** deleteCookieFinish #method:deleteCookieFinish#

#if ENABLE_OVERLOADING
    CookieManagerDeleteCookieFinishMethodInfo,
#endif
    cookieManagerDeleteCookieFinish         ,


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


-- ** getCookies #method:getCookies#

#if ENABLE_OVERLOADING
    CookieManagerGetCookiesMethodInfo       ,
#endif
    cookieManagerGetCookies                 ,


-- ** getCookiesFinish #method:getCookiesFinish#

#if ENABLE_OVERLOADING
    CookieManagerGetCookiesFinishMethodInfo ,
#endif
    cookieManagerGetCookiesFinish           ,


-- ** 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.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.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Soup.Structs.Cookie as Soup.Cookie
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, O.IsDescendantOf CookieManager o) => IsCookieManager o
instance (GObject o, O.IsDescendantOf CookieManager o) => IsCookieManager o

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

-- | 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 "addCookie" o = CookieManagerAddCookieMethodInfo
    ResolveCookieManagerMethod "addCookieFinish" o = CookieManagerAddCookieFinishMethodInfo
    ResolveCookieManagerMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveCookieManagerMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveCookieManagerMethod "deleteAllCookies" o = CookieManagerDeleteAllCookiesMethodInfo
    ResolveCookieManagerMethod "deleteCookie" o = CookieManagerDeleteCookieMethodInfo
    ResolveCookieManagerMethod "deleteCookieFinish" o = CookieManagerDeleteCookieFinishMethodInfo
    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 "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 "getCookies" o = CookieManagerGetCookiesMethodInfo
    ResolveCookieManagerMethod "getCookiesFinish" o = CookieManagerGetCookiesFinishMethodInfo
    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) => OL.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

-- 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 `GClosure`.
genClosure_CookieManagerChanged :: MonadIO m => CookieManagerChangedCallback -> m (GClosure C_CookieManagerChangedCallback)
genClosure_CookieManagerChanged cb = liftIO $ do
    let cb' = wrap_CookieManagerChangedCallback cb
    mk_CookieManagerChangedCallback cb' >>= B.GClosure.newGClosure


-- | 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::add_cookie
-- 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 = "cookie", argType = TInterface (Name {namespace = "Soup", name = "Cookie"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupCookie to be added", 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 = 4, 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_add_cookie" webkit_cookie_manager_add_cookie ::
    Ptr CookieManager ->                    -- cookie_manager : TInterface (Name {namespace = "WebKit2", name = "CookieManager"})
    Ptr Soup.Cookie.Cookie ->               -- cookie : TInterface (Name {namespace = "Soup", name = "Cookie"})
    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 add a 'GI.Soup.Structs.Cookie.Cookie' to the underlying storage.

When the operation is finished, /@callback@/ will be called. You can then call
'GI.WebKit2.Objects.CookieManager.cookieManagerAddCookieFinish' to get the result of the operation.

/Since: 2.20/
-}
cookieManagerAddCookie ::
    (B.CallStack.HasCallStack, MonadIO m, IsCookieManager a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@cookieManager@/: a 'GI.WebKit2.Objects.CookieManager.CookieManager' -}
    -> Soup.Cookie.Cookie
    {- ^ /@cookie@/: the 'GI.Soup.Structs.Cookie.Cookie' to be added -}
    -> 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 ()
cookieManagerAddCookie cookieManager cookie cancellable callback = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    cookie' <- unsafeManagedPtrGetPtr cookie
    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_cookie_manager_add_cookie cookieManager' cookie' maybeCancellable maybeCallback userData
    touchManagedPtr cookieManager
    touchManagedPtr cookie
    whenJust cancellable touchManagedPtr
    return ()

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

#endif

-- method CookieManager::add_cookie_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 (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "webkit_cookie_manager_add_cookie_finish" webkit_cookie_manager_add_cookie_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 CInt

{- |
Finish an asynchronous operation started with 'GI.WebKit2.Objects.CookieManager.cookieManagerAddCookie'.

/Since: 2.20/
-}
cookieManagerAddCookieFinish ::
    (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 ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
cookieManagerAddCookieFinish cookieManager result_ = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ webkit_cookie_manager_add_cookie_finish cookieManager' result_'
        touchManagedPtr cookieManager
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data CookieManagerAddCookieFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsCookieManager a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo CookieManagerAddCookieFinishMethodInfo a signature where
    overloadedMethod _ = cookieManagerAddCookieFinish

#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_cookie
-- 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 = "cookie", argType = TInterface (Name {namespace = "Soup", name = "Cookie"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupCookie to be deleted", 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 = 4, 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_delete_cookie" webkit_cookie_manager_delete_cookie ::
    Ptr CookieManager ->                    -- cookie_manager : TInterface (Name {namespace = "WebKit2", name = "CookieManager"})
    Ptr Soup.Cookie.Cookie ->               -- cookie : TInterface (Name {namespace = "Soup", name = "Cookie"})
    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 delete a 'GI.Soup.Structs.Cookie.Cookie' from the current session.

When the operation is finished, /@callback@/ will be called. You can then call
'GI.WebKit2.Objects.CookieManager.cookieManagerDeleteCookieFinish' to get the result of the operation.

/Since: 2.20/
-}
cookieManagerDeleteCookie ::
    (B.CallStack.HasCallStack, MonadIO m, IsCookieManager a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@cookieManager@/: a 'GI.WebKit2.Objects.CookieManager.CookieManager' -}
    -> Soup.Cookie.Cookie
    {- ^ /@cookie@/: the 'GI.Soup.Structs.Cookie.Cookie' to be deleted -}
    -> 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 ()
cookieManagerDeleteCookie cookieManager cookie cancellable callback = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    cookie' <- unsafeManagedPtrGetPtr cookie
    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_cookie_manager_delete_cookie cookieManager' cookie' maybeCancellable maybeCallback userData
    touchManagedPtr cookieManager
    touchManagedPtr cookie
    whenJust cancellable touchManagedPtr
    return ()

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

#endif

-- method CookieManager::delete_cookie_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 (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "webkit_cookie_manager_delete_cookie_finish" webkit_cookie_manager_delete_cookie_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 CInt

{- |
Finish an asynchronous operation started with 'GI.WebKit2.Objects.CookieManager.cookieManagerDeleteCookie'.

/Since: 2.20/
-}
cookieManagerDeleteCookieFinish ::
    (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 ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
cookieManagerDeleteCookieFinish cookieManager result_ = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ webkit_cookie_manager_delete_cookie_finish cookieManager' result_'
        touchManagedPtr cookieManager
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data CookieManagerDeleteCookieFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsCookieManager a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo CookieManagerDeleteCookieFinishMethodInfo a signature where
    overloadedMethod _ = cookieManagerDeleteCookieFinish

#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'
    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_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_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 = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the URI associated to the cookies to be retrieved", 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 = 4, 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_cookies" webkit_cookie_manager_get_cookies ::
    Ptr CookieManager ->                    -- cookie_manager : TInterface (Name {namespace = "WebKit2", name = "CookieManager"})
    CString ->                              -- uri : TBasicType TUTF8
    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 a list of 'GI.Soup.Structs.Cookie.Cookie' from /@cookieManager@/ associated with /@uri@/, which
must be either an HTTP or an HTTPS URL.

When the operation is finished, /@callback@/ will be called. You can then call
'GI.WebKit2.Objects.CookieManager.cookieManagerGetCookiesFinish' to get the result of the operation.

/Since: 2.20/
-}
cookieManagerGetCookies ::
    (B.CallStack.HasCallStack, MonadIO m, IsCookieManager a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@cookieManager@/: a 'GI.WebKit2.Objects.CookieManager.CookieManager' -}
    -> T.Text
    {- ^ /@uri@/: the URI associated to the cookies to be retrieved -}
    -> 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 ()
cookieManagerGetCookies cookieManager uri cancellable callback = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    uri' <- textToCString uri
    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_cookie_manager_get_cookies cookieManager' uri' maybeCancellable maybeCallback userData
    touchManagedPtr cookieManager
    whenJust cancellable touchManagedPtr
    freeMem uri'
    return ()

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

#endif

-- method CookieManager::get_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 (TGList (TInterface (Name {namespace = "Soup", name = "Cookie"})))
-- throws : True
-- Skip return : False

foreign import ccall "webkit_cookie_manager_get_cookies_finish" webkit_cookie_manager_get_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 (GList (Ptr Soup.Cookie.Cookie)))

{- |
Finish an asynchronous operation started with 'GI.WebKit2.Objects.CookieManager.cookieManagerGetCookies'.
The return value is a 'GI.GLib.Structs.SList.SList' of 'GI.Soup.Structs.Cookie.Cookie' instances which should be released
with @/g_list_free_full()/@ and 'GI.Soup.Structs.Cookie.cookieFree'.

/Since: 2.20/
-}
cookieManagerGetCookiesFinish ::
    (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 [Soup.Cookie.Cookie]
    {- ^ __Returns:__ A 'GI.GLib.Structs.List.List' of 'GI.Soup.Structs.Cookie.Cookie' instances. /(Can throw 'Data.GI.Base.GError.GError')/ -}
cookieManagerGetCookiesFinish cookieManager result_ = liftIO $ do
    cookieManager' <- unsafeManagedPtrCastPtr cookieManager
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ webkit_cookie_manager_get_cookies_finish cookieManager' result_'
        result' <- unpackGList result
        result'' <- mapM (wrapBoxed Soup.Cookie.Cookie) result'
        g_list_free result
        touchManagedPtr cookieManager
        touchManagedPtr result_
        return result''
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data CookieManagerGetCookiesFinishMethodInfo
instance (signature ~ (b -> m [Soup.Cookie.Cookie]), MonadIO m, IsCookieManager a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo CookieManagerGetCookiesFinishMethodInfo a signature where
    overloadedMethod _ = cookieManagerGetCookiesFinish

#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'
    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_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