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

-- * Exported types
    WebsiteData(..)                         ,
    noWebsiteData                           ,


 -- * Methods
-- ** getName #method:getName#

#if ENABLE_OVERLOADING
    WebsiteDataGetNameMethodInfo            ,
#endif
    websiteDataGetName                      ,


-- ** getSize #method:getSize#

#if ENABLE_OVERLOADING
    WebsiteDataGetSizeMethodInfo            ,
#endif
    websiteDataGetSize                      ,


-- ** getTypes #method:getTypes#

#if ENABLE_OVERLOADING
    WebsiteDataGetTypesMethodInfo           ,
#endif
    websiteDataGetTypes                     ,


-- ** ref #method:ref#

#if ENABLE_OVERLOADING
    WebsiteDataRefMethodInfo                ,
#endif
    websiteDataRef                          ,


-- ** unref #method:unref#

#if ENABLE_OVERLOADING
    WebsiteDataUnrefMethodInfo              ,
#endif
    websiteDataUnref                        ,




    ) 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

import {-# SOURCE #-} qualified GI.WebKit2.Flags as WebKit2.Flags

-- | Memory-managed wrapper type.
newtype WebsiteData = WebsiteData (ManagedPtr WebsiteData)
foreign import ccall "webkit_website_data_get_type" c_webkit_website_data_get_type ::
    IO GType

instance BoxedObject WebsiteData where
    boxedType _ = c_webkit_website_data_get_type

-- | A convenience alias for `Nothing` :: `Maybe` `WebsiteData`.
noWebsiteData :: Maybe WebsiteData
noWebsiteData = Nothing


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

-- method WebsiteData::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "website_data", argType = TInterface (Name {namespace = "WebKit2", name = "WebsiteData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebsiteData", 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_website_data_get_name" webkit_website_data_get_name ::
    Ptr WebsiteData ->                      -- website_data : TInterface (Name {namespace = "WebKit2", name = "WebsiteData"})
    IO CString

{- |
Gets the name of 'GI.WebKit2.Structs.WebsiteData.WebsiteData'. This is the website name, normally represented by
a domain or host name. All local documents are grouped in the same 'GI.WebKit2.Structs.WebsiteData.WebsiteData' using
the name \"Local files\".

/Since: 2.16/
-}
websiteDataGetName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    WebsiteData
    {- ^ /@websiteData@/: a 'GI.WebKit2.Structs.WebsiteData.WebsiteData' -}
    -> m T.Text
    {- ^ __Returns:__ the website name of /@websiteData@/. -}
websiteDataGetName websiteData = liftIO $ do
    websiteData' <- unsafeManagedPtrGetPtr websiteData
    result <- webkit_website_data_get_name websiteData'
    checkUnexpectedReturnNULL "websiteDataGetName" result
    result' <- cstringToText result
    touchManagedPtr websiteData
    return result'

#if ENABLE_OVERLOADING
data WebsiteDataGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo WebsiteDataGetNameMethodInfo WebsiteData signature where
    overloadedMethod _ = websiteDataGetName

#endif

-- method WebsiteData::get_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "website_data", argType = TInterface (Name {namespace = "WebKit2", name = "WebsiteData"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebsiteData", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "types", argType = TInterface (Name {namespace = "WebKit2", name = "WebsiteDataTypes"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a bitmask  of #WebKitWebsiteDataTypes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_website_data_get_size" webkit_website_data_get_size ::
    Ptr WebsiteData ->                      -- website_data : TInterface (Name {namespace = "WebKit2", name = "WebsiteData"})
    CUInt ->                                -- types : TInterface (Name {namespace = "WebKit2", name = "WebsiteDataTypes"})
    IO Word64

{- |
Gets the size of the data of types /@types@/ in a 'GI.WebKit2.Structs.WebsiteData.WebsiteData'.
Note that currently the data size is only known for 'GI.WebKit2.Flags.WebsiteDataTypesDiskCache' data type
so for all other types 0 will be returned.

/Since: 2.16/
-}
websiteDataGetSize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    WebsiteData
    {- ^ /@websiteData@/: a 'GI.WebKit2.Structs.WebsiteData.WebsiteData' -}
    -> [WebKit2.Flags.WebsiteDataTypes]
    {- ^ /@types@/: a bitmask  of 'GI.WebKit2.Flags.WebsiteDataTypes' -}
    -> m Word64
    {- ^ __Returns:__ the size of /@websiteData@/ for the given /@types@/. -}
websiteDataGetSize websiteData types = liftIO $ do
    websiteData' <- unsafeManagedPtrGetPtr websiteData
    let types' = gflagsToWord types
    result <- webkit_website_data_get_size websiteData' types'
    touchManagedPtr websiteData
    return result

#if ENABLE_OVERLOADING
data WebsiteDataGetSizeMethodInfo
instance (signature ~ ([WebKit2.Flags.WebsiteDataTypes] -> m Word64), MonadIO m) => O.MethodInfo WebsiteDataGetSizeMethodInfo WebsiteData signature where
    overloadedMethod _ = websiteDataGetSize

#endif

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

foreign import ccall "webkit_website_data_get_types" webkit_website_data_get_types ::
    Ptr WebsiteData ->                      -- website_data : TInterface (Name {namespace = "WebKit2", name = "WebsiteData"})
    IO CUInt

{- |
Gets the types of data stored in the client for a 'GI.WebKit2.Structs.WebsiteData.WebsiteData'. These are the
types actually present, not the types queried with 'GI.WebKit2.Objects.WebsiteDataManager.websiteDataManagerFetch'.

/Since: 2.16/
-}
websiteDataGetTypes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    WebsiteData
    {- ^ /@websiteData@/: a 'GI.WebKit2.Structs.WebsiteData.WebsiteData' -}
    -> m [WebKit2.Flags.WebsiteDataTypes]
    {- ^ __Returns:__ a bitmask of 'GI.WebKit2.Flags.WebsiteDataTypes' in /@websiteData@/ -}
websiteDataGetTypes websiteData = liftIO $ do
    websiteData' <- unsafeManagedPtrGetPtr websiteData
    result <- webkit_website_data_get_types websiteData'
    let result' = wordToGFlags result
    touchManagedPtr websiteData
    return result'

#if ENABLE_OVERLOADING
data WebsiteDataGetTypesMethodInfo
instance (signature ~ (m [WebKit2.Flags.WebsiteDataTypes]), MonadIO m) => O.MethodInfo WebsiteDataGetTypesMethodInfo WebsiteData signature where
    overloadedMethod _ = websiteDataGetTypes

#endif

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

foreign import ccall "webkit_website_data_ref" webkit_website_data_ref ::
    Ptr WebsiteData ->                      -- website_data : TInterface (Name {namespace = "WebKit2", name = "WebsiteData"})
    IO (Ptr WebsiteData)

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

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

#if ENABLE_OVERLOADING
data WebsiteDataRefMethodInfo
instance (signature ~ (m WebsiteData), MonadIO m) => O.MethodInfo WebsiteDataRefMethodInfo WebsiteData signature where
    overloadedMethod _ = websiteDataRef

#endif

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

foreign import ccall "webkit_website_data_unref" webkit_website_data_unref ::
    Ptr WebsiteData ->                      -- website_data : TInterface (Name {namespace = "WebKit2", name = "WebsiteData"})
    IO ()

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

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

#if ENABLE_OVERLOADING
data WebsiteDataUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo WebsiteDataUnrefMethodInfo WebsiteData signature where
    overloadedMethod _ = websiteDataUnref

#endif

#if ENABLE_OVERLOADING
type family ResolveWebsiteDataMethod (t :: Symbol) (o :: *) :: * where
    ResolveWebsiteDataMethod "ref" o = WebsiteDataRefMethodInfo
    ResolveWebsiteDataMethod "unref" o = WebsiteDataUnrefMethodInfo
    ResolveWebsiteDataMethod "getName" o = WebsiteDataGetNameMethodInfo
    ResolveWebsiteDataMethod "getSize" o = WebsiteDataGetSizeMethodInfo
    ResolveWebsiteDataMethod "getTypes" o = WebsiteDataGetTypesMethodInfo
    ResolveWebsiteDataMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveWebsiteDataMethod t WebsiteData, O.MethodInfo info WebsiteData p) => OL.IsLabel t (WebsiteData -> 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