{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

'GI.WebKit.Objects.Download.Download' carries information about a download request,
including a 'GI.WebKit.Objects.NetworkRequest.NetworkRequest' object. The application may use
this object to control the download process, or to simply figure
out what is to be downloaded, and do it itself.
-}

module GI.WebKit.Objects.Download
    ( 

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


 -- * Methods
-- ** cancel #method:cancel#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadCancelMethodInfo                ,
#endif
    downloadCancel                          ,


-- ** getCurrentSize #method:getCurrentSize#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadGetCurrentSizeMethodInfo        ,
#endif
    downloadGetCurrentSize                  ,


-- ** getDestinationUri #method:getDestinationUri#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadGetDestinationUriMethodInfo     ,
#endif
    downloadGetDestinationUri               ,


-- ** getElapsedTime #method:getElapsedTime#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadGetElapsedTimeMethodInfo        ,
#endif
    downloadGetElapsedTime                  ,


-- ** getNetworkRequest #method:getNetworkRequest#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadGetNetworkRequestMethodInfo     ,
#endif
    downloadGetNetworkRequest               ,


-- ** getNetworkResponse #method:getNetworkResponse#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadGetNetworkResponseMethodInfo    ,
#endif
    downloadGetNetworkResponse              ,


-- ** getProgress #method:getProgress#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadGetProgressMethodInfo           ,
#endif
    downloadGetProgress                     ,


-- ** getStatus #method:getStatus#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadGetStatusMethodInfo             ,
#endif
    downloadGetStatus                       ,


-- ** getSuggestedFilename #method:getSuggestedFilename#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadGetSuggestedFilenameMethodInfo  ,
#endif
    downloadGetSuggestedFilename            ,


-- ** getTotalSize #method:getTotalSize#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadGetTotalSizeMethodInfo          ,
#endif
    downloadGetTotalSize                    ,


-- ** getUri #method:getUri#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadGetUriMethodInfo                ,
#endif
    downloadGetUri                          ,


-- ** new #method:new#
    downloadNew                             ,


-- ** setDestinationUri #method:setDestinationUri#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadSetDestinationUriMethodInfo     ,
#endif
    downloadSetDestinationUri               ,


-- ** start #method:start#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadStartMethodInfo                 ,
#endif
    downloadStart                           ,




 -- * Properties
-- ** currentSize #attr:currentSize#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadCurrentSizePropertyInfo         ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    downloadCurrentSize                     ,
#endif
    getDownloadCurrentSize                  ,


-- ** destinationUri #attr:destinationUri#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadDestinationUriPropertyInfo      ,
#endif
    constructDownloadDestinationUri         ,
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    downloadDestinationUri                  ,
#endif
    getDownloadDestinationUri               ,
    setDownloadDestinationUri               ,


-- ** networkRequest #attr:networkRequest#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadNetworkRequestPropertyInfo      ,
#endif
    constructDownloadNetworkRequest         ,
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    downloadNetworkRequest                  ,
#endif
    getDownloadNetworkRequest               ,


-- ** networkResponse #attr:networkResponse#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadNetworkResponsePropertyInfo     ,
#endif
    constructDownloadNetworkResponse        ,
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    downloadNetworkResponse                 ,
#endif
    getDownloadNetworkResponse              ,


-- ** progress #attr:progress#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadProgressPropertyInfo            ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    downloadProgress                        ,
#endif
    getDownloadProgress                     ,


-- ** status #attr:status#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadStatusPropertyInfo              ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    downloadStatus                          ,
#endif
    getDownloadStatus                       ,


-- ** suggestedFilename #attr:suggestedFilename#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadSuggestedFilenamePropertyInfo   ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    downloadSuggestedFilename               ,
#endif
    getDownloadSuggestedFilename            ,


-- ** totalSize #attr:totalSize#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadTotalSizePropertyInfo           ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    downloadTotalSize                       ,
#endif
    getDownloadTotalSize                    ,




 -- * Signals
-- ** error #signal:error#
    C_DownloadErrorCallback                 ,
    DownloadErrorCallback                   ,
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DownloadErrorSignalInfo                 ,
#endif
    afterDownloadError                      ,
    genClosure_DownloadError                ,
    mk_DownloadErrorCallback                ,
    noDownloadErrorCallback                 ,
    onDownloadError                         ,
    wrap_DownloadErrorCallback              ,




    ) 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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.WebKit.Enums as WebKit.Enums
import {-# SOURCE #-} qualified GI.WebKit.Objects.NetworkRequest as WebKit.NetworkRequest
import {-# SOURCE #-} qualified GI.WebKit.Objects.NetworkResponse as WebKit.NetworkResponse

newtype Download = Download (ManagedPtr Download)
foreign import ccall "webkit_download_get_type"
    c_webkit_download_get_type :: IO GType

instance GObject Download where
    gobjectType _ = c_webkit_download_get_type
    

class GObject o => IsDownload o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Download a) =>
    IsDownload a
#endif
instance IsDownload Download
instance GObject.Object.IsObject Download

toDownload :: (MonadIO m, IsDownload o) => o -> m Download
toDownload = liftIO . unsafeCastTo Download

noDownload :: Maybe Download
noDownload = Nothing

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveDownloadMethod (t :: Symbol) (o :: *) :: * where
    ResolveDownloadMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDownloadMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDownloadMethod "cancel" o = DownloadCancelMethodInfo
    ResolveDownloadMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDownloadMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDownloadMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDownloadMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDownloadMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDownloadMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDownloadMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDownloadMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveDownloadMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveDownloadMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDownloadMethod "start" o = DownloadStartMethodInfo
    ResolveDownloadMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDownloadMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDownloadMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDownloadMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDownloadMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDownloadMethod "getCurrentSize" o = DownloadGetCurrentSizeMethodInfo
    ResolveDownloadMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDownloadMethod "getDestinationUri" o = DownloadGetDestinationUriMethodInfo
    ResolveDownloadMethod "getElapsedTime" o = DownloadGetElapsedTimeMethodInfo
    ResolveDownloadMethod "getNetworkRequest" o = DownloadGetNetworkRequestMethodInfo
    ResolveDownloadMethod "getNetworkResponse" o = DownloadGetNetworkResponseMethodInfo
    ResolveDownloadMethod "getProgress" o = DownloadGetProgressMethodInfo
    ResolveDownloadMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDownloadMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDownloadMethod "getStatus" o = DownloadGetStatusMethodInfo
    ResolveDownloadMethod "getSuggestedFilename" o = DownloadGetSuggestedFilenameMethodInfo
    ResolveDownloadMethod "getTotalSize" o = DownloadGetTotalSizeMethodInfo
    ResolveDownloadMethod "getUri" o = DownloadGetUriMethodInfo
    ResolveDownloadMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDownloadMethod "setDestinationUri" o = DownloadSetDestinationUriMethodInfo
    ResolveDownloadMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDownloadMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDownloadMethod t Download, O.MethodInfo info Download p) => O.IsLabelProxy t (Download -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDownloadMethod t Download, O.MethodInfo info Download p) => O.IsLabel t (Download -> 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

#endif

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

noDownloadErrorCallback :: Maybe DownloadErrorCallback
noDownloadErrorCallback = Nothing

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

foreign import ccall "wrapper"
    mk_DownloadErrorCallback :: C_DownloadErrorCallback -> IO (FunPtr C_DownloadErrorCallback)

genClosure_DownloadError :: DownloadErrorCallback -> IO Closure
genClosure_DownloadError cb = do
    let cb' = wrap_DownloadErrorCallback cb
    mk_DownloadErrorCallback cb' >>= newCClosure


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


onDownloadError :: (IsDownload a, MonadIO m) => a -> DownloadErrorCallback -> m SignalHandlerId
onDownloadError obj cb = liftIO $ do
    let cb' = wrap_DownloadErrorCallback cb
    cb'' <- mk_DownloadErrorCallback cb'
    connectSignalFunPtr obj "error" cb'' SignalConnectBefore

afterDownloadError :: (IsDownload a, MonadIO m) => a -> DownloadErrorCallback -> m SignalHandlerId
afterDownloadError obj cb = liftIO $ do
    let cb' = wrap_DownloadErrorCallback cb
    cb'' <- mk_DownloadErrorCallback cb'
    connectSignalFunPtr obj "error" cb'' SignalConnectAfter


-- VVV Prop "current-size"
   -- Type: TBasicType TUInt64
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

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

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadCurrentSizePropertyInfo
instance AttrInfo DownloadCurrentSizePropertyInfo where
    type AttrAllowedOps DownloadCurrentSizePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DownloadCurrentSizePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DownloadCurrentSizePropertyInfo = IsDownload
    type AttrGetType DownloadCurrentSizePropertyInfo = Word64
    type AttrLabel DownloadCurrentSizePropertyInfo = "current-size"
    type AttrOrigin DownloadCurrentSizePropertyInfo = Download
    attrGet _ = getDownloadCurrentSize
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

-- VVV Prop "destination-uri"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just False)

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

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

