{- |
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.WebKit2WebExtension.Objects.DOMMediaList
    ( 

-- * Exported types
    DOMMediaList(..)                        ,
    DOMMediaListK                           ,
    toDOMMediaList                          ,
    noDOMMediaList                          ,


 -- * Methods
-- ** dOMMediaListAppendMedium
    dOMMediaListAppendMedium                ,


-- ** dOMMediaListDeleteMedium
    dOMMediaListDeleteMedium                ,


-- ** dOMMediaListGetLength
    dOMMediaListGetLength                   ,


-- ** dOMMediaListGetMediaText
    dOMMediaListGetMediaText                ,


-- ** dOMMediaListItem
    dOMMediaListItem                        ,


-- ** dOMMediaListSetMediaText
    dOMMediaListSetMediaText                ,




 -- * Properties
-- ** Length
    DOMMediaListLengthPropertyInfo          ,
    getDOMMediaListLength                   ,


-- ** MediaText
    DOMMediaListMediaTextPropertyInfo       ,
    constructDOMMediaListMediaText          ,
    getDOMMediaListMediaText                ,
    setDOMMediaListMediaText                ,




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

newtype DOMMediaList = DOMMediaList (ForeignPtr DOMMediaList)
foreign import ccall "webkit_dom_media_list_get_type"
    c_webkit_dom_media_list_get_type :: IO GType

type instance ParentTypes DOMMediaList = DOMMediaListParentTypes
type DOMMediaListParentTypes = '[DOMObject, GObject.Object]

instance GObject DOMMediaList where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_media_list_get_type
    

class GObject o => DOMMediaListK o
instance (GObject o, IsDescendantOf DOMMediaList o) => DOMMediaListK o

toDOMMediaList :: DOMMediaListK o => o -> IO DOMMediaList
toDOMMediaList = unsafeCastTo DOMMediaList

noDOMMediaList :: Maybe DOMMediaList
noDOMMediaList = Nothing

-- VVV Prop "length"
   -- Type: TBasicType TUInt64
   -- Flags: [PropertyReadable]

getDOMMediaListLength :: (MonadIO m, DOMMediaListK o) => o -> m Word64
getDOMMediaListLength obj = liftIO $ getObjectPropertyUInt64 obj "length"

data DOMMediaListLengthPropertyInfo
instance AttrInfo DOMMediaListLengthPropertyInfo where
    type AttrAllowedOps DOMMediaListLengthPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMMediaListLengthPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMMediaListLengthPropertyInfo = DOMMediaListK
    type AttrGetType DOMMediaListLengthPropertyInfo = Word64
    type AttrLabel DOMMediaListLengthPropertyInfo = "DOMMediaList::length"
    attrGet _ = getDOMMediaListLength
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "media-text"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]

getDOMMediaListMediaText :: (MonadIO m, DOMMediaListK o) => o -> m T.Text
getDOMMediaListMediaText obj = liftIO $ getObjectPropertyString obj "media-text"

setDOMMediaListMediaText :: (MonadIO m, DOMMediaListK o) => o -> T.Text -> m ()
setDOMMediaListMediaText obj val = liftIO $ setObjectPropertyString obj "media-text" val

constructDOMMediaListMediaText :: T.Text -> IO ([Char], GValue)
constructDOMMediaListMediaText val = constructObjectPropertyString "media-text" val

data DOMMediaListMediaTextPropertyInfo
instance AttrInfo DOMMediaListMediaTextPropertyInfo where
    type AttrAllowedOps DOMMediaListMediaTextPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DOMMediaListMediaTextPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DOMMediaListMediaTextPropertyInfo = DOMMediaListK
    type AttrGetType DOMMediaListMediaTextPropertyInfo = T.Text
    type AttrLabel DOMMediaListMediaTextPropertyInfo = "DOMMediaList::media-text"
    attrGet _ = getDOMMediaListMediaText
    attrSet _ = setDOMMediaListMediaText
    attrConstruct _ = constructDOMMediaListMediaText

type instance AttributeList DOMMediaList = DOMMediaListAttributeList
type DOMMediaListAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("length", DOMMediaListLengthPropertyInfo), '("media-text", DOMMediaListMediaTextPropertyInfo)] :: [(Symbol, *)])

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

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

foreign import ccall "webkit_dom_media_list_append_medium" webkit_dom_media_list_append_medium :: 
    Ptr DOMMediaList ->                     -- _obj : TInterface "WebKit2WebExtension" "DOMMediaList"
    CString ->                              -- newMedium : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()


dOMMediaListAppendMedium ::
    (MonadIO m, DOMMediaListK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- newMedium
    m ()
dOMMediaListAppendMedium _obj newMedium = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    newMedium' <- textToCString newMedium
    onException (do
        propagateGError $ webkit_dom_media_list_append_medium _obj' newMedium'
        touchManagedPtr _obj
        freeMem newMedium'
        return ()
     ) (do
        freeMem newMedium'
     )

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

foreign import ccall "webkit_dom_media_list_delete_medium" webkit_dom_media_list_delete_medium :: 
    Ptr DOMMediaList ->                     -- _obj : TInterface "WebKit2WebExtension" "DOMMediaList"
    CString ->                              -- oldMedium : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()


dOMMediaListDeleteMedium ::
    (MonadIO m, DOMMediaListK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- oldMedium
    m ()
dOMMediaListDeleteMedium _obj oldMedium = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    oldMedium' <- textToCString oldMedium
    onException (do
        propagateGError $ webkit_dom_media_list_delete_medium _obj' oldMedium'
        touchManagedPtr _obj
        freeMem oldMedium'
        return ()
     ) (do
        freeMem oldMedium'
     )

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

foreign import ccall "webkit_dom_media_list_get_length" webkit_dom_media_list_get_length :: 
    Ptr DOMMediaList ->                     -- _obj : TInterface "WebKit2WebExtension" "DOMMediaList"
    IO Word64


dOMMediaListGetLength ::
    (MonadIO m, DOMMediaListK a) =>
    a ->                                    -- _obj
    m Word64
dOMMediaListGetLength _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_media_list_get_length _obj'
    touchManagedPtr _obj
    return result

-- method DOMMediaList::get_media_text
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMMediaList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMMediaList", 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_media_list_get_media_text" webkit_dom_media_list_get_media_text :: 
    Ptr DOMMediaList ->                     -- _obj : TInterface "WebKit2WebExtension" "DOMMediaList"
    IO CString


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

-- method DOMMediaList::item
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMMediaList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMMediaList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index", argType = TBasicType TUInt64, 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_media_list_item" webkit_dom_media_list_item :: 
    Ptr DOMMediaList ->                     -- _obj : TInterface "WebKit2WebExtension" "DOMMediaList"
    Word64 ->                               -- index : TBasicType TUInt64
    IO CString


dOMMediaListItem ::
    (MonadIO m, DOMMediaListK a) =>
    a ->                                    -- _obj
    Word64 ->                               -- index
    m T.Text
dOMMediaListItem _obj index = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_media_list_item _obj' index
    checkUnexpectedReturnNULL "webkit_dom_media_list_item" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_dom_media_list_set_media_text" webkit_dom_media_list_set_media_text :: 
    Ptr DOMMediaList ->                     -- _obj : TInterface "WebKit2WebExtension" "DOMMediaList"
    CString ->                              -- value : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()


dOMMediaListSetMediaText ::
    (MonadIO m, DOMMediaListK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- value
    m ()
dOMMediaListSetMediaText _obj value = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    value' <- textToCString value
    onException (do
        propagateGError $ webkit_dom_media_list_set_media_text _obj' value'
        touchManagedPtr _obj
        freeMem value'
        return ()
     ) (do
        freeMem value'
     )