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

/No description available in the introspection data./
-}

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

module GI.WebKit2.Structs.SecurityOrigin
    (

-- * Exported types
    SecurityOrigin(..)                      ,
    noSecurityOrigin                        ,


 -- * Methods
-- ** getHost #method:getHost#

#if ENABLE_OVERLOADING
    SecurityOriginGetHostMethodInfo         ,
#endif
    securityOriginGetHost                   ,


-- ** getPort #method:getPort#

#if ENABLE_OVERLOADING
    SecurityOriginGetPortMethodInfo         ,
#endif
    securityOriginGetPort                   ,


-- ** getProtocol #method:getProtocol#

#if ENABLE_OVERLOADING
    SecurityOriginGetProtocolMethodInfo     ,
#endif
    securityOriginGetProtocol               ,


-- ** isOpaque #method:isOpaque#

#if ENABLE_OVERLOADING
    SecurityOriginIsOpaqueMethodInfo        ,
#endif
    securityOriginIsOpaque                  ,


-- ** new #method:new#

    securityOriginNew                       ,


-- ** newForUri #method:newForUri#

    securityOriginNewForUri                 ,


-- ** ref #method:ref#

#if ENABLE_OVERLOADING
    SecurityOriginRefMethodInfo             ,
#endif
    securityOriginRef                       ,


-- ** toString #method:toString#

#if ENABLE_OVERLOADING
    SecurityOriginToStringMethodInfo        ,
#endif
    securityOriginToString                  ,


-- ** unref #method:unref#

#if ENABLE_OVERLOADING
    SecurityOriginUnrefMethodInfo           ,
#endif
    securityOriginUnref                     ,




    ) 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.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
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.Text as T
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


-- | Memory-managed wrapper type.
newtype SecurityOrigin = SecurityOrigin (ManagedPtr SecurityOrigin)
foreign import ccall "webkit_security_origin_get_type" c_webkit_security_origin_get_type ::
    IO GType

instance BoxedObject SecurityOrigin where
    boxedType _ = c_webkit_security_origin_get_type

-- | A convenience alias for `Nothing` :: `Maybe` `SecurityOrigin`.
noSecurityOrigin :: Maybe SecurityOrigin
noSecurityOrigin = Nothing


#if ENABLE_OVERLOADING
instance O.HasAttributeList SecurityOrigin
type instance O.AttributeList SecurityOrigin = SecurityOriginAttributeList
type SecurityOriginAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method SecurityOrigin::new
-- method type : Constructor
-- Args : [Arg {argCName = "protocol", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The protocol for the new origin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "host", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The host for the new origin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "port", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The port number for the new origin, or 0 to indicate the\n       default port for @protocol", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_security_origin_new" webkit_security_origin_new ::
    CString ->                              -- protocol : TBasicType TUTF8
    CString ->                              -- host : TBasicType TUTF8
    Word16 ->                               -- port : TBasicType TUInt16
    IO (Ptr SecurityOrigin)

{- |
Create a new security origin from the provided protocol, host and
port.

/Since: 2.16/
-}
securityOriginNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@protocol@/: The protocol for the new origin -}
    -> T.Text
    {- ^ /@host@/: The host for the new origin -}
    -> Word16
    {- ^ /@port@/: The port number for the new origin, or 0 to indicate the
       default port for /@protocol@/ -}
    -> m SecurityOrigin
    {- ^ __Returns:__ A 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin'. -}
securityOriginNew protocol host port = liftIO $ do
    protocol' <- textToCString protocol
    host' <- textToCString host
    result <- webkit_security_origin_new protocol' host' port
    checkUnexpectedReturnNULL "securityOriginNew" result
    result' <- (wrapBoxed SecurityOrigin) result
    freeMem protocol'
    freeMem host'
    return result'

#if ENABLE_OVERLOADING
#endif

-- method SecurityOrigin::new_for_uri
-- method type : Constructor
-- Args : [Arg {argCName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The URI for the new origin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_security_origin_new_for_uri" webkit_security_origin_new_for_uri ::
    CString ->                              -- uri : TBasicType TUTF8
    IO (Ptr SecurityOrigin)

{- |
Create a new security origin from the provided URI. Components of
/@uri@/ other than protocol, host, and port do not affect the created
'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin'.

/Since: 2.16/
-}
securityOriginNewForUri ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    {- ^ /@uri@/: The URI for the new origin -}
    -> m SecurityOrigin
    {- ^ __Returns:__ A 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin'. -}
securityOriginNewForUri uri = liftIO $ do
    uri' <- textToCString uri
    result <- webkit_security_origin_new_for_uri uri'
    checkUnexpectedReturnNULL "securityOriginNewForUri" result
    result' <- (wrapBoxed SecurityOrigin) result
    freeMem uri'
    return result'

#if ENABLE_OVERLOADING
#endif

-- method SecurityOrigin::get_host
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "origin", argType = TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitSecurityOrigin", 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 "webkit_security_origin_get_host" webkit_security_origin_get_host ::
    Ptr SecurityOrigin ->                   -- origin : TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"})
    IO CString

{- |
Gets the hostname of /@origin@/, or 'Nothing' if /@origin@/ is opaque or if its
protocol does not require a host component.

/Since: 2.16/
-}
securityOriginGetHost ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    SecurityOrigin
    {- ^ /@origin@/: a 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ The host of the 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' -}
securityOriginGetHost origin = liftIO $ do
    origin' <- unsafeManagedPtrGetPtr origin
    result <- webkit_security_origin_get_host origin'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr origin
    return maybeResult

#if ENABLE_OVERLOADING
data SecurityOriginGetHostMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m) => O.MethodInfo SecurityOriginGetHostMethodInfo SecurityOrigin signature where
    overloadedMethod _ = securityOriginGetHost

#endif

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

foreign import ccall "webkit_security_origin_get_port" webkit_security_origin_get_port ::
    Ptr SecurityOrigin ->                   -- origin : TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"})
    IO Word16

{- |
Gets the port of /@origin@/. This function will always return 0 if the
port is the default port for the given protocol. For example,
http:\/\/example.com has the same security origin as
http:\/\/example.com:80, and this function will return 0 for a
'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' constructed from either URI. It will also
return 0 if /@origin@/ is opaque.

/Since: 2.16/
-}
securityOriginGetPort ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    SecurityOrigin
    {- ^ /@origin@/: a 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' -}
    -> m Word16
    {- ^ __Returns:__ The port of the 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin'. -}
securityOriginGetPort origin = liftIO $ do
    origin' <- unsafeManagedPtrGetPtr origin
    result <- webkit_security_origin_get_port origin'
    touchManagedPtr origin
    return result

#if ENABLE_OVERLOADING
data SecurityOriginGetPortMethodInfo
instance (signature ~ (m Word16), MonadIO m) => O.MethodInfo SecurityOriginGetPortMethodInfo SecurityOrigin signature where
    overloadedMethod _ = securityOriginGetPort

#endif

-- method SecurityOrigin::get_protocol
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "origin", argType = TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitSecurityOrigin", 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 "webkit_security_origin_get_protocol" webkit_security_origin_get_protocol ::
    Ptr SecurityOrigin ->                   -- origin : TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"})
    IO CString

{- |
Gets the protocol of /@origin@/, or 'Nothing' if /@origin@/ is opaque.

/Since: 2.16/
-}
securityOriginGetProtocol ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    SecurityOrigin
    {- ^ /@origin@/: a 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ The protocol of the 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' -}
securityOriginGetProtocol origin = liftIO $ do
    origin' <- unsafeManagedPtrGetPtr origin
    result <- webkit_security_origin_get_protocol origin'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr origin
    return maybeResult

#if ENABLE_OVERLOADING
data SecurityOriginGetProtocolMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m) => O.MethodInfo SecurityOriginGetProtocolMethodInfo SecurityOrigin signature where
    overloadedMethod _ = securityOriginGetProtocol

#endif

-- method SecurityOrigin::is_opaque
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "origin", argType = TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitSecurityOrigin", 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 "webkit_security_origin_is_opaque" webkit_security_origin_is_opaque ::
    Ptr SecurityOrigin ->                   -- origin : TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"})
    IO CInt

{- |
Gets whether /@origin@/ is an opaque security origin, which does not
possess an associated protocol, host, or port.

/Since: 2.16/
-}
securityOriginIsOpaque ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    SecurityOrigin
    {- ^ /@origin@/: a 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@origin@/ is opaque. -}
securityOriginIsOpaque origin = liftIO $ do
    origin' <- unsafeManagedPtrGetPtr origin
    result <- webkit_security_origin_is_opaque origin'
    let result' = (/= 0) result
    touchManagedPtr origin
    return result'

#if ENABLE_OVERLOADING
data SecurityOriginIsOpaqueMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo SecurityOriginIsOpaqueMethodInfo SecurityOrigin signature where
    overloadedMethod _ = securityOriginIsOpaque

#endif

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

foreign import ccall "webkit_security_origin_ref" webkit_security_origin_ref ::
    Ptr SecurityOrigin ->                   -- origin : TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"})
    IO (Ptr SecurityOrigin)

{- |
Atomically increments the reference count of /@origin@/ by one.
This function is MT-safe and may be called from any thread.

/Since: 2.16/
-}
securityOriginRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    SecurityOrigin
    {- ^ /@origin@/: a 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' -}
    -> m SecurityOrigin
    {- ^ __Returns:__ The passed 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' -}
securityOriginRef origin = liftIO $ do
    origin' <- unsafeManagedPtrGetPtr origin
    result <- webkit_security_origin_ref origin'
    checkUnexpectedReturnNULL "securityOriginRef" result
    result' <- (wrapBoxed SecurityOrigin) result
    touchManagedPtr origin
    return result'

#if ENABLE_OVERLOADING
data SecurityOriginRefMethodInfo
instance (signature ~ (m SecurityOrigin), MonadIO m) => O.MethodInfo SecurityOriginRefMethodInfo SecurityOrigin signature where
    overloadedMethod _ = securityOriginRef

#endif

-- method SecurityOrigin::to_string
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "origin", argType = TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitSecurityOrigin", 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 "webkit_security_origin_to_string" webkit_security_origin_to_string ::
    Ptr SecurityOrigin ->                   -- origin : TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"})
    IO CString

{- |
Gets a string representation of /@origin@/. The string representation
is a valid URI with only protocol, host, and port components. It may
be 'Nothing', but usually only if /@origin@/ is opaque.

/Since: 2.16/
-}
securityOriginToString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    SecurityOrigin
    {- ^ /@origin@/: a 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ a URI representing /@origin@/. -}
securityOriginToString origin = liftIO $ do
    origin' <- unsafeManagedPtrGetPtr origin
    result <- webkit_security_origin_to_string origin'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        freeMem result'
        return result''
    touchManagedPtr origin
    return maybeResult

#if ENABLE_OVERLOADING
data SecurityOriginToStringMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m) => O.MethodInfo SecurityOriginToStringMethodInfo SecurityOrigin signature where
    overloadedMethod _ = securityOriginToString

#endif

-- method SecurityOrigin::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "origin", argType = TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitSecurityOrigin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_security_origin_unref" webkit_security_origin_unref ::
    Ptr SecurityOrigin ->                   -- origin : TInterface (Name {namespace = "WebKit2", name = "SecurityOrigin"})
    IO ()

{- |
Atomically decrements the reference count of /@origin@/ by one.
If the reference count drops to 0, all memory allocated by
'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' is released. This function is MT-safe and may be
called from any thread.

/Since: 2.16/
-}
securityOriginUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    SecurityOrigin
    {- ^ /@origin@/: A 'GI.WebKit2.Structs.SecurityOrigin.SecurityOrigin' -}
    -> m ()
securityOriginUnref origin = liftIO $ do
    origin' <- unsafeManagedPtrGetPtr origin
    webkit_security_origin_unref origin'
    touchManagedPtr origin
    return ()

#if ENABLE_OVERLOADING
data SecurityOriginUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo SecurityOriginUnrefMethodInfo SecurityOrigin signature where
    overloadedMethod _ = securityOriginUnref

#endif

#if ENABLE_OVERLOADING
type family ResolveSecurityOriginMethod (t :: Symbol) (o :: *) :: * where
    ResolveSecurityOriginMethod "isOpaque" o = SecurityOriginIsOpaqueMethodInfo
    ResolveSecurityOriginMethod "ref" o = SecurityOriginRefMethodInfo
    ResolveSecurityOriginMethod "toString" o = SecurityOriginToStringMethodInfo
    ResolveSecurityOriginMethod "unref" o = SecurityOriginUnrefMethodInfo
    ResolveSecurityOriginMethod "getHost" o = SecurityOriginGetHostMethodInfo
    ResolveSecurityOriginMethod "getPort" o = SecurityOriginGetPortMethodInfo
    ResolveSecurityOriginMethod "getProtocol" o = SecurityOriginGetProtocolMethodInfo
    ResolveSecurityOriginMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveSecurityOriginMethod t SecurityOrigin, O.MethodInfo info SecurityOrigin p) => OL.IsLabel t (SecurityOrigin -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif