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-06-28 18:21:48 +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/. */
|
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
#include "IccManager.h"
|
2014-04-16 11:30:28 +04:00
|
|
|
#include "mozilla/dom/MozIccManagerBinding.h"
|
2013-10-09 13:40:12 +04:00
|
|
|
#include "Icc.h"
|
|
|
|
#include "IccListener.h"
|
2014-11-13 14:12:11 +03:00
|
|
|
#include "mozilla/AsyncEventDispatcher.h"
|
2013-10-09 13:40:12 +04:00
|
|
|
#include "mozilla/dom/IccChangeEvent.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
2014-09-19 11:53:05 +04:00
|
|
|
#include "nsIIccInfo.h"
|
2015-01-13 13:03:44 +03:00
|
|
|
// Service instantiation
|
|
|
|
#include "ipc/IccIPCService.h"
|
|
|
|
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
|
|
|
#include "nsIGonkIccService.h"
|
|
|
|
#endif
|
|
|
|
#include "nsXULAppAPI.h" // For XRE_GetProcessType()
|
2012-04-10 16:04:27 +04:00
|
|
|
|
2013-10-22 15:23:00 +04:00
|
|
|
using namespace mozilla::dom;
|
2012-06-11 15:28:16 +04:00
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(IccManager)
|
2013-03-06 13:53:27 +04:00
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IccManager,
|
2014-04-01 10:13:50 +04:00
|
|
|
DOMEventTargetHelper)
|
2013-10-09 13:40:12 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2012-06-28 18:21:48 +04:00
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IccManager,
|
2014-04-01 10:13:50 +04:00
|
|
|
DOMEventTargetHelper)
|
2013-10-09 13:40:12 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
2012-06-28 18:21:48 +04:00
|
|
|
|
2014-04-16 11:30:28 +04:00
|
|
|
// QueryInterface implementation for IccManager
|
2013-10-09 13:40:12 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IccManager)
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
2012-06-28 18:21:48 +04:00
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(IccManager, DOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(IccManager, DOMEventTargetHelper)
|
2012-06-28 18:21:48 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
IccManager::IccManager(nsPIDOMWindowInner* aWindow)
|
2014-04-16 11:30:28 +04:00
|
|
|
: DOMEventTargetHelper(aWindow)
|
2012-06-28 18:21:48 +04:00
|
|
|
{
|
2013-10-09 13:40:12 +04:00
|
|
|
uint32_t numberOfServices =
|
|
|
|
mozilla::Preferences::GetUint("ril.numRadioInterfaces", 1);
|
2012-06-28 18:21:48 +04:00
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
for (uint32_t i = 0; i < numberOfServices; i++) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IccListener> iccListener = new IccListener(this, i);
|
2013-10-09 13:40:12 +04:00
|
|
|
mIccListeners.AppendElement(iccListener);
|
2012-04-10 16:04:27 +04:00
|
|
|
}
|
2012-06-28 18:21:48 +04:00
|
|
|
}
|
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
IccManager::~IccManager()
|
2012-06-28 18:21:48 +04:00
|
|
|
{
|
2013-10-09 13:40:12 +04:00
|
|
|
Shutdown();
|
2014-04-16 11:30:28 +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
|
|
|
IccManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2014-04-16 11:30:28 +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 MozIccManagerBinding::Wrap(aCx, this, aGivenProto);
|
2012-09-12 11:24:58 +04:00
|
|
|
}
|
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
void
|
|
|
|
IccManager::Shutdown()
|
2013-05-30 14:36:10 +04:00
|
|
|
{
|
2013-10-09 13:40:12 +04:00
|
|
|
for (uint32_t i = 0; i < mIccListeners.Length(); i++) {
|
|
|
|
mIccListeners[i]->Shutdown();
|
|
|
|
mIccListeners[i] = nullptr;
|
2013-05-30 14:36:10 +04:00
|
|
|
}
|
2013-10-09 13:40:12 +04:00
|
|
|
mIccListeners.Clear();
|
2013-05-30 14:36:10 +04:00
|
|
|
}
|
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
nsresult
|
|
|
|
IccManager::NotifyIccAdd(const nsAString& aIccId)
|
2013-05-22 12:58:44 +04:00
|
|
|
{
|
2014-04-16 11:30:28 +04:00
|
|
|
MozIccManagerBinding::ClearCachedIccIdsValue(this);
|
2013-05-22 12:58:44 +04:00
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
IccChangeEventInit init;
|
|
|
|
init.mBubbles = false;
|
|
|
|
init.mCancelable = false;
|
|
|
|
init.mIccId = aIccId;
|
2013-10-15 08:21:36 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IccChangeEvent> event =
|
2013-10-09 13:40:12 +04:00
|
|
|
IccChangeEvent::Constructor(this, NS_LITERAL_STRING("iccdetected"), init);
|
2014-11-13 14:12:11 +03:00
|
|
|
event->SetTrusted(true);
|
2013-05-22 12:58:44 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<AsyncEventDispatcher> asyncDispatcher =
|
2014-11-13 14:12:11 +03:00
|
|
|
new AsyncEventDispatcher(this, event);
|
|
|
|
|
|
|
|
return asyncDispatcher->PostDOMEvent();
|
2013-04-11 07:45:39 +04:00
|
|
|
}
|
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
nsresult
|
|
|
|
IccManager::NotifyIccRemove(const nsAString& aIccId)
|
2013-04-11 07:45:39 +04:00
|
|
|
{
|
2014-04-16 11:30:28 +04:00
|
|
|
MozIccManagerBinding::ClearCachedIccIdsValue(this);
|
2013-04-11 07:45:39 +04:00
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
IccChangeEventInit init;
|
|
|
|
init.mBubbles = false;
|
|
|
|
init.mCancelable = false;
|
|
|
|
init.mIccId = aIccId;
|
2013-04-11 07:45:39 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IccChangeEvent> event =
|
2013-10-09 13:40:12 +04:00
|
|
|
IccChangeEvent::Constructor(this, NS_LITERAL_STRING("iccundetected"), init);
|
2014-11-13 14:12:11 +03:00
|
|
|
event->SetTrusted(true);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<AsyncEventDispatcher> asyncDispatcher =
|
2014-11-13 14:12:11 +03:00
|
|
|
new AsyncEventDispatcher(this, event);
|
2013-04-11 07:45:39 +04:00
|
|
|
|
2014-11-13 14:12:11 +03:00
|
|
|
return asyncDispatcher->PostDOMEvent();
|
2013-04-11 07:45:39 +04:00
|
|
|
}
|
|
|
|
|
2014-04-16 11:30:28 +04:00
|
|
|
// MozIccManager
|
Bug 875710: Added getCardLockRetryCount to nsIIccProvider, r=vyang, sr=mounir
This patch adds getCardLockRetryCount to nsIIccProvider and its
implementations. This method allows callers to query the number
of remaining tries for unlocking a SIM-card lock. Supported locks
are 'pin', 'puk', 'pin2', 'puk2', 'nck', 'cck', and 'spck'. The
call returns a DOM request that returns the retry count in its
success handler, or signals an appropriate error.
Reading the retry count is an optional feature and may not be
supported for all lock types. In this case the DOM request receives
and error with the name GECKO_ERROR_NOT_SUPPORTED. For an invalid
lock type, the error name is GECKO_ERROR_GENERIC_FAILURE.
getCardLockRetryCount replaces retryCount in nsIDOMMobileConnection,
which is now deprecated.
--HG--
extra : rebase_source : d1d11612f836652dca85f7c701f09e7af962e3b7
2013-07-09 18:06:05 +04:00
|
|
|
|
2013-10-09 13:40:12 +04:00
|
|
|
void
|
2014-04-16 11:30:28 +04:00
|
|
|
IccManager::GetIccIds(nsTArray<nsString>& aIccIds)
|
2013-02-25 13:27:23 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<IccListener>>::size_type i;
|
2014-04-16 11:30:28 +04:00
|
|
|
for (i = 0; i < mIccListeners.Length(); ++i) {
|
2014-05-19 21:20:21 +04:00
|
|
|
Icc* icc = mIccListeners[i]->GetIcc();
|
2014-04-16 11:30:28 +04:00
|
|
|
if (icc) {
|
|
|
|
aIccIds.AppendElement(icc->GetIccId());
|
2013-10-09 13:40:12 +04:00
|
|
|
}
|
2012-12-24 14:38:49 +04:00
|
|
|
}
|
|
|
|
}
|
2013-02-25 13:27:23 +04:00
|
|
|
|
2014-05-19 21:20:21 +04:00
|
|
|
Icc*
|
2014-04-16 11:30:28 +04:00
|
|
|
IccManager::GetIccById(const nsAString& aIccId) const
|
2013-03-06 13:53:27 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<IccListener>>::size_type i;
|
2014-04-16 11:30:28 +04:00
|
|
|
for (i = 0; i < mIccListeners.Length(); ++i) {
|
2014-05-19 21:20:21 +04:00
|
|
|
Icc* icc = mIccListeners[i]->GetIcc();
|
2013-10-09 13:40:12 +04:00
|
|
|
if (icc && aIccId == icc->GetIccId()) {
|
2014-05-19 21:20:21 +04:00
|
|
|
return icc;
|
2013-10-09 13:40:12 +04:00
|
|
|
}
|
2013-07-18 03:18:00 +04:00
|
|
|
}
|
2014-04-16 11:30:28 +04:00
|
|
|
return nullptr;
|
2013-05-30 14:36:10 +04:00
|
|
|
}
|
2015-01-13 13:03:44 +03:00
|
|
|
|
|
|
|
already_AddRefed<nsIIccService>
|
|
|
|
NS_CreateIccService()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIIccService> service;
|
|
|
|
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsContentProcess()) {
|
2015-01-13 13:03:44 +03:00
|
|
|
service = new mozilla::dom::icc::IccIPCService();
|
|
|
|
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
|
|
|
} else {
|
2015-04-17 14:03:46 +03:00
|
|
|
service = do_GetService(GONK_ICC_SERVICE_CONTRACTID);
|
2015-01-13 13:03:44 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return service.forget();
|
|
|
|
}
|