Ubuntu Download Manager  1.2.0
A session-wide downloading service
Ubuntu::DownloadManager::Download Class Referenceabstract

The Download class allows to control a download that was created in the download manager. More...

#include <download.h>

+ Inheritance diagram for Ubuntu::DownloadManager::Download:
+ Collaboration diagram for Ubuntu::DownloadManager::Download:

Public Types

enum  State {
  IDLE,
  START,
  PAUSE,
  RESUME,
  CANCEL,
  UNCOLLECTED,
  FINISH,
  ERROR
}
 

Signals

void canceled (bool success)
 
void error (Error *error)
 
void finished (const QString &path)
 
void paused (bool success)
 
void processing (const QString &path)
 
void progress (qulonglong received, qulonglong total)
 
void resumed (bool success)
 
void started (bool success)
 
void clickPackagedChanged ()
 
void showInIndicatorChanged ()
 
void titleChanged ()
 
void destinationAppChanged ()
 

Public Member Functions

 Download (QObject *parent=0)
 
virtual void start ()=0
 
virtual void pause ()=0
 
virtual void resume ()=0
 
virtual void cancel ()=0
 
virtual void collected ()=0
 
virtual void allowMobileDownload (bool allowed)=0
 
virtual bool isMobileDownloadAllowed ()=0
 
virtual void setDestinationDir (const QString &path)=0
 
virtual void setHeaders (QMap< QString, QString > headers)=0
 
virtual void setMetadata (QVariantMap map)=0
 
virtual QMap< QString, QString > headers ()=0
 
virtual void setThrottle (qulonglong speed)=0
 
virtual qulonglong throttle ()=0
 
virtual QString id () const =0
 
virtual QVariantMap metadata ()=0
 
virtual qulonglong progress ()=0
 
virtual qulonglong totalSize ()=0
 
virtual QString filePath ()=0
 
virtual State state ()=0
 
virtual bool isError () const =0
 
virtual Errorerror () const =0
 
virtual QString clickPackage () const =0
 
virtual bool showInIndicator () const =0
 
virtual QString title () const =0
 
virtual QString destinationApp () const =0
 

Properties

QString ClickPackage
 
bool ShowInIndicator
 
QString Title
 
QString DownloadOwner
 

Detailed Description

The Download class allows to control a download that was created in the download manager.

Since
0.3

The Download class represents a download request that was created to be performed by the download manager.

Due to the asynchronous nature of the API a download request is not performed on the Download object creation but after the client has requested it via the Download::start method.

Note
The ownership of the Download is relayed to the caller and therefore the client must call delete or deleteLater whenever it considers to be appropriate.

Definition at line 49 of file download.h.

Member Enumeration Documentation

◆ State

Enumerator
IDLE 
START 
PAUSE 
RESUME 
CANCEL 
UNCOLLECTED 
FINISH 
ERROR 

Definition at line 60 of file download.h.

Constructor & Destructor Documentation

◆ Download()

Ubuntu::DownloadManager::Download::Download ( QObject parent = 0)
inlineexplicit

Definition at line 57 of file download.h.

Member Function Documentation

◆ allowMobileDownload()

void Ubuntu::DownloadManager::Download::allowMobileDownload ( bool  allowed)
pure virtual

Notifies the download manager that the download represented by this download object is allowed or not to use the phones mobile data whenever the devices is connected to it. If the download is not allows to use mobile data it will be automatically paused until a valid network connection is present.

◆ cancel()

void Ubuntu::DownloadManager::Download::cancel ( )
pure virtual

Notifies the download manager that the download represented by this download object must be canceled and all it resources must be cleaned.

◆ canceled

void Ubuntu::DownloadManager::Download::canceled ( bool  success)
signal

This signal is emitted whenever a download cancellation was requested and notifies if the cancellation was successful or not via success.

Definition at line 310 of file moc_download.cpp.

◆ clickPackage()

QString Ubuntu::DownloadManager::Download::clickPackage ( ) const
pure virtual

