mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 783525 - part 1 - idl and DOM impl for ICCCardLockErrorEvent. r=smaug, sr=sicking
This commit is contained in:
parent
c9bfc213c0
commit
81d7a61b89
@ -699,6 +699,7 @@ GK_ATOM(onhashchange, "onhashchange")
|
||||
GK_ATOM(onheld, "onheld")
|
||||
GK_ATOM(onholding, "onholding")
|
||||
GK_ATOM(oniccinfochange, "oniccinfochange")
|
||||
GK_ATOM(onicccardlockerror, "onicccardlockerror")
|
||||
GK_ATOM(onincoming, "onincoming")
|
||||
GK_ATOM(oninput, "oninput")
|
||||
GK_ATOM(oninvalid, "oninvalid")
|
||||
|
@ -16,6 +16,7 @@ include $(topsrcdir)/dom/dom-config.mk
|
||||
XPIDLSRCS = \
|
||||
nsIDOMIccManager.idl \
|
||||
SimToolKit.idl \
|
||||
nsIDOMICCCardLockErrorEvent.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
24
dom/icc/interfaces/nsIDOMICCCardLockErrorEvent.idl
Normal file
24
dom/icc/interfaces/nsIDOMICCCardLockErrorEvent.idl
Normal file
@ -0,0 +1,24 @@
|
||||
/* 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/. */
|
||||
|
||||
#include "nsIDOMEvent.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(109c1117-1199-47aa-aad2-ea9f456220fa)]
|
||||
interface nsIDOMICCCardLockErrorEvent : nsIDOMEvent
|
||||
{
|
||||
readonly attribute DOMString lockType;
|
||||
readonly attribute long retryCount;
|
||||
|
||||
[noscript] void initICCCardLockErrorEvent(in DOMString aType,
|
||||
in boolean aCanBubble,
|
||||
in boolean aCancelable,
|
||||
in DOMString aLockType,
|
||||
in int32_t aRetryCount);
|
||||
};
|
||||
|
||||
dictionary ICCCardLockErrorEventInit : EventInit
|
||||
{
|
||||
DOMString lockType;
|
||||
long retryCount;
|
||||
};
|
@ -12,7 +12,7 @@ interface nsIDOMMozMobileNetworkInfo;
|
||||
interface nsIDOMMozMobileCellInfo;
|
||||
interface nsIDOMMozIccManager;
|
||||
|
||||
[scriptable, builtinclass, uuid(f7bddd87-e967-4f97-9481-2042beb86a92)]
|
||||
[scriptable, builtinclass, uuid(5362762c-7091-4da9-aecd-ba878bc51b3d)]
|
||||
interface nsIDOMMozMobileConnection : nsIDOMEventTarget
|
||||
{
|
||||
/**
|
||||
@ -260,6 +260,12 @@ interface nsIDOMMozMobileConnection : nsIDOMEventTarget
|
||||
* receives an error from the RIL
|
||||
*/
|
||||
[implicit_jscontext] attribute jsval ondataerror;
|
||||
|
||||
/**
|
||||
* The 'icccardlockerror' event is notified whenever 'unlockCardLock' or
|
||||
* 'setCardLock' fails.
|
||||
*/
|
||||
[implicit_jscontext] attribute jsval onicccardlockerror;
|
||||
};
|
||||
|
||||
[scriptable, uuid(5ea0e4a9-4684-40da-9930-8ebb61d187f3)]
|
||||
|
@ -11,6 +11,13 @@
|
||||
#include "DataErrorEvent.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "IccManager.h"
|
||||
#include "GeneratedEvents.h"
|
||||
#include "nsIDOMICCCardLockErrorEvent.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsJSON.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
#define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"
|
||||
|
||||
@ -20,6 +27,7 @@
|
||||
#define ICCINFOCHANGE_EVENTNAME NS_LITERAL_STRING("iccinfochange")
|
||||
#define USSDRECEIVED_EVENTNAME NS_LITERAL_STRING("ussdreceived")
|
||||
#define DATAERROR_EVENTNAME NS_LITERAL_STRING("dataerror")
|
||||
#define ICCCARDLOCKERROR_EVENTNAME NS_LITERAL_STRING("icccardlockerror")
|
||||
|
||||
DOMCI_DATA(MozMobileConnection, mozilla::dom::network::MobileConnection)
|
||||
|
||||
@ -33,6 +41,7 @@ const char* kCardStateChangedTopic = "mobile-connection-cardstate-changed";
|
||||
const char* kIccInfoChangedTopic = "mobile-connection-iccinfo-changed";
|
||||
const char* kUssdReceivedTopic = "mobile-connection-ussd-received";
|
||||
const char* kDataErrorTopic = "mobile-connection-data-error";
|
||||
const char* kIccCardLockErrorTopic = "mobile-connection-icccardlock-error";
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection)
|
||||
|
||||
@ -61,6 +70,7 @@ NS_IMPL_EVENT_HANDLER(MobileConnection, voicechange)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, datachange)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, ussdreceived)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, dataerror)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, icccardlockerror)
|
||||
|
||||
MobileConnection::MobileConnection()
|
||||
{
|
||||
@ -90,6 +100,7 @@ MobileConnection::Init(nsPIDOMWindow* aWindow)
|
||||
obs->AddObserver(this, kIccInfoChangedTopic, false);
|
||||
obs->AddObserver(this, kUssdReceivedTopic, false);
|
||||
obs->AddObserver(this, kDataErrorTopic, false);
|
||||
obs->AddObserver(this, kIccCardLockErrorTopic, false);
|
||||
|
||||
mIccManager = new icc::IccManager();
|
||||
mIccManager->Init(aWindow);
|
||||
@ -110,6 +121,7 @@ MobileConnection::Shutdown()
|
||||
obs->RemoveObserver(this, kIccInfoChangedTopic);
|
||||
obs->RemoveObserver(this, kUssdReceivedTopic);
|
||||
obs->RemoveObserver(this, kDataErrorTopic);
|
||||
obs->RemoveObserver(this, kIccCardLockErrorTopic);
|
||||
|
||||
if (mIccManager) {
|
||||
mIccManager->Shutdown();
|
||||
@ -168,6 +180,60 @@ MobileConnection::Observe(nsISupports* aSubject,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!strcmp(aTopic, kIccCardLockErrorTopic)) {
|
||||
nsString errorMsg;
|
||||
errorMsg.Assign(aData);
|
||||
|
||||
if (errorMsg.IsEmpty()) {
|
||||
NS_ERROR("Got a 'icc-cardlock-error' topic without a valid message!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsString lockType;
|
||||
int32_t retryCount = -1;
|
||||
|
||||
// Decode the json string "errorMsg" and retrieve its properties:
|
||||
// "lockType" and "retryCount".
|
||||
nsresult rv;
|
||||
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
|
||||
NS_ENSURE_STATE(sc);
|
||||
JSContext* cx = sc->GetNativeContext();
|
||||
NS_ASSERTION(cx, "Failed to get a context!");
|
||||
|
||||
nsCOMPtr<nsIJSON> json(new nsJSON());
|
||||
jsval error;
|
||||
rv = json->DecodeToJSVal(errorMsg, cx, &error);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
jsval type;
|
||||
if (JS_GetProperty(cx, JSVAL_TO_OBJECT(error), "lockType", &type)) {
|
||||
if (JSVAL_IS_STRING(type)) {
|
||||
nsDependentJSString str;
|
||||
str.init(cx, type.toString());
|
||||
lockType.Assign(str);
|
||||
}
|
||||
}
|
||||
|
||||
jsval count;
|
||||
if (JS_GetProperty(cx, JSVAL_TO_OBJECT(error), "retryCount", &count)) {
|
||||
if (JSVAL_IS_NUMBER(count)) {
|
||||
retryCount = count.toNumber();
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
NS_NewDOMICCCardLockErrorEvent(getter_AddRefs(event), nullptr, nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMICCCardLockErrorEvent> e = do_QueryInterface(event);
|
||||
e->InitICCCardLockErrorEvent(NS_LITERAL_STRING("icccardlockerror"),
|
||||
false, false, lockType, retryCount);
|
||||
e->SetTrusted(true);
|
||||
bool dummy;
|
||||
DispatchEvent(event, &dummy);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_NOT_REACHED("Unknown observer topic!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -25,6 +25,9 @@ simple_events = [
|
||||
#ifdef MOZ_B2G_BT
|
||||
'BluetoothDeviceEvent',
|
||||
'BluetoothDeviceAddressEvent',
|
||||
#endif
|
||||
#ifdef MOZ_B2G_RIL
|
||||
'ICCCardLockErrorEvent',
|
||||
#endif
|
||||
'DeviceStorageChangeEvent',
|
||||
'PopupBlockedEvent'
|
||||
|
Loading…
Reference in New Issue
Block a user