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

module GI.WebKit2.Objects.CookieManager
    ( 

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


 -- * Methods
-- ** deleteAllCookies #method:deleteAllCookies#
    CookieManagerDeleteAllCookiesMethodInfo ,
    cookieManagerDeleteAllCookies           ,


-- ** deleteCookiesForDomain #method:deleteCookiesForDomain#
    CookieManagerDeleteCookiesForDomainMethodInfo,
    cookieManagerDeleteCookiesForDomain     ,


-- ** getAcceptPolicy #method:getAcceptPolicy#
    CookieManagerGetAcceptPolicyMethodInfo  ,
    cookieManagerGetAcceptPolicy            ,


-- ** getAcceptPolicyFinish #method:getAcceptPolicyFinish#
    CookieManagerGetAcceptPolicyFinishMethodInfo,
    cookieManagerGetAcceptPolicyFinish      ,


-- ** getDomainsWithCookies #method:getDomainsWithCookies#
    CookieManagerGetDomainsWithCookiesMethodInfo,
    cookieManagerGetDomainsWithCookies      ,


-- ** getDomainsWithCookiesFinish #method:getDomainsWithCookiesFinish#
    CookieManagerGetDomainsWithCookiesFinishMethodInfo,
    cookieManagerGetDomainsWithCookiesFinish,


-- ** setAcceptPolicy #method:setAcceptPolicy#
    CookieManagerSetAcceptPolicyMethodInfo  ,
    cookieManagerSetAcceptPolicy            ,


-- ** setPersistentStorage #method:setPersistentStorage#
    CookieManagerSetPersistentStorageMethodInfo,
    cookieManagerSetPersistentStorage       ,




 -- * Signals
-- ** changed #signal:changed#
    C_CookieManagerChangedCallback          ,
    CookieManagerChangedCallback            ,
    CookieManagerChangedSignalInfo          ,
    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.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

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
    

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

toCookieManager :: IsCookieManager o => o -> IO CookieManager
toCookieManager = unsafeCastTo CookieManager

noCookieManager :: Maybe CookieManager
noCookieManager = Nothing

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 "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
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal CookieManager::changed
type CookieManagerChangedCallback =
    IO ()

noCookieManagerChangedCallback :: Maybe CookieManagerChangedCallback
noCookieManagerChangedCallback = Nothing

type C_CookieManagerChangedCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_CookieManagerChangedCallback :: C_CookieManagerChangedCallback -> IO (FunPtr C_CookieManagerChangedCallback)

genClosure_CookieManagerChanged :: CookieManagerChangedCallback -> IO Closure
genClosure_CookieManagerChanged cb = do
    let cb' = wrap_CookieManagerChangedCallback cb
    mk_CookieManagerChangedCallback cb' >>= newCClosure


wrap_CookieManagerChangedCallback ::
    CookieManagerChangedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
wrap_CookieManagerChangedCallback _cb _ _ = do
    _cb 


onCookieManagerChanged :: (GObject a, MonadIO m) => a -> CookieManagerChangedCallback -> m SignalHandlerId
onCookieManagerChanged obj cb = liftIO $ connectCookieManagerChanged obj cb SignalConnectBefore
afterCookieManagerChanged :: (GObject a, MonadIO m) => a -> CookieManagerChangedCallback -> m SignalHandlerId
afterCookieManagerChanged obj cb = connectCookieManagerChanged obj cb SignalConnectAfter

connectCookieManagerChanged :: (GObject a, MonadIO m) =>
                               a -> CookieManagerChangedCallback -> SignalConnectMode -> m SignalHandlerId
connectCookieManagerChanged obj cb after = liftIO $ do
    let cb' = wrap_CookieManagerChangedCallback cb
    cb'' <- mk_CookieManagerChangedCallback cb'
    connectSignalFunPtr obj "changed" cb'' after

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

data CookieManagerChangedSignalInfo
instance SignalInfo CookieManagerChangedSignalInfo where
    type HaskellCallbackType CookieManagerChangedSignalInfo = CookieManagerChangedCallback
    connectSignal _ = connectCookieManagerChanged

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

-- 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 ()

{- |
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 ()

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

-- 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 ()

{- |
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 ()

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

-- 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 ()

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

-- 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 ()
     )

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

-- 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 ()

{- |
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 ()

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

-- 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)

{- |
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 ()
     )

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

-- 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 ()

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

-- 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 persistenly, so you need to call this
method to keep cookies saved across sessions.
-}
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 ()

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