D0301
HTML Application SDK  A0.101
Classes | Public Member Functions | Public Attributes | List of all members
CustomDownloadManager Interface Reference

import"CustomDownloadManagerPlugin.idl";

Classes

interface  downloadStateChange
 

Public Member Functions

void addEventListener ([in] String event_name, [in] EventListener listener)
 
enumerations checkDownloadPossible ([in] String storage_device_path, [in] Integer sizeInBytes)
 
Boolean getDownloads ()
 
Boolean isInProgress ([in] String destination)
 
Boolean registerDownloadURL ([in] String url, [in] String destination)
 
Boolean remove ([in] String destination)
 
void removeEventListener ([in] String event_name, [in] EventListener listener)
 
void removeEventListener ([in] String event_name)
 

Public Attributes

const Integer DOWNLOAD_CANCELED_BY_USER = 3
 
const Integer DOWNLOAD_COMPLETED = 1
 
const Integer DOWNLOAD_FAILED = 8
 
const Integer DOWNLOAD_FILE_CREATION_ERROR = 5
 
const Integer DOWNLOAD_FILE_WRITE_ERROR = 4
 
const Integer DOWNLOAD_IN_PROGRESS = 2
 
const Integer DOWNLOAD_INSUFFICIENT_STORAGE = 1
 
const Integer DOWNLOAD_LOCAL_ERROR = 7
 
const Integer DOWNLOAD_NETWORK_ERROR = 9
 
const Integer DOWNLOAD_PLUGIN_NOT_SUPPORTED = 10
 
const Integer DOWNLOAD_POSSIBLE = 0
 
const Integer DOWNLOAD_REMOTE_ERROR = 6
 
const Integer DOWNLOAD_STORAGE_NOT_AVAILABLE = 2
 

Detailed Description

This is a class which implements global CustomDownloadManager object. Responsible for starting a download and keeping a record of it until it is finished either with success or error. Every download should have a unique destination. User is responsible for providing a unique destination and the safety of the destination file.

Member Function Documentation

void CustomDownloadManager.addEventListener ( [in] String  event_name,
[in] EventListener  listener 
)

Adds DOM2 event listener for specified event.

Possible values are: event_name: "downloadStateChange", listener: function that has arguments similar to the downloadStateChange interface properties.

Parameters
event_nameName of the event.
listenerjavascript function that has arguments like the properties listed in the listener's interface.
enumerations CustomDownloadManager.checkDownloadPossible ( [in] String  storage_device_path,
[in] Integer  sizeInBytes 
)

Queries if the given storage has available free space in given size in bytes. Note: Destination should be the root of the storage. Root of storage is received from the StorageManager return of getListOfAvailableStorages()->RemovableDevice.path. Using registerDownloadURL does not reserve the final size of the download file so while a download is in progress Storage size decreases, meaning that the this function will have different results if there are downloads in progress. This function is most useful before starting any download. User should know the summation of the sizes of all files to be downloaded and check if this will fit. Example: A 5MB video file and a 2MB image file will be downloaded. This function should be called before starting the downloads with the parameter 7 000 000.

var possibleDownloadState = CustomDownloadManager.checkDownloadPossible(usbPath, sizeInBytes);
expect(possibleDownloadState).toBe(CustomDownloadManager.DOWNLOAD_POSSIBLE, "Download state is not DOWNLOAD_POSSIBLE");
Parameters
storage_device_pathStorage device root path.
sizeInBytesFree space to query.
Returns
one of the following: DOWNLOAD_POSSIBLE, DOWNLOAD_INSUFFICIENT_STORAGE, DOWNLOAD_STORAGE_NOT_AVAILABLE.
Boolean CustomDownloadManager.getDownloads ( )

Requests for a list of on going downloads. Each download will invoke a downloadStateChange event with a DOWNLOAD_IN_PROGRESS status.

var gotDownloads = CustomDownloadManager.getDownloads();
Returns
False on internal error, otherwise true.
Boolean CustomDownloadManager.isInProgress ( [in] String  destination)

Synchronous check if the download is in progress. Note: StorageManager actions on a download destination should be performed if and only if this function returns false.

destinationPath = cdmTestDir + "file_name7.mp4";
Parameters
destinationDestination that matches a download.
Returns
True if download is in progress otherwise false.
Boolean CustomDownloadManager.registerDownloadURL ( [in] String  url,
[in] String  destination 
)

Gets the URL for the file which will be downloaded and destination path to where the file will be downloaded into in order to use them to start the download operation. The function can start a download from the same URL if two different destination paths are given. Each download will invoke a downloadStateChange event with a DOWNLOAD_IN_PROGRESS status. The destination path should consist of both the directory and the filename.

var invalidDownloadUrl = "http://mediatest.vestek.com.tr/SomeInvalidURL.mp4";
var registeredDownload = CustomDownloadManager.registerDownloadURL(invalidDownloadUrl, destinationPath);
Parameters
urlDownload url of the remote file.
destinationOptional: Download destination of the file must be under the removable storage device. If destination is left empty, platform will decide on a removable storage device and a filename. Note: if destination is decided by the platform downloading from the same url without a destination will yeild the same filename which will violate the unique destination rule, resulting an error.
Returns
Returns true if download request is added successfully. If false is returned, a download to the same destination is in progress already(User will not receive an event that indicates that the download is already in progress. File will not be created for a false return so you don't need to clean it up.). Note: does not indicate result of the download
Boolean CustomDownloadManager.remove ( [in] String  destination)

Removes a download in progress. Notes: User should use StorageManager to cleanup the destination after removal. Does not remove the file of a download that is completed.

var removedDownload = CustomDownloadManager.remove(destinationPath);
Parameters
destinationDownload destination of the file.
Returns
False on internal error otherwise true.
void CustomDownloadManager.removeEventListener ( [in] String  event_name,
[in] EventListener  listener 
)

Removes single DOM2 event listener for specified event

Possible values are: event_name: "downloadStateChange", listener: function that has arguments similar to the downloadStateChange interface properties.

Parameters
event_nameName of the event
listenernamed javascript function that has arguments like the properties listed in the listener's interface.
void CustomDownloadManager.removeEventListener ( [in] String  event_name)

Removes all DOM2 event listeners for specified event

Parameters
event_nameName of the event
See also
removeEventListener([in] String event_name, [in] EventListener listener);

Member Data Documentation

const Integer CustomDownloadManager.DOWNLOAD_CANCELED_BY_USER = 3

remove function was called and successfully executed

const Integer CustomDownloadManager.DOWNLOAD_COMPLETED = 1

Download is successful

const Integer CustomDownloadManager.DOWNLOAD_FAILED = 8

Download failed

const Integer CustomDownloadManager.DOWNLOAD_FILE_CREATION_ERROR = 5

Couldn't create the file. e.g path was invalid.

const Integer CustomDownloadManager.DOWNLOAD_FILE_WRITE_ERROR = 4

Couldn't write to destionation path. e.g file was deleted or file with the same name already exists in the destination path (e.g It can be checked using StorageManager listFiles API).

const Integer CustomDownloadManager.DOWNLOAD_IN_PROGRESS = 2

Download is in progress

const Integer CustomDownloadManager.DOWNLOAD_INSUFFICIENT_STORAGE = 1

Insufficent space for download

const Integer CustomDownloadManager.DOWNLOAD_LOCAL_ERROR = 7

There was a problem with the local network interface.

const Integer CustomDownloadManager.DOWNLOAD_NETWORK_ERROR = 9

Network error

const Integer CustomDownloadManager.DOWNLOAD_PLUGIN_NOT_SUPPORTED = 10

Plugin is disabled

const Integer CustomDownloadManager.DOWNLOAD_POSSIBLE = 0

Have enough space for download

const Integer CustomDownloadManager.DOWNLOAD_REMOTE_ERROR = 6

The server could not provide the content. Check downloadStateChange.errorMessage. e.g. the file may not exist on the server.

const Integer CustomDownloadManager.DOWNLOAD_STORAGE_NOT_AVAILABLE = 2

Storage is unreachable


The documentation for this interface was generated from the following file: