mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 814634 - part4 - RIL and tests. r=vicamo
This commit is contained in:
parent
99a3a4b63a
commit
b889245961
@ -271,7 +271,9 @@ MobileCellInfo.prototype = {
|
||||
cdmaNetworkId: -1
|
||||
};
|
||||
|
||||
function VoicemailStatus() {}
|
||||
function VoicemailStatus(clientId) {
|
||||
this.serviceId = clientId;
|
||||
}
|
||||
VoicemailStatus.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozVoicemailStatus]),
|
||||
classID: VOICEMAILSTATUS_CID,
|
||||
@ -284,8 +286,9 @@ VoicemailStatus.prototype = {
|
||||
|
||||
// nsIDOMMozVoicemailStatus
|
||||
|
||||
serviceId: -1,
|
||||
hasMessages: false,
|
||||
messageCount: Ci.nsIDOMMozVoicemailStatus.MESSAGE_COUNT_UNKNOWN,
|
||||
messageCount: -1, // Count unknown.
|
||||
returnNumber: null,
|
||||
returnMessage: null
|
||||
};
|
||||
@ -451,6 +454,8 @@ function RILContentHelper() {
|
||||
debug("Number of clients: " + this.numClients);
|
||||
|
||||
this.rilContexts = [];
|
||||
this.voicemailInfos = [];
|
||||
this.voicemailStatuses = [];
|
||||
for (let clientId = 0; clientId < this.numClients; clientId++) {
|
||||
this.rilContexts[clientId] = {
|
||||
cardState: RIL.GECKO_CARDSTATE_UNKNOWN,
|
||||
@ -459,9 +464,10 @@ function RILContentHelper() {
|
||||
voiceConnectionInfo: new MobileConnectionInfo(),
|
||||
dataConnectionInfo: new MobileConnectionInfo()
|
||||
};
|
||||
|
||||
this.voicemailInfos[clientId] = new VoicemailInfo();
|
||||
}
|
||||
|
||||
this.voicemailInfo = new VoicemailInfo();
|
||||
this.voicemailDefaultServiceId = this.getVoicemailDefaultServiceId();
|
||||
|
||||
this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES);
|
||||
@ -1361,7 +1367,8 @@ RILContentHelper.prototype = {
|
||||
_voicemailListeners: null,
|
||||
_iccListeners: null,
|
||||
|
||||
voicemailStatus: null,
|
||||
voicemailInfos: null,
|
||||
voicemailStatuses: null,
|
||||
|
||||
voicemailDefaultServiceId: 0,
|
||||
getVoicemailDefaultServiceId: function getVoicemailDefaultServiceId() {
|
||||
@ -1374,27 +1381,33 @@ RILContentHelper.prototype = {
|
||||
return id;
|
||||
},
|
||||
|
||||
getVoicemailInfo: function getVoicemailInfo() {
|
||||
getVoicemailInfo: function getVoicemailInfo(clientId) {
|
||||
// Get voicemail infomation by IPC only on first time.
|
||||
this.getVoicemailInfo = function getVoicemailInfo() {
|
||||
return this.voicemailInfo;
|
||||
this.getVoicemailInfo = function getVoicemailInfo(clientId) {
|
||||
return this.voicemailInfos[clientId];
|
||||
};
|
||||
|
||||
let voicemailInfo =
|
||||
cpmm.sendSyncMessage("RIL:GetVoicemailInfo", {clientId: 0})[0];
|
||||
if (voicemailInfo) {
|
||||
this.updateInfo(voicemailInfo, this.voicemailInfo);
|
||||
for (let cId = 0; cId < gNumRadioInterfaces; cId++) {
|
||||
let voicemailInfo =
|
||||
cpmm.sendSyncMessage("RIL:GetVoicemailInfo", {clientId: cId})[0];
|
||||
if (voicemailInfo) {
|
||||
this.updateInfo(voicemailInfo, this.voicemailInfos[cId]);
|
||||
}
|
||||
}
|
||||
|
||||
return this.voicemailInfo;
|
||||
return this.voicemailInfos[clientId];
|
||||
},
|
||||
|
||||
get voicemailNumber() {
|
||||
return this.getVoicemailInfo().number;
|
||||
getVoicemailNumber: function getVoicemailNumber(clientId) {
|
||||
return this.getVoicemailInfo(clientId).number;
|
||||
},
|
||||
|
||||
get voicemailDisplayName() {
|
||||
return this.getVoicemailInfo().displayName;
|
||||
getVoicemailDisplayName: function getVoicemailDisplayName(clientId) {
|
||||
return this.getVoicemailInfo(clientId).displayName;
|
||||
},
|
||||
|
||||
getVoicemailStatus: function getVoicemailStatus(clientId) {
|
||||
return this.voicemailStatuses[clientId];
|
||||
},
|
||||
|
||||
registerListener: function registerListener(listenerType, clientId, listener) {
|
||||
@ -1442,13 +1455,17 @@ RILContentHelper.prototype = {
|
||||
|
||||
registerVoicemailMsg: function registerVoicemailMsg(listener) {
|
||||
debug("Registering for voicemail-related messages");
|
||||
//TODO: Bug 814634 - WebVoicemail API: support multiple sim cards.
|
||||
// To follow the listener registration scheme, we add a dummy clientId 0.
|
||||
// All voicemail events are routed to listener for client id 0.
|
||||
// See |handleVoicemailNotification|.
|
||||
this.registerListener("_voicemailListeners", 0, listener);
|
||||
cpmm.sendAsyncMessage("RIL:RegisterVoicemailMsg");
|
||||
},
|
||||
|
||||
unregisterVoicemailMsg: function unregisteVoicemailMsg(listener) {
|
||||
//TODO: Bug 814634 - WebVoicemail API: support multiple sim cards.
|
||||
// To follow the listener unregistration scheme, we add a dummy clientId 0.
|
||||
// All voicemail events are routed to listener for client id 0.
|
||||
// See |handleVoicemailNotification|.
|
||||
this.unregisterListener("_voicemailListeners", 0, listener);
|
||||
},
|
||||
|
||||
@ -1619,7 +1636,7 @@ RILContentHelper.prototype = {
|
||||
this.handleVoicemailNotification(clientId, data);
|
||||
break;
|
||||
case "RIL:VoicemailInfoChanged":
|
||||
this.updateInfo(data, this.voicemailInfo);
|
||||
this.updateInfo(data, this.voicemailInfos[clientId]);
|
||||
break;
|
||||
case "RIL:CardLockResult": {
|
||||
let requestId = data.requestId;
|
||||
@ -1835,41 +1852,44 @@ RILContentHelper.prototype = {
|
||||
this.fireRequestSuccess(message.requestId, result);
|
||||
},
|
||||
|
||||
handleVoicemailNotification: function handleVoicemailNotification(clientId, message) {
|
||||
// Bug 814634 - WebVoicemail API: support multiple sim cards
|
||||
handleVoicemailNotification: function handleVoicemailNotification(clientId,
|
||||
message) {
|
||||
let changed = false;
|
||||
if (!this.voicemailStatus) {
|
||||
this.voicemailStatus = new VoicemailStatus();
|
||||
if (!this.voicemailStatuses[clientId]) {
|
||||
this.voicemailStatuses[clientId] = new VoicemailStatus(clientId);
|
||||
}
|
||||
|
||||
if (this.voicemailStatus.hasMessages != message.active) {
|
||||
let voicemailStatus = this.voicemailStatuses[clientId];
|
||||
if (voicemailStatus.hasMessages != message.active) {
|
||||
changed = true;
|
||||
this.voicemailStatus.hasMessages = message.active;
|
||||
voicemailStatus.hasMessages = message.active;
|
||||
}
|
||||
|
||||
if (this.voicemailStatus.messageCount != message.msgCount) {
|
||||
if (voicemailStatus.messageCount != message.msgCount) {
|
||||
changed = true;
|
||||
this.voicemailStatus.messageCount = message.msgCount;
|
||||
voicemailStatus.messageCount = message.msgCount;
|
||||
} else if (message.msgCount == -1) {
|
||||
// For MWI using DCS the message count is not available
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (this.voicemailStatus.returnNumber != message.returnNumber) {
|
||||
if (voicemailStatus.returnNumber != message.returnNumber) {
|
||||
changed = true;
|
||||
this.voicemailStatus.returnNumber = message.returnNumber;
|
||||
voicemailStatus.returnNumber = message.returnNumber;
|
||||
}
|
||||
|
||||
if (this.voicemailStatus.returnMessage != message.returnMessage) {
|
||||
if (voicemailStatus.returnMessage != message.returnMessage) {
|
||||
changed = true;
|
||||
this.voicemailStatus.returnMessage = message.returnMessage;
|
||||
voicemailStatus.returnMessage = message.returnMessage;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
this._deliverEvent(clientId,
|
||||
// To follow the event delivering scheme, we add a dummy clientId 0.
|
||||
// All voicemail events are routed to listener for client id 0.
|
||||
this._deliverEvent(0,
|
||||
"_voicemailListeners",
|
||||
"notifyStatusChanged",
|
||||
[this.voicemailStatus]);
|
||||
[voicemailStatus]);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -8,9 +8,14 @@ SpecialPowers.addPermission("voicemail", true, document);
|
||||
let voicemail = window.navigator.mozVoicemail;
|
||||
ok(voicemail instanceof MozVoicemail);
|
||||
|
||||
let serviceId = 0;
|
||||
|
||||
// These are the emulator's hard coded voicemail number and alphaId
|
||||
is(voicemail.number, "+15552175049");
|
||||
is(voicemail.displayName, "Voicemail");
|
||||
is(voicemail.getNumber(serviceId), "+15552175049");
|
||||
is(voicemail.getDisplayName(serviceId), "Voicemail");
|
||||
|
||||
is(voicemail.getNumber(), "+15552175049");
|
||||
is(voicemail.getDisplayName(), "Voicemail");
|
||||
|
||||
SpecialPowers.removePermission("voicemail", document);
|
||||
finish();
|
||||
|
@ -4,6 +4,8 @@
|
||||
SpecialPowers.addPermission("voicemail", true, document);
|
||||
|
||||
let voicemail = window.navigator.mozVoicemail;
|
||||
let serviceId = 0;
|
||||
|
||||
ok(voicemail instanceof MozVoicemail);
|
||||
is(voicemail.status, null);
|
||||
|
||||
@ -42,10 +44,13 @@ function sendIndicatorPDU(pdu, listener, nextTest) {
|
||||
// See RadioInterfaceLayer.js / Bug #768441
|
||||
|
||||
function isVoicemailStatus(status) {
|
||||
is(voicemail.status.hasMessages, status.hasMessages);
|
||||
is(voicemail.status.messageCount, status.messageCount);
|
||||
is(voicemail.status.returnNumber, status.returnNumber);
|
||||
is(voicemail.status.returnMessage, status.returnMessage);
|
||||
is(voicemail.getStatus(), status);
|
||||
is(voicemail.getStatus(serviceId), status);
|
||||
|
||||
is(voicemail.getStatus().hasMessages, status.hasMessages);
|
||||
is(voicemail.getStatus().messageCount, status.messageCount);
|
||||
is(voicemail.getStatus().returnNumber, status.returnNumber);
|
||||
is(voicemail.getStatus().returnMessage, status.returnMessage);
|
||||
}
|
||||
|
||||
const MWI_PDU_PREFIX = "0000";
|
||||
@ -80,7 +85,7 @@ function testLevel1Indicator() {
|
||||
// TODO: bug 905228 - MozVoicemailStatus is not defined.
|
||||
//ok(status instanceof MozVoicemailStatus);
|
||||
is(status.hasMessages, true);
|
||||
is(status.messageCount, status.MESSAGE_COUNT_UNKNOWN);
|
||||
is(status.messageCount, -1);
|
||||
is(status.returnNumber, MWI_LEVEL1_SENDER);
|
||||
is(status.returnMessage, MWI_DEFAULT_BODY);
|
||||
isVoicemailStatus(status);
|
||||
|
Loading…
Reference in New Issue
Block a user