-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall.js
100 lines (81 loc) · 3.63 KB
/
install.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const APP_DISPLAY_NAME = "autopager";
const APP_NAME = "autopager";
const APP_PACKAGE = "/informaction/autopager";
const APP_VERSION = "0.8.0.8";
const APP_PREFS_FILE="defaults/preferences/autopagerdef.js";
const APP_XPCOM_SERVICE="components/AutopagerCOMP.js";
const APP_JAR_FILE = "autopager.jar";
const APP_CONTENT_FOLDER = "content/";
const APP_LOCALES = [
"zh-CN", "zh-TW","nl","en-US","fr","de","it-IT","ja-JP","pt-BR","tr-TR","hu-HU","he-IL","vi","pl-PL","ro","es","sv-SE"
];
//"it-IT","ja-JP",
const APP_SUCCESS_MESSAGE = APP_DISPLAY_NAME+" should now be available on the statusbar when you restart Mozilla.";
const INST_TO_PROFILE = "Do you wish to install "+APP_DISPLAY_NAME+" to your profile?\nThis will mean it does not need reinstalling when you update Mozilla.\n(Click Cancel if you want "+APP_DISPLAY_NAME+" installing to the Mozilla directory.)";
var instToProfile = true;
myPerformInstall(false);
function myPerformInstall(secondTry) {
var err;
initInstall(APP_NAME, APP_PACKAGE, APP_VERSION);
if(!secondTry) {
// profile installs only work since 2003-03-06
instToProfile = (buildID>2003030600 && confirm(INST_TO_PROFILE));
}
var chromef = instToProfile ? getFolder("Profile", "extensions/[email protected]/chrome") : getFolder("chrome");
//err = addFile(APP_PACKAGE, APP_VERSION, "chrome/" + APP_JAR_FILE, chromef, null,true);
if(APP_PREFS_FILE /*&& (err == SUCCESS)*/ ) {
const prefDirs=[
getFolder("Profile","pref"),
getFolder(getFolder(getFolder("Program"),"defaults"),"pref")
];
for(var j=prefDirs.length; j-->0;) {
var prefDir=prefDirs[j];
err = addFile(APP_PACKAGE, APP_VERSION, APP_PREFS_FILE, prefDir, null, true);
logComment("Adding "+APP_PREFS_FILE+" in "+prefDir+": exit code = "+err);
}
}
if(APP_XPCOM_SERVICE) {
var componentsDir = getFolder("Components");
addFile(APP_PACKAGE,APP_VERSION, APP_XPCOM_SERVICE, componentsDir, null, true);
addFile(APP_NAME, "components/.autoreg", getFolder("Program"), "");
}
if(err == SUCCESS) {
//var jar = getFolder(chromef, APP_JAR_FILE);
const chromeFlag=instToProfile?PROFILE_CHROME:DELAYED_CHROME;
//registerChrome(CONTENT | chromeFlag, jar, APP_CONTENT_FOLDER);//'jar, APP_CONTENT_FOLDER);
var localesCount=APP_LOCALES.length;
if(localesCount>0) {
//registerChrome(LOCALE | chromeFlag, jar,"locale/"+APP_LOCALES[--localesCount]+"/");
while(localesCount-- >0) {
//registerChrome(LOCALE | chromeFlag, jar,"locale/"+APP_LOCALES[localesCount]+"/");
}
}
performInstall();
initInstall(APP_NAME, APP_PACKAGE, APP_VERSION);
//registerChrome(SKIN | chromeFlag, jar ,"skin/");
err = performInstall();
if(err == -239 && !secondTry) {
alert("Chrome registration problem, maybe transient, you can try restart to see it works or not.");
cancelInstall(err);
myPerformInstall(true);
return;
}
if(err == SUCCESS || err == 999) {
alert(APP_DISPLAY_NAME+" "+APP_VERSION+" has been succesfully installed.\n"+APP_SUCCESS_MESSAGE);
} else {
var msg = "Install failed!!! Error code:" + err;
if(err == -239) {
msg += "\nThis specific error is usually transient:"
+"\nif you retry to install again, it will probably go away."
}
alert(msg);
//cancelInstall(err);
}
} else {
alert("Failed to create " +APP_JAR_FILE +"\n"
+"You probably don't have appropriate permissions \n"
+"(write access to your profile or chrome directory). \n"
+"_____________________________\nError code:" + err);
cancelInstall(err);
}
}