bug 1428175 - follow-up to restrict max version to 56.* r=me
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */const{classes:Cc,interfaces:Ci,utils:Cu}=Components;Cu.import("resource://gre/modules/AddonManager.jsm");Cu.import("resource://gre/modules/Services.jsm");Cu.import("resource://gre/modules/osfile.jsm");constAPP_UPDATE_URL_PREF="app.update.url";constREPLACE_KEY="%OS_VERSION%";functioninstall(data,reason){if(!shouldHotfixApp()){uninstallHotfix(data);return;}AddonManager.getAddonByID(data.id,function(addon){// Enable on install in case the user disabled a prior hotfixaddon.userDisabled=false;});}functionstartup(data,reason){if(!shouldHotfixApp()){uninstallHotfix(data);return;}try{letwindir=Services.dirsvc.get("WinD",Ci.nsILocalFile).path;letfile1=OS.Path.join(windir,"System32\\qipcap.dll");letfile2=OS.Path.join(windir,"System32\\qipcap64.dll");letfile3=OS.Path.join(windir,"sysnative\\qipcap.dll");letfile4=OS.Path.join(windir,"sysnative\\qipcap64.dll");letexistPromises=[OS.File.exists(file1),OS.File.exists(file2),OS.File.exists(file3),OS.File.exists(file4)];// Update the app.update.url pref to include a special mark// telling whether any of those files are present or not.Promise.all(existPromises).then(results=>{letnewValue="(nowebsense)";if(results.some(value=>value==true)){newValue="(websense)";}letbranch=Services.prefs.getDefaultBranch("");letcurValue=branch.getCharPref(APP_UPDATE_URL_PREF);newValue=curValue.replace(REPLACE_KEY,REPLACE_KEY+newValue);branch.setCharPref(APP_UPDATE_URL_PREF,newValue);},reject=>{Cu.reportError("Hotfix unexpected error: "+reject);});}catch(ex){Cu.reportError(ex);}}functionshutdown(data,reason){}functionuninstall(data,reason){}/** * @return boolean whether the hotfix applies to the application. */functionshouldHotfixApp(){// Ensure that this is the correct version in case compatibility checking is overridden.if(Services.vc.compare(Services.appinfo.version,"39.0")<0||Services.vc.compare(Services.appinfo.version,"48.*")>0){returnfalse;}if(Services.appinfo.OS!="WINNT"){returnfalse;}returntrue;}functionuninstallHotfix(data){AddonManager.getAddonByID(data.id,function(addon){addon.uninstall();});}