home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2005 February / WN_129_CD.iso / Windows / Extensions Firefox / WebmailCompose / webmailcompose-0.5.7-fx+mz.xpi / install.js next >
Encoding:
Text File  |  2004-11-06  |  2.1 KB  |  55 lines

  1. /* ***************
  2. Desc: Installation script
  3. Author: Jed Brown (mozilla@jedbrown.net)
  4. ****************** */
  5. const author              = "Jed Brown";
  6. const displayName         = "WebmailCompose";
  7. const name                = "webmailcompose";
  8. const version             = "0.5.x";
  9. var contentFlag           = CONTENT | PROFILE_CHROME;
  10. var error                 = null;
  11. var folder                = getFolder("Profile", "chrome");
  12. var localeFlag            = LOCALE | PROFILE_CHROME;
  13. var skinFlag              = SKIN | PROFILE_CHROME;
  14. var jarName               = name + ".jar";
  15. var existsInApplication   = File.exists(getFolder(getFolder("chrome"), jarName));
  16. var existsInProfile       = File.exists(getFolder(folder, jarName));
  17. const SUCCESS_MESSAGE     = " has been Installed!";
  18.  
  19. initInstall(displayName, name, version);
  20.  
  21. // If the extension exists in the application folder or it doesn't exist in the profile folder and the user doesn't want it installed to the profile folder
  22. if(existsInApplication || (!existsInProfile && !confirm("Do you want to install the extension into your profile folder?\n(Cancel will install into the application folder)")))
  23. {
  24.     contentFlag = CONTENT | DELAYED_CHROME;
  25.     folder      = getFolder("chrome");
  26.     skinFlag    = SKIN | DELAYED_CHROME;
  27. }
  28.  
  29. setPackageFolder(folder);
  30. error = addFile(author, version, 'chrome/' + jarName, folder, null);
  31. // If adding the JAR file succeeded
  32. if(error == SUCCESS)
  33. {
  34.     folder = getFolder(folder, jarName);
  35.     registerChrome(contentFlag, folder, "content/webmailcompose/");
  36.     registerChrome(skinFlag, folder, "skin/classic/webmailcompose/");
  37.  
  38.     error = performInstall();
  39.  
  40.     // If the install failed
  41.     if(error == SUCCESS || error == 999)
  42.     {
  43.       alert(displayName+" "+version+" has been succesfully installed.\n"+displayName + SUCCESS_MESSAGE);
  44.     }else{
  45.       alert("Install failed. Error code:" + error);
  46.       cancelInstall(error);
  47.     }
  48. }
  49. else
  50. {
  51.     alert("The installation of the extension failed.\n" + error + "\n Failed to create " +jarName+ " \n"
  52.           +"Make sure you have the correct permissions");
  53.     cancelInstall(error);
  54. }
  55.