Tizen API
The API provides the basic definitions that are used in the Tizen Web Device API. These include generic callbacks that are invoked when the operations succeed or fail, WebAPIError and WebAPIException that give information of the platform's error and filter interfaces that are used to make query statements for searching.
Additionally, this API specifies the location in the ECMAScript hierarchy in which the Tizen Web Device API is instantiated (window.tizen).
For more information on the Tizen features, see Tizen Guide.
Since: 1.0
Table of Contents
- 1. Type Definitions
- 1.1. FilterMatchFlag
- 1.2. SortModeOrder
- 1.3. CompositeFilterType
- 2. Interfaces
- 2.1. TizenObject
- 2.2. Tizen
- 2.3. AbstractFilter
- 2.4. AttributeFilter
- 2.5. AttributeRangeFilter
- 2.6. CompositeFilter
- 2.7. SortMode
- 2.8. SimpleCoordinates
- 2.9. WebAPIException
- 2.10. WebAPIError
- 2.11. SuccessCallback
- 2.12. ErrorCallback
- 3. Full WebIDL
Summary of Interfaces and Methods
Interface | Method |
---|---|
TizenObject | |
Tizen | |
AbstractFilter | |
AttributeFilter | |
AttributeRangeFilter | |
CompositeFilter | |
SortMode | |
SimpleCoordinates | |
WebAPIException | |
WebAPIError | |
SuccessCallback | void onsuccess () |
ErrorCallback | void onerror (WebAPIError error) |
1. Type Definitions
1.1. FilterMatchFlag
enum FilterMatchFlag { "EXACTLY", "FULLSTRING", "CONTAINS", "STARTSWITH", "ENDSWITH", "EXISTS" };
Since: 1.0
These values are supported:
- EXACTLY - Indicates that an attribute value should match exactly with the specified default value. For strings, this type of comparison is case-sensitive.
- FULLSTRING - Indicates String-based comparison and that the attribute value should match the whole string (case insensitive).
- CONTAINS - Indicates that an attribute value should contain the specified string. This type of comparison works only on strings and is case insensitive.
- STARTSWITH - Indicates that an attribute value should start with the specified string. This type of comparison works only on strings and is case insensitive.
- ENDSWITH - Indicates that an attribute value should end with the specified string. This type of comparison works only on strings and is case insensitive.
- EXISTS - Indicates that a filter comparison should match if the specified attribute exists.
1.2. SortModeOrder
enum SortModeOrder { "ASC", "DESC" };
Since: 1.0
Following values are supported:
- ASC - Indicates that the sorting order is ascending
- DESC - Indicates that the sorting order is descending
1.3. CompositeFilterType
enum CompositeFilterType { "UNION", "INTERSECTION" };
Since: 1.0
Following values are supported:
- UNION - Indicates that the composite is a union of filters ("OR" operator)
- INTERSECTION - Indicates that the composite is an intersection of filters ("AND" operator)
2. Interfaces
2.1. TizenObject
[NoInterfaceObject] interface TizenObject { readonly attribute Tizen tizen; };
Window implements TizenObject;
Since: 1.0
The Tizen interface is always available within the Window object in the ECMAScript hierarchy.
Attributes
-
readonly
Tizen tizenObject representing a tizen manager.
Since: 1.0
2.2. Tizen
[NoInterfaceObject] interface Tizen { };
Since: 1.0
This is the Tizen root interface. It is a property of the ECMAScript global object, as specified by the TizenObject interface.
2.3. AbstractFilter
[NoInterfaceObject] interface AbstractFilter { };
Since: 1.0
Never use this base interface directly, instead use AbstractFilter subtypes, such as AttributeFilter, AttributeRangeFilter, and CompositeFilter.
2.4. AttributeFilter
[Constructor(DOMString attributeName, optional FilterMatchFlag? matchFlag, optional any matchValue)] interface AttributeFilter : AbstractFilter { attribute DOMString attributeName; attribute FilterMatchFlag matchFlag; attribute any matchValue; };
Since: 1.0
It represents the query statement for the specified value of matchValue by the rule of matchFlag.
If no matchValue is defined, the filter matches all objects that have the attribute defined (same as the "EXISTS" filter works), otherwise, it only matches objects which have an attribute that match the specified value.
Code example:
/* Following example retrieves all songs from the album "The Joshua Tree". */ var count = 100; var offset = 0; var albumFilter = new tizen.AttributeFilter("album", "EXACTLY", "The Joshua Tree"); function errorCB(err) { console.log("Following error occurred: " + err.name); } function findCB(contents) { console.log("The Joshua Tree: " + contents.length); } tizen.content.find(findCB, errorCB, null, albumFilter, null, count, offset);
Constructors
-
Constructor (DOMString, FilterMatchFlag?, any)
AttributeFilter(DOMString attributeName, optional FilterMatchFlag? matchFlag, optional any matchValue);
Attributes
-
DOMString attributeNameThe name of the object attribute used for filtering.
This is the name of the object attribute exactly as it is defined in the object's interface. For attributes of complex type, use fully-qualified names (such as "geolocation.latitude" to filter a video or image content's latitude in a geolocation).
For attributes of an array type, the filter will match if any value in the array matches.
Since: 1.0
-
FilterMatchFlag matchFlagThe match flag used for attribute-based filtering.
By default, this attribute is set to "EXACTLY".
Since: 1.0
-
any matchValueThe value used for matching.
The filter will match if the attribute value matches the given matchValue.
This value is not used if the matchFlag is set to "EXISTS". By default, this attribute is set to null.
Since: 1.0
2.5. AttributeRangeFilter
[Constructor(DOMString attributeName, optional any initialValue, optional any endValue)] interface AttributeRangeFilter : AbstractFilter { attribute DOMString attributeName; attribute any initialValue; attribute any endValue; };
Since: 1.0
Range filters, where only one boundary is set, are available.
Code example:
var count = 100; var offset = 0; /* Use the modifiedDate attribute with a range that starts today and ends in 1 day */ /* (meaning that you search for all contents modified today). */ var today = new Date(); var today_begin = new Date(today.getFullYear(), today.getMonth(), today.getDate()); var today_end = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1); var dateRangeFilter = new tizen.AttributeRangeFilter("modifiedDate", today_begin, today_end); function errorCB(err) { console.log("Following error occurred: " + err.name); } function findCB(contents) { console.log("The contents modified today: " + contents.length); } tizen.content.find(findCB, errorCB, null, dateRangeFilter, null, count, offset);
Constructors
Attributes
-
DOMString attributeNameThe name of the object attribute used for filtering.
The value of this attribute is exactly as it is defined in the object's interface. For attributes of complex type, use fully-qualified names (such as "geolocation.latitude" to filter a video or image content's latitude in a geolocation).
For attributes of array type, the filter will match if any value in the array matches.
Since: 1.0
-
any initialValueObjects with an attribute that is greater than or equal to initialValue will match.
By default, this attribute is set to null.
Since: 1.0
-
any endValueObjects with an attribute that is strictly lower than or equal to endValue will match.
By default, this attribute is set to null.
Since: 1.0
2.6. CompositeFilter
[Constructor(CompositeFilterType type, optional AbstractFilter[]? filters)] interface CompositeFilter : AbstractFilter { attribute CompositeFilterType type; attribute AbstractFilter[] filters; };
Since: 1.0
The composite filters can be one of the following 2 types:
- The union - used to filter objects that match any of the filters it includes.
- The intersection - used to filter objects that match all the filters it includes.
Code example:
/* Following example retrieves all songs from the album "The Joshua Tree", by artist "U2". */ var count = 100; var offset = 0; var artistFilter = new tizen.AttributeFilter("artists", "EXACTLY", "U2"); var albumFilter = new tizen.AttributeFilter("album", "EXACTLY", "The Joshua Tree"); var filter = new tizen.CompositeFilter("INTERSECTION", [albumFilter, artistFilter]); function errorCB(err) { console.log("Following error occurred: " + err.name); } function findCB(contents) { console.log("The Joshua Tree by U2: " + contents.length); } tizen.content.find(findCB, errorCB, null, filter, null, count, offset);
Code example:
/* Following example retrieves all songs from the album "Tormato" and all songs by artist "Rush". */ var count = 100; var offset = 0; var artistFilter = new tizen.AttributeFilter("artists", "EXACTLY", "Rush"); var albumFilter = new tizen.AttributeFilter("album", "EXACTLY", "Tormato"); var filter = new tizen.CompositeFilter("UNION", [albumFilter, artistFilter]); function errorCB(err) { console.log("Following error occurred: " + err.name); } function findCB(contents) { console.log("Songs found: " + contents.length); } tizen.content.find(findCB, errorCB, null, filter, null, count, offset);
Constructors
-
Constructor (CompositeFilterType, AbstractFilter[]?)
CompositeFilter(CompositeFilterType type, optional AbstractFilter[]? filters);
Attributes
-
CompositeFilterType typeThe composite filter type.
Since: 1.0
-
AbstractFilter[]
filtersThe list of filters in the composite filter.
Since: 1.0
2.7. SortMode
[Constructor(DOMString attributeName, optional SortModeOrder? order)] interface SortMode { attribute DOMString attributeName; attribute SortModeOrder order; };
Since: 1.0
Note that the sorting result of list type attributes is not determined.
Code example:
/* Following example retrieves all songs from the album "The Joshua Tree", by artist "U2", ordered */ /* by the track number. */ var count = 100; var offset = 0; var sortMode = new tizen.SortMode("trackNumber", "ASC"); var artistFilter = new tizen.AttributeFilter("artists", "EXACTLY", "U2"); var albumFilter = new tizen.AttributeFilter("album", "EXACTLY", "The Joshua Tree"); var filter = new tizen.CompositeFilter("INTERSECTION", [albumFilter, artistFilter]); function errorCB(err) { console.log("Following error occurred: " + err.name); } function printContent(content, index, contents) { console.log("Track: " + content.trackNumber + " Title: " + content.title + " Duration: " + content.duration + " URL: " + content.contentURI + " MIME: " + content.mimeType); } function findCB(contents) { console.log("The Joshua Tree by U2:"); contents.forEach(printContent); /* Increase the offset as much as the count and then find content again. */ if (contents.length == count) { offset += count; tizen.content.find(findCB, errorCB, null, filter, sortMode, count, offset); } } tizen.content.find(findCB, errorCB, null, filter, sortMode, count, offset);
Constructors
-
Constructor (DOMString, SortModeOrder?)
SortMode(DOMString attributeName, optional SortModeOrder? order);
Attributes
-
DOMString attributeNameThe name of the object attribute used for sorting.
Since: 1.0
-
SortModeOrder orderThe type of the sorting.
By default, this attribute is set to ASC.
Since: 1.0
2.8. SimpleCoordinates
[Constructor(double latitude, double longitude)] interface SimpleCoordinates { attribute double latitude; attribute double longitude; };
Since: 1.0
Latitude and longitude are of the WGS84 datum.
Code example:
/* This example utilizes methods from Tizen's HAM module to get current latitude and longitude. */ var myPosition; /* Reads current position from the GPS module. */ function onChangedCB(info) { var latitude, longitude; latitude = info.gpsInfo[0].latitude; longitude = info.gpsInfo[0].longitude; /* Packs these values in one variable. */ myPosition = new SimpleCoordinates(latitude, longitude); } /* Starts monitoring GPS info periodically. */ try { tizen.humanactivitymonitor.start( "GPS", onChangedCB, {callbackInterval: 120000, sampleInterval: 60000}); } catch (err) { console.log(err.name + ": " + err.message); }
Attributes
-
double latitudeLatitude.
Since: 1.0
-
double longitudeLongitude.
Since: 1.0
2.9. WebAPIException
[NoInterfaceObject] interface WebAPIException { const unsigned short INDEX_SIZE_ERR = 1; const unsigned short DOMSTRING_SIZE_ERR = 2; const unsigned short HIERARCHY_REQUEST_ERR = 3; const unsigned short WRONG_DOCUMENT_ERR = 4; const unsigned short INVALID_CHARACTER_ERR = 5; const unsigned short NO_DATA_ALLOWED_ERR = 6; const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7; const unsigned short NOT_FOUND_ERR = 8; const unsigned short NOT_SUPPORTED_ERR = 9; const unsigned short INUSE_ATTRIBUTE_ERR = 10; const unsigned short INVALID_STATE_ERR = 11; const unsigned short SYNTAX_ERR = 12; const unsigned short INVALID_MODIFICATION_ERR = 13; const unsigned short NAMESPACE_ERR = 14; const unsigned short INVALID_ACCESS_ERR = 15; const unsigned short VALIDATION_ERR = 16; const unsigned short TYPE_MISMATCH_ERR = 17; const unsigned short SECURITY_ERR = 18; const unsigned short NETWORK_ERR = 19; const unsigned short ABORT_ERR = 20; const unsigned short URL_MISMATCH_ERR = 21; const unsigned short QUOTA_EXCEEDED_ERR = 22; const unsigned short TIMEOUT_ERR = 23; const unsigned short INVALID_NODE_TYPE_ERR = 24; const unsigned short DATA_CLONE_ERR = 25; readonly attribute unsigned short code; readonly attribute DOMString name; readonly attribute DOMString message; };
Since: 2.0
This interface will be used by the APIs to throw errors synchronously.
The attempt to set an attribute value may or may not raise WebAPIException synchronously with error type TypeMismatchError or InvalidValuesError.
Constants
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Since: 2.0
Attributes
-
readonly
unsigned short code16-bit error code.
For the possible values of this attribute, see DOMException.
Since: 2.0
-
readonly
DOMString nameAn error type. The name attribute must return the value it had been initialized with.
This attribute can have one of the following values:
- UnknownError - An unknown error has occurred.
- InvalidValuesError - The content of an object does not contain valid values.
- IOError - An error occurred in communication with the underlying implementation and so the requested method cannot be completed.
- ServiceNotAvailableError - The requested service is not available.
- VerificationError - An error occurred in authentication and so the requested method cannot be completed.
For other possible values of this attribute, see the values defined in DOM error names
Since: 2.0
-
readonly
DOMString messageAn error message that describes the details of an encountered error.
This attribute is mainly intended to be used for developers rather than end users, so it should not be used directly in the user interfaces as it is.
Since: 2.0
2.10. WebAPIError
[NoInterfaceObject] interface WebAPIError { readonly attribute unsigned short code; readonly attribute DOMString name; readonly attribute DOMString message; };
Since: 2.0
This interface will be used by the APIs in order to return them in the error callback of asynchronous methods.
Attributes
-
readonly
unsigned short code16-bit error code.
Possible values are defined in DOMException.
Since: 2.0
-
readonly
DOMString nameAn error type. The name attribute must return the value it had been initialized with.
This attribute can have one of the following values:
- UnknownError - An unknown error has occurred.
- InvalidValuesError - The content of an object does not contain valid values.
- IOError - An error occurred in communication with the underlying implementation and so the requested method cannot be completed.
- ServiceNotAvailableError - The requested service is not available.
- VerificationError - An error occurred in authentication and so the requested method cannot be completed.
For other possible values of this attribute, see the values defined in DOM error names
Since: 2.0
-
readonly
DOMString messageAn error message that describes the details of the error encountered.
This attribute is not intended to be used directly in the user interfaces as it is mainly intended to be useful for developers rather than end users.
Since: 2.0
2.11. SuccessCallback
[Callback=FunctionOnly, NoInterfaceObject] interface SuccessCallback { void onsuccess(); };
Since: 1.0
In case of successful execution of an asynchronous call, SuccessCallback or an API defined callback must be called immediately to notify the user.
Code example:
/* This example assumes that the application "MyFiles" */ /* has been installed correctly and can be launched. */ function onSuccess() { console.log("Application launched successfully"); } /* The ID of launched application. */ var otherAppID = "0pnxz8hbsr.MyFiles"; tizen.application.launch(otherAppID, onSuccess);
2.12. ErrorCallback
[Callback=FunctionOnly, NoInterfaceObject] interface ErrorCallback { void onerror(WebAPIError error); };
Since: 1.0
If an invalid function (such as null) is passed to the API that accepts ErrorCallback, it silently fails and there is no further action.
Code example:
/* This example assumes that the application "NonexistentApp" */ /* has not been installed and can not be launched. */ /* Define the error callback. */ function onError(error) { console.log(error.message); } function onSuccess() { console.log("The application has launched successfully"); } /* The ID of non-existing application. */ var bogusAppID = "NonexistentApp.main"; tizen.application.launch(bogusAppID, onSuccess, onError);
Methods
-
onerror
-
Method that is invoked when an error occurs.
void onerror(WebAPIError error);
Since: 1.0
Parameters:
- error: Generic error.
3. Full WebIDL
module Tizen { enum FilterMatchFlag { "EXACTLY", "FULLSTRING", "CONTAINS", "STARTSWITH", "ENDSWITH", "EXISTS" }; enum SortModeOrder { "ASC", "DESC" }; enum CompositeFilterType { "UNION", "INTERSECTION" }; Window implements TizenObject; [NoInterfaceObject] interface TizenObject { readonly attribute Tizen tizen; }; [NoInterfaceObject] interface Tizen { }; [NoInterfaceObject] interface AbstractFilter { }; [Constructor(DOMString attributeName, optional FilterMatchFlag? matchFlag, optional any matchValue)] interface AttributeFilter : AbstractFilter { attribute DOMString attributeName; attribute FilterMatchFlag matchFlag; attribute any matchValue; }; [Constructor(DOMString attributeName, optional any initialValue, optional any endValue)] interface AttributeRangeFilter : AbstractFilter { attribute DOMString attributeName; attribute any initialValue; attribute any endValue; }; [Constructor(CompositeFilterType type, optional AbstractFilter[]? filters)] interface CompositeFilter : AbstractFilter { attribute CompositeFilterType type; attribute AbstractFilter[] filters; }; [Constructor(DOMString attributeName, optional SortModeOrder? order)] interface SortMode { attribute DOMString attributeName; attribute SortModeOrder order; }; [Constructor(double latitude, double longitude)] interface SimpleCoordinates { attribute double latitude; attribute double longitude; }; [NoInterfaceObject] interface WebAPIException { const unsigned short INDEX_SIZE_ERR = 1; const unsigned short DOMSTRING_SIZE_ERR = 2; const unsigned short HIERARCHY_REQUEST_ERR = 3; const unsigned short WRONG_DOCUMENT_ERR = 4; const unsigned short INVALID_CHARACTER_ERR = 5; const unsigned short NO_DATA_ALLOWED_ERR = 6; const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7; const unsigned short NOT_FOUND_ERR = 8; const unsigned short NOT_SUPPORTED_ERR = 9; const unsigned short INUSE_ATTRIBUTE_ERR = 10; const unsigned short INVALID_STATE_ERR = 11; const unsigned short SYNTAX_ERR = 12; const unsigned short INVALID_MODIFICATION_ERR = 13; const unsigned short NAMESPACE_ERR = 14; const unsigned short INVALID_ACCESS_ERR = 15; const unsigned short VALIDATION_ERR = 16; const unsigned short TYPE_MISMATCH_ERR = 17; const unsigned short SECURITY_ERR = 18; const unsigned short NETWORK_ERR = 19; const unsigned short ABORT_ERR = 20; const unsigned short URL_MISMATCH_ERR = 21; const unsigned short QUOTA_EXCEEDED_ERR = 22; const unsigned short TIMEOUT_ERR = 23; const unsigned short INVALID_NODE_TYPE_ERR = 24; const unsigned short DATA_CLONE_ERR = 25; readonly attribute unsigned short code; readonly attribute DOMString name; readonly attribute DOMString message; }; [NoInterfaceObject] interface WebAPIError { readonly attribute unsigned short code; readonly attribute DOMString name; readonly attribute DOMString message; }; [Callback=FunctionOnly, NoInterfaceObject] interface SuccessCallback { void onsuccess(); }; [Callback=FunctionOnly, NoInterfaceObject] interface ErrorCallback { void onerror(WebAPIError error); }; };