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

This commit is contained in:
Kyle Machulis 2011-12-16 13:47:32 -08:00
Родитель c3d1c5ea79
Коммит 9d0499d944
5 изменённых файлов: 99 добавлений и 13 удалений

Просмотреть файл

@ -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;
},

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -234,6 +234,16 @@ nsTelephonyWorker.prototype = {
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"});
},

Просмотреть файл

@ -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.
*