© 2009 OMTP Ltd. All rights reserved. OMTP and OMTP BONDI are registered trademarks of OMTP Ltd.
Provides access to the device status from the web context
PropertyChangeSuccessCallback
DeviceStatusError
DeviceStatusManager
AspectName
PropertyRef
| Interface | Method |
|---|---|
| PropertyChangeSuccessCallback | void onPropertyChange(PropertyRef property, Object newValue) |
| DeviceStatusError | |
| DeviceStatusManager | StringArray listVocabularies() void setDefaultVocabulary(DOMString vocabulary) StringArray listAspects() StringArray getComponents(AspectName aspect) StringArray listProperties(AspectName aspect) Object getPropertyValue(PropertyRef prop) void setPropertyValue(PropertyRef pref, Object value) unsigned integer watchPropertyChange(PropertyRef pref, PropertyChangeSuccessCallback listener, Map options) void clearPropertyChange(unsigned long watchHandler) |
| AspectName | |
| PropertyRef |
The status information is organized in a tree of properties grouped by category. The interface provides methods to browse the tree, to get/set the value of a selected property and to set up asynchronous notifications of changes in certain values.
This interface defines the access to the properties of the DeviceStatus but does not specify which aspects or properties are available. To browse a comprehensive list of properties, please refer to the BONDI Property Classification document.
This is the list of URIs used to declare this API's features, for use in bondi.requestFeature. For each URL, the list of functions provided is provided.
Call to getPropertyValue or addEventListener in DeviceStatusManager
Device capabilities: devicestatus.get
Call to setPropertyValue in DeviceStatusManager
Device capabilities: devicestatus.set
Call to listVocabularies, listAspects, listProperties or getComponents in DeviceStatusManager
Device capabilities: devicestatus.list
devicestatus.get
Get (or subscribe to) device status property value
Security parameters:
vocabulary:
Vocabulary IRI
component:
Component Identifier
aspect:
Local Aspect Name
property:
Local Property Name
devicestatus.set
Set device status property value
Security parameters:
vocabulary:
Vocabulary IRI
component:
Component Identifier
aspect:
Local Aspect Name
property:
Local Property Name
devicestatus.list
List available elements in the vocabulary
Security parameters:
level:
One of (vocabulary, aspect, component, property)
PropertyChangeSuccessCallback
Device Status Listener success callback.
[Callback=FunctionOnly, NoInterfaceObject] interface PropertyChangeSuccessCallback {
void onPropertyChange(in PropertyRef property, in Object newValue);
};
Success callback for notifying changes to a property. When the callback is invoked its input parameters are the PropertyRef of the property being watched and its new value.
onPropertyChange
Method invoked to notify about property changes
void onPropertyChange(PropertyRef property, Object newValue);
DeviceStatusError
Device Status specific errors.
interface DeviceStatusError : GenericError {
const unsigned short READ_ONLY_PROPERTY_ERROR = 1;
};
This interface inherits from: GenericError
unsigned
short
READ_ONLY_PROPERTY_ERROR
Property is read only
DeviceStatusManager
Simple Context API for querying/modifying the status of the device (BONDI Terminal Status Interfaces Requirements, Section 9)
interface DeviceStatusManager {
StringArray listVocabularies();
void setDefaultVocabulary(in DOMString vocabulary)
raises(DeviceAPIError);
StringArray listAspects();
StringArray getComponents(in AspectName aspect)
raises(DeviceAPIError);
StringArray listProperties(in AspectName aspect)
raises(DeviceAPIError);
Object getPropertyValue(in PropertyRef prop)
raises(SecurityError, DeviceAPIError);
void setPropertyValue(in PropertyRef pref, in Object value)
raises(SecurityError, DeviceAPIError, DeviceStatusError);
unsigned long watchPropertyChange(in PropertyRef pref,
in PropertyChangeSuccessCallback listener,
in Map options)
raises(SecurityError, DeviceAPIError);
void clearPropertyChange(in unsigned long watchHandler)
raises(DeviceAPIError);
};
This module offers the functionality to get information about the device status. The status information is structured in:
- "Vocabularies": (similar to namespaces) BONDI has specified a vocabulary available at BONDI Vocabulary
- "Aspects": A vocabulary is composed of different aspects that gather information related to a unique aspect of the device (e.g. 'WebBrowser', 'GraphicDisplay', 'Memory').
- "Components": An aspect may comprise different components that are intended to describe different
instances of the same aspect (e.g. 'Memory' aspect may have three different components
'physical', 'virtual', 'storage').
There are two special component identifiers:
* _default: which denotes the default component of an aspect
* _active: which denotes the Active component of an aspect
- "Properties": Aspects are composed of properties which provide information about a particular property of the component, for instance for every 'Memory' component the properties 'total', 'available', 'removable' are supported.
When trying to resolve a property, the only mandatory parameter is the property name. If no other data is specified the implementation will look in the default vocabulary for the default aspect/component pair including a property with the given name.
// Get the batteryLevel property of the Battery aspect.
var batteryLevel = bondi.devicestatus.getPropertyValue({property:"batteryLevel", aspect:"Battery", component:"_default"});
alert("The current battery level is: " + batteryLevel);
listVocabularies
Lists the vocabularies available
StringArray listVocabularies();
Every vocabulary returned is identified by an IRI. At the very least BONDI vocabulary will always be available. Other vocabularies may also be implemented.
var vocabularies = bondi.devicestatus.listVocabularies();
setDefaultVocabulary
Sets the default vocabulary to be used when a vocabulary is not specified.
void setDefaultVocabulary(DOMString vocabulary);
The selected vocabulary specified in the input parameter MUST be one of the returned by the listVocabularies() method. In case the vocabulary is not found, a DeviceAPIError with NOT_FOUND_ERROR code will be raised. By default, BONDI vocabulary is selected.
bondi.devicestatus.setDefaultVocabulary("http://bondi.omtp.org");
listAspects
Lists all the aspects for a specific vocabulary.
StringArray listAspects();
An aspect is a category of properties, like Battery, Display or NetworkConnection. This method returns a list of all the aspects supported by a specific vocabulary.
If no explicit vocabulary is specified, the default vocabulary is used.
var aspects = bondi.devicestatus.listAspects();
getComponents
Returns the name of all the components that are instances of the specified aspect.
StringArray getComponents(AspectName aspect);
This method provides information on all the different components that compose an aspect. An aspect is determined by the vocabulary IRI and the aspect name.
If no vocabulary is specified, the default vocabulary will be used.
If the vocabulary or the aspect do not have a valid value, the method will return a DeviceAPIError with code INVALID_ARGUMENT_ERROR
If the aspect is valid, but the implementation has not implemented that aspect, the method will raise a DeviceAPIError with code NOT_FOUND_ERROR
If the vocabulary exists and the aspect is valid, it will return all the different components part of the aspects.
var cameras = bondi.devicestatus.getComponents({aspect:'Camera'});
listProperties
Returns the names of all the properties in the specified aspect.
StringArray listProperties(AspectName aspect);
An aspect is determined by the vocabulary IRI and the aspect name.
If no vocabulary is specified the default vocabulary will be used.
If the vocabulary or the aspect do not have a valid value the method will return a DeviceAPIError with code INVALID_ARGUMENT_ERROR
If the aspect is valid but the implementation has not implemented that aspect the method will raise a DeviceAPIError with code NOT_FOUND_ERROR
If the vocabulary exists and the aspect is valid it will return all the different properties part of the aspects.
var props = bondi.devicestatus.listProperties({aspect:'Camera'});
getPropertyValue
Returns the value of a specific property referenced by a PropertyRef.
Object getPropertyValue(PropertyRef prop);
This method returns the value of a property in a vocabulary.
The property name is mandatory; the vocabulary, aspect and
components are optional. The implementation will use the
following rules if optional elements are not specified:
- If no vocabulary is specified, the default vocabulary will
be used.
- If the aspect is not specified, the first aspect with a
property matching the property name will be used.
- If the component is not specified, the primary component of
the given aspect will be used.
- If an invalid propertyName is specified a DeviceAPIError
with code INVALID_ARGUMENT_ERROR will be raised.
- If the propertyName is valid but the implementation has not
implemented that property a DeviceAPIError with code
NOT_FOUND_ERROR will be raised.
var level = bondi.devicestatus.getPropertyValue({property:"batteryLevel", aspect:"Battery", component:"_default"});
// The above call is equivalent to:
var level = bondi.devicestatus.getPropertyValue({property:"batteryLevel", aspect:"Battery"});
// or
var level = bondi.devicestatus.getPropertyValue({property:"batteryLevel"});
setPropertyValue
Sets the value of a property
void setPropertyValue(PropertyRef pref, Object value);
This method changes the value of a property to that given by the value parameter
The property name in the pref attribute is mandatory. The
vocabulary, aspect and component are optional. The
implementation will use the following rules if optional elements
are not specified:
- If no vocabulary is specified the default vocabulary will
be used.
- If the aspect is not specified the first aspect with a
property matching the property name will be used.
- If the component is not specified the primary component of
the given aspect will be used.
- If an invalid propertyName is specified a DeviceAPIError
with code INVALID_ARGUMENT_ERROR will be raised.
- If the propertyName is valid but the implementation has not
implemented that property a DeviceAPIError with code
NOT_FOUND_ERROR will be raised.
- If the property can not be written a DeviceStatusError with
code READ_ONLY_PROPERTY_ERROR will be raised
bondi.devicestatus.setPropertyValue({property:"orientation", aspect:"Display"}, 0);
watchPropertyChange
Registers for property change notifications.
unsigned long watchPropertyChange(PropertyRef pref, PropertyChangeSuccessCallback listener, Map options);
The property name in the pref attribute is mandatory; the
vocabulary, aspect and component are optional. The
implementation will use the following rules if optional elements
are not specified:
- If no vocabulary is specified the default vocabulary will
be used.
- If the aspect is not specified the first aspect with a
property matching the property name will be used.
- If the component is not specified the primary component of
the given aspect will be used.
The callback argument is mandatory. Whenever the watched property value changes the system will call the supplied callback passing the full PropertyRef of the modified property and the property's new value.
The options argument is optional, and is used to specify the
granularity of the notifications. If any option is invalid
it will be ignored. The permitted options are:
- "minTimeout": Minimum time between notifications, expressed
in milliseconds. Default value 0.
- "maxTimeout": Maximum time between notifification,
expressed in milliseconds. The callback will be called
after the specified time even if the property has not
changed in the meantime. maxTimeout must always be greater
than minTimeout. Default value: infinite.
- "callCallbackOnRegister": Call the callback just after the
callback was registered. Simplifies the task of inlining
the implementation of the callback and initializing the
application. Default value: false.
- "minChangePercent": Sets the minimum change percent of the
value, when the type is numeric. For example if the last
value was 100, and the specified minChangePercent is 20%,
Then the value must go under 80 or over 120 to get
notified. Default value: 0.
If an invalid propertyName is specified, a DeviceAPIError with code INVALID_ARGUMENT_ERROR will be raised.
If the propertyName is valid, but the implementation has not implemented that property, a DeviceAPIError with code NOT_FOUND_ERROR will be raised.
var orientationChangeHandler = bondi.devicestatus.watchPropertyChange({aspect:"display", property:"orientation"},
{
onPropertyChange:function(ref, value) {
alert("Property changed: "+ref.property+" "+ref.component+" "+ref.aspect+" "+ref.vocabulary);
alert("New value: "+value);
}
}, {
minTimeout:1000,
callCallbackOnRegister:true
}
);
clearPropertyChange
Unregister notifications from a property change.
void clearPropertyChange(unsigned long watchHandler);
If the watchHandler identifier does not exist, a DeviceAPIError with code INVALID_ARGUMENT_ERROR will be raised
bondi.devicestatus.clearPropertyChange(orientationChangeHandler);
AspectName
Class to unequivocally refer to an aspect by its name and vocabulary (namespace)
interface AspectName {
attribute DOMString aspect;
attribute DOMString vocabulary;
};
If no vocabulary is specified the default vocabulary will be used.
DOMString
aspect
Local Aspect Name
ref.aspect = "battery";
DOMString
vocabulary
Vocabulary IRI (the namespace)
ref.vocabulary = BONDI_VOC;
PropertyRef
Full reference to a property, specified by the property name, the component name, the aspect name and the vocabulary namespace. It is used to refer to a single property inside the vocabulary. The "property" attribute is mandatory and the remainder optional.
interface PropertyRef {
attribute DOMString vocabulary;
attribute DOMString component;
attribute DOMString aspect;
attribute DOMString property;
};
var dpiXProperty = {property:"dpiX"};
var batteryLevelProperty = {vocabulary:BONDI_VOC, aspect:"battery", component:"default", property:"batteryLevel" };
DOMString
vocabulary
Vocabulary IRI (optional)
DOMString
component
Component Identifier (optional)
DOMString
aspect
Local Aspect Name (optional)
DOMString
property
Local Property Name (mandatory)