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

-- * Exported types
    Download(..)                            ,
    DownloadK                               ,
    toDownload                              ,
    noDownload                              ,


 -- * Methods
-- ** downloadCancel
    downloadCancel                          ,


-- ** downloadGetCurrentSize
    downloadGetCurrentSize                  ,


-- ** downloadGetDestinationUri
    downloadGetDestinationUri               ,


-- ** downloadGetElapsedTime
    downloadGetElapsedTime                  ,


-- ** downloadGetNetworkRequest
    downloadGetNetworkRequest               ,


-- ** downloadGetNetworkResponse
    downloadGetNetworkResponse              ,


-- ** downloadGetProgress
    downloadGetProgress                     ,


-- ** downloadGetStatus
    downloadGetStatus                       ,


-- ** downloadGetSuggestedFilename
    downloadGetSuggestedFilename            ,


-- ** downloadGetTotalSize
    downloadGetTotalSize                    ,


-- ** downloadGetUri
    downloadGetUri                          ,


-- ** downloadNew
    downloadNew                             ,


-- ** downloadSetDestinationUri
    downloadSetDestinationUri               ,


-- ** downloadStart
    downloadStart                           ,




 -- * Properties
-- ** CurrentSize
    DownloadCurrentSizePropertyInfo         ,
    getDownloadCurrentSize                  ,


-- ** DestinationUri
    DownloadDestinationUriPropertyInfo      ,
    constructDownloadDestinationUri         ,
    getDownloadDestinationUri               ,
    setDownloadDestinationUri               ,


-- ** NetworkRequest
    DownloadNetworkRequestPropertyInfo      ,
    constructDownloadNetworkRequest         ,
    getDownloadNetworkRequest               ,


-- ** NetworkResponse
    DownloadNetworkResponsePropertyInfo     ,
    constructDownloadNetworkResponse        ,
    getDownloadNetworkResponse              ,


-- ** Progress
    DownloadProgressPropertyInfo            ,
    getDownloadProgress                     ,


-- ** Status
    DownloadStatusPropertyInfo              ,
    getDownloadStatus                       ,


-- ** SuggestedFilename
    DownloadSuggestedFilenamePropertyInfo   ,
    getDownloadSuggestedFilename            ,


-- ** TotalSize
    DownloadTotalSizePropertyInfo           ,
    getDownloadTotalSize                    ,




 -- * Signals
-- ** Error
    DownloadErrorCallback                   ,
    DownloadErrorCallbackC                  ,
    DownloadErrorSignalInfo                 ,
    afterDownloadError                      ,
    downloadErrorCallbackWrapper            ,
    downloadErrorClosure                    ,
    mkDownloadErrorCallback                 ,
    noDownloadErrorCallback                 ,
    onDownloadError                         ,




    ) 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 Download = Download (ForeignPtr Download)
foreign import ccall "webkit_download_get_type"
    c_webkit_download_get_type :: IO GType

type instance ParentTypes Download = DownloadParentTypes
type DownloadParentTypes = '[GObject.Object]

instance GObject Download where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_download_get_type
    

class GObject o => DownloadK o
instance (GObject o, IsDescendantOf Download o) => DownloadK o

toDownload :: DownloadK o => o -> IO Download
toDownload = unsafeCastTo Download

noDownload :: Maybe Download
noDownload = Nothing

-- signal Download::error
type DownloadErrorCallback =
    Int32 ->
    Int32 ->
    T.Text ->
    IO Bool

noDownloadErrorCallback :: Maybe DownloadErrorCallback
noDownloadErrorCallback = Nothing

type DownloadErrorCallbackC =
    Ptr () ->                               -- object
    Int32 ->
    Int32 ->
    CString ->
    Ptr () ->                               -- user_data
    IO CInt

foreign import ccall "wrapper"
    mkDownloadErrorCallback :: DownloadErrorCallbackC -> IO (FunPtr DownloadErrorCallbackC)

downloadErrorClosure :: DownloadErrorCallback -> IO Closure
downloadErrorClosure cb = newCClosure =<< mkDownloadErrorCallback wrapped
    where wrapped = downloadErrorCallbackWrapper cb

downloadErrorCallbackWrapper ::
    DownloadErrorCallback ->
    Ptr () ->
    Int32 ->
    Int32 ->
    CString ->
    Ptr () ->
    IO CInt
downloadErrorCallbackWrapper _cb _ error_code error_detail reason _ = do
    reason' <- cstringToText reason
    result <- _cb  error_code error_detail reason'
    let result' = (fromIntegral . fromEnum) result
    return result'

onDownloadError :: (GObject a, MonadIO m) => a -> DownloadErrorCallback -> m SignalHandlerId
onDownloadError obj cb = liftIO $ connectDownloadError obj cb SignalConnectBefore
afterDownloadError :: (GObject a, MonadIO m) => a -> DownloadErrorCallback -> m SignalHandlerId
afterDownloadError obj cb = connectDownloadError obj cb SignalConnectAfter

connectDownloadError :: (GObject a, MonadIO m) =>
                        a -> DownloadErrorCallback -> SignalConnectMode -> m SignalHandlerId
connectDownloadError obj cb after = liftIO $ do
    cb' <- mkDownloadErrorCallback (downloadErrorCallbackWrapper cb)
    connectSignalFunPtr obj "error" cb' after

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

getDownloadCurrentSize :: (MonadIO m, DownloadK o) => o -> m Word64
getDownloadCurrentSize obj = liftIO $ getObjectPropertyUInt64 obj "current-size"

data DownloadCurrentSizePropertyInfo
instance AttrInfo DownloadCurrentSizePropertyInfo where
    type AttrAllowedOps DownloadCurrentSizePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DownloadCurrentSizePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DownloadCurrentSizePropertyInfo = DownloadK
    type AttrGetType DownloadCurrentSizePropertyInfo = Word64
    type AttrLabel DownloadCurrentSizePropertyInfo = "Download::current-size"
    attrGet _ = getDownloadCurrentSize
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "destination-uri"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]

getDownloadDestinationUri :: (MonadIO m, DownloadK o) => o -> m T.Text
getDownloadDestinationUri obj = liftIO $ getObjectPropertyString obj "destination-uri"

setDownloadDestinationUri :: (MonadIO m, DownloadK o) => o -> T.Text -> m ()
setDownloadDestinationUri obj val = liftIO $ setObjectPropertyString obj "destination-uri" val

constructDownloadDestinationUri :: T.Text -> IO ([Char], GValue)
constructDownloadDestinationUri val = constructObjectPropertyString "destination-uri" val

data DownloadDestinationUriPropertyInfo
instance AttrInfo DownloadDestinationUriPropertyInfo where
    type AttrAllowedOps DownloadDestinationUriPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DownloadDestinationUriPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DownloadDestinationUriPropertyInfo = DownloadK
    type AttrGetType DownloadDestinationUriPropertyInfo = T.Text
    type AttrLabel DownloadDestinationUriPropertyInfo = "Download::destination-uri"
    attrGet _ = getDownloadDestinationUri
    attrSet _ = setDownloadDestinationUri
    attrConstruct _ = constructDownloadDestinationUri

-- VVV Prop "network-request"
   -- Type: TInterface "WebKit" "NetworkRequest"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getDownloadNetworkRequest :: (MonadIO m, DownloadK o) => o -> m NetworkRequest
getDownloadNetworkRequest obj = liftIO $ getObjectPropertyObject obj "network-request" NetworkRequest

constructDownloadNetworkRequest :: (NetworkRequestK a) => a -> IO ([Char], GValue)
constructDownloadNetworkRequest val = constructObjectPropertyObject "network-request" val

data DownloadNetworkRequestPropertyInfo
instance AttrInfo DownloadNetworkRequestPropertyInfo where
    type AttrAllowedOps DownloadNetworkRequestPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DownloadNetworkRequestPropertyInfo = NetworkRequestK
    type AttrBaseTypeConstraint DownloadNetworkRequestPropertyInfo = DownloadK
    type AttrGetType DownloadNetworkRequestPropertyInfo = NetworkRequest
    type AttrLabel DownloadNetworkRequestPropertyInfo = "Download::network-request"
    attrGet _ = getDownloadNetworkRequest
    attrSet _ = undefined
    attrConstruct _ = constructDownloadNetworkRequest

-- VVV Prop "network-response"
   -- Type: TInterface "WebKit" "NetworkResponse"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getDownloadNetworkResponse :: (MonadIO m, DownloadK o) => o -> m NetworkResponse
getDownloadNetworkResponse obj = liftIO $ getObjectPropertyObject obj "network-response" NetworkResponse

constructDownloadNetworkResponse :: (NetworkResponseK a) => a -> IO ([Char], GValue)
constructDownloadNetworkResponse val = constructObjectPropertyObject "network-response" val

data DownloadNetworkResponsePropertyInfo
instance AttrInfo DownloadNetworkResponsePropertyInfo where
    type AttrAllowedOps DownloadNetworkResponsePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DownloadNetworkResponsePropertyInfo = NetworkResponseK
    type AttrBaseTypeConstraint DownloadNetworkResponsePropertyInfo = DownloadK
    type AttrGetType DownloadNetworkResponsePropertyInfo = NetworkResponse
    type AttrLabel DownloadNetworkResponsePropertyInfo = "Download::network-response"
    attrGet _ = getDownloadNetworkResponse
    attrSet _ = undefined
    attrConstruct _ = constructDownloadNetworkResponse

-- VVV Prop "progress"
   -- Type: TBasicType TDouble
   -- Flags: [PropertyReadable]

getDownloadProgress :: (MonadIO m, DownloadK o) => o -> m Double
getDownloadProgress obj = liftIO $ getObjectPropertyDouble obj "progress"

data DownloadProgressPropertyInfo
instance AttrInfo DownloadProgressPropertyInfo where
    type AttrAllowedOps DownloadProgressPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DownloadProgressPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DownloadProgressPropertyInfo = DownloadK
    type AttrGetType DownloadProgressPropertyInfo = Double
    type AttrLabel DownloadProgressPropertyInfo = "Download::progress"
    attrGet _ = getDownloadProgress
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "status"
   -- Type: TInterface "WebKit" "DownloadStatus"
   -- Flags: [PropertyReadable]

getDownloadStatus :: (MonadIO m, DownloadK o) => o -> m DownloadStatus
getDownloadStatus obj = liftIO $ getObjectPropertyEnum obj "status"

data DownloadStatusPropertyInfo
instance AttrInfo DownloadStatusPropertyInfo where
    type AttrAllowedOps DownloadStatusPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DownloadStatusPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DownloadStatusPropertyInfo = DownloadK
    type AttrGetType DownloadStatusPropertyInfo = DownloadStatus
    type AttrLabel DownloadStatusPropertyInfo = "Download::status"
    attrGet _ = getDownloadStatus
    attrSet _ = undefined
    attrConstruct _ = undefined

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

getDownloadSuggestedFilename :: (MonadIO m, DownloadK o) => o -> m T.Text
getDownloadSuggestedFilename obj = liftIO $ getObjectPropertyString obj "suggested-filename"

data DownloadSuggestedFilenamePropertyInfo
instance AttrInfo DownloadSuggestedFilenamePropertyInfo where
    type AttrAllowedOps DownloadSuggestedFilenamePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DownloadSuggestedFilenamePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DownloadSuggestedFilenamePropertyInfo = DownloadK
    type AttrGetType DownloadSuggestedFilenamePropertyInfo = T.Text
    type AttrLabel DownloadSuggestedFilenamePropertyInfo = "Download::suggested-filename"
    attrGet _ = getDownloadSuggestedFilename
    attrSet _ = undefined
    attrConstruct _ = undefined

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

getDownloadTotalSize :: (MonadIO m, DownloadK o) => o -> m Word64
getDownloadTotalSize obj = liftIO $ getObjectPropertyUInt64 obj "total-size"

data DownloadTotalSizePropertyInfo
instance AttrInfo DownloadTotalSizePropertyInfo where
    type AttrAllowedOps DownloadTotalSizePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DownloadTotalSizePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DownloadTotalSizePropertyInfo = DownloadK
    type AttrGetType DownloadTotalSizePropertyInfo = Word64
    type AttrLabel DownloadTotalSizePropertyInfo = "Download::total-size"
    attrGet _ = getDownloadTotalSize
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList Download = DownloadAttributeList
type DownloadAttributeList = ('[ '("current-size", DownloadCurrentSizePropertyInfo), '("destination-uri", DownloadDestinationUriPropertyInfo), '("network-request", DownloadNetworkRequestPropertyInfo), '("network-response", DownloadNetworkResponsePropertyInfo), '("progress", DownloadProgressPropertyInfo), '("status", DownloadStatusPropertyInfo), '("suggested-filename", DownloadSuggestedFilenamePropertyInfo), '("total-size", DownloadTotalSizePropertyInfo)] :: [(Symbol, *)])

data DownloadErrorSignalInfo
instance SignalInfo DownloadErrorSignalInfo where
    type HaskellCallbackType DownloadErrorSignalInfo = DownloadErrorCallback
    connectSignal _ = connectDownloadError

type instance SignalList Download = DownloadSignalList
type DownloadSignalList = ('[ '("error", DownloadErrorSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method Download::new
-- method type : Constructor
-- Args : [Arg {argName = "request", argType = TInterface "WebKit" "NetworkRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "request", argType = TInterface "WebKit" "NetworkRequest", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit" "Download"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_download_new" webkit_download_new :: 
    Ptr NetworkRequest ->                   -- request : TInterface "WebKit" "NetworkRequest"
    IO (Ptr Download)


downloadNew ::
    (MonadIO m, NetworkRequestK a) =>
    a ->                                    -- request
    m Download
downloadNew request = liftIO $ do
    let request' = unsafeManagedPtrCastPtr request
    result <- webkit_download_new request'
    checkUnexpectedReturnNULL "webkit_download_new" result
    result' <- (wrapObject Download) result
    touchManagedPtr request
    return result'

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

foreign import ccall "webkit_download_cancel" webkit_download_cancel :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO ()


downloadCancel ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m ()
downloadCancel _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    webkit_download_cancel _obj'
    touchManagedPtr _obj
    return ()

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

foreign import ccall "webkit_download_get_current_size" webkit_download_get_current_size :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO Word64


downloadGetCurrentSize ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m Word64
downloadGetCurrentSize _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_download_get_current_size _obj'
    touchManagedPtr _obj
    return result

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

foreign import ccall "webkit_download_get_destination_uri" webkit_download_get_destination_uri :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO CString


downloadGetDestinationUri ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m T.Text
downloadGetDestinationUri _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_download_get_destination_uri _obj'
    checkUnexpectedReturnNULL "webkit_download_get_destination_uri" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_download_get_elapsed_time" webkit_download_get_elapsed_time :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO CDouble


downloadGetElapsedTime ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m Double
downloadGetElapsedTime _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_download_get_elapsed_time _obj'
    let result' = realToFrac result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_download_get_network_request" webkit_download_get_network_request :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO (Ptr NetworkRequest)


downloadGetNetworkRequest ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m NetworkRequest
downloadGetNetworkRequest _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_download_get_network_request _obj'
    checkUnexpectedReturnNULL "webkit_download_get_network_request" result
    result' <- (newObject NetworkRequest) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_download_get_network_response" webkit_download_get_network_response :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO (Ptr NetworkResponse)


downloadGetNetworkResponse ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m NetworkResponse
downloadGetNetworkResponse _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_download_get_network_response _obj'
    checkUnexpectedReturnNULL "webkit_download_get_network_response" result
    result' <- (newObject NetworkResponse) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_download_get_progress" webkit_download_get_progress :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO CDouble


downloadGetProgress ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m Double
downloadGetProgress _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_download_get_progress _obj'
    let result' = realToFrac result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_download_get_status" webkit_download_get_status :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO CUInt


downloadGetStatus ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m DownloadStatus
downloadGetStatus _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_download_get_status _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_download_get_suggested_filename" webkit_download_get_suggested_filename :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO CString


downloadGetSuggestedFilename ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m T.Text
downloadGetSuggestedFilename _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_download_get_suggested_filename _obj'
    checkUnexpectedReturnNULL "webkit_download_get_suggested_filename" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_download_get_total_size" webkit_download_get_total_size :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO Word64


downloadGetTotalSize ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m Word64
downloadGetTotalSize _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_download_get_total_size _obj'
    touchManagedPtr _obj
    return result

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

foreign import ccall "webkit_download_get_uri" webkit_download_get_uri :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO CString


downloadGetUri ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m T.Text
downloadGetUri _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_download_get_uri _obj'
    checkUnexpectedReturnNULL "webkit_download_get_uri" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_download_set_destination_uri" webkit_download_set_destination_uri :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    CString ->                              -- destination_uri : TBasicType TUTF8
    IO ()


downloadSetDestinationUri ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- destination_uri
    m ()
downloadSetDestinationUri _obj destination_uri = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    destination_uri' <- textToCString destination_uri
    webkit_download_set_destination_uri _obj' destination_uri'
    touchManagedPtr _obj
    freeMem destination_uri'
    return ()

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

foreign import ccall "webkit_download_start" webkit_download_start :: 
    Ptr Download ->                         -- _obj : TInterface "WebKit" "Download"
    IO ()


downloadStart ::
    (MonadIO m, DownloadK a) =>
    a ->                                    -- _obj
    m ()
downloadStart _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    webkit_download_start _obj'
    touchManagedPtr _obj
    return ()