Bug 906404 - B2G RIL: move MozVoicemailStatus to WebIDL. r=vicamo,smaug
authorRoshan Vidyashankar <roshanvid@gmail.com>
Thu, 17 Jul 2014 13:47:41 -0700
changeset 216713 e8ad29f1166a523e727ff6fd297aa9eaf85e5eed
parent 216712 e95389b24a0d0b477f392a163007535031e57868
child 216714 330ba968ed6153bce59d4aa3dc74d27f1b7d3001
child 216837 929cddec67254b95b833f8ad9c504ce491fef27f
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo, smaug
bugs906404
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 906404 - B2G RIL: move MozVoicemailStatus to WebIDL. r=vicamo,smaug
dom/base/nsPluginArray.h
dom/bindings/Bindings.conf
dom/system/gonk/RILContentHelper.js
dom/system/gonk/RadioInterfaceLayer.manifest
dom/tests/mochitest/general/test_interfaces.html
dom/voicemail/Voicemail.cpp
dom/voicemail/Voicemail.h
dom/voicemail/moz.build
dom/voicemail/nsIDOMMozVoicemailStatus.idl
dom/voicemail/nsIVoicemailProvider.idl
dom/webidl/MozVoicemail.webidl
dom/webidl/MozVoicemailEvent.webidl
dom/webidl/MozVoicemailStatus.webidl
dom/webidl/moz.build
--- a/dom/base/nsPluginArray.h
+++ b/dom/base/nsPluginArray.h
@@ -8,19 +8,19 @@
 #define nsPluginArray_h___
 
 #include "nsTArray.h"
 #include "nsWeakReference.h"
 #include "nsIObserver.h"
 #include "nsWrapperCache.h"
 #include "nsPluginTags.h"
 #include "nsPIDOMWindow.h"
+#include "nsMimeTypeArray.h"
 
 class nsPluginElement;
-class nsMimeType;
 
 class nsPluginArray MOZ_FINAL : public nsIObserver,
                                 public nsSupportsWeakReference,
                                 public nsWrapperCache
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsPluginArray,
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1993,17 +1993,16 @@ addExternalIface('MozRDFCompositeDataSou
                  notflattened=True)
 addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True)
 addExternalIface('MozSmsFilter', headerFile='nsIDOMSmsFilter.h')
 addExternalIface('MozSmsMessage')
 addExternalIface('MozTreeBoxObject', nativeType='nsITreeBoxObject',
                  notflattened=True)
 addExternalIface('MozTreeColumn', nativeType='nsITreeColumn',
                  headerFile='nsITreeColumns.h')
-addExternalIface('MozVoicemailStatus')
 addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h')
 addExternalIface('MozXULTemplateBuilder', nativeType='nsIXULTemplateBuilder')
 addExternalIface('nsIBrowserDOMWindow', nativeType='nsIBrowserDOMWindow',
                  notflattened=True)
 addExternalIface('nsIControllers', nativeType='nsIControllers')
 addExternalIface('nsIDOMCrypto', nativeType='nsIDOMCrypto',
                  headerFile='Crypto.h')
 addExternalIface('nsIInputStreamCallback', nativeType='nsIInputStreamCallback',
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -268,26 +268,19 @@ MobileCellInfo.prototype = {
   cdmaSystemId: -1,
   cdmaNetworkId: -1
 };
 
 function VoicemailStatus(clientId) {
   this.serviceId = clientId;
 }
 VoicemailStatus.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozVoicemailStatus]),
+  QueryInterface: XPCOMUtils.generateQI([]),
   classID:        VOICEMAILSTATUS_CID,
-  classInfo:      XPCOMUtils.generateCI({
-    classID:          VOICEMAILSTATUS_CID,
-    classDescription: "VoicemailStatus",
-    flags:            Ci.nsIClassInfo.DOM_OBJECT,
-    interfaces:       [Ci.nsIDOMMozVoicemailStatus]
-  }),
-
-  // nsIDOMMozVoicemailStatus
+  contractID:     "@mozilla.org/voicemailstatus;1",
 
   serviceId: -1,
   hasMessages: false,
   messageCount: -1, // Count unknown.
   returnNumber: null,
   returnMessage: null
 };
 
