mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 734145 - B2G RIL: Support USSD codes. Part 4: MobileConnection. r=bent
This commit is contained in:
parent
95ac02d9a9
commit
a2c3da9827
@ -7,6 +7,7 @@
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "USSDReceivedEvent.h"
|
||||
#include "mozilla/Services.h"
|
||||
|
||||
#define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1"
|
||||
@ -14,6 +15,7 @@
|
||||
#define VOICECHANGE_EVENTNAME NS_LITERAL_STRING("voicechange")
|
||||
#define DATACHANGE_EVENTNAME NS_LITERAL_STRING("datachange")
|
||||
#define CARDSTATECHANGE_EVENTNAME NS_LITERAL_STRING("cardstatechange")
|
||||
#define USSDRECEIVED_EVENTNAME NS_LITERAL_STRING("ussdreceived")
|
||||
|
||||
DOMCI_DATA(MozMobileConnection, mozilla::dom::network::MobileConnection)
|
||||
|
||||
@ -24,6 +26,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* kUssdReceivedTopic = "mobile-connection-ussd-received";
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(MobileConnection)
|
||||
|
||||
@ -32,6 +35,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MobileConnection,
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(cardstatechange)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(voicechange)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(datachange)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(ussdreceived)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MobileConnection,
|
||||
@ -39,6 +43,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MobileConnection,
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(cardstatechange)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(voicechange)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(datachange)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(ussdreceived)
|
||||
tmp->mProvider = nsnull;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
@ -76,6 +81,7 @@ MobileConnection::Init(nsPIDOMWindow* aWindow)
|
||||
obs->AddObserver(this, kVoiceChangedTopic, false);
|
||||
obs->AddObserver(this, kDataChangedTopic, false);
|
||||
obs->AddObserver(this, kCardStateChangedTopic, false);
|
||||
obs->AddObserver(this, kUssdReceivedTopic, false);
|
||||
}
|
||||
|
||||
void
|
||||
@ -90,6 +96,7 @@ MobileConnection::Shutdown()
|
||||
obs->RemoveObserver(this, kVoiceChangedTopic);
|
||||
obs->RemoveObserver(this, kDataChangedTopic);
|
||||
obs->RemoveObserver(this, kCardStateChangedTopic);
|
||||
obs->RemoveObserver(this, kUssdReceivedTopic);
|
||||
}
|
||||
|
||||
// nsIObserver
|
||||
@ -114,6 +121,19 @@ MobileConnection::Observe(nsISupports* aSubject,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!strcmp(aTopic, kUssdReceivedTopic)) {
|
||||
nsString ussd;
|
||||
ussd.Assign(aData);
|
||||
nsRefPtr<USSDReceivedEvent> event = USSDReceivedEvent::Create(ussd);
|
||||
NS_ASSERTION(event, "This should never fail!");
|
||||
|
||||
nsresult rv =
|
||||
event->Dispatch(ToIDOMEventTarget(), USSDRECEIVED_EVENTNAME);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_NOT_REACHED("Unknown observer topic!");
|
||||
return NS_OK;
|
||||
}
|
||||
@ -198,6 +218,27 @@ MobileConnection::SetCardLock(const jsval& aInfo, nsIDOMDOMRequest** aDomRequest
|
||||
return mProvider->SetCardLock(GetOwner(), aInfo, aDomRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnection::SendUSSD(const nsAString& aUSSDString,
|
||||
nsIDOMDOMRequest** request)
|
||||
{
|
||||
if (!mProvider) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return mProvider->SendUSSD(GetOwner(), aUSSDString, request);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnection::CancelUSSD(nsIDOMDOMRequest** request)
|
||||
{
|
||||
if (!mProvider) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return mProvider->CancelUSSD(GetOwner(), request);
|
||||
}
|
||||
|
||||
nsresult
|
||||
MobileConnection::InternalDispatchEvent(const nsAString& aType)
|
||||
{
|
||||
@ -218,6 +259,7 @@ MobileConnection::InternalDispatchEvent(const nsAString& aType)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, cardstatechange)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, voicechange)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, datachange)
|
||||
NS_IMPL_EVENT_HANDLER(MobileConnection, ussdreceived)
|
||||
|
||||
} // namespace network
|
||||
} // namespace dom
|
||||
|
@ -37,11 +37,19 @@ public:
|
||||
private:
|
||||
nsCOMPtr<nsIMobileConnectionProvider> mProvider;
|
||||
|
||||
nsIDOMEventTarget*
|
||||
ToIDOMEventTarget() const
|
||||
{
|
||||
return static_cast<nsDOMEventTargetHelper*>(
|
||||
const_cast<MobileConnection*>(this));
|
||||
}
|
||||
|
||||
nsresult InternalDispatchEvent(const nsAString& aType);
|
||||
|
||||
NS_DECL_EVENT_HANDLER(cardstatechange)
|
||||
NS_DECL_EVENT_HANDLER(voicechange)
|
||||
NS_DECL_EVENT_HANDLER(datachange)
|
||||
NS_DECL_EVENT_HANDLER(ussdreceived)
|
||||
};
|
||||
|
||||
} // namespace network
|
||||
|
Loading…
Reference in New Issue
Block a user