Tizen API

This API provides common Tizen functionality.

The API provides the basic definitions that are used in 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 Tizen Web Device API is instantiated (window.tizen).

For more information on Tizen features, see Tizen Guide.

Since: 1.0

Table of Contents


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

Filter match flags.
  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

An enumerator that indicates the sorting order.
  enum SortModeOrder { "ASC", "DESC" };

Since: 1.0

The following values are supported:

  • ASC - Indicates that the sorting order is ascending
  • DESC - Indicates that the sorting order is descending

1.3 CompositeFilterType

An enumerator that indicates the type of composite filter.
  enum CompositeFilterType { "UNION", "INTERSECTION" };

Since: 1.0

The 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

Defines Tizen interface as a part of the window global object.
  [NoInterfaceObject] interface TizenObject {
    readonly attribute Tizen tizen;
  };
  Window implements TizenObject;

Since: 1.0

Tizen interface is always available within the Window object in the ECMAScript hierarchy.

2.2 Tizen

The root of Tizen Web Device API.
  [NoInterfaceObject] interface Tizen {
  };

Since: 1.0

This is Tizen root interface. It is a property of the ECMAScript global object, as specified by TizenObject interface.

2.3 AbstractFilter

This is a common interface used by different types of object filters.
  [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

This interface represents a set of filters.
  [Constructor(DOMString attributeName, optional FilterMatchFlag? matchFlag, optional any matchValue)]
  interface AttributeFilter : AbstractFilter {
    attribute DOMString attributeName;

    attribute FilterMatchFlag matchFlag setraises(WebAPIException);

    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:

 // The 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('The 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

AttributeFilter(DOMString attributeName, optional FilterMatchFlag? matchFlag, optional any matchValue);

Attributes

  • DOMString attributeName

    The 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 matchFlag
    The match flag used for attribute-based filtering.

    By default, this attribute is set to "EXACTLY".

    Since: 1.0

  • any matchValue
    The 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

AttributeRangeFilter represents a filter based on an object attribute which has values that are within a particular range.
  [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('The 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

AttributeRangeFilter(DOMString attributeName, optional any initialValue, optional any endValue);

Attributes

  • DOMString attributeName

    The 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 initialValue
    Objects 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 endValue
    Objects 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

CompositeFilter represents a set of filters.
  [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:

 // The 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('The 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:

 // The 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('The 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

CompositeFilter(CompositeFilterType type, optional AbstractFilter[]? filters);

Attributes

  • CompositeFilterType type

    The composite filter type.

    Since: 1.0

  • AbstractFilter[] filters
    The list of filters in the composite filter.

    Since: 1.0

2.7 SortMode

SortMode is a common interface used for sorting of queried data.
  [Constructor(DOMString attributeName, optional SortModeOrder? order)]
  interface SortMode {
    attribute DOMString attributeName;

    attribute SortModeOrder order setraises(WebAPIException);
  };

Since: 1.0

Note that the sorting result of list type attributes is not determined.

Code example:

 // The 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('The 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

SortMode(DOMString attributeName, optional SortModeOrder? order);

Attributes

  • DOMString attributeName

    The name of the object attribute used for sorting.

    Since: 1.0

  • SortModeOrder order
    The type of the sorting.

    By default, this attribute is set to ASC.

    Since: 1.0

2.8 SimpleCoordinates

SimpleCoordinates represents a point (latitude and longitude) in the map coordinate system.
  [Constructor(double latitude, double longitude)]
  interface SimpleCoordinates {
    attribute double latitude setraises(WebAPIException);

    attribute double longitude setraises(WebAPIException);
  };

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);
   }
 

Constructors

SimpleCoordinates(double latitude, double longitude);

Attributes

  • double latitude

    Latitude.

    Since: 1.0

  • double longitude
    Longitude.

    Since: 1.0

2.9 WebAPIException

Generic exception interface.
  [NoInterfaceObject]
  interface WebAPIException {
    readonly attribute unsigned short code;

    readonly attribute DOMString name;

    readonly attribute DOMString message;

    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;
  };

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

  • INDEX_SIZE_ERR

    The index is not in the allowed range.

    Since: 2.0

     

  • DOMSTRING_SIZE_ERR
    The specified range of text is too large.

    Since: 2.0

     

  • HIERARCHY_REQUEST_ERR
    The operation would yield an incorrect node tree.

    Since: 2.0

     

  • WRONG_DOCUMENT_ERR
    The object is in the wrong document.

    Since: 2.0

     

  • INVALID_CHARACTER_ERR
    The string contains invalid characters.

    Since: 2.0

     

  • NO_DATA_ALLOWED_ERR
    Data is specified for a node that does not support data.

    Since: 2.0

     

  • NO_MODIFICATION_ALLOWED_ERR
    The object cannot be modified.

    Since: 2.0

     

  • NOT_FOUND_ERR
    The object cannot be found here.

    Since: 2.0

     

  • NOT_SUPPORTED_ERR
    The operation is not supported.

    Since: 2.0

     

  • INUSE_ATTRIBUTE_ERR
    The specified attribute is already in use elsewhere.

    Since: 2.0

     

  • INVALID_STATE_ERR
    The object is in an invalid state.

    Since: 2.0

     

  • SYNTAX_ERR
    The string did not match the expected pattern.

    Since: 2.0

     

  • INVALID_MODIFICATION_ERR
    The object cannot be modified in this way.

    Since: 2.0

     

  • NAMESPACE_ERR
    The operation is not allowed by Namespaces in XML.

    Since: 2.0

     

  • INVALID_ACCESS_ERR
    The object does not support the operation or argument.

    Since: 2.0

     

  • VALIDATION_ERR
    The operation would cause the node to fail validation.

    Since: 2.0

     

  • TYPE_MISMATCH_ERR
    The type of the object does not match the expected type.

    Since: 2.0

     

  • SECURITY_ERR
    The operation is insecure.

    Since: 2.0

     

  • NETWORK_ERR
    A network error occurred.

    Since: 2.0

     

  • ABORT_ERR
    The operation has been aborted.

    Since: 2.0

     

  • URL_MISMATCH_ERR
    The given URL does not match another URL.

    Since: 2.0

     

  • QUOTA_EXCEEDED_ERR
    The quota has been exceeded.

    Since: 2.0

     

  • TIMEOUT_ERR
    The operation has timed out.

    Since: 2.0

     

  • INVALID_NODE_TYPE_ERR
    The supplied node is incorrect or has an incorrect ancestor for this operation.

    Since: 2.0

     

  • DATA_CLONE_ERR
    The object cannot be cloned.

    Since: 2.0

     

Attributes

  • readonly unsigned short code

    16-bit error code.

    For the possible values of this attribute, see DOMException.

    Since: 2.0

  • readonly DOMString name
    An 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 message
    An 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

Generic error interface.
  [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 code

    16-bit error code.

    Possible values are defined in DOMException.

    Since: 2.0

  • readonly DOMString name
    An 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 message
    An 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

This interface is used in methods that do not require any return value in the success callback.
  [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);
 

Methods

onsuccess
Method invoked when the asynchronous call completes successfully.
void onsuccess();
             

Since: 1.0

2.12 ErrorCallback

This interface is used in methods that require only an error as an input parameter in the error callback.
  [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" };

  [NoInterfaceObject] interface TizenObject {
    readonly attribute Tizen tizen;
  };
  Window implements TizenObject;

  [NoInterfaceObject] interface Tizen {
  };

  [NoInterfaceObject] interface AbstractFilter {
  };

  [Constructor(DOMString attributeName, optional FilterMatchFlag? matchFlag, optional any matchValue)]
  interface AttributeFilter : AbstractFilter {
    attribute DOMString attributeName;

    attribute FilterMatchFlag matchFlag setraises(WebAPIException);

    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 setraises(WebAPIException);
  };

  [Constructor(double latitude, double longitude)]
  interface SimpleCoordinates {
    attribute double latitude setraises(WebAPIException);

    attribute double longitude setraises(WebAPIException);
  };

  [NoInterfaceObject]
  interface WebAPIException {
    readonly attribute unsigned short code;

    readonly attribute DOMString name;

    readonly attribute DOMString message;

    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;
  };

  [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);
  };
};