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

-- * Exported types
    DOMBlob(..)                             ,
    DOMBlobK                                ,
    toDOMBlob                               ,
    noDOMBlob                               ,


 -- * Methods
-- ** dOMBlobGetSize
    dOMBlobGetSize                          ,


-- ** dOMBlobSlice
    dOMBlobSlice                            ,


-- ** dOMBlobWebkitSlice
    dOMBlobWebkitSlice                      ,




 -- * Properties
-- ** Size
    DOMBlobSizePropertyInfo                 ,
    getDOMBlobSize                          ,


-- ** Type
    DOMBlobTypePropertyInfo                 ,
    getDOMBlobType                          ,




    ) 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 DOMBlob = DOMBlob (ForeignPtr DOMBlob)
foreign import ccall "webkit_dom_blob_get_type"
    c_webkit_dom_blob_get_type :: IO GType

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

instance GObject DOMBlob where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_blob_get_type
    

class GObject o => DOMBlobK o
instance (GObject o, IsDescendantOf DOMBlob o) => DOMBlobK o

toDOMBlob :: DOMBlobK o => o -> IO DOMBlob
toDOMBlob = unsafeCastTo DOMBlob

noDOMBlob :: Maybe DOMBlob
noDOMBlob = Nothing

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

getDOMBlobSize :: (MonadIO m, DOMBlobK o) => o -> m Word64
getDOMBlobSize obj = liftIO $ getObjectPropertyUInt64 obj "size"

data DOMBlobSizePropertyInfo
instance AttrInfo DOMBlobSizePropertyInfo where
    type AttrAllowedOps DOMBlobSizePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMBlobSizePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMBlobSizePropertyInfo = DOMBlobK
    type AttrGetType DOMBlobSizePropertyInfo = Word64
    type AttrLabel DOMBlobSizePropertyInfo = "DOMBlob::size"
    attrGet _ = getDOMBlobSize
    attrSet _ = undefined
    attrConstruct _ = undefined

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

getDOMBlobType :: (MonadIO m, DOMBlobK o) => o -> m T.Text
getDOMBlobType obj = liftIO $ getObjectPropertyString obj "type"

data DOMBlobTypePropertyInfo
instance AttrInfo DOMBlobTypePropertyInfo where
    type AttrAllowedOps DOMBlobTypePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMBlobTypePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMBlobTypePropertyInfo = DOMBlobK
    type AttrGetType DOMBlobTypePropertyInfo = T.Text
    type AttrLabel DOMBlobTypePropertyInfo = "DOMBlob::type"
    attrGet _ = getDOMBlobType
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMBlob = DOMBlobAttributeList
type DOMBlobAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("size", DOMBlobSizePropertyInfo), '("type", DOMBlobTypePropertyInfo)] :: [(Symbol, *)])

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

-- method DOMBlob::get_size
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMBlob", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMBlob", 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_blob_get_size" webkit_dom_blob_get_size :: 
    Ptr DOMBlob ->                          -- _obj : TInterface "WebKit" "DOMBlob"
    IO Word64


dOMBlobGetSize ::
    (MonadIO m, DOMBlobK a) =>
    a ->                                    -- _obj
    m Word64
dOMBlobGetSize _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_blob_get_size _obj'
    touchManagedPtr _obj
    return result

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

foreign import ccall "webkit_dom_blob_slice" webkit_dom_blob_slice :: 
    Ptr DOMBlob ->                          -- _obj : TInterface "WebKit" "DOMBlob"
    Int64 ->                                -- start : TBasicType TInt64
    Int64 ->                                -- end : TBasicType TInt64
    CString ->                              -- contentType : TBasicType TUTF8
    IO (Ptr DOMBlob)


dOMBlobSlice ::
    (MonadIO m, DOMBlobK a) =>
    a ->                                    -- _obj
    Int64 ->                                -- start
    Int64 ->                                -- end
    T.Text ->                               -- contentType
    m DOMBlob
dOMBlobSlice _obj start end contentType = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    contentType' <- textToCString contentType
    result <- webkit_dom_blob_slice _obj' start end contentType'
    checkUnexpectedReturnNULL "webkit_dom_blob_slice" result
    result' <- (wrapObject DOMBlob) result
    touchManagedPtr _obj
    freeMem contentType'
    return result'

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

foreign import ccall "webkit_dom_blob_webkit_slice" webkit_dom_blob_webkit_slice :: 
    Ptr DOMBlob ->                          -- _obj : TInterface "WebKit" "DOMBlob"
    Int64 ->                                -- start : TBasicType TInt64
    Int64 ->                                -- end : TBasicType TInt64
    CString ->                              -- content_type : TBasicType TUTF8
    IO (Ptr DOMBlob)

{-# DEPRECATED dOMBlobWebkitSlice ["(Since version 1.10)","Use webkit_dom_blob_slice() instead."]#-}
dOMBlobWebkitSlice ::
    (MonadIO m, DOMBlobK a) =>
    a ->                                    -- _obj
    Int64 ->                                -- start
    Int64 ->                                -- end
    T.Text ->                               -- content_type
    m DOMBlob
dOMBlobWebkitSlice _obj start end content_type = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    content_type' <- textToCString content_type
    result <- webkit_dom_blob_webkit_slice _obj' start end content_type'
    checkUnexpectedReturnNULL "webkit_dom_blob_webkit_slice" result
    result' <- (newObject DOMBlob) result
    touchManagedPtr _obj
    freeMem content_type'
    return result'