Changes

Jump to: navigation, search

WebAPI/WebTelephony

565 bytes added, 16:53, 5 June 2014
DOM API
We can access the phone functionality simply through navigator.mozTelephony. Once we have a reference to that object, we can start placing and recieving calls by the API below.
 
interface nsIDOMTelephony: nsIDOMEventTarget
{
nsIDOMTelephonyCall dial(in DOMString number);
attribute boolean muted; interface Telephony : EventTarget { /** * There are multiple telephony services in multi-sim architecture. We use * |serviceId| to indicate the target telephony service. If not specified, attribute boolean speakerEnabled; * the implementation MUST use the default service. * // The call that * Possible values of |serviceId| are 0 ~ (number of services - 1), which is "active", i * simply the index of a service. Get number of services by acquiring * |navigator.mozMobileConnections.elength|. receives microphone input and tones */ // generated via startTone.Promise<TelephonyCall> readonly attribute jsval active Promise dial(DOMString number, optional unsigned long serviceId); // Array of all calls that are currently connected.Promise<TelephonyCall> readonly attribute jsval calls Promise dialEmergency(DOMString number, optional unsigned long serviceId); readonly attribute nsIDOMTelephonyCallGroup conferenceGroup; [Throws] void startTone(in DOMString tone, optional unsigned long serviceId); [Throws] void stopTone(optional unsigned long serviceId); [Throws] attribute boolean muted; [Throws] attribute boolean speakerEnabled; readonly attribute (TelephonyCall or TelephonyCallGroup)? active; // A call is contained either in Telephony or in TelephonyCallGroup. readonly attribute CallsList calls; readonly attribute TelephonyCallGroup conferenceGroup; attribute nsIDOMEventListener EventHandler onincoming; attribute nsIDOMEventListener EventHandler oncallschanged; attribute EventHandler onremoteheld; attribute EventHandler onremoteresumed; }; interface nsIDOMTelephonyCallTelephonyCall : nsIDOMEventTargetEventTarget { { // Indicate which service the call comes from. readonly attribute unsigned long serviceId; readonly attribute DOMString number; // "dialing"In CDMA networks, the 2nd waiting call shares the connection with the 1st // call. We need an additional attribute for the 2nd number. readonly attribute DOMString? secondNumber; readonly attribute DOMString state; // The property "alertingemergency", "busy", "connecting", indicates whether the call number is an emergency // number. Only the outgoing call could have a value with true and it is // available after dialing state. readonly attribute boolean emergency; // Indicate whether the call state can be switched between "connected", "disconnecting", and // "disconnected", "incoming", "holding", "held", "resuming". readonly attribute boolean switchable; // Indicate whether the call can be added into TelephonyCallGroup. readonly attribute boolean mergeable; readonly attribute DOMString stateDOMError? error; readonly attribute nsIDOMTelephonyCallGroup TelephonyCallGroup? group; // functions to mediate a call. [Throws] void answer(); [Throws] void hangUp(); [Throws] void hold(); // Resuming a group automatically holds any other groups/calls [Throws] void resume(); attribute nsIDOMEventListener EventHandler onstatechange; attribute nsIDOMEventListener EventHandler ondialing; attribute nsIDOMEventListener EventHandler onalerting; attribute nsIDOMEventListener onbusy; attribute nsIDOMEventListener EventHandler onconnecting; attribute nsIDOMEventListener EventHandler onconnected; attribute nsIDOMEventListener EventHandler ondisconnecting; attribute nsIDOMEventListener EventHandler ondisconnected; attribute nsIDOMEventListener onincomingEventHandler onholding; attribute nsIDOMEventListener onholdingEventHandler onheld; attribute nsIDOMEventListener onheldEventHandler onresuming; attribute nsIDOMEventListener onresumingEventHandler onerror; // Fired whenever the .group attribute changes. attribute nsIDOMEventListener EventHandler ongroupchange; }; interface nsIDOMTelephonyCallGroup TelephonyCallGroup : nsIDOMEventTarget EventTarget { // Array of all calls that are currently in this group. The length // of this array is never 1. readonly attribute jsval CallsList calls; // Add a call to the callgroup. call2 must not be specified if the [Throws] // callgroup isn't empty. // If the callgroup is empty both void add(TelephonyCall call and call2 must be specified, // and one of them must be in 'held' state and the other in); // 'connected' state. // Neither call or call2 can be in 'disconnected' state. [Throws] void add(nsIDOMTelephonyCall TelephonyCall call, optional nsIDOMTelephonyCall call2TelephonyCall secondCall); // Removes a call from the callgroup. If this leaves the callgroup with [Throws] // just one call, then that last call is also removed from the callgroup. void remove(nsIDOMTelephonyCall TelephonyCall call); [Throws] void hold(); // Resuming a group automatically holds any other groups/calls [Throws] void resume(); // When this changes, the state of all contained calls changes at the same time readonly attribute DOMString state; attribute nsIDOMEventListener EventHandler onstatechange; attribute nsIDOMEventListener EventHandler onconnected; attribute nsIDOMEventListener EventHandler onholding; attribute nsIDOMEventListener EventHandler onheld; attribute nsIDOMEventListener EventHandler onresuming; attribute EventHandler oncallschanged; // Fires when the array in the 'calls' property changes. attribute nsIDOMEventListener oncallschangedEventHandler onerror; };
=== Example ===
Confirm
53
edits

Navigation menu