home *** CD-ROM | disk | FTP | other *** search
/ Freelog 52 / Freelog052.iso / Extra / Internet / Mozilla / mozilla-l10n-fr-FR-1.4-1.xpi / install.js next >
Text File  |  2003-08-13  |  15KB  |  449 lines

  1. // ***** BEGIN LICENSE BLOCK *****
  2. // Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. //
  4. // The contents of this file are subject to the Mozilla Public License Version
  5. // 1.1 (the "License"); you may not use this file except in compliance with
  6. // the License. You may obtain a copy of the License at
  7. // http://www.mozilla.org/MPL/
  8. //
  9. // Software distributed under the License is distributed on an "AS IS" basis,
  10. // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. // for the specific language governing rights and limitations under the
  12. // License.
  13. //
  14. // The Original Code is mozilla.org code.
  15. //
  16. // The Initial Developer of the Original Code is
  17. // the Mozilla Organization.
  18. // Portions created by the Initial Developer are Copyright (C) 1998-2002
  19. // the Initial Developer. All Rights Reserved.
  20. //
  21. // Contributor(s):
  22. //   Robert Kaiser <KaiRo@KaiRo.at>
  23. //   Nagarjuna Venna (vnagarjuna@yahoo.com)
  24. //
  25. // Alternatively, the contents of this file may be used under the terms of
  26. // either the GNU General Public License Version 2 or later (the "GPL"), or
  27. // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. // in which case the provisions of the GPL or the LGPL are applicable instead
  29. // of those above. If you wish to allow use of your version of this file only
  30. // under the terms of either the GPL or the LGPL, and not to allow others to
  31. // use your version of this file under the terms of the MPL, indicate your
  32. // decision by deleting the provisions above and replace them with the notice
  33. // and other provisions required by the GPL or the LGPL. If you do not delete
  34. // the provisions above, a recipient may use your version of this file under
  35. // the terms of any one of the MPL, the GPL or the LGPL.
  36. //
  37. // ***** END LICENSE BLOCK *****
  38.  
  39.  
  40. // --- strings specific to that single Language Pack ---
  41. var prettyName = "Fran\u00e7ais";
  42. var langcode = "fr";
  43. var regioncode = "FR";
  44. var version = "1.4";
  45. // --- end pack-specific strings ---
  46.  
  47.  
  48. // this function verifies disk space in kilobytes
  49. function verifyDiskSpace(dirPath, spaceRequired) {
  50.   var spaceAvailable;
  51.  
  52.   // Get the available disk space on the given path
  53.   spaceAvailable = fileGetDiskSpaceAvailable(dirPath);
  54.  
  55.   // Convert the available disk space into kilobytes
  56.   spaceAvailable = parseInt(spaceAvailable / 1024);
  57.  
  58.   // do the verification
  59.   if(spaceAvailable < spaceRequired) {
  60.     logComment("Espace disque insuffisant : " + dirPath);
  61.     logComment("  requis : " + spaceRequired + " Ko");
  62.     logComment("  disponible : " + spaceAvailable + " Ko");
  63.     return(false);
  64.   }
  65.  
  66.   return(true);
  67. }
  68.  
  69. // this function converts an error number to the error code
  70. function ErrCode(errornum)
  71. {
  72.     if (errornum == 0)  {
  73.         errorstring = "SUCCESS";
  74.     }
  75.     else if (errornum == -200)  {
  76.         errorstring = "BAD_PACKAGE_NAME";
  77.     }
  78.     else if (errornum == -201) {
  79.         errorstring = "UNEXPECTED_ERROR";
  80.     }
  81.     else if (errornum == -202) {
  82.         errorstring = "ACCESS_DENIED";
  83.     }
  84.     else if (errornum == -203) {
  85.         errorstring = "TOO_MANY_CERTIFICATES";
  86.     }
  87.     else if (errornum == -204) {
  88.         errorstring = "NO_INSTALL_SCRIPT";
  89.     }
  90.     else if (errornum == -205) {
  91.         errorstring = "NO_CERTIFICATE";
  92.     }
  93.     else if (errornum == -206) {
  94.         errorstring = "NO_MATCHING_CERTIFICATE";
  95.     }
  96.     else if (errornum == -207) {
  97.         errorstring = "CANT_READ_ARCHIVE";
  98.     }
  99.     else if (errornum == -208) {
  100.         errorstring = "INVALID_ARGUMENTS";
  101.     }
  102.     else if (errornum == -209) {
  103.         errorstring = "ILLEGAL_RELATIVE_PATH";
  104.     }
  105.     else if (errornum == -210) {
  106.         errorstring = "USER_CANCELLED";
  107.     }
  108.     else if (errornum == -211) {
  109.         errorstring = "INSTALL_NOT_STARTED";
  110.     }
  111.     else if (errornum == -212) {
  112.         errorstring = "SILENT_MODE_DENIED";
  113.     }
  114.     else if (errornum == -213) {
  115.         errorstring = "NO_SUCH_COMPONENT";
  116.     }
  117.     else if (errornum == -214) {
  118.         errorstring = "DOES_NOT_EXIST";
  119.     }
  120.     else if (errornum == -215) {
  121.         errorstring = "READ_ONLY";
  122.     }
  123.     else if (errornum == -216) {
  124.         errorstring = "IS_DIRECTORY";
  125.     }
  126.     else if (errornum == -217) {
  127.         errorstring = "NETWORK_FILE_IS_IN_USE";
  128.     }
  129.     else if (errornum == -218) {
  130.         errorstring = "APPLE_SINGLE_ERR";
  131.     }
  132.     else if (errornum == -219) {
  133.         errorstring = "INVALID_PATH_ERR";
  134.     }
  135.     else if (errornum == -220) {
  136.         errorstring = "PATCH_BAD_DIFF";
  137.     }
  138.     else if (errornum == -221) {
  139.         errorstring = "PATCH_BAD_CHECKSUM_TARGET";
  140.     }
  141.     else if (errornum == -222) {
  142.         errorstring = "PATCH_BAD_CHECKSUM_RESULT";
  143.     }
  144.     else if (errornum == -223) {
  145.         errorstring = "UNINSTALL_FAILED";
  146.     }
  147.     else if (errornum == -224) {
  148.         errorstring = "PACKAGE_FOLDER_NOT_SET";
  149.     }
  150.     else if (errornum == -225) {
  151.         errorstring = "EXTRACTION_FAILED";
  152.     }
  153.     else if (errornum == -226) {
  154.         errorstring = "FILENAME_ALREADY_USED";
  155.     }
  156.     else if (errornum == -227) {
  157.         errorstring = "INSTALL_CANCELLED";
  158.     }
  159.     else if (errornum == -228) {
  160.         errorstring = "DOWNLOAD_ERROR";
  161.     }
  162.     else if (errornum == -229) {
  163.         errorstring = "SCRIPT_ERROR";
  164.     }
  165.     else if (errornum == -230) {
  166.         errorstring = "ALREADY_EXISTS";
  167.     }
  168.     else if (errornum == -231) {
  169.         errorstring = "IS_FILE";
  170.     }
  171.     else if (errornum == -232) {
  172.         errorstring = "SOURCE_DOES_NOT_EXIST";
  173.     }
  174.     else if (errornum == -233) {
  175.         errorstring = "SOURCE_IS_DIRECTORY";
  176.     }
  177.     else if (errornum == -234) {
  178.         errorstring = "SOURCE_IS_FILE";
  179.     }
  180.     else if (errornum == -235) {
  181.         errorstring = "INSUFFICIENT_DISK_SPACE";
  182.     }
  183.     else if (errornum == -236) {
  184.         errorstring = "FILENAME_TOO_LONG";
  185.     }
  186.     else if (errornum == -237) {
  187.         errorstring = "UNABLE_TO_LOCATE_LIB_FUNCTION";
  188.     }
  189.     else if (errornum == -238) {
  190.         errorstring = "UNABLE_TO_LOAD_LIBRARY";
  191.     }
  192.     else if (errornum == -239) {
  193.         errorstring = "CHROME_REGISTRY_ERROR";
  194.     }
  195.     else if (errornum == -240) {
  196.         errorstring = "MALFORMED_INSTALL";
  197.     }
  198.     else if (errornum == -299) {
  199.         errorstring = "OUT_OF_MEMORY";
  200.     }
  201.     else if (errornum == 999) {
  202.         errorstring = "REBOOT_NEEDED";
  203.     }
  204.     else if (errornum == -5550) {
  205.         errorstring = "GESTALT_UNKNOWN_ERROR";
  206.     }
  207.     else if (errornum == -5551) {
  208.         errorstring = "GESTALT_INVALID_ARGUMENT";
  209.     }
  210.     else {
  211.         errorstring = "Erreur #" + errornum;
  212.     }
  213.  
  214.     return(errorstring);
  215. }
  216.  
  217. // this function converts an error number to a string with code and number
  218. function ErrWithCode(err)
  219. {
  220.   return(err + " (" + ErrCode(err) + ")");
  221. }
  222.  
  223. // OS type detection - which platform?
  224. function getPlatform() {
  225.   var platformStr;
  226.   var platformNode;
  227.  
  228.   if('platform' in Install) {
  229.     platformStr = new String(Install.platform);
  230.  
  231.     if (!platformStr.search(/^Macintosh/))
  232.       platformNode = 'mac';
  233.     else if (!platformStr.search(/^Win/))
  234.       platformNode = 'win';
  235.     else if (!platformStr.search(/^OS\/2/))
  236.       platformNode = 'win';
  237.     else
  238.       platformNode = 'unix';
  239.   }
  240.   else {
  241.     var fOSMac  = getFolder("Mac System");
  242.     var fOSWin  = getFolder("Win System");
  243.  
  244.     logComment("fOSMac: "  + fOSMac);
  245.     logComment("fOSWin: "  + fOSWin);
  246.  
  247.     if(fOSMac != null)
  248.       platformNode = 'mac';
  249.     else if(fOSWin != null)
  250.       platformNode = 'win';
  251.     else
  252.       platformNode = 'unix';
  253.   }
  254.  
  255.   return platformNode;
  256. }
  257.  
  258. // *** start main install routine ***
  259.  
  260. var srDest = 2900;
  261. var err;
  262. var fProgram;
  263. var platformNode;
  264. var profileInstall = 0;
  265. var alertstring;
  266.  
  267. platformNode = getPlatform();
  268. logComment("Installation d'un pack de langue: type de la plateforme d\u00e9tect\u00e9 comme \u00e9tant: " + platformNode);
  269.  
  270. var chromeNode = langcode + "-" + regioncode;
  271. var regName    = "locales/mozilla/" + chromeNode;
  272. var chromeName = chromeNode + ".jar";
  273. var regionFile = regioncode + ".jar";
  274. var platformName = langcode + "-" + platformNode + ".jar";
  275. var localeName = "locale/" + chromeNode + "/";
  276. var regionName = "locale/" + regioncode + "/";
  277.  
  278. err = initInstall(prettyName, regName, version); 
  279. logComment("initInstall: " + ErrWithCode(err));
  280.  
  281. var messages = loadResources("install.properties");
  282.  
  283. fProgram = getFolder("Program");
  284. logComment("fProgram: " + fProgram);
  285.  
  286. // searchplugins directory detection
  287. if (platformNode == 'mac') {
  288.   fSearchPlugins = getFolder("Program", "Search Plugins");
  289. }
  290. else {
  291.   fSearchPlugins = getFolder("Program", "searchplugins");
  292. }
  293. logComment("fSearchPlugins: " + fSearchPlugins);
  294.  
  295. if ((err == 0) && verifyDiskSpace(fProgram, srDest)) {
  296.   // install search plugins first
  297.   err = addDirectory("", "bin/searchplugins", fSearchPlugins, "");
  298.   logComment("addDirectory() pour searchplugins a retourn\u00e9 : " + ErrWithCode(err));
  299.   resetError();
  300.  
  301.   var chromeType = LOCALE;
  302.   var tellRestart = 0;
  303. // well, just try to do it right (tm) on unix as well for Mozilla 1.3 !!!  
  304. //  if (platformNode == 'unix') {
  305.     // DELAYED_CHROME is still needed on many unix systems for bug 109044; this needs a Mozilla restart!
  306. //    logComment("d\u00e9tected un syst\u00e8me unix : utilise DELAYED_CHROME pour registerChrome d\u00fb au bug 109044");
  307. //    chromeType |= DELAYED_CHROME;
  308. //    tellRestart = 1;
  309. //  }
  310.   err = addDirectory("", "bin/chrome", fProgram, "chrome");
  311.   logComment("addDirectory() pour chrome a retourn\u00e9 : " + ErrWithCode(err));
  312.   err = addDirectory("", "bin/defaults", fProgram, "defaults");
  313.   logComment("addDirectory() pour defaults a retourn\u00e9 : " + ErrWithCode(err));
  314.  
  315.   if (err != 0) {
  316.     // return value 0 is SUCCESS
  317.     logComment("addDirectory() pour " + fProgram + " a \u00e9chou\u00e9!");
  318.  
  319. // well, just try to do it right (tm) on unix as well for Mozilla 1.3 !!!  
  320. //    if (platformNode != 'unix') {
  321.       // couldn't install globally, try installing to the profile (does only install chrome part, no defaults, no searchplugins)
  322.       // does not work with DELAYED_CHROME !!! (see comment above - bug 109044)
  323.       resetError();
  324.       chromeType |= PROFILE_CHROME;
  325.       profileInstall = 1;
  326.       fProgram = getFolder("Profile");
  327.       logComment("essaie l'installation dans le profil de l'utilisateur : " + fProgram);
  328.       err = addDirectory("", "bin/chrome", fProgram, "chrome");
  329.       logComment("addDirectory() pour le profil chrome a return\u00e9 : " + ErrWithCode(err));
  330. //    }
  331. //    else {
  332. //      logComment("ne peut pas utiliser le profil de l'utilisateur \u00e0 cause du bug 109044");
  333. //    }
  334.   }
  335.  
  336.   setPackageFolder(fProgram);
  337.  
  338.   // check return value: 0 is SUCCESS, 999 is REBOOT_NEEDED
  339.   if ((err == 0) || (err == 999)) {
  340.     var tellReboot = 0;
  341.     if (err == 999) {
  342.       if (platformNode == 'win') {
  343.         tellRestart = 1;
  344.       }
  345.       else {
  346.         tellReboot = 1;
  347.       }
  348.       resetError();
  349.     }
  350.     // register chrome
  351.     var cf = getFolder(fProgram, "chrome/"+chromeName);
  352.     var pf = getFolder(fProgram, "chrome/"+platformName);
  353.     var rf = getFolder(fProgram, "chrome/"+regionFile);
  354.  
  355.     registerChrome(chromeType, cf, localeName + "autoconfig/");
  356.     registerChrome(chromeType, cf, localeName + "chatzilla/");
  357.     registerChrome(chromeType, cf, localeName + "communicator/");
  358.     registerChrome(chromeType, cf, localeName + "content-packs/");
  359.     registerChrome(chromeType, cf, localeName + "cookie/");
  360.     registerChrome(chromeType, cf, localeName + "editor/");
  361.     registerChrome(chromeType, cf, localeName + "global/");
  362.     registerChrome(chromeType, cf, localeName + "help/");
  363.     registerChrome(chromeType, cf, localeName + "inspector/");
  364.     registerChrome(chromeType, cf, localeName + "messenger/");
  365.     registerChrome(chromeType, cf, localeName + "messenger-mdn/");
  366.     registerChrome(chromeType, cf, localeName + "messenger-smime/");
  367.     registerChrome(chromeType, cf, localeName + "mozldap/");
  368.     registerChrome(chromeType, cf, localeName + "navigator/");
  369.     registerChrome(chromeType, cf, localeName + "necko/");
  370.     registerChrome(chromeType, cf, localeName + "p3p/");
  371.     registerChrome(chromeType, cf, localeName + "pipnss/");
  372.     registerChrome(chromeType, cf, localeName + "pippki/");
  373.     registerChrome(chromeType, cf, localeName + "venkman/");
  374.     registerChrome(chromeType, cf, localeName + "wallet/");
  375.  
  376.     registerChrome(chromeType, pf, localeName + "communicator-platform/");
  377.     registerChrome(chromeType, pf, localeName + "global-platform/");
  378.     registerChrome(chromeType, pf, localeName + "navigator-platform/");
  379.  
  380.     if (platformNode == 'win') {
  381.       registerChrome(chromeType, pf, localeName + "messenger-mapi/");
  382.     }
  383.  
  384.     registerChrome(chromeType, rf, regionName + "communicator-region/");
  385.     registerChrome(chromeType, rf, regionName + "editor-region/");
  386.     registerChrome(chromeType, rf, regionName + "global-region/");
  387.     registerChrome(chromeType, rf, regionName + "messenger-region/");
  388.     registerChrome(chromeType, rf, regionName + "navigator-region/");
  389.  
  390.     err = performInstall(); 
  391.     logComment("performInstall() a return\u00e9 : " + ErrWithCode(err));
  392.     if (err == 999) {
  393.       if (platformNode == 'win') {
  394.         tellRestart = 1;
  395.       }
  396.       else {
  397.         tellReboot = 1;
  398.       }
  399.       resetError(); err = 0;
  400.     }
  401.     if (err == 0) {
  402.       if (profileInstall == 1) {
  403.         alertstring = messages.install_successprofile;
  404.       }
  405.       else {
  406.         alertstring = messages.install_successglobal;
  407.       }
  408.       if (tellReboot == 1) {
  409.         alertstring = alertstring + "\n\n" + messages.tell_reboot;
  410.         logComment("REBOOT_NEEDED (999): avertir l'utilisateur qu'il doit red\u00e9marrer son syst\u00e8me.");
  411.         cancelInstall(REBOOT_NEEDED);
  412.       }
  413.       else {
  414.         if (tellRestart == 1) {
  415.           alertstring = alertstring + "\n\n" + messages.tell_restart;
  416.           logComment("on utilisait DELAYED_CHROME: avertir l'utilisateur qu'il doit red\u00e9marrer Mozilla.");
  417.         }
  418.       }
  419.       alertstring = alertstring + "\n\n" + messages.howto_switch;
  420.     }
  421.     else {
  422.       alertstring = messages.install_failed + " " + ErrWithCode(err) + ".";
  423.       cancelInstall(err);
  424.     }
  425.   }
  426.   else {
  427.     cancelInstall(err);
  428.     logComment("cancelInstall d\u00fb \u00e0 l'erreur : " + ErrWithCode(err));
  429.     alertstring = messages.install_cancel + " " + ErrWithCode(err) + ".";
  430.     if ((err == -202) || (err == -215)) {
  431.       // -202 is ACCESS_DENIED, -215 is READ_ONLY
  432.       alertstring = alertstring + "\n\n" + messages.need_write_perm;
  433.       if (err == -202) {
  434.         logComment("ACCESS_DENIED (-202): avertir l'utilisateur qu'il n'a probablement pas les permissions en \u00e9criture \u00e0 chrome.");
  435.       }
  436.       else {
  437.         logComment("READ_ONLY (-215): avertir l'utilisateur qu'il n'a probablement pas les permissions en \u00e9criture \u00e0 chrome.");
  438.       }
  439.     }
  440.   }
  441.   alert(alertstring);
  442. }
  443. else {
  444.   if (err == 0)
  445.     cancelInstall(INSUFFICIENT_DISK_SPACE);
  446.   else
  447.     cancelInstall(err);
  448. }
  449.