Returns the value of the click package property of the download. The property shows the id of a download that represents a new click application being downloaded. Only unconfined applications are allowed to set this property.

◆ clickPackagedChanged

void Ubuntu::DownloadManager::Download::clickPackagedChanged ( )
signal

This signal is emitted whenever the click property of a download has been updated.

Definition at line 366 of file moc_download.cpp.

◆ collected()

void Ubuntu::DownloadManager::Download::collected ( )
pure virtual

Notifies the download manager that the finished signal for this download object has been received by the client. This allows UDM to report downloads that have finished while a client isn't running.

◆ destinationApp()

QString Ubuntu::DownloadManager::Download::destinationApp ( ) const
pure virtual

Returns the value of the destinationApp property of the download. The owner of the download is the application that created the download in the system.

◆ destinationAppChanged

void Ubuntu::DownloadManager::Download::destinationAppChanged ( )
signal

This signal is emitted whenever the download owner property of the download has been updated.

Definition at line 384 of file moc_download.cpp.

◆ error() [1/2]

Error * Ubuntu::DownloadManager::Download::error ( ) const
pure virtual

Returns the last error encountered by the download object.

◆ error [2/2]

void Ubuntu::DownloadManager::Download::error ( Error error)
signal

This signal is emitted whenever and error occurred during a download. To get more information about the cause of the error the client can check the type of the error via Error::type() and cast error to the appropriate subclass.

Definition at line 317 of file moc_download.cpp.

◆ filePath()

QString Ubuntu::DownloadManager::Download::filePath ( )
pure virtual

Returns the value of the downloaded file's location. This is only set once the download is complete.

◆ finished

void Ubuntu::DownloadManager::Download::finished ( const QString &  path)
signal

This signal is emitted whenever a download has successfully completed. path is the absolute local file path where the downloaded file can be found.

Definition at line 324 of file moc_download.cpp.

◆ headers()

QMap< QString, QString > Ubuntu::DownloadManager::Download::headers ( )
pure virtual
Since
0.4

Returns the headers that have been set to be fwd in the download request.

◆ id()

QString Ubuntu::DownloadManager::Download::id ( ) const
pure virtual

Returns the unique identifier that represents the download within the download manager.

◆ isError()

bool Ubuntu::DownloadManager::Download::isError ( ) const
pure virtual

Returns if the download represented by the object has had an error.

◆ isMobileDownloadAllowed()

bool Ubuntu::DownloadManager::Download::isMobileDownloadAllowed ( )
pure virtual

Returns if the download represented by this download object is allowed to use the phones mobile data connection.

◆ metadata()

QVariantMap Ubuntu::DownloadManager::Download::metadata ( )
pure virtual

Returns the metadata used upon creation of the download represented by the object.

◆ pause()

void Ubuntu::DownloadManager::Download::pause ( )
pure virtual

Notifies the download manager that the download represented by this download object must be paused.

◆ paused

void Ubuntu::DownloadManager::Download::paused ( bool  success)
signal

This signal is emitted whenever a download paused was requested and notifies if the pause was successful or not via success.

Definition at line 331 of file moc_download.cpp.

◆ processing

void Ubuntu::DownloadManager::Download::processing ( const QString &  path)
signal

This signal is emitted whenever a post processing action is being performed on the download file indicated by path.

Definition at line 338 of file moc_download.cpp.

◆ progress() [1/2]

qulonglong Ubuntu::DownloadManager::Download::progress ( )
pure virtual

Returns the size of all the data downloaded so far in bytes.

◆ progress [2/2]

void Ubuntu::DownloadManager::Download::progress ( qulonglong  received,
qulonglong  total 
)
signal

This signal is emitted to indicate the progress of the download where received is the number of bytes received and total is the total size of the download.

Note
If the download manager is not able to estimate the size of a download, which is something that can happen when the server does not correctly send the size back, received and total will have the same value. The fact that the values are the same \tt DOES NOT mean that a download was completed for that the signals Download::finished(const QString& path) should be used.

Definition at line 345 of file moc_download.cpp.

◆ resume()

void Ubuntu::DownloadManager::Download::resume ( )
pure virtual

Notifies the download manager that the download represented by this download object must be resumed. There is no guarantee that nor errors will be raised if a not paused download is resumed.

◆ resumed

void Ubuntu::DownloadManager::Download::resumed ( bool  success)
signal

This signal is emitted whenever a download resume was requested and notifies if the resume was successful via success.

Definition at line 352 of file moc_download.cpp.

◆ setDestinationDir()

void Ubuntu::DownloadManager::Download::setDestinationDir ( const QString &  path)
pure virtual

Notifies the download manager that the local path of the download must be a different one. This call can only be performed if the download was not started else it will result in an error.

◆ setHeaders()

void Ubuntu::DownloadManager::Download::setHeaders ( QMap< QString, QString >  headers)
pure virtual
Since
0.4

Allows to set the headers to be used for the download request. If the download has been started the operation will result in an error.

◆ setMetadata()

void Ubuntu::DownloadManager::Download::setMetadata ( QVariantMap  map)
pure virtual
Since
0.9

Allows to set the metadata to be used for the download request.

◆ setThrottle()

void Ubuntu::DownloadManager::Download::setThrottle ( qulonglong  speed)
pure virtual

Notifies the download manager that the download represented by this download object has its download bandwidth limited to the value provided by speed represented in bytes.

◆ showInIndicator()

bool Ubuntu::DownloadManager::Download::showInIndicator ( ) const
pure virtual

Returns the value of the show in indicator property of the download. The property states if the download will be shown in the systems transfer indicator. Confined applications are allowed to set this property to false via the metadata to hide their downloads from being shown in the indicator.

◆ showInIndicatorChanged

void Ubuntu::DownloadManager::Download::showInIndicatorChanged ( )
signal

Definition at line 372 of file moc_download.cpp.

◆ start()

void Ubuntu::DownloadManager::Download::start ( )
pure virtual

Notifies the download manager that the download that is represented by this download object is ready to be downloaded.

The normal use case is that the client of the API connects to all the download signals that he is interested in and the calls the start methods. This pattern ensures that if a download is performed that all signals are connected else the client could see cases in where no signals are received because the download finished before he connected to the signals.

◆ started

void Ubuntu::DownloadManager::Download::started ( bool  success)
signal

This signal is emitted whenever a download start was requested and notifies if the start action was successful via success.

Definition at line 359 of file moc_download.cpp.

◆ state()

State Ubuntu::DownloadManager::Download::state ( )
pure virtual

Returns the current state of the download.

◆ throttle()

qulonglong Ubuntu::DownloadManager::Download::throttle ( )
pure virtual

Returns the bandwidth limit that was set for the download represented by this object. If the result is 0 is that no limit was set.

◆ title()

QString Ubuntu::DownloadManager::Download::title ( ) const
pure virtual

Returns the value of the title property of the download. The title of the download is the string that will be shown in the transfer indicator while the download is in progress. Confined applications are allowed to set the properties value via the metadata.

◆ titleChanged

void Ubuntu::DownloadManager::Download::titleChanged ( )
signal

This signal is emitted whenever the title property of the download has been updated.

Definition at line 378 of file moc_download.cpp.

◆ totalSize()

qulonglong Ubuntu::DownloadManager::Download::totalSize ( )
pure virtual

Returns the totals size estimated for the download. The result can be 0 when the download manager was not able to deduce the download size due to a wrong configuration of the server.

Property Documentation

◆ ClickPackage

QString Ubuntu::DownloadManager::Download::ClickPackage
read

Definition at line 1 of file download.h.

◆ DownloadOwner

QString Ubuntu::DownloadManager::Download::DownloadOwner
read

Definition at line 1 of file download.h.

◆ ShowInIndicator

bool Ubuntu::DownloadManager::Download::ShowInIndicator
read

Definition at line 1 of file download.h.

◆ Title

QString Ubuntu::DownloadManager::Download::Title
read

Definition at line 1 of file download.h.


The documentation for this class was generated from the following files: