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

-- * Exported types
    AuthDomainDigest(..)                    ,
    AuthDomainDigestK                       ,
    toAuthDomainDigest                      ,
    noAuthDomainDigest                      ,


 -- * Methods
-- ** authDomainDigestEncodePassword
    authDomainDigestEncodePassword          ,




 -- * Properties
-- ** AuthCallback
    AuthDomainDigestAuthCallbackPropertyInfo,
    constructAuthDomainDigestAuthCallback   ,
    getAuthDomainDigestAuthCallback         ,
    setAuthDomainDigestAuthCallback         ,


-- ** AuthData
    AuthDomainDigestAuthDataPropertyInfo    ,
    constructAuthDomainDigestAuthData       ,
    getAuthDomainDigestAuthData             ,
    setAuthDomainDigestAuthData             ,




    ) 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 AuthDomainDigest = AuthDomainDigest (ForeignPtr AuthDomainDigest)
foreign import ccall "soup_auth_domain_digest_get_type"
    c_soup_auth_domain_digest_get_type :: IO GType

type instance ParentTypes AuthDomainDigest = AuthDomainDigestParentTypes
type AuthDomainDigestParentTypes = '[AuthDomain, GObject.Object]

instance GObject AuthDomainDigest where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_soup_auth_domain_digest_get_type
    

class GObject o => AuthDomainDigestK o
instance (GObject o, IsDescendantOf AuthDomainDigest o) => AuthDomainDigestK o

toAuthDomainDigest :: AuthDomainDigestK o => o -> IO AuthDomainDigest
toAuthDomainDigest = unsafeCastTo AuthDomainDigest

noAuthDomainDigest :: Maybe AuthDomainDigest
noAuthDomainDigest = Nothing

-- VVV Prop "auth-callback"
   -- Type: TBasicType TVoid
   -- Flags: [PropertyReadable,PropertyWritable]

getAuthDomainDigestAuthCallback :: (MonadIO m, AuthDomainDigestK o) => o -> m (Ptr ())
getAuthDomainDigestAuthCallback obj = liftIO $ getObjectPropertyPtr obj "auth-callback"

setAuthDomainDigestAuthCallback :: (MonadIO m, AuthDomainDigestK o) => o -> (Ptr ()) -> m ()
setAuthDomainDigestAuthCallback obj val = liftIO $ setObjectPropertyPtr obj "auth-callback" val

constructAuthDomainDigestAuthCallback :: (Ptr ()) -> IO ([Char], GValue)
constructAuthDomainDigestAuthCallback val = constructObjectPropertyPtr "auth-callback" val

data AuthDomainDigestAuthCallbackPropertyInfo
instance AttrInfo AuthDomainDigestAuthCallbackPropertyInfo where
    type AttrAllowedOps AuthDomainDigestAuthCallbackPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint AuthDomainDigestAuthCallbackPropertyInfo = (~) (Ptr ())
    type AttrBaseTypeConstraint AuthDomainDigestAuthCallbackPropertyInfo = AuthDomainDigestK
    type AttrGetType AuthDomainDigestAuthCallbackPropertyInfo = (Ptr ())
    type AttrLabel AuthDomainDigestAuthCallbackPropertyInfo = "AuthDomainDigest::auth-callback"
    attrGet _ = getAuthDomainDigestAuthCallback
    attrSet _ = setAuthDomainDigestAuthCallback
    attrConstruct _ = constructAuthDomainDigestAuthCallback

-- VVV Prop "auth-data"
   -- Type: TBasicType TVoid
   -- Flags: [PropertyReadable,PropertyWritable]

getAuthDomainDigestAuthData :: (MonadIO m, AuthDomainDigestK o) => o -> m (Ptr ())
getAuthDomainDigestAuthData obj = liftIO $ getObjectPropertyPtr obj "auth-data"

setAuthDomainDigestAuthData :: (MonadIO m, AuthDomainDigestK o) => o -> (Ptr ()) -> m ()
setAuthDomainDigestAuthData obj val = liftIO $ setObjectPropertyPtr obj "auth-data" val

constructAuthDomainDigestAuthData :: (Ptr ()) -> IO ([Char], GValue)
constructAuthDomainDigestAuthData val = constructObjectPropertyPtr "auth-data" val

data AuthDomainDigestAuthDataPropertyInfo
instance AttrInfo AuthDomainDigestAuthDataPropertyInfo where
    type AttrAllowedOps AuthDomainDigestAuthDataPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint AuthDomainDigestAuthDataPropertyInfo = (~) (Ptr ())
    type AttrBaseTypeConstraint AuthDomainDigestAuthDataPropertyInfo = AuthDomainDigestK
    type AttrGetType AuthDomainDigestAuthDataPropertyInfo = (Ptr ())
    type AttrLabel AuthDomainDigestAuthDataPropertyInfo = "AuthDomainDigest::auth-data"
    attrGet _ = getAuthDomainDigestAuthData
    attrSet _ = setAuthDomainDigestAuthData
    attrConstruct _ = constructAuthDomainDigestAuthData

type instance AttributeList AuthDomainDigest = AuthDomainDigestAttributeList
type AuthDomainDigestAttributeList = ('[ '("add-path", AuthDomainAddPathPropertyInfo), '("auth-callback", AuthDomainDigestAuthCallbackPropertyInfo), '("auth-data", AuthDomainDigestAuthDataPropertyInfo), '("filter", AuthDomainFilterPropertyInfo), '("filter-data", AuthDomainFilterDataPropertyInfo), '("generic-auth-callback", AuthDomainGenericAuthCallbackPropertyInfo), '("generic-auth-data", AuthDomainGenericAuthDataPropertyInfo), '("proxy", AuthDomainProxyPropertyInfo), '("realm", AuthDomainRealmPropertyInfo), '("remove-path", AuthDomainRemovePathPropertyInfo)] :: [(Symbol, *)])

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

-- method AuthDomainDigest::encode_password
-- method type : MemberFunction
-- Args : [Arg {argName = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "realm", 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 = "username", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "realm", 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 TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "soup_auth_domain_digest_encode_password" soup_auth_domain_digest_encode_password :: 
    CString ->                              -- username : TBasicType TUTF8
    CString ->                              -- realm : TBasicType TUTF8
    CString ->                              -- password : TBasicType TUTF8
    IO CString


authDomainDigestEncodePassword ::
    (MonadIO m) =>
    T.Text ->                               -- username
    T.Text ->                               -- realm
    T.Text ->                               -- password
    m T.Text
authDomainDigestEncodePassword username realm password = liftIO $ do
    username' <- textToCString username
    realm' <- textToCString realm
    password' <- textToCString password
    result <- soup_auth_domain_digest_encode_password username' realm' password'
    checkUnexpectedReturnNULL "soup_auth_domain_digest_encode_password" result
    result' <- cstringToText result
    freeMem result
    freeMem username'
    freeMem realm'
    freeMem password'
    return result'