Proposal for an improved and simplied Telephony API (José M. Cantera, Telefónica I+D)
navigator.telephony would return an object with the following interface
interface Telephony : EventTarget {
TelephonySession newSession(DOMString number); // Multiple number call??
readonly attribute TelephonySession liveSession;
attribute Function onincoming;
}
interface TelephonySession : EventTarget {
readonly attribute DOMString originNumber;
readonly attribute DOMString number;
// Do the call
void call();
attribute boolean muted;
attribute boolean speakerOn;
void startTone(DOMString tone);
void stopTone();
void sendTones(DOMString tones,
[optional] unsigned long toneDuration,
[optional] unsigned long intervalDuration);
readonly attribute DOMString readyState; // "calling", "incomming", "connected", "closed", "busy"
// Can we get info on when a call goes from "trying to place call" to "calling"?
attribute Function onconnect;
attribute Function ondisconnect;
attribute Function onbusy;
attribute Function onreadystatechange;
void answer();
void hangUp();
}
interface IncomingCallEvent : Event {
readonly attribute TelephonySession session;
}
philikon's thoughts
- IMHO
navigator.telephony.dial("numbergoeshere");is nicer thannew TelephonyCall("numbergoeshere"); - We have a bunch of telephony-related functionality that's not reflected yet:
- controlling and reading radio power
- reading radio metadata (operator, signal strength, etc.)
- ...
- I would also suggest another readyState,
"dialing"that comes before"calling"for outgoing calls. - Nits: we should probably define the possible values for readyState on the interface (nit: for XHR they're ints, not strings... I like being consistent, but I also prefers strings... hmmm...). Also, event listener objects should probably be declared as
EventListener.
My proposal on this (as a delta to the main proposal):
interface Telephony {
void power(bool on);
Some thoughts on this:
TelephonyCall dial(String number);
EventListener onpowerchange
EventListener onsignalstrengthchange
EventListener onoperatorchange
}