2015-05-03 12:32:37 -07: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 07:21:48 -07: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 02:40:12 -07:00
|
|
|
#include "IccManager.h"
|
2014-04-16 00:30:28 -07:00
|
|
|
#include "mozilla/dom/MozIccManagerBinding.h"
|
2013-10-09 02:40:12 -07:00
|
|
|
#include "Icc.h"
|
|
|
|
#include "IccListener.h"
|
2014-11-13 03:12:11 -08:00
|
|
|
#include "mozilla/AsyncEventDispatcher.h"
|
2013-10-09 02:40:12 -07:00
|
|
|
#include "mozilla/dom/IccChangeEvent.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
2014-09-19 00:53:05 -07:00
|
|
|
#include "nsIIccInfo.h"
|
2015-01-13 02:03:44 -08: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 05:04:27 -07:00
|
|
|
|
2013-10-22 04:23:00 -07:00
|
|
|
using namespace mozilla::dom;
|
2012-06-11 04:28:16 -07:00
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(IccManager)
|
2013-03-06 01:53:27 -08:00
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IccManager,
|
2014-03-31 23:13:50 -07:00
|
|
|
DOMEventTargetHelper)
|
2013-10-09 02:40:12 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2012-06-28 07:21:48 -07:00
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IccManager,
|
2014-03-31 23:13:50 -07:00
|
|
|
DOMEventTargetHelper)
|
2013-10-09 02:40:12 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
2012-06-28 07:21:48 -07:00
|
|
|
|
2014-04-16 00:30:28 -07:00
|
|
|
// QueryInterface implementation for IccManager
|
2013-10-09 02:40:12 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IccManager)
|
2014-03-31 23:13:50 -07:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
2012-06-28 07:21:48 -07:00
|
|
|
|
2014-03-31 23:13:50 -07:00
|
|
|
NS_IMPL_ADDREF_INHERITED(IccManager, DOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(IccManager, DOMEventTargetHelper)
|
2012-06-28 07:21:48 -07:00
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
IccManager::IccManager(nsPIDOMWindow* aWindow)
|
2014-04-16 00:30:28 -07:00
|
|
|
: DOMEventTargetHelper(aWindow)
|
2012-06-28 07:21:48 -07:00
|
|
|
{
|
2013-10-09 02:40:12 -07:00
|
|
|
uint32_t numberOfServices =
|
|
|
|
mozilla::Preferences::GetUint("ril.numRadioInterfaces", 1);
|
2012-06-28 07:21:48 -07:00
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
for (uint32_t i = 0; i < numberOfServices; i++) {
|
|
|
|
nsRefPtr<IccListener> iccListener = new IccListener(this, i);
|
|
|
|
mIccListeners.AppendElement(iccListener);
|
2012-04-10 05:04:27 -07:00
|
|
|
}
|
2012-06-28 07:21:48 -07:00
|
|
|
}
|
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
IccManager::~IccManager()
|
2012-06-28 07:21:48 -07:00
|
|
|
{
|
2013-10-09 02:40:12 -07:00
|
|
|
Shutdown();
|
2014-04-16 00:30:28 -07: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 07:13:33 -07:00
|
|
|
IccManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2014-04-16 00:30:28 -07: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 07:13:33 -07:00
|
|
|
return MozIccManagerBinding::Wrap(aCx, this, aGivenProto);
|
2012-09-12 00:24:58 -07:00
|
|
|
}
|
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
void
|
|
|
|
IccManager::Shutdown()
|
2013-05-30 03:36:10 -07:00
|
|
|
{
|
2013-10-09 02:40:12 -07:00
|
|
|
for (uint32_t i = 0; i < mIccListeners.Length(); i++) {
|
|
|
|
mIccListeners[i]->Shutdown();
|
|
|
|
mIccListeners[i] = nullptr;
|
2013-05-30 03:36:10 -07:00
|
|
|
}
|
2013-10-09 02:40:12 -07:00
|
|
|
mIccListeners.Clear();
|
2013-05-30 03:36:10 -07:00
|
|
|
}
|
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
nsresult
|
|
|
|
IccManager::NotifyIccAdd(const nsAString& aIccId)
|
2013-05-22 01:58:44 -07:00
|
|
|
{
|
2014-04-16 00:30:28 -07:00
|
|
|
MozIccManagerBinding::ClearCachedIccIdsValue(this);
|
2013-05-22 01:58:44 -07:00
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
IccChangeEventInit init;
|
|
|
|
init.mBubbles = false;
|
|
|
|
init.mCancelable = false;
|
|
|
|
init.mIccId = aIccId;
|
2013-10-14 21:21:36 -07:00
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
nsRefPtr<IccChangeEvent> event =
|
|
|
|
IccChangeEvent::Constructor(this, NS_LITERAL_STRING("iccdetected"), init);
|
2014-11-13 03:12:11 -08:00
|
|
|
event->SetTrusted(true);
|
2013-05-22 01:58:44 -07:00
|
|
|
|
2014-11-13 03:12:11 -08:00
|
|
|
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
|
|
|
|
new AsyncEventDispatcher(this, event);
|
|
|
|
|
|
|
|
return asyncDispatcher->PostDOMEvent();
|
2013-04-10 20:45:39 -07:00
|
|
|
}
|
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
nsresult
|
|
|
|
IccManager::NotifyIccRemove(const nsAString& aIccId)
|
2013-04-10 20:45:39 -07:00
|
|
|
{
|
2014-04-16 00:30:28 -07:00
|
|
|
MozIccManagerBinding::ClearCachedIccIdsValue(this);
|
2013-04-10 20:45:39 -07:00
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
IccChangeEventInit init;
|
|
|
|
init.mBubbles = false;
|
|
|
|
init.mCancelable = false;
|
|
|
|
init.mIccId = aIccId;
|
2013-04-10 20:45:39 -07:00
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
nsRefPtr<IccChangeEvent> event =
|
|
|
|
IccChangeEvent::Constructor(this, NS_LITERAL_STRING("iccundetected"), init);
|
2014-11-13 03:12:11 -08:00
|
|
|
event->SetTrusted(true);
|
|
|
|
|
|
|
|
nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
|
|
|
|
new AsyncEventDispatcher(this, event);
|
2013-04-10 20:45:39 -07:00
|
|
|
|
2014-11-13 03:12:11 -08:00
|
|
|
return asyncDispatcher->PostDOMEvent();
|
2013-04-10 20:45:39 -07:00
|
|
|
}
|
|
|
|
|
2014-04-16 00:30:28 -07: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 07:06:05 -07:00
|
|
|
|
2013-10-09 02:40:12 -07:00
|
|
|
void
|
2014-04-16 00:30:28 -07:00
|
|
|
IccManager::GetIccIds(nsTArray<nsString>& aIccIds)
|
2013-02-25 01:27:23 -08:00
|
|
|
{
|
2014-04-16 00:30:28 -07:00
|
|
|
nsTArray<nsRefPtr<IccListener>>::size_type i;
|
|
|
|
for (i = 0; i < mIccListeners.Length(); ++i) {
|
2014-05-19 10:20:21 -07:00
|
|
|
Icc* icc = mIccListeners[i]->GetIcc();
|
2014-04-16 00:30:28 -07:00
|
|
|
if (icc) {
|
|
|
|
aIccIds.AppendElement(icc->GetIccId());
|
2013-10-09 02:40:12 -07:00
|
|
|
}
|
2012-12-24 02:38:49 -08:00
|
|
|
}
|
|
|
|
}
|
2013-02-25 01:27:23 -08:00
|
|
|
|
2014-05-19 10:20:21 -07:00
|
|
|
Icc*
|
2014-04-16 00:30:28 -07:00
|
|
|
IccManager::GetIccById(const nsAString& aIccId) const
|
2013-03-06 01:53:27 -08:00
|
|
|
{
|
2014-04-16 00:30:28 -07:00
|
|
|
nsTArray<nsRefPtr<IccListener>>::size_type i;
|
|
|
|
for (i = 0; i < mIccListeners.Length(); ++i) {
|
2014-05-19 10:20:21 -07:00
|
|
|
Icc* icc = mIccListeners[i]->GetIcc();
|
2013-10-09 02:40:12 -07:00
|
|
|
if (icc && aIccId == icc->GetIccId()) {
|
2014-05-19 10:20:21 -07:00
|
|
|
return icc;
|
2013-10-09 02:40:12 -07:00
|
|
|
}
|
2013-07-17 16:18:00 -07:00
|
|
|
}
|
2014-04-16 00:30:28 -07:00
|
|
|
return nullptr;
|
2013-05-30 03:36:10 -07:00
|
|
|
}
|
2015-01-13 02:03:44 -08:00
|
|
|
|
|
|
|
already_AddRefed<nsIIccService>
|
|
|
|
NS_CreateIccService()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIIccService> service;
|
|
|
|
|
2015-06-24 11:11:00 -07:00
|
|
|
if (XRE_IsContentProcess()) {
|
2015-01-13 02:03:44 -08:00
|
|
|
service = new mozilla::dom::icc::IccIPCService();
|
|
|
|
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
|
|
|
|
} else {
|
2015-04-17 04:03:46 -07:00
|
|
|
service = do_GetService(GONK_ICC_SERVICE_CONTRACTID);
|
2015-01-13 02:03:44 -08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return service.forget();
|
|
|
|
}
|