xpcomcore-rubygem 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/templates/application/components/bootstrapper.js +45 -30
- data/xpcomcore-rubygem.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.2
|
@@ -8,6 +8,8 @@ var XPCOMCoreBootstrapper = function() {
|
|
8
8
|
|
9
9
|
XPCOMCoreBootstrapper.prototype = {
|
10
10
|
bootstrapped: false,
|
11
|
+
xpcomcoreEnvVar: 'XPCOMCORE',
|
12
|
+
|
11
13
|
classDescription: "XPCOMCore Bootstrapper Component",
|
12
14
|
contractID: "@conflagrationjs.org/xpcomcore/bootstrapper;1",
|
13
15
|
classID: Components.ID("{5412c380-b3b2-11de-8a39-0800200c9a66}"),
|
@@ -16,38 +18,51 @@ XPCOMCoreBootstrapper.prototype = {
|
|
16
18
|
|
17
19
|
observe: function(subject, topic, data) {
|
18
20
|
if (topic != "xpcom-startup") { return false; }
|
19
|
-
if (this.bootstrapped) {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
var xpcomcoreBootstrapper = env.exists('XPCOMCORE') && env.get('XPCOMCORE');
|
24
|
-
if (xpcomcoreBootstrapper) {
|
25
|
-
try {
|
26
|
-
var iniFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("XCurProcD", Components.interfaces.nsIFile);
|
27
|
-
iniFile.append("application.ini");
|
28
|
-
iniFile.QueryInterface(Components.interfaces.nsILocalFile);
|
29
|
-
|
30
|
-
var iniParser = Components.classes["@mozilla.org/xpcom/ini-parser-factory;1"].getService(Components.interfaces.nsIINIParserFactory).createINIParser(iniFile);
|
31
|
-
var xpcomCoreMinVersion = iniParser.getString('XPCOMCore', 'MinVersion');
|
32
|
-
|
33
|
-
dump("\n\nLoading XPCOMCore Bootstrapper from " + xpcomcoreBootstrapper + ".\n\n");
|
34
|
-
Components.utils.import("file://" + xpcomcoreBootstrapper);
|
35
|
-
var versionComparator = Components.classes["@mozilla.org/xpcom/version-comparator;1"].createInstance(Components.interfaces.nsIVersionComparator);
|
36
|
-
|
37
|
-
if (versionComparator.compare(XPCOMCoreConfig.getProperty('version'), xpcomCoreMinVersion) < 0) {
|
38
|
-
throw("XPCOMCore version " + xpcomCoreMinVersion + " is required but we were bootstrapped with " + XPCOMCoreConfig.getProperty('version') + ".");
|
39
|
-
}
|
21
|
+
if (this.bootstrapped) { this.puts("XPCOMCore already bootstrapped."); return true; }
|
22
|
+
try {
|
23
|
+
var xpcomcoreBootstrapper = this.getBootstrapper();
|
24
|
+
if (!xpcomcoreBootstrapper) { throw("No bootstrapper was found. Are you sure " + this.xpcomcoreEnvVar + " is set in your environment?"); }
|
40
25
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
26
|
+
this.puts("Loading XPCOMCore Bootstrapper from " + xpcomcoreBootstrapper);
|
27
|
+
Components.utils.import("file://" + xpcomcoreBootstrapper);
|
28
|
+
this.checkVersion();
|
29
|
+
this.puts("XPCOMCore bootstrapped with version " + XPCOMCoreConfig.getProperty('version'));
|
30
|
+
} catch (e) {
|
31
|
+
this.puts("Exception caught. Quitting.\n" + e);
|
32
|
+
this.forceQuit();
|
33
|
+
}
|
34
|
+
},
|
35
|
+
|
36
|
+
getBootstrapper: function() {
|
37
|
+
var env = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
|
38
|
+
return env.exists(this.xpcomcoreEnvVar) && env.get(this.xpcomcoreEnvVar);
|
39
|
+
},
|
40
|
+
|
41
|
+
getMinXPCOMCoreVersion: function() {
|
42
|
+
var iniFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("XCurProcD", Components.interfaces.nsIFile);
|
43
|
+
iniFile.append("application.ini");
|
44
|
+
iniFile.QueryInterface(Components.interfaces.nsILocalFile);
|
45
|
+
|
46
|
+
var iniParser = Components.classes["@mozilla.org/xpcom/ini-parser-factory;1"].getService(Components.interfaces.nsIINIParserFactory).createINIParser(iniFile);
|
47
|
+
return iniParser.getString('XPCOMCore', 'MinVersion');
|
48
|
+
},
|
49
|
+
|
50
|
+
checkVersion: function() {
|
51
|
+
var xpcomCoreMinVersion = this.getMinXPCOMCoreVersion();
|
52
|
+
var versionComparator = Components.classes["@mozilla.org/xpcom/version-comparator;1"].createInstance(Components.interfaces.nsIVersionComparator);
|
53
|
+
|
54
|
+
if (versionComparator.compare(XPCOMCoreConfig.getProperty('version'), xpcomCoreMinVersion) < 0) {
|
55
|
+
throw("XPCOMCore version " + xpcomCoreMinVersion + " is required but we were bootstrapped with " + XPCOMCoreConfig.getProperty('version') + ".");
|
50
56
|
}
|
57
|
+
},
|
58
|
+
|
59
|
+
forceQuit: function() {
|
60
|
+
var appStartup = Components.classes['@mozilla.org/toolkit/app-startup;1'].getService(Components.interfaces.nsIAppStartup);
|
61
|
+
appStartup.quit(Components.interfaces.nsIAppStartup.eForceQuit);
|
62
|
+
},
|
63
|
+
|
64
|
+
puts: function(str) {
|
65
|
+
dump(str + "\n");
|
51
66
|
}
|
52
67
|
|
53
68
|
};
|
data/xpcomcore-rubygem.gemspec
CHANGED