|
"use strict"; |
|
Object.defineProperty(exports, "__esModule", { value: true }); |
|
const smart_buffer_1 = require("smart-buffer"); |
|
const Language_1 = require("./Language"); |
|
function makeLicensePlist(licenses, context) { |
|
const ret = { |
|
"LPic": [], |
|
"RTF ": [], |
|
"STR#": [], |
|
"TEXT": [] |
|
}; |
|
|
|
for (const [index, item] of licenses.inOrder.entries()) { |
|
const ID = String(index + 5000); |
|
const Name = Language_1.default.byID[item.languageIDs[0]].englishName; |
|
ret["STR#"].push({ |
|
Attributes: "0x0000", |
|
Data: item.labels, |
|
ID, |
|
Name |
|
}); |
|
ret[item.body.type].push({ |
|
Attributes: "0x0000", |
|
Data: item.body.data, |
|
ID, |
|
Name: `${Name} SLA` |
|
}); |
|
} |
|
|
|
for (const prop of ["RTF ", "TEXT"]) |
|
if (!ret[prop].length) |
|
delete ret[prop]; |
|
|
|
{ |
|
const buf = smart_buffer_1.SmartBuffer.fromSize(4 + (6 * licenses.inOrder.length)); |
|
|
|
|
|
buf.writeInt16BE(licenses.defaultLanguageID); |
|
|
|
buf.writeUInt16BE(licenses.byLanguageID.size); |
|
|
|
for (const [languageID, item] of licenses.byLanguageID.entries()) { |
|
|
|
buf.writeInt16BE(languageID); |
|
|
|
buf.writeInt16BE(licenses.inOrder.indexOf(item)); |
|
|
|
|
|
buf.writeInt16BE(Language_1.default.byID[languageID].doubleByteCharset ? 1 : 0); |
|
} |
|
ret.LPic.push({ |
|
Attributes: "0x0000", |
|
Data: buf.toBuffer(), |
|
ID: "5000", |
|
Name: "" |
|
}); |
|
} |
|
return ret; |
|
} |
|
exports.default = makeLicensePlist; |
|
|