constructDownloadDestinationUri :: (IsDownload o) => T.Text -> IO (GValueConstruct o)
constructDownloadDestinationUri val = constructObjectPropertyString "destination-uri" (Just val)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadDestinationUriPropertyInfo
instance AttrInfo DownloadDestinationUriPropertyInfo where
    type AttrAllowedOps DownloadDestinationUriPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DownloadDestinationUriPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DownloadDestinationUriPropertyInfo = IsDownload
    type AttrGetType DownloadDestinationUriPropertyInfo = T.Text
    type AttrLabel DownloadDestinationUriPropertyInfo = "destination-uri"
    type AttrOrigin DownloadDestinationUriPropertyInfo = Download
    attrGet _ = getDownloadDestinationUri
    attrSet _ = setDownloadDestinationUri
    attrConstruct _ = constructDownloadDestinationUri
    attrClear _ = undefined
#endif

-- VVV Prop "network-request"
   -- Type: TInterface (Name {namespace = "WebKit", name = "NetworkRequest"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getDownloadNetworkRequest :: (MonadIO m, IsDownload o) => o -> m WebKit.NetworkRequest.NetworkRequest
getDownloadNetworkRequest obj = liftIO $ checkUnexpectedNothing "getDownloadNetworkRequest" $ getObjectPropertyObject obj "network-request" WebKit.NetworkRequest.NetworkRequest

constructDownloadNetworkRequest :: (IsDownload o, WebKit.NetworkRequest.IsNetworkRequest a) => a -> IO (GValueConstruct o)
constructDownloadNetworkRequest val = constructObjectPropertyObject "network-request" (Just val)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadNetworkRequestPropertyInfo
instance AttrInfo DownloadNetworkRequestPropertyInfo where
    type AttrAllowedOps DownloadNetworkRequestPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DownloadNetworkRequestPropertyInfo = WebKit.NetworkRequest.IsNetworkRequest
    type AttrBaseTypeConstraint DownloadNetworkRequestPropertyInfo = IsDownload
    type AttrGetType DownloadNetworkRequestPropertyInfo = WebKit.NetworkRequest.NetworkRequest
    type AttrLabel DownloadNetworkRequestPropertyInfo = "network-request"
    type AttrOrigin DownloadNetworkRequestPropertyInfo = Download
    attrGet _ = getDownloadNetworkRequest
    attrSet _ = undefined
    attrConstruct _ = constructDownloadNetworkRequest
    attrClear _ = undefined
#endif

-- VVV Prop "network-response"
   -- Type: TInterface (Name {namespace = "WebKit", name = "NetworkResponse"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getDownloadNetworkResponse :: (MonadIO m, IsDownload o) => o -> m WebKit.NetworkResponse.NetworkResponse
getDownloadNetworkResponse obj = liftIO $ checkUnexpectedNothing "getDownloadNetworkResponse" $ getObjectPropertyObject obj "network-response" WebKit.NetworkResponse.NetworkResponse

constructDownloadNetworkResponse :: (IsDownload o, WebKit.NetworkResponse.IsNetworkResponse a) => a -> IO (GValueConstruct o)
constructDownloadNetworkResponse val = constructObjectPropertyObject "network-response" (Just val)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadNetworkResponsePropertyInfo
instance AttrInfo DownloadNetworkResponsePropertyInfo where
    type AttrAllowedOps DownloadNetworkResponsePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DownloadNetworkResponsePropertyInfo = WebKit.NetworkResponse.IsNetworkResponse
    type AttrBaseTypeConstraint DownloadNetworkResponsePropertyInfo = IsDownload
    type AttrGetType DownloadNetworkResponsePropertyInfo = WebKit.NetworkResponse.NetworkResponse
    type AttrLabel DownloadNetworkResponsePropertyInfo = "network-response"
    type AttrOrigin DownloadNetworkResponsePropertyInfo = Download
    attrGet _ = getDownloadNetworkResponse
    attrSet _ = undefined
    attrConstruct _ = constructDownloadNetworkResponse
    attrClear _ = undefined
#endif

-- VVV Prop "progress"
   -- Type: TBasicType TDouble
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

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

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadProgressPropertyInfo
instance AttrInfo DownloadProgressPropertyInfo where
    type AttrAllowedOps DownloadProgressPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DownloadProgressPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DownloadProgressPropertyInfo = IsDownload
    type AttrGetType DownloadProgressPropertyInfo = Double
    type AttrLabel DownloadProgressPropertyInfo = "progress"
    type AttrOrigin DownloadProgressPropertyInfo = Download
    attrGet _ = getDownloadProgress
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

-- VVV Prop "status"
   -- Type: TInterface (Name {namespace = "WebKit", name = "DownloadStatus"})
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getDownloadStatus :: (MonadIO m, IsDownload o) => o -> m WebKit.Enums.DownloadStatus
getDownloadStatus obj = liftIO $ getObjectPropertyEnum obj "status"

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadStatusPropertyInfo
instance AttrInfo DownloadStatusPropertyInfo where
    type AttrAllowedOps DownloadStatusPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DownloadStatusPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DownloadStatusPropertyInfo = IsDownload
    type AttrGetType DownloadStatusPropertyInfo = WebKit.Enums.DownloadStatus
    type AttrLabel DownloadStatusPropertyInfo = "status"
    type AttrOrigin DownloadStatusPropertyInfo = Download
    attrGet _ = getDownloadStatus
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

-- VVV Prop "suggested-filename"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

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

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadSuggestedFilenamePropertyInfo
instance AttrInfo DownloadSuggestedFilenamePropertyInfo where
    type AttrAllowedOps DownloadSuggestedFilenamePropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DownloadSuggestedFilenamePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DownloadSuggestedFilenamePropertyInfo = IsDownload
    type AttrGetType DownloadSuggestedFilenamePropertyInfo = T.Text
    type AttrLabel DownloadSuggestedFilenamePropertyInfo = "suggested-filename"
    type AttrOrigin DownloadSuggestedFilenamePropertyInfo = Download
    attrGet _ = getDownloadSuggestedFilename
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

-- VVV Prop "total-size"
   -- Type: TBasicType TUInt64
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

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

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadTotalSizePropertyInfo
instance AttrInfo DownloadTotalSizePropertyInfo where
    type AttrAllowedOps DownloadTotalSizePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DownloadTotalSizePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DownloadTotalSizePropertyInfo = IsDownload
    type AttrGetType DownloadTotalSizePropertyInfo = Word64
    type AttrLabel DownloadTotalSizePropertyInfo = "total-size"
    type AttrOrigin DownloadTotalSizePropertyInfo = Download
    attrGet _ = getDownloadTotalSize
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList Download
type instance O.AttributeList Download = DownloadAttributeList
type DownloadAttributeList = ('[ '("currentSize", DownloadCurrentSizePropertyInfo), '("destinationUri", DownloadDestinationUriPropertyInfo), '("networkRequest", DownloadNetworkRequestPropertyInfo), '("networkResponse", DownloadNetworkResponsePropertyInfo), '("progress", DownloadProgressPropertyInfo), '("status", DownloadStatusPropertyInfo), '("suggestedFilename", DownloadSuggestedFilenamePropertyInfo), '("totalSize", DownloadTotalSizePropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
downloadCurrentSize :: AttrLabelProxy "currentSize"
downloadCurrentSize = AttrLabelProxy

downloadDestinationUri :: AttrLabelProxy "destinationUri"
downloadDestinationUri = AttrLabelProxy

downloadNetworkRequest :: AttrLabelProxy "networkRequest"
downloadNetworkRequest = AttrLabelProxy

downloadNetworkResponse :: AttrLabelProxy "networkResponse"
downloadNetworkResponse = AttrLabelProxy

downloadProgress :: AttrLabelProxy "progress"
downloadProgress = AttrLabelProxy

downloadStatus :: AttrLabelProxy "status"
downloadStatus = AttrLabelProxy

downloadSuggestedFilename :: AttrLabelProxy "suggestedFilename"
downloadSuggestedFilename = AttrLabelProxy

downloadTotalSize :: AttrLabelProxy "totalSize"
downloadTotalSize = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadErrorSignalInfo
instance SignalInfo DownloadErrorSignalInfo where
    type HaskellCallbackType DownloadErrorSignalInfo = DownloadErrorCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_DownloadErrorCallback cb
        cb'' <- mk_DownloadErrorCallback cb'
        connectSignalFunPtr obj "error" cb'' connectMode

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

#endif

-- method Download::new
-- method type : Constructor
-- Args : [Arg {argCName = "request", argType = TInterface (Name {namespace = "WebKit", name = "NetworkRequest"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNetworkRequest", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit", name = "Download"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_download_new" webkit_download_new :: 
    Ptr WebKit.NetworkRequest.NetworkRequest -> -- request : TInterface (Name {namespace = "WebKit", name = "NetworkRequest"})
    IO (Ptr Download)

{- |
Creates a new 'GI.WebKit.Objects.Download.Download' object for the given
'GI.WebKit.Objects.NetworkRequest.NetworkRequest' object.

@since 1.1.2
-}
downloadNew ::
    (B.CallStack.HasCallStack, MonadIO m, WebKit.NetworkRequest.IsNetworkRequest a) =>
    a
    {- ^ /@request@/: a 'GI.WebKit.Objects.NetworkRequest.NetworkRequest' -}
    -> m Download
    {- ^ __Returns:__ the new 'GI.WebKit.Objects.Download.Download' -}
downloadNew request = liftIO $ do
    request' <- unsafeManagedPtrCastPtr request
    result <- webkit_download_new request'
    checkUnexpectedReturnNULL "downloadNew" result
    result' <- (wrapObject Download) result
    touchManagedPtr request
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
#endif

-- method Download::cancel
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitDownload", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_download_cancel" webkit_download_cancel :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO ()

{- |
Cancels the download. Calling this will not free the
'GI.WebKit.Objects.Download.Download' object, so you still need to call
'GI.GObject.Objects.Object.objectUnref' on it, if you are the owner of a reference. Notice
that cancelling the download provokes the emission of the
WebKitDownload::error signal, reporting that the download was
cancelled.

@since 1.1.2
-}
downloadCancel ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: the 'GI.WebKit.Objects.Download.Download' -}
    -> m ()
downloadCancel download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    webkit_download_cancel download'
    touchManagedPtr download
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadCancelMethodInfo
instance (signature ~ (m ()), MonadIO m, IsDownload a) => O.MethodInfo DownloadCancelMethodInfo a signature where
    overloadedMethod _ = downloadCancel

#endif

-- method Download::get_current_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitDownload", 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_download_get_current_size" webkit_download_get_current_size :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO Word64

{- |
Current already downloaded size.

@since 1.1.2
-}
downloadGetCurrentSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: the 'GI.WebKit.Objects.Download.Download' -}
    -> m Word64
    {- ^ __Returns:__ the already downloaded size -}
downloadGetCurrentSize download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    result <- webkit_download_get_current_size download'
    touchManagedPtr download
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadGetCurrentSizeMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsDownload a) => O.MethodInfo DownloadGetCurrentSizeMethodInfo a signature where
    overloadedMethod _ = downloadGetCurrentSize

#endif

-- method Download::get_destination_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitDownload", 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_download_get_destination_uri" webkit_download_get_destination_uri :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO CString

{- |
Obtains the URI to which the downloaded file will be written. This
must have been set by the application before calling
'GI.WebKit.Objects.Download.downloadStart', and may be 'Nothing'.

@since 1.1.2
-}
downloadGetDestinationUri ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: the 'GI.WebKit.Objects.Download.Download' -}
    -> m T.Text
    {- ^ __Returns:__ the destination URI or 'Nothing' -}
downloadGetDestinationUri download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    result <- webkit_download_get_destination_uri download'
    checkUnexpectedReturnNULL "downloadGetDestinationUri" result
    result' <- cstringToText result
    touchManagedPtr download
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadGetDestinationUriMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDownload a) => O.MethodInfo DownloadGetDestinationUriMethodInfo a signature where
    overloadedMethod _ = downloadGetDestinationUri

#endif

-- method Download::get_elapsed_time
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitDownload", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_download_get_elapsed_time" webkit_download_get_elapsed_time :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO CDouble

{- |
Elapsed time for the download in seconds, including any fractional
part. If the download is finished, had an error or was cancelled
this is the time between its start and the event.

@since 1.1.2
-}
downloadGetElapsedTime ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: a 'GI.WebKit.Objects.Download.Download' -}
    -> m Double
    {- ^ __Returns:__ seconds since the download was started, as a @/gdouble/@ -}
downloadGetElapsedTime download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    result <- webkit_download_get_elapsed_time download'
    let result' = realToFrac result
    touchManagedPtr download
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadGetElapsedTimeMethodInfo
instance (signature ~ (m Double), MonadIO m, IsDownload a) => O.MethodInfo DownloadGetElapsedTimeMethodInfo a signature where
    overloadedMethod _ = downloadGetElapsedTime

#endif

-- method Download::get_network_request
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitDownload", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit", name = "NetworkRequest"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_download_get_network_request" webkit_download_get_network_request :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO (Ptr WebKit.NetworkRequest.NetworkRequest)

{- |
Retrieves the 'GI.WebKit.Objects.NetworkRequest.NetworkRequest' object that backs the download
process.

@since 1.1.2
-}
downloadGetNetworkRequest ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: the 'GI.WebKit.Objects.Download.Download' -}
    -> m WebKit.NetworkRequest.NetworkRequest
    {- ^ __Returns:__ the 'GI.WebKit.Objects.NetworkRequest.NetworkRequest' instance -}
downloadGetNetworkRequest download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    result <- webkit_download_get_network_request download'
    checkUnexpectedReturnNULL "downloadGetNetworkRequest" result
    result' <- (newObject WebKit.NetworkRequest.NetworkRequest) result
    touchManagedPtr download
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadGetNetworkRequestMethodInfo
instance (signature ~ (m WebKit.NetworkRequest.NetworkRequest), MonadIO m, IsDownload a) => O.MethodInfo DownloadGetNetworkRequestMethodInfo a signature where
    overloadedMethod _ = downloadGetNetworkRequest

#endif

-- method Download::get_network_response
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitDownload", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit", name = "NetworkResponse"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_download_get_network_response" webkit_download_get_network_response :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO (Ptr WebKit.NetworkResponse.NetworkResponse)

{- |
Retrieves the 'GI.WebKit.Objects.NetworkResponse.NetworkResponse' object that backs the download
process.

@since 1.1.16
-}
downloadGetNetworkResponse ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: the 'GI.WebKit.Objects.Download.Download' -}
    -> m WebKit.NetworkResponse.NetworkResponse
    {- ^ __Returns:__ the 'GI.WebKit.Objects.NetworkResponse.NetworkResponse' instance -}
downloadGetNetworkResponse download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    result <- webkit_download_get_network_response download'
    checkUnexpectedReturnNULL "downloadGetNetworkResponse" result
    result' <- (newObject WebKit.NetworkResponse.NetworkResponse) result
    touchManagedPtr download
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadGetNetworkResponseMethodInfo
instance (signature ~ (m WebKit.NetworkResponse.NetworkResponse), MonadIO m, IsDownload a) => O.MethodInfo DownloadGetNetworkResponseMethodInfo a signature where
    overloadedMethod _ = downloadGetNetworkResponse

#endif

-- method Download::get_progress
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitDownload", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_download_get_progress" webkit_download_get_progress :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO CDouble

{- |
Determines the current progress of the download.

@since 1.1.2
-}
downloadGetProgress ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: a 'GI.WebKit.Objects.Download.Download' -}
    -> m Double
    {- ^ __Returns:__ a @/gdouble/@ ranging from 0.0 to 1.0. -}
