{- |
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.Soup.Objects.CookieJar
    ( 

-- * Exported types
    CookieJar(..)                           ,
    CookieJarK                              ,
    toCookieJar                             ,
    noCookieJar                             ,


 -- * Methods
-- ** cookieJarAddCookie
    cookieJarAddCookie                      ,


-- ** cookieJarAddCookieWithFirstParty
    cookieJarAddCookieWithFirstParty        ,


-- ** cookieJarAllCookies
    cookieJarAllCookies                     ,


-- ** cookieJarDeleteCookie
    cookieJarDeleteCookie                   ,


-- ** cookieJarGetAcceptPolicy
    cookieJarGetAcceptPolicy                ,


-- ** cookieJarGetCookieList
    cookieJarGetCookieList                  ,


-- ** cookieJarGetCookies
    cookieJarGetCookies                     ,


-- ** cookieJarIsPersistent
    cookieJarIsPersistent                   ,


-- ** cookieJarNew
    cookieJarNew                            ,


-- ** cookieJarSave
    cookieJarSave                           ,


-- ** cookieJarSetAcceptPolicy
    cookieJarSetAcceptPolicy                ,


-- ** cookieJarSetCookie
    cookieJarSetCookie                      ,


-- ** cookieJarSetCookieWithFirstParty
    cookieJarSetCookieWithFirstParty        ,




 -- * Properties
-- ** AcceptPolicy
    CookieJarAcceptPolicyPropertyInfo       ,
    constructCookieJarAcceptPolicy          ,
    getCookieJarAcceptPolicy                ,
    setCookieJarAcceptPolicy                ,


-- ** ReadOnly
    CookieJarReadOnlyPropertyInfo           ,
    constructCookieJarReadOnly              ,
    getCookieJarReadOnly                    ,




 -- * Signals
-- ** Changed
    CookieJarChangedCallback                ,
    CookieJarChangedCallbackC               ,
    CookieJarChangedSignalInfo              ,
    afterCookieJarChanged                   ,
    cookieJarChangedCallbackWrapper         ,
    cookieJarChangedClosure                 ,
    mkCookieJarChangedCallback              ,
    noCookieJarChangedCallback              ,
    onCookieJarChanged                      ,




    ) 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.Soup.Types
import GI.Soup.Callbacks
import qualified GI.GObject as GObject

newtype CookieJar = CookieJar (ForeignPtr CookieJar)
foreign import ccall "soup_cookie_jar_get_type"
    c_soup_cookie_jar_get_type :: IO GType

type instance ParentTypes CookieJar = CookieJarParentTypes
type CookieJarParentTypes = '[GObject.Object, SessionFeature]

instance GObject CookieJar where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_soup_cookie_jar_get_type
    

class GObject o => CookieJarK o
instance (GObject o, IsDescendantOf CookieJar o) => CookieJarK o

toCookieJar :: CookieJarK o => o -> IO CookieJar
toCookieJar = unsafeCastTo CookieJar

noCookieJar :: Maybe CookieJar
noCookieJar = Nothing

-- signal CookieJar::changed
type CookieJarChangedCallback =
    Cookie ->
    Cookie ->
    IO ()

noCookieJarChangedCallback :: Maybe CookieJarChangedCallback
noCookieJarChangedCallback = Nothing

type CookieJarChangedCallbackC =
    Ptr () ->                               -- object
    Ptr Cookie ->
    Ptr Cookie ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkCookieJarChangedCallback :: CookieJarChangedCallbackC -> IO (FunPtr CookieJarChangedCallbackC)

cookieJarChangedClosure :: CookieJarChangedCallback -> IO Closure
cookieJarChangedClosure cb = newCClosure =<< mkCookieJarChangedCallback wrapped
    where wrapped = cookieJarChangedCallbackWrapper cb

cookieJarChangedCallbackWrapper ::
    CookieJarChangedCallback ->
    Ptr () ->
    Ptr Cookie ->
    Ptr Cookie ->
    Ptr () ->
    IO ()
cookieJarChangedCallbackWrapper _cb _ old_cookie new_cookie _ = do
    old_cookie' <- (newBoxed Cookie) old_cookie
    new_cookie' <- (newBoxed Cookie) new_cookie
    _cb  old_cookie' new_cookie'

onCookieJarChanged :: (GObject a, MonadIO m) => a -> CookieJarChangedCallback -> m SignalHandlerId
onCookieJarChanged obj cb = liftIO $ connectCookieJarChanged obj cb SignalConnectBefore
afterCookieJarChanged :: (GObject a, MonadIO m) => a -> CookieJarChangedCallback -> m SignalHandlerId
afterCookieJarChanged obj cb = connectCookieJarChanged obj cb SignalConnectAfter

connectCookieJarChanged :: (GObject a, MonadIO m) =>
                           a -> CookieJarChangedCallback -> SignalConnectMode -> m SignalHandlerId
connectCookieJarChanged obj cb after = liftIO $ do
    cb' <- mkCookieJarChangedCallback (cookieJarChangedCallbackWrapper cb)
    connectSignalFunPtr obj "changed" cb' after

-- VVV Prop "accept-policy"
   -- Type: TInterface "Soup" "CookieJarAcceptPolicy"
   -- Flags: [PropertyReadable,PropertyWritable]

getCookieJarAcceptPolicy :: (MonadIO m, CookieJarK o) => o -> m CookieJarAcceptPolicy
getCookieJarAcceptPolicy obj = liftIO $ getObjectPropertyEnum obj "accept-policy"

setCookieJarAcceptPolicy :: (MonadIO m, CookieJarK o) => o -> CookieJarAcceptPolicy -> m ()
setCookieJarAcceptPolicy obj val = liftIO $ setObjectPropertyEnum obj "accept-policy" val

constructCookieJarAcceptPolicy :: CookieJarAcceptPolicy -> IO ([Char], GValue)
constructCookieJarAcceptPolicy val = constructObjectPropertyEnum "accept-policy" val

data CookieJarAcceptPolicyPropertyInfo
instance AttrInfo CookieJarAcceptPolicyPropertyInfo where
    type AttrAllowedOps CookieJarAcceptPolicyPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint CookieJarAcceptPolicyPropertyInfo = (~) CookieJarAcceptPolicy
    type AttrBaseTypeConstraint CookieJarAcceptPolicyPropertyInfo = CookieJarK
    type AttrGetType CookieJarAcceptPolicyPropertyInfo = CookieJarAcceptPolicy
    type AttrLabel CookieJarAcceptPolicyPropertyInfo = "CookieJar::accept-policy"
    attrGet _ = getCookieJarAcceptPolicy
    attrSet _ = setCookieJarAcceptPolicy
    attrConstruct _ = constructCookieJarAcceptPolicy

-- VVV Prop "read-only"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getCookieJarReadOnly :: (MonadIO m, CookieJarK o) => o -> m Bool
getCookieJarReadOnly obj = liftIO $ getObjectPropertyBool obj "read-only"

constructCookieJarReadOnly :: Bool -> IO ([Char], GValue)
constructCookieJarReadOnly val = constructObjectPropertyBool "read-only" val

data CookieJarReadOnlyPropertyInfo
instance AttrInfo CookieJarReadOnlyPropertyInfo where
    type AttrAllowedOps CookieJarReadOnlyPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint CookieJarReadOnlyPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint CookieJarReadOnlyPropertyInfo = CookieJarK
    type AttrGetType CookieJarReadOnlyPropertyInfo = Bool
    type AttrLabel CookieJarReadOnlyPropertyInfo = "CookieJar::read-only"
    attrGet _ = getCookieJarReadOnly
    attrSet _ = undefined
    attrConstruct _ = constructCookieJarReadOnly

type instance AttributeList CookieJar = CookieJarAttributeList
type CookieJarAttributeList = ('[ '("accept-policy", CookieJarAcceptPolicyPropertyInfo), '("read-only", CookieJarReadOnlyPropertyInfo)] :: [(Symbol, *)])

data CookieJarChangedSignalInfo
instance SignalInfo CookieJarChangedSignalInfo where
    type HaskellCallbackType CookieJarChangedSignalInfo = CookieJarChangedCallback
    connectSignal _ = connectCookieJarChanged

type instance SignalList CookieJar = CookieJarSignalList
type CookieJarSignalList = ('[ '("changed", CookieJarChangedSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method CookieJar::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Soup" "CookieJar"
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookie_jar_new" soup_cookie_jar_new :: 
    IO (Ptr CookieJar)


cookieJarNew ::
    (MonadIO m) =>
    m CookieJar
cookieJarNew  = liftIO $ do
    result <- soup_cookie_jar_new
    checkUnexpectedReturnNULL "soup_cookie_jar_new" result
    result' <- (wrapObject CookieJar) result
    return result'

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

foreign import ccall "soup_cookie_jar_add_cookie" soup_cookie_jar_add_cookie :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    Ptr Cookie ->                           -- cookie : TInterface "Soup" "Cookie"
    IO ()


cookieJarAddCookie ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    Cookie ->                               -- cookie
    m ()
cookieJarAddCookie _obj cookie = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    cookie' <- copyBoxed cookie
    soup_cookie_jar_add_cookie _obj' cookie'
    touchManagedPtr _obj
    touchManagedPtr cookie
    return ()

-- method CookieJar::add_cookie_with_first_party
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "first_party", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cookie", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "first_party", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cookie", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookie_jar_add_cookie_with_first_party" soup_cookie_jar_add_cookie_with_first_party :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    Ptr URI ->                              -- first_party : TInterface "Soup" "URI"
    Ptr Cookie ->                           -- cookie : TInterface "Soup" "Cookie"
    IO ()


cookieJarAddCookieWithFirstParty ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    URI ->                                  -- first_party
    Cookie ->                               -- cookie
    m ()
cookieJarAddCookieWithFirstParty _obj first_party cookie = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let first_party' = unsafeManagedPtrGetPtr first_party
    cookie' <- copyBoxed cookie
    soup_cookie_jar_add_cookie_with_first_party _obj' first_party' cookie'
    touchManagedPtr _obj
    touchManagedPtr first_party
    touchManagedPtr cookie
    return ()

-- method CookieJar::all_cookies
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGSList (TInterface "Soup" "Cookie")
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookie_jar_all_cookies" soup_cookie_jar_all_cookies :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    IO (Ptr (GSList (Ptr Cookie)))


cookieJarAllCookies ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    m [Cookie]
cookieJarAllCookies _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- soup_cookie_jar_all_cookies _obj'
    checkUnexpectedReturnNULL "soup_cookie_jar_all_cookies" result
    result' <- unpackGSList result
    result'' <- mapM (wrapBoxed Cookie) result'
    g_slist_free result
    touchManagedPtr _obj
    return result''

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

foreign import ccall "soup_cookie_jar_delete_cookie" soup_cookie_jar_delete_cookie :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    Ptr Cookie ->                           -- cookie : TInterface "Soup" "Cookie"
    IO ()


cookieJarDeleteCookie ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    Cookie ->                               -- cookie
    m ()
cookieJarDeleteCookie _obj cookie = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let cookie' = unsafeManagedPtrGetPtr cookie
    soup_cookie_jar_delete_cookie _obj' cookie'
    touchManagedPtr _obj
    touchManagedPtr cookie
    return ()

-- method CookieJar::get_accept_policy
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Soup" "CookieJarAcceptPolicy"
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookie_jar_get_accept_policy" soup_cookie_jar_get_accept_policy :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    IO CUInt


cookieJarGetAcceptPolicy ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    m CookieJarAcceptPolicy
cookieJarGetAcceptPolicy _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- soup_cookie_jar_get_accept_policy _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method CookieJar::get_cookie_list
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "for_http", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "for_http", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGSList (TInterface "Soup" "Cookie")
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookie_jar_get_cookie_list" soup_cookie_jar_get_cookie_list :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    Ptr URI ->                              -- uri : TInterface "Soup" "URI"
    CInt ->                                 -- for_http : TBasicType TBoolean
    IO (Ptr (GSList (Ptr Cookie)))


cookieJarGetCookieList ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    URI ->                                  -- uri
    Bool ->                                 -- for_http
    m [Cookie]
cookieJarGetCookieList _obj uri for_http = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let uri' = unsafeManagedPtrGetPtr uri
    let for_http' = (fromIntegral . fromEnum) for_http
    result <- soup_cookie_jar_get_cookie_list _obj' uri' for_http'
    checkUnexpectedReturnNULL "soup_cookie_jar_get_cookie_list" result
    result' <- unpackGSList result
    result'' <- mapM (wrapBoxed Cookie) result'
    g_slist_free result
    touchManagedPtr _obj
    touchManagedPtr uri
    return result''

-- method CookieJar::get_cookies
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "for_http", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "for_http", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookie_jar_get_cookies" soup_cookie_jar_get_cookies :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    Ptr URI ->                              -- uri : TInterface "Soup" "URI"
    CInt ->                                 -- for_http : TBasicType TBoolean
    IO CString


cookieJarGetCookies ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    URI ->                                  -- uri
    Bool ->                                 -- for_http
    m T.Text
cookieJarGetCookies _obj uri for_http = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let uri' = unsafeManagedPtrGetPtr uri
    let for_http' = (fromIntegral . fromEnum) for_http
    result <- soup_cookie_jar_get_cookies _obj' uri' for_http'
    checkUnexpectedReturnNULL "soup_cookie_jar_get_cookies" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    touchManagedPtr uri
    return result'

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

foreign import ccall "soup_cookie_jar_is_persistent" soup_cookie_jar_is_persistent :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    IO CInt


cookieJarIsPersistent ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    m Bool
cookieJarIsPersistent _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- soup_cookie_jar_is_persistent _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "soup_cookie_jar_save" soup_cookie_jar_save :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    IO ()

{-# DEPRECATED cookieJarSave ["This is a no-op."]#-}
cookieJarSave ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    m ()
cookieJarSave _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    soup_cookie_jar_save _obj'
    touchManagedPtr _obj
    return ()

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

foreign import ccall "soup_cookie_jar_set_accept_policy" soup_cookie_jar_set_accept_policy :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    CUInt ->                                -- policy : TInterface "Soup" "CookieJarAcceptPolicy"
    IO ()


cookieJarSetAcceptPolicy ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    CookieJarAcceptPolicy ->                -- policy
    m ()
cookieJarSetAcceptPolicy _obj policy = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let policy' = (fromIntegral . fromEnum) policy
    soup_cookie_jar_set_accept_policy _obj' policy'
    touchManagedPtr _obj
    return ()

-- method CookieJar::set_cookie
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cookie", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cookie", 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 "soup_cookie_jar_set_cookie" soup_cookie_jar_set_cookie :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    Ptr URI ->                              -- uri : TInterface "Soup" "URI"
    CString ->                              -- cookie : TBasicType TUTF8
    IO ()


cookieJarSetCookie ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    URI ->                                  -- uri
    T.Text ->                               -- cookie
    m ()
cookieJarSetCookie _obj uri cookie = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let uri' = unsafeManagedPtrGetPtr uri
    cookie' <- textToCString cookie
    soup_cookie_jar_set_cookie _obj' uri' cookie'
    touchManagedPtr _obj
    touchManagedPtr uri
    freeMem cookie'
    return ()

-- method CookieJar::set_cookie_with_first_party
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "first_party", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cookie", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "CookieJar", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "first_party", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cookie", 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 "soup_cookie_jar_set_cookie_with_first_party" soup_cookie_jar_set_cookie_with_first_party :: 
    Ptr CookieJar ->                        -- _obj : TInterface "Soup" "CookieJar"
    Ptr URI ->                              -- uri : TInterface "Soup" "URI"
    Ptr URI ->                              -- first_party : TInterface "Soup" "URI"
    CString ->                              -- cookie : TBasicType TUTF8
    IO ()


cookieJarSetCookieWithFirstParty ::
    (MonadIO m, CookieJarK a) =>
    a ->                                    -- _obj
    URI ->                                  -- uri
    URI ->                                  -- first_party
    T.Text ->                               -- cookie
    m ()
cookieJarSetCookieWithFirstParty _obj uri first_party cookie = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let uri' = unsafeManagedPtrGetPtr uri
    let first_party' = unsafeManagedPtrGetPtr first_party
    cookie' <- textToCString cookie
    soup_cookie_jar_set_cookie_with_first_party _obj' uri' first_party' cookie'
    touchManagedPtr _obj
    touchManagedPtr uri
    touchManagedPtr first_party
    freeMem cookie'
    return ()