source: trunk/thunderbird/funambol/dist/install.js @ 187

Last change on this file since 187 was 187, checked in by sebas, 15 years ago

unzipped

File size: 3.8 KB
Line 
1/*
2 * Copyright (C) 2003-2007 Funambol
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18
19var fnblInstaller = {
20
21        extFullName: 'Funambol Mozilla Sync Client', // The name displayed to the user (don't include the version)
22        extShortName: 'funambol', // The leafname of the JAR file (without the .jar part)
23    extVersion: '0.9.1',
24   
25        extAuthor: 'Carlo Codega',
26       
27        extPostInstallMessage: null, // Set to null for no post-install message
28       
29    profileInstall : true,
30    silentInstall  : false,
31 
32    install: function() {
33 
34                var jarName    = this.extShortName + '.jar';
35                var profileDir = Install.getFolder('Profile', 'chrome');
36                var globalDir  = Install.getFolder('Chrome');
37               
38                // Parse HTTP arguments
39                this.parseArguments();
40               
41                // Check if extension is already installed in profile
42                if (File.exists(Install.getFolder(profileDir, jarName))) {
43                   if (!this.silentInstall) {
44                          Install.alert('Updating existing Profile install of ' + 
45                                                        this.extFullName + ' to version ' + this.extVersion + '.');
46                   }
47                   this.profileInstall = true;
48                }
49                else if (!this.silentInstall) {
50                   // Ask user for install location, profile or browser dir?
51                   this.profileInstall = Install.confirm('Install ' + this.extFullName + ' ' + 
52                                                                 this.extVersion + ' to the Profile directory [OK] or ' +
53                                                                 'the Browser directory [Cancel]?');
54                }
55               
56                // Init install
57                var dispName = this.extFullName + ' ' + this.extVersion;
58                var regName  = '/' + this.extAuthor + '/' + this.extShortName;
59                Install.initInstall(dispName, regName, this.extVersion);
60               
61                // Find directory to install into
62                var installPath;
63                if (this.profileInstall) {
64                   installPath = profileDir;
65                }
66                else {
67                   installPath = globalDir;
68                }
69               
70                // Add JAR file
71                Install.addFile(null, 'chrome/' + jarName, installPath, null);
72               
73                // Register chrome
74                var jarPath = Install.getFolder(installPath, jarName);
75                var installType = (this.profileInstall ? Install.PROFILE_CHROME : Install.DELAYED_CHROME);
76               
77                // Register content
78                Install.registerChrome(Install.CONTENT | installType, jarPath, 
79                                                          'content/' + this.extShortName + '/');
80               
81                // Perform install
82                var err = Install.performInstall();
83                if (err == Install.SUCCESS || err == Install.REBOOT_NEEDED) {
84                   if (!this.silentInstall && this.extPostInstallMessage) {
85                          Install.alert('The ' + this.extFullName + ' ' + this.extVersion     + 
86                                                        ' extension has been ' + 'succesfully installed.\n\n' +
87                                                         jarPath + '\n\n' + this.extPostInstallMessage);
88                   }
89                }
90                else   {
91                   this.handleError(err);
92                   return;
93                }
94  },
95 
96  parseArguments: function()   {
97    // Can't use string handling in install, so use if statement instead
98    var args = Install.arguments;
99    if (args == 'p=0') {
100       this.profileInstall = false;
101       this.silentInstall = true;
102    }
103    else if (args == 'p=1')   {
104       this.profileInstall = true;
105       this.silentInstall = true;
106    }
107  },
108 
109  handleError: function(err)   {
110    if (!this.silentInstall) {
111       Install.alert('Error: Could not install ' + this.extFullName + ' ' + this.extVersion +
112                     ' (Error code: ' + err + ')');
113    }
114    Install.cancelInstall(err);
115  }
116};
117
118fnblInstaller.install();
119
120
121
122   
Note: See TracBrowser for help on using the repository browser.