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

-- * Exported types
    Auth(..)                                ,
    AuthK                                   ,
    toAuth                                  ,
    noAuth                                  ,


 -- * Methods
-- ** authAuthenticate
    authAuthenticate                        ,


-- ** authGetAuthorization
    authGetAuthorization                    ,


-- ** authGetHost
    authGetHost                             ,


-- ** authGetInfo
    authGetInfo                             ,


-- ** authGetProtectionSpace
    authGetProtectionSpace                  ,


-- ** authGetRealm
    authGetRealm                            ,


-- ** authGetSavedPassword
    authGetSavedPassword                    ,


-- ** authGetSavedUsers
    authGetSavedUsers                       ,


-- ** authGetSchemeName
    authGetSchemeName                       ,


-- ** authHasSavedPassword
    authHasSavedPassword                    ,


-- ** authIsAuthenticated
    authIsAuthenticated                     ,


-- ** authIsForProxy
    authIsForProxy                          ,


-- ** authIsReady
    authIsReady                             ,


-- ** authNew
    authNew                                 ,


-- ** authSavePassword
    authSavePassword                        ,


-- ** authUpdate
    authUpdate                              ,




 -- * Properties
-- ** Host
    AuthHostPropertyInfo                    ,
    constructAuthHost                       ,
    getAuthHost                             ,
    setAuthHost                             ,


-- ** IsAuthenticated
    AuthIsAuthenticatedPropertyInfo         ,
    getAuthIsAuthenticated                  ,


-- ** IsForProxy
    AuthIsForProxyPropertyInfo              ,
    constructAuthIsForProxy                 ,
    getAuthIsForProxy                       ,
    setAuthIsForProxy                       ,


-- ** Realm
    AuthRealmPropertyInfo                   ,
    constructAuthRealm                      ,
    getAuthRealm                            ,
    setAuthRealm                            ,


-- ** SchemeName
    AuthSchemeNamePropertyInfo              ,
    getAuthSchemeName                       ,




    ) 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 Auth = Auth (ForeignPtr Auth)
foreign import ccall "soup_auth_get_type"
    c_soup_auth_get_type :: IO GType

type instance ParentTypes Auth = AuthParentTypes
type AuthParentTypes = '[GObject.Object]

instance GObject Auth where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_soup_auth_get_type
    

class GObject o => AuthK o
instance (GObject o, IsDescendantOf Auth o) => AuthK o

toAuth :: AuthK o => o -> IO Auth
toAuth = unsafeCastTo Auth

noAuth :: Maybe Auth
noAuth = Nothing

-- VVV Prop "host"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]

getAuthHost :: (MonadIO m, AuthK o) => o -> m T.Text
getAuthHost obj = liftIO $ getObjectPropertyString obj "host"

setAuthHost :: (MonadIO m, AuthK o) => o -> T.Text -> m ()
setAuthHost obj val = liftIO $ setObjectPropertyString obj "host" val

constructAuthHost :: T.Text -> IO ([Char], GValue)
constructAuthHost val = constructObjectPropertyString "host" val

data AuthHostPropertyInfo
instance AttrInfo AuthHostPropertyInfo where
    type AttrAllowedOps AuthHostPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint AuthHostPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint AuthHostPropertyInfo = AuthK
    type AttrGetType AuthHostPropertyInfo = T.Text
    type AttrLabel AuthHostPropertyInfo = "Auth::host"
    attrGet _ = getAuthHost
    attrSet _ = setAuthHost
    attrConstruct _ = constructAuthHost

-- VVV Prop "is-authenticated"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable]

getAuthIsAuthenticated :: (MonadIO m, AuthK o) => o -> m Bool
getAuthIsAuthenticated obj = liftIO $ getObjectPropertyBool obj "is-authenticated"

data AuthIsAuthenticatedPropertyInfo
instance AttrInfo AuthIsAuthenticatedPropertyInfo where
    type AttrAllowedOps AuthIsAuthenticatedPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint AuthIsAuthenticatedPropertyInfo = (~) ()
    type AttrBaseTypeConstraint AuthIsAuthenticatedPropertyInfo = AuthK
    type AttrGetType AuthIsAuthenticatedPropertyInfo = Bool
    type AttrLabel AuthIsAuthenticatedPropertyInfo = "Auth::is-authenticated"
    attrGet _ = getAuthIsAuthenticated
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "is-for-proxy"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]

getAuthIsForProxy :: (MonadIO m, AuthK o) => o -> m Bool
getAuthIsForProxy obj = liftIO $ getObjectPropertyBool obj "is-for-proxy"

setAuthIsForProxy :: (MonadIO m, AuthK o) => o -> Bool -> m ()
setAuthIsForProxy obj val = liftIO $ setObjectPropertyBool obj "is-for-proxy" val

constructAuthIsForProxy :: Bool -> IO ([Char], GValue)
constructAuthIsForProxy val = constructObjectPropertyBool "is-for-proxy" val

