Bug 708446 - Part 3: Implement mute and speaker. r=mrbkap a=khuey

This commit is contained in:
Philipp von Weitershausen 2011-12-12 10:30:43 -08:00
parent 221092b136
commit 984dca283f
4 changed files with 48 additions and 2 deletions

View File

@ -356,6 +356,20 @@ Telephony.prototype = {
return call;
},
get muted() {
return this.telephone.microphoneMuted;
},
set muted(value) {
this.telephone.microphoneMuted = value;
},
get speakerOn() {
return this.telephone.speakerEnabled;
},
set speakerOn(value) {
this.telephone.speakerEnabled = value;
},
// Additional stuff that's useful.
signalStrength: null,

View File

@ -40,13 +40,16 @@
interface nsIDOMEventListener;
interface mozIDOMTelephonyCall;
[scriptable, uuid(24371c72-1631-477d-b26e-f14db369bc22)]
[scriptable, uuid(55b23b6e-ef31-4a30-bddb-15ce9274dad8)]
interface mozIDOMTelephony : nsIDOMEventTarget {
readonly attribute jsval liveCalls;
mozIDOMTelephonyCall dial(in DOMString number);
attribute nsIDOMEventListener onincoming;
attribute boolean muted;
attribute boolean speakerOn;
//XXX philikon's additions
attribute nsIDOMEventListener onoperatorchange;
attribute nsIDOMEventListener onradiostatechange;

View File

@ -48,7 +48,7 @@ interface nsITelephoneCallback : nsISupports {
void onsignalstrengthchange(in jsval event);
};
[scriptable, uuid(3d3deb80-fa5e-4e05-9153-91ee614f67d5)]
[scriptable, uuid(f6baa721-665e-403e-8a98-acaa0d8bf267)]
interface nsITelephone : nsISupports {
readonly attribute jsval currentState;
@ -57,6 +57,8 @@ interface nsITelephone : nsISupports {
void hangUp(in long callIndex);
void answerCall();
void rejectCall();
attribute bool microphoneMuted;
attribute bool speakerEnabled;
void registerCallback(in nsITelephoneCallback callback);
void unregisterCallback(in nsITelephoneCallback callback);

View File

@ -242,6 +242,33 @@ nsTelephonyWorker.prototype = {
this.worker.postMessage({type: "rejectCall"});
},
get microphoneMuted() {
return gAudioManager.microphoneMuted;
},
set microphoneMuted(value) {
if (value == this.microphoneMuted) {
return;
}
gAudioManager.phoneState = value ?
Ci.nsIAudioManager.PHONE_STATE_IN_COMMUNICATION :
Ci.nsIAudioManager.PHONE_STATE_IN_CALL; //XXX why is this needed?
gAudioManager.microphoneMuted = value;
},
get speakerEnabled() {
return (gAudioManager.getForceForUse(Ci.nsIAudioManager.USE_COMMUNICATION)
== Ci.nsIAudioManager.FORCE_SPEAKER);
},
set speakerEnabled(value) {
if (value == this.speakerEnabled) {
return;
}
gAudioManager.phoneState = Ci.nsIAudioManager.PHONE_STATE_IN_CALL; // XXX why is this needed?
let force = value ? Ci.nsIAudioManager.FORCE_SPEAKER :
Ci.nsIAudioManager.FORCE_NONE;
gAudioManager.setForceUse(Ci.nsIAudioManager.USE_COMMUNICATION, force);
},
_callbacks: null,
registerCallback: function registerCallback(callback) {