Bug 1218721 - Part 1 - Always Insert Name/Number when Providing IccContact Response. r=echen

This commit is contained in:
Bevis Tseng 2015-10-30 20:22:07 +08:00
parent f386c45be8
commit 24d30b464d
5 changed files with 30 additions and 17 deletions

View File

@ -38,7 +38,10 @@ IccContactToMozContact(JSContext* aCx, GlobalObject& aGlobal,
if (count > 0) {
Sequence<nsString>& nameSeq = properties.mName.Construct().SetValue();
for (uint32_t i = 0; i < count; i++) {
nameSeq.AppendElement(nsDependentString(rawStringArray[i]), fallible);
nameSeq.AppendElement(
rawStringArray[i] ? nsDependentString(rawStringArray[i])
: EmptyString(),
fallible);
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray);
}
@ -52,7 +55,9 @@ IccContactToMozContact(JSContext* aCx, GlobalObject& aGlobal,
Sequence<ContactTelField>& numberSeq = properties.mTel.Construct().SetValue();
for (uint32_t i = 0; i < count; i++) {
ContactTelField number;
number.mValue.Construct() = nsDependentString(rawStringArray[i]);
number.mValue.Construct() =
rawStringArray[i] ? nsDependentString(rawStringArray[i])
: EmptyString();
numberSeq.AppendElement(number, fallible);
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray);
@ -67,7 +72,9 @@ IccContactToMozContact(JSContext* aCx, GlobalObject& aGlobal,
Sequence<ContactField>& emailSeq = properties.mEmail.Construct().SetValue();
for (uint32_t i = 0; i < count; i++) {
ContactField email;
email.mValue.Construct() = nsDependentString(rawStringArray[i]);
email.mValue.Construct() =
rawStringArray[i] ? nsDependentString(rawStringArray[i])
: EmptyString();
emailSeq.AppendElement(email, fallible);
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray);

View File

@ -129,6 +129,11 @@ NS_IMETHODIMP IccContact::Get##_field(uint32_t* aCount, char16_t*** a##_field)
return NS_ERROR_OUT_OF_MEMORY; \
} \
for (uint32_t i = 0; i < count; i++) { \
if(m##_field[i].IsVoid()) { \
(temp)[i] = nullptr; \
continue; \
} \
\
(temp)[i] = ToNewUnicode(m##_field[i]); \
if (!(temp)[i]) { \
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, temp); \

View File

@ -86,13 +86,8 @@ function IccContact(aContact) {
this._numbers = [];
this._emails = [];
if (aContact.alphaId) {
this._names.push(aContact.alphaId);
}
if (aContact.number) {
this._numbers.push(aContact.number);
}
this._names.push(aContact.alphaId);
this._numbers.push(aContact.number);
let anrLen = aContact.anr ? aContact.anr.length : 0;
for (let i = 0; i < anrLen; i++) {

View File

@ -51,7 +51,9 @@ IccIPCUtils::GetIccContactDataFromIccContact(nsIIccContact* aContact,
NS_ENSURE_SUCCESS_VOID(rv);
if (count > 0) {
for (uint32_t i = 0; i < count; i++) {
aOutData.names().AppendElement(nsDependentString(rawStringArray[i]));
aOutData.names().AppendElement(
rawStringArray[i] ? nsDependentString(rawStringArray[i])
: NullString());
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray);
}
@ -63,7 +65,9 @@ IccIPCUtils::GetIccContactDataFromIccContact(nsIIccContact* aContact,
NS_ENSURE_SUCCESS_VOID(rv);
if (count > 0) {
for (uint32_t i = 0; i < count; i++) {
aOutData.numbers().AppendElement(nsDependentString(rawStringArray[i]));
aOutData.numbers().AppendElement(
rawStringArray[i] ? nsDependentString(rawStringArray[i])
: NullString());
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray);
}
@ -75,7 +79,9 @@ IccIPCUtils::GetIccContactDataFromIccContact(nsIIccContact* aContact,
NS_ENSURE_SUCCESS_VOID(rv);
if (count > 0) {
for (uint32_t i = 0; i < count; i++) {
aOutData.emails().AppendElement(nsDependentString(rawStringArray[i]));
aOutData.emails().AppendElement(
rawStringArray[i] ? nsDependentString(rawStringArray[i])
: NullString());
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, rawStringArray);
}

View File

@ -8689,7 +8689,7 @@ ICCPDUHelperObject.prototype = {
* 0xff.
* @param str String to be written. Could be null.
*
* @return The string has been written into Buf.
* @return The string has been written into Buf. "" if str is null.
*/
writeStringTo8BitUnpacked: function(numOctets, str) {
const langTable = PDU_NL_LOCKING_SHIFT_TABLES[PDU_NL_IDENTIFIER_DEFAULT];
@ -8729,7 +8729,7 @@ ICCPDUHelperObject.prototype = {
GsmPDUHelper.writeHexOctet(0xff);
}
return (str) ? str.substring(0, i) : null;
return (str) ? str.substring(0, i) : "";
},
/**
@ -9090,7 +9090,7 @@ ICCPDUHelperObject.prototype = {
*/
writeAlphaIdentifier: function(numOctets, alphaId) {
if (numOctets === 0) {
return null;
return "";
}
// If alphaId is empty or it's of GSM 8 bit.
@ -9222,7 +9222,7 @@ ICCPDUHelperObject.prototype = {
for (let i = 0; i < ADN_MAX_BCD_NUMBER_BYTES + 1; i++) {
GsmPDUHelper.writeHexOctet(0xff);
}
return null;
return "";
}
}
};