data AuthIsForProxyPropertyInfo
instance AttrInfo AuthIsForProxyPropertyInfo where
    type AttrAllowedOps AuthIsForProxyPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint AuthIsForProxyPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint AuthIsForProxyPropertyInfo = AuthK
    type AttrGetType AuthIsForProxyPropertyInfo = Bool
    type AttrLabel AuthIsForProxyPropertyInfo = "Auth::is-for-proxy"
    attrGet _ = getAuthIsForProxy
    attrSet _ = setAuthIsForProxy
    attrConstruct _ = constructAuthIsForProxy

-- VVV Prop "realm"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]

getAuthRealm :: (MonadIO m, AuthK o) => o -> m T.Text
getAuthRealm obj = liftIO $ getObjectPropertyString obj "realm"

setAuthRealm :: (MonadIO m, AuthK o) => o -> T.Text -> m ()
setAuthRealm obj val = liftIO $ setObjectPropertyString obj "realm" val

constructAuthRealm :: T.Text -> IO ([Char], GValue)
constructAuthRealm val = constructObjectPropertyString "realm" val

data AuthRealmPropertyInfo
instance AttrInfo AuthRealmPropertyInfo where
    type AttrAllowedOps AuthRealmPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint AuthRealmPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint AuthRealmPropertyInfo = AuthK
    type AttrGetType AuthRealmPropertyInfo = T.Text
    type AttrLabel AuthRealmPropertyInfo = "Auth::realm"
    attrGet _ = getAuthRealm
    attrSet _ = setAuthRealm
    attrConstruct _ = constructAuthRealm

-- VVV Prop "scheme-name"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]

getAuthSchemeName :: (MonadIO m, AuthK o) => o -> m T.Text
getAuthSchemeName obj = liftIO $ getObjectPropertyString obj "scheme-name"

data AuthSchemeNamePropertyInfo
instance AttrInfo AuthSchemeNamePropertyInfo where
    type AttrAllowedOps AuthSchemeNamePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint AuthSchemeNamePropertyInfo = (~) ()
    type AttrBaseTypeConstraint AuthSchemeNamePropertyInfo = AuthK
    type AttrGetType AuthSchemeNamePropertyInfo = T.Text
    type AttrLabel AuthSchemeNamePropertyInfo = "Auth::scheme-name"
    attrGet _ = getAuthSchemeName
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList Auth = AuthAttributeList
type AuthAttributeList = ('[ '("host", AuthHostPropertyInfo), '("is-authenticated", AuthIsAuthenticatedPropertyInfo), '("is-for-proxy", AuthIsForProxyPropertyInfo), '("realm", AuthRealmPropertyInfo), '("scheme-name", AuthSchemeNamePropertyInfo)] :: [(Symbol, *)])

