home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2011 November
/
CHIP_2011_11.iso
/
Programy
/
Narzedzia
/
AIMP2
/
aimp_2.61.583.exe
/
$TEMP
/
YandexPackSetup.msi
/
filDFB8D069BB0C3F726985645BE0C24FC4
< prev
next >
Wrap
Text File
|
2010-07-12
|
3KB
|
87 lines
/*
XB package manifest.
*/
XB.PackageManifest = function XBPkgMan_constructor(srcURL, XMLDocOrFile) {
if (!sysutils.isString(srcURL))
throw new CustomErrors.EArgType("srcURL", "String", typeof srcURL);
this._packageID = srcURL;
this._files = [];
if (XMLDocOrFile instanceof Ci.nsIFile)
this._loadFromFile(XMLDocOrFile);
else if (XMLDocOrFile instanceof Ci.nsIDOMDocument)
this._loadFromDocument(XMLDocOrFile);
else
throw new CustomErrors.EArgType("XMLDocOrFile", "nsIDOMDocument | nsIFile", typeof XMLDocOrFile);
};
XB.PackageManifest.EPacManifestSyntax = CustomErrors.ECustom.extend({
$name: "EPacManifestSyntax",
constructor: function EPacManifestSyntax_constructor(elementName) {
this.base("Package manifest parse error");
this._elementName = elementName.toString();
},
get _details() {
return [this._elementName];
},
_elementName: undefined
});
XB.PackageManifest.prototype = {
constructor: XB.PackageManifest,
get packageID() {
return this._packageID;
},
get id() {
return this._packageID;
},
get packagesInfo() {
var result = [];
for each (let packageInfo in this._files) {
result.push(sysutils.copyObj(packageInfo));
}
return result;
},
_packageID: undefined,
_files: null,
_loadFromFile: function(file) {
this._loadFromDocument(sysutils.xmlDocFromFile(file));
},
_loadFromDocument: function XBPkgMan_loadFromDocument(document) {
var root = document.documentElement;
if (root.localName !== "manifest")
throw new XB.PackageManifest.EPacManifestSyntax(root.nodeName);
var children = root.childNodes;
for (let i = 0, length = children.length; i < length; i++) {
let packageElement = children[i];
if ((packageElement.nodeType != packageElement.ELEMENT_NODE) || (packageElement.localName !== "package"))
continue;
let versionMin = parseInt( packageElement.getAttribute("platform-min"), 10 );
if (isNaN(versionMin))
throw new XB.PackageManifest.EPacManifestSyntax(packageElement.nodeName);
let packageVersion = packageElement.getAttribute("version") || "1";
packageInfo = {
id: this._packageID,
uri: this._packageID,
version: packageVersion,
fileURL: packageElement.getAttribute("url"),
platformMin: versionMin
};
this._files.push(packageInfo);
}
}
};