Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Object used to communicate with the application when downloading.
Download
carries information about a download request and
response, including a URIRequest
and a URIResponse
objects. The application may use this object to control the
download process, or to simply figure out what is to be downloaded,
and handle the download process itself.
Synopsis
- newtype Download = Download (ManagedPtr Download)
- class (GObject o, IsDescendantOf Download o) => IsDownload o
- toDownload :: (MonadIO m, IsDownload o) => o -> m Download
- downloadCancel :: (HasCallStack, MonadIO m, IsDownload a) => a -> m ()
- downloadGetAllowOverwrite :: (HasCallStack, MonadIO m, IsDownload a) => a -> m Bool
- downloadGetDestination :: (HasCallStack, MonadIO m, IsDownload a) => a -> m (Maybe Text)
- downloadGetElapsedTime :: (HasCallStack, MonadIO m, IsDownload a) => a -> m Double
- downloadGetEstimatedProgress :: (HasCallStack, MonadIO m, IsDownload a) => a -> m Double
- downloadGetReceivedDataLength :: (HasCallStack, MonadIO m, IsDownload a) => a -> m Word64
- downloadGetRequest :: (HasCallStack, MonadIO m, IsDownload a) => a -> m URIRequest
- downloadGetResponse :: (HasCallStack, MonadIO m, IsDownload a) => a -> m (Maybe URIResponse)
- downloadGetWebView :: (HasCallStack, MonadIO m, IsDownload a) => a -> m (Maybe WebView)
- downloadSetAllowOverwrite :: (HasCallStack, MonadIO m, IsDownload a) => a -> Bool -> m ()
- downloadSetDestination :: (HasCallStack, MonadIO m, IsDownload a) => a -> Text -> m ()
- constructDownloadAllowOverwrite :: (IsDownload o, MonadIO m) => Bool -> m (GValueConstruct o)
- getDownloadAllowOverwrite :: (MonadIO m, IsDownload o) => o -> m Bool
- setDownloadAllowOverwrite :: (MonadIO m, IsDownload o) => o -> Bool -> m ()
- getDownloadDestination :: (MonadIO m, IsDownload o) => o -> m (Maybe Text)
- getDownloadEstimatedProgress :: (MonadIO m, IsDownload o) => o -> m Double
- getDownloadResponse :: (MonadIO m, IsDownload o) => o -> m (Maybe URIResponse)
- type DownloadCreatedDestinationCallback = Text -> IO ()
- afterDownloadCreatedDestination :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadCreatedDestinationCallback) -> m SignalHandlerId
- onDownloadCreatedDestination :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadCreatedDestinationCallback) -> m SignalHandlerId
- type DownloadDecideDestinationCallback = Text -> IO Bool
- afterDownloadDecideDestination :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadDecideDestinationCallback) -> m SignalHandlerId
- onDownloadDecideDestination :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadDecideDestinationCallback) -> m SignalHandlerId
- type DownloadFailedCallback = GError -> IO ()
- afterDownloadFailed :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadFailedCallback) -> m SignalHandlerId
- onDownloadFailed :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadFailedCallback) -> m SignalHandlerId
- type DownloadFinishedCallback = IO ()
- afterDownloadFinished :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadFinishedCallback) -> m SignalHandlerId
- onDownloadFinished :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadFinishedCallback) -> m SignalHandlerId
- type DownloadReceivedDataCallback = Word64 -> IO ()
- afterDownloadReceivedData :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadReceivedDataCallback) -> m SignalHandlerId
- onDownloadReceivedData :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadReceivedDataCallback) -> m SignalHandlerId
Exported types
Memory-managed wrapper type.
Instances
Eq Download Source # | |
GObject Download Source # | |
Defined in GI.WebKit2.Objects.Download | |
ManagedPtrNewtype Download Source # | |
Defined in GI.WebKit2.Objects.Download toManagedPtr :: Download -> ManagedPtr Download | |
TypedObject Download Source # | |
Defined in GI.WebKit2.Objects.Download | |
HasParentTypes Download Source # | |
Defined in GI.WebKit2.Objects.Download | |
IsGValue (Maybe Download) Source # | Convert |
Defined in GI.WebKit2.Objects.Download gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Download -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Download) | |
type ParentTypes Download Source # | |
Defined in GI.WebKit2.Objects.Download type ParentTypes Download = '[Object] |
class (GObject o, IsDescendantOf Download o) => IsDownload o Source #
Type class for types which can be safely cast to Download
, for instance with toDownload
.
Instances
(GObject o, IsDescendantOf Download o) => IsDownload o Source # | |
Defined in GI.WebKit2.Objects.Download |
toDownload :: (MonadIO m, IsDownload o) => o -> m Download Source #
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, cancel, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getAllowOverwrite, getData, getDestination, getElapsedTime, getEstimatedProgress, getProperty, getQdata, getReceivedDataLength, getRequest, getResponse, getWebView.
Setters
setAllowOverwrite, setData, setDataFull, setDestination, setProperty.
cancel
:: (HasCallStack, MonadIO m, IsDownload a) | |
=> a |
|
-> m () |
Cancels the download.
When the ongoing download
operation is effectively cancelled the signal
Download::failed is emitted with
DownloadErrorCancelledByUser
error.
getAllowOverwrite
downloadGetAllowOverwrite Source #
:: (HasCallStack, MonadIO m, IsDownload a) | |
=> a |
|
-> m Bool | Returns: the current value of the Download:allowOverwrite property |
Returns the current value of the Download:allowOverwrite property.
Returns the current value of the Download:allowOverwrite property, which determines whether the download will overwrite an existing file on disk, or if it will fail if the destination already exists.
Since: 2.6
getDestination
downloadGetDestination Source #
:: (HasCallStack, MonadIO m, IsDownload a) | |
=> a |
|
-> m (Maybe Text) | Returns: the destination or |
Obtains the destination to which the downloaded file will be written.
You can connect to Download::createdDestination to make sure this method returns a valid destination.
getElapsedTime
downloadGetElapsedTime Source #
:: (HasCallStack, MonadIO m, IsDownload a) | |
=> a |
|
-> m Double | Returns: seconds since the download was started |
Gets the elapsed time in seconds, including any fractional part.
If the download finished, had an error or was cancelled this is the time between its start and the event.
getEstimatedProgress
downloadGetEstimatedProgress Source #
:: (HasCallStack, MonadIO m, IsDownload a) | |
=> a |
|
-> m Double | Returns: an estimate of the of the percent complete for a download as a range from 0.0 to 1.0. |
Gets the value of the Download:estimatedProgress property.
Gets the value of the Download:estimatedProgress property.
You can monitor the estimated progress of the download operation by
connecting to the notifyestimatedProgress signal of download
.
getReceivedDataLength
downloadGetReceivedDataLength Source #
:: (HasCallStack, MonadIO m, IsDownload a) | |
=> a |
|
-> m Word64 | Returns: the amount of bytes already downloaded. |
Gets the length of the data already downloaded for download
.
Gets the length of the data already downloaded for download
in bytes.
getRequest
:: (HasCallStack, MonadIO m, IsDownload a) | |
=> a |
|
-> m URIRequest | Returns: the |
Retrieves the URIRequest
object that backs the download
process.
getResponse
:: (HasCallStack, MonadIO m, IsDownload a) | |
=> a |
|
-> m (Maybe URIResponse) | Returns: the |
Retrieves the URIResponse
object that backs the download process.
Retrieves the URIResponse
object that backs the download
process. This method returns Nothing
if called before the response
is received from the server. You can connect to notifyresponse
signal to be notified when the response is received.
getWebView
:: (HasCallStack, MonadIO m, IsDownload a) | |
=> a |
|
-> m (Maybe WebView) | Returns: the |
Get the WebView
that initiated the download.
setAllowOverwrite
downloadSetAllowOverwrite Source #
:: (HasCallStack, MonadIO m, IsDownload a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets the Download:allowOverwrite property.
Sets the Download:allowOverwrite property, which determines whether the download may overwrite an existing file on disk, or if it will fail if the destination already exists.
Since: 2.6
setDestination
downloadSetDestination Source #
:: (HasCallStack, MonadIO m, IsDownload a) | |
=> a |
|
-> Text |
|
-> m () |
Sets the destination to which the downloaded file will be written.
This method should be called before the download transfer
starts or it will not have any effect on the ongoing download
operation. To set the destination using the filename suggested
by the server connect to Download::decideDestination
signal and call downloadSetDestination
. If you want to
set a fixed destination that doesn't depend on the suggested
filename you can connect to notifyresponse signal and call
downloadSetDestination
.
If Download::decideDestination signal is not handled
and destination is not set when the download transfer starts,
the file will be saved with the filename suggested by the server in
UserDirectoryDirectoryDownload
directory.
Properties
allowOverwrite
Whether or not the download is allowed to overwrite an existing file on
disk. If this property is False
and the destination already exists,
the download will fail.
Since: 2.6
constructDownloadAllowOverwrite :: (IsDownload o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “allow-overwrite
” property. This is rarely needed directly, but it is used by new
.
getDownloadAllowOverwrite :: (MonadIO m, IsDownload o) => o -> m Bool Source #
Get the value of the “allow-overwrite
” property.
When overloading is enabled, this is equivalent to
get
download #allowOverwrite
setDownloadAllowOverwrite :: (MonadIO m, IsDownload o) => o -> Bool -> m () Source #
Set the value of the “allow-overwrite
” property.
When overloading is enabled, this is equivalent to
set
download [ #allowOverwrite:=
value ]
destination
The local path to where the download will be saved.
getDownloadDestination :: (MonadIO m, IsDownload o) => o -> m (Maybe Text) Source #
Get the value of the “destination
” property.
When overloading is enabled, this is equivalent to
get
download #destination
estimatedProgress
An estimate of the percent completion for the download operation. This value will range from 0.0 to 1.0. The value is an estimate based on the total number of bytes expected to be received for a download. If you need a more accurate progress information you can connect to Download::receivedData signal to track the progress.
getDownloadEstimatedProgress :: (MonadIO m, IsDownload o) => o -> m Double Source #
Get the value of the “estimated-progress
” property.
When overloading is enabled, this is equivalent to
get
download #estimatedProgress
response
The URIResponse
associated with this download.
getDownloadResponse :: (MonadIO m, IsDownload o) => o -> m (Maybe URIResponse) Source #
Get the value of the “response
” property.
When overloading is enabled, this is equivalent to
get
download #response
Signals
createdDestination
type DownloadCreatedDestinationCallback Source #
This signal is emitted after Download::decideDestination and before
Download::receivedData to notify that destination file has been
created successfully at destination
.
afterDownloadCreatedDestination :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadCreatedDestinationCallback) -> m SignalHandlerId Source #
Connect a signal handler for the createdDestination signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
download #createdDestination callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onDownloadCreatedDestination :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadCreatedDestinationCallback) -> m SignalHandlerId Source #
Connect a signal handler for the createdDestination signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
download #createdDestination callback
decideDestination
type DownloadDecideDestinationCallback Source #
= Text |
|
-> IO Bool | Returns: |
This signal is emitted after response is received to
decide a destination for the download using
downloadSetDestination
. If this signal is not
handled, the file will be downloaded to UserDirectoryDirectoryDownload
directory using suggestedFilename
.
Since 2.40, you may handle this signal asynchronously by
returning True
without calling downloadSetDestination
.
This indicates intent to eventually call downloadSetDestination
.
In this case, the download will not proceed until the destination is set
or cancelled with downloadCancel
.
afterDownloadDecideDestination :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadDecideDestinationCallback) -> m SignalHandlerId Source #
Connect a signal handler for the decideDestination signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
download #decideDestination callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onDownloadDecideDestination :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadDecideDestinationCallback) -> m SignalHandlerId Source #
Connect a signal handler for the decideDestination signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
download #decideDestination callback
failed
type DownloadFailedCallback Source #
= GError |
|
-> IO () |
This signal is emitted when an error occurs during the download
operation. The given error
, of the domain WEBKIT_DOWNLOAD_ERROR
,
contains further details of the failure. If the download is cancelled
with downloadCancel
, this signal is emitted with error
DownloadErrorCancelledByUser
. The download operation finishes
after an error and Download::finished signal is emitted after this one.
afterDownloadFailed :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadFailedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the failed signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
download #failed callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onDownloadFailed :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadFailedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the failed signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
download #failed callback
finished
type DownloadFinishedCallback = IO () Source #
This signal is emitted when download finishes successfully or due to an error. In case of errors Download::failed signal is emitted before this one.
afterDownloadFinished :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadFinishedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the finished signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
download #finished callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onDownloadFinished :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadFinishedCallback) -> m SignalHandlerId Source #
Connect a signal handler for the finished signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
download #finished callback
receivedData
type DownloadReceivedDataCallback Source #
This signal is emitted after response is received, every time new data has been written to the destination. It's useful to know the progress of the download operation.
afterDownloadReceivedData :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadReceivedDataCallback) -> m SignalHandlerId Source #
Connect a signal handler for the receivedData signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
download #receivedData callback
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onDownloadReceivedData :: (IsDownload a, MonadIO m) => a -> ((?self :: a) => DownloadReceivedDataCallback) -> m SignalHandlerId Source #
Connect a signal handler for the receivedData signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
download #receivedData callback