{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy' implements HTTP policies, as described by
-- <http://tools.ietf.org/html/rfc6797 RFC 6797>.
-- 
-- /@domain@/ represents the host that this policy applies to. The domain
-- must be IDNA-canonicalized. [ctor/@hSTSPolicy@/.new] and related methods
-- will do this for you.
-- 
-- /@maxAge@/ contains the \'max-age\' value from the Strict Transport
-- Security header and indicates the time to live of this policy,
-- in seconds.
-- 
-- /@expires@/ will be non-'P.Nothing' if the policy has been set by the host and
-- hence has an expiry time. If /@expires@/ is 'P.Nothing', it indicates that the
-- policy is a permanent session policy set by the user agent.
-- 
-- If /@includeSubdomains@/ is 'P.True', the Strict Transport Security policy
-- must also be enforced on subdomains of /@domain@/.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Soup.Structs.HSTSPolicy
    ( 

-- * Exported types
    HSTSPolicy(..)                          ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [copy]("GI.Soup.Structs.HSTSPolicy#g:method:copy"), [equal]("GI.Soup.Structs.HSTSPolicy#g:method:equal"), [free]("GI.Soup.Structs.HSTSPolicy#g:method:free"), [includesSubdomains]("GI.Soup.Structs.HSTSPolicy#g:method:includesSubdomains"), [isExpired]("GI.Soup.Structs.HSTSPolicy#g:method:isExpired"), [isSessionPolicy]("GI.Soup.Structs.HSTSPolicy#g:method:isSessionPolicy").
-- 
-- ==== Getters
-- [getDomain]("GI.Soup.Structs.HSTSPolicy#g:method:getDomain"), [getExpires]("GI.Soup.Structs.HSTSPolicy#g:method:getExpires"), [getMaxAge]("GI.Soup.Structs.HSTSPolicy#g:method:getMaxAge").
-- 
-- ==== Setters
-- /None/.

#if defined(ENABLE_OVERLOADING)
    ResolveHSTSPolicyMethod                 ,
#endif

-- ** copy #method:copy#

#if defined(ENABLE_OVERLOADING)
    HSTSPolicyCopyMethodInfo                ,
#endif
    hSTSPolicyCopy                          ,


-- ** equal #method:equal#

#if defined(ENABLE_OVERLOADING)
    HSTSPolicyEqualMethodInfo               ,
#endif
    hSTSPolicyEqual                         ,


-- ** free #method:free#

#if defined(ENABLE_OVERLOADING)
    HSTSPolicyFreeMethodInfo                ,
#endif
    hSTSPolicyFree                          ,


-- ** getDomain #method:getDomain#

#if defined(ENABLE_OVERLOADING)
    HSTSPolicyGetDomainMethodInfo           ,
#endif
    hSTSPolicyGetDomain                     ,


-- ** getExpires #method:getExpires#

#if defined(ENABLE_OVERLOADING)
    HSTSPolicyGetExpiresMethodInfo          ,
#endif
    hSTSPolicyGetExpires                    ,


-- ** getMaxAge #method:getMaxAge#

#if defined(ENABLE_OVERLOADING)
    HSTSPolicyGetMaxAgeMethodInfo           ,
#endif
    hSTSPolicyGetMaxAge                     ,


-- ** includesSubdomains #method:includesSubdomains#

#if defined(ENABLE_OVERLOADING)
    HSTSPolicyIncludesSubdomainsMethodInfo  ,
#endif
    hSTSPolicyIncludesSubdomains            ,


-- ** isExpired #method:isExpired#

#if defined(ENABLE_OVERLOADING)
    HSTSPolicyIsExpiredMethodInfo           ,
#endif
    hSTSPolicyIsExpired                     ,


-- ** isSessionPolicy #method:isSessionPolicy#

#if defined(ENABLE_OVERLOADING)
    HSTSPolicyIsSessionPolicyMethodInfo     ,
#endif
    hSTSPolicyIsSessionPolicy               ,


-- ** new #method:new#

    hSTSPolicyNew                           ,


-- ** newFromResponse #method:newFromResponse#

    hSTSPolicyNewFromResponse               ,


-- ** newFull #method:newFull#

    hSTSPolicyNewFull                       ,


-- ** newSessionPolicy #method:newSessionPolicy#

    hSTSPolicyNewSessionPolicy              ,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GLib.Structs.DateTime as GLib.DateTime
import qualified GI.GLib.Structs.Uri as GLib.Uri
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Enums as Gio.Enums
import qualified GI.Gio.Flags as Gio.Flags
import qualified GI.Gio.Interfaces.TlsClientConnection as Gio.TlsClientConnection
import qualified GI.Gio.Objects.IOStream as Gio.IOStream
import qualified GI.Gio.Objects.InputStream as Gio.InputStream
import qualified GI.Gio.Objects.SocketAddress as Gio.SocketAddress
import qualified GI.Gio.Objects.TlsCertificate as Gio.TlsCertificate
import qualified GI.Gio.Objects.TlsPassword as Gio.TlsPassword
import qualified GI.Soup.Callbacks as Soup.Callbacks
import {-# SOURCE #-} qualified GI.Soup.Enums as Soup.Enums
import {-# SOURCE #-} qualified GI.Soup.Flags as Soup.Flags
import {-# SOURCE #-} qualified GI.Soup.Objects.Auth as Soup.Auth
import {-# SOURCE #-} qualified GI.Soup.Objects.Message as Soup.Message
import {-# SOURCE #-} qualified GI.Soup.Structs.MessageHeaders as Soup.MessageHeaders
import {-# SOURCE #-} qualified GI.Soup.Structs.MessageMetrics as Soup.MessageMetrics
import {-# SOURCE #-} qualified GI.Soup.Structs.Multipart as Soup.Multipart
import {-# SOURCE #-} qualified GI.Soup.Structs.Range as Soup.Range

#else
import qualified GI.GLib.Structs.DateTime as GLib.DateTime
import {-# SOURCE #-} qualified GI.Soup.Objects.Message as Soup.Message

#endif

-- | Memory-managed wrapper type.
newtype HSTSPolicy = HSTSPolicy (SP.ManagedPtr HSTSPolicy)
    deriving (HSTSPolicy -> HSTSPolicy -> Bool
(HSTSPolicy -> HSTSPolicy -> Bool)
-> (HSTSPolicy -> HSTSPolicy -> Bool) -> Eq HSTSPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HSTSPolicy -> HSTSPolicy -> Bool
== :: HSTSPolicy -> HSTSPolicy -> Bool
$c/= :: HSTSPolicy -> HSTSPolicy -> Bool
/= :: HSTSPolicy -> HSTSPolicy -> Bool
Eq)

instance SP.ManagedPtrNewtype HSTSPolicy where
    toManagedPtr :: HSTSPolicy -> ManagedPtr HSTSPolicy
toManagedPtr (HSTSPolicy ManagedPtr HSTSPolicy
p) = ManagedPtr HSTSPolicy
p

foreign import ccall "soup_hsts_policy_get_type" c_soup_hsts_policy_get_type :: 
    IO GType

type instance O.ParentTypes HSTSPolicy = '[]
instance O.HasParentTypes HSTSPolicy

instance B.Types.TypedObject HSTSPolicy where
    glibType :: IO GType
glibType = IO GType
c_soup_hsts_policy_get_type

instance B.Types.GBoxed HSTSPolicy

-- | Convert 'HSTSPolicy' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe HSTSPolicy) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_soup_hsts_policy_get_type
    gvalueSet_ :: Ptr GValue -> Maybe HSTSPolicy -> IO ()
gvalueSet_ Ptr GValue
gv Maybe HSTSPolicy
P.Nothing = Ptr GValue -> Ptr HSTSPolicy -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr HSTSPolicy
forall a. Ptr a
FP.nullPtr :: FP.Ptr HSTSPolicy)
    gvalueSet_ Ptr GValue
gv (P.Just HSTSPolicy
obj) = HSTSPolicy -> (Ptr HSTSPolicy -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr HSTSPolicy
obj (Ptr GValue -> Ptr HSTSPolicy -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe HSTSPolicy)
gvalueGet_ Ptr GValue
gv = do
        Ptr HSTSPolicy
ptr <- Ptr GValue -> IO (Ptr HSTSPolicy)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr HSTSPolicy)
        if Ptr HSTSPolicy
ptr Ptr HSTSPolicy -> Ptr HSTSPolicy -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr HSTSPolicy
forall a. Ptr a
FP.nullPtr
        then HSTSPolicy -> Maybe HSTSPolicy
forall a. a -> Maybe a
P.Just (HSTSPolicy -> Maybe HSTSPolicy)
-> IO HSTSPolicy -> IO (Maybe HSTSPolicy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr HSTSPolicy -> HSTSPolicy)
-> Ptr HSTSPolicy -> IO HSTSPolicy
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr HSTSPolicy -> HSTSPolicy
HSTSPolicy Ptr HSTSPolicy
ptr
        else Maybe HSTSPolicy -> IO (Maybe HSTSPolicy)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe HSTSPolicy
forall a. Maybe a
P.Nothing
        
    


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList HSTSPolicy
type instance O.AttributeList HSTSPolicy = HSTSPolicyAttributeList
type HSTSPolicyAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

-- method HSTSPolicy::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "domain"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "policy domain or hostname"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "max_age"
--           , argType = TBasicType TULong
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "max age of the policy"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "include_subdomains"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "%TRUE if the policy applies on subdomains"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Soup" , name = "HSTSPolicy" })
-- throws : False
-- Skip return : False

foreign import ccall "soup_hsts_policy_new" soup_hsts_policy_new :: 
    CString ->                              -- domain : TBasicType TUTF8
    FCT.CULong ->                           -- max_age : TBasicType TULong
    CInt ->                                 -- include_subdomains : TBasicType TBoolean
    IO (Ptr HSTSPolicy)

-- | Creates a new t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy' with the given attributes.
-- 
-- /@domain@/ is a domain on which the strict transport security policy
-- represented by this object must be enforced.
-- 
-- /@maxAge@/ is used to set the \"expires\" attribute on the policy; pass
-- 'GI.Soup.Constants.HSTS_POLICY_MAX_AGE_PAST' for an already-expired policy, or a
-- lifetime in seconds.
-- 
-- If /@includeSubdomains@/ is 'P.True', the strict transport security policy
-- must also be enforced on all subdomains of /@domain@/.
hSTSPolicyNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@domain@/: policy domain or hostname
    -> FCT.CULong
    -- ^ /@maxAge@/: max age of the policy
    -> Bool
    -- ^ /@includeSubdomains@/: 'P.True' if the policy applies on subdomains
    -> m HSTSPolicy
    -- ^ __Returns:__ a new t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'.
hSTSPolicyNew :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> CULong -> Bool -> m HSTSPolicy
hSTSPolicyNew Text
domain CULong
maxAge Bool
includeSubdomains = IO HSTSPolicy -> m HSTSPolicy
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO HSTSPolicy -> m HSTSPolicy) -> IO HSTSPolicy -> m HSTSPolicy
forall a b. (a -> b) -> a -> b
$ do
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    let includeSubdomains' :: CInt
includeSubdomains' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
P.fromEnum) Bool
includeSubdomains
    Ptr HSTSPolicy
result <- CString -> CULong -> CInt -> IO (Ptr HSTSPolicy)
soup_hsts_policy_new CString
domain' CULong
maxAge CInt
includeSubdomains'
    Text -> Ptr HSTSPolicy -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"hSTSPolicyNew" Ptr HSTSPolicy
result
    HSTSPolicy
result' <- ((ManagedPtr HSTSPolicy -> HSTSPolicy)
-> Ptr HSTSPolicy -> IO HSTSPolicy
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr HSTSPolicy -> HSTSPolicy
HSTSPolicy) Ptr HSTSPolicy
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
    HSTSPolicy -> IO HSTSPolicy
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return HSTSPolicy
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method HSTSPolicy::new_from_response
-- method type : Constructor
-- Args: [ 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
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Soup" , name = "HSTSPolicy" })
-- throws : False
-- Skip return : False

foreign import ccall "soup_hsts_policy_new_from_response" soup_hsts_policy_new_from_response :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    IO (Ptr HSTSPolicy)

-- | Parses /@msg@/\'s first \"Strict-Transport-Security\" response header and
-- returns a t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'.
hSTSPolicyNewFromResponse ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: a t'GI.Soup.Objects.Message.Message'
    -> m (Maybe HSTSPolicy)
    -- ^ __Returns:__ a new t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy', or 'P.Nothing' if no valid
    --   \"Strict-Transport-Security\" response header was found.
hSTSPolicyNewFromResponse :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsMessage a) =>
a -> m (Maybe HSTSPolicy)
hSTSPolicyNewFromResponse a
msg = IO (Maybe HSTSPolicy) -> m (Maybe HSTSPolicy)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe HSTSPolicy) -> m (Maybe HSTSPolicy))
-> IO (Maybe HSTSPolicy) -> m (Maybe HSTSPolicy)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    Ptr HSTSPolicy
result <- Ptr Message -> IO (Ptr HSTSPolicy)
soup_hsts_policy_new_from_response Ptr Message
msg'
    Maybe HSTSPolicy
maybeResult <- Ptr HSTSPolicy
-> (Ptr HSTSPolicy -> IO HSTSPolicy) -> IO (Maybe HSTSPolicy)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr HSTSPolicy
result ((Ptr HSTSPolicy -> IO HSTSPolicy) -> IO (Maybe HSTSPolicy))
-> (Ptr HSTSPolicy -> IO HSTSPolicy) -> IO (Maybe HSTSPolicy)
forall a b. (a -> b) -> a -> b
$ \Ptr HSTSPolicy
result' -> do
        HSTSPolicy
result'' <- ((ManagedPtr HSTSPolicy -> HSTSPolicy)
-> Ptr HSTSPolicy -> IO HSTSPolicy
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr HSTSPolicy -> HSTSPolicy
HSTSPolicy) Ptr HSTSPolicy
result'
        HSTSPolicy -> IO HSTSPolicy
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return HSTSPolicy
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
    Maybe HSTSPolicy -> IO (Maybe HSTSPolicy)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe HSTSPolicy
maybeResult

#if defined(ENABLE_OVERLOADING)
#endif

-- method HSTSPolicy::new_full
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "domain"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "policy domain or hostname"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "max_age"
--           , argType = TBasicType TULong
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "max age of the policy"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "expires"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "DateTime" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the date of expiration of the policy or %NULL for a permanent policy"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "include_subdomains"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "%TRUE if the policy applies on subdomains"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Soup" , name = "HSTSPolicy" })
-- throws : False
-- Skip return : False

foreign import ccall "soup_hsts_policy_new_full" soup_hsts_policy_new_full :: 
    CString ->                              -- domain : TBasicType TUTF8
    FCT.CULong ->                           -- max_age : TBasicType TULong
    Ptr GLib.DateTime.DateTime ->           -- expires : TInterface (Name {namespace = "GLib", name = "DateTime"})
    CInt ->                                 -- include_subdomains : TBasicType TBoolean
    IO (Ptr HSTSPolicy)

-- | Full version of [ctor/@hSTSPolicy@/.new], to use with an existing
-- expiration date.
-- 
-- See [ctor/@hSTSPolicy@/.new] for details.
hSTSPolicyNewFull ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@domain@/: policy domain or hostname
    -> FCT.CULong
    -- ^ /@maxAge@/: max age of the policy
    -> GLib.DateTime.DateTime
    -- ^ /@expires@/: the date of expiration of the policy or 'P.Nothing' for a permanent policy
    -> Bool
    -- ^ /@includeSubdomains@/: 'P.True' if the policy applies on subdomains
    -> m HSTSPolicy
    -- ^ __Returns:__ a new t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'.
hSTSPolicyNewFull :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> CULong -> DateTime -> Bool -> m HSTSPolicy
hSTSPolicyNewFull Text
domain CULong
maxAge DateTime
expires Bool
includeSubdomains = IO HSTSPolicy -> m HSTSPolicy
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO HSTSPolicy -> m HSTSPolicy) -> IO HSTSPolicy -> m HSTSPolicy
forall a b. (a -> b) -> a -> b
$ do
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    Ptr DateTime
expires' <- DateTime -> IO (Ptr DateTime)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr DateTime
expires
    let includeSubdomains' :: CInt
includeSubdomains' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
P.fromEnum) Bool
includeSubdomains
    Ptr HSTSPolicy
result <- CString -> CULong -> Ptr DateTime -> CInt -> IO (Ptr HSTSPolicy)
soup_hsts_policy_new_full CString
domain' CULong
maxAge Ptr DateTime
expires' CInt
includeSubdomains'
    Text -> Ptr HSTSPolicy -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"hSTSPolicyNewFull" Ptr HSTSPolicy
result
    HSTSPolicy
result' <- ((ManagedPtr HSTSPolicy -> HSTSPolicy)
-> Ptr HSTSPolicy -> IO HSTSPolicy
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr HSTSPolicy -> HSTSPolicy
HSTSPolicy) Ptr HSTSPolicy
result
    DateTime -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr DateTime
expires
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
    HSTSPolicy -> IO HSTSPolicy
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return HSTSPolicy
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method HSTSPolicy::new_session_policy
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "domain"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "policy domain or hostname"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "include_subdomains"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "%TRUE if the policy applies on sub domains"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Soup" , name = "HSTSPolicy" })
-- throws : False
-- Skip return : False

foreign import ccall "soup_hsts_policy_new_session_policy" soup_hsts_policy_new_session_policy :: 
    CString ->                              -- domain : TBasicType TUTF8
    CInt ->                                 -- include_subdomains : TBasicType TBoolean
    IO (Ptr HSTSPolicy)

-- | Creates a new session t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy' with the given attributes.
-- 
-- A session policy is a policy that is valid during the lifetime of
-- the [class/@hSTSEnforcer@/] it is added to. Contrary to regular policies,
-- it has no expiration date and is not stored in persistent
-- enforcers. These policies are useful for user-agent to load their
-- own or user-defined rules.
-- 
-- /@domain@/ is a domain on which the strict transport security policy
-- represented by this object must be enforced.
-- 
-- If /@includeSubdomains@/ is 'P.True', the strict transport security policy
-- must also be enforced on all subdomains of /@domain@/.
hSTSPolicyNewSessionPolicy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@domain@/: policy domain or hostname
    -> Bool
    -- ^ /@includeSubdomains@/: 'P.True' if the policy applies on sub domains
    -> m HSTSPolicy
    -- ^ __Returns:__ a new t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'.
hSTSPolicyNewSessionPolicy :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Bool -> m HSTSPolicy
hSTSPolicyNewSessionPolicy Text
domain Bool
includeSubdomains = IO HSTSPolicy -> m HSTSPolicy
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO HSTSPolicy -> m HSTSPolicy) -> IO HSTSPolicy -> m HSTSPolicy
forall a b. (a -> b) -> a -> b
$ do
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    let includeSubdomains' :: CInt
includeSubdomains' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
P.fromEnum) Bool
includeSubdomains
    Ptr HSTSPolicy
