diff -r 913c9751c067 -r 716254ccbcc0 org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-46EABDC1-37CB-412A-ACAD-1A1A9466BB68.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-46EABDC1-37CB-412A-ACAD-1A1A9466BB68.html Fri Mar 05 19:11:15 2010 -0800 @@ -0,0 +1,128 @@ + + +Using +platform services

Using +platform services

+

The S60 platform allows widgets installed +on S60 mobile devices to:

+

+

+

+

The Service APIs are supported since WRT 1.1.

+ +

Using S60 Platform Services and Service +APIs

+

Widgets use the S60 Platform Services through JavaScript +Service APIs provided by the Web Runtime environment. Programming a +widget to access a service through its Service API involves two steps:

+
    +
  1. Create a service +object (an object for calling the Service API) using the getServiceObject() factory method provided by the device object. +This method uses a service provider name and an interface name to create the +appropriate service object:

    + +
    var so = device.getServiceObject(provider, interface);
    +

    Each Service API has a service provider name and supports one interface. +The service provider name identifies the Service API while the interface defines +a set of common methods for service objects.

    +

    For example, the service provider name for the Calendar +Service API is Service.Calendar and the supported +interface is IDataSource. To create a Calendar service +object, use the following code:

    +
    var so = device.getServiceObject("Service.Calendar", "IDataSource");
    + +
  2. +
  3. Use the service +object to call the Service API. The calls to the Service API are made through +the supported interface, since it provides the necessary methods.

    + +

    For example, the IDataSource interface defines +the GetList() method, which returns an object as its +return value. To make a GetList() call with the Calendar +service object created above, use the following code:

    +
    var result = so.IDataSource.GetList(criteria);
    + +
  4. +
+

The only exception to the above is the SystemInfo Service API of WRT +1.0, which is a scriptable plug-in. For instructions on using this API, see +section JavaScript SystemInfo Service API (WRT 1.0).

+
+

Arguments and return values

+

Service API methods use JavaScript objects as arguments and return +values. Argument objects can contain primitive types and other objects. Return +value objects can contain primitive types, objects, arrays, and iterators. +A primitive type is a string, number, or boolean. An object is a type of JavaScript object. +It is a collection of properties. An array is a type of object that stores +values that can be primitive types or objects. These values are accessed by +indexing. An iterator is an object used to traverse through an ordered list +of objects. The getNext() method +on the iterator returns the next object in the ordered list.

+ + +
+

Creating objects in JavaScript

+

In JavaScript, you can create an object in three ways.

+

new() with dot notation syntax:

+
// example 1
+var criteria = new Object();
+criteria.Type = 'FileInfo';
+// example 2 - nested object
+var filter = new Object();
+filter.FileType = 'Sound'
+var criteria = new Object();
+criteria.Filter = filter;
+
+

Object literal syntax:

+
var criteria = { 'Type': 'FileInfo', 'Filter': { 'FileType': 'Sound' } };
+

new() with array syntax:

+
// example 1
+var criteria = new Object();
+criteria ['Type'] = 'FileInfo';
+// example 2 - nested object
+var filter = new Object();
+filter['FileType'] = 'Sound'
+var criteria = new Object();
+criteria ['Filter'] = filter;
+
+
+
\ No newline at end of file