2014-07-01 10:28:18 +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/. */
|
|
|
|
|
2014-09-21 07:24:42 +00:00
|
|
|
#include "mozilla/dom/mobileconnection/MobileConnectionParent.h"
|
2014-07-01 10:28:18 +00:00
|
|
|
|
|
|
|
#include "mozilla/AppProcessChecker.h"
|
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
2014-09-21 07:24:42 +00:00
|
|
|
#include "mozilla/dom/mobileconnection/MobileConnectionIPCSerializer.h"
|
2014-07-01 10:28:18 +00:00
|
|
|
#include "mozilla/dom/MozMobileConnectionBinding.h"
|
|
|
|
#include "mozilla/dom/ToJSValue.h"
|
|
|
|
#include "nsIVariant.h"
|
|
|
|
#include "nsJSUtils.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
using namespace mozilla::dom::mobileconnection;
|
|
|
|
|
|
|
|
MobileConnectionParent::MobileConnectionParent(uint32_t aClientId)
|
2014-09-21 07:24:43 +00:00
|
|
|
: mLive(true)
|
2014-07-01 10:28:18 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(MobileConnectionParent);
|
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
nsCOMPtr<nsIMobileConnectionService> service =
|
|
|
|
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
|
|
|
|
NS_ASSERTION(service, "This shouldn't fail!");
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
nsresult rv = service->GetItemByServiceId(aClientId,
|
|
|
|
getter_AddRefs(mMobileConnection));
|
|
|
|
if (NS_SUCCEEDED(rv) && mMobileConnection) {
|
|
|
|
mMobileConnection->RegisterListener(this);
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MobileConnectionParent::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
mLive = false;
|
2014-09-21 07:24:43 +00:00
|
|
|
if (mMobileConnection) {
|
|
|
|
mMobileConnection->UnregisterListener(this);
|
|
|
|
mMobileConnection = nullptr;
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionParent::RecvPMobileConnectionRequestConstructor(PMobileConnectionRequestParent* aActor,
|
|
|
|
const MobileConnectionRequest& aRequest)
|
|
|
|
{
|
|
|
|
MobileConnectionRequestParent* actor = static_cast<MobileConnectionRequestParent*>(aActor);
|
|
|
|
|
|
|
|
switch (aRequest.type()) {
|
|
|
|
case MobileConnectionRequest::TGetNetworksRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_GetNetworksRequest());
|
|
|
|
case MobileConnectionRequest::TSelectNetworkRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SelectNetworkRequest());
|
|
|
|
case MobileConnectionRequest::TSelectNetworkAutoRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SelectNetworkAutoRequest());
|
|
|
|
case MobileConnectionRequest::TSetPreferredNetworkTypeRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SetPreferredNetworkTypeRequest());
|
|
|
|
case MobileConnectionRequest::TGetPreferredNetworkTypeRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_GetPreferredNetworkTypeRequest());
|
|
|
|
case MobileConnectionRequest::TSetRoamingPreferenceRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SetRoamingPreferenceRequest());
|
|
|
|
case MobileConnectionRequest::TGetRoamingPreferenceRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_GetRoamingPreferenceRequest());
|
|
|
|
case MobileConnectionRequest::TSetVoicePrivacyModeRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SetVoicePrivacyModeRequest());
|
|
|
|
case MobileConnectionRequest::TGetVoicePrivacyModeRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_GetVoicePrivacyModeRequest());
|
|
|
|
case MobileConnectionRequest::TSetCallForwardingRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SetCallForwardingRequest());
|
|
|
|
case MobileConnectionRequest::TGetCallForwardingRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_GetCallForwardingRequest());
|
|
|
|
case MobileConnectionRequest::TSetCallBarringRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SetCallBarringRequest());
|
|
|
|
case MobileConnectionRequest::TGetCallBarringRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_GetCallBarringRequest());
|
|
|
|
case MobileConnectionRequest::TChangeCallBarringPasswordRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_ChangeCallBarringPasswordRequest());
|
|
|
|
case MobileConnectionRequest::TSetCallWaitingRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SetCallWaitingRequest());
|
|
|
|
case MobileConnectionRequest::TGetCallWaitingRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_GetCallWaitingRequest());
|
|
|
|
case MobileConnectionRequest::TSetCallingLineIdRestrictionRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SetCallingLineIdRestrictionRequest());
|
|
|
|
case MobileConnectionRequest::TGetCallingLineIdRestrictionRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_GetCallingLineIdRestrictionRequest());
|
|
|
|
case MobileConnectionRequest::TExitEmergencyCbModeRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_ExitEmergencyCbModeRequest());
|
|
|
|
case MobileConnectionRequest::TSetRadioEnabledRequest:
|
|
|
|
return actor->DoRequest(aRequest.get_SetRadioEnabledRequest());
|
|
|
|
default:
|
|
|
|
MOZ_CRASH("Received invalid request type!");
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
PMobileConnectionRequestParent*
|
|
|
|
MobileConnectionParent::AllocPMobileConnectionRequestParent(const MobileConnectionRequest& request)
|
|
|
|
{
|
|
|
|
if (!AssertAppProcessPermission(Manager(), "mobileconnection")) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
MobileConnectionRequestParent* actor =
|
|
|
|
new MobileConnectionRequestParent(mMobileConnection);
|
2014-07-01 10:28:18 +00:00
|
|
|
// Add an extra ref for IPDL. Will be released in
|
|
|
|
// MobileConnectionParent::DeallocPMobileConnectionRequestParent().
|
|
|
|
actor->AddRef();
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionParent::DeallocPMobileConnectionRequestParent(PMobileConnectionRequestParent* aActor)
|
|
|
|
{
|
|
|
|
// MobileConnectionRequestParent is refcounted, must not be freed manually.
|
|
|
|
static_cast<MobileConnectionRequestParent*>(aActor)->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionParent::RecvInit(nsMobileConnectionInfo* aVoice,
|
|
|
|
nsMobileConnectionInfo* aData,
|
|
|
|
nsString* aLastKnownNetwork,
|
|
|
|
nsString* aLastKnownHomeNetwork,
|
2014-10-21 06:31:44 +00:00
|
|
|
int32_t* aNetworkSelectionMode,
|
2014-10-24 09:12:33 +00:00
|
|
|
int32_t* aRadioState,
|
2014-11-18 02:07:00 +00:00
|
|
|
nsTArray<int32_t>* aSupportedNetworkTypes)
|
2014-07-01 10:28:18 +00:00
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_SUCCESS(mMobileConnection->GetVoice(aVoice), false);
|
|
|
|
NS_ENSURE_SUCCESS(mMobileConnection->GetData(aData), false);
|
|
|
|
NS_ENSURE_SUCCESS(mMobileConnection->GetLastKnownNetwork(*aLastKnownNetwork), false);
|
|
|
|
NS_ENSURE_SUCCESS(mMobileConnection->GetLastKnownHomeNetwork(*aLastKnownHomeNetwork), false);
|
2014-10-21 06:31:44 +00:00
|
|
|
NS_ENSURE_SUCCESS(mMobileConnection->GetNetworkSelectionMode(aNetworkSelectionMode), false);
|
2014-10-24 09:12:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(mMobileConnection->GetRadioState(aRadioState), false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-11-18 02:07:00 +00:00
|
|
|
int32_t* types = nullptr;
|
2014-09-21 07:24:43 +00:00
|
|
|
uint32_t length = 0;
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
nsresult rv = mMobileConnection->GetSupportedNetworkTypes(&types, &length);
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2014-09-16 13:20:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
for (uint32_t i = 0; i < length; ++i) {
|
2014-11-18 02:07:00 +00:00
|
|
|
aSupportedNetworkTypes->AppendElement(types[i]);
|
2014-09-17 11:13:09 +00:00
|
|
|
}
|
2014-09-21 07:24:43 +00:00
|
|
|
|
2014-11-18 02:07:00 +00:00
|
|
|
nsMemory::Free(types);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIMobileConnectionListener
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(MobileConnectionParent, nsIMobileConnectionListener)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionParent::NotifyVoiceChanged()
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIMobileConnectionInfo> info;
|
2014-09-21 07:24:43 +00:00
|
|
|
rv = mMobileConnection->GetVoice(getter_AddRefs(info));
|
2014-07-01 10:28:18 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// We release the ref after serializing process is finished in
|
|
|
|
// MobileConnectionIPCSerializer.
|
|
|
|
return SendNotifyVoiceInfoChanged(info.forget().take()) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionParent::NotifyDataChanged()
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIMobileConnectionInfo> info;
|
2014-09-21 07:24:43 +00:00
|
|
|
rv = mMobileConnection->GetData(getter_AddRefs(info));
|
2014-07-01 10:28:18 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// We release the ref after serializing process is finished in
|
|
|
|
// MobileConnectionIPCSerializer.
|
|
|
|
return SendNotifyDataInfoChanged(info.forget().take()) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionParent::NotifyDataError(const nsAString& aMessage)
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return SendNotifyDataError(nsAutoString(aMessage)) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-23 14:13:35 +00:00
|
|
|
MobileConnectionParent::NotifyCFStateChanged(uint16_t aAction,
|
2014-07-01 10:28:18 +00:00
|
|
|
uint16_t aReason,
|
|
|
|
const nsAString &aNumber,
|
|
|
|
uint16_t aTimeSeconds,
|
|
|
|
uint16_t aServiceClass)
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
2014-10-23 14:13:35 +00:00
|
|
|
return SendNotifyCFStateChanged(aAction, aReason, nsAutoString(aNumber),
|
|
|
|
aTimeSeconds, aServiceClass) ? NS_OK : NS_ERROR_FAILURE;
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionParent::NotifyEmergencyCbModeChanged(bool aActive,
|
|
|
|
uint32_t aTimeoutMs)
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return SendNotifyEmergencyCbModeChanged(aActive, aTimeoutMs)
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionParent::NotifyOtaStatusChanged(const nsAString& aStatus)
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return SendNotifyOtaStatusChanged(nsAutoString(aStatus))
|
|
|
|
? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionParent::NotifyRadioStateChanged()
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsresult rv;
|
2014-10-24 09:12:33 +00:00
|
|
|
int32_t radioState;
|
|
|
|
rv = mMobileConnection->GetRadioState(&radioState);
|
2014-07-01 10:28:18 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return SendNotifyRadioStateChanged(radioState) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionParent::NotifyClirModeChanged(uint32_t aMode)
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return SendNotifyClirModeChanged(aMode) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionParent::NotifyLastKnownNetworkChanged()
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsAutoString network;
|
2014-09-21 07:24:43 +00:00
|
|
|
rv = mMobileConnection->GetLastKnownNetwork(network);
|
2014-07-01 10:28:18 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return SendNotifyLastNetworkChanged(network) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionParent::NotifyLastKnownHomeNetworkChanged()
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsAutoString network;
|
2014-09-21 07:24:43 +00:00
|
|
|
rv = mMobileConnection->GetLastKnownHomeNetwork(network);
|
2014-07-01 10:28:18 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return SendNotifyLastHomeNetworkChanged(network) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionParent::NotifyNetworkSelectionModeChanged()
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsresult rv;
|
2014-10-21 06:31:44 +00:00
|
|
|
int32_t mode;
|
|
|
|
rv = mMobileConnection->GetNetworkSelectionMode(&mode);
|
2014-07-01 10:28:18 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return SendNotifyNetworkSelectionModeChanged(mode) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* PMobileConnectionRequestParent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
MobileConnectionRequestParent::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
mLive = false;
|
2014-09-21 07:24:43 +00:00
|
|
|
mMobileConnection = nullptr;
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const GetNetworksRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->GetNetworks(this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const SelectNetworkRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
|
|
|
// Use dont_AddRef here because this instances is already AddRef-ed in
|
|
|
|
// MobileConnectionIPCSerializer.h
|
|
|
|
nsCOMPtr<nsIMobileNetworkInfo> network = dont_AddRef(aRequest.network());
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->SelectNetwork(network, this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const SelectNetworkAutoRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->SelectNetworkAutomatically(this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const SetPreferredNetworkTypeRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->SetPreferredNetworkType(aRequest.type(), this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const GetPreferredNetworkTypeRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->GetPreferredNetworkType(this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const SetRoamingPreferenceRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->SetRoamingPreference(aRequest.mode(), this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const GetRoamingPreferenceRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->GetRoamingPreference(this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const SetVoicePrivacyModeRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->SetVoicePrivacyMode(aRequest.enabled(), this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const GetVoicePrivacyModeRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->GetVoicePrivacyMode(this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const SetCallForwardingRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-10-08 06:34:00 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->SetCallForwarding(aRequest.action(),
|
|
|
|
aRequest.reason(),
|
|
|
|
aRequest.number(),
|
|
|
|
aRequest.timeSeconds(),
|
|
|
|
aRequest.serviceClass(),
|
|
|
|
this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const GetCallForwardingRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-10-08 06:34:00 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->GetCallForwarding(aRequest.reason(),
|
|
|
|
this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const SetCallBarringRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-10-08 06:34:00 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->SetCallBarring(aRequest.program(),
|
|
|
|
aRequest.enabled(),
|
|
|
|
aRequest.password(),
|
|
|
|
aRequest.serviceClass(),
|
|
|
|
this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const GetCallBarringRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-10-08 06:34:00 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->GetCallBarring(aRequest.program(),
|
|
|
|
aRequest.password(),
|
|
|
|
aRequest.serviceClass(),
|
|
|
|
this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const ChangeCallBarringPasswordRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-10-08 06:34:00 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->ChangeCallBarringPassword(aRequest.pin(),
|
|
|
|
aRequest.newPin(),
|
|
|
|
this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const SetCallWaitingRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->SetCallWaiting(aRequest.enabled(), this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const GetCallWaitingRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->GetCallWaiting(this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const SetCallingLineIdRestrictionRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->SetCallingLineIdRestriction(aRequest.mode(), this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const GetCallingLineIdRestrictionRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->GetCallingLineIdRestriction(this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const ExitEmergencyCbModeRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->ExitEmergencyCbMode(this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MobileConnectionRequestParent::DoRequest(const SetRadioEnabledRequest& aRequest)
|
|
|
|
{
|
2014-09-21 07:24:43 +00:00
|
|
|
NS_ENSURE_TRUE(mMobileConnection, false);
|
2014-07-01 10:28:18 +00:00
|
|
|
|
2014-09-21 07:24:43 +00:00
|
|
|
return NS_SUCCEEDED(mMobileConnection->SetRadioEnabled(aRequest.enabled(), this));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
MobileConnectionRequestParent::SendReply(const MobileConnectionReply& aReply)
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mLive, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return Send__delete__(this, aReply) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIMobileConnectionListener
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(MobileConnectionRequestParent, nsIMobileConnectionCallback);
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionRequestParent::NotifySuccess()
|
|
|
|
{
|
|
|
|
return SendReply(MobileConnectionReplySuccess());
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionRequestParent::NotifySuccessWithBoolean(bool aResult)
|
|
|
|
{
|
|
|
|
return SendReply(MobileConnectionReplySuccessBoolean(aResult));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionRequestParent::NotifyGetNetworksSuccess(uint32_t aCount,
|
|
|
|
nsIMobileNetworkInfo** aNetworks)
|
|
|
|
{
|
|
|
|
nsTArray<nsIMobileNetworkInfo*> networks;
|
|
|
|
for (uint32_t i = 0; i < aCount; i++) {
|
|
|
|
nsCOMPtr<nsIMobileNetworkInfo> network = aNetworks[i];
|
|
|
|
// We release the ref after serializing process is finished in
|
|
|
|
// MobileConnectionIPCSerializer.
|
|
|
|
networks.AppendElement(network.forget().take());
|
|
|
|
}
|
|
|
|
return SendReply(MobileConnectionReplySuccessNetworks(networks));
|
|
|
|
}
|
|
|
|
|
2014-10-08 06:34:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionRequestParent::NotifyGetCallForwardingSuccess(uint32_t aCount,
|
|
|
|
nsIMobileCallForwardingOptions** aResults)
|
|
|
|
{
|
|
|
|
nsTArray<nsIMobileCallForwardingOptions*> results;
|
|
|
|
for (uint32_t i = 0; i < aCount; i++) {
|
|
|
|
results.AppendElement(aResults[i]);
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return SendReply(MobileConnectionReplySuccessCallForwarding(results));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionRequestParent::NotifyGetCallBarringSuccess(uint16_t aProgram,
|
|
|
|
bool aEnabled,
|
|
|
|
uint16_t aServiceClass)
|
|
|
|
{
|
|
|
|
return SendReply(MobileConnectionReplySuccessCallBarring(aProgram, aEnabled,
|
|
|
|
aServiceClass));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionRequestParent::NotifyGetClirStatusSuccess(uint16_t aN,
|
|
|
|
uint16_t aM)
|
|
|
|
{
|
|
|
|
return SendReply(MobileConnectionReplySuccessClirStatus(aN, aM));
|
|
|
|
}
|
|
|
|
|
2014-10-30 06:56:00 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionRequestParent::NotifyGetPreferredNetworkTypeSuccess(int32_t aType)
|
|
|
|
{
|
|
|
|
return SendReply(MobileConnectionReplySuccessPreferredNetworkType(aType));
|
|
|
|
}
|
|
|
|
|
2014-11-10 09:56:13 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
MobileConnectionRequestParent::NotifyGetRoamingPreferenceSuccess(int32_t aMode)
|
|
|
|
{
|
|
|
|
return SendReply(MobileConnectionReplySuccessRoamingPreference(aMode));
|
|
|
|
}
|
|
|
|
|
2014-07-01 10:28:18 +00:00
|
|
|
NS_IMETHODIMP
|
2014-12-21 16:35:00 +00:00
|
|
|
MobileConnectionRequestParent::NotifyError(const nsAString& aName)
|
|
|
|
{
|
|
|
|
nsAutoString error(aName);
|
|
|
|
return SendReply(MobileConnectionReplyError(error));
|
2014-07-01 10:28:18 +00:00
|
|
|
}
|