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

An HTTP cookie.

@name and @value will be set for all cookies. If the cookie is
generated from a string that appears to have no name, then @name
will be the empty string.

@domain and @path give the host or domain, and path within that
host/domain, to restrict this cookie to. If @domain starts with
".", that indicates a domain (which matches the string after the
".", or any hostname that has @domain as a suffix). Otherwise, it
is a hostname and must match exactly.

@expires will be non-%NULL if the cookie uses either the original
"expires" attribute, or the newer "max-age" attribute. If @expires
is %NULL, it indicates that neither "expires" nor "max-age" was
specified, and the cookie expires at the end of the session.

If @http_only is set, the cookie should not be exposed to untrusted
code (eg, javascript), so as to minimize the danger posed by
cross-site scripting attacks.
-}

module GI.Soup.Structs.Cookie
    ( 

-- * Exported types
    Cookie(..)                              ,
    noCookie                                ,


 -- * Methods
-- ** cookieAppliesToUri
    cookieAppliesToUri                      ,


-- ** cookieCopy
    cookieCopy                              ,


-- ** cookieDomainMatches
    cookieDomainMatches                     ,


-- ** cookieEqual
    cookieEqual                             ,


-- ** cookieFree
    cookieFree                              ,


-- ** cookieGetDomain
    cookieGetDomain                         ,


-- ** cookieGetExpires
    cookieGetExpires                        ,


-- ** cookieGetHttpOnly
    cookieGetHttpOnly                       ,


-- ** cookieGetName
    cookieGetName                           ,


-- ** cookieGetPath
    cookieGetPath                           ,


-- ** cookieGetSecure
    cookieGetSecure                         ,


-- ** cookieGetValue
    cookieGetValue                          ,


-- ** cookieNew
    cookieNew                               ,


-- ** cookieSetDomain
    cookieSetDomain                         ,


-- ** cookieSetExpires
    cookieSetExpires                        ,


-- ** cookieSetHttpOnly
    cookieSetHttpOnly                       ,


-- ** cookieSetMaxAge
    cookieSetMaxAge                         ,


-- ** cookieSetName
    cookieSetName                           ,


-- ** cookieSetPath
    cookieSetPath                           ,


-- ** cookieSetSecure
    cookieSetSecure                         ,


-- ** cookieSetValue
    cookieSetValue                          ,


-- ** cookieToCookieHeader
    cookieToCookieHeader                    ,


-- ** cookieToSetCookieHeader
    cookieToSetCookieHeader                 ,




 -- * Properties
-- ** Domain
    cookieReadDomain                        ,


-- ** Expires
    cookieReadExpires                       ,


-- ** HttpOnly
    cookieReadHttpOnly                      ,


-- ** Name
    cookieReadName                          ,


-- ** Path
    cookieReadPath                          ,


-- ** Secure
    cookieReadSecure                        ,


-- ** Value
    cookieReadValue                         ,




    ) 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

newtype Cookie = Cookie (ForeignPtr Cookie)
foreign import ccall "soup_cookie_get_type" c_soup_cookie_get_type :: 
    IO GType

instance BoxedObject Cookie where
    boxedType _ = c_soup_cookie_get_type

noCookie :: Maybe Cookie
noCookie = Nothing

cookieReadName :: Cookie -> IO T.Text
cookieReadName s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO CString
    val' <- cstringToText val
    return val'

cookieReadValue :: Cookie -> IO T.Text
cookieReadValue s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO CString
    val' <- cstringToText val
    return val'

cookieReadDomain :: Cookie -> IO T.Text
cookieReadDomain s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO CString
    val' <- cstringToText val
    return val'

cookieReadPath :: Cookie -> IO T.Text
cookieReadPath s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 24) :: IO CString
    val' <- cstringToText val
    return val'

cookieReadExpires :: Cookie -> IO Date
cookieReadExpires s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 32) :: IO (Ptr Date)
    val' <- (newBoxed Date) val
    return val'

cookieReadSecure :: Cookie -> IO Bool
cookieReadSecure s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 40) :: IO CInt
    let val' = (/= 0) val
    return val'

cookieReadHttpOnly :: Cookie -> IO Bool
cookieReadHttpOnly s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 44) :: IO CInt
    let val' = (/= 0) val
    return val'

-- method Cookie::new
-- method type : Constructor
-- Args : [Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TUTF8, 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},Arg {argName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "max_age", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TUTF8, 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},Arg {argName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "max_age", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Soup" "Cookie"
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookie_new" soup_cookie_new :: 
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    CString ->                              -- domain : TBasicType TUTF8
    CString ->                              -- path : TBasicType TUTF8
    Int32 ->                                -- max_age : TBasicType TInt32
    IO (Ptr Cookie)


cookieNew ::
    (MonadIO m) =>
    T.Text ->                               -- name
    T.Text ->                               -- value
    T.Text ->                               -- domain
    T.Text ->                               -- path
    Int32 ->                                -- max_age
    m Cookie
cookieNew name value domain path max_age = liftIO $ do
    name' <- textToCString name
    value' <- textToCString value
    domain' <- textToCString domain
    path' <- textToCString path
    result <- soup_cookie_new name' value' domain' path' max_age
    checkUnexpectedReturnNULL "soup_cookie_new" result
    result' <- (wrapBoxed Cookie) result
    freeMem name'
    freeMem value'
    freeMem domain'
    freeMem path'
    return result'

-- method Cookie::applies_to_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", 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}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", 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}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookie_applies_to_uri" soup_cookie_applies_to_uri :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    Ptr URI ->                              -- uri : TInterface "Soup" "URI"
    IO CInt


cookieAppliesToUri ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    URI ->                                  -- uri
    m Bool
cookieAppliesToUri _obj uri = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let uri' = unsafeManagedPtrGetPtr uri
    result <- soup_cookie_applies_to_uri _obj' uri'
    let result' = (/= 0) result
    touchManagedPtr _obj
    touchManagedPtr uri
    return result'

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

foreign import ccall "soup_cookie_copy" soup_cookie_copy :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    IO (Ptr Cookie)


cookieCopy ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    m Cookie
cookieCopy _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- soup_cookie_copy _obj'
    checkUnexpectedReturnNULL "soup_cookie_copy" result
    result' <- (wrapBoxed Cookie) result
    touchManagedPtr _obj
    return result'

-- method Cookie::domain_matches
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "host", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "host", argType = TBasicType TUTF8, 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_domain_matches" soup_cookie_domain_matches :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    CString ->                              -- host : TBasicType TUTF8
    IO CInt


cookieDomainMatches ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    T.Text ->                               -- host
    m Bool
cookieDomainMatches _obj host = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    host' <- textToCString host
    result <- soup_cookie_domain_matches _obj' host'
    let result' = (/= 0) result
    touchManagedPtr _obj
    freeMem host'
    return result'

-- method Cookie::equal
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cookie2", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cookie2", argType = TInterface "Soup" "Cookie", 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_equal" soup_cookie_equal :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    Ptr Cookie ->                           -- cookie2 : TInterface "Soup" "Cookie"
    IO CInt


cookieEqual ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    Cookie ->                               -- cookie2
    m Bool
cookieEqual _obj cookie2 = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let cookie2' = unsafeManagedPtrGetPtr cookie2
    result <- soup_cookie_equal _obj' cookie2'
    let result' = (/= 0) result
    touchManagedPtr _obj
    touchManagedPtr cookie2
    return result'

-- method Cookie::free
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", 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_free" soup_cookie_free :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    IO ()


cookieFree ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    m ()
cookieFree _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    soup_cookie_free _obj'
    touchManagedPtr _obj
    return ()

-- method Cookie::get_domain
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", 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_get_domain" soup_cookie_get_domain :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    IO CString


cookieGetDomain ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    m T.Text
cookieGetDomain _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- soup_cookie_get_domain _obj'
    checkUnexpectedReturnNULL "soup_cookie_get_domain" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "soup_cookie_get_expires" soup_cookie_get_expires :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    IO (Ptr Date)


cookieGetExpires ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    m Date
cookieGetExpires _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- soup_cookie_get_expires _obj'
    checkUnexpectedReturnNULL "soup_cookie_get_expires" result
    result' <- (newBoxed Date) result
    touchManagedPtr _obj
    return result'

-- method Cookie::get_http_only
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", 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_get_http_only" soup_cookie_get_http_only :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    IO CInt


cookieGetHttpOnly ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    m Bool
cookieGetHttpOnly _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- soup_cookie_get_http_only _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Cookie::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", 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_get_name" soup_cookie_get_name :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    IO CString


cookieGetName ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    m T.Text
cookieGetName _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- soup_cookie_get_name _obj'
    checkUnexpectedReturnNULL "soup_cookie_get_name" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method Cookie::get_path
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", 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_get_path" soup_cookie_get_path :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    IO CString


cookieGetPath ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    m T.Text
cookieGetPath _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- soup_cookie_get_path _obj'
    checkUnexpectedReturnNULL "soup_cookie_get_path" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method Cookie::get_secure
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", 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_get_secure" soup_cookie_get_secure :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    IO CInt


cookieGetSecure ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    m Bool
cookieGetSecure _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- soup_cookie_get_secure _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Cookie::get_value
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", 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_get_value" soup_cookie_get_value :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    IO CString


cookieGetValue ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    m T.Text
cookieGetValue _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- soup_cookie_get_value _obj'
    checkUnexpectedReturnNULL "soup_cookie_get_value" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method Cookie::set_domain
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", 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 "Soup" "Cookie", 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 "soup_cookie_set_domain" soup_cookie_set_domain :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    CString ->                              -- domain : TBasicType TUTF8
    IO ()


cookieSetDomain ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    T.Text ->                               -- domain
    m ()
cookieSetDomain _obj domain = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    domain' <- textToCString domain
    soup_cookie_set_domain _obj' domain'
    touchManagedPtr _obj
    freeMem domain'
    return ()

-- method Cookie::set_expires
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "expires", argType = TInterface "Soup" "Date", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "expires", argType = TInterface "Soup" "Date", 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_set_expires" soup_cookie_set_expires :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    Ptr Date ->                             -- expires : TInterface "Soup" "Date"
    IO ()


cookieSetExpires ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    Date ->                                 -- expires
    m ()
cookieSetExpires _obj expires = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let expires' = unsafeManagedPtrGetPtr expires
    soup_cookie_set_expires _obj' expires'
    touchManagedPtr _obj
    touchManagedPtr expires
    return ()

-- method Cookie::set_http_only
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "http_only", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "http_only", argType = TBasicType TBoolean, 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_set_http_only" soup_cookie_set_http_only :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    CInt ->                                 -- http_only : TBasicType TBoolean
    IO ()


cookieSetHttpOnly ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    Bool ->                                 -- http_only
    m ()
cookieSetHttpOnly _obj http_only = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let http_only' = (fromIntegral . fromEnum) http_only
    soup_cookie_set_http_only _obj' http_only'
    touchManagedPtr _obj
    return ()

-- method Cookie::set_max_age
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "max_age", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "max_age", argType = TBasicType TInt32, 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_set_max_age" soup_cookie_set_max_age :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    Int32 ->                                -- max_age : TBasicType TInt32
    IO ()


cookieSetMaxAge ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    Int32 ->                                -- max_age
    m ()
cookieSetMaxAge _obj max_age = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    soup_cookie_set_max_age _obj' max_age
    touchManagedPtr _obj
    return ()

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


cookieSetName ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    T.Text ->                               -- name
    m ()
cookieSetName _obj name = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    name' <- textToCString name
    soup_cookie_set_name _obj' name'
    touchManagedPtr _obj
    freeMem name'
    return ()

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


cookieSetPath ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    T.Text ->                               -- path
    m ()
cookieSetPath _obj path = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    path' <- textToCString path
    soup_cookie_set_path _obj' path'
    touchManagedPtr _obj
    freeMem path'
    return ()

-- method Cookie::set_secure
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "secure", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "secure", argType = TBasicType TBoolean, 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_set_secure" soup_cookie_set_secure :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    CInt ->                                 -- secure : TBasicType TBoolean
    IO ()


cookieSetSecure ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    Bool ->                                 -- secure
    m ()
cookieSetSecure _obj secure = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let secure' = (fromIntegral . fromEnum) secure
    soup_cookie_set_secure _obj' secure'
    touchManagedPtr _obj
    return ()

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


cookieSetValue ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    T.Text ->                               -- value
    m ()
cookieSetValue _obj value = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    value' <- textToCString value
    soup_cookie_set_value _obj' value'
    touchManagedPtr _obj
    freeMem value'
    return ()

-- method Cookie::to_cookie_header
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", 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_to_cookie_header" soup_cookie_to_cookie_header :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    IO CString


cookieToCookieHeader ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    m T.Text
cookieToCookieHeader _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- soup_cookie_to_cookie_header _obj'
    checkUnexpectedReturnNULL "soup_cookie_to_cookie_header" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    return result'

-- method Cookie::to_set_cookie_header
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Cookie", 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_to_set_cookie_header" soup_cookie_to_set_cookie_header :: 
    Ptr Cookie ->                           -- _obj : TInterface "Soup" "Cookie"
    IO CString


cookieToSetCookieHeader ::
    (MonadIO m) =>
    Cookie ->                               -- _obj
    m T.Text
cookieToSetCookieHeader _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- soup_cookie_to_set_cookie_header _obj'
    checkUnexpectedReturnNULL "soup_cookie_to_set_cookie_header" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    return result'