2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-04-20 01:33:25 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2014-09-21 11:24:42 +04:00
|
|
|
#include "mozilla/dom/MobileConnection.h"
|
2013-10-29 12:12:41 +04:00
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
#include "MobileConnectionCallback.h"
|
2014-11-13 14:12:11 +03:00
|
|
|
#include "mozilla/AsyncEventDispatcher.h"
|
2014-01-03 09:55:27 +04:00
|
|
|
#include "mozilla/dom/CFStateChangeEvent.h"
|
|
|
|
#include "mozilla/dom/DataErrorEvent.h"
|
2014-04-24 10:37:49 +04:00
|
|
|
#include "mozilla/dom/MozClirModeEvent.h"
|
2014-01-03 09:55:27 +04:00
|
|
|
#include "mozilla/dom/MozEmergencyCbModeEvent.h"
|
|
|
|
#include "mozilla/dom/MozOtaStatusEvent.h"
|
2014-06-11 23:38:55 +04:00
|
|
|
#include "mozilla/dom/ToJSValue.h"
|
2013-08-13 03:13:38 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2014-05-05 10:36:20 +04:00
|
|
|
#include "mozilla/Services.h"
|
2013-08-14 16:50:22 +04:00
|
|
|
#include "nsIDOMDOMRequest.h"
|
2015-01-15 13:19:01 +03:00
|
|
|
#include "nsIIccInfo.h"
|
2013-05-03 05:37:51 +04:00
|
|
|
#include "nsIPermissionManager.h"
|
2014-01-02 12:01:15 +04:00
|
|
|
#include "nsIVariant.h"
|
2012-10-03 10:29:07 +04:00
|
|
|
#include "nsJSON.h"
|
2014-05-05 10:36:20 +04:00
|
|
|
#include "nsJSUtils.h"
|
2014-11-13 14:12:11 +03:00
|
|
|
#include "nsRadioInterfaceLayer.h"
|
2014-05-05 10:36:20 +04:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2012-10-17 15:17:19 +04:00
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
#define MOBILECONN_ERROR_INVALID_PARAMETER NS_LITERAL_STRING("InvalidParameter")
|
|
|
|
#define MOBILECONN_ERROR_INVALID_PASSWORD NS_LITERAL_STRING("InvalidPassword")
|
|
|
|
|
2014-09-25 18:10:42 +04:00
|
|
|
#ifdef CONVERT_STRING_TO_NULLABLE_ENUM
|
|
|
|
#undef CONVERT_STRING_TO_NULLABLE_ENUM
|
|
|
|
#endif
|
2014-05-05 10:36:20 +04:00
|
|
|
#define CONVERT_STRING_TO_NULLABLE_ENUM(_string, _enumType, _enum) \
|
|
|
|
{ \
|
|
|
|
uint32_t i = 0; \
|
|
|
|
for (const EnumEntry* entry = _enumType##Values::strings; \
|
|
|
|
entry->value; \
|
|
|
|
++entry, ++i) { \
|
|
|
|
if (_string.EqualsASCII(entry->value)) { \
|
|
|
|
_enum.SetValue(static_cast<_enumType>(i)); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
using mozilla::ErrorResult;
|
2014-01-02 07:06:17 +04:00
|
|
|
using namespace mozilla::dom;
|
2014-09-21 11:24:42 +04:00
|
|
|
using namespace mozilla::dom::mobileconnection;
|
2013-03-06 13:53:12 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class MobileConnection::Listener final : public nsIMobileConnectionListener
|
2015-01-15 13:19:01 +03:00
|
|
|
, public nsIIccListener
|
2013-03-06 13:53:12 +04:00
|
|
|
{
|
|
|
|
MobileConnection* mMobileConnection;
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_FORWARD_SAFE_NSIMOBILECONNECTIONLISTENER(mMobileConnection)
|
2014-11-13 14:12:11 +03:00
|
|
|
NS_FORWARD_SAFE_NSIICCLISTENER(mMobileConnection)
|
2013-03-06 13:53:12 +04:00
|
|
|
|
2014-09-05 07:22:49 +04:00
|
|
|
explicit Listener(MobileConnection* aMobileConnection)
|
2013-03-06 13:53:12 +04:00
|
|
|
: mMobileConnection(aMobileConnection)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mMobileConnection);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Disconnect()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mMobileConnection);
|
|
|
|
mMobileConnection = nullptr;
|
|
|
|
}
|
2014-07-11 11:58:01 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
~Listener()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mMobileConnection);
|
|
|
|
}
|
2013-03-06 13:53:12 +04:00
|
|
|
};
|
|
|
|
|
2014-11-13 14:12:11 +03:00
|
|
|
NS_IMPL_ISUPPORTS(MobileConnection::Listener, nsIMobileConnectionListener,
|
|
|
|
nsIIccListener)
|
2013-03-06 13:53:12 +04:00
|
|
|
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection)
|
|
|
|
|
2012-04-20 01:33:25 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MobileConnection,
|
2014-04-01 10:13:50 +04:00
|
|
|
DOMEventTargetHelper)
|
2013-03-06 13:53:12 +04:00
|
|
|
// Don't traverse mListener because it doesn't keep any reference to
|
2014-09-21 11:24:43 +04:00
|
|
|
// MobileConnection but a raw pointer instead. Neither does mMobileConnection
|
|
|
|
// because it's an xpcom service owned object and is only released at shutting
|
|
|
|
// down.
|
2014-05-05 10:36:20 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVoice)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mData)
|
2015-01-15 13:19:01 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIccHandler)
|
2012-04-20 01:33:25 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MobileConnection,
|
2014-04-01 10:13:50 +04:00
|
|
|
DOMEventTargetHelper)
|
2014-08-07 08:21:29 +04:00
|
|
|
tmp->Shutdown();
|
2014-05-05 10:36:20 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mVoice)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mData)
|
2015-01-15 13:19:01 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mIccHandler)
|
2012-04-20 01:33:25 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MobileConnection)
|
2014-08-20 05:01:49 +04:00
|
|
|
// MobileConnection does not expose nsIMobileConnectionListener. mListener is
|
|
|
|
// the exposed nsIMobileConnectionListener and forwards the calls it receives
|
|
|
|
// to us.
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(MobileConnection, DOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(MobileConnection, DOMEventTargetHelper)
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
MobileConnection::MobileConnection(nsPIDOMWindow* aWindow, uint32_t aClientId)
|
|
|
|
: DOMEventTargetHelper(aWindow)
|
2014-11-13 14:12:11 +03:00
|
|
|
, mClientId(aClientId)
|
2012-04-20 01:33:25 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
nsCOMPtr<nsIMobileConnectionService> service =
|
|
|
|
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2014-12-31 10:13:50 +03:00
|
|
|
// Per WebAPI design, mIccId should be null instead of an empty string when no
|
|
|
|
// SIM card is inserted. Set null as default value.
|
|
|
|
mIccId.SetIsVoid(true);
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
// Not being able to acquire the service isn't fatal since we check
|
2012-04-20 01:33:25 +04:00
|
|
|
// for it explicitly below.
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!service) {
|
2014-07-02 13:38:23 +04:00
|
|
|
NS_WARNING("Could not acquire nsIMobileConnectionService!");
|
2013-03-06 13:53:12 +04:00
|
|
|
return;
|
2012-04-20 01:33:25 +04:00
|
|
|
}
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2014-11-13 14:12:11 +03:00
|
|
|
nsresult rv = service->GetItemByServiceId(mClientId,
|
2014-09-21 11:24:43 +04:00
|
|
|
getter_AddRefs(mMobileConnection));
|
2015-03-18 21:48:52 +03:00
|
|
|
|
|
|
|
if (NS_FAILED(rv) || !mMobileConnection) {
|
|
|
|
NS_WARNING("Could not acquire nsIMobileConnection!");
|
2014-09-21 11:24:43 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-03 05:37:51 +04:00
|
|
|
mListener = new Listener(this);
|
2014-05-05 10:36:20 +04:00
|
|
|
mVoice = new MobileConnectionInfo(GetOwner());
|
|
|
|
mData = new MobileConnectionInfo(GetOwner());
|
2013-05-03 05:37:51 +04:00
|
|
|
|
2013-12-23 06:59:43 +04:00
|
|
|
if (CheckPermission("mobileconnection")) {
|
2014-09-21 11:24:43 +04:00
|
|
|
DebugOnly<nsresult> rv = mMobileConnection->RegisterListener(mListener);
|
2013-05-03 05:37:51 +04:00
|
|
|
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
|
2014-07-02 13:38:23 +04:00
|
|
|
"Failed registering mobile connection messages with service");
|
2014-05-05 10:36:20 +04:00
|
|
|
UpdateVoice();
|
|
|
|
UpdateData();
|
2014-11-13 14:12:11 +03:00
|
|
|
|
2015-01-15 13:19:01 +03:00
|
|
|
nsCOMPtr<nsIIccService> iccService = do_GetService(ICC_SERVICE_CONTRACTID);
|
|
|
|
|
|
|
|
if (iccService) {
|
|
|
|
iccService->GetIccByServiceId(mClientId, getter_AddRefs(mIccHandler));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mIccHandler) {
|
|
|
|
NS_WARNING("Could not acquire nsIMobileConnection or nsIIcc!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = mIccHandler->RegisterListener(mListener);
|
2014-11-13 14:12:11 +03:00
|
|
|
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
|
|
|
|
"Failed registering icc messages with service");
|
|
|
|
UpdateIccId();
|
2013-05-03 05:37:51 +04:00
|
|
|
}
|
2012-04-20 01:33:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MobileConnection::Shutdown()
|
|
|
|
{
|
2014-08-07 08:21:29 +04:00
|
|
|
if (mListener) {
|
2014-09-21 11:24:43 +04:00
|
|
|
if (mMobileConnection) {
|
|
|
|
mMobileConnection->UnregisterListener(mListener);
|
2014-08-07 08:21:29 +04:00
|
|
|
}
|
|
|
|
|
2015-01-15 13:19:01 +03:00
|
|
|
if (mIccHandler) {
|
|
|
|
mIccHandler->UnregisterListener(mListener);
|
2014-11-13 14:12:11 +03:00
|
|
|
}
|
|
|
|
|
2013-03-06 13:53:12 +04:00
|
|
|
mListener->Disconnect();
|
|
|
|
mListener = nullptr;
|
2012-04-20 01:33:25 +04:00
|
|
|
}
|
2012-04-20 01:33:25 +04:00
|
|
|
}
|
|
|
|
|
2014-07-11 11:58:01 +04:00
|
|
|
MobileConnection::~MobileConnection()
|
|
|
|
{
|
2014-08-07 08:21:29 +04:00
|
|
|
Shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MobileConnection::DisconnectFromOwner()
|
|
|
|
{
|
|
|
|
DOMEventTargetHelper::DisconnectFromOwner();
|
|
|
|
// Event listeners can't be handled anymore, so we can shutdown
|
|
|
|
// the MobileConnection.
|
|
|
|
Shutdown();
|
2014-07-11 11:58:01 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
MobileConnection::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2014-05-05 10:36:20 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return MozMobileConnectionBinding::Wrap(aCx, this, aGivenProto);
|
2014-05-05 10:36:20 +04:00
|
|
|
}
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
bool
|
|
|
|
MobileConnection::CheckPermission(const char* aType) const
|
2013-05-03 05:37:51 +04:00
|
|
|
{
|
2014-05-05 10:36:20 +04:00
|
|
|
nsCOMPtr<nsIPermissionManager> permMgr =
|
|
|
|
mozilla::services::GetPermissionManager();
|
|
|
|
NS_ENSURE_TRUE(permMgr, false);
|
2013-05-03 05:37:51 +04:00
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
uint32_t permission = nsIPermissionManager::DENY_ACTION;
|
|
|
|
permMgr->TestPermissionFromWindow(GetOwner(), aType, &permission);
|
|
|
|
return permission == nsIPermissionManager::ALLOW_ACTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MobileConnection::UpdateVoice()
|
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
return;
|
2013-05-03 05:37:51 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
nsCOMPtr<nsIMobileConnectionInfo> info;
|
2014-09-21 11:24:43 +04:00
|
|
|
mMobileConnection->GetVoice(getter_AddRefs(info));
|
2014-05-05 10:36:20 +04:00
|
|
|
mVoice->Update(info);
|
2013-05-03 05:37:51 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
void
|
|
|
|
MobileConnection::UpdateData()
|
2013-05-03 05:37:51 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
return;
|
2013-05-03 05:37:51 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
nsCOMPtr<nsIMobileConnectionInfo> info;
|
2014-09-21 11:24:43 +04:00
|
|
|
mMobileConnection->GetData(getter_AddRefs(info));
|
2014-05-05 10:36:20 +04:00
|
|
|
mData->Update(info);
|
2013-05-03 05:37:51 +04:00
|
|
|
}
|
|
|
|
|
2014-11-13 14:12:11 +03:00
|
|
|
bool
|
|
|
|
MobileConnection::UpdateIccId()
|
|
|
|
{
|
|
|
|
nsAutoString iccId;
|
|
|
|
nsCOMPtr<nsIIccInfo> iccInfo;
|
2015-01-15 13:19:01 +03:00
|
|
|
if (mIccHandler &&
|
|
|
|
NS_SUCCEEDED(mIccHandler->GetIccInfo(getter_AddRefs(iccInfo))) &&
|
2014-11-13 14:12:11 +03:00
|
|
|
iccInfo) {
|
|
|
|
iccInfo->GetIccid(iccId);
|
|
|
|
} else {
|
|
|
|
iccId.SetIsVoid(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mIccId.Equals(iccId)) {
|
|
|
|
mIccId = iccId;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
nsresult
|
|
|
|
MobileConnection::NotifyError(nsIDOMDOMRequest* aRequest, const nsAString& aMessage)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMRequestService> rs = do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
|
|
|
|
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return rs->FireErrorAsync(aRequest, aMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnection::IsValidPassword(const nsAString& aPassword)
|
|
|
|
{
|
|
|
|
// Check valid PIN for supplementary services. See TS.22.004 clause 5.2.
|
|
|
|
if (aPassword.IsEmpty() || aPassword.Length() != 4) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
int32_t password = nsString(aPassword).ToInteger(&rv);
|
|
|
|
return NS_SUCCEEDED(rv) && password >= 0 && password <= 9999;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnection::IsValidCallForwardingReason(int32_t aReason)
|
|
|
|
{
|
|
|
|
return aReason >= nsIMobileConnection::CALL_FORWARD_REASON_UNCONDITIONAL &&
|
|
|
|
aReason <= nsIMobileConnection::CALL_FORWARD_REASON_ALL_CONDITIONAL_CALL_FORWARDING;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnection::IsValidCallForwardingAction(int32_t aAction)
|
|
|
|
{
|
|
|
|
return aAction >= nsIMobileConnection::CALL_FORWARD_ACTION_DISABLE &&
|
|
|
|
aAction <= nsIMobileConnection::CALL_FORWARD_ACTION_ERASURE &&
|
|
|
|
// Set operation doesn't allow "query" action.
|
|
|
|
aAction != nsIMobileConnection::CALL_FORWARD_ACTION_QUERY_STATUS;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnection::IsValidCallBarringProgram(int32_t aProgram)
|
|
|
|
{
|
|
|
|
return aProgram >= nsIMobileConnection::CALL_BARRING_PROGRAM_ALL_OUTGOING &&
|
2015-05-28 10:41:55 +03:00
|
|
|
aProgram <= nsIMobileConnection::CALL_BARRING_PROGRAM_INCOMING_SERVICE;
|
2014-10-08 10:33:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnection::IsValidCallBarringOptions(const MozCallBarringOptions& aOptions,
|
|
|
|
bool isSetting)
|
|
|
|
{
|
|
|
|
if (!aOptions.mServiceClass.WasPassed() || aOptions.mServiceClass.Value().IsNull() ||
|
|
|
|
!aOptions.mProgram.WasPassed() || aOptions.mProgram.Value().IsNull() ||
|
|
|
|
!IsValidCallBarringProgram(aOptions.mProgram.Value().Value())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// For setting callbarring options, |enabled| and |password| are required.
|
|
|
|
if (isSetting &&
|
|
|
|
(!aOptions.mEnabled.WasPassed() || aOptions.mEnabled.Value().IsNull() ||
|
|
|
|
!aOptions.mPassword.WasPassed() || aOptions.mPassword.Value().IsVoid())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnection::IsValidCallForwardingOptions(const MozCallForwardingOptions& aOptions)
|
|
|
|
{
|
|
|
|
if (!aOptions.mReason.WasPassed() || aOptions.mReason.Value().IsNull() ||
|
|
|
|
!aOptions.mAction.WasPassed() || aOptions.mAction.Value().IsNull() ||
|
|
|
|
!IsValidCallForwardingReason(aOptions.mReason.Value().Value()) ||
|
|
|
|
!IsValidCallForwardingAction(aOptions.mAction.Value().Value())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
// WebIDL interface
|
2013-05-03 05:37:51 +04:00
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
void
|
|
|
|
MobileConnection::GetLastKnownNetwork(nsString& aRetVal) const
|
2013-05-03 05:37:51 +04:00
|
|
|
{
|
2014-05-05 10:36:20 +04:00
|
|
|
aRetVal.SetIsVoid(true);
|
2013-05-03 05:37:51 +04:00
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
return;
|
|
|
|
}
|
2013-05-03 05:37:51 +04:00
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
mMobileConnection->GetLastKnownNetwork(aRetVal);
|
2013-05-03 05:37:51 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
void
|
|
|
|
MobileConnection::GetLastKnownHomeNetwork(nsString& aRetVal) const
|
2012-04-20 01:33:25 +04:00
|
|
|
{
|
2014-05-05 10:36:20 +04:00
|
|
|
aRetVal.SetIsVoid(true);
|
2013-05-03 05:37:51 +04:00
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
return;
|
2012-04-20 01:33:25 +04:00
|
|
|
}
|
2014-05-05 10:36:20 +04:00
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
mMobileConnection->GetLastKnownHomeNetwork(aRetVal);
|
2012-04-20 01:33:25 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
// All fields below require the "mobileconnection" permission.
|
2013-05-03 05:37:51 +04:00
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
MobileConnectionInfo*
|
|
|
|
MobileConnection::Voice() const
|
|
|
|
{
|
|
|
|
return mVoice;
|
2013-11-13 12:51:04 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
MobileConnectionInfo*
|
|
|
|
MobileConnection::Data() const
|
2013-11-13 12:51:04 +04:00
|
|
|
{
|
2014-05-05 10:36:20 +04:00
|
|
|
return mData;
|
2012-04-20 01:33:25 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
void
|
|
|
|
MobileConnection::GetIccId(nsString& aRetVal) const
|
2012-06-20 02:52:06 +04:00
|
|
|
{
|
2014-11-13 14:12:11 +03:00
|
|
|
aRetVal = mIccId;
|
2012-06-20 02:52:06 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
Nullable<MobileNetworkSelectionMode>
|
|
|
|
MobileConnection::GetNetworkSelectionMode() const
|
2013-11-21 18:08:50 +04:00
|
|
|
{
|
2014-05-05 10:36:20 +04:00
|
|
|
Nullable<MobileNetworkSelectionMode> retVal =
|
|
|
|
Nullable<MobileNetworkSelectionMode>();
|
2013-11-21 18:08:50 +04:00
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
return retVal;
|
2013-11-21 18:08:50 +04:00
|
|
|
}
|
2014-05-05 10:36:20 +04:00
|
|
|
|
2014-10-21 10:31:44 +04:00
|
|
|
int32_t mode = nsIMobileConnection::NETWORK_SELECTION_MODE_UNKNOWN;
|
|
|
|
if (NS_SUCCEEDED(mMobileConnection->GetNetworkSelectionMode(&mode)) &&
|
|
|
|
mode != nsIMobileConnection::NETWORK_SELECTION_MODE_UNKNOWN) {
|
|
|
|
MOZ_ASSERT(mode < static_cast<int32_t>(MobileNetworkSelectionMode::EndGuard_));
|
|
|
|
retVal.SetValue(static_cast<MobileNetworkSelectionMode>(mode));
|
|
|
|
}
|
2014-05-05 10:36:20 +04:00
|
|
|
|
|
|
|
return retVal;
|
2013-11-21 18:08:50 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
Nullable<MobileRadioState>
|
|
|
|
MobileConnection::GetRadioState() const
|
2014-01-02 12:01:15 +04:00
|
|
|
{
|
2014-05-05 10:36:20 +04:00
|
|
|
Nullable<MobileRadioState> retVal = Nullable<MobileRadioState>();
|
2014-01-02 12:01:15 +04:00
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
return retVal;
|
2014-01-02 12:01:15 +04:00
|
|
|
}
|
|
|
|
|
2014-10-24 13:12:33 +04:00
|
|
|
int32_t state = nsIMobileConnection::MOBILE_RADIO_STATE_UNKNOWN;
|
|
|
|
if (NS_SUCCEEDED(mMobileConnection->GetRadioState(&state)) &&
|
|
|
|
state != nsIMobileConnection::MOBILE_RADIO_STATE_UNKNOWN) {
|
|
|
|
MOZ_ASSERT(state < static_cast<int32_t>(MobileRadioState::EndGuard_));
|
|
|
|
retVal.SetValue(static_cast<MobileRadioState>(state));
|
|
|
|
}
|
2014-05-05 10:36:20 +04:00
|
|
|
|
|
|
|
return retVal;
|
2014-01-02 12:01:15 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
void
|
|
|
|
MobileConnection::GetSupportedNetworkTypes(nsTArray<MobileNetworkType>& aTypes) const
|
2012-04-20 01:33:25 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-18 05:07:00 +03:00
|
|
|
int32_t* types = nullptr;
|
2014-09-21 11:24:43 +04:00
|
|
|
uint32_t length = 0;
|
2012-04-20 01:33:25 +04:00
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv = mMobileConnection->GetSupportedNetworkTypes(&types, &length);
|
|
|
|
NS_ENSURE_SUCCESS_VOID(rv);
|
2014-05-05 10:36:20 +04:00
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
for (uint32_t i = 0; i < length; ++i) {
|
2014-11-18 05:07:00 +03:00
|
|
|
int32_t type = types[i];
|
2014-05-05 10:36:20 +04:00
|
|
|
|
2014-11-18 05:07:00 +03:00
|
|
|
MOZ_ASSERT(type < static_cast<int32_t>(MobileNetworkType::EndGuard_));
|
|
|
|
aTypes.AppendElement(static_cast<MobileNetworkType>(type));
|
2014-05-05 10:36:20 +04:00
|
|
|
}
|
2014-09-21 11:24:43 +04:00
|
|
|
|
2015-03-27 03:01:12 +03:00
|
|
|
free(types);
|
2014-05-05 10:36:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::GetNetworks(ErrorResult& aRv)
|
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
2012-04-20 01:33:25 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv = mMobileConnection->GetNetworks(requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2012-04-20 01:33:25 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::SelectNetwork(MobileNetworkInfo& aNetwork, ErrorResult& aRv)
|
2012-06-20 02:52:06 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv = mMobileConnection->SelectNetwork(&aNetwork, requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
2012-06-20 02:52:06 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2012-06-20 02:52:06 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::SelectNetworkAutomatically(ErrorResult& aRv)
|
2012-06-20 02:52:06 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv =
|
|
|
|
mMobileConnection->SelectNetworkAutomatically(requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
2012-06-20 02:52:06 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2012-06-20 02:52:06 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::SetPreferredNetworkType(MobilePreferredNetworkType& aType,
|
|
|
|
ErrorResult& aRv)
|
2013-12-11 07:14:41 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
2013-12-11 07:14:41 +04:00
|
|
|
}
|
|
|
|
|
2014-10-30 09:56:00 +03:00
|
|
|
int32_t type = static_cast<int32_t>(aType);
|
2014-05-05 10:36:20 +04:00
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv =
|
|
|
|
mMobileConnection->SetPreferredNetworkType(type, requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-12-11 07:14:41 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::GetPreferredNetworkType(ErrorResult& aRv)
|
2013-12-11 07:14:41 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
2013-12-11 07:14:41 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv = mMobileConnection->GetPreferredNetworkType(requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-12-11 07:14:41 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::SetRoamingPreference(MobileRoamingMode& aMode,
|
|
|
|
ErrorResult& aRv)
|
2013-06-10 11:40:08 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-11-10 12:56:13 +03:00
|
|
|
int32_t mode = static_cast<int32_t>(aMode);
|
2014-05-05 10:36:20 +04:00
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv = mMobileConnection->SetRoamingPreference(mode, requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
2013-06-10 11:40:08 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-06-10 11:40:08 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::GetRoamingPreference(ErrorResult& aRv)
|
2013-06-10 11:40:08 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
2013-06-10 11:40:08 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv = mMobileConnection->GetRoamingPreference(requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
2014-07-02 13:38:23 +04:00
|
|
|
return nullptr;
|
2014-05-05 10:36:20 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-06-10 11:40:08 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::SetVoicePrivacyMode(bool aEnabled, ErrorResult& aRv)
|
2013-08-14 12:21:05 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv =
|
|
|
|
mMobileConnection->SetVoicePrivacyMode(aEnabled, requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
2013-08-14 12:21:05 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-08-14 12:21:05 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::GetVoicePrivacyMode(ErrorResult& aRv)
|
2013-08-14 12:21:05 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv = mMobileConnection->GetVoicePrivacyMode(requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
2013-08-14 12:21:05 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-08-14 12:21:05 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::GetCallForwardingOption(uint16_t aReason, ErrorResult& aRv)
|
2012-10-31 17:58:32 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
2014-10-08 10:33:00 +04:00
|
|
|
|
|
|
|
if (!IsValidCallForwardingReason(aReason)) {
|
|
|
|
nsresult rv = NotifyError(request, MOBILECONN_ERROR_INVALID_PARAMETER);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return request.forget();
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv = mMobileConnection->GetCallForwarding(aReason, requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
2012-10-31 17:58:32 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2012-10-31 17:58:32 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::SetCallForwardingOption(const MozCallForwardingOptions& aOptions,
|
|
|
|
ErrorResult& aRv)
|
2012-10-31 17:58:32 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
2012-10-31 17:58:32 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
|
|
|
|
if (!IsValidCallForwardingOptions(aOptions)) {
|
|
|
|
nsresult rv = NotifyError(request, MOBILECONN_ERROR_INVALID_PARAMETER);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return request.forget();
|
2014-06-25 07:57:16 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
// Fill in optional attributes.
|
|
|
|
uint16_t timeSeconds = 0;
|
|
|
|
if (aOptions.mTimeSeconds.WasPassed() && !aOptions.mTimeSeconds.Value().IsNull()) {
|
|
|
|
timeSeconds = aOptions.mTimeSeconds.Value().Value();
|
|
|
|
}
|
|
|
|
uint16_t serviceClass = nsIMobileConnection::ICC_SERVICE_CLASS_NONE;
|
|
|
|
if (aOptions.mServiceClass.WasPassed() && !aOptions.mServiceClass.Value().IsNull()) {
|
|
|
|
serviceClass = aOptions.mServiceClass.Value().Value();
|
|
|
|
}
|
|
|
|
nsAutoString number;
|
|
|
|
if (aOptions.mNumber.WasPassed()) {
|
|
|
|
number = aOptions.mNumber.Value();
|
|
|
|
} else {
|
|
|
|
number.SetIsVoid(true);
|
2014-05-05 10:36:20 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
nsresult rv = mMobileConnection->SetCallForwarding(aOptions.mAction.Value().Value(),
|
|
|
|
aOptions.mReason.Value().Value(),
|
|
|
|
number,
|
|
|
|
timeSeconds,
|
|
|
|
serviceClass,
|
|
|
|
requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2012-10-31 17:58:32 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::GetCallBarringOption(const MozCallBarringOptions& aOptions,
|
|
|
|
ErrorResult& aRv)
|
2013-05-21 09:12:59 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
|
|
|
|
if (!IsValidCallBarringOptions(aOptions, false)) {
|
|
|
|
nsresult rv = NotifyError(request, MOBILECONN_ERROR_INVALID_PARAMETER);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return request.forget();
|
2014-06-25 07:57:16 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
// Fill in optional attributes.
|
|
|
|
nsAutoString password;
|
|
|
|
if (aOptions.mPassword.WasPassed()) {
|
|
|
|
password = aOptions.mPassword.Value();
|
|
|
|
} else {
|
|
|
|
password.SetIsVoid(true);
|
2013-05-21 09:12:59 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
nsresult rv = mMobileConnection->GetCallBarring(aOptions.mProgram.Value().Value(),
|
|
|
|
password,
|
|
|
|
aOptions.mServiceClass.Value().Value(),
|
|
|
|
requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-05-21 09:12:59 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::SetCallBarringOption(const MozCallBarringOptions& aOptions,
|
|
|
|
ErrorResult& aRv)
|
2013-05-21 09:12:59 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
2014-06-25 07:57:16 +04:00
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
if (!IsValidCallBarringOptions(aOptions, true)) {
|
|
|
|
nsresult rv = NotifyError(request, MOBILECONN_ERROR_INVALID_PARAMETER);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return request.forget();
|
2013-05-21 09:12:59 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
nsresult rv = mMobileConnection->SetCallBarring(aOptions.mProgram.Value().Value(),
|
|
|
|
aOptions.mEnabled.Value().Value(),
|
|
|
|
aOptions.mPassword.Value(),
|
|
|
|
aOptions.mServiceClass.Value().Value(),
|
|
|
|
requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-05-21 09:12:59 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::ChangeCallBarringPassword(const MozCallBarringOptions& aOptions,
|
|
|
|
ErrorResult& aRv)
|
2013-08-27 05:53:30 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
2014-06-25 07:57:16 +04:00
|
|
|
|
2014-10-08 10:33:00 +04:00
|
|
|
if (!aOptions.mPin.WasPassed() || aOptions.mPin.Value().IsVoid() ||
|
|
|
|
!aOptions.mNewPin.WasPassed() || aOptions.mNewPin.Value().IsVoid() ||
|
|
|
|
!IsValidPassword(aOptions.mPin.Value()) ||
|
|
|
|
!IsValidPassword(aOptions.mNewPin.Value())) {
|
|
|
|
nsresult rv = NotifyError(request, MOBILECONN_ERROR_INVALID_PASSWORD);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return request.forget();
|
2013-08-27 05:53:30 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv =
|
2014-10-08 10:33:00 +04:00
|
|
|
mMobileConnection->ChangeCallBarringPassword(aOptions.mPin.Value(),
|
|
|
|
aOptions.mNewPin.Value(),
|
|
|
|
requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-08-27 05:53:30 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::GetCallWaitingOption(ErrorResult& aRv)
|
2013-04-18 16:18:48 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv = mMobileConnection->GetCallWaiting(requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
2013-04-18 16:18:48 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-04-18 16:18:48 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::SetCallWaitingOption(bool aEnabled, ErrorResult& aRv)
|
2013-04-18 16:18:48 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2015-05-28 14:18:22 +03:00
|
|
|
nsresult rv = mMobileConnection->SetCallWaiting(aEnabled,
|
|
|
|
nsIMobileConnection::ICC_SERVICE_CLASS_VOICE,
|
|
|
|
requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
2013-04-18 16:18:48 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-04-18 16:18:48 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::GetCallingLineIdRestriction(ErrorResult& aRv)
|
2013-07-18 01:18:24 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
2013-07-18 01:18:24 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv =
|
|
|
|
mMobileConnection->GetCallingLineIdRestriction(requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-07-18 01:18:24 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::SetCallingLineIdRestriction(uint16_t aMode,
|
|
|
|
ErrorResult& aRv)
|
2013-07-18 01:18:24 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv =
|
|
|
|
mMobileConnection->SetCallingLineIdRestriction(aMode, requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
2013-07-18 01:18:24 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-07-18 01:18:24 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::ExitEmergencyCbMode(ErrorResult& aRv)
|
2013-08-14 16:50:22 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
2013-08-14 16:50:22 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv = mMobileConnection->ExitEmergencyCbMode(requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-08-14 16:50:22 +04:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
already_AddRefed<DOMRequest>
|
|
|
|
MobileConnection::SetRadioEnabled(bool aEnabled, ErrorResult& aRv)
|
2013-11-21 18:08:50 +04:00
|
|
|
{
|
2014-09-21 11:24:43 +04:00
|
|
|
if (!mMobileConnection) {
|
2014-05-05 10:36:20 +04:00
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
|
|
|
|
nsRefPtr<MobileConnectionCallback> requestCallback =
|
|
|
|
new MobileConnectionCallback(GetOwner(), request);
|
|
|
|
|
2014-09-21 11:24:43 +04:00
|
|
|
nsresult rv = mMobileConnection->SetRadioEnabled(aEnabled, requestCallback);
|
2014-05-05 10:36:20 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aRv.Throw(rv);
|
|
|
|
return nullptr;
|
2013-11-21 18:08:50 +04:00
|
|
|
}
|
|
|
|
|
2014-07-02 13:38:23 +04:00
|
|
|
return request.forget();
|
2013-11-21 18:08:50 +04:00
|
|
|
}
|
|
|
|
|
2013-03-06 13:53:12 +04:00
|
|
|
// nsIMobileConnectionListener
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyVoiceChanged()
|
|
|
|
{
|
2013-05-03 05:37:51 +04:00
|
|
|
if (!CheckPermission("mobileconnection")) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
UpdateVoice();
|
|
|
|
|
2013-03-06 13:53:12 +04:00
|
|
|
return DispatchTrustedEvent(NS_LITERAL_STRING("voicechange"));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyDataChanged()
|
|
|
|
{
|
2013-05-03 05:37:51 +04:00
|
|
|
if (!CheckPermission("mobileconnection")) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-05-05 10:36:20 +04:00
|
|
|
UpdateData();
|
|
|
|
|
2013-03-06 13:53:12 +04:00
|
|
|
return DispatchTrustedEvent(NS_LITERAL_STRING("datachange"));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyDataError(const nsAString& aMessage)
|
|
|
|
{
|
2013-05-03 05:37:51 +04:00
|
|
|
if (!CheckPermission("mobileconnection")) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
DataErrorEventInit init;
|
|
|
|
init.mBubbles = false;
|
|
|
|
init.mCancelable = false;
|
|
|
|
init.mMessage = aMessage;
|
2013-03-06 13:53:12 +04:00
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
nsRefPtr<DataErrorEvent> event =
|
|
|
|
DataErrorEvent::Constructor(this, NS_LITERAL_STRING("dataerror"), init);
|
2013-03-06 13:53:12 +04:00
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
return DispatchTrustedEvent(event);
|
2013-03-06 13:53:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-23 18:13:35 +04:00
|
|
|
MobileConnection::NotifyCFStateChanged(unsigned short aAction,
|
2014-07-02 13:38:23 +04:00
|
|
|
unsigned short aReason,
|
|
|
|
const nsAString& aNumber,
|
|
|
|
unsigned short aSeconds,
|
|
|
|
unsigned short aServiceClass)
|
2013-03-06 13:53:12 +04:00
|
|
|
{
|
2013-05-03 05:37:51 +04:00
|
|
|
if (!CheckPermission("mobileconnection")) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
CFStateChangeEventInit init;
|
|
|
|
init.mBubbles = false;
|
|
|
|
init.mCancelable = false;
|
|
|
|
init.mAction = aAction;
|
|
|
|
init.mReason = aReason;
|
|
|
|
init.mNumber = aNumber;
|
|
|
|
init.mTimeSeconds = aSeconds;
|
|
|
|
init.mServiceClass = aServiceClass;
|
2013-03-06 13:53:12 +04:00
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
nsRefPtr<CFStateChangeEvent> event =
|
|
|
|
CFStateChangeEvent::Constructor(this, NS_LITERAL_STRING("cfstatechange"), init);
|
2013-03-06 13:53:12 +04:00
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
return DispatchTrustedEvent(event);
|
2013-03-06 13:53:12 +04:00
|
|
|
}
|
2013-08-14 16:50:22 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyEmergencyCbModeChanged(bool aActive,
|
|
|
|
uint32_t aTimeoutMs)
|
|
|
|
{
|
|
|
|
if (!CheckPermission("mobileconnection")) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
MozEmergencyCbModeEventInit init;
|
|
|
|
init.mBubbles = false;
|
|
|
|
init.mCancelable = false;
|
|
|
|
init.mActive = aActive;
|
|
|
|
init.mTimeoutMs = aTimeoutMs;
|
2013-08-14 16:50:22 +04:00
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
nsRefPtr<MozEmergencyCbModeEvent> event =
|
|
|
|
MozEmergencyCbModeEvent::Constructor(this, NS_LITERAL_STRING("emergencycbmodechange"), init);
|
2013-08-14 16:50:22 +04:00
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
return DispatchTrustedEvent(event);
|
2013-08-14 16:50:22 +04:00
|
|
|
}
|
2013-08-27 16:25:53 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyOtaStatusChanged(const nsAString& aStatus)
|
|
|
|
{
|
|
|
|
if (!CheckPermission("mobileconnection")) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
MozOtaStatusEventInit init;
|
|
|
|
init.mBubbles = false;
|
|
|
|
init.mCancelable = false;
|
|
|
|
init.mStatus = aStatus;
|
2013-08-27 16:25:53 +04:00
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
nsRefPtr<MozOtaStatusEvent> event =
|
|
|
|
MozOtaStatusEvent::Constructor(this, NS_LITERAL_STRING("otastatuschange"), init);
|
2013-08-27 16:25:53 +04:00
|
|
|
|
2014-01-03 09:55:27 +04:00
|
|
|
return DispatchTrustedEvent(event);
|
2013-08-27 16:25:53 +04:00
|
|
|
}
|
2013-10-30 08:02:47 +04:00
|
|
|
|
2013-11-21 18:08:50 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyRadioStateChanged()
|
|
|
|
{
|
|
|
|
if (!CheckPermission("mobileconnection")) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DispatchTrustedEvent(NS_LITERAL_STRING("radiostatechange"));
|
2013-12-09 05:59:17 +04:00
|
|
|
}
|
2014-04-24 10:37:49 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyClirModeChanged(uint32_t aMode)
|
|
|
|
{
|
|
|
|
if (!CheckPermission("mobileconnection")) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
MozClirModeEventInit init;
|
|
|
|
init.mBubbles = false;
|
|
|
|
init.mCancelable = false;
|
|
|
|
init.mMode = aMode;
|
|
|
|
|
|
|
|
nsRefPtr<MozClirModeEvent> event =
|
|
|
|
MozClirModeEvent::Constructor(this, NS_LITERAL_STRING("clirmodechange"), init);
|
|
|
|
|
|
|
|
return DispatchTrustedEvent(event);
|
|
|
|
}
|
2014-07-02 13:38:23 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyLastKnownNetworkChanged()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyLastKnownHomeNetworkChanged()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyNetworkSelectionModeChanged()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-11-13 14:12:11 +03:00
|
|
|
|
|
|
|
// nsIIccListener
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-04-27 11:01:56 +03:00
|
|
|
MobileConnection::NotifyStkCommand(nsIStkProactiveCmd *aStkProactiveCmd)
|
2014-11-13 14:12:11 +03:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyStkSessionEnd()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyCardStateChanged()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnection::NotifyIccInfoChanged()
|
|
|
|
{
|
|
|
|
if (!CheckPermission("mobileconnection")) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!UpdateIccId()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
|
|
|
|
new AsyncEventDispatcher(this, NS_LITERAL_STRING("iccchange"), false);
|
|
|
|
|
|
|
|
return asyncDispatcher->PostDOMEvent();
|
|
|
|
}
|