tizen api this api provides common tizen functionality. 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 data filtering and sorting guide or error handling guide. since: 1.0 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 the tizen interface as a part of the window global object. [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. 2.2. tizen the root of the tizen web device api. [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 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); 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. 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: function onsuccess() { console.log("application launched successfully"); } tizen.application.launch('0pnxz8hbsr.myfiles', 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: // define the error callback. function onerror(error) { console.log(error.message); } function onsuccess() { console.log("the application has launched successfully"); } tizen.application.launch("targetapp0.main", 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); }; };