{- |
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.WebKit.Objects.DOMFile
    ( 

-- * Exported types
    DOMFile(..)                             ,
    DOMFileK                                ,
    toDOMFile                               ,
    noDOMFile                               ,


 -- * Methods
-- ** dOMFileGetName
    dOMFileGetName                          ,


-- ** dOMFileGetWebkitRelativePath
    dOMFileGetWebkitRelativePath            ,




 -- * Properties
-- ** Name
    DOMFileNamePropertyInfo                 ,
    getDOMFileName                          ,


-- ** WebkitRelativePath
    DOMFileWebkitRelativePathPropertyInfo   ,
    getDOMFileWebkitRelativePath            ,




    ) 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.WebKit.Types
import GI.WebKit.Callbacks
import qualified GI.GObject as GObject

newtype DOMFile = DOMFile (ForeignPtr DOMFile)
foreign import ccall "webkit_dom_file_get_type"
    c_webkit_dom_file_get_type :: IO GType

type instance ParentTypes DOMFile = DOMFileParentTypes
type DOMFileParentTypes = '[DOMBlob, DOMObject, GObject.Object]

instance GObject DOMFile where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_file_get_type
    

class GObject o => DOMFileK o
instance (GObject o, IsDescendantOf DOMFile o) => DOMFileK o

toDOMFile :: DOMFileK o => o -> IO DOMFile
toDOMFile = unsafeCastTo DOMFile

noDOMFile :: Maybe DOMFile
noDOMFile = Nothing

-- VVV Prop "name"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]

getDOMFileName :: (MonadIO m, DOMFileK o) => o -> m T.Text
getDOMFileName obj = liftIO $ getObjectPropertyString obj "name"

data DOMFileNamePropertyInfo
instance AttrInfo DOMFileNamePropertyInfo where
    type AttrAllowedOps DOMFileNamePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMFileNamePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMFileNamePropertyInfo = DOMFileK
    type AttrGetType DOMFileNamePropertyInfo = T.Text
    type AttrLabel DOMFileNamePropertyInfo = "DOMFile::name"
    attrGet _ = getDOMFileName
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "webkit-relative-path"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]

getDOMFileWebkitRelativePath :: (MonadIO m, DOMFileK o) => o -> m T.Text
getDOMFileWebkitRelativePath obj = liftIO $ getObjectPropertyString obj "webkit-relative-path"

data DOMFileWebkitRelativePathPropertyInfo
instance AttrInfo DOMFileWebkitRelativePathPropertyInfo where
    type AttrAllowedOps DOMFileWebkitRelativePathPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMFileWebkitRelativePathPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMFileWebkitRelativePathPropertyInfo = DOMFileK
    type AttrGetType DOMFileWebkitRelativePathPropertyInfo = T.Text
    type AttrLabel DOMFileWebkitRelativePathPropertyInfo = "DOMFile::webkit-relative-path"
    attrGet _ = getDOMFileWebkitRelativePath
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMFile = DOMFileAttributeList
type DOMFileAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("name", DOMFileNamePropertyInfo), '("size", DOMBlobSizePropertyInfo), '("type", DOMBlobTypePropertyInfo), '("webkit-relative-path", DOMFileWebkitRelativePathPropertyInfo)] :: [(Symbol, *)])

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

-- method DOMFile::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMFile", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMFile", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_file_get_name" webkit_dom_file_get_name :: 
    Ptr DOMFile ->                          -- _obj : TInterface "WebKit" "DOMFile"
    IO CString


dOMFileGetName ::
    (MonadIO m, DOMFileK a) =>
    a ->                                    -- _obj
    m T.Text
dOMFileGetName _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_file_get_name _obj'
    checkUnexpectedReturnNULL "webkit_dom_file_get_name" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    return result'

-- method DOMFile::get_webkit_relative_path
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMFile", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMFile", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_file_get_webkit_relative_path" webkit_dom_file_get_webkit_relative_path :: 
    Ptr DOMFile ->                          -- _obj : TInterface "WebKit" "DOMFile"
    IO CString


dOMFileGetWebkitRelativePath ::
    (MonadIO m, DOMFileK a) =>
    a ->                                    -- _obj
    m T.Text
dOMFileGetWebkitRelativePath _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_file_get_webkit_relative_path _obj'
    checkUnexpectedReturnNULL "webkit_dom_file_get_webkit_relative_path" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    return result'