Bug 709565 - B2G telephony: implement DTMF. r=philikon

This commit is contained in:
Kyle Machulis 2011-12-16 13:47:32 -08:00
parent 1aa0b162dd
commit 52aa632c7f
5 changed files with 99 additions and 13 deletions

View File

@ -73,9 +73,9 @@ const CALLINDEX_TEMPORARY_DIALING = -1;
/**
* Define an event listener slot on an object, e.g.
*
*
* obj.onerror = function () {...}
*
*
* will register the function as an event handler for the "error" event
* if the "error" slot was defined on 'obj' or its prototype.
*/
@ -274,7 +274,7 @@ Telephony.prototype = {
event.call = call; //XXX this is probably not going to work
//event.isTrusted = true;
target = target || call;
target.dispatchEvent(event);
target.dispatchEvent(event);
},
_processCallState: function _processCallState(state) {
@ -356,6 +356,14 @@ Telephony.prototype = {
return call;
},
startTone: function startTone(dtmfChar) {
this.telephone.startTone(dtmfChar);
},
stopTone: function stopTone() {
this.telephone.stopTone();
},
get muted() {
return this.telephone.microphoneMuted;
},

View File

@ -40,11 +40,13 @@
interface nsIDOMEventListener;
interface mozIDOMTelephonyCall;
[scriptable, uuid(55b23b6e-ef31-4a30-bddb-15ce9274dad8)]
[scriptable, uuid(c7b0046b-ee80-447c-8a95-a389003891bc)]
interface mozIDOMTelephony : nsIDOMEventTarget {
readonly attribute jsval liveCalls;
mozIDOMTelephonyCall dial(in DOMString number);
void startTone(in DOMString dtmfChar);
void stopTone();
attribute nsIDOMEventListener onincoming;
attribute boolean muted;

View File

@ -55,6 +55,8 @@ interface nsITelephone : nsISupports {
void dial(in DOMString number);
void hangUp(in long callIndex);
void startTone(in DOMString dtmfChar);
void stopTone();
void answerCall();
void rejectCall();
attribute bool microphoneMuted;

View File

@ -233,6 +233,16 @@ nsTelephonyWorker.prototype = {
debug("Hanging up call no. " + callIndex);
this.worker.postMessage({type: "hangUp", callIndex: callIndex});
},
startTone: function startTone(dtmfChar) {
debug("Sending Tone for " + dtmfChar);
this.worker.postMessage({type: "startTone", dtmfChar: dtmfChar});
},
stopTone: function stopTone() {
debug("Stopping Tone");
this.worker.postMessage({type: "stopTone"});
},
answerCall: function answerCall() {
this.worker.postMessage({type: "answerCall"});

View File

@ -50,7 +50,7 @@
*
* The three objects in this file represent individual parts of this
* communication chain:
*
*
* - RILMessageEvent -> Buf -> RIL -> Phone -> postMessage()
* - "message" event -> Phone -> RIL -> Buf -> postRILMessage()
*
@ -513,7 +513,7 @@ let RIL = {
/**
* Retrieve the ICC card's status.
*
*
* Response will call Phone.onICCStatus().
*/
getICCStatus: function getICCStatus() {
@ -522,7 +522,7 @@ let RIL = {
/**
* Enter a PIN to unlock the ICC.
*
*
* @param pin
* String containing the PIN.
*
@ -684,6 +684,29 @@ let RIL = {
Buf.sendParcel();
},
/**
* Start a DTMF Tone.
*
* @param dtmfChar
* DTMF signal to send, 0-9, *, +
*/
startTone: function startTone(dtmfChar) {
Buf.newParcel(REQUEST_DTMF_START);
Buf.writeString(dtmfChar);
Buf.sendParcel();
},
stopTone: function stopTone() {
Buf.simpleRequest(REQUEST_DTMF_STOP);
},
sendTone: function sendTone(dtmfChar) {
Buf.newParcel(REQUEST_DTMF);
Buf.writeString(dtmfChar);
Buf.sendParcel();
},
/**
* Handle incoming requests from the RIL. We find the method that
* corresponds to the request type. Incidentally, the request type
@ -832,7 +855,9 @@ RIL[REQUEST_OPERATOR] = function REQUEST_OPERATOR(length) {
Phone.onOperator(operator);
};
RIL[REQUEST_RADIO_POWER] = null;
RIL[REQUEST_DTMF] = null;
RIL[REQUEST_DTMF] = function REQUEST_DTMF() {
Phone.onSendTone();
};
RIL[REQUEST_SEND_SMS] = function REQUEST_SEND_SMS() {
let messageRef = Buf.readUint32();
let ackPDU = p.readString();
@ -873,8 +898,12 @@ RIL[REQUEST_QUERY_NETWORK_SELECTION_MODE] = function REQUEST_QUERY_NETWORK_SELEC
RIL[REQUEST_SET_NETWORK_SELECTION_AUTOMATIC] = null;
RIL[REQUEST_SET_NETWORK_SELECTION_MANUAL] = null;
RIL[REQUEST_QUERY_AVAILABLE_NETWORKS] = null;
RIL[REQUEST_DTMF_START] = null;
RIL[REQUEST_DTMF_STOP] = null;
RIL[REQUEST_DTMF_START] = function REQUEST_DTMF_START() {
Phone.onStartTone();
};
RIL[REQUEST_DTMF_STOP] = function REQUEST_DTMF_STOP() {
Phone.onStopTone();
};
RIL[REQUEST_BASEBAND_VERSION] = function REQUEST_BASEBAND_VERSION() {
let version = Buf.readString();
Phone.onBasebandVersion(version);
@ -1270,11 +1299,19 @@ let Phone = {
onSetMute: function onSetMute() {
},
onSendTone: function onSendTone() {
},
onStartTone: function onStartTone() {
},
onStopTone: function onStopTone() {
},
onSendSMS: function onSendSMS(messageRef, ackPDU, errorCode) {
//TODO
},
/**
* Outgoing requests to the RIL. These can be triggered from the
* main thread via messages that look like this:
@ -1309,6 +1346,33 @@ let Phone = {
RIL.dial(options.number, 0, 0);
},
/**
* Send DTMF Tone
*
* @param dtmfChar
* String containing the DTMF signal to send.
*/
sendTone: function sendTone(options) {
RIL.sendTone(options.dtmfChar);
},
/**
* Start DTMF Tone
*
* @param dtmfChar
* String containing the DTMF signal to send.
*/
startTone: function startTone(options) {
RIL.startTone(options.dtmfChar);
},
/**
* Stop DTMF Tone
*/
stopTone: function stopTone() {
RIL.stopTone();
},
/**
* Hang up a call.
*
@ -1364,9 +1428,9 @@ let Phone = {
/**
* Handle incoming messages from the main UI thread.
*
*
* @param message
* Object containing the message. Messages are supposed
* Object containing the message. Messages are supposed
*/
handleDOMMessage: function handleMessage(message) {
if (DEBUG) debug("Received DOM message " + JSON.stringify(message));