result <- CString -> CInt -> IO (Ptr HSTSPolicy)
soup_hsts_policy_new_session_policy CString
domain' CInt
includeSubdomains'
    Text -> Ptr HSTSPolicy -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"hSTSPolicyNewSessionPolicy" Ptr HSTSPolicy
result
    HSTSPolicy
result' <- ((ManagedPtr HSTSPolicy -> HSTSPolicy)
-> Ptr HSTSPolicy -> IO HSTSPolicy
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr HSTSPolicy -> HSTSPolicy
HSTSPolicy) Ptr HSTSPolicy
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
    HSTSPolicy -> IO HSTSPolicy
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return HSTSPolicy
result'

#if defined(ENABLE_OVERLOADING)
#endif

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

foreign import ccall "soup_hsts_policy_copy" soup_hsts_policy_copy :: 
    Ptr HSTSPolicy ->                       -- policy : TInterface (Name {namespace = "Soup", name = "HSTSPolicy"})
    IO (Ptr HSTSPolicy)

-- | Copies /@policy@/.
hSTSPolicyCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    HSTSPolicy
    -- ^ /@policy@/: a t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'
    -> m HSTSPolicy
    -- ^ __Returns:__ a copy of /@policy@/
hSTSPolicyCopy :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
HSTSPolicy -> m HSTSPolicy
hSTSPolicyCopy HSTSPolicy
policy = IO HSTSPolicy -> m HSTSPolicy
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO HSTSPolicy -> m HSTSPolicy) -> IO HSTSPolicy -> m HSTSPolicy
forall a b. (a -> b) -> a -> b
$ do
    Ptr HSTSPolicy
