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

The abstract base class for handling authentication. Specific HTTP
Authentication mechanisms are implemented by its subclasses, but
applications never need to be aware of the specific subclasses
being used.
-}

module GI.Soup.Objects.Auth
    ( 

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


 -- * Methods
-- ** authenticate #method:authenticate#
    AuthAuthenticateMethodInfo              ,
    authAuthenticate                        ,


-- ** canAuthenticate #method:canAuthenticate#
    AuthCanAuthenticateMethodInfo           ,
    authCanAuthenticate                     ,


-- ** getAuthorization #method:getAuthorization#
    AuthGetAuthorizationMethodInfo          ,
    authGetAuthorization                    ,


-- ** getHost #method:getHost#
    AuthGetHostMethodInfo                   ,
    authGetHost                             ,


-- ** getInfo #method:getInfo#
    AuthGetInfoMethodInfo                   ,
    authGetInfo                             ,


-- ** getProtectionSpace #method:getProtectionSpace#
    AuthGetProtectionSpaceMethodInfo        ,
    authGetProtectionSpace                  ,


-- ** getRealm #method:getRealm#
    AuthGetRealmMethodInfo                  ,
    authGetRealm                            ,


-- ** getSavedPassword #method:getSavedPassword#
    AuthGetSavedPasswordMethodInfo          ,
    authGetSavedPassword                    ,


-- ** getSavedUsers #method:getSavedUsers#
    AuthGetSavedUsersMethodInfo             ,
    authGetSavedUsers                       ,


-- ** getSchemeName #method:getSchemeName#
    AuthGetSchemeNameMethodInfo             ,
    authGetSchemeName                       ,


-- ** hasSavedPassword #method:hasSavedPassword#
    AuthHasSavedPasswordMethodInfo          ,
    authHasSavedPassword                    ,


-- ** isAuthenticated #method:isAuthenticated#
    AuthIsAuthenticatedMethodInfo           ,
    authIsAuthenticated                     ,


-- ** isForProxy #method:isForProxy#
    AuthIsForProxyMethodInfo                ,
    authIsForProxy                          ,


-- ** isReady #method:isReady#
    AuthIsReadyMethodInfo                   ,
    authIsReady                             ,


-- ** new #method:new#
    authNew                                 ,


-- ** savePassword #method:savePassword#
    AuthSavePasswordMethodInfo              ,
    authSavePassword                        ,


-- ** update #method:update#
    AuthUpdateMethodInfo                    ,
    authUpdate                              ,




 -- * Properties
-- ** host #attr:host#
    AuthHostPropertyInfo                    ,
    authHost                                ,
    clearAuthHost                           ,
    constructAuthHost                       ,
    getAuthHost                             ,
    setAuthHost                             ,


-- ** isAuthenticated #attr:isAuthenticated#
    AuthIsAuthenticatedPropertyInfo         ,
    getAuthIsAuthenticated                  ,


-- ** isForProxy #attr:isForProxy#
    AuthIsForProxyPropertyInfo              ,
    constructAuthIsForProxy                 ,
    getAuthIsForProxy                       ,
    setAuthIsForProxy                       ,


-- ** realm #attr:realm#
    AuthRealmPropertyInfo                   ,
    authRealm                               ,
    clearAuthRealm                          ,
    constructAuthRealm                      ,
    getAuthRealm                            ,
    setAuthRealm                            ,


-- ** schemeName #attr:schemeName#
    AuthSchemeNamePropertyInfo              ,
    authSchemeName                          ,
    getAuthSchemeName                       ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Soup.Objects.Message as Soup.Message
import {-# SOURCE #-} qualified GI.Soup.Structs.URI as Soup.URI

newtype Auth = Auth (ManagedPtr Auth)
foreign import ccall "soup_auth_get_type"
    c_soup_auth_get_type :: IO GType

instance GObject Auth where
    gobjectType _ = c_soup_auth_get_type
    

class GObject o => IsAuth o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Auth a) =>
    IsAuth a
#endif
instance IsAuth Auth
instance GObject.Object.IsObject Auth

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

noAuth :: Maybe Auth
noAuth = Nothing

type family ResolveAuthMethod (t :: Symbol) (o :: *) :: * where
    ResolveAuthMethod "authenticate" o = AuthAuthenticateMethodInfo
    ResolveAuthMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveAuthMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveAuthMethod "canAuthenticate" o = AuthCanAuthenticateMethodInfo
    ResolveAuthMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveAuthMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveAuthMethod "hasSavedPassword" o = AuthHasSavedPasswordMethodInfo
    ResolveAuthMethod "isAuthenticated" o = AuthIsAuthenticatedMethodInfo
    ResolveAuthMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveAuthMethod "isForProxy" o = AuthIsForProxyMethodInfo
    ResolveAuthMethod "isReady" o = AuthIsReadyMethodInfo
    ResolveAuthMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveAuthMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveAuthMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveAuthMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveAuthMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveAuthMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveAuthMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveAuthMethod "savePassword" o = AuthSavePasswordMethodInfo
    ResolveAuthMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveAuthMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveAuthMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveAuthMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveAuthMethod "update" o = AuthUpdateMethodInfo
    ResolveAuthMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveAuthMethod "getAuthorization" o = AuthGetAuthorizationMethodInfo
    ResolveAuthMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveAuthMethod "getHost" o = AuthGetHostMethodInfo
    ResolveAuthMethod "getInfo" o = AuthGetInfoMethodInfo
    ResolveAuthMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveAuthMethod "getProtectionSpace" o = AuthGetProtectionSpaceMethodInfo
    ResolveAuthMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveAuthMethod "getRealm" o = AuthGetRealmMethodInfo
    ResolveAuthMethod "getSavedPassword" o = AuthGetSavedPasswordMethodInfo
    ResolveAuthMethod "getSavedUsers" o = AuthGetSavedUsersMethodInfo
    ResolveAuthMethod "getSchemeName" o = AuthGetSchemeNameMethodInfo
    ResolveAuthMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveAuthMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveAuthMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveAuthMethod t Auth, O.MethodInfo info Auth p) => O.IsLabelProxy t (Auth -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveAuthMethod t Auth, O.MethodInfo info Auth p) => O.IsLabel t (Auth -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "host"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Nothing)

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

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

constructAuthHost :: (IsAuth o) => T.Text -> IO (GValueConstruct o)
constructAuthHost val = constructObjectPropertyString "host" (Just val)

clearAuthHost :: (MonadIO m, IsAuth o) => o -> m ()
clearAuthHost obj = liftIO $ setObjectPropertyString obj "host" (Nothing :: Maybe T.Text)

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

-- VVV Prop "is-authenticated"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable]
   -- Nullable: (Nothing,Nothing)

getAuthIsAuthenticated :: (MonadIO m, IsAuth 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 = IsAuth
    type AttrGetType AuthIsAuthenticatedPropertyInfo = Bool
    type AttrLabel AuthIsAuthenticatedPropertyInfo = "is-authenticated"
    type AttrOrigin AuthIsAuthenticatedPropertyInfo = Auth
    attrGet _ = getAuthIsAuthenticated
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

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

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

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

constructAuthIsForProxy :: (IsAuth o) => Bool -> IO (GValueConstruct o)
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 = IsAuth
    type AttrGetType AuthIsForProxyPropertyInfo = Bool
    type AttrLabel AuthIsForProxyPropertyInfo = "is-for-proxy"
    type AttrOrigin AuthIsForProxyPropertyInfo = Auth
    attrGet _ = getAuthIsForProxy
    attrSet _ = setAuthIsForProxy
    attrConstruct _ = constructAuthIsForProxy
    attrClear _ = undefined

-- VVV Prop "realm"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Nothing)

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

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

constructAuthRealm :: (IsAuth o) => T.Text -> IO (GValueConstruct o)
constructAuthRealm val = constructObjectPropertyString "realm" (Just val)

clearAuthRealm :: (MonadIO m, IsAuth o) => o -> m ()
clearAuthRealm obj = liftIO $ setObjectPropertyString obj "realm" (Nothing :: Maybe T.Text)

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

-- VVV Prop "scheme-name"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

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

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

instance O.HasAttributeList Auth
type instance O.AttributeList Auth = AuthAttributeList
type AuthAttributeList = ('[ '("host", AuthHostPropertyInfo), '("isAuthenticated", AuthIsAuthenticatedPropertyInfo), '("isForProxy", AuthIsForProxyPropertyInfo), '("realm", AuthRealmPropertyInfo), '("schemeName", AuthSchemeNamePropertyInfo)] :: [(Symbol, *)])

authHost :: AttrLabelProxy "host"
authHost = AttrLabelProxy

authRealm :: AttrLabelProxy "realm"
authRealm = AttrLabelProxy

authSchemeName :: AttrLabelProxy "schemeName"
authSchemeName = AttrLabelProxy

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

-- method Auth::new
-- method type : Constructor
-- Args : [Arg {argCName = "type", argType = TBasicType TGType, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the type of auth to create (a subtype of #SoupAuth)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupMessage the auth is being created for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "auth_header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WWW-Authenticate/Proxy-Authenticate header", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Auth"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_new" soup_auth_new :: 
    CGType ->                               -- type : TBasicType TGType
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    CString ->                              -- auth_header : TBasicType TUTF8
    IO (Ptr Auth)

{- |
Creates a new 'GI.Soup.Objects.Auth.Auth' of type /@type@/ with the information from
/@msg@/ and /@authHeader@/.

This is called by 'GI.Soup.Objects.Session.Session'; you will normally not create auths
yourself.
-}
authNew ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    GType
    {- ^ /@type@/: the type of auth to create (a subtype of 'GI.Soup.Objects.Auth.Auth') -}
    -> a
    {- ^ /@msg@/: the 'GI.Soup.Objects.Message.Message' the auth is being created for -}
    -> T.Text
    {- ^ /@authHeader@/: the WWW-Authenticate\/Proxy-Authenticate header -}
    -> m (Maybe Auth)
    {- ^ __Returns:__ the new 'GI.Soup.Objects.Auth.Auth', or 'Nothing' if it could
not be created -}
authNew type_ msg authHeader = liftIO $ do
    let type_' = gtypeToCGType type_
    msg' <- unsafeManagedPtrCastPtr msg
    authHeader' <- textToCString authHeader
    result <- soup_auth_new type_' msg' authHeader'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Auth) result'
        return result''
    touchManagedPtr msg
    freeMem authHeader'
    return maybeResult

-- method Auth::authenticate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the username provided by the user or client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "password", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the password provided by the user or client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_authenticate" soup_auth_authenticate :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    CString ->                              -- username : TBasicType TUTF8
    CString ->                              -- password : TBasicType TUTF8
    IO ()

{- |
Call this on an auth to authenticate it; normally this will cause
the auth\'s message to be requeued with the new authentication info.
-}
authAuthenticate ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> T.Text
    {- ^ /@username@/: the username provided by the user or client -}
    -> T.Text
    {- ^ /@password@/: the password provided by the user or client -}
    -> m ()
authAuthenticate auth username password = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    username' <- textToCString username
    password' <- textToCString password
    soup_auth_authenticate auth' username' password'
    touchManagedPtr auth
    freeMem username'
    freeMem password'
    return ()

data AuthAuthenticateMethodInfo
instance (signature ~ (T.Text -> T.Text -> m ()), MonadIO m, IsAuth a) => O.MethodInfo AuthAuthenticateMethodInfo a signature where
    overloadedMethod _ = authAuthenticate

-- method Auth::can_authenticate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_can_authenticate" soup_auth_can_authenticate :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    IO CInt

{- |
Tests if /@auth@/ is able to authenticate by providing credentials to the
'GI.Soup.Objects.Auth.authAuthenticate'.

@since 2.54
-}
authCanAuthenticate ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@auth@/ is able to accept credentials. -}
authCanAuthenticate auth = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    result <- soup_auth_can_authenticate auth'
    let result' = (/= 0) result
    touchManagedPtr auth
    return result'

data AuthCanAuthenticateMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAuth a) => O.MethodInfo AuthCanAuthenticateMethodInfo a signature where
    overloadedMethod _ = authCanAuthenticate

-- method Auth::get_authorization
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupMessage to be authorized", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_get_authorization" soup_auth_get_authorization :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    IO CString

{- |
Generates an appropriate \"Authorization\" header for /@msg@/. (The
session will only call this if 'GI.Soup.Objects.Auth.authIsAuthenticated'
returned 'True'.)
-}
authGetAuthorization ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a, Soup.Message.IsMessage b) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> b
    {- ^ /@msg@/: the 'GI.Soup.Objects.Message.Message' to be authorized -}
    -> m T.Text
    {- ^ __Returns:__ the \"Authorization\" header, which must be freed. -}
authGetAuthorization auth msg = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    msg' <- unsafeManagedPtrCastPtr msg
    result <- soup_auth_get_authorization auth' msg'
    checkUnexpectedReturnNULL "authGetAuthorization" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr auth
    touchManagedPtr msg
    return result'

data AuthGetAuthorizationMethodInfo
instance (signature ~ (b -> m T.Text), MonadIO m, IsAuth a, Soup.Message.IsMessage b) => O.MethodInfo AuthGetAuthorizationMethodInfo a signature where
    overloadedMethod _ = authGetAuthorization

-- method Auth::get_host
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_get_host" soup_auth_get_host :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    IO CString

{- |
Returns the host that /@auth@/ is associated with.
-}
authGetHost ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> m T.Text
    {- ^ __Returns:__ the hostname -}
authGetHost auth = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    result <- soup_auth_get_host auth'
    checkUnexpectedReturnNULL "authGetHost" result
    result' <- cstringToText result
    touchManagedPtr auth
    return result'

data AuthGetHostMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsAuth a) => O.MethodInfo AuthGetHostMethodInfo a signature where
    overloadedMethod _ = authGetHost

-- method Auth::get_info
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_get_info" soup_auth_get_info :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    IO CString

{- |
Gets an opaque identifier for /@auth@/, for use as a hash key or the
like. 'GI.Soup.Objects.Auth.Auth' objects from the same server with the same
identifier refer to the same authentication domain (eg, the URLs
associated with them take the same usernames and passwords).
-}
authGetInfo ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> m T.Text
    {- ^ __Returns:__ the identifier -}
authGetInfo auth = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    result <- soup_auth_get_info auth'
    checkUnexpectedReturnNULL "authGetInfo" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr auth
    return result'

data AuthGetInfoMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsAuth a) => O.MethodInfo AuthGetInfoMethodInfo a signature where
    overloadedMethod _ = authGetInfo

-- method Auth::get_protection_space
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "source_uri", argType = TInterface (Name {namespace = "Soup", name = "URI"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the URI of the request that @auth was generated in\nresponse to.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGSList (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_get_protection_space" soup_auth_get_protection_space :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    Ptr Soup.URI.URI ->                     -- source_uri : TInterface (Name {namespace = "Soup", name = "URI"})
    IO (Ptr (GSList CString))

{- |
Returns a list of paths on the server which /@auth@/ extends over.
(All subdirectories of these paths are also assumed to be part
of /@auth@/\'s protection space, unless otherwise discovered not to
be.)
-}
authGetProtectionSpace ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> Soup.URI.URI
    {- ^ /@sourceUri@/: the URI of the request that /@auth@/ was generated in
response to. -}
    -> m [T.Text]
    {- ^ __Returns:__ the list of
paths, which can be freed with @/soup_auth_free_protection_space()/@. -}
authGetProtectionSpace auth sourceUri = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    sourceUri' <- unsafeManagedPtrGetPtr sourceUri
    result <- soup_auth_get_protection_space auth' sourceUri'
    result' <- unpackGSList result
    result'' <- mapM cstringToText result'
    mapGSList freeMem result
    g_slist_free result
    touchManagedPtr auth
    touchManagedPtr sourceUri
    return result''

data AuthGetProtectionSpaceMethodInfo
instance (signature ~ (Soup.URI.URI -> m [T.Text]), MonadIO m, IsAuth a) => O.MethodInfo AuthGetProtectionSpaceMethodInfo a signature where
    overloadedMethod _ = authGetProtectionSpace

-- method Auth::get_realm
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_get_realm" soup_auth_get_realm :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    IO CString

{- |
Returns /@auth@/\'s realm. This is an identifier that distinguishes
separate authentication spaces on a given server, and may be some
string that is meaningful to the user. (Although it is probably not
localized.)
-}
authGetRealm ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> m T.Text
    {- ^ __Returns:__ the realm name -}
authGetRealm auth = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    result <- soup_auth_get_realm auth'
    checkUnexpectedReturnNULL "authGetRealm" result
    result' <- cstringToText result
    touchManagedPtr auth
    return result'

data AuthGetRealmMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsAuth a) => O.MethodInfo AuthGetRealmMethodInfo a signature where
    overloadedMethod _ = authGetRealm

-- method Auth::get_saved_password
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_get_saved_password" soup_auth_get_saved_password :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    CString ->                              -- user : TBasicType TUTF8
    IO CString

{- |
/No description available in the introspection data./
-}
authGetSavedPassword ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    -> T.Text
    -> m T.Text
authGetSavedPassword auth user = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    user' <- textToCString user
    result <- soup_auth_get_saved_password auth' user'
    checkUnexpectedReturnNULL "authGetSavedPassword" result
    result' <- cstringToText result
    touchManagedPtr auth
    freeMem user'
    return result'

data AuthGetSavedPasswordMethodInfo
instance (signature ~ (T.Text -> m T.Text), MonadIO m, IsAuth a) => O.MethodInfo AuthGetSavedPasswordMethodInfo a signature where
    overloadedMethod _ = authGetSavedPassword

-- method Auth::get_saved_users
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGSList (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_get_saved_users" soup_auth_get_saved_users :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    IO (Ptr (GSList CString))

{- |
/No description available in the introspection data./
-}
authGetSavedUsers ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    -> m [T.Text]
authGetSavedUsers auth = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    result <- soup_auth_get_saved_users auth'
    result' <- unpackGSList result
    result'' <- mapM cstringToText result'
    mapGSList freeMem result
    g_slist_free result
    touchManagedPtr auth
    return result''

data AuthGetSavedUsersMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m, IsAuth a) => O.MethodInfo AuthGetSavedUsersMethodInfo a signature where
    overloadedMethod _ = authGetSavedUsers

-- method Auth::get_scheme_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_get_scheme_name" soup_auth_get_scheme_name :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    IO CString

{- |
Returns /@auth@/\'s scheme name. (Eg, \"Basic\", \"Digest\", or \"NTLM\")
-}
authGetSchemeName ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> m T.Text
    {- ^ __Returns:__ the scheme name -}
authGetSchemeName auth = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    result <- soup_auth_get_scheme_name auth'
    checkUnexpectedReturnNULL "authGetSchemeName" result
    result' <- cstringToText result
    touchManagedPtr auth
    return result'

data AuthGetSchemeNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsAuth a) => O.MethodInfo AuthGetSchemeNameMethodInfo a signature where
    overloadedMethod _ = authGetSchemeName

-- method Auth::has_saved_password
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "password", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_has_saved_password" soup_auth_has_saved_password :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    CString ->                              -- username : TBasicType TUTF8
    CString ->                              -- password : TBasicType TUTF8
    IO ()

{- |
/No description available in the introspection data./
-}
authHasSavedPassword ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    -> T.Text
    -> T.Text
    -> m ()
authHasSavedPassword auth username password = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    username' <- textToCString username
    password' <- textToCString password
    soup_auth_has_saved_password auth' username' password'
    touchManagedPtr auth
    freeMem username'
    freeMem password'
    return ()

data AuthHasSavedPasswordMethodInfo
instance (signature ~ (T.Text -> T.Text -> m ()), MonadIO m, IsAuth a) => O.MethodInfo AuthHasSavedPasswordMethodInfo a signature where
    overloadedMethod _ = authHasSavedPassword

-- method Auth::is_authenticated
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_is_authenticated" soup_auth_is_authenticated :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    IO CInt

{- |
Tests if /@auth@/ has been given a username and password
-}
authIsAuthenticated ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@auth@/ has been given a username and password -}
authIsAuthenticated auth = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    result <- soup_auth_is_authenticated auth'
    let result' = (/= 0) result
    touchManagedPtr auth
    return result'

data AuthIsAuthenticatedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAuth a) => O.MethodInfo AuthIsAuthenticatedMethodInfo a signature where
    overloadedMethod _ = authIsAuthenticated

-- method Auth::is_for_proxy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_is_for_proxy" soup_auth_is_for_proxy :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    IO CInt

{- |
Tests whether or not /@auth@/ is associated with a proxy server rather
than an \"origin\" server.
-}
authIsForProxy ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> m Bool
    {- ^ __Returns:__ 'True' or 'False' -}
authIsForProxy auth = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    result <- soup_auth_is_for_proxy auth'
    let result' = (/= 0) result
    touchManagedPtr auth
    return result'

data AuthIsForProxyMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsAuth a) => O.MethodInfo AuthIsForProxyMethodInfo a signature where
    overloadedMethod _ = authIsForProxy

-- method Auth::is_ready
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_is_ready" soup_auth_is_ready :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    IO CInt

{- |
Tests if /@auth@/ is ready to make a request for /@msg@/ with. For most
auths, this is equivalent to 'GI.Soup.Objects.Auth.authIsAuthenticated', but for
some auth types (eg, NTLM), the auth may be sendable (eg, as an
authentication request) even before it is authenticated.

@since 2.42
-}
authIsReady ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a, Soup.Message.IsMessage b) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> b
    {- ^ /@msg@/: a 'GI.Soup.Objects.Message.Message' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@auth@/ is ready to make a request with. -}
