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

« back to all changes in this revision

Viewing changes to install.js

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-04-09 13:10:00 UTC
  • Revision ID: james.westby@ubuntu.com-20080409131000-5wd25isw94ithgp8
Tags: upstream-1.3.9a
ImportĀ upstreamĀ versionĀ 1.3.9a

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
const APP_DISPLAY_NAME = "Flashblock";
 
2
const APP_NAME = "flashblock";
 
3
const APP_PACKAGE = "/Ted Mielczarek,Ted Drake/flashblock";
 
4
const APP_VERSION = "1.3.9a";
 
5
const APP_DEFAULTS = "Flashblock Defaults";
 
6
 
 
7
const APP_JAR_FILE = "flashblock.jar";
 
8
const APP_CONTENT_FOLDER = "content/flashblock/";
 
9
const APP_SKIN_FOLDER = "skin/classic/flashblock/";
 
10
 
 
11
const APP_SUCCESS_MESSAGE = "Flash objects will now be replaced with a button that you can click on to view them.\n\n";
 
12
 
 
13
var   APP_PLATFORM = ""
 
14
 
 
15
var contentFlag = CONTENT | PROFILE_CHROME;
 
16
var localeFlag  = LOCALE | PROFILE_CHROME;
 
17
var skinFlag    = SKIN | PROFILE_CHROME;
 
18
 
 
19
var locales = [
 
20
"en-US", "it-IT", "nl-NL", "de-DE", "fr-FR", "pl-PL", "ko-KR", "pt-BR",
 
21
"da-DK", "hu-HU", "cs-CZ", "es-ES", "ru-RU", "ro-RO", "de-AT", "ja-JP",
 
22
"zh-CN", "ar-YE", "ar-JO", "fi-FI", "sv-SE", "sk-SK", "zh-TW", "tr-TR",
 
23
"el-GR", "bg-BG", "te-IN", "ca-ES","is-IS"]
 
24
 
 
25
// start it all up
 
26
initInstall(APP_NAME, APP_PACKAGE, APP_VERSION);
 
27
 
 
28
// get user's profile chrome directory
 
29
var chromef = getFolder("Profile", "chrome");
 
30
var prefDir = getFolder("Program", "defaults/pref")
 
31
// add jar file
 
32
var err = addFile(APP_PACKAGE, APP_VERSION, "chrome/" + APP_JAR_FILE, chromef, null, true);
 
33
if(err == SUCCESS) {
 
34
        err = addFile(APP_DEFAULTS, APP_VERSION, "defaults/preferences/flashblock.js", prefDir, "flashblock.js", true);
 
35
// on unixy platforms, global defaults directory is not writable! Ignore this error!
 
36
        if(err == ACCESS_DENIED || err == READ_ONLY) {
 
37
                err = SUCCESS;
 
38
        }
 
39
}
 
40
 
 
41
if(err == SUCCESS) {
 
42
        var jar = getFolder(chromef, APP_JAR_FILE);
 
43
        registerChrome(contentFlag, jar, APP_CONTENT_FOLDER);
 
44
        registerChrome(skinFlag   , jar, APP_SKIN_FOLDER);
 
45
        for (var i = 0; i < locales.length; i++) {
 
46
                registerChrome(localeFlag, jar, "locale/" + locales[i] + "/"+APP_NAME+"/"  );
 
47
        }
 
48
 
 
49
        err = performInstall();
 
50
        if(err == SUCCESS || err == REBOOT_NEEDED) {
 
51
            var gPlatform = getPlatform();
 
52
                alert("Debug: We think your OS is: " + APP_PLATFORM);
 
53
                if(gPlatform == 'unix') {
 
54
//                      var uxerr = setUnixPermissions();
 
55
//                      alert("Debug: setUnixPermissions returned with: " + uxerr);
 
56
                };
 
57
                msg = APP_NAME + " " + APP_VERSION + " has been succesfully installed.\n"
 
58
                        +APP_SUCCESS_MESSAGE
 
59
                        +"Please restart your browser to enable flashblock.";
 
60
                alert(msg);
 
61
        }
 
62
        else if(err == CHROME_REGISTRY_ERROR) {
 
63
                msg = "Install failed. There was a Chrome Registry Error: " + err
 
64
                        + ".\nPlease restart Mozilla and try installing "
 
65
                        + APP_DISPLAY_NAME + " again.";
 
66
                alert(msg);
 
67
                resetError();
 
68
                cancelInstall(err);
 
69
        }
 
70
        else {
 
71
                alert("Install failed. Could not performInstall. Error code:" + err);
 
72
                cancelInstall(err);
 
73
        }
 
74
}
 
