This is just some static backup of the original site, don't expect every link to work!

source: install.js @ 9e9bab

Last change on this file since 9e9bab was 9e9bab, checked in by root <root@…>, 15 years ago

initial import v0.4.0

  • Property mode set to 100644
File size: 5.3 KB
Line 
1// This code is heavily inspired by Chris Pederick (useragentswitcher) install.js
2// Contributors: Philip Chee, deathburger
3//
4// Philip Chee: Added installation of prefs, components, and locales.
5// deathburger: Refactored to move all changable items to the top of the file.
6
7// Editable Items Begin
8var displayName         = "Virtual Identity"; // The name displayed to the user (don't include the version)
9var version             = "0.4.0";
10var name                = "v_identity"; // The leafname of the JAR file (without the .jar part)
11
12// The following three sets of variables tell this installer script how your
13// extension directory structure looks.
14// If your jar file contains content/packagename use the second packageDir
15// variable. Same rule applies for skinDir and localeDir. I set them up
16// independent of each other just in case an extension layout is wacky.
17//var packageDir           = "/"
18var packageDir           = "/" + name + "/"
19//var skinDir           = "/"
20var skinDir           = "/" + name + "/"
21//var localeDir           = "/"
22var localeDir           = "/" + name + "/"
23
24var locales             = new Array( "en-US", "es-ES", "de-DE", "fr-FR", "nl-NL", "cs-CZ", "it-IT" );
25var skins               = new Array( "classic" ); // "modern"
26var prefs               = new Array( "preferences.js" );
27var components          = new Array(  );
28var searchPlugins       = new Array(  );
29
30// Mozilla Suite/Seamonkey stores all pref files in a single directory
31// under the application directory.  If the name of the preference file(s)
32// is/are not unique enough, you may override other extension preferences.
33// set this to true if you need to prevent this.
34var disambiguatePrefs   = true;
35
36// Editable Items End
37
38var jarName             = name + ".jar";
39var jarFolder           = "content" + packageDir
40var error               = null;
41
42var folder              = getFolder("Profile", "chrome");
43var prefFolder          = getFolder(getFolder("Program", "defaults"), "pref");
44var compFolder          = getFolder("Components");
45var searchFolder        = getFolder("Plugins");
46
47var existsInApplication = File.exists(getFolder(getFolder("Chrome"), jarName));
48var existsInProfile     = File.exists(getFolder(folder, jarName));
49
50var contentFlag         = CONTENT | PROFILE_CHROME;
51var localeFlag          = LOCALE | PROFILE_CHROME;
52var skinFlag            = SKIN | PROFILE_CHROME;
53
54// If the extension exists in the application folder or it doesn't exist
55// in the profile folder and the user doesn't want it installed to the
56// profile folder
57//~ if(existsInApplication ||
58    //~ (!existsInProfile &&
59      //~ !confirm( "Do you want to install the " + displayName +
60                //~ " extension into your profile folder?\n" +
61                //~ "(Cancel will install into the application folder)")))
62//~ {
63    contentFlag = CONTENT | DELAYED_CHROME;
64    folder      = getFolder("chrome");
65    localeFlag  = LOCALE | DELAYED_CHROME;
66    skinFlag    = SKIN | DELAYED_CHROME;
67//~ }
68
69initInstall(displayName, name, version);
70setPackageFolder(folder);
71error = addFile(name, version, "chrome/" + jarName, folder, null);
72
73// If adding the JAR file succeeded
74if(error == SUCCESS)
75{
76    folder = getFolder(folder, jarName);
77
78    registerChrome(contentFlag, folder, jarFolder);
79    for (var i = 0; i < locales.length; i++) {
80        registerChrome(localeFlag, folder, "locale/" + locales[i] + localeDir);
81    }
82
83    for (var i = 0; i < skins.length; i++) {
84        registerChrome(skinFlag, folder, "skin/" + skins[i] + skinDir);
85    }
86
87    for (var i = 0; i < prefs.length; i++) {
88        if (!disambiguatePrefs) {
89            addFile(name + " Defaults", version, "defaults/preferences/" + prefs[i],
90                prefFolder, prefs[i], true);
91        } else {
92            addFile(name + " Defaults", version, "defaults/preferences/" + prefs[i],
93                prefFolder, name + "-" + prefs[i], true);
94        }
95    }
96
97    for (var i = 0; i < components.length; i++) {
98        addFile(name + " Components", version, "components/" + components[i],
99            compFolder, components[i], true);
100    }
101
102    for (var i = 0; i < searchPlugins.length; i++) {
103        addFile(name + " searchPlugins", version, "searchplugins/" + searchPlugins[i],
104            searchFolder, searchPlugins[i], true);
105    }
106
107    error = performInstall();
108
109    // If the install failed
110    if(error != SUCCESS && error != REBOOT_NEEDED)
111    {
112        displayError(error);
113        cancelInstall(error);
114    }
115    else
116    {
117        alert("The installation of the " + displayName + " extension succeeded.");
118    }
119}
120else
121{
122    displayError(error);
123    cancelInstall(error);
124}
125
126// Displays the error message to the user
127function displayError(error)
128{
129    // If the error code was -215
130    if(error == READ_ONLY)
131    {
132        alert("The installation of " + displayName +
133            " failed.\nOne of the files being overwritten is read-only.");
134    }
135    // If the error code was -235
136    else if(error == INSUFFICIENT_DISK_SPACE)
137    {
138        alert("The installation of " + displayName +
139            " failed.\nThere is insufficient disk space.");
140    }
141    // If the error code was -239
142    else if(error == CHROME_REGISTRY_ERROR)
143    {
144        alert("The installation of " + displayName +
145            " failed.\nChrome registration failed.");
146    }
147    else
148    {
149        alert("The installation of " + displayName +
150            " failed.\nThe error code is: " + error);
151    }
152}
Note: See TracBrowser for help on using the repository browser.