michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "mozilla/dom/MobileConnection.h" michael@0: michael@0: #include "GeneratedEvents.h" michael@0: #include "mozilla/dom/CFStateChangeEvent.h" michael@0: #include "mozilla/dom/DataErrorEvent.h" michael@0: #include "mozilla/dom/MozEmergencyCbModeEvent.h" michael@0: #include "mozilla/dom/MozOtaStatusEvent.h" michael@0: #include "mozilla/dom/USSDReceivedEvent.h" michael@0: #include "mozilla/Preferences.h" michael@0: #include "nsIDOMClassInfo.h" michael@0: #include "nsIDOMDOMRequest.h" michael@0: #include "nsIPermissionManager.h" michael@0: #include "nsIVariant.h" michael@0: michael@0: #include "nsJSUtils.h" michael@0: #include "nsJSON.h" michael@0: #include "mozilla/Services.h" michael@0: michael@0: #define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1" michael@0: michael@0: using namespace mozilla::dom; michael@0: michael@0: class MobileConnection::Listener MOZ_FINAL : public nsIMobileConnectionListener michael@0: { michael@0: MobileConnection* mMobileConnection; michael@0: michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_FORWARD_SAFE_NSIMOBILECONNECTIONLISTENER(mMobileConnection) michael@0: michael@0: Listener(MobileConnection* aMobileConnection) michael@0: : mMobileConnection(aMobileConnection) michael@0: { michael@0: MOZ_ASSERT(mMobileConnection); michael@0: } michael@0: michael@0: void Disconnect() michael@0: { michael@0: MOZ_ASSERT(mMobileConnection); michael@0: mMobileConnection = nullptr; michael@0: } michael@0: }; michael@0: michael@0: NS_IMPL_ISUPPORTS(MobileConnection::Listener, nsIMobileConnectionListener) michael@0: michael@0: DOMCI_DATA(MozMobileConnection, MobileConnection) michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection) michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MobileConnection, michael@0: DOMEventTargetHelper) michael@0: // Don't traverse mListener because it doesn't keep any reference to michael@0: // MobileConnection but a raw pointer instead. Neither does mProvider because michael@0: // it's an xpcom service and is only released at shutting down. michael@0: NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MobileConnection, michael@0: DOMEventTargetHelper) michael@0: NS_IMPL_CYCLE_COLLECTION_UNLINK_END michael@0: michael@0: NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MobileConnection) michael@0: NS_INTERFACE_MAP_ENTRY(nsIDOMMozMobileConnection) michael@0: NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMobileConnection) michael@0: NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) michael@0: michael@0: NS_IMPL_ADDREF_INHERITED(MobileConnection, DOMEventTargetHelper) michael@0: NS_IMPL_RELEASE_INHERITED(MobileConnection, DOMEventTargetHelper) michael@0: michael@0: NS_IMPL_EVENT_HANDLER(MobileConnection, voicechange) michael@0: NS_IMPL_EVENT_HANDLER(MobileConnection, datachange) michael@0: NS_IMPL_EVENT_HANDLER(MobileConnection, ussdreceived) michael@0: NS_IMPL_EVENT_HANDLER(MobileConnection, dataerror) michael@0: NS_IMPL_EVENT_HANDLER(MobileConnection, cfstatechange) michael@0: NS_IMPL_EVENT_HANDLER(MobileConnection, emergencycbmodechange) michael@0: NS_IMPL_EVENT_HANDLER(MobileConnection, otastatuschange) michael@0: NS_IMPL_EVENT_HANDLER(MobileConnection, iccchange) michael@0: NS_IMPL_EVENT_HANDLER(MobileConnection, radiostatechange) michael@0: michael@0: MobileConnection::MobileConnection(uint32_t aClientId) michael@0: : mClientId(aClientId) michael@0: { michael@0: mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID); michael@0: mWindow = nullptr; michael@0: michael@0: // Not being able to acquire the provider isn't fatal since we check michael@0: // for it explicitly below. michael@0: if (!mProvider) { michael@0: NS_WARNING("Could not acquire nsIMobileConnectionProvider!"); michael@0: return; michael@0: } michael@0: } michael@0: michael@0: void michael@0: MobileConnection::Init(nsPIDOMWindow* aWindow) michael@0: { michael@0: BindToOwner(aWindow); michael@0: michael@0: mWindow = do_GetWeakReference(aWindow); michael@0: mListener = new Listener(this); michael@0: michael@0: if (CheckPermission("mobileconnection")) { michael@0: DebugOnly rv = mProvider->RegisterMobileConnectionMsg(mClientId, mListener); michael@0: NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), michael@0: "Failed registering mobile connection messages with provider"); michael@0: } michael@0: } michael@0: michael@0: void michael@0: MobileConnection::Shutdown() michael@0: { michael@0: if (mProvider && mListener) { michael@0: mListener->Disconnect(); michael@0: mProvider->UnregisterMobileConnectionMsg(mClientId, mListener); michael@0: mProvider = nullptr; michael@0: mListener = nullptr; michael@0: } michael@0: } michael@0: michael@0: // nsIDOMMozMobileConnection michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetLastKnownNetwork(nsAString& aNetwork) michael@0: { michael@0: aNetwork.SetIsVoid(true); michael@0: michael@0: if (!CheckPermission("mobilenetwork")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: return mProvider->GetLastKnownNetwork(mClientId, aNetwork); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetLastKnownHomeNetwork(nsAString& aNetwork) michael@0: { michael@0: aNetwork.SetIsVoid(true); michael@0: michael@0: if (!CheckPermission("mobilenetwork")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: return mProvider->GetLastKnownHomeNetwork(mClientId, aNetwork); michael@0: } michael@0: michael@0: // All fields below require the "mobileconnection" permission. michael@0: michael@0: bool michael@0: MobileConnection::CheckPermission(const char* aType) michael@0: { michael@0: nsCOMPtr window = do_QueryReferent(mWindow); michael@0: NS_ENSURE_TRUE(window, false); michael@0: michael@0: nsCOMPtr permMgr = michael@0: do_GetService(NS_PERMISSIONMANAGER_CONTRACTID); michael@0: NS_ENSURE_TRUE(permMgr, false); michael@0: michael@0: uint32_t permission = nsIPermissionManager::DENY_ACTION; michael@0: permMgr->TestPermissionFromWindow(window, aType, &permission); michael@0: return permission == nsIPermissionManager::ALLOW_ACTION; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetVoice(nsIDOMMozMobileConnectionInfo** aVoice) michael@0: { michael@0: *aVoice = nullptr; michael@0: michael@0: if (!mProvider || !CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: return mProvider->GetVoiceConnectionInfo(mClientId, aVoice); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetData(nsIDOMMozMobileConnectionInfo** aData) michael@0: { michael@0: *aData = nullptr; michael@0: michael@0: if (!mProvider || !CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: return mProvider->GetDataConnectionInfo(mClientId, aData); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetIccId(nsAString& aIccId) michael@0: { michael@0: aIccId.SetIsVoid(true); michael@0: michael@0: if (!mProvider || !CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: return mProvider->GetIccId(mClientId, aIccId); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetNetworkSelectionMode(nsAString& aNetworkSelectionMode) michael@0: { michael@0: aNetworkSelectionMode.SetIsVoid(true); michael@0: michael@0: if (!mProvider || !CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: return mProvider->GetNetworkSelectionMode(mClientId, aNetworkSelectionMode); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetRadioState(nsAString& aRadioState) michael@0: { michael@0: aRadioState.SetIsVoid(true); michael@0: michael@0: if (!mProvider || !CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: return mProvider->GetRadioState(mClientId, aRadioState); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetSupportedNetworkTypes(nsIVariant** aSupportedNetworkTypes) michael@0: { michael@0: *aSupportedNetworkTypes = nullptr; michael@0: michael@0: if (!mProvider || !CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: return mProvider->GetSupportedNetworkTypes(mClientId, aSupportedNetworkTypes); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetNetworks(nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->GetNetworks(mClientId, GetOwner(), aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::SelectNetwork(nsIDOMMozMobileNetworkInfo* aNetwork, nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->SelectNetwork(mClientId, GetOwner(), aNetwork, aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::SelectNetworkAutomatically(nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->SelectNetworkAutomatically(mClientId, GetOwner(), aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::SetPreferredNetworkType(const nsAString& aType, michael@0: nsIDOMDOMRequest** aDomRequest) michael@0: { michael@0: *aDomRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->SetPreferredNetworkType(mClientId, GetOwner(), aType, aDomRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetPreferredNetworkType(nsIDOMDOMRequest** aDomRequest) michael@0: { michael@0: *aDomRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->GetPreferredNetworkType(mClientId, GetOwner(), aDomRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::SetRoamingPreference(const nsAString& aMode, nsIDOMDOMRequest** aDomRequest) michael@0: { michael@0: *aDomRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->SetRoamingPreference(mClientId, GetOwner(), aMode, aDomRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetRoamingPreference(nsIDOMDOMRequest** aDomRequest) michael@0: { michael@0: *aDomRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->GetRoamingPreference(mClientId, GetOwner(), aDomRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::SetVoicePrivacyMode(bool aEnabled, nsIDOMDOMRequest** aDomRequest) michael@0: { michael@0: *aDomRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->SetVoicePrivacyMode(mClientId, GetOwner(), aEnabled, aDomRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetVoicePrivacyMode(nsIDOMDOMRequest** aDomRequest) michael@0: { michael@0: *aDomRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->GetVoicePrivacyMode(mClientId, GetOwner(), aDomRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::SendMMI(const nsAString& aMMIString, michael@0: nsIDOMDOMRequest** aRequest) michael@0: { michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->SendMMI(mClientId, GetOwner(), aMMIString, aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::CancelMMI(nsIDOMDOMRequest** aRequest) michael@0: { michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->CancelMMI(mClientId, GetOwner(),aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetCallForwardingOption(uint16_t aReason, michael@0: nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->GetCallForwardingOption(mClientId, GetOwner(), aReason, aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::SetCallForwardingOption(nsIDOMMozMobileCFInfo* aCFInfo, michael@0: nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->SetCallForwardingOption(mClientId, GetOwner(), aCFInfo, aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetCallBarringOption(JS::Handle aOption, michael@0: nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->GetCallBarringOption(mClientId, GetOwner(), aOption, aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::SetCallBarringOption(JS::Handle aOption, michael@0: nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->SetCallBarringOption(mClientId, GetOwner(), aOption, aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::ChangeCallBarringPassword(JS::Handle aInfo, michael@0: nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->ChangeCallBarringPassword(mClientId, GetOwner(), aInfo, aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetCallWaitingOption(nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->GetCallWaitingOption(mClientId, GetOwner(), aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::SetCallWaitingOption(bool aEnabled, michael@0: nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->SetCallWaitingOption(mClientId, GetOwner(), aEnabled, aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::GetCallingLineIdRestriction(nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->GetCallingLineIdRestriction(mClientId, GetOwner(), aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::SetCallingLineIdRestriction(unsigned short aClirMode, michael@0: nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->SetCallingLineIdRestriction(mClientId, GetOwner(), aClirMode, aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::ExitEmergencyCbMode(nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->ExitEmergencyCbMode(mClientId, GetOwner(), aRequest); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::SetRadioEnabled(bool aEnabled, michael@0: nsIDOMDOMRequest** aRequest) michael@0: { michael@0: *aRequest = nullptr; michael@0: michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: if (!mProvider) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: return mProvider->SetRadioEnabled(mClientId, GetOwner(), aEnabled, aRequest); michael@0: } michael@0: michael@0: // nsIMobileConnectionListener michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::NotifyVoiceChanged() michael@0: { michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: return DispatchTrustedEvent(NS_LITERAL_STRING("voicechange")); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::NotifyDataChanged() michael@0: { michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: return DispatchTrustedEvent(NS_LITERAL_STRING("datachange")); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::NotifyUssdReceived(const nsAString& aMessage, michael@0: bool aSessionEnded) michael@0: { michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: USSDReceivedEventInit init; michael@0: init.mBubbles = false; michael@0: init.mCancelable = false; michael@0: init.mMessage = aMessage; michael@0: init.mSessionEnded = aSessionEnded; michael@0: michael@0: nsRefPtr event = michael@0: USSDReceivedEvent::Constructor(this, NS_LITERAL_STRING("ussdreceived"), init); michael@0: michael@0: return DispatchTrustedEvent(event); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::NotifyDataError(const nsAString& aMessage) michael@0: { michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: DataErrorEventInit init; michael@0: init.mBubbles = false; michael@0: init.mCancelable = false; michael@0: init.mMessage = aMessage; michael@0: michael@0: nsRefPtr event = michael@0: DataErrorEvent::Constructor(this, NS_LITERAL_STRING("dataerror"), init); michael@0: michael@0: return DispatchTrustedEvent(event); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::NotifyCFStateChange(bool aSuccess, michael@0: unsigned short aAction, michael@0: unsigned short aReason, michael@0: const nsAString& aNumber, michael@0: unsigned short aSeconds, michael@0: unsigned short aServiceClass) michael@0: { michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: CFStateChangeEventInit init; michael@0: init.mBubbles = false; michael@0: init.mCancelable = false; michael@0: init.mSuccess = aSuccess; michael@0: init.mAction = aAction; michael@0: init.mReason = aReason; michael@0: init.mNumber = aNumber; michael@0: init.mTimeSeconds = aSeconds; michael@0: init.mServiceClass = aServiceClass; michael@0: michael@0: nsRefPtr event = michael@0: CFStateChangeEvent::Constructor(this, NS_LITERAL_STRING("cfstatechange"), init); michael@0: michael@0: return DispatchTrustedEvent(event); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::NotifyEmergencyCbModeChanged(bool aActive, michael@0: uint32_t aTimeoutMs) michael@0: { michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: MozEmergencyCbModeEventInit init; michael@0: init.mBubbles = false; michael@0: init.mCancelable = false; michael@0: init.mActive = aActive; michael@0: init.mTimeoutMs = aTimeoutMs; michael@0: michael@0: nsRefPtr event = michael@0: MozEmergencyCbModeEvent::Constructor(this, NS_LITERAL_STRING("emergencycbmodechange"), init); michael@0: michael@0: return DispatchTrustedEvent(event); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::NotifyOtaStatusChanged(const nsAString& aStatus) michael@0: { michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: MozOtaStatusEventInit init; michael@0: init.mBubbles = false; michael@0: init.mCancelable = false; michael@0: init.mStatus = aStatus; michael@0: michael@0: nsRefPtr event = michael@0: MozOtaStatusEvent::Constructor(this, NS_LITERAL_STRING("otastatuschange"), init); michael@0: michael@0: return DispatchTrustedEvent(event); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::NotifyIccChanged() michael@0: { michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: return DispatchTrustedEvent(NS_LITERAL_STRING("iccchange")); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileConnection::NotifyRadioStateChanged() michael@0: { michael@0: if (!CheckPermission("mobileconnection")) { michael@0: return NS_OK; michael@0: } michael@0: michael@0: return DispatchTrustedEvent(NS_LITERAL_STRING("radiostatechange")); michael@0: }