75
else {
 
76
        alert("Install failed. Could not addFile: " + APP_JAR_FILE + ". Error code:" + err);
 
77
        cancelInstall(err);
 
78
}
 
79
 
 
80
function getPlatform() {
 
81
        var platformStr, platformNode;
 
82
 
 
83
        if ('platform' in Install) {
 
84
                platformStr = new String(Install.platform);
 
85
                APP_PLATFORM = platformStr;
 
86
                // Mac OS X (aka Darwin) is a real unix system
 
87
                if (!platformStr.search(/.*Darwin/))
 
88
                        platformNode = 'unix';
 
89
                else if (!platformStr.search(/^Macintosh/))
 
90
                        platformNode = 'mac';
 
91
                else if (!platformStr.search(/^Win/))
 
92
                        platformNode = 'win';
 
93
                else if (!platformStr.search(/^OS\/2/))
 
94
                        platformNode = 'win';
 
95
                else if (!platformStr.search(/unix|sun|linux/i))
 
96
                        platformNode = 'unix';
 
97
                else if (getFolder("Unix Lib") != null)
 
98
                        platformNode = 'unix';
 
99
                else
 
100
                        platformNode = 'unknown';
 
101
        }
 
102
        else
 
103
        {
 
104
                if (getFolder("Unix Lib") != null)
 
105
                        platformNode = 'unix';
 
106
                else if (getFolder("Mac System")!= null)
 
107
                        platformNode = 'mac';
 
108
                else if(getFolder("Win System")!= null)
 
109
                        platformNode = 'win';
 
110
                else
 
111
                        platformNode = 'unknown';
 
112
        }
 
113
        return platformNode;
 
114
}
 
115
 
 
116
function setUnixPermissions() {
 
117
        initInstall(APP_NAME, APP_PACKAGE, APP_VERSION);
 
118
        var err, cmdPath;
 
119
        var chromeF = getFolder(getFolder("Profile", "chrome"), APP_JAR_FILE);
 
120
        var cmdArgs = "u+rwx,go+r ";
 
121
 
 
122
        alert("Debug: The next step will try to set unix permissions");
 
123
 
 
124
        cmdPath = chromeF;
 
125
        if (!File.isFile(cmdPath)) {
 
126
                alert("Cannot find :" + cmdPath);
 
127
                return DOES_NOT_EXIST;
 
128
        } ;
 
129
 
 
130
        cmdPath = getFolder("OS Drive");
 
131
        if (!File.isDirectory(cmdPath)) {
 
132
                alert("Cannot find OS Drive :" + cmdPath);
 
133
                return DOES_NOT_EXIST;
 
134
        } ;
 
135
 
 
136
        cmdPath = getFolder(cmdPath, "bin");
 
137
        if (!File.isDirectory(cmdPath)) {
 
138
                alert("Cannot find bin directory:" + cmdPath);
 
139
                return DOES_NOT_EXIST;
 
140
        } ;
 
141
 
 
142
        cmdPath = getFolder(cmdPath, "chmod");
 
143
        if (!File.isFile(cmdPath)) {
 
144
                alert("Cannot find chmod:" + cmdPath);
 
145
                return DOES_NOT_EXIST;
 
146
        } ;
 
147
 
 
148
        cmdArgs = cmdArgs + chromeF;
 
149
alert( "Will perform chmod");
 
150
        try {
 
151
        err = File.execute(cmdPath, cmdArgs );
 
152
        } catch(e) { alert("Error executing chmod: " + e) };
 
153
        if (err != SUCCESS) {
 
154
                alert("chmod didn't work, Error :" + err + " " + cmdPath + " " + cmdArgs);
 
155
//              return err;
 
156
        } ;
 
157
 
 
158
alert( "Will performInstall on setUnixPermissions");
 
159
        err = performInstall();
 
160
        if(err != SUCCESS) {
 
161
                alert("setUnixpermissions Error: "+ err + " " + cmdPath + " " + CmdArgs);
 
162
        }
 
163
        return err;
 
164
}
 
 
b'\\ No newline at end of file'