~ubuntu-branches/ubuntu/lucid/flashblock/lucid-proposed

« back to all changes in this revision

Viewing changes to install-global.js

  • Committer: Bazaar Package Importer
  • Author(s): Alexander GQ Gerasiov
  • Date: 2009-11-30 01:21:27 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091130012127-ngxo3jqkddn3smi1
Tags: 1.5.11-2
* Fixed typo in debian/copyright.
* Using new dpkg v3 format, it rocks.
* Package description updated (taken from extension's homepage).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
8
 
var displayName         = "Flashblock"; // The name displayed to the user (don't include the version)
9
 
var version             = "1.3.5";
10
 
var name                = "flashblock"; // 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           = "/"
18
 
var packageDir           = "/" + name + "/"
19
 
//var skinDir           = "/"
20
 
var skinDir           = "/" + name + "/"
21
 
//var localeDir           = "/"
22
 
var localeDir           = "/" + name + "/"
23
 
 
24
 
var locales             = new Array( "en-US", "it-IT", "nl-NL", "de-DE",
25
 
"fr-FR", "pl-PL", "ko-KR", "pt-BR", "da-DK", "hu-HU", "cs-CZ", "es-ES",
26
 
"ru-RU", "ro-RO", "de-AT", "ja-JP", "zh-CN", "ar-YE", "ar-JO", "fi-FI",
27
 
"sv-SE", "sk-SK", "zh-TW", "tr-TR" );
28
 
var skins               = new Array( "classic" ); // "modern"
29
 
var prefs               = new Array( "flashblock.js" );
30
 
var components          = new Array(  );
31
 
var searchPlugins       = new Array(  );
32
 
 
33
 
// Mozilla Suite/Seamonkey stores all pref files in a single directory
34
 
// under the application directory.  If the name of the preference file(s)
35
 
// is/are not unique enough, you may override other extension preferences.
36
 
// set this to true if you need to prevent this.
37
 
var disambiguatePrefs   = false;
38
 
 
39
 
// Editable Items End
40
 
 
41
 
var jarName             = name + ".jar";
42
 
var jarFolder           = "content" + packageDir
43
 
var error               = null;
44
 
 
45
 
var folder              = getFolder("Profile", "chrome");
46
 
var prefFolder          = getFolder(getFolder("Program", "defaults"), "pref");
47
 
var compFolder          = getFolder("Components");
48
 
var searchFolder        = getFolder("Plugins");
49
 
 
50
 
var existsInApplication = File.exists(getFolder(getFolder("chrome"), jarName));
51
 
var existsInProfile     = File.exists(getFolder(folder, jarName));
52
 
 
53
 
var contentFlag         = CONTENT | PROFILE_CHROME;
54
 
var localeFlag          = LOCALE | PROFILE_CHROME;
55
 
var skinFlag            = SKIN | PROFILE_CHROME;
56
 
 
57
 
var APP_PLATFORM        = "";
58
 
var gPlatform           = getPlatform();
59
 
 
60
 
// If the extension exists in the application folder or it doesn't exist
61
 
// in the profile folder and the user doesn't want it installed to the
62
 
// profile folder
63
 
if(existsInApplication ||
64
 
    (!existsInProfile &&
65
 
      !confirm( "Do you want to install the " + displayName +
66
 
                " extension into your profile folder?\n" +
67
 
                "(Cancel will install into the application folder)")))
68
 
{
69
 
    contentFlag = CONTENT | DELAYED_CHROME;
70
 
    folder      = getFolder("chrome");
71
 
    localeFlag  = LOCALE | DELAYED_CHROME;
72
 
    skinFlag    = SKIN | DELAYED_CHROME;
73
 
}
74
 
 
75
 
initInstall(displayName, name, version);
76
 
setPackageFolder(folder);
77
 
error = addFile(name, version, "chrome/" + jarName, folder, null);
78
 
 
79
 
// If adding the JAR file succeeded
80
 
if(error == SUCCESS)
81
 
{
82
 
    folder = getFolder(folder, jarName);
83
 
 
84
 
    registerChrome(contentFlag, folder, jarFolder);
85
 
    for (var i = 0; i < locales.length; i++) {
86
 
        registerChrome(localeFlag, folder, "locale/" + locales[i] + localeDir);
87
 
    }
88
 
 
89
 
    for (var i = 0; i < skins.length; i++) {
90
 
        registerChrome(skinFlag, folder, "skin/" + skins[i] + skinDir);
91
 
    }
92
 
 
93
 
    for (var i = 0; i < prefs.length; i++) {
94
 
        if (!disambiguatePrefs) {
95
 
            addFile(name + " Defaults", version, "defaults/preferences/" + prefs[i],
96
 
                prefFolder, prefs[i], true);
97
 
        } else {
98
 
            addFile(name + " Defaults", version, "defaults/preferences/" + prefs[i],
99
 
                prefFolder, name + "-" + prefs[i], true);
100
 
        }
101
 
    }
102
 
 
103
 
    for (var i = 0; i < components.length; i++) {
104
 
        addFile(name + " Components", version, "components/" + components[i],
105
 
            compFolder, components[i], true);
106
 
    }
107
 
 
108
 
    for (var i = 0; i < searchPlugins.length; i++) {
109
 
        addFile(name + " searchPlugins", version, "searchplugins/" + searchPlugins[i],
110
 
            searchFolder, searchPlugins[i], true);
111
 
    }
112
 
 
113
 
    error = performInstall();
114
 
 
115
 
    // If the install failed
116
 
    if(error != SUCCESS && error != REBOOT_NEEDED)
117
 
    {
118
 
        displayError(error);
119
 
        cancelInstall(error);
120
 
    }
121
 
    else
122
 
    {
123
 
    msg = displayName + " " + version + " has been succesfully installed.\n"
124
 
          + "Flash objects will now be replaced with a button that you can click on to view them.\n\n"
125
 
          + "Please restart your browser to enable " + displayName + ".";
126
 
        alert(msg);
127
 
    }
128
 
}
129
 
else
130
 
{
131
 
    displayError(error);
132
 
        cancelInstall(error);
133
 
}
134
 
 
135
 
// Displays the error message to the user
136
 
function displayError(error)
137
 
{
138
 
    // If the error code was -215
139
 
    if(error == READ_ONLY)
140
 
    {
141
 
        alert("The installation of " + displayName +
142
 
            " failed.\nOne of the files being overwritten is read-only.");
143
 
    }
144
 
    // If the error code was -235
145
 
    else if(error == INSUFFICIENT_DISK_SPACE)
146
 
    {
147
 
        alert("The installation of " + displayName +
148
 
            " failed.\nThere is insufficient disk space.");
149
 
    }
150
 
    // If the error code was -239
151
 
    else if(error == CHROME_REGISTRY_ERROR)
152
 
    {
153
 
        alert("The installation of " + displayName +
154
 
            " failed.\nChrome registration failed.");
155
 
    }
156
 
    else
157
 
    {
158
 
        alert("The installation of " + displayName +
159
 
            " failed.\nThe error code is: " + error);
160
 
    }
161
 
}
162
 
 
163
 
function getPlatform() {
164
 
        var platformStr, platformNode;
165
 
 
166
 
        if ('platform' in Install) {
167
 
                platformStr = new String(Install.platform);
168
 
                APP_PLATFORM = platformStr;
169
 
                // Mac OS X (aka Darwin) is a real unix system
170
 
                if (!platformStr.search(/.*Darwin/))
171
 
                        platformNode = 'unix';
172
 
                else if (!platformStr.search(/^Macintosh/))
173
 
                        platformNode = 'mac';
174
 
                else if (!platformStr.search(/^Win/))
175
 
                        platformNode = 'win';
176
 
                else if (!platformStr.search(/^OS\/2/))
177
 
                        platformNode = 'win';
178
 
                else if (!platformStr.search(/unix|sun|linux/i))
179
 
                        platformNode = 'unix';
180
 
                else if (getFolder("Unix Lib") != null)
181
 
                        platformNode = 'unix';
182
 
                else
183
 
                        platformNode = 'unknown';
184
 
        }
185
 
        else
186
 
        {
187
 
                if (getFolder("Unix Lib") != null)
188
 
                        platformNode = 'unix';
189
 
                else if (getFolder("Mac System")!= null)
190
 
                        platformNode = 'mac';
191
 
                else if(getFolder("Win System")!= null)
192
 
                        platformNode = 'win';
193
 
                else
194
 
                        platformNode = 'unknown';
195
 
        }
196
 
        return platformNode;
197
 
}