Source: stbUpdate.js

/**
 * STB object declaration and documentation.
 * JSDoc specification ({@link http://usejsdoc.org/}).
 * An introduction to JSDoc ({@link http://www.2ality.com/2011/08/jsdoc-intro.html}).
 *
 * @fileOverview Provides API to the software updates subsystem operations.
 */

'use strict';

/* jshint unused:false */

//noinspection JSUnusedGlobalSymbols

/**
 * The object provides an interface to the update manager (handles software updates subsystem operations).
 *
 * Update Manager allows you to initiate and display the status of the software upgrade procedure.
 * Before any software update operation you must stop every single process of media content accessing and displaying.
 *
 * Update manager is a finite state machine. State is accessible via {@link stbUpdate.getStatus} method. Initial state "Idle" (value "21").
 * Any active operation upon the update system is only allowed in one of final states (for example "Idle"). Right after
 * starting of an operation state machine should be considered as busy until any of final states is settled back.
 *
 * @namespace
 */
var stbUpdate = {

	/**
	 * Return total number of banks available for update.
	 *
	 * @return {number} if everything is fine at least one bank should be available [0..n]
	 *
	 * @since 0.2.16
	 */
	GetFlashBankCount:
		function () { return 1; },


	/**
	 * @private
	 */
	eventProgress:
		function () {},


	/**
	 * @private
	 */
	eventStateChanged:
		function () {},


	/**
	 * Return memory bank number, that has been used for current software boot.
	 *
	 * @return {number} possible values:
	 *
	 *  Value | Description
	 * -------|-------------
	 *   0    | first memory bank
	 *   1    | second memory bank
	 *  -1    | memory bank is undefined (it could be possible if device was booted from network storage, e.g. NFS)
	 *
	 * @since 0.2.16
	 */
	getActiveBank:
		function () { return 0; },


	/**
	 * Return timestamp of "Update Image" file that has been read during last successful "Check" operation.
	 *
	 * @return {string} timestamp expressed in image-specific format
	 *
	 * @example
	 * 'Thu Nov 3 15:07:57 EET 2011'
	 *
	 * @since 0.2.16
	 */
	getImageDateStr:
		function () { return ''; },


	/**
	 * Return description of "Update Image" file that has been read during last successful "Check" operation.
	 *
	 * @return {string} description
	 *
	 * @example
	 * '0.2.12-250-alpha'
	 *
	 * @since 0.2.16
	 */
	getImageDescStr:
		function () { return ''; },


	/**
	 * Return version of "Update Image" file that has been read during last successful "Check" operation.
	 *
	 * @return {string} version
	 *
	 * @example
	 * '211'
	 *
	 * @since 0.2.16
	 */
	getImageVersionStr:
		function () { return ''; },


	/**
	 * Return a progress indicator value for pending update operation.
	 *
	 * @return {number} value expressed in percents [0..100]
	 *
	 * @since 0.2.16
	 */
	getPercents:
		function () { return 0; },


	/**
	 * Return the last available status code for an update operation.
	 *
	 * @return {number} possible values:
	 *
	 *  Value | Description
	 * -------|-------------
	 *  -1    | Not defined
	 *   1    | Signature init error (final state error)
	 *   2    | Wrong device model
	 *   3    | Section size exceeds partition size on FLASH
	 *   4    | Required FLASH section not found. Aborting update
	 *   5    | Updating kernel
	 *   6    | Updating image
	 *   7    | Internal error (final state error)
	 *   8    | Inspecting firmware
	 *   9    | Updating environment variables
	 *  10    | Updating Bootstrap section
	 *  11    | Skipping Bootstrap section
	 *  12    | Updating User FS section
	 *  13    | Skipping User FS section
	 *  14    | Updating second boot
	 *  15    | Updating logotype
	 *  16    | Update finished OK (final state OK)
	 *  17    | Wrong signature (final state OK)
	 *  18    | Erasing flash section
	 *  19    | Flash write error (final state error)
	 *  20    | File write error (final state error)
	 *  21    | Idle (final state OK)
	 *  22    | Invalid file header (final state error)
	 *  23    | Inspecting update file
	 *  23    | File check finished
	 *  24    | File check finished (final state OK)
	 *  25    | File not found (final state error)
	 *  26    | Initialising
	 *  27    | Read error (final state error)
	 *
	 * @since 0.2.16
	 */
	getStatus:
		function () { return 0; },


	/**
	 * Return the last available status for an update operation.
	 *
	 * @return {string} status description string
	 *
	 * localization will be done according to settings of internal portal
	 */
	getStatusStr:
		function () { return ''; },


	/**
	 * Start an automatic software update procedure.
	 *
	 * Dedicated web window will be opened using URL "`imageUrl`".
	 *
	 * @param {string} imageUrl "Update Image" file address, can be in following forms:
	 *
	 * - URL pointing to the update file using HTTP scheme (e.g. `http://test.com/imageupdate`)
	 * - file path to the update file (e.g. `/media/usbdisk/mag200/imageupdate`)
	 *
	 * @param {boolean} checkVersion possible values:
	 *
	 *  Value | Description
	 * -------|-------------
	 *  true  | commit update procedure only if current version of software older than available version
	 *  false | unconditional update
	 *
	 * @since 0.2.16
	 */
	startAutoUpdate:
		function ( imageUrl, checkVersion ) {},


	/**
	 * Set URL for "Auto Update" web window.
	 *
	 * @param {string} options parameters from function {@link stbWindowMgr.windowInit}
	 *
	 * @example
	 * stbUpdate.setAutoUpdateInitAttr('{"url":"/home/web/system/updater/index.html"}');
	 *
	 * @since 0.2.18
	 *
	 */
	setAutoUpdateInitAttr:
		function ( options ) {},


	/**
	 * Start a metadata inspection for "Update Image" file.
	 *
	 * @param {string} imageUrl file address which will be inspected for available metadata, can be in following forms:
	 *
	 * - URL pointing to the update file using HTTP scheme (e.g. `http://test.com/imageupdate`)
	 * - file path to the update file (e.g. `/media/usbdisk/mag200/imageupdate`)
	 *
	 * @since 0.2.16
	 */
	startCheck:
		function ( imageUrl ) {},


	/**
	 * Start a software update using "Update Image" file.
	 *
	 * @param {number} bankIndex possible values:
	 *
	 *  Value | Description
	 * -------|-------------
	 *  0     | use first memory bank
	 *  1     | use second memory bank
	 *
	 * @param {string} imageUrl "Update Image" file address, can be in following forms:
	 *
	 * - URL pointing to the update file using HTTP scheme (e.g. `http://test.com/imageupdate`)
	 * - file path to the update file (e.g. `/media/usbdisk/mag200/imageupdate`)
	 *
	 * @since 0.2.16
	 */
	startUpdate:
		function ( bankIndex, imageUrl ) {}

};