--- a/dom/system/gonk/RadioInterfaceLayer.manifest
+++ b/dom/system/gonk/RadioInterfaceLayer.manifest
@@ -13,13 +13,15 @@
 # limitations under the License.
 
 # RadioInterfaceLayer.js
 component {2d831c8d-6017-435b-a80c-e5d422810cea} RadioInterfaceLayer.js
 contract @mozilla.org/ril;1 {2d831c8d-6017-435b-a80c-e5d422810cea}
 category profile-after-change RadioInterfaceLayer @mozilla.org/ril;1
 
 # RILContentHelper.js
+component {5467f2eb-e214-43ea-9b89-67711241ec8e} RILContentHelper.js
 component {472816e1-1fd6-4405-996c-806f9ea68174} RILContentHelper.js
 component {08a71987-408c-44ff-93fd-177c0a85c3dd} RILContentHelper.js
+contract @mozilla.org/voicemailstatus;1 {5467f2eb-e214-43ea-9b89-67711241ec8e}
 contract @mozilla.org/ril/content-helper;1 {472816e1-1fd6-4405-996c-806f9ea68174}
 contract @mozilla.org/dom/icccardlock-error;1 {08a71987-408c-44ff-93fd-177c0a85c3dd}
 category profile-after-change RILContentHelper @mozilla.org/ril/content-helper;1
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -713,16 +713,18 @@ var interfaceNamesInGlobalScope =
     {name: "MozStkCommandEvent", b2g: true, pref: "dom.icc.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozTimeManager", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozVoicemail", b2g: true, pref: "dom.voicemail.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozVoicemailEvent", b2g: true, pref: "dom.voicemail.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
+    {name: "MozVoicemailStatus", b2g: true, pref: "dom.voicemail.enabled"},
+// IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozWakeLock", b2g: true, pref: "dom.wakelock.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozWifiCapabilities", b2g: true, permission: "wifi-manage"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozWifiConnectionInfoEvent", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "MozWifiStationInfoEvent", b2g: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
--- a/dom/voicemail/Voicemail.cpp
+++ b/dom/voicemail/Voicemail.cpp
@@ -3,20 +3,21 @@
 /* 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/. */
 
 #include "Voicemail.h"
 
 #include "mozilla/dom/MozVoicemailBinding.h"
 #include "mozilla/dom/MozVoicemailEvent.h"
-#include "nsIDOMMozVoicemailStatus.h"
+#include "mozilla/dom/MozVoicemailStatusBinding.h"
 
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
+#include "nsContentUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsServiceManagerUtils.h"
 
 #define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"
 const char* kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
 
 using namespace mozilla::dom;
 
@@ -95,38 +96,44 @@ Voicemail::PassedOrDefaultServiceId(cons
     mProvider->GetVoicemailDefaultServiceId(&aResult);
   }
 
   return true;
 }
 
 // MozVoicemail WebIDL
 
-already_AddRefed<nsIDOMMozVoicemailStatus>
+already_AddRefed<MozVoicemailStatus>
 Voicemail::GetStatus(const Optional<uint32_t>& aServiceId,
                      ErrorResult& aRv) const
 {
   if (!mProvider) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
   uint32_t id = 0;
   if (!PassedOrDefaultServiceId(aServiceId, id)) {
     aRv.Throw(NS_ERROR_INVALID_ARG);
     return nullptr;
   }
-  nsCOMPtr<nsIDOMMozVoicemailStatus> status;
-  nsresult rv = mProvider->GetVoicemailStatus(id, getter_AddRefs(status));
+  JSContext *cx = nsContentUtils::GetCurrentJSContext();
+  JS::Rooted<JS::Value> status(cx);
+  nsresult rv = mProvider->GetVoicemailStatus(id, &status);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
-
-  return status.forget();
+  if (!status.isObject()) {
+    aRv.Throw(NS_ERROR_UNEXPECTED);
+    return nullptr;
+  }
+  JS::Rooted<JSObject*> statusObj(cx, &status.toObject());
+  nsRefPtr<MozVoicemailStatus> res = new MozVoicemailStatus(statusObj, GetParentObject());
+  return res.forget();
 }
 
 void
 Voicemail::GetNumber(const Optional<uint32_t>& aServiceId, nsString& aNumber,
                      ErrorResult& aRv) const
 {
   aNumber.SetIsVoid(true);
 
@@ -162,22 +169,26 @@ Voicemail::GetDisplayName(const Optional
   }
 
   aRv = mProvider->GetVoicemailDisplayName(id, aDisplayName);
 }
 
 // nsIVoicemailListener
 
 NS_IMETHODIMP
-Voicemail::NotifyStatusChanged(nsIDOMMozVoicemailStatus* aStatus)
+Voicemail::NotifyStatusChanged(JS::HandleValue aStatus)
 {
   MozVoicemailEventInit init;
   init.mBubbles = false;
   init.mCancelable = false;
-  init.mStatus = aStatus;
+  if (aStatus.isObject()) {
+    JSContext *cx = nsContentUtils::GetCurrentJSContext();
+    JS::Rooted<JSObject*> statusObj(cx, &aStatus.toObject());
+    init.mStatus = new MozVoicemailStatus(statusObj, GetParentObject());
+  }
 
   nsRefPtr<MozVoicemailEvent> event =
     MozVoicemailEvent::Constructor(this, NS_LITERAL_STRING("statuschanged"), init);
   return DispatchTrustedEvent(event);
 }
 
 nsresult
 NS_NewVoicemail(nsPIDOMWindow* aWindow, Voicemail** aVoicemail)
--- a/dom/voicemail/Voicemail.h
+++ b/dom/voicemail/Voicemail.h
@@ -11,21 +11,22 @@
 #include "mozilla/DOMEventTargetHelper.h"
 #include "mozilla/ErrorResult.h"
 #include "nsIVoicemailProvider.h"
 
 class JSObject;
 struct JSContext;
 
 class nsPIDOMWindow;
-class nsIDOMMozVoicemailStatus;
 
 namespace mozilla {
 namespace dom {
 
+class MozVoicemailStatus;
+
 class Voicemail MOZ_FINAL : public DOMEventTargetHelper
 {
   /**
    * Class Voicemail doesn't actually inherit nsIVoicemailListener. Instead, it
    * owns an nsIVoicemailListener derived instance mListener and passes it to
    * nsIVoicemailProvider. The onreceived events are first delivered to
    * mListener and then forwarded to its owner, Voicemail. See also bug 775997
    * comment #51.
@@ -45,17 +46,17 @@ public:
   GetParentObject() const
   {
     return GetOwner();
   }
 
   virtual JSObject*
   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
-  already_AddRefed<nsIDOMMozVoicemailStatus>
+  already_AddRefed<MozVoicemailStatus>
   GetStatus(const Optional<uint32_t>& aServiceId, ErrorResult& aRv) const;
 
   void
   GetNumber(const Optional<uint32_t>& aServiceId, nsString& aNumber,
             ErrorResult& aRv) const;
 
   void
   GetDisplayName(const Optional<uint32_t>& aServiceId, nsString& aDisplayName,
--- a/dom/voicemail/moz.build
+++ b/dom/voicemail/moz.build
@@ -1,16 +1,15 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 XPIDL_SOURCES += [
-    'nsIDOMMozVoicemailStatus.idl',
     'nsIVoicemailProvider.idl',
 ]
 
 XPIDL_MODULE = 'dom_voicemail'
 
 EXPORTS.mozilla.dom += [
     'Voicemail.h',
 ]
--- a/dom/voicemail/nsIVoicemailProvider.idl
+++ b/dom/voicemail/nsIVoicemailProvider.idl
@@ -1,26 +1,24 @@
 /* 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/. */
 
 #include "nsISupports.idl"
 
-interface nsIDOMMozVoicemailStatus;
-
 [scriptable, uuid(214b0963-da48-4859-a56c-f065a90e0403)]
 interface nsIVoicemailListener : nsISupports
 {
   /**
    * Called when a voicemail notification has been received by the network.
    *
    * @param status
    *        The new voicemail status
    */
-  void notifyStatusChanged(in nsIDOMMozVoicemailStatus status);
+  void notifyStatusChanged(in jsval status);
 };
 
 /**
  * XPCOM component (in the content process) that provides the voicemail
  * information.
  */
 [scriptable, uuid(1bbfff90-88f7-4d73-896e-9620a0000ab0)]
 interface nsIVoicemailProvider : nsISupports
@@ -30,12 +28,12 @@ interface nsIVoicemailProvider : nsISupp
   /**
    * Called when a content process registers receiving unsolicited messages from
    * RadioInterfaceLayer in the chrome process. Only a content process that has
    * the 'voicemail' permission is allowed to register.
    */
   void registerVoicemailMsg(in nsIVoicemailListener listener);
   void unregisterVoicemailMsg(in nsIVoicemailListener listener);
 
-  nsIDOMMozVoicemailStatus getVoicemailStatus(in unsigned long clientId);
+  jsval getVoicemailStatus(in unsigned long clientId);
   DOMString getVoicemailNumber(in unsigned long clientId);
   DOMString getVoicemailDisplayName(in unsigned long clientId);
 };
--- a/dom/webidl/MozVoicemail.webidl
+++ b/dom/webidl/MozVoicemail.webidl
@@ -1,17 +1,14 @@
 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
 /* vim: set ts=2 et sw=2 tw=40: */
 /* 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/. */
 
-// nsIDOMMozVoicemailStatus
-interface MozVoicemailStatus;
-
 [Pref="dom.voicemail.enabled"]
 interface MozVoicemail : EventTarget
 {
   /**
    * The current voicemail status of a specified service, or null when the
    * status is unknown.
    */
   [Throws]
--- a/dom/webidl/MozVoicemailEvent.webidl
+++ b/dom/webidl/MozVoicemailEvent.webidl
@@ -1,14 +1,13 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/.
  */
-interface MozVoicemailStatus;
 
 [Constructor(DOMString type, optional MozVoicemailEventInit eventInitDict), Pref="dom.voicemail.enabled"]
 interface MozVoicemailEvent : Event
 {
   readonly attribute MozVoicemailStatus? status;
 };
 
 dictionary MozVoicemailEventInit : EventInit
rename from dom/voicemail/nsIDOMMozVoicemailStatus.idl
rename to dom/webidl/MozVoicemailStatus.webidl
--- a/dom/voicemail/nsIDOMMozVoicemailStatus.idl
+++ b/dom/webidl/MozVoicemailStatus.webidl
@@ -1,18 +1,18 @@
 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
 /* vim: set ts=2 et sw=2 tw=40: */
 /* 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/. */
 
-#include "nsISupports.idl"
+[JSImplementation="@mozilla.org/voicemailstatus;1",
+Pref="dom.voicemail.enabled"]
 
-[scriptable, uuid(efd352af-9eee-48dc-8e92-4d4fdbc89ecb)]
-interface nsIDOMMozVoicemailStatus : nsISupports
+interface MozVoicemailStatus 
 {
   readonly attribute unsigned long serviceId;
 
   /**
    * Whether or not there are messages waiting in the voicemail box
    */
   readonly attribute boolean hasMessages;
 
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -585,16 +585,17 @@ if CONFIG['MOZ_B2G_RIL']:
         'MozIcc.webidl',
         'MozIccManager.webidl',
         'MozMobileCellInfo.webidl',
         'MozMobileConnection.webidl',
         'MozMobileConnectionArray.webidl',
         'MozMobileConnectionInfo.webidl',
         'MozMobileNetworkInfo.webidl',
         'MozVoicemail.webidl',
+        'MozVoicemailStatus.webidl'
     ]
 
 if CONFIG['MOZ_NFC']:
     WEBIDL_FILES += [
          'MozNDEFRecord.webidl',
          'MozNFC.webidl',
          'MozNFCPeer.webidl',
          'MozNFCTag.webidl',