⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nsupdateservice.js

📁 从国外的站点上淘的个人财务管理系统.开源.
💻 JS
📖 第 1 页 / 共 5 页
字号:
//@line 42 "/c/builds/1813/mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in"const PREF_APP_UPDATE_ENABLED             = "app.update.enabled";const PREF_APP_UPDATE_AUTO                = "app.update.auto";const PREF_APP_UPDATE_MODE                = "app.update.mode";const PREF_APP_UPDATE_SILENT              = "app.update.silent";const PREF_APP_UPDATE_INTERVAL            = "app.update.interval";const PREF_APP_UPDATE_TIMER               = "app.update.timer";const PREF_APP_UPDATE_LOG_BRANCH          = "app.update.log.";const PREF_APP_UPDATE_URL                 = "app.update.url";const PREF_APP_UPDATE_URL_OVERRIDE        = "app.update.url.override";const PREF_APP_UPDATE_URL_DETAILS         = "app.update.url.details";const PREF_APP_UPDATE_CHANNEL             = "app.update.channel";const PREF_APP_UPDATE_SHOW_INSTALLED_UI   = "app.update.showInstalledUI";const PREF_APP_UPDATE_LASTUPDATETIME_FMT  = "app.update.lastUpdateTime.%ID%";const PREF_APP_EXTENSIONS_VERSION         = "app.extensions.version";const PREF_GENERAL_USERAGENT_LOCALE       = "general.useragent.locale";const PREF_APP_UPDATE_INCOMPATIBLE_MODE   = "app.update.incompatible.mode";const PREF_UPDATE_NEVER_BRANCH            = "app.update.never."const PREF_PARTNER_BRANCH                 = "app.partner.";const URI_UPDATE_PROMPT_DIALOG  = "chrome://mozapps/content/update/updates.xul";const URI_UPDATE_HISTORY_DIALOG = "chrome://mozapps/content/update/history.xul";const URI_BRAND_PROPERTIES      = "chrome://branding/locale/brand.properties";const URI_UPDATES_PROPERTIES    = "chrome://mozapps/locale/update/updates.properties";const URI_UPDATE_NS             = "http://www.mozilla.org/2005/app-update";const KEY_APPDIR          = "XCurProcD";//@line 70 "/c/builds/1813/mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in"const KEY_LOCALDATA       = "DefProfLRt";const KEY_PROGRAMFILES    = "ProgF";const KEY_UAPPDATA        = "UAppData";//@line 74 "/c/builds/1813/mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in"const DIR_UPDATES         = "updates";const FILE_UPDATE_STATUS  = "update.status";const FILE_UPDATE_ARCHIVE = "update.mar";const FILE_UPDATE_LOG     = "update.log"const FILE_UPDATES_DB     = "updates.xml";const FILE_UPDATE_ACTIVE  = "active-update.xml";const FILE_PERMS_TEST     = "update.test";const FILE_LAST_LOG       = "last-update.log";const MODE_RDONLY   = 0x01;const MODE_WRONLY   = 0x02;const MODE_CREATE   = 0x08;const MODE_APPEND   = 0x10;const MODE_TRUNCATE = 0x20;const PERMS_FILE      = 0644;const PERMS_DIRECTORY = 0755;const STATE_NONE            = "null";const STATE_DOWNLOADING     = "downloading";const STATE_PENDING         = "pending";const STATE_APPLYING        = "applying";const STATE_SUCCEEDED       = "succeeded";const STATE_DOWNLOAD_FAILED = "download-failed";const STATE_FAILED          = "failed";// From updater/errors.h:const WRITE_ERROR = 7;const DOWNLOAD_CHUNK_SIZE           = 300000; // bytesconst DOWNLOAD_BACKGROUND_INTERVAL  = 600;    // secondsconst DOWNLOAD_FOREGROUND_INTERVAL  = 0;// Values for the PREF_APP_UPDATE_INCOMPATIBLE_MODE pref. See documentation in// code below. const INCOMPATIBLE_MODE_NEWVERSIONS   = 0;const INCOMPATIBLE_MODE_NONEWVERSIONS = 1;const POST_UPDATE_CONTRACTID = "@mozilla.org/updates/post-update;1";const nsILocalFile            = Components.interfaces.nsILocalFile;const nsIUpdateService        = Components.interfaces.nsIUpdateService;const nsIUpdateItem           = Components.interfaces.nsIUpdateItem;const nsIPrefLocalizedString  = Components.interfaces.nsIPrefLocalizedString;const nsIIncrementalDownload  = Components.interfaces.nsIIncrementalDownload;const nsIFileInputStream      = Components.interfaces.nsIFileInputStream;const nsIFileOutputStream     = Components.interfaces.nsIFileOutputStream;const nsICryptoHash           = Components.interfaces.nsICryptoHash;const Node = Components.interfaces.nsIDOMNode;var gApp        = null;var gPref       = null;var gABI        = null;var gOSVersion  = null;var gConsole    = null;var gLogEnabled = { };// shared code for suppressing bad cert dialogs//@line 40 "/c/builds/1813/mozilla/toolkit/mozapps/update/src/../../shared/src/badCertHandler.js"/** * Only allow built-in certs for HTTPS connections.  See bug 340198. */function checkCert(channel) {  if (!channel.originalURI.schemeIs("https"))  // bypass    return;  const Ci = Components.interfaces;    var cert =      channel.securityInfo.QueryInterface(Ci.nsISSLStatusProvider).      SSLStatus.QueryInterface(Ci.nsISSLStatus).serverCert;  var issuer = cert.issuer;  while (issuer && !cert.equals(issuer)) {    cert = issuer;    issuer = cert.issuer;  }  if (!issuer || issuer.tokenName != "Builtin Object Token")    throw "cert issuer is not built-in";}/** * This class implements nsIBadCertListener.  It's job is to prevent "bad cert" * security dialogs from being shown to the user.  It is better to simply fail * if the certificate is bad. See bug 304286. */function BadCertHandler() {}BadCertHandler.prototype = {  // nsIBadCertListener  confirmUnknownIssuer: function(socketInfo, cert, certAddType) {    LOG("EM BadCertHandler: Unknown issuer");    return false;  },  confirmMismatchDomain: function(socketInfo, targetURL, cert) {    LOG("EM BadCertHandler: Mismatched domain");    return false;  },  confirmCertExpired: function(socketInfo, cert) {    LOG("EM BadCertHandler: Expired certificate");    return false;  },  notifyCrlNextupdate: function(socketInfo, targetURL, cert) {  },  // nsIChannelEventSink  onChannelRedirect: function(oldChannel, newChannel, flags) {    // make sure the certificate of the old channel checks out before we follow    // a redirect from it.  See bug 340198.    checkCert(oldChannel);  },  // nsIInterfaceRequestor  getInterface: function(iid) {    if (iid.equals(Components.interfaces.nsIBadCertListener) ||        iid.equals(Components.interfaces.nsIChannelEventSink))      return this;    Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;    return null;  },  // nsISupports  QueryInterface: function(iid) {    if (!iid.equals(Components.interfaces.nsIBadCertListener) &&        !iid.equals(Components.interfaces.nsIChannelEventSink) &&        !iid.equals(Components.interfaces.nsIInterfaceRequestor) &&        !iid.equals(Components.interfaces.nsISupports))      throw Components.results.NS_ERROR_NO_INTERFACE;    return this;  }};//@line 135 "/c/builds/1813/mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in"/** * Logs a string to the error console.  * @param   string *          The string to write to the error console.. */  function LOG(module, string) {  if (module in gLogEnabled) {    dump("*** " + module + ": " + string + "\n");    gConsole.logStringMessage(string);  }}/** * Convert a string containing binary values to hex. */function binaryToHex(input) {  var result = "";  for (var i = 0; i < input.length; ++i) {    var hex = input.charCodeAt(i).toString(16);    if (hex.length == 1)      hex = "0" + hex;    result += hex;  }  return result;}/** * Gets a File URL spec for a nsIFile * @param   file *          The file to get a file URL spec to * @returns The file URL spec to the file */function getURLSpecFromFile(file) {  var ioServ = Components.classes["@mozilla.org/network/io-service;1"]                         .getService(Components.interfaces.nsIIOService);  var fph = ioServ.getProtocolHandler("file")                  .QueryInterface(Components.interfaces.nsIFileProtocolHandler);  return fph.getURLSpecFromFile(file);}/** * Gets the specified directory at the specified hierarchy under a  * Directory Service key.  * @param   key *          The Directory Service Key to start from * @param   pathArray *          An array of path components to locate beneath the directory  *          specified by |key| * @return  nsIFile object for the location specified. If the directory *          requested does not exist, it is created, along with any *          parent directories that need to be created. */function getDir(key, pathArray) {  return getDirInternal(key, pathArray, true, false);}/** * Gets the specified directory at the speciifed hierarchy under a  * Directory Service key.  * @param   key *          The Directory Service Key to start from * @param   pathArray *          An array of path components to locate beneath the directory  *          specified by |key| * @return  nsIFile object for the location specified. If the directory *          requested does not exist, it is NOT created. */function getDirNoCreate(key, pathArray) {  return getDirInternal(key, pathArray, false, false);}/** * Gets the specified directory at the specified hierarchy under the  * update root directory. * @param   pathArray *          An array of path components to locate beneath the directory  *          specified by |key| * @return  nsIFile object for the location specified. If the directory *          requested does not exist, it is created, along with any *          parent directories that need to be created. */function getUpdateDir(pathArray) {  return getDirInternal(KEY_APPDIR, pathArray, true, true);}/** * Gets the specified directory at the speciifed hierarchy under a  * Directory Service key.  * @param   key *          The Directory Service Key to start from * @param   pathArray *          An array of path components to locate beneath the directory  *          specified by |key| * @param   shouldCreate *          true if the directory hierarchy specified in |pathArray| *          should be created if it does not exist, *          false otherwise. * @param   update *          true if finding the update directory, *          false otherwise. * @return  nsIFile object for the location specified.  */function getDirInternal(key, pathArray, shouldCreate, update) {  var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]                              .getService(Components.interfaces.nsIProperties);  var dir = fileLocator.get(key, Components.interfaces.nsILocalFile);//@line 243 "/c/builds/1813/mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in"  if (update) {    // Fallback to previous behavior since getting ProgF    // (e.g. KEY_PROGRAMFILES) may fail on Win9x.    try {      var programFilesDir = fileLocator.get(KEY_PROGRAMFILES,          Components.interfaces.nsILocalFile);      if (programFilesDir.contains(dir, true)) {        var relativePath = dir.getRelativeDescriptor(programFilesDir);        var userLocalDir = fileLocator.get(KEY_LOCALDATA,            Components.interfaces.nsILocalFile).parent;        dir.setRelativeDescriptor(userLocalDir, relativePath);      }    }    catch (e) {}  }//@line 259 "/c/builds/1813/mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in"  for (var i = 0; i < pathArray.length; ++i) {    dir.append(pathArray[i]);    if (shouldCreate && !dir.exists())      dir.create(nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY);  }  return dir;}/** * Gets the file at the speciifed hierarchy under a Directory Service key. * @param   key *          The Directory Service Key to start from * @param   pathArray *          An array of path components to locate beneath the directory  *          specified by |key|. The last item in this array must be the *          leaf name of a file. * @return  nsIFile object for the file specified. The file is NOT created *          if it does not exist, however all required directories along  *          the way are. */function getFile(key, pathArray) {  var file = getDir(key, pathArray.slice(0, -1));  file.append(pathArray[pathArray.length - 1]);  return file;}/** * Gets the file at the speciifed hierarchy under the update root directory. * @param   pathArray *          An array of path components to locate beneath the directory  *          specified by |key|. The last item in this array must be the *          leaf name of a file. * @return  nsIFile object for the file specified. The file is NOT created *          if it does not exist, however all required directories along  *          the way are. */function getUpdateFile(pathArray) {  var file = getUpdateDir(pathArray.slice(0, -1));  file.append(pathArray[pathArray.length - 1]);  return file;}/** * Closes a Safe Output Stream * @param   fos *          The Safe Output Stream to close */function closeSafeOutputStream(fos) {  if (fos instanceof Components.interfaces.nsISafeOutputStream) {    try {      fos.finish();    }    catch (e) {      fos.close();    }  }  else    fos.close();}/** * Returns human readable status text from the updates.properties bundle * based on an error code * @param   code *          The error code to look up human readable status text for * @param   defaultCode *          The default code to look up should human readable status text *          not exist for |code| * @returns A human readable status text string */function getStatusTextFromCode(code, defaultCode) {  var sbs =       Components.classes["@mozilla.org/intl/stringbundle;1"].      getService(Components.interfaces.nsIStringBundleService);  var updateBundle = sbs.createBundle(URI_UPDATES_PROPERTIES);  var reason = updateBundle.GetStringFromName("checker_error-" + defaultCode);  try {    reason = updateBundle.GetStringFromName("checker_error-" + code);    LOG("General", "Transfer Error: " + reason + ", code: " + code);  }  catch (e) {    // Use the default reason    LOG("General", "Transfer Error: " + reason + ", code: " + defaultCode);  }  return reason;}/** * Get the Active Updates directory * @param   key *          The Directory Service Key (optional). *          If used, don't search local appdata on Win32 and don't create dir. * @returns The active updates directory, as a nsIFile object */function getUpdatesDir(key) {  // Right now, we only support downloading one patch at a time, so we always  // use the same target directory.  var fileLocator =      Components.classes["@mozilla.org/file/directory_service;1"].      getService(Components.interfaces.nsIProperties);  var appDir;  if (key)    appDir = fileLocator.get(key, Components.interfaces.nsILocalFile);  else {    appDir = fileLocator.get(KEY_APPDIR, Components.interfaces.nsILocalFile);//@line 365 "/c/builds/1813/mozilla/toolkit/mozapps/update/src/nsUpdateService.js.in"    // Fallback to previous behavior since getting ProgF    // (e.g. KEY_PROGRAMFILES) may fail on Win9x.    try {      var programFilesDir = fileLocator.get(KEY_PROGRAMFILES,          Components.interfaces.nsILocalFile);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -