Bug 856553 - Part 2: Add setRadioEnabled API (dom). r=khuey

This commit is contained in:
Szu-Yu Chen [:aknow] 2013-11-21 09:08:50 -05:00
Родитель 0f8176fbb9
Коммит 83e5883eb3
2 изменённых файлов: 40 добавлений и 0 удалений

Просмотреть файл

@ -769,6 +769,7 @@ GK_ATOM(onpopuphidden, "onpopuphidden")
GK_ATOM(onpopuphiding, "onpopuphiding")
GK_ATOM(onpopupshowing, "onpopupshowing")
GK_ATOM(onpopupshown, "onpopupshown")
GK_ATOM(onradiostatechange, "onradiostatechange")
GK_ATOM(onreadystatechange, "onreadystatechange")
GK_ATOM(onreceived, "onreceived")
GK_ATOM(onremoteheld, "onremoteheld")

Просмотреть файл

@ -78,6 +78,7 @@ NS_IMPL_EVENT_HANDLER(MobileConnection, cfstatechange)
NS_IMPL_EVENT_HANDLER(MobileConnection, emergencycbmodechange)
NS_IMPL_EVENT_HANDLER(MobileConnection, otastatuschange)
NS_IMPL_EVENT_HANDLER(MobileConnection, iccchange)
NS_IMPL_EVENT_HANDLER(MobileConnection, radiostatechange)
MobileConnection::MobileConnection(uint32_t aClientId)
: mClientId(aClientId)
@ -211,6 +212,17 @@ MobileConnection::GetNetworkSelectionMode(nsAString& aNetworkSelectionMode)
return mProvider->GetNetworkSelectionMode(mClientId, aNetworkSelectionMode);
}
NS_IMETHODIMP
MobileConnection::GetRadioState(nsAString& aRadioState)
{
aRadioState.SetIsVoid(true);
if (!mProvider || !CheckPermission("mobileconnection")) {
return NS_OK;
}
return mProvider->GetRadioState(mClientId, aRadioState);
}
NS_IMETHODIMP
MobileConnection::GetNetworks(nsIDOMDOMRequest** aRequest)
{
@ -519,6 +531,23 @@ MobileConnection::ExitEmergencyCbMode(nsIDOMDOMRequest** aRequest)
return mProvider->ExitEmergencyCbMode(mClientId, GetOwner(), aRequest);
}
NS_IMETHODIMP
MobileConnection::SetRadioEnabled(bool aEnabled,
nsIDOMDOMRequest** aRequest)
{
*aRequest = nullptr;
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
if (!mProvider) {
return NS_ERROR_FAILURE;
}
return mProvider->SetRadioEnabled(mClientId, GetOwner(), aEnabled, aRequest);
}
// nsIMobileConnectionListener
NS_IMETHODIMP
@ -654,3 +683,13 @@ MobileConnection::NotifyIccChanged()
return DispatchTrustedEvent(NS_LITERAL_STRING("iccchange"));
}
NS_IMETHODIMP
MobileConnection::NotifyRadioStateChanged()
{
if (!CheckPermission("mobileconnection")) {
return NS_OK;
}
return DispatchTrustedEvent(NS_LITERAL_STRING("radiostatechange"));
}