authIsReady auth msg = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    msg' <- unsafeManagedPtrCastPtr msg
    result <- soup_auth_is_ready auth' msg'
    let result' = (/= 0) result
    touchManagedPtr auth
    touchManagedPtr msg
    return result'

data AuthIsReadyMethodInfo
instance (signature ~ (b -> m Bool), MonadIO m, IsAuth a, Soup.Message.IsMessage b) => O.MethodInfo AuthIsReadyMethodInfo a signature where
    overloadedMethod _ = authIsReady

-- method Auth::save_password
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "password", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_save_password" soup_auth_save_password :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    CString ->                              -- username : TBasicType TUTF8
    CString ->                              -- password : TBasicType TUTF8
    IO ()

{- |
/No description available in the introspection data./
-}
authSavePassword ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a) =>
    a
    -> T.Text
    -> T.Text
    -> m ()
authSavePassword auth username password = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    username' <- textToCString username
    password' <- textToCString password
    soup_auth_save_password auth' username' password'
    touchManagedPtr auth
    freeMem username'
    freeMem password'
    return ()

data AuthSavePasswordMethodInfo
instance (signature ~ (T.Text -> T.Text -> m ()), MonadIO m, IsAuth a) => O.MethodInfo AuthSavePasswordMethodInfo a signature where
    overloadedMethod _ = authSavePassword

-- method Auth::update
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "auth", argType = TInterface (Name {namespace = "Soup", name = "Auth"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuth", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #SoupMessage @auth is being updated for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "auth_header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WWW-Authenticate/Proxy-Authenticate header", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_update" soup_auth_update :: 
    Ptr Auth ->                             -- auth : TInterface (Name {namespace = "Soup", name = "Auth"})
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    CString ->                              -- auth_header : TBasicType TUTF8
    IO CInt

{- |
Updates /@auth@/ with the information from /@msg@/ and /@authHeader@/,
possibly un-authenticating it. As with 'GI.Soup.Objects.Auth.authNew', this is
normally only used by 'GI.Soup.Objects.Session.Session'.
-}
authUpdate ::
    (B.CallStack.HasCallStack, MonadIO m, IsAuth a, Soup.Message.IsMessage b) =>
    a
    {- ^ /@auth@/: a 'GI.Soup.Objects.Auth.Auth' -}
    -> b
    {- ^ /@msg@/: the 'GI.Soup.Objects.Message.Message' /@auth@/ is being updated for -}
    -> T.Text
    {- ^ /@authHeader@/: the WWW-Authenticate\/Proxy-Authenticate header -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@auth@/ is still a valid (but potentially
unauthenticated) 'GI.Soup.Objects.Auth.Auth'. 'False' if something about /@authParams@/
could not be parsed or incorporated into /@auth@/ at all. -}
authUpdate auth msg authHeader = liftIO $ do
    auth' <- unsafeManagedPtrCastPtr auth
    msg' <- unsafeManagedPtrCastPtr msg
    authHeader' <- textToCString authHeader
    result <- soup_auth_update auth' msg' authHeader'
    let result' = (/= 0) result
    touchManagedPtr auth
    touchManagedPtr msg
    freeMem authHeader'
    return result'

data AuthUpdateMethodInfo
instance (signature ~ (b -> T.Text -> m Bool), MonadIO m, IsAuth a, Soup.Message.IsMessage b) => O.MethodInfo AuthUpdateMethodInfo a signature where
    overloadedMethod _ = authUpdate