Bug 1098210 - Use WebIDL enums for mvnoType. r=hsinyi

This commit is contained in:
Edgar Chen 2014-12-12 19:04:00 +08:00
parent 9fe4f6a264
commit 948ddc5868
7 changed files with 40 additions and 16 deletions

View File

@ -94,6 +94,18 @@ ASSERT_ICC_CONTACT_TYPE_EQUALITY(Sdn, CARD_CONTACT_TYPE_SDN);
#undef ASSERT_ICC_CONTACT_TYPE_EQUALITY
/**
* Enum IccMvnoType
*/
#define ASSERT_ICC_MVNO_TYPE_EQUALITY(webidlState, xpidlState) \
ASSERT_EQUALITY(IccMvnoType, webidlState, xpidlState)
ASSERT_ICC_MVNO_TYPE_EQUALITY(Imsi, CARD_MVNO_TYPE_IMSI);
ASSERT_ICC_MVNO_TYPE_EQUALITY(Spn, CARD_MVNO_TYPE_SPN);
ASSERT_ICC_MVNO_TYPE_EQUALITY(Gid, CARD_MVNO_TYPE_GID);
#undef ASSERT_ICC_MVNO_TYPE_EQUALITY
#undef ASSERT_EQUALITY
} // namespace icc

View File

@ -384,8 +384,7 @@ Icc::UpdateContact(const JSContext* aCx, IccContactType aContactType,
}
already_AddRefed<DOMRequest>
Icc::MatchMvno(const nsAString& aMvnoType,
const nsAString& aMvnoData,
Icc::MatchMvno(IccMvnoType aMvnoType, const nsAString& aMvnoData,
ErrorResult& aRv)
{
if (!mProvider) {
@ -395,8 +394,8 @@ Icc::MatchMvno(const nsAString& aMvnoType,
nsRefPtr<nsIDOMDOMRequest> request;
nsresult rv = mProvider->MatchMvno(mClientId, GetOwner(),
aMvnoType, aMvnoData,
getter_AddRefs(request));
static_cast<uint32_t>(aMvnoType),
aMvnoData, getter_AddRefs(request));
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;

View File

@ -98,7 +98,7 @@ public:
ErrorResult& aRv);
already_AddRefed<DOMRequest>
MatchMvno(const nsAString& aMvnoType, const nsAString& aMatchData,
MatchMvno(IccMvnoType aMvnoType, const nsAString& aMatchData,
ErrorResult& aRv);
IMPL_EVENT_HANDLER(iccinfochange)

View File

@ -20,7 +20,7 @@ interface nsIIccListener : nsISupports
/**
* XPCOM component (in the content process) that provides the ICC information.
*/
[scriptable, uuid(937213c3-f64e-4f58-b4e0-3010f219d0c3)]
[scriptable, uuid(c3e3c1a9-6ac4-4916-a777-7d49ffd89c46)]
interface nsIIccProvider : nsISupports
{
// MUST match enum IccCardState in MozIcc.webidl!
@ -85,6 +85,11 @@ interface nsIIccProvider : nsISupports
const unsigned long CARD_CONTACT_TYPE_FDN = 1;
const unsigned long CARD_CONTACT_TYPE_SDN = 2;
// MUST match with enum IccMvnoType in MozIcc.webidl
const unsigned long CARD_MVNO_TYPE_IMSI = 0;
const unsigned long CARD_MVNO_TYPE_SPN = 1;
const unsigned long CARD_MVNO_TYPE_GID = 2;
/**
* Called when a content process registers receiving unsolicited messages from
* RadioInterfaceLayer in the chrome process. Only a content process that has
@ -182,6 +187,6 @@ interface nsIIccProvider : nsISupports
*/
nsIDOMDOMRequest matchMvno(in unsigned long clientId,
in nsIDOMWindow window,
in DOMString mvnoType,
in unsigned long mvnoType,
in DOMString mvnoData);
};

View File

@ -1993,20 +1993,20 @@ RadioInterface.prototype = {
matchMvno: function(target, message) {
if (DEBUG) this.debug("matchMvno: " + JSON.stringify(message));
if (!message || !message.mvnoType || !message.mvnoData) {
if (!message || !message.mvnoData) {
message.errorMsg = RIL.GECKO_ERROR_INVALID_PARAMETER;
}
if (!message.errorMsg) {
switch (message.mvnoType) {
case "imsi":
case RIL.GECKO_CARDMVNO_TYPE_IMSI:
if (!this.rilContext.imsi) {
message.errorMsg = RIL.GECKO_ERROR_GENERIC_FAILURE;
break;
}
message.result = this.isImsiMatches(message.mvnoData);
break;
case "spn":
case RIL.GECKO_CARDMVNO_TYPE_SPN:
let spn = this.rilContext.iccInfo && this.rilContext.iccInfo.spn;
if (!spn) {
message.errorMsg = RIL.GECKO_ERROR_GENERIC_FAILURE;
@ -2014,7 +2014,7 @@ RadioInterface.prototype = {
}
message.result = spn == message.mvnoData;
break;
case "gid":
case RIL.GECKO_CARDMVNO_TYPE_GID:
this.workerMessenger.send("getGID1", null, (function(response) {
let gid = response.gid1;
let mvnoDataLength = message.mvnoData.length;

View File

@ -2645,6 +2645,11 @@ this.GECKO_CARDCONTACT_TYPE_ADN = 0;
this.GECKO_CARDCONTACT_TYPE_FDN = 1;
this.GECKO_CARDCONTACT_TYPE_SDN = 2;
// See nsIIccProvider::CARD_MVNO_TYPE_*
this.GECKO_CARDMVNO_TYPE_IMSI = 0;
this.GECKO_CARDMVNO_TYPE_SPN = 1;
this.GECKO_CARDMVNO_TYPE_GID = 2;
// See ril.h RIL_PersoSubstate
this.PERSONSUBSTATE = {};
PERSONSUBSTATE[CARD_PERSOSUBSTATE_UNKNOWN] = GECKO_CARDSTATE_UNKNOWN;

View File

@ -82,6 +82,13 @@ enum IccContactType
"sdn" // Service Dialling Number.
};
enum IccMvnoType
{
"imsi",
"spn",
"gid"
};
dictionary IccUnlockCardLockOptions
{
required IccLockType lockType;
@ -315,17 +322,13 @@ interface MozIcc : EventTarget
*
* @param mvnoType
* Mvno type to use to compare the match data.
* Currently, we only support 'imsi'.
* @param matchData
* Data to be compared with ICC's field.
*
* @return a DOMRequest.
* The request's result will be a boolean indicating the matching
* result.
*
* TODO: change param mvnoType to WebIDL enum after Bug 864489 -
* B2G RIL: use ipdl as IPC in MozIccManager
*/
[Throws]
DOMRequest matchMvno(DOMString mvnoType, DOMString matchData);
DOMRequest matchMvno(IccMvnoType mvnoType, DOMString matchData);
};