type instance SignalList Auth = AuthSignalList
type AuthSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method Auth::new
-- method type : Constructor
-- Args : [Arg {argName = "type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "auth_header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "auth_header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Soup" "Auth"
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_new" soup_auth_new :: 
    CGType ->                               -- type : TBasicType TGType
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    CString ->                              -- auth_header : TBasicType TUTF8
    IO (Ptr Auth)


authNew ::
    (MonadIO m, MessageK a) =>
    GType ->                                -- type
    a ->                                    -- msg
    T.Text ->                               -- auth_header
    m Auth
authNew type_ msg auth_header = liftIO $ do
    let type_' = gtypeToCGType type_
    let msg' = unsafeManagedPtrCastPtr msg
    auth_header' <- textToCString auth_header
    result <- soup_auth_new type_' msg' auth_header'
    checkUnexpectedReturnNULL "soup_auth_new" result
    result' <- (wrapObject Auth) result
    touchManagedPtr msg
    freeMem auth_header'
    return result'

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


authAuthenticate ::
    (MonadIO m, AuthK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- username
    T.Text ->                               -- password
    m ()
authAuthenticate _obj username password = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    username' <- textToCString username
    password' <- textToCString password
    soup_auth_authenticate _obj' username' password'
    touchManagedPtr _obj
    freeMem username'
    freeMem password'
    return ()

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

foreign import ccall "soup_auth_get_authorization" soup_auth_get_authorization :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    IO CString


authGetAuthorization ::
    (MonadIO m, AuthK a, MessageK b) =>
    a ->                                    -- _obj
    b ->                                    -- msg
    m T.Text
authGetAuthorization _obj msg = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let msg' = unsafeManagedPtrCastPtr msg
    result <- soup_auth_get_authorization _obj' msg'
    checkUnexpectedReturnNULL "soup_auth_get_authorization" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    touchManagedPtr msg
    return result'

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

foreign import ccall "soup_auth_get_host" soup_auth_get_host :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    IO CString


authGetHost ::
    (MonadIO m, AuthK a) =>
    a ->                                    -- _obj
    m T.Text
authGetHost _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- soup_auth_get_host _obj'
    checkUnexpectedReturnNULL "soup_auth_get_host" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "soup_auth_get_info" soup_auth_get_info :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    IO CString


authGetInfo ::
    (MonadIO m, AuthK a) =>
    a ->                                    -- _obj
    m T.Text
authGetInfo _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- soup_auth_get_info _obj'
    checkUnexpectedReturnNULL "soup_auth_get_info" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    return result'

-- method Auth::get_protection_space
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Auth", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_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" "Auth", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "source_uri", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGSList (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_get_protection_space" soup_auth_get_protection_space :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    Ptr URI ->                              -- source_uri : TInterface "Soup" "URI"
    IO (Ptr (GSList CString))


authGetProtectionSpace ::
    (MonadIO m, AuthK a) =>
    a ->                                    -- _obj
    URI ->                                  -- source_uri
    m [T.Text]
authGetProtectionSpace _obj source_uri = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let source_uri' = unsafeManagedPtrGetPtr source_uri
    result <- soup_auth_get_protection_space _obj' source_uri'
    checkUnexpectedReturnNULL "soup_auth_get_protection_space" result
    result' <- unpackGSList result
    result'' <- mapM cstringToText result'
    mapGSList freeMem result
    g_slist_free result
    touchManagedPtr _obj
    touchManagedPtr source_uri
    return result''

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

foreign import ccall "soup_auth_get_realm" soup_auth_get_realm :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    IO CString


authGetRealm ::
    (MonadIO m, AuthK a) =>
    a ->                                    -- _obj
    m T.Text
authGetRealm _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- soup_auth_get_realm _obj'
    checkUnexpectedReturnNULL "soup_auth_get_realm" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "soup_auth_get_saved_password" soup_auth_get_saved_password :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    CString ->                              -- user : TBasicType TUTF8
    IO CString


authGetSavedPassword ::
    (MonadIO m, AuthK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- user
    m T.Text
authGetSavedPassword _obj user = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    user' <- textToCString user
    result <- soup_auth_get_saved_password _obj' user'
    checkUnexpectedReturnNULL "soup_auth_get_saved_password" result
    result' <- cstringToText result
    touchManagedPtr _obj
    freeMem user'
    return result'

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

foreign import ccall "soup_auth_get_saved_users" soup_auth_get_saved_users :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    IO (Ptr (GSList CString))


authGetSavedUsers ::
    (MonadIO m, AuthK a) =>
    a ->                                    -- _obj
    m [T.Text]
authGetSavedUsers _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- soup_auth_get_saved_users _obj'
    checkUnexpectedReturnNULL "soup_auth_get_saved_users" result
    result' <- unpackGSList result
    result'' <- mapM cstringToText result'
    mapGSList freeMem result
    g_slist_free result
    touchManagedPtr _obj
    return result''

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

foreign import ccall "soup_auth_get_scheme_name" soup_auth_get_scheme_name :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    IO CString


authGetSchemeName ::
    (MonadIO m, AuthK a) =>
    a ->                                    -- _obj
    m T.Text
authGetSchemeName _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- soup_auth_get_scheme_name _obj'
    checkUnexpectedReturnNULL "soup_auth_get_scheme_name" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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


authHasSavedPassword ::
    (MonadIO m, AuthK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- username
    T.Text ->                               -- password
    m ()
authHasSavedPassword _obj username password = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    username' <- textToCString username
    password' <- textToCString password
    soup_auth_has_saved_password _obj' username' password'
    touchManagedPtr _obj
    freeMem username'
    freeMem password'
    return ()

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

foreign import ccall "soup_auth_is_authenticated" soup_auth_is_authenticated :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    IO CInt


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

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

foreign import ccall "soup_auth_is_for_proxy" soup_auth_is_for_proxy :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    IO CInt


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

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

foreign import ccall "soup_auth_is_ready" soup_auth_is_ready :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    IO CInt


authIsReady ::
    (MonadIO m, AuthK a, MessageK b) =>
    a ->                                    -- _obj
    b ->                                    -- msg
    m Bool
authIsReady _obj msg = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let msg' = unsafeManagedPtrCastPtr msg
    result <- soup_auth_is_ready _obj' msg'
    let result' = (/= 0) result
    touchManagedPtr _obj
    touchManagedPtr msg
    return result'

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


authSavePassword ::
    (MonadIO m, AuthK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- username
    T.Text ->                               -- password
    m ()
authSavePassword _obj username password = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    username' <- textToCString username
    password' <- textToCString password
    soup_auth_save_password _obj' username' password'
    touchManagedPtr _obj
    freeMem username'
    freeMem password'
    return ()

-- method Auth::update
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Soup" "Auth", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "auth_header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Soup" "Auth", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "auth_header", 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_auth_update" soup_auth_update :: 
    Ptr Auth ->                             -- _obj : TInterface "Soup" "Auth"
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    CString ->                              -- auth_header : TBasicType TUTF8
    IO CInt


authUpdate ::
    (MonadIO m, AuthK a, MessageK b) =>
    a ->                                    -- _obj
    b ->                                    -- msg
    T.Text ->                               -- auth_header
    m Bool
authUpdate _obj msg auth_header = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let msg' = unsafeManagedPtrCastPtr msg
    auth_header' <- textToCString auth_header
    result <- soup_auth_update _obj' msg' auth_header'
    let result' = (/= 0) result
    touchManagedPtr _obj
    touchManagedPtr msg
    freeMem auth_header'
    return result'