policy' <- HSTSPolicy -> IO (Ptr HSTSPolicy)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr HSTSPolicy
policy
    Ptr HSTSPolicy
result <- Ptr HSTSPolicy -> IO (Ptr HSTSPolicy)
soup_hsts_policy_copy Ptr HSTSPolicy
policy'
    Text -> Ptr HSTSPolicy -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"hSTSPolicyCopy" Ptr HSTSPolicy
result
    HSTSPolicy
result' <- ((ManagedPtr HSTSPolicy -> HSTSPolicy)
-> Ptr HSTSPolicy -> IO HSTSPolicy
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr HSTSPolicy -> HSTSPolicy
HSTSPolicy) Ptr HSTSPolicy
result
    HSTSPolicy -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr HSTSPolicy
policy
    HSTSPolicy -> IO HSTSPolicy
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return HSTSPolicy
result'

#if defined(ENABLE_OVERLOADING)
data HSTSPolicyCopyMethodInfo
instance (signature ~ (m HSTSPolicy), MonadIO m) => O.OverloadedMethod HSTSPolicyCopyMethodInfo HSTSPolicy signature where
    overloadedMethod = hSTSPolicyCopy

instance O.OverloadedMethodInfo HSTSPolicyCopyMethodInfo HSTSPolicy where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Structs.HSTSPolicy.hSTSPolicyCopy",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-3.0.3/docs/GI-Soup-Structs-HSTSPolicy.html#v:hSTSPolicyCopy"
        })


#endif

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

foreign import ccall "soup_hsts_policy_equal" soup_hsts_policy_equal :: 
    Ptr HSTSPolicy ->                       -- policy1 : TInterface (Name {namespace = "Soup", name = "HSTSPolicy"})
    Ptr HSTSPolicy ->                       -- policy2 : TInterface (Name {namespace = "Soup", name = "HSTSPolicy"})
    IO CInt

-- | Tests if /@policy1@/ and /@policy2@/ are equal.
hSTSPolicyEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    HSTSPolicy
    -- ^ /@policy1@/: a t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'
    -> HSTSPolicy
    -- ^ /@policy2@/: a t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'
    -> m Bool
    -- ^ __Returns:__ whether the policies are equal.
hSTSPolicyEqual :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
HSTSPolicy -> HSTSPolicy -> m Bool
hSTSPolicyEqual HSTSPolicy
policy1 HSTSPolicy
policy2 = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr HSTSPolicy
policy1' <- HSTSPolicy -> IO (Ptr HSTSPolicy)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr HSTSPolicy
policy1
    Ptr HSTSPolicy
policy2' <- HSTSPolicy -> IO (Ptr HSTSPolicy)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr HSTSPolicy
policy2
    CInt
result <- Ptr HSTSPolicy -> Ptr HSTSPolicy -> IO CInt
soup_hsts_policy_equal Ptr HSTSPolicy
policy1' Ptr HSTSPolicy
policy2'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    HSTSPolicy -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr HSTSPolicy
policy1
    HSTSPolicy -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr HSTSPolicy
policy2
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data HSTSPolicyEqualMethodInfo
instance (signature ~ (HSTSPolicy -> m Bool), MonadIO m) => O.OverloadedMethod HSTSPolicyEqualMethodInfo HSTSPolicy signature where
    overloadedMethod = hSTSPolicyEqual

instance O.OverloadedMethodInfo HSTSPolicyEqualMethodInfo HSTSPolicy where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Structs.HSTSPolicy.hSTSPolicyEqual",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-3.0.3/docs/GI-Soup-Structs-HSTSPolicy.html#v:hSTSPolicyEqual"
        })


#endif

-- method HSTSPolicy::free
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "policy"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "HSTSPolicy" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupHSTSPolicy" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_hsts_policy_free" soup_hsts_policy_free :: 
    Ptr HSTSPolicy ->                       -- policy : TInterface (Name {namespace = "Soup", name = "HSTSPolicy"})
    IO ()

-- | Frees /@policy@/.
hSTSPolicyFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    HSTSPolicy
    -- ^ /@policy@/: a t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'
    -> m ()
hSTSPolicyFree :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
HSTSPolicy -> m ()
hSTSPolicyFree HSTSPolicy
policy = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr HSTSPolicy
policy' <- HSTSPolicy -> IO (Ptr HSTSPolicy)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed HSTSPolicy
policy
    Ptr HSTSPolicy -> IO ()
soup_hsts_policy_free Ptr HSTSPolicy
policy'
    HSTSPolicy -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr HSTSPolicy
policy
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data HSTSPolicyFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod HSTSPolicyFreeMethodInfo HSTSPolicy signature where
    overloadedMethod = hSTSPolicyFree

instance O.OverloadedMethodInfo HSTSPolicyFreeMethodInfo HSTSPolicy where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Structs.HSTSPolicy.hSTSPolicyFree",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-3.0.3/docs/GI-Soup-Structs-HSTSPolicy.html#v:hSTSPolicyFree"
        })


#endif

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

foreign import ccall "soup_hsts_policy_get_domain" soup_hsts_policy_get_domain :: 
    Ptr HSTSPolicy ->                       -- policy : TInterface (Name {namespace = "Soup", name = "HSTSPolicy"})
    IO CString

-- | Gets /@policy@/\'s domain.
hSTSPolicyGetDomain ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    HSTSPolicy
    -- ^ /@policy@/: a t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'
    -> m T.Text
    -- ^ __Returns:__ /@policy@/\'s domain.
hSTSPolicyGetDomain :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
HSTSPolicy -> m Text
hSTSPolicyGetDomain HSTSPolicy
policy = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr HSTSPolicy
policy' <- HSTSPolicy -> IO (Ptr HSTSPolicy)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr HSTSPolicy
policy
    CString
result <- Ptr HSTSPolicy -> IO CString
soup_hsts_policy_get_domain Ptr HSTSPolicy
policy'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"hSTSPolicyGetDomain" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    HSTSPolicy -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr HSTSPolicy
policy
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(ENABLE_OVERLOADING)
data HSTSPolicyGetDomainMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.OverloadedMethod HSTSPolicyGetDomainMethodInfo HSTSPolicy signature where
    overloadedMethod = hSTSPolicyGetDomain

instance O.OverloadedMethodInfo HSTSPolicyGetDomainMethodInfo HSTSPolicy where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Structs.HSTSPolicy.hSTSPolicyGetDomain",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-3.0.3/docs/GI-Soup-Structs-HSTSPolicy.html#v:hSTSPolicyGetDomain"
        })


#endif

-- method HSTSPolicy::get_expires
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "policy"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "HSTSPolicy" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupHSTSPolicy" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GLib" , name = "DateTime" })
-- throws : False
-- Skip return : False

foreign import ccall "soup_hsts_policy_get_expires" soup_hsts_policy_get_expires :: 
    Ptr HSTSPolicy ->                       -- policy : TInterface (Name {namespace = "Soup", name = "HSTSPolicy"})
    IO (Ptr GLib.DateTime.DateTime)

-- | Returns the expiration date for /@policy@/.
hSTSPolicyGetExpires ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    HSTSPolicy
    -- ^ /@policy@/: a t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'
    -> m GLib.DateTime.DateTime
    -- ^ __Returns:__ A t'GI.GLib.Structs.DateTime.DateTime' or 'P.Nothing' if unset
hSTSPolicyGetExpires :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
HSTSPolicy -> m DateTime
hSTSPolicyGetExpires HSTSPolicy
policy = IO DateTime -> m DateTime
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DateTime -> m DateTime) -> IO DateTime -> m DateTime
forall a b. (a -> b) -> a -> b
$ do
    Ptr HSTSPolicy
policy' <- HSTSPolicy -> IO (Ptr HSTSPolicy)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr HSTSPolicy
policy
    Ptr DateTime