downloadGetProgress download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    result <- webkit_download_get_progress download'
    let result' = realToFrac result
    touchManagedPtr download
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadGetProgressMethodInfo
instance (signature ~ (m Double), MonadIO m, IsDownload a) => O.MethodInfo DownloadGetProgressMethodInfo a signature where
    overloadedMethod _ = downloadGetProgress

#endif

-- method Download::get_status
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitDownload", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit", name = "DownloadStatus"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_download_get_status" webkit_download_get_status :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO CUInt

{- |
Obtains the current status of the download, as a
'GI.WebKit.Enums.DownloadStatus'.

@since 1.1.2
-}
downloadGetStatus ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: the 'GI.WebKit.Objects.Download.Download' -}
    -> m WebKit.Enums.DownloadStatus
    {- ^ __Returns:__ the current 'GI.WebKit.Enums.DownloadStatus' -}
downloadGetStatus download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    result <- webkit_download_get_status download'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr download
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadGetStatusMethodInfo
instance (signature ~ (m WebKit.Enums.DownloadStatus), MonadIO m, IsDownload a) => O.MethodInfo DownloadGetStatusMethodInfo a signature where
    overloadedMethod _ = downloadGetStatus

#endif

-- method Download::get_suggested_filename
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitDownload", 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_download_get_suggested_filename" webkit_download_get_suggested_filename :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO CString

{- |
Retrieves the filename that was suggested by the server, or the one
derived by WebKit from the URI.

@since 1.1.2
-}
downloadGetSuggestedFilename ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: the 'GI.WebKit.Objects.Download.Download' -}
    -> m T.Text
    {- ^ __Returns:__ the suggested filename -}
downloadGetSuggestedFilename download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    result <- webkit_download_get_suggested_filename download'
    checkUnexpectedReturnNULL "downloadGetSuggestedFilename" result
    result' <- cstringToText result
    touchManagedPtr download
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadGetSuggestedFilenameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDownload a) => O.MethodInfo DownloadGetSuggestedFilenameMethodInfo a signature where
    overloadedMethod _ = downloadGetSuggestedFilename

#endif

-- method Download::get_total_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitDownload", 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_download_get_total_size" webkit_download_get_total_size :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO Word64

{- |
Returns the expected total size of the download. This is expected
because the server may provide incorrect or missing
Content-Length. Notice that this may grow over time, as it will be
always the same as current_size in the cases where current size
surpasses it.

@since 1.1.2
-}
downloadGetTotalSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: the 'GI.WebKit.Objects.Download.Download' -}
    -> m Word64
    {- ^ __Returns:__ the expected total size of the downloaded file -}
downloadGetTotalSize download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    result <- webkit_download_get_total_size download'
    touchManagedPtr download
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadGetTotalSizeMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsDownload a) => O.MethodInfo DownloadGetTotalSizeMethodInfo a signature where
    overloadedMethod _ = downloadGetTotalSize

#endif

-- method Download::get_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitDownload", 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_download_get_uri" webkit_download_get_uri :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO CString

{- |
Convenience method to retrieve the URI from the
'GI.WebKit.Objects.NetworkRequest.NetworkRequest' which is being downloaded.

@since 1.1.2
-}
downloadGetUri ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: the 'GI.WebKit.Objects.Download.Download' -}
    -> m T.Text
    {- ^ __Returns:__ the URI -}
downloadGetUri download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    result <- webkit_download_get_uri download'
    checkUnexpectedReturnNULL "downloadGetUri" result
    result' <- cstringToText result
    touchManagedPtr download
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadGetUriMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDownload a) => O.MethodInfo DownloadGetUriMethodInfo a signature where
    overloadedMethod _ = downloadGetUri

#endif

-- method Download::set_destination_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitDownload", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destination_uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the destination URI", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_download_set_destination_uri" webkit_download_set_destination_uri :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    CString ->                              -- destination_uri : TBasicType TUTF8
    IO ()

{- |
Defines the URI that should be used to save the downloaded file to.

@since 1.1.2
-}
downloadSetDestinationUri ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: the 'GI.WebKit.Objects.Download.Download' -}
    -> T.Text
    {- ^ /@destinationUri@/: the destination URI -}
    -> m ()
downloadSetDestinationUri download destinationUri = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    destinationUri' <- textToCString destinationUri
    webkit_download_set_destination_uri download' destinationUri'
    touchManagedPtr download
    freeMem destinationUri'
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadSetDestinationUriMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsDownload a) => O.MethodInfo DownloadSetDestinationUriMethodInfo a signature where
    overloadedMethod _ = downloadSetDestinationUri

#endif

-- method Download::start
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "download", argType = TInterface (Name {namespace = "WebKit", name = "Download"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #WebKitDownload", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_download_start" webkit_download_start :: 
    Ptr Download ->                         -- download : TInterface (Name {namespace = "WebKit", name = "Download"})
    IO ()

{- |
Initiates the download. Notice that you must have set the
destination-uri property before calling this method.

@since 1.1.2
-}
downloadStart ::
    (B.CallStack.HasCallStack, MonadIO m, IsDownload a) =>
    a
    {- ^ /@download@/: the 'GI.WebKit.Objects.Download.Download' -}
    -> m ()
downloadStart download = liftIO $ do
    download' <- unsafeManagedPtrCastPtr download
    webkit_download_start download'
    touchManagedPtr download
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DownloadStartMethodInfo
instance (signature ~ (m ()), MonadIO m, IsDownload a) => O.MethodInfo DownloadStartMethodInfo a signature where
    overloadedMethod _ = downloadStart

#endif