{- |
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(..)                       ,
    CookieManagerK                          ,
    toCookieManager                         ,
    noCookieManager                         ,


 -- * Methods
-- ** cookieManagerDeleteAllCookies
    cookieManagerDeleteAllCookies           ,


-- ** cookieManagerDeleteCookiesForDomain
    cookieManagerDeleteCookiesForDomain     ,


-- ** cookieManagerGetAcceptPolicy
    cookieManagerGetAcceptPolicy            ,


-- ** cookieManagerGetAcceptPolicyFinish
    cookieManagerGetAcceptPolicyFinish      ,


-- ** cookieManagerGetDomainsWithCookies
    cookieManagerGetDomainsWithCookies      ,


-- ** cookieManagerGetDomainsWithCookiesFinish
    cookieManagerGetDomainsWithCookiesFinish,


-- ** cookieManagerSetAcceptPolicy
    cookieManagerSetAcceptPolicy            ,


-- ** cookieManagerSetPersistentStorage
    cookieManagerSetPersistentStorage       ,




 -- * Signals
-- ** Changed
    CookieManagerChangedCallback            ,
    CookieManagerChangedCallbackC           ,
    CookieManagerChangedSignalInfo          ,
    afterCookieManagerChanged               ,
    cookieManagerChangedCallbackWrapper     ,
    cookieManagerChangedClosure             ,
    mkCookieManagerChangedCallback          ,
    noCookieManagerChangedCallback          ,
    onCookieManagerChanged                  ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.WebKit2.Types
import GI.WebKit2.Callbacks
import qualified GI.GObject as GObject
import qualified GI.Gio as Gio

newtype CookieManager = CookieManager (ForeignPtr CookieManager)
foreign import ccall "webkit_cookie_manager_get_type"
    c_webkit_cookie_manager_get_type :: IO GType

type instance ParentTypes CookieManager = CookieManagerParentTypes
type CookieManagerParentTypes = '[GObject.Object]

instance GObject CookieManager where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_cookie_manager_get_type
    

class GObject o => CookieManagerK o
instance (GObject o, IsDescendantOf CookieManager o) => CookieManagerK o

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

noCookieManager :: Maybe CookieManager
noCookieManager = Nothing

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

noCookieManagerChangedCallback :: Maybe CookieManagerChangedCallback
noCookieManagerChangedCallback = Nothing

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

foreign import ccall "wrapper"
    mkCookieManagerChangedCallback :: CookieManagerChangedCallbackC -> IO (FunPtr CookieManagerChangedCallbackC)

cookieManagerChangedClosure :: CookieManagerChangedCallback -> IO Closure
cookieManagerChangedClosure cb = newCClosure =<< mkCookieManagerChangedCallback wrapped
    where wrapped = cookieManagerChangedCallbackWrapper cb

cookieManagerChangedCallbackWrapper ::
    CookieManagerChangedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
cookieManagerChangedCallbackWrapper _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
    cb' <- mkCookieManagerChangedCallback (cookieManagerChangedCallbackWrapper cb)
    connectSignalFunPtr obj "changed" cb' after

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

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

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

-- method CookieManager::delete_all_cookies
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "webkit_cookie_manager_delete_all_cookies" webkit_cookie_manager_delete_all_cookies :: 
    Ptr CookieManager ->                    -- _obj : TInterface "WebKit2" "CookieManager"
    IO ()


cookieManagerDeleteAllCookies ::
    (MonadIO m, CookieManagerK a) =>
    a ->                                    -- _obj
    m ()
cookieManagerDeleteAllCookies _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    webkit_cookie_manager_delete_all_cookies _obj'
    touchManagedPtr _obj
    return ()

-- method CookieManager::delete_cookies_for_domain
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "webkit_cookie_manager_delete_cookies_for_domain" webkit_cookie_manager_delete_cookies_for_domain :: 
    Ptr CookieManager ->                    -- _obj : TInterface "WebKit2" "CookieManager"
    CString ->                              -- domain : TBasicType TUTF8
    IO ()


cookieManagerDeleteCookiesForDomain ::
    (MonadIO m, CookieManagerK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- domain
    m ()
cookieManagerDeleteCookiesForDomain _obj domain = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    domain' <- textToCString domain
    webkit_cookie_manager_delete_cookies_for_domain _obj' domain'
    touchManagedPtr _obj
    freeMem domain'
    return ()

-- method CookieManager::get_accept_policy
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "webkit_cookie_manager_get_accept_policy" webkit_cookie_manager_get_accept_policy :: 
    Ptr CookieManager ->                    -- _obj : TInterface "WebKit2" "CookieManager"
    Ptr Gio.Cancellable ->                  -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr Gio.AsyncReadyCallbackC ->       -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


cookieManagerGetAcceptPolicy ::
    (MonadIO m, CookieManagerK a, Gio.CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- cancellable
    Maybe (Gio.AsyncReadyCallback) ->       -- callback
    m ()
cookieManagerGetAcceptPolicy _obj cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.mkAsyncReadyCallback (Gio.asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    webkit_cookie_manager_get_accept_policy _obj' maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust cancellable touchManagedPtr
    return ()

-- method CookieManager::get_accept_policy_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit2" "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 ->                    -- _obj : TInterface "WebKit2" "CookieManager"
    Ptr Gio.AsyncResult ->                  -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO CUInt


cookieManagerGetAcceptPolicyFinish ::
    (MonadIO m, CookieManagerK a, Gio.AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m CookieAcceptPolicy
cookieManagerGetAcceptPolicyFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ webkit_cookie_manager_get_accept_policy_finish _obj' result_'
        let result' = (toEnum . fromIntegral) result
        touchManagedPtr _obj
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )

-- method CookieManager::get_domains_with_cookies
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "webkit_cookie_manager_get_domains_with_cookies" webkit_cookie_manager_get_domains_with_cookies :: 
    Ptr CookieManager ->                    -- _obj : TInterface "WebKit2" "CookieManager"
    Ptr Gio.Cancellable ->                  -- cancellable : TInterface "Gio" "Cancellable"
    FunPtr Gio.AsyncReadyCallbackC ->       -- callback : TInterface "Gio" "AsyncReadyCallback"
    Ptr () ->                               -- user_data : TBasicType TVoid
    IO ()


cookieManagerGetDomainsWithCookies ::
    (MonadIO m, CookieManagerK a, Gio.CancellableK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- cancellable
    Maybe (Gio.AsyncReadyCallback) ->       -- callback
    m ()
cookieManagerGetDomainsWithCookies _obj cancellable callback = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            let jCancellable' = unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.AsyncReadyCallbackC))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.mkAsyncReadyCallback (Gio.asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
            poke ptrcallback jCallback'
            return jCallback'
    let user_data = nullPtr
    webkit_cookie_manager_get_domains_with_cookies _obj' maybeCancellable maybeCallback user_data
    touchManagedPtr _obj
    whenJust cancellable touchManagedPtr
    return ()

-- method CookieManager::get_domains_with_cookies_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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 ->                    -- _obj : TInterface "WebKit2" "CookieManager"
    Ptr Gio.AsyncResult ->                  -- result : TInterface "Gio" "AsyncResult"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr CString)


cookieManagerGetDomainsWithCookiesFinish ::
    (MonadIO m, CookieManagerK a, Gio.AsyncResultK b) =>
    a ->                                    -- _obj
    b ->                                    -- result
    m [T.Text]
cookieManagerGetDomainsWithCookiesFinish _obj result_ = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let result_' = unsafeManagedPtrCastPtr result_
    onException (do
        result <- propagateGError $ webkit_cookie_manager_get_domains_with_cookies_finish _obj' result_'
        checkUnexpectedReturnNULL "webkit_cookie_manager_get_domains_with_cookies_finish" result
        result' <- unpackZeroTerminatedUTF8CArray result
        mapZeroTerminatedCArray freeMem result
        freeMem result
        touchManagedPtr _obj
        touchManagedPtr result_
        return result'
     ) (do
        return ()
     )

-- method CookieManager::set_accept_policy
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "policy", argType = TInterface "WebKit2" "CookieAcceptPolicy", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "policy", argType = TInterface "WebKit2" "CookieAcceptPolicy", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "webkit_cookie_manager_set_accept_policy" webkit_cookie_manager_set_accept_policy :: 
    Ptr CookieManager ->                    -- _obj : TInterface "WebKit2" "CookieManager"
    CUInt ->                                -- policy : TInterface "WebKit2" "CookieAcceptPolicy"
    IO ()


cookieManagerSetAcceptPolicy ::
    (MonadIO m, CookieManagerK a) =>
    a ->                                    -- _obj
    CookieAcceptPolicy ->                   -- policy
    m ()
cookieManagerSetAcceptPolicy _obj policy = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let policy' = (fromIntegral . fromEnum) policy
    webkit_cookie_manager_set_accept_policy _obj' policy'
    touchManagedPtr _obj
    return ()

-- method CookieManager::set_persistent_storage
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "filename", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "storage", argType = TInterface "WebKit2" "CookiePersistentStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2" "CookieManager", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "filename", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "storage", argType = TInterface "WebKit2" "CookiePersistentStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "webkit_cookie_manager_set_persistent_storage" webkit_cookie_manager_set_persistent_storage :: 
    Ptr CookieManager ->                    -- _obj : TInterface "WebKit2" "CookieManager"
    CString ->                              -- filename : TBasicType TUTF8
    CUInt ->                                -- storage : TInterface "WebKit2" "CookiePersistentStorage"
    IO ()


cookieManagerSetPersistentStorage ::
    (MonadIO m, CookieManagerK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- filename
    CookiePersistentStorage ->              -- storage
    m ()
cookieManagerSetPersistentStorage _obj filename storage = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    filename' <- textToCString filename
    let storage' = (fromIntegral . fromEnum) storage
    webkit_cookie_manager_set_persistent_storage _obj' filename' storage'
    touchManagedPtr _obj
    freeMem filename'
    return ()