• Skip to content
  • Skip to link menu
KDE API Documentation - DownloadManager Class Reference (GCompris-qt)
  • KDE Home
  • Contact Us
 

GCompris-qt

  • View on LXR
  • Comments
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | List of all members
DownloadManager Class Reference
Core Infrastructure

#include <DownloadManager.h>

Inherits QObject.

Public Types

enum  DownloadFinishedCode { Success = 0, Error = 1, NoChange = 2 }
 

Public Slots

Q_INVOKABLE void abortDownloads ()
 
Q_INVOKABLE bool downloadResource (const QString &path)
 
Q_INVOKABLE void shutdown ()
 
Q_INVOKABLE bool updateResource (const QString &path)
 

Signals

void downloadFinished (int code)
 
void downloadProgress (qint64 bytesReceived, qint64 bytesTotal)
 
void downloadStarted (const QString &resource)
 
void error (int code, const QString &msg)
 
void resourceRegistered (const QString &resource)
 
void voicesRegistered ()
 

Public Member Functions

Q_INVOKABLE bool areVoicesRegistered () const
 
Q_INVOKABLE bool downloadIsRunning () const
 
Q_INVOKABLE QString getVoicesResourceForLocale (const QString &locale) const
 
Q_INVOKABLE bool haveLocalResource (const QString &path) const
 
Q_INVOKABLE bool isDataRegistered (const QString &data) const
 

Static Public Member Functions

static DownloadManager * getInstance ()
 
static void init ()
 
static QObject * systeminfoProvider (QQmlEngine *engine, QJSEngine *scriptEngine)
 

Detailed Description

A singleton class responsible for downloading, updating and maintaining remote resources.

DownloadManager is responsible for downloading, updating and registering additional resources (in Qt's binary .rcc format) used by GCompris. It downloads from a upstream URL (ApplicationSettings.downloadServerUrl) to the default local writable location. Downloads are based on common relative resource paths, such that a URL of the form

http://<server-base>/<path/to/my/resource.rcc>

will be downloaded to a local path

/<QStandardPaths::writableLocation(QStandardPaths::DataLocation)>/<path/to/my/resource.rcc>

and registered with a resource root path

qrc:/<path/to/my>/

Internally resources are uniquely identified by their relative resource path

<path/to/my/resource.rcc> (e.g. data2/voices-ogg/voices-en.rcc>)

Downloading and verification of local files is controlled by MD5 checksums that are expected to be stored in Contents files in each upstream directory according to the syntax produced by the md5sum tool. The checksums are used for checking whether a local rcc file is up-to-date (to avoid unnecesary rcc downloads) and to verify that the transfer was complete. Only valid rcc files (with correct checksums) are registered.

A resource file must reference the "/gcompris/data" prefix with <qresource prefix="/gcompris/data">. All data are loaded and referenced from this prefix. It is possible to check if a data is registered with isDataRegistered.

See also
DownloadDialog, ApplicationSettings.downloadServerUrl, ApplicationSettings.isAutomaticDownloadsEnabled

Definition at line 81 of file DownloadManager.h.

Member Enumeration Documentation

enum DownloadManager::DownloadFinishedCode

Possible return codes of a finished download.

Enumerator
Success 

Download finished successfully.

Error 

Download error.

NoChange 

Local files are up-to-date, no download was needed.

Definition at line 211 of file DownloadManager.h.

Member Function Documentation

void DownloadManager::abortDownloads ( )
slot

Abort all currently running downloads.

Definition at line 94 of file DownloadManager.cpp.

bool DownloadManager::areVoicesRegistered ( ) const

Whether voices for the currently active locale are registered.

See also
isDataRegistered

Definition at line 483 of file DownloadManager.cpp.

void DownloadManager::downloadFinished ( int  code)
signal

Emitted when a download has finished.

Also emitted in error cases.

Parameters
codeDownloadFinishedCode. FIXME: when using DownloadFinishedCode instead of int the code will not be passed to the QML layer, use QENUMS?
bool DownloadManager::downloadIsRunning ( ) const

Whether any download is currently running.

Definition at line 89 of file DownloadManager.cpp.

void DownloadManager::downloadProgress ( qint64  bytesReceived,
qint64  bytesTotal 
)
signal

Emitted during a running download.

All values refer to the currently active sub-job.

Parameters
bytesReceivedDownloaded bytes.
bytesTotalTotal bytes to download.
bool DownloadManager::downloadResource ( const QString &  path)
slot

Download a resource specified by the relative resource path and register it if possible.

If a corresponding local resource exists, an update will only be downloaded if it is not up-to-date according to checksum comparison. Whenever at the end we have a valid .rcc file it will be registered.

Parameters
pathA relative resource path.
Returns
success

Definition at line 167 of file DownloadManager.cpp.

void DownloadManager::downloadStarted ( const QString &  resource)
signal

Emitted when a download has started.

Parameters
resourceRelative resource path of the started download.
void DownloadManager::error ( int  code,
const QString &  msg 
)
signal

Emitted when a download error occurs.

Parameters
codeenum NetworkError code.
msgError string.
QString DownloadManager::getVoicesResourceForLocale ( const QString &  locale) const

Generates a relative voices resources file-path for a given locale.

Parameters
localeLocale name string of the form <language>_<country>.
Returns
A relative voices resource path.

Definition at line 120 of file DownloadManager.cpp.

bool DownloadManager::haveLocalResource ( const QString &  path) const

Checks whether the given relative resource path exists locally.

Parameters
pathA relative resource path.

Definition at line 145 of file DownloadManager.cpp.

void DownloadManager::init ( )
static

Registers DownloadManager singleton in the QML engine.

Definition at line 82 of file DownloadManager.cpp.

bool DownloadManager::isDataRegistered ( const QString &  data) const

Whether the passed relative data is registered.

For example, if you have a resource file which loads files under the 'words' path like 'words/one.png'. You can call this method with 'words/one.png' or with 'words'.

Parameters
dataRelative resource path (file or directory).
See also
areVoicesRegistered

Definition at line 476 of file DownloadManager.cpp.

void DownloadManager::resourceRegistered ( const QString &  resource)
signal

Emitted when a resource has been registered.

Parameters
resourceRelative resource path of the registered resource.
See also
voicesRegistered
void DownloadManager::shutdown ( )
slot

Shutdown DownloadManager instance.

Aborts all currently running downloads.

Definition at line 56 of file DownloadManager.cpp.

bool DownloadManager::updateResource ( const QString &  path)
slot

Updates a resource path from the upstream server unless prohibited by the settings and registers it if possible.

If not prohibited by the setting 'isAutomaticDownloadsEnabled' checks for an available upstream resource specified by path. If the corresponding local resource does not exist or is out of date, the resource is downloaded and registered.

If automatic downloads/updates are prohibited and a local copy of the specified resource exists, it is registered.

Parameters
pathA relative resource path.
Returns
success

Definition at line 150 of file DownloadManager.cpp.

void DownloadManager::voicesRegistered ( )
signal

Emitted when voices resources for current locale have been registered.

Convenience signal and special case of resourceRegistered.

See also
resourceRegistered

The documentation for this class was generated from the following files:
  • DownloadManager.h
  • DownloadManager.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2015 The KDE developers.
Generated on Tue Jun 2 2015 21:47:48 by doxygen 1.8.9.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

GCompris-qt

Skip menu "GCompris-qt"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Modules

Class Picker

Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal