Annotation of mailredirect/src/install.js.template, revision 1.9

1.1       krzesnia    1: 
                      2: // 1. Set parameters of package installation
                      3: const APP_DISPLAY_NAME = "Mail Redirect";
                      4: const APP_NAME = "mailredirect";
                      5: const APP_VERSION = "@VERSION@";
                      6: 
1.9     ! krzesnia    7: const supported_locales = ["en-US", "de-DE", "fr-FR", "it-IT", "sv-SE", "cs-CZ", "es-ES", "es-AR", "de-AT", "sk-SK", "pl-PL" ];
1.4       krzesnia    8: 
1.1       krzesnia    9: const APP_PACKAGE = "/" + APP_NAME;
                     10: const APP_JAR_FILE = APP_NAME + ".jar";
                     11: const APP_SKIN_JAR_FILE = APP_NAME + "-skin.jar";
                     12: const APP_SKIN_MOZ_JAR_FILE = APP_NAME + "-skin-moz.jar";
1.6       krzesnia   13: const APP_CONTENT_FOLDER = "content/";
1.4       krzesnia   14: const APP_LOCALE_FOLDER1 = "locale/";
1.6       krzesnia   15: const APP_SKIN_CLASSIC_FOLDER = "skin/classic/";
                     16: const APP_SKIN_MODERN_FOLDER = "skin/modern/";
1.1       krzesnia   17: 
                     18: 
                     19: 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 your application.\n(Click Cancel if you want "+APP_DISPLAY_NAME+" installing to the application directory.)";
                     20: 
                     21: 
                     22: // 2. Initialise package
                     23: initInstall(APP_NAME, APP_PACKAGE, APP_VERSION);
                     24: 
                     25: // Get package directories
                     26: // profile installs only work since 2003-03-06
1.3       krzesnia   27: var instToProfile = false;
1.4       krzesnia   28: var instToProfile = ((buildID>2003030600 || buildID==0000000000) && confirm(INST_TO_PROFILE));
1.1       krzesnia   29: var chromef = instToProfile ? getFolder("Profile", "chrome") : getFolder("chrome");
1.4       krzesnia   30: setPackageFolder(chromef);
1.1       krzesnia   31: 
                     32: // 2,5. mozilla or thunderbird?
                     33: var isTbird = false;
                     34: var execFile = 'thunderbird' + (getPlatform() == "win" ? '.exe' : '-bin');
                     35: if (File.exists(getFolder(getFolder('Program'), execFile))) {
                     36:   isTbird = confirm("Detected installation on Thunderbird. Is this correct?");
                     37: } else {
                     38:   isTbird = !confirm("Detected installation on Mozilla or Netscape. Is this correct?");
                     39: } 
                     40: 
                     41: // 3. Flag files/folders to be added
                     42: addFile("", "chrome/" + APP_JAR_FILE, chromef, "")
                     43: if (isTbird) { 
                     44:   addFile("", "chrome/" + APP_SKIN_JAR_FILE, chromef, "")
                     45: } else {
                     46:   addFile("", "chrome/" + APP_SKIN_MOZ_JAR_FILE, chromef, "")
                     47: }
                     48: 
                     49: err = getLastError();
                     50: 
                     51: // 3,5. add default prefs and don't care about errors
1.2       krzesnia   52: // var prefDir = getFolder("Program", "defaults/pref");
                     53: // addFile("", "defaults/preferences/mailredirect.js", prefDir, "");
1.1       krzesnia   54: 
                     55: 
                     56: if (err == SUCCESS) {
                     57: 
                     58:   // 4. Register chrome (this is what contents.rdf is used for)
                     59:   if(instToProfile) {
                     60:     registerChrome(CONTENT | PROFILE_CHROME, getFolder(chromef, APP_JAR_FILE), APP_CONTENT_FOLDER);
1.4       krzesnia   61:     for (var s in supported_locales) {
                     62:       registerChrome(LOCALE  | PROFILE_CHROME, getFolder(chromef, APP_JAR_FILE),
1.6       krzesnia   63:         APP_LOCALE_FOLDER1 + supported_locales[s] + "/");
1.4       krzesnia   64:     }
1.1       krzesnia   65:     if (isTbird) {
                     66:       registerChrome(SKIN    | PROFILE_CHROME, getFolder(chromef, APP_SKIN_JAR_FILE), APP_SKIN_CLASSIC_FOLDER);
                     67:     } else {
                     68:       registerChrome(SKIN    | PROFILE_CHROME, getFolder(chromef, APP_SKIN_MOZ_JAR_FILE), APP_SKIN_CLASSIC_FOLDER);
                     69:       registerChrome(SKIN    | PROFILE_CHROME, getFolder(chromef, APP_SKIN_MOZ_JAR_FILE), APP_SKIN_MODERN_FOLDER);
                     70:     }
                     71:   } else {
                     72:     registerChrome(CONTENT | DELAYED_CHROME, getFolder(chromef, APP_JAR_FILE), APP_CONTENT_FOLDER);
1.4       krzesnia   73:     for (var s in supported_locales) {
                     74:       registerChrome(LOCALE  | DELAYED_CHROME, getFolder(chromef, APP_JAR_FILE),
1.6       krzesnia   75:         APP_LOCALE_FOLDER1 + supported_locales[s] + "/");
1.4       krzesnia   76:     }
1.1       krzesnia   77:     if (isTbird) {
                     78:       registerChrome(SKIN    | DELAYED_CHROME, getFolder(chromef, APP_SKIN_JAR_FILE), APP_SKIN_CLASSIC_FOLDER);
                     79:     } else {
                     80:       registerChrome(SKIN    | DELAYED_CHROME, getFolder(chromef, APP_SKIN_MOZ_JAR_FILE), APP_SKIN_CLASSIC_FOLDER);
                     81:       registerChrome(SKIN    | DELAYED_CHROME, getFolder(chromef, APP_SKIN_MOZ_JAR_FILE), APP_SKIN_MODERN_FOLDER);
                     82:     }
                     83:   }
                     84: 
                     85:   // 5. Perform the installation
                     86:   err = performInstall();
                     87: 
                     88:   // 6. Report on success or otherwise  
                     89:   if(err == SUCCESS || err == 999) {
                     90:     refreshPlugins();
1.2       krzesnia   91:     alert(APP_DISPLAY_NAME+" "+APP_VERSION+" has been succesfully installed.\nYou need to restart Mozilla " + 
                     92:         (isTbird ? "Thunderbird " : "") + "first.");
1.1       krzesnia   93:   } else {
                     94:     alert("Install failed. Error code: " + err);
                     95:     cancelInstall(err);
                     96:   }
                     97: } else {
                     98:   alert("Failed to create JAR file.\n"
                     99:     +"You probably don't have appropriate permissions \n"
                    100:     +"(write access to your profile or chrome directory). \n"
                    101:     +"_____________________________\nError code:" + err);
                    102:   cancelInstall(err);
                    103: }
                    104: 
                    105: // OS type detection
                    106: // which platform?
                    107: function getPlatform() {
                    108:   var platformStr;
                    109:   var platformNode;
                    110: 
                    111:   if('platform' in Install) {
                    112:     platformStr = new String(Install.platform);
                    113: 
                    114:     if (!platformStr.search(/^Macintosh/))
                    115:       platformNode = 'mac';
                    116:     else if (!platformStr.search(/^Win/))
                    117:       platformNode = 'win';
                    118:     else
                    119:       platformNode = 'unix';
                    120:   } else {
                    121:     var fOSMac  = getFolder("Mac System");
                    122:     var fOSWin  = getFolder("Win System");
                    123: 
                    124:     logComment("fOSMac: "  + fOSMac);
                    125:     logComment("fOSWin: "  + fOSWin);
                    126: 
                    127:     if(fOSMac != null)
                    128:       platformNode = 'mac';
                    129:     else if(fOSWin != null)
                    130:       platformNode = 'win';
                    131:     else
                    132:       platformNode = 'unix';
                    133:   }
                    134: 
                    135:   return platformNode;
                    136: } 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>