mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1052846 - Part 2: Use enums for MobileNetworkType in nsIMobileConnectionService.idl (dom/ipc). r=echen
This commit is contained in:
parent
12733f8228
commit
565ce1d394
@ -57,5 +57,17 @@ ASSERT_MOBILE_ROAMING_MODE_EQUALITY(Any, CDMA_ROAMING_PREFERENCE_ANY);
|
||||
|
||||
#undef ASSERT_MOBILE_ROAMING_MODE_EQUALITY
|
||||
|
||||
#define ASSERT_MOBILE_NETWORK_TYPE_EQUALITY(webidlState, xpidlState) \
|
||||
static_assert(static_cast<int32_t>(MobileNetworkType::webidlState) == nsIMobileConnection::xpidlState, \
|
||||
"MobileNetworkType::" #webidlState " should equal to nsIMobileConnection::" #xpidlState)
|
||||
|
||||
ASSERT_MOBILE_NETWORK_TYPE_EQUALITY(Gsm, MOBILE_NETWORK_TYPE_GSM);
|
||||
ASSERT_MOBILE_NETWORK_TYPE_EQUALITY(Wcdma, MOBILE_NETWORK_TYPE_WCDMA);
|
||||
ASSERT_MOBILE_NETWORK_TYPE_EQUALITY(Cdma, MOBILE_NETWORK_TYPE_CDMA);
|
||||
ASSERT_MOBILE_NETWORK_TYPE_EQUALITY(Evdo, MOBILE_NETWORK_TYPE_EVDO);
|
||||
ASSERT_MOBILE_NETWORK_TYPE_EQUALITY(Lte, MOBILE_NETWORK_TYPE_LTE);
|
||||
|
||||
#undef ASSERT_MOBILE_NETWORK_TYPE_EQUALITY
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -378,23 +378,20 @@ MobileConnection::GetSupportedNetworkTypes(nsTArray<MobileNetworkType>& aTypes)
|
||||
return;
|
||||
}
|
||||
|
||||
char16_t** types = nullptr;
|
||||
int32_t* types = nullptr;
|
||||
uint32_t length = 0;
|
||||
|
||||
nsresult rv = mMobileConnection->GetSupportedNetworkTypes(&types, &length);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
nsDependentString rawType(types[i]);
|
||||
Nullable<MobileNetworkType> type = Nullable<MobileNetworkType>();
|
||||
CONVERT_STRING_TO_NULLABLE_ENUM(rawType, MobileNetworkType, type);
|
||||
int32_t type = types[i];
|
||||
|
||||
if (!type.IsNull()) {
|
||||
aTypes.AppendElement(type.Value());
|
||||
}
|
||||
MOZ_ASSERT(type < static_cast<int32_t>(MobileNetworkType::EndGuard_));
|
||||
aTypes.AppendElement(static_cast<MobileNetworkType>(type));
|
||||
}
|
||||
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(length, types);
|
||||
nsMemory::Free(types);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRequest>
|
||||
|
@ -113,7 +113,7 @@ MobileConnectionChild::GetRadioState(int32_t* aRadioState)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileConnectionChild::GetSupportedNetworkTypes(char16_t*** aTypes,
|
||||
MobileConnectionChild::GetSupportedNetworkTypes(int32_t** aTypes,
|
||||
uint32_t* aLength)
|
||||
{
|
||||
NS_ENSURE_ARG(aTypes);
|
||||
@ -121,11 +121,11 @@ MobileConnectionChild::GetSupportedNetworkTypes(char16_t*** aTypes,
|
||||
|
||||
*aLength = mSupportedNetworkTypes.Length();
|
||||
*aTypes =
|
||||
static_cast<char16_t**>(nsMemory::Alloc((*aLength) * sizeof(char16_t*)));
|
||||
static_cast<int32_t*>(nsMemory::Alloc((*aLength) * sizeof(int32_t)));
|
||||
NS_ENSURE_TRUE(*aTypes, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
for (uint32_t i = 0; i < *aLength; i++) {
|
||||
(*aTypes)[i] = ToNewUnicode(mSupportedNetworkTypes[i]);
|
||||
(*aTypes)[i] = mSupportedNetworkTypes[i];
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -117,7 +117,7 @@ private:
|
||||
nsString mLastNetwork;
|
||||
nsString mLastHomeNetwork;
|
||||
int32_t mNetworkSelectionMode;
|
||||
nsTArray<nsString> mSupportedNetworkTypes;
|
||||
nsTArray<int32_t> mSupportedNetworkTypes;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -131,7 +131,7 @@ MobileConnectionParent::RecvInit(nsMobileConnectionInfo* aVoice,
|
||||
nsString* aIccId,
|
||||
int32_t* aNetworkSelectionMode,
|
||||
int32_t* aRadioState,
|
||||
nsTArray<nsString>* aSupportedNetworkTypes)
|
||||
nsTArray<int32_t>* aSupportedNetworkTypes)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMobileConnection, false);
|
||||
|
||||
@ -143,18 +143,17 @@ MobileConnectionParent::RecvInit(nsMobileConnectionInfo* aVoice,
|
||||
NS_ENSURE_SUCCESS(mMobileConnection->GetNetworkSelectionMode(aNetworkSelectionMode), false);
|
||||
NS_ENSURE_SUCCESS(mMobileConnection->GetRadioState(aRadioState), false);
|
||||
|
||||
char16_t** types = nullptr;
|
||||
int32_t* types = nullptr;
|
||||
uint32_t length = 0;
|
||||
|
||||
nsresult rv = mMobileConnection->GetSupportedNetworkTypes(&types, &length);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
nsDependentString type(types[i]);
|
||||
aSupportedNetworkTypes->AppendElement(type);
|
||||
aSupportedNetworkTypes->AppendElement(types[i]);
|
||||
}
|
||||
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(length, types);
|
||||
nsMemory::Free(types);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ protected:
|
||||
RecvInit(nsMobileConnectionInfo* aVoice, nsMobileConnectionInfo* aData,
|
||||
nsString* aLastKnownNetwork, nsString* aLastKnownHomeNetwork,
|
||||
nsString* aIccId, int32_t* aNetworkSelectionMode,
|
||||
int32_t* aRadioState, nsTArray<nsString>* aSupportedNetworkTypes) MOZ_OVERRIDE;
|
||||
int32_t* aRadioState, nsTArray<int32_t>* aSupportedNetworkTypes) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIMobileConnection> mMobileConnection;
|
||||
|
@ -51,7 +51,7 @@ parent:
|
||||
returns (nsMobileConnectionInfo aVoice, nsMobileConnectionInfo aData,
|
||||
nsString aLastKnownNetwork, nsString aLastKnownHomeNetwork,
|
||||
nsString aIccId, int32_t aNetworkSelectionMode,
|
||||
int32_t aRadioState, nsString[] aSupportedNetworkTypes);
|
||||
int32_t aRadioState, int32_t[] aSupportedNetworkTypes);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user