result <- Ptr HSTSPolicy -> IO (Ptr DateTime)
soup_hsts_policy_get_expires Ptr HSTSPolicy
policy'
    Text -> Ptr DateTime -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"hSTSPolicyGetExpires" Ptr DateTime
result
    DateTime
result' <- ((ManagedPtr DateTime -> DateTime) -> Ptr DateTime -> IO DateTime
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr DateTime -> DateTime
GLib.DateTime.DateTime) Ptr DateTime
result
    HSTSPolicy -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr HSTSPolicy
policy
    DateTime -> IO DateTime
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return DateTime
result'

#if defined(ENABLE_OVERLOADING)
data HSTSPolicyGetExpiresMethodInfo
instance (signature ~ (m GLib.DateTime.DateTime), MonadIO m) => O.OverloadedMethod HSTSPolicyGetExpiresMethodInfo HSTSPolicy signature where
    overloadedMethod = hSTSPolicyGetExpires

instance O.OverloadedMethodInfo HSTSPolicyGetExpiresMethodInfo HSTSPolicy where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Structs.HSTSPolicy.hSTSPolicyGetExpires",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-3.0.3/docs/GI-Soup-Structs-HSTSPolicy.html#v:hSTSPolicyGetExpires"
        })


#endif

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

foreign import ccall "soup_hsts_policy_get_max_age" soup_hsts_policy_get_max_age :: 
    Ptr HSTSPolicy ->                       -- policy : TInterface (Name {namespace = "Soup", name = "HSTSPolicy"})
    IO FCT.CULong

-- | Returns the max age for /@policy@/.
hSTSPolicyGetMaxAge ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    HSTSPolicy
    -- ^ /@policy@/: a t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'
    -> m FCT.CULong
    -- ^ __Returns:__ Max age in seconds
hSTSPolicyGetMaxAge :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
HSTSPolicy -> m CULong
hSTSPolicyGetMaxAge HSTSPolicy
policy = IO CULong -> m CULong
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CULong -> m CULong) -> IO CULong -> m CULong
forall a b. (a -> b) -> a -> b
$ do
    Ptr HSTSPolicy
policy' <- HSTSPolicy -> IO (Ptr HSTSPolicy)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr HSTSPolicy
policy
    CULong
result <- Ptr HSTSPolicy -> IO CULong
soup_hsts_policy_get_max_age Ptr HSTSPolicy
policy'
    HSTSPolicy -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr HSTSPolicy
policy
    CULong -> IO CULong
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CULong
result

#if defined(ENABLE_OVERLOADING)
data HSTSPolicyGetMaxAgeMethodInfo
instance (signature ~ (m FCT.CULong), MonadIO m) => O.OverloadedMethod HSTSPolicyGetMaxAgeMethodInfo HSTSPolicy signature where
    overloadedMethod = hSTSPolicyGetMaxAge

instance O.OverloadedMethodInfo HSTSPolicyGetMaxAgeMethodInfo HSTSPolicy where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Structs.HSTSPolicy.hSTSPolicyGetMaxAge",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-3.0.3/docs/GI-Soup-Structs-HSTSPolicy.html#v:hSTSPolicyGetMaxAge"
        })


#endif

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

foreign import ccall "soup_hsts_policy_includes_subdomains" soup_hsts_policy_includes_subdomains :: 
    Ptr HSTSPolicy ->                       -- policy : TInterface (Name {namespace = "Soup", name = "HSTSPolicy"})
    IO CInt

-- | Gets whether /@policy@/ include its subdomains.
hSTSPolicyIncludesSubdomains ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    HSTSPolicy
    -- ^ /@policy@/: a t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@policy@/ includes subdomains, 'P.False' otherwise.
hSTSPolicyIncludesSubdomains :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
HSTSPolicy -> m Bool
hSTSPolicyIncludesSubdomains HSTSPolicy
policy = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr HSTSPolicy
policy' <- HSTSPolicy -> IO (Ptr HSTSPolicy)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr HSTSPolicy
policy
    CInt
result <- Ptr HSTSPolicy -> IO CInt
soup_hsts_policy_includes_subdomains Ptr HSTSPolicy
policy'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    HSTSPolicy -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr HSTSPolicy
policy
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data HSTSPolicyIncludesSubdomainsMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.OverloadedMethod HSTSPolicyIncludesSubdomainsMethodInfo HSTSPolicy signature where
    overloadedMethod = hSTSPolicyIncludesSubdomains

instance O.OverloadedMethodInfo HSTSPolicyIncludesSubdomainsMethodInfo HSTSPolicy where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Structs.HSTSPolicy.hSTSPolicyIncludesSubdomains",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-3.0.3/docs/GI-Soup-Structs-HSTSPolicy.html#v:hSTSPolicyIncludesSubdomains"
        })


#endif

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

foreign import ccall "soup_hsts_policy_is_expired" soup_hsts_policy_is_expired :: 
    Ptr HSTSPolicy ->                       -- policy : TInterface (Name {namespace = "Soup", name = "HSTSPolicy"})
    IO CInt

-- | Gets whether /@policy@/ is expired.
-- 
-- Permanent policies never expire.
hSTSPolicyIsExpired ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    HSTSPolicy
    -- ^ /@policy@/: a t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@policy@/ is expired, 'P.False' otherwise.
hSTSPolicyIsExpired :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
HSTSPolicy -> m Bool
hSTSPolicyIsExpired HSTSPolicy
policy = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr HSTSPolicy
policy' <- HSTSPolicy -> IO (Ptr HSTSPolicy)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr HSTSPolicy
policy
    CInt
result <- Ptr HSTSPolicy -> IO CInt
soup_hsts_policy_is_expired Ptr HSTSPolicy
policy'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    HSTSPolicy -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr HSTSPolicy
policy
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data HSTSPolicyIsExpiredMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.OverloadedMethod HSTSPolicyIsExpiredMethodInfo HSTSPolicy signature where
    overloadedMethod = hSTSPolicyIsExpired

instance O.OverloadedMethodInfo HSTSPolicyIsExpiredMethodInfo HSTSPolicy where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Structs.HSTSPolicy.hSTSPolicyIsExpired",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-3.0.3/docs/GI-Soup-Structs-HSTSPolicy.html#v:hSTSPolicyIsExpired"
        })


#endif

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

foreign import ccall "soup_hsts_policy_is_session_policy" soup_hsts_policy_is_session_policy :: 
    Ptr HSTSPolicy ->                       -- policy : TInterface (Name {namespace = "Soup", name = "HSTSPolicy"})
    IO CInt

-- | Gets whether /@policy@/ is a non-permanent, non-expirable session policy.
-- 
-- See [ctor/@hSTSPolicy@/.new_session_policy] for details.
hSTSPolicyIsSessionPolicy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    HSTSPolicy
    -- ^ /@policy@/: a t'GI.Soup.Structs.HSTSPolicy.HSTSPolicy'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@policy@/ is permanent, 'P.False' otherwise
hSTSPolicyIsSessionPolicy :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
HSTSPolicy -> m Bool
hSTSPolicyIsSessionPolicy HSTSPolicy
policy = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr HSTSPolicy
policy' <- HSTSPolicy -> IO (Ptr HSTSPolicy)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr HSTSPolicy
policy
    CInt
result <- Ptr HSTSPolicy -> IO CInt
soup_hsts_policy_is_session_policy Ptr HSTSPolicy
policy'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    HSTSPolicy -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr HSTSPolicy
policy
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data HSTSPolicyIsSessionPolicyMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.OverloadedMethod HSTSPolicyIsSessionPolicyMethodInfo HSTSPolicy signature where
    overloadedMethod = hSTSPolicyIsSessionPolicy

instance O.OverloadedMethodInfo HSTSPolicyIsSessionPolicyMethodInfo HSTSPolicy where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Soup.Structs.HSTSPolicy.hSTSPolicyIsSessionPolicy",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-soup-3.0.3/docs/GI-Soup-Structs-HSTSPolicy.html#v:hSTSPolicyIsSessionPolicy"
        })


#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveHSTSPolicyMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveHSTSPolicyMethod "copy" o = HSTSPolicyCopyMethodInfo
    ResolveHSTSPolicyMethod "equal" o = HSTSPolicyEqualMethodInfo
    ResolveHSTSPolicyMethod "free" o = HSTSPolicyFreeMethodInfo
    ResolveHSTSPolicyMethod "includesSubdomains" o = HSTSPolicyIncludesSubdomainsMethodInfo
    ResolveHSTSPolicyMethod "isExpired" o = HSTSPolicyIsExpiredMethodInfo
    ResolveHSTSPolicyMethod "isSessionPolicy" o = HSTSPolicyIsSessionPolicyMethodInfo
    ResolveHSTSPolicyMethod "getDomain" o = HSTSPolicyGetDomainMethodInfo
    ResolveHSTSPolicyMethod "getExpires" o = HSTSPolicyGetExpiresMethodInfo
    ResolveHSTSPolicyMethod "getMaxAge" o = HSTSPolicyGetMaxAgeMethodInfo
    ResolveHSTSPolicyMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveHSTSPolicyMethod t HSTSPolicy, O.OverloadedMethod info HSTSPolicy p) => OL.IsLabel t (HSTSPolicy -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveHSTSPolicyMethod t HSTSPolicy, O.OverloadedMethod info HSTSPolicy p, R.HasField t HSTSPolicy p) => R.HasField t HSTSPolicy p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveHSTSPolicyMethod t HSTSPolicy, O.OverloadedMethodInfo info HSTSPolicy) => OL.IsLabel t (O.MethodProxy info HSTSPolicy) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif