Bug 833697 - Transaction-based MmsService. r=vyang

This commit is contained in:
Chia-hung Tai 2013-02-21 18:28:35 +08:00
Родитель efeb14948c
Коммит 1101a14768
3 изменённых файлов: 742 добавлений и 594 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,4 +1,3 @@
# MmsService.js
component {217ddd76-75db-4210-955d-8806cd8d87f9} MmsService.js
contract @mozilla.org/mms/rilmmsservice;1 {217ddd76-75db-4210-955d-8806cd8d87f9}
category profile-after-change MmsService @mozilla.org/mms/rilmmsservice;1

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

@ -2154,7 +2154,10 @@ this.PduHelper = {
let conv = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter);
let entry = WSP_WELL_KNOWN_CHARSETS[charset];
let entry;
if (charset) {
entry = WSP_WELL_KNOWN_CHARSETS[charset];
}
// Set converter to default one if (entry && entry.converter) is null.
// @see OMA-TS-MMS-CONF-V1_3-20050526-D 7.1.9
conv.charset = (entry && entry.converter) || "UTF-8";
@ -2164,6 +2167,33 @@ this.PduHelper = {
}
return null;
},
/**
* @param strContent
* Decoded string content.
* @param charset
* Charset for encode.
*
* @return An encoded UInt8Array of string content.
*/
encodeStringContent: function encodeStringContent(strContent, charset) {
let conv = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter);
let entry;
if (charset) {
entry = WSP_WELL_KNOWN_CHARSETS[charset];
}
// Set converter to default one if (entry && entry.converter) is null.
// @see OMA-TS-MMS-CONF-V1_3-20050526-D 7.1.9
conv.charset = (entry && entry.converter) || "UTF-8";
try {
return conv.convertToByteArray(strContent);
} catch (e) {
}
return null;
},
/**
* Parse multiple header fields with end mark.
*
@ -2394,7 +2424,19 @@ this.PduHelper = {
// Encode headersLen, DataLen
let headersLen = data.offset;
UintVar.encode(data, headersLen);
if (typeof part.content === "string") {
let charset;
if (contentType && contentType.params && contentType.params.charset &&
contentType.params.charset.charset) {
charset = contentType.params.charset.charset;
}
part.content = this.encodeStringContent(part.content, charset);
UintVar.encode(data, part.content.length);
} else if (part.content instanceof Uint8Array) {
UintVar.encode(data, part.content.length);
} else {
throw new TypeError();
}
// Move them to the beginning of encoded octet array.
let slice1 = data.array.slice(headersLen);