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