mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 782603 - Part 2: MCC/MNC codes DOM implementation. r=smaug
This commit is contained in:
parent
80eff32f37
commit
aa8f6ce2ce
@ -693,6 +693,7 @@ GK_ATOM(onget, "onget")
|
||||
GK_ATOM(onhashchange, "onhashchange")
|
||||
GK_ATOM(onheld, "onheld")
|
||||
GK_ATOM(onholding, "onholding")
|
||||
GK_ATOM(oniccinfochange, "oniccinfochange")
|
||||
GK_ATOM(onincoming, "onincoming")
|
||||
GK_ATOM(oninput, "oninput")
|
||||
GK_ATOM(oninvalid, "oninvalid")
|
||||
|
@ -16,6 +16,7 @@
|
||||
#define VOICECHANGE_EVENTNAME NS_LITERAL_STRING("voicechange")
|
||||
#define DATACHANGE_EVENTNAME NS_LITERAL_STRING("datachange")
|
||||
#define CARDSTATECHANGE_EVENTNAME NS_LITERAL_STRING("cardstatechange")
|
||||
#define ICCINFOCHANGE_EVENTNAME NS_LITERAL_STRING("iccinfochange")
|
||||
#define USSDRECEIVED_EVENTNAME NS_LITERAL_STRING("ussdreceived")
|
||||
|
||||
DOMCI_DATA(MozMobileConnection, mozilla::dom::network::MobileConnection)
|
||||
@ -27,6 +28,7 @@ namespace network {
|
||||
const char* kVoiceChangedTopic = "mobile-connection-voice-changed";
|
||||
const char* kDataChangedTopic = "mobile-connection-data-changed";
|
||||
const char* kCardStateChangedTopic = "mobile-connection-cardstate-changed";
|
||||
const char* kIccInfoChangedTopic = "mobile-connection-iccinfo-changed";
|
||||
const char* kUssdReceivedTopic = "mobile-connection-ussd-received";
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection)
|
||||
@ -51,6 +53,7 @@ NS_IMPL_ADDREF_INHERITED(MobileConnection, nsDOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(MobileConnection, nsDOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, cardstatechange)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, iccinfochange)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, voicechange)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, datachange)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, ussdreceived)
|
||||
@ -80,6 +83,7 @@ MobileConnection::Init(nsPIDOMWindow* aWindow)
|
||||
obs->AddObserver(this, kVoiceChangedTopic, false);
|
||||
obs->AddObserver(this, kDataChangedTopic, false);
|
||||
obs->AddObserver(this, kCardStateChangedTopic, false);
|
||||
obs->AddObserver(this, kIccInfoChangedTopic, false);
|
||||
obs->AddObserver(this, kUssdReceivedTopic, false);
|
||||
|
||||
mIccManager = new icc::IccManager();
|
||||
@ -98,6 +102,7 @@ MobileConnection::Shutdown()
|
||||
obs->RemoveObserver(this, kVoiceChangedTopic);
|
||||
obs->RemoveObserver(this, kDataChangedTopic);
|
||||
obs->RemoveObserver(this, kCardStateChangedTopic);
|
||||
obs->RemoveObserver(this, kIccInfoChangedTopic);
|
||||
obs->RemoveObserver(this, kUssdReceivedTopic);
|
||||
|
||||
if (mIccManager) {
|
||||
@ -128,6 +133,11 @@ MobileConnection::Observe(nsISupports* aSubject,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!strcmp(aTopic, kIccInfoChangedTopic)) {
|
||||
InternalDispatchEvent(ICCINFOCHANGE_EVENTNAME);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!strcmp(aTopic, kUssdReceivedTopic)) {
|
||||
nsString ussd;
|
||||
ussd.Assign(aData);
|
||||
@ -157,6 +167,16 @@ MobileConnection::GetCardState(nsAString& cardState)
|
||||
return mProvider->GetCardState(cardState);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnection::GetIccInfo(nsIDOMMozMobileICCInfo** aIccInfo)
|
||||
{
|
||||
if (!mProvider) {
|
||||
*aIccInfo = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
return mProvider->GetIccInfo(aIccInfo);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnection::GetVoice(nsIDOMMozMobileConnectionInfo** voice)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user