Bug 1052825 - Part 1: Interface changes for using WebIDL enum in lockType. r=hsinyi
authorEdgar Chen <echen@mozilla.com>
Thu, 30 Oct 2014 16:29:37 +0800
changeset 219810 4d28acaa9aacd90fdd276a47ce51e776583b2c14
parent 219809 d8c69e7db5903a98104e7a4fe23a0652ec0052c9
child 219811 a7c483766f6090665a3ad145c1c13358b63f05cd
push id10419
push usercbook@mozilla.com
push dateTue, 16 Dec 2014 12:45:27 +0000
treeherderfx-team@ec87657146eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs1052825
milestone37.0a1
Bug 1052825 - Part 1: Interface changes for using WebIDL enum in lockType. r=hsinyi
dom/icc/interfaces/nsIIccProvider.idl
dom/webidl/MozIcc.webidl
--- a/dom/icc/interfaces/nsIIccProvider.idl
+++ b/dom/icc/interfaces/nsIIccProvider.idl
@@ -15,17 +15,17 @@ interface nsIIccListener : nsISupports
   void notifyStkSessionEnd();
   void notifyCardStateChanged();
   void notifyIccInfoChanged();
 };
 
 /**
  * XPCOM component (in the content process) that provides the ICC information.
  */
-[scriptable, uuid(bf802bf0-4df2-11e4-916c-0800200c9a66)]
+[scriptable, uuid(38bbc600-76ac-11e4-82f8-0800200c9a66)]
 interface nsIIccProvider : nsISupports
 {
   // MUST match enum IccCardState in MozIcc.webidl!
   const unsigned long CARD_STATE_UNKNOWN = 0;
   const unsigned long CARD_STATE_READY = 1;
   const unsigned long CARD_STATE_PIN_REQUIRED = 2;
   const unsigned long CARD_STATE_PUK_REQUIRED = 3;
   const unsigned long CARD_STATE_PERMANENT_BLOCKED = 4;
@@ -52,16 +52,39 @@ interface nsIIccProvider : nsISupports
   const unsigned long CARD_STATE_HRPD_NETWORK_PUK_REQUIRED = 25;
   const unsigned long CARD_STATE_RUIM_CORPORATE_PUK_REQUIRED = 26;
   const unsigned long CARD_STATE_RUIM_SERVICE_PROVIDER_PUK_REQUIRED = 27;
   const unsigned long CARD_STATE_RUIM_PUK_REQUIRED = 28;
   const unsigned long CARD_STATE_ILLEGAL = 29;
 
   const unsigned long CARD_STATE_UNDETECTED = 4294967295; // UINT32_MAX
 
+  // MUST match with enum IccLockType in MozIcc.webidl
+  const unsigned long CARD_LOCK_TYPE_PIN = 0;
+  const unsigned long CARD_LOCK_TYPE_PIN2 = 1;
+  const unsigned long CARD_LOCK_TYPE_PUK = 2;
+  const unsigned long CARD_LOCK_TYPE_PUK2 = 3;
+  const unsigned long CARD_LOCK_TYPE_NCK = 4;
+  const unsigned long CARD_LOCK_TYPE_NCK1 = 5;
+  const unsigned long CARD_LOCK_TYPE_NCK2 = 6;
+  const unsigned long CARD_LOCK_TYPE_HNCK = 7;
+  const unsigned long CARD_LOCK_TYPE_CCK = 8;
+  const unsigned long CARD_LOCK_TYPE_SPCK = 9;
+  const unsigned long CARD_LOCK_TYPE_RCCK = 10;
+  const unsigned long CARD_LOCK_TYPE_RSPCK = 11;
+  const unsigned long CARD_LOCK_TYPE_NCK_PUK = 12;
+  const unsigned long CARD_LOCK_TYPE_NCK1_PUK = 13;
+  const unsigned long CARD_LOCK_TYPE_NCK2_PUK = 14;
+  const unsigned long CARD_LOCK_TYPE_HNCK_PUK = 15;
+  const unsigned long CARD_LOCK_TYPE_CCK_PUK = 16;
+  const unsigned long CARD_LOCK_TYPE_SPCK_PUK = 17;
+  const unsigned long CARD_LOCK_TYPE_RCCK_PUK = 18;
+  const unsigned long CARD_LOCK_TYPE_RSPCK_PUK = 19;
+  const unsigned long CARD_LOCK_TYPE_FDN = 20;
+
   /**
    * Called when a content process registers receiving unsolicited messages from
    * RadioInterfaceLayer in the chrome process. Only a content process that has
    * the 'mobileconnection' permission is allowed to register.
    */
   void registerIccMsg(in unsigned long clientId, in nsIIccListener listener);
   void unregisterIccMsg(in unsigned long clientId, in nsIIccListener listener);
 
@@ -93,28 +116,37 @@ interface nsIIccProvider : nsISupports
                               in jsval timer);
   void sendStkEventDownload(in unsigned long clientId,
                             in nsIDOMWindow window,
                             in jsval event);
 
   /**
    * Card lock interfaces.
    */
-  nsIDOMDOMRequest getCardLockState(in unsigned long clientId,
-                                    in nsIDOMWindow window,
-                                    in DOMString lockType);
+  nsIDOMDOMRequest getCardLockEnabled(in unsigned long clientId,
+                                      in nsIDOMWindow window,
+                                      in unsigned long lockType);
   nsIDOMDOMRequest unlockCardLock(in unsigned long clientId,
                                   in nsIDOMWindow window,
-                                  in jsval info);
-  nsIDOMDOMRequest setCardLock(in unsigned long clientId,
-                               in nsIDOMWindow window,
-                               in jsval info);
+                                  in unsigned long lockType,
+                                  in DOMString password,
+                                  [optional] in DOMString newPin);
+  nsIDOMDOMRequest setCardLockEnabled(in unsigned long clientId,
+                                      in nsIDOMWindow window,
+                                      in unsigned long lockType,
+                                      in DOMString password,
+                                      in boolean enabled);
+  nsIDOMDOMRequest changeCardLockPassword(in unsigned long clientId,
+                                          in nsIDOMWindow window,
+                                          in unsigned long lockType,
+                                          in DOMString password,
+                                          in DOMString newPassword);
   nsIDOMDOMRequest getCardLockRetryCount(in unsigned long clientId,
                                          in nsIDOMWindow window,
-                                         in DOMString lockType);
+                                         in unsigned long lockType);
 
   /**
    * Phonebook interfaces.
    */
   nsIDOMDOMRequest readContacts(in unsigned long clientId,
                                 in nsIDOMWindow window,
                                 in DOMString contactType);
 
--- a/dom/webidl/MozIcc.webidl
+++ b/dom/webidl/MozIcc.webidl
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-enum IccCardState {
+enum IccCardState
+{
   "unknown", // ICC card state is either not yet reported from modem or in an
              // unknown state.
   "ready",
   "pinRequired",
   "pukRequired",
   "permanentBlocked",
 
   /**
@@ -44,16 +45,72 @@ enum IccCardState {
 
   /**
    * Additional States.
    */
   "illegal" // See Bug 916000. An owed pay card will be rejected by the network
             // and fall in this state.
 };
 
+enum IccLockType
+{
+  "pin",
+  "pin2",
+  "puk",
+  "puk2",
+  "nck",      // Network depersonalization -- network control key (NCK).
+  "nck1",     // Network type 1 depersonalization -- network type 1 control key (NCK1).
+  "nck2",     // Network type 2 depersonalization -- network type 2 control key (NCK2).
+  "hnck",     // HRPD network depersonalization -- HRPD network control key (HNCK).
+  "cck",      // Corporate depersonalization -- corporate control key (CCK).
+  "spck",     // Service provider depersonalization -- service provider control key (SPCK).
+  "rcck",     // RUIM corporate depersonalization -- RUIM corporate control key (RCCK).
+  "rspck",    // RUIM service provider depersonalization -- RUIM service provider control key (RSPCK).
+  "nckPuk",   // Network PUK depersonalization -- network control key (NCK).
+  "nck1Puk",  // Network type 1 PUK depersonalization -- network type 1 control key (NCK1).
+  "nck2Puk",  // Network type 2 PUK depersonalization -- Network type 2 control key (NCK2).
+  "hnckPuk",  // HRPD network PUK depersonalization -- HRPD network control key (HNCK).
+  "cckPuk",   // Corporate PUK depersonalization -- corporate control key (CCK).
+  "spckPuk",  // Service provider PUK depersonalization -- service provider control key (SPCK).
+  "rcckPuk",  // RUIM corporate PUK depersonalization -- RUIM corporate control key (RCCK).
+  "rspckPuk", // RUIM service provider PUK depersonalization -- service provider control key (SPCK).
+  "fdn"
+};
+
+dictionary IccUnlockCardLockOptions
+{
+  required IccLockType lockType;
+
+  DOMString? pin = null; // Necessary for lock types: "pin", "pin2", "nck",
+                         // "nck1", "nck2", "hnck", "cck", "spck", "rcck",
+                         // "rspck".
+
+  DOMString? puk = null; // Necessary for lock types: "puk", "puk2", "nckPuk",
+                         // "nck1Puk", "nck2Puk", "hnckPuk", "cckPuk",
+                         // "spckPuk", "rcckPuk", "rspckPuk".
+
+  DOMString? newPin = null; // Necessary for lock types: "puk", "puk2".
+};
+
+dictionary IccSetCardLockOptions
+{
+ required IccLockType lockType;
+
+ DOMString? pin = null; // Necessary for lock types: "pin", "pin2"
+
+ DOMString? pin2 = null; // Used for enabling/disabling operation.
+                         // Necessary for lock types: "fdn".
+
+ DOMString? newPin = null; // Used for changing password operation.
+                           // Necessary for lock types: "pin", "pin2"
+
+ boolean enabled; // Used for enabling/disabling operation.
+                  // Necessary for lock types: "pin", "fdn"
+};
+
 [Pref="dom.icc.enabled"]
 interface MozIcc : EventTarget
 {
   // Integrated Circuit Card Information.
 
   /**
    * Information stored in the device's ICC.
    *
@@ -154,203 +211,69 @@ interface MozIcc : EventTarget
   attribute EventHandler onstksessionend;
 
   // Integrated Circuit Card Lock interfaces.
 
   /**
    * Find out about the status of an ICC lock (e.g. the PIN lock).
    *
    * @param lockType
-   *        Identifies the lock type, e.g. "pin" for the PIN lock, "fdn" for
-   *        the FDN lock.
+   *        Identifies the lock type.
    *
    * @return a DOMRequest.
    *         The request's result will be an object containing
    *         information about the specified lock's status.
    *         e.g. {enabled: true}.
    */
   [Throws]
-  DOMRequest getCardLock(DOMString lockType);
+  DOMRequest getCardLock(IccLockType lockType);
 
   /**
    * Unlock a card lock.
    *
    * @param info
    *        An object containing the information necessary to unlock
-   *        the given lock. At a minimum, this object must have a
-   *        "lockType" attribute which specifies the type of lock, e.g.
-   *        "pin" for the PIN lock. Other attributes are dependent on
-   *        the lock type.
-   *
-   * Examples:
-   *
-   * (1) Unlocking the PIN:
-   *
-   *   unlockCardLock({lockType: "pin",
-   *                   pin: "..."});
-   *
-   * (2) Unlocking the PUK and supplying a new PIN:
-   *
-   *   unlockCardLock({lockType: "puk",
-   *                   puk: "...",
-   *                   newPin: "..."});
-   *
-   * (3) Network depersonalization. Unlocking the network control key (NCK).
-   *
-   *   unlockCardLock({lockType: "nck",
-   *                   pin: "..."});
-   *
-   * (4) Network type 1 depersonalization. Unlocking the network type 1 control
-   *     key (NCK1).
-   *
-   *   unlockCardLock({lockType: "nck1",
-   *                   pin: "..."});
-   *
-   * (5) Network type 2 depersonalization. Unlocking the network type 2 control
-   *     key (NCK2).
-   *
-   *   unlockCardLock({lockType: "nck2",
-   *                   pin: "..."});
-   *
-   * (6) HRPD network depersonalization. Unlocking the HRPD network control key
-   *     (HNCK).
-   *
-   *   unlockCardLock({lockType: "hnck",
-   *                   pin: "..."});
-   *
-   * (7) Corporate depersonalization. Unlocking the corporate control key (CCK).
-   *
-   *   unlockCardLock({lockType: "cck",
-   *                   pin: "..."});
-   *
-   * (8) Service provider depersonalization. Unlocking the service provider
-   *     control key (SPCK).
-   *
-   *   unlockCardLock({lockType: "spck",
-   *                   pin: "..."});
-   *
-   * (9) RUIM corporate depersonalization. Unlocking the RUIM corporate control
-   *     key (RCCK).
-   *
-   *   unlockCardLock({lockType: "rcck",
-   *                   pin: "..."});
-   *
-   * (10) RUIM service provider depersonalization. Unlocking the RUIM service
-   *      provider control key (RSPCK).
-   *
-   *   unlockCardLock({lockType: "rspck",
-   *                   pin: "..."});
-   *
-   * (11) Network PUK depersonalization. Unlocking the network control key (NCK).
-   *
-   *   unlockCardLock({lockType: "nckPuk",
-   *                   puk: "..."});
-   *
-   * (12) Network type 1 PUK depersonalization. Unlocking the network type 1
-   *      control key (NCK1).
-   *
-   *   unlockCardLock({lockType: "nck1Puk",
-   *                   puk: "..."});
-   *
-   * (13) Network type 2 PUK depersonalization. Unlocking the Network type 2
-   *      control key (NCK2).
-   *
-   *   unlockCardLock({lockType: "nck2Puk",
-   *                   puk: "..."});
-   *
-   * (14) HRPD network PUK depersonalization. Unlocking the HRPD network control
-   *      key (HNCK).
-   *
-   *   unlockCardLock({lockType: "hnckPuk",
-   *                   puk: "..."});
-   *
-   * (15) Corporate PUK depersonalization. Unlocking the corporate control key
-   *      (CCK).
-   *
-   *   unlockCardLock({lockType: "cckPuk",
-   *                   puk: "..."});
-   *
-   * (16) Service provider PUK depersonalization. Unlocking the service provider
-   *      control key (SPCK).
-   *
-   *   unlockCardLock({lockType: "spckPuk",
-   *                   puk: "..."});
-   *
-   * (17) RUIM corporate PUK depersonalization. Unlocking the RUIM corporate
-   *      control key (RCCK).
-   *
-   *   unlockCardLock({lockType: "rcckPuk",
-   *                   puk: "..."});
-   *
-   * (18) RUIM service provider PUK depersonalization. Unlocking the service
-   *      provider control key (SPCK).
-   *
-   *   unlockCardLock({lockType: "rspckPuk",
-   *                   puk: "..."});
+   *        the given lock.
    *
    * @return a DOMRequest.
    *         The request's error will be an object containing the number of
    *         remaining retries
    *         @see IccCardLockError.
    */
   [Throws]
-  DOMRequest unlockCardLock(any info);
+  DOMRequest unlockCardLock(optional IccUnlockCardLockOptions info);
 
   /**
    * Modify the state of a card lock.
    *
    * @param info
    *        An object containing information about the lock and
-   *        how to modify its state. At a minimum, this object
-   *        must have a "lockType" attribute which specifies the
-   *        type of lock, e.g. "pin" for the PIN lock. Other
-   *        attributes are dependent on the lock type.
-   *
-   * Examples:
-   *
-   * (1a) Disabling the PIN lock:
-   *
-   *   setCardLock({lockType: "pin",
-   *                pin: "...",
-   *                enabled: false});
-   *
-   * (1b) Disabling the FDN lock:
-   *
-   *   setCardLock({lockType: "fdn",
-   *                pin2: "...",
-   *                enabled: false});
-   *
-   * (2) Changing the PIN:
-   *
-   *   setCardLock({lockType: "pin",
-   *                pin: "...",
-   *                newPin: "..."});
+   *        how to modify its state.
    *
    * @return a DOMRequest.
    *         The request's error will be an object containing the number of
    *         remaining retries.
    *         @see IccCardLockError.
    */
   [Throws]
-  DOMRequest setCardLock(any info);
+  DOMRequest setCardLock(optional IccSetCardLockOptions info);
 
   /**
    * Retrieve the number of remaining tries for unlocking the card.
    *
    * @param lockType
-   *        Identifies the lock type, e.g. "pin" for the PIN lock, "puk" for
-   *        the PUK lock.
+   *        Identifies the lock type.
    *
    * @return a DOMRequest.
    *         The request's result will be an object containing the number of
    *         remaining retries.
    *         e.g. {retryCount: 3}.
    */
   [Throws]
-  DOMRequest getCardLockRetryCount(DOMString lockType);
+  DOMRequest getCardLockRetryCount(IccLockType lockType);
 
   // Integrated Circuit Card Phonebook Interfaces.
 
   /**
    * Read ICC contacts.
    *
    * @param contactType
    *        One of type as below,