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
/
fil753F8BAD0122C135E8FD934A8DAF3DA9
< prev
next >
Wrap
Text File
|
2010-07-12
|
3KB
|
85 lines
const ARBITER_NAME = "arbiter"
const ARBITER_CLASS_ID_STR = "{19FB0AE6-E66A-11DE-B97E-E96F55D89593}";
const ARBITER_CLASS_ID = Components.ID(ARBITER_CLASS_ID_STR);
const ARBITER_CLASS_NAME = "Arbiter.";
const ARBITER_CONTRACT_ID = "@yandex.ru/" + ARBITER_NAME + ";1";
const Cc = Components.classes,
Ci = Components.interfaces,
Cr = Components.results,
Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function Arbiter() {
this.base = {};
};
Arbiter.prototype = {
base: null,
get wrappedJSObject() {
return this;
},
register: function(name, version) {
if (!this.base[name])
this.base[name] = {
name: name,
version: version,
done: false
};
else {
var item = this.base[name];
if (this.compare(version, item.version) > 0)
item.version = version;
}
},
accept: function(name, version) {
var item = this.base[name];
if (item) {
if (!item.done && (this.compare(version, item.version) >= 0)) {
this.done(name);
return true;
}
else
return false;
}
else {
return false;
}
},
done: function(name) {
var item = this.base[name];
if (item)
item.done = true;
},
compare: function(a, b) {
if (!this._checker)
this._checker = Cc["@mozilla.org/xpcom/version-comparator;1"].getService(Ci.nsIVersionComparator);
return this._checker.compare(a, b);
},
classDescription: ARBITER_CLASS_NAME,
classID: ARBITER_CLASS_ID,
contractID: ARBITER_CONTRACT_ID,
QueryInterface: XPCOMUtils.generateQI([Ci.yIArbiter]),
_xpcom_factory: {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
if (!this._componentInstance)
this._componentInstance = new Arbiter();
return this._componentInstance.QueryInterface(iid);
}
},
_xpcom_categories: [
{
category: "app-startup",
service: true
}
]
};
var components = [Arbiter];
function NSGetModule(compMgr, fileSpec) {
return XPCOMUtils.generateModule(components);
}