File: //volume1/@appstore/AntiVirus/app/antivirus.js
/* Copyright (c) 2025 Synology Inc. All rights reserved. */
Ext.ns("SYNO.SDS.AV");SYNO.SDS.AV.ENGTYPE="ClamAV";SYNO.SDS.AV.AV_PIC_PREFIX="webman/3rdparty/AntiVirus/images/";Ext.define("SYNO.SDS.AV.Instance",{extend:"SYNO.SDS.AppInstance",appWindowName:"SYNO.SDS.AV.AVMainWindow",constructor:function(){this.callParent(arguments)}});Ext.define("SYNO.SDS.AV.AVMainWindow",{extend:"SYNO.SDS.PageListAppWindow",activePage:"SYNO.SDS.AV.AVPanelOverview",skipDirtyCheck:false,constructor:function(a){return this.callParent([Ext.apply({cls:this.getWindowClass(),resizable:true,maximizable:true,minimizable:true,minWidth:SYNO.SDS.AV.MAINWINDOW_DEFAULT_WIDTH,minHeight:SYNO.SDS.AV.MAINWINDOW_DEFAULT_HEIGHT,width:SYNO.SDS.AV.MAINWINDOW_DEFAULT_WIDTH,height:SYNO.SDS.AV.MAINWINDOW_DEFAULT_HEIGHT,listItems:[{text:_TT("SYNO.SDS.AV.Instance","ui","overview"),iconCls:"syno-av-list-overview",fn:"SYNO.SDS.AV.AVPanelOverview"},{text:_TT("SYNO.SDS.AV.Instance","ui","quarantine"),iconCls:"syno-av-list-quarantine",fn:"SYNO.SDS.AV.AVPanelQuarantine"},{text:_TT("SYNO.SDS.AV.Instance","ui","event_report"),iconCls:"syno-av-list-eventreport",fn:"SYNO.SDS.AV.AVPanelEventReport"},{text:_TT("SYNO.SDS.AV.Instance","ui","configuration"),iconCls:"syno-av-list-config",fn:"SYNO.SDS.AV.AVPanelConfig"},{text:_TT("SYNO.SDS.AV.Instance","ui","schedule_scan"),iconCls:"syno-av-list-schedulescan",fn:"SYNO.SDS.AV.AVPanelScheduleScan"},{text:_TT("SYNO.SDS.AV.Instance","ui","virus_code_update"),iconCls:"syno-av-list-viruscodeupdate",fn:"SYNO.SDS.AV.AVPanelVirusCodeUpdate"}]},a)])},getWindowClass:function(){if("ClamAV"==SYNO.SDS.AV.ENGTYPE||!SYNO.SDS.AV.ENGTYPE){return"syno-av syno-av-clam"}if("McAfee"==SYNO.SDS.AV.ENGTYPE||!SYNO.SDS.AV.ENGTYPE){return"syno-av syno-av-mcafee"}return"syno-av"},onBeforeSelect:function(b,c,d){if(!this.skipDirtyCheck){if(d&&d.leaf){var a=this.pageCt.getComponent(d.attributes.fn);if(a&&Ext.isFunction(a.isDirty)&&a.isDirty()){this.getMsgBox().confirm(_TT("SYNO.SDS.AV.Instance","app","app_name"),_T("common","confirm_lostchange"),function(e){if("yes"===e){this.skipDirtyCheck=true;this.selectPage(c.attributes.fn);this.skipDirtyCheck=false}},this);return false}}}if(c&&c.attributes){if("SYNO.SDS.AV.AVPanelOverview"===c.attributes.fn){this.getPageCt().addClass("syno-av-overview-background")}if((d&&d.attributes)&&("SYNO.SDS.AV.AVPanelOverview"===d.attributes.fn&&"SYNO.SDS.AV.AVPanelOverview"!==c.attributes.fn)){this.getPageCt().removeClass("syno-av-overview-background")}}return this.callParent(arguments)}});Ext.define("SYNO.SDS.AV.AVPanelOverview",{extend:"SYNO.ux.Panel",iconCSSClass:["syno-av-overview-icon-secure","syno-av-overview-icon-danger","syno-av-overview-icon-infected","syno-av-overview-icon-scanning","syno-av-overview-icon-preparing","syno-av-overview-icon-updating","syno-av-overview-icon-completed","syno-av-overview-icon-reprocessing","syno-av-overview-icon-update-failed","syno-av-overview-icon-installvirusdef","syno-av-overview-icon-licenseexpired","syno-av-overview-icon-licenseinvalid","syno-av-overview-icon-mydserror","syno-av-overview-icon-timeerror","syno-av-overview-icon-scan-pause","syno-av-overview-icon-prepare-pause","syno-av-overview-icon-scan-failed","syno-av-overview-icon-local-update-failed"],statusTitleCSSClass:["syno-av-overview-title-secure","syno-av-overview-title-danger","syno-av-overview-title-infected","syno-av-overview-title-scan","syno-av-overview-title-preparing","syno-av-overview-title-updating","syno-av-overview-title-completed","syno-av-overview-title-reprocessing","syno-av-overview-title-update-failed","syno-av-overview-title-installvirusdef","syno-av-overview-title-licenseexpired","syno-av-overview-title-licenseinvalid","syno-av-overview-title-mydserror","syno-av-overview-title-timeerror","syno-av-overview-title-scan-pause","syno-av-overview-title-prepare-pause","syno-av-overview-title-scan-failed","syno-av-overview-title-local-update-failed"],statusIndex:["secure","danger","infected","scanning","preparing","updating","completed","reprocessing","update_failed","installvirusdef","licenseexpired","licenseinvalid","mydserror","timeerror","scanning-pause","preparing-pause","scan_failed","local_update_failed"],pauseIconCSS:"syno-av-overview-pause-button",resumeIconCSS:"syno-av-overview-resume-button",pollOverviewId:null,scanTaskLaunched:false,constructor:function(a){this.app=a.appWin;var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){var b={border:false,itemId:"overview",layout:"vbox",layoutConfig:{pack:"start",align:"stretch"},items:[this.createStatusScanPanel(),this.createInformationPanel()]};return SYNO.LayoutConfig.fill(b)},createStatusScanPanel:function(){return{xtype:"syno_panel",cls:"syno-av-overview-status-scan-panel",id:this.stabtnbgId=Ext.id(),hideLabel:true,layout:"vbox",layoutConfig:{pack:"start",align:"stretch"},boxMinHeight:372,items:[this.createStatusPanel(),this.createScanPanel()]}},createStatusPanel:function(){return{xtype:"syno_panel",id:this.statusPanelId=Ext.id(),hideLabel:true,layout:"hbox",layoutConfig:{pack:"start"},border:false,boxMinHeight:140,items:[this.createIconPanel(),this.createTitleMessagePanel(),this.createStatusButtonPanel()]}},createIconPanel:function(){return{xtype:"syno_panel",itemId:"iconPanel",cls:"syno-av-overview-icon-panel",id:this.iconPanelID=Ext.id(),hideLabel:true,margins:"30 20 0 24",border:false,height:48,width:48}},createTitleMessagePanel:function(){return{xtype:"syno_panel",id:this.statusMsgPanelId=Ext.id(),hideLabel:true,layout:"vbox",layoutConfig:{align:"stretch",pack:"start"},border:false,margins:"30 0 0 0",flex:1,boxMinHeight:112,items:[{xtype:"syno_displayfield",id:this.statusTitleID=Ext.id(),height:28,style:"padding: 0;line-height: 32px",margins:"0 0 4 0",value:_TT("SYNO.SDS.AV.Instance","overview","loading_status")},{xtype:"syno_displayfield",id:this.statusSubTitleID=Ext.id(),boxMinHeight:20,cls:"syno-av-overview-status-message",style:"padding: 0",value:""},{xtype:"syno_displayfield",id:this.statusMessageID=Ext.id(),htmlEncode:false,cls:"syno-av-overview-status-message",boxMinHeight:60,style:"padding: 0",value:""}]}},createStatusButtonPanel:function(){return{xtype:"syno_panel",id:this.statusBtnPanelId=Ext.id(),hideLabel:true,layout:"hbox",height:28,border:false,cls:"syno-av-overview-status-button",margins:"18 20 0 0",hidden:false,layoutConfig:{pack:"end"},items:[{xtype:"syno_button",text:_TT("SYNO.SDS.AV.Instance","scanning","pause"),id:this.pauseScanButtonID=Ext.id(),scope:this,margins:"0 0 0 6",handler:this.doPauseScan,disabled:true,hidden:true},{xtype:"syno_button",text:_TT("SYNO.SDS.AV.Instance","scanning","stop"),id:this.stopScanButtonID=Ext.id(),scope:this,margins:"0 0 0 6",handler:this.doStopScan,hidden:true},{xtype:"syno_button",text:_TT("SYNO.SDS.AV.Instance","overview","clear_warning"),id:this.clearWarningButtonID=Ext.id(),scope:this,margins:"0 0 0 6",handler:this.doClearWarning,hidden:true},{xtype:"syno_button",text:_TT("SYNO.SDS.AV.Instance","overview","process_again"),id:this.reProcessButtonID=Ext.id(),scope:this,margins:"0 0 0 6",handler:this.doReProcess,hidden:true},{xtype:"syno_button",text:_TT("SYNO.SDS.AV.Instance","overview","acknowledged"),id:this.acknowledgeButtonID=Ext.id(),scope:this,margins:"0 0 0 6",handler:this.doAcknowledge,hidden:true}]}},createScanPanel:function(){return{xtype:"syno_panel",layout:{type:"hbox",pack:"start"},cls:"syno-av-overview-scan-panel",border:false,height:180,minWidth:576,margins:"28 26 22 26",items:[this.createFullScanButton(),this.createCustomScanButton(),this.createSystemScanButton()]}},createFullScanButton:function(){return{xtype:"syno_button",cls:"syno-av-overview-scanbuttonicon-fullscan-btn",height:180,minWidth:180,flex:1,html:'<div class="syno-av-overview-scanbuttonicon-fullscan"></div><div class="syno-av-overview-scanbuttonicon-fullscan-text">'+_TT("SYNO.SDS.AV.Instance","overview","full_scan")+"</div>",scope:this,handler:this.confirmThenScan.bind(this,this.doFullScan),id:this.fullScanButtonID=Ext.id()}},createCustomScanButton:function(){return{xtype:"syno_button",margins:"0 18 0 18",cls:"syno-av-overview-scanbuttonicon-customscan-btn",height:180,minWidth:180,flex:1,html:'<div class="syno-av-overview-scanbuttonicon-customscan"></div><div class="syno-av-overview-scanbuttonicon-customscan-text">'+_TT("SYNO.SDS.AV.Instance","overview","custom_scan")+"</div>",scope:this,handler:this.confirmThenScan.bind(this,this.checkSharedFolderCount),id:this.customScanButtonID=Ext.id()}},createSystemScanButton:function(){return{xtype:"syno_button",cls:"syno-av-overview-scanbuttonicon-systemscan-btn",height:180,minWidth:180,flex:1,html:'<div class="syno-av-overview-scanbuttonicon-systemscan"></div><div class="syno-av-overview-scanbuttonicon-systemscan-text">'+_TT("SYNO.SDS.AV.Instance","overview","sys_scan")+"</div>",scope:this,handler:this.confirmThenScan.bind(this,this.doSysScan),id:this.sysScanButtonID=Ext.id()}},createInformationPanel:function(){return{xtype:"syno_panel",cls:"syno-av-overview-informationPanel",itemId:"informationPanel",id:this.infoPanelID=Ext.id(),hideLabels:true,layout:"hbox",boxMinHeight:80,autoHeight:true,style:"padding: 20px 20px 20px 24px",margins:"16 0 40 0",items:[this.createInfoMessagePanel(),this.createPurchaseBtnPanel()]}},createInfoMessagePanel:function(){return{xtype:"syno_panel",cls:"syno-av-overview-info-msg-panel",id:this.infoMsgPanelID=Ext.id(),hideLabels:true,flex:1,layout:{type:"vbox",align:"stretch",pack:"start"},items:[{xtype:"syno_displayfield",cls:"synoav-patch-date-text",text:"",height:20,style:"padding: 0",id:this.patchDateTextID=Ext.id(),hideLabel:true},{xtype:"syno_displayfield",text:"",height:20,style:"padding: 0",id:this.quarantineFileTextID=Ext.id(),hideLabel:true},{xtype:"syno_displayfield",text:"",height:20,style:"padding: 0",id:this.ExpireDayLabelID=Ext.id(),hidden:("ClamAV"==SYNO.SDS.AV.ENGTYPE),hideLabel:true}]}},createPurchaseBtnPanel:function(){return{xtype:"syno_panel",cls:"syno-av-overview-info-purchase-btn-panel",id:this.infoPurchaseBtnPanelID=Ext.id(),autoWidth:true,height:60,hideLabels:true,layout:{type:"hbox",align:"middle",pack:"end"},items:[{xtype:"syno_displayfield",cls:"syno-av-overview-loading",id:this.ConnectIconID=Ext.id(),height:20,width:20,style:"padding: 0",hidden:false},{xtype:"syno_button",height:28,id:this.PurchaseButtonID=Ext.id(),text:_TT("SYNO.SDS.AV.Instance","overview","purchase_button"),cls:"syno-av-overview-upgradebutton",btnStyle:"blue",hidden:true,disabled:false,scope:this,handler:this.onClickPurchaseButton}]}},confirmThenScan:function(b){if(SYNO.SDS.AV.hasRecommendedMemSize()){b.call(this)}else{var a=String.format(_TT("SYNO.SDS.AV.Instance","ui_message","scan_confirm"),_T("common","ok"));this.app.getMsgBox().confirm(_TT("SYNO.SDS.AV.Instance","app","app_name"),a,function(c){if("ok"!=c){return}b.call(this)},this,Ext.MessageBox.OKCANCEL,{width:480})}},doFullScan:function(){this.scanTaskLaunched=true;this.disableAllScanButton();this.disableAllOperationButton();this.stopPolling();this.sendWebAPI({api:"SYNO.AntiVirus.Scan",version:1,method:"start_full",callback:function(d,a,c,b){this.startPolling();if(!d){this.scanTaskLaunched=false;this.enableAllScanButton();this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}},scope:this})},doSysScan:function(){this.scanTaskLaunched=true;this.disableAllScanButton();this.disableAllOperationButton();this.stopPolling();this.sendWebAPI({api:"SYNO.AntiVirus.Scan",version:1,method:"start_system",callback:function(d,a,c,b){this.startPolling();if(!d){this.scanTaskLaunched=false;this.enableAllScanButton();this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}},scope:this})},checkSharedFolderCount:function(){this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.Core.File",method:"list",version:1,params:{folder_path:"/",superuser:false,type:"dir"},scope:this,callback:function(d,a,c,b){if(d){if(Ext.isDefined(a.length)&&(0!==a.length)){this.doCustomScan()}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),_TT("SYNO.SDS.AV.Instance","common","no_share_folder"))}}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}this.getEl().unmask()}})},doCustomScan:function(){var a=new SYNO.SDS.AV.AVCustomScanWindow({owner:this.app,caller:this,preCheckFolder:[]});a.open()},doPauseScan:function(){this.disableAllOperationButton();this.stopPolling();var a=Ext.getCmp(this.pauseScanButtonID).getEl().select(".x-btn-text").first();if(a.hasClass(this.pauseIconCSS)){this.sendWebAPI({api:"SYNO.AntiVirus.Scan",version:1,method:"pause",callback:function(e,b,d,c){this.startPolling();if(!e){this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(b.code))}},scope:this})}else{if(a.hasClass(this.resumeIconCSS)){this.sendWebAPI({api:"SYNO.AntiVirus.Scan",version:1,method:"resume",callback:function(e,b,d,c){this.startPolling();if(!e){this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(b.code))}},scope:this})}else{this.startPolling();SYNO.Debug("unexpected button status")}}},doStopScan:function(){this.disableAllOperationButton();this.stopPolling();this.sendWebAPI({api:"SYNO.AntiVirus.Scan",version:1,method:"stop",callback:function(d,a,c,b){this.startPolling();if(!d){this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}},scope:this})},doClearWarning:function(){this.disableAllOperationButton();this.disableAllScanButton();this.stopPolling();this.sendWebAPI({api:"SYNO.AntiVirus.Quarantine",version:1,method:"clear_failed_list",callback:function(d,a,c,b){this.startPolling();if(!d){this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}},scope:this})},doReProcess:function(){this.disableAllOperationButton();this.disableAllScanButton();Ext.getCmp(this.reProcessButtonID).setText(_TT("SYNO.SDS.AV.Instance","overview","reprocessing"));this.stopPolling();this.sendWebAPI({api:"SYNO.AntiVirus.Quarantine",version:1,method:"retry",callback:function(d,a,c,b){this.startPolling();if(!d){this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}},scope:this})},doAcknowledge:function(){this.disableAllOperationButton();this.stopPolling();this.sendWebAPI({api:"SYNO.AntiVirus.Scan",version:1,method:"ack_result",callback:function(d,a,c,b){this.startPolling();if(!d){this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}},scope:this})},commitCustomScanTarget:function(a){this.scanTaskLaunched=true;this.disableAllScanButton();this.disableAllOperationButton();this.stopPolling();this.sendWebAPI({api:"SYNO.AntiVirus.Scan",version:1,method:"start_custom",params:{scanTarget:a},callback:function(e,b,d,c){this.startPolling();if(!e){this.scanTaskLaunched=false;this.enableAllScanButton();this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.SDS.AV.getErrorString(b.code))}},scope:this})},setAllOperationButtonInvisible:function(){Ext.getCmp(this.clearWarningButtonID).setVisible(false);Ext.getCmp(this.pauseScanButtonID).setVisible(false);Ext.getCmp(this.stopScanButtonID).setVisible(false);Ext.getCmp(this.reProcessButtonID).setVisible(false);Ext.getCmp(this.acknowledgeButtonID).setVisible(false)},disableAllOperationButton:function(){Ext.getCmp(this.clearWarningButtonID).disable();Ext.getCmp(this.pauseScanButtonID).disable();Ext.getCmp(this.stopScanButtonID).disable();Ext.getCmp(this.reProcessButtonID).disable();Ext.getCmp(this.acknowledgeButtonID).disable()},disableAllScanButton:function(){Ext.getCmp(this.fullScanButtonID).disable();Ext.getCmp(this.sysScanButtonID).disable();Ext.getCmp(this.customScanButtonID).disable()},enableAllScanButton:function(){Ext.getCmp(this.fullScanButtonID).enable();Ext.getCmp(this.sysScanButtonID).enable();Ext.getCmp(this.customScanButtonID).enable()},errStage:{none:0,once:1,twice:2},errPolling:function(){if(this.errPolling.stage===undefined||this.errPolling.stage===this.errStage.none){this.errPolling.stage=this.errStage.once}else{this.errPolling.stage=this.errStage.twice}},startPolling:function(){if(this.pollOverviewId){return}this.pollOverviewId=this.app.pollReg({scope:this,webapi:{api:"SYNO.AntiVirus.General",version:1,method:"get_sys_info"},interval:3,immediate:true,status_callback:function(d,c,b,a){if(d){this.refreshInformation(c);this.getEl().unmask();this.errPolling.stage=this.errStage.none}else{this.errPolling();if(this.errPolling.stage==this.errStage.twice){this.getEl().unmask();this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(c.code))}}}})},stopPolling:function(){if(!this.pollOverviewId){return}this.app.pollUnreg(this.pollOverviewId);this.pollOverviewId=null},onPageActivate:function(){this.doLayout();this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.startPolling()},onPageDeactivate:function(){this.stopPolling()},msgBoldWrapper:function(a){return'<span class="syno-av-overview-counter-msg">'+a+"</span>"},refreshInformation:function(h){this.sysStatus=h.sysStatus;var i=Number(h.scanRoundIndex),j=Number(h.scanRoundTotal);var d=Ext.getCmp(this.statusTitleID);var b=Ext.getCmp(this.statusSubTitleID);if("Unknown"==h.releaseDate){Ext.getCmp(this.patchDateTextID).update(_TT("SYNO.SDS.AV.Instance","qerror","database_error"))}else{var a=SYNO.SDS.DateTimeFormatter(Date.parseDate(h.releaseDate,"Y-n-d H:i"));Ext.getCmp(this.patchDateTextID).update(String.format(_TT("SYNO.SDS.AV.Instance","overview","release_date"),('<span class="syno-av-overview-patch-date">'+a+"</span>")))}if("obsolete"==h.updaterStatus){Ext.getCmp(this.patchDateTextID).addClass("syno-av-overview-vd-obsolete")}else{Ext.getCmp(this.patchDateTextID).removeClass("syno-av-overview-vd-obsolete")}Ext.getCmp(this.quarantineFileTextID).update(String.format(_TT("SYNO.SDS.AV.Instance","overview","quarantined_files_dsm7"),'<span class="syno-av-overview-quarantined-files">',h.quarantineCount,"</span>"));if(h.licenceType.match(/Purchase/)||h.licenceType.match(/Trial/)){Ext.getCmp(this.infoPurchaseBtnPanelID).show();Ext.getCmp(this.ExpireDayLabelID).show();Ext.getCmp(this.ExpireDayLabelID).update(String.format(_TT("SYNO.SDS.AV.Instance","overview","license_days_left_dsm7"),'<span class="syno-av-overview-license-days-left">',h.licenceExpire,"</span>"));Ext.getCmp(this.PurchaseButtonID).setVisible("0"===h.licenceExpire||h.licenceType.match(/Trial/));Ext.getCmp(this.PurchaseButtonID).setText(_TT("SYNO.SDS.AV.Instance","overview","purchase_button"));Ext.getCmp(this.ConnectIconID).setVisible(false)}else{Ext.getCmp(this.infoPurchaseBtnPanelID).hide();Ext.getCmp(this.ExpireDayLabelID).hide();Ext.getCmp(this.PurchaseButtonID).setVisible(false);Ext.getCmp(this.ConnectIconID).setVisible(false)}Ext.getCmp(this.infoMsgPanelID).doLayout();Ext.getCmp(this.infoPanelID).doLayout();if(true===Ext.getCmp(this.PurchaseButtonID).disabled){Ext.getCmp(this.PurchaseButtonID).setText(_TT("SYNO.SDS.AV.Instance","purchase","connecting"));Ext.getCmp(this.ConnectIconID).setVisible(true)}else{Ext.getCmp(this.ConnectIconID).setVisible(false)}this.setObjectClassByStatus(Ext.getCmp(this.iconPanelID),h.sysStatus,this.iconCSSClass);var l="";if("scanning"===h.sysStatus&&true===h.button.isPaused){l=_TT("SYNO.SDS.AV.Instance","status","scanning_paused")}else{if("preparing"===h.sysStatus&&true===h.button.isPaused){l=_TT("SYNO.SDS.AV.Instance","status","prepare_paused")}else{l=_TT("SYNO.SDS.AV.Instance","status",h.sysStatus)}}d.setValue(l);b.setVisible(false);var m=String.format(_TT("SYNO.SDS.AV.Instance","status_message",h.sysStatus),this.msgBoldWrapper(h.scan.scanned),this.msgBoldWrapper(h.scan.processed),this.msgBoldWrapper(h.scan.failed),this.msgBoldWrapper(h.procFailCount));Ext.getCmp(this.statusMessageID).setValue(m);this.setObjectClassByStatus(d,h.sysStatus,this.statusTitleCSSClass);switch(h.sysStatus){case"updating":this.setAllOperationButtonInvisible();Ext.getCmp(this.stopScanButtonID).setVisible(true);this.disableAllScanButton();this.scanTaskLaunched=false;if(0<Number(h.downloadSizeTotal)){var c=Math.round(Number(h.downloadSizeNow)/Number(h.downloadSizeTotal)*100);m+=" ("+c+"%)";Ext.getCmp(this.statusMessageID).setValue(m)}break;case"preparing":case"scanning":this.setAllOperationButtonInvisible();Ext.getCmp(this.pauseScanButtonID).setVisible(true);Ext.getCmp(this.stopScanButtonID).setVisible(true);this.disableAllScanButton();this.scanTaskLaunched=false;b.setVisible(true).setValue(String.format(_TT("SYNO.SDS.AV.Instance","status","round_info"),i,j));if(0<Number(h.scanFileCountTotal)&&0<Number(h.scan.scanned)){var g=(i-1)/j||0;var e=Number(h.scan.scanned)/(Number(h.scanFileCountTotal)*j);e=Math.min(Math.round((e+g)*100),99);d.setValue(l+" ("+e+"%)")}break;case"infected":case"completed":b.setVisible(true).setValue(String.format(_TT("SYNO.SDS.AV.Instance","status","round_info"),i,j));this.setAllOperationButtonInvisible();Ext.getCmp(this.acknowledgeButtonID).setVisible(true);if("Unknown"==h.licenceExpire||"0"==h.licenceExpire){this.disableAllScanButton()}else{if(!this.scanTaskLaunched){this.enableAllScanButton()}}break;case"danger":this.setAllOperationButtonInvisible();Ext.getCmp(this.clearWarningButtonID).setVisible(true);Ext.getCmp(this.reProcessButtonID).setVisible(true);Ext.getCmp(this.reProcessButtonID).setText(_TT("SYNO.SDS.AV.Instance","overview","process_again"));if("Unknown"==h.licenceExpire||"0"==h.licenceExpire){this.disableAllScanButton()}else{if(!this.scanTaskLaunched){this.enableAllScanButton()}}break;case"reprocessing":this.setAllOperationButtonInvisible();Ext.getCmp(this.clearWarningButtonID).setVisible(true);Ext.getCmp(this.reProcessButtonID).setVisible(true);Ext.getCmp(this.reProcessButtonID).setText(_TT("SYNO.SDS.AV.Instance","overview","reprocessing"));this.disableAllScanButton();break;case"scan_failed":this.scanTaskLaunched=false;this.setAllOperationButtonInvisible();this.enableAllScanButton();break;case"local_update_failed":case"secure":this.setAllOperationButtonInvisible();if(!this.scanTaskLaunched){this.enableAllScanButton()}break;case"installvirusdef":case"licenseexpired":case"licenseinvalid":case"timeerror":case"update_failed":this.setAllOperationButtonInvisible();this.disableAllScanButton();break;case"mydserror":this.setAllOperationButtonInvisible();this.disableAllScanButton();m=String.format(_TT("SYNO.SDS.AV.Instance","status_message",h.sysStatus),h.errormsg);Ext.getCmp(this.statusMessageID).setValue(m);break;default:SYNO.Debug("undefined system status");break}if(true===h.button.isPauseDisabled){Ext.getCmp(this.pauseScanButtonID).disable()}else{Ext.getCmp(this.pauseScanButtonID).enable()}if(true===h.button.isPaused){if("scanning"===this.sysStatus||"preparing"===this.sysStatus){this.setObjectClassByStatus(Ext.getCmp(this.iconPanelID),this.sysStatus+"-pause",this.iconCSSClass);this.setObjectClassByStatus(d,this.sysStatus+"-pause",this.statusTitleCSSClass)}Ext.getCmp(this.pauseScanButtonID).setIconClass(this.resumeIconCSS);Ext.getCmp(this.pauseScanButtonID).setText(_TT("SYNO.SDS.AV.Instance","scanning","resume"))}else{Ext.getCmp(this.pauseScanButtonID).setIconClass(this.pauseIconCSS);Ext.getCmp(this.pauseScanButtonID).setText(_TT("SYNO.SDS.AV.Instance","scanning","pause"))}if(true===h.button.isStopDisabled){Ext.getCmp(this.stopScanButtonID).disable()}else{Ext.getCmp(this.stopScanButtonID).enable()}if(true===h.button.isClearDisabled){Ext.getCmp(this.clearWarningButtonID).disable()}else{Ext.getCmp(this.clearWarningButtonID).enable()}if(true===h.button.isReProcessDisabled){Ext.getCmp(this.reProcessButtonID).disable()}else{Ext.getCmp(this.reProcessButtonID).enable()}if(true===h.button.isAckDisabled){Ext.getCmp(this.acknowledgeButtonID).disable()}else{Ext.getCmp(this.acknowledgeButtonID).enable()}var f=Ext.getCmp(this.statusBtnPanelId);var k=f.items.items.reduce(function(n,o){return n+((o.hidden)?0:(o.getWidth()+6))},0);f.body.setWidth(k);this.doLayout()},setObjectClassByStatus:function(d,b,a){var c=0;for(c=0;c<this.statusIndex.length;c++){if(this.statusIndex[c]!=b){d.removeClass(a[c])}else{d.addClass(a[c])}}},onClickPurchaseButton:function(){var a=new SYNO.SDS.AV.AVOverviewPurchaseWindow({owner:this.app,caller:this});a.open()}});Ext.define("SYNO.SDS.AV.AVCustomScanWindow",{extend:"SYNO.SDS.ModalWindow",owner:null,treePanel:null,startButtonId:Ext.id(),constructor:function(a){this.owner=a.owner;this.caller=a.caller;this.preCheckFolder=a.preCheckFolder;this.callParent([Ext.apply(a,{title:_TT("SYNO.SDS.AV.Instance","scanning","select_for_custom_scan"),height:570,width:506,layout:{type:"vbox",align:"stretch",pack:"start"},items:[{xtype:"syno_panel",cls:"syno-av-overview-custom-filechooser-card",flex:1,margins:"16 20 12 20",layout:{type:"fit"},items:[this.treePanel=new SYNO.SDS.AV.AVCustomScanTreePanel({okBtnID:this.startButtonId,preCheckFolder:this.preCheckFolder})]}],buttons:[{text:_T("common","cancel"),scope:this,handler:this.onClickClose},{text:_T("common","apply"),btnStyle:"blue",disabled:true,id:this.startButtonId,scope:this,handler:this.onClickStart}]})])},onClickClose:function(){if(Ext.isFunction(this.caller.onBeforeScanTargetSelectorWinClosed)){this.caller.onBeforeScanTargetSelectorWinClosed()}this.close()},onClickStart:function(){var b=this.treePanel.getChecked();var a=[];for(var c=0;c<b.length;c++){a.push(b[c].realPath)}this.caller.commitCustomScanTarget(a);if(Ext.isFunction(this.caller.onBeforeScanTargetSelectorWinClosed)){this.caller.onBeforeScanTargetSelectorWinClosed()}this.close()}});Ext.define("SYNO.SDS.AV.AVCustomScanTreePanel",{extend:"SYNO.ux.TreePanel",constructor:function(b){this.startButtonId=b.okBtnID;this.preCheckFolder=b.preCheckFolder;this.treeroot=new Ext.tree.AsyncTreeNode({cls:"root_node",text:_TT("SYNO.SDS.AV.Instance","scanning","all_sharefolders"),draggable:false,expanded:true,id:"fm_root",allowDrop:false,uiProvider:SYNO.SDS.AV.TriTreeNodeUI});this.dirTreeLoader=new SYNO.API.TreeLoader({api:"SYNO.Core.File",method:"list",version:1,baseParams:{superuser:false,needrw:true,filetype:"dir",folder_path:"/",status_filter:"valid",additional:["real_path","size","owner","time","perm","type","mount_point_type"],node:"fm_root"},baseAttrs:{uiProvider:SYNO.SDS.AV.TriTreeNodeUI},listeners:{beforeload:function(e,d,c){if(Ext.isDefined(d.realPath)){Ext.apply(e.baseParams,{folder_path:d.id.substr(d.id.indexOf("/"))})}return(true!==d.disabled)},load:function(h,g,c){if(g.id==this.treeroot.id){this.attachCheckChangeHandler()}if(c.responseData){var e=c.responseData;if(e&&e.errno){this.getMsgBox().alert(this.title,_TT("SYNO.SDS.AV.Instance","common","connection_error"))}else{if(Ext.isDefined(e.data.files)){e=e.data.files}else{e=e.data}for(var f=0;f<e.length;f++){g.childNodes[f].realPath=g.childNodes[f].attributes.path;for(var d=0;d<this.preCheckFolder.length;d++){if(this.preCheckFolder[d]==g.childNodes[f].realPath){g.childNodes[f].getUI().toggleCheck(true);continue}if(0===this.preCheckFolder[d].indexOf(g.childNodes[f].realPath)){g.childNodes[f].expand()}}}}}},scope:this},createNode:function(c,d){if(!Ext.isDefined(c.text)&&Ext.isDefined(c.name)){c.spath=c.path;c.id=c.spath;c.path=d.attributes.path+"/"+c.name;c.text=c.name;c.hidden=c.isdir?false:true}switch(c.text){case"@quarantine":case"#recycle":c.hidden=true;break;default:break}c.text=Ext.util.Format.htmlEncode(c.text);if(0===c.path.search(/^\/volumeGluster/)){c.hidden=true}return Ext.tree.TreeLoader.prototype.createNode.call(this,c)},processResponse:function(g,f,l,m){try{var c=g.responseData;if("fm_root"===f.id){c=c.data}else{c=c.data.files}f.beginUpdate();for(var h=0,j=c.length;h<j;h++){var d=this.createNode(c[h],f);if(d){f.appendChild(d)}}f.endUpdate();this.runCallback(l,m||f,[f])}catch(k){this.handleFailure(g)}}});var a={animate:false,autoScroll:true,cls:"syno-av-overview-customscan-treepanel",loader:this.dirTreeLoader,containerScroll:true,enableDD:false,rootVisible:true,border:false,useArrows:true,bodyStyle:"padding-right: 0px;",root:this.treeroot,tbar:null,listeners:{beforedestroy:{fn:function(){Ext.destroy(this.dirTree)},scope:this}},getChecked:function(c,e,d){e=e||this.root;var g=d||[];var f=e.firstChild;do{switch(f.getUI().getCheckIndex(f)){case SYNO.SDS.AV.TriTreeNodeUI_GRAYSTATE:if(f.firstChild){this.getChecked(c,f,g)}break;case SYNO.SDS.AV.TriTreeNodeUI_CHECKSTATE:g.push(!c?f:(c=="id"?f.id:f.attributes[c]));break;default:break}f=f.nextSibling}while(f);return g}};Ext.apply(a,b);SYNO.LayoutConfig.fill(a);this.callParent([a])},attachCheckChangeHandler:function(){this.on("checkchange",this.checkCheckedSelection,this)},checkCheckedSelection:function(){var a=this.getChecked();if(0===a.length){Ext.getCmp(this.startButtonId).disable()}else{Ext.getCmp(this.startButtonId).enable()}}});if("ClamAV"!=SYNO.SDS.AV.ENGTYPE){Ext.define("SYNO.SDS.AV.AVOverviewPurchaseWindow",{extend:"SYNO.SDS.PkgManApp.CustMyDSDialog",appId:"AntiVirus-"+SYNO.SDS.AV.ENGTYPE,owner:null,WaitConnectionPanel:null,PurchaseListPanel:null,constructor:function(a){this.owner=a.owner;this.caller=a.caller;this.PurchaseListPanel=new SYNO.SDS.AV.AVPurchaseListPanel({owner:this.owner,caller:this});this.WaitConnectionPanel=new SYNO.SDS.AV.AVPurchaseWaitPanel({owner:this.owner,caller:this});this.callParent([Ext.apply(a,{title:_TT("SYNO.SDS.AV.Instance","purchase","title_mcafee"),width:480,height:360,activeItem:0,layout:"card",listeners:{activate:{single:true,scope:this,fn:this.onRenderPurchaseList}},items:[this.WaitConnectionPanel,this.PurchaseListPanel]})])},onRenderPurchaseList:function(){Ext.getCmp(this.caller.PurchaseButtonID).setDisabled(true);if(this.PurchaseListPanel){this.PurchaseListPanel.onGetPurchaseList()}},onNext:function(a){this._onGoMyDS({appId:this.appId,itemId:a,trans_all_item:1})},onClose:function(){this.sendWebAPI({api:"SYNO.AntiVirus.Purchase",version:1,method:"sync",callback:function(d,a,c,b){Ext.getCmp(this.caller.PurchaseButtonID).setDisabled(false);this.caller.onPageActivate()},scope:this})}})}Ext.define("SYNO.SDS.AV.AVPanelQuarantine",{extend:"SYNO.ux.Panel",thisCardPanel:null,constructor:function(a){this.app=a.appWin;var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){var b={border:false,itemId:"quarantine",layout:"fit",items:[this.thisCardPanel=this.createQuarantinePanel()],listeners:{activate:this.onActivate,deactivate:this.onDeactivate,scope:this}};return b},createQuarantinePanel:function(){return new SYNO.SDS.AV.AVQuarantineListPanel({app:this.app})},onActivate:function(){if(this.thisCardPanel){this.thisCardPanel.fireEvent("activate")}},onDeactivate:function(){if(this.thisCardPanel){this.thisCardPanel.fireEvent("deactivate")}}});Ext.define("SYNO.SDS.AV.AVQuarantineListPanel",{extend:"SYNO.ux.GridPanel",QUARANTINE_ITEM_PER_PAGE:200,quarantineStore:null,quarantineColumeModel:null,quarantineSelectionModel:null,restoreButtonID:null,deleteButtonID:null,pagingToolbar:null,storeParam:null,displayNum:this.QUARANTINE_ITEM_PER_PAGE,taskId:null,taskType:null,pollId:null,skipShowProgress:false,constructor:function(b){this.app=b.app;this.quarantineSelectionModel=new Ext.grid.RowSelectionModel();var a={header:false,border:false,frame:false,ds:this.quarantineStore=this.createStore(b),cm:this.quarantineColumeModel=this.createColumnModel(),sm:this.quarantineSelectionModel,viewConfig:{forceFit:true,emptyText:['<div class="syno-dataview">','<div class="empty-text-wrap">','<div class="empty-text-inner-wrap">','<div class="empty-text-icon"></div>','<div class="empty-text">',_JSLIBSTR("extlang","pagenodata"),"</div>","</div>","</div>","</div>"].join("")},loadMask:true,stripeRows:true,tbar:{defaults:{xtype:"syno_button"},items:[{text:_TT("SYNO.SDS.AV.Instance","quarantine","restore"),itemId:"restore",id:this.restoreButtonID=Ext.id(),scope:this,handler:this.confirmRestoreFile},{text:_TT("SYNO.SDS.AV.Instance","quarantine","delete_file"),itemId:"unquarantine",id:this.deleteButtonID=Ext.id(),scope:this,handler:this.confirmDeleteFile},{text:_TT("SYNO.SDS.AV.Instance","quarantine","edit_all"),itemId:"massive_process",id:this.massiveProcessButtonID=Ext.id(),scope:this,handler:this.onClickMassiveProcess}]},bbar:this.getPagingToolbar(),listeners:{activate:this.onActivate,deactivate:this.onDeactivate,scope:this}};this.loadtaskTypeText();Ext.apply(a,b);SYNO.LayoutConfig.fill(a);this.callParent([a]);this.getSelectionModel().on("selectionchange",this.selectionChangeHandler,this);this.getSelectionModel().fireEvent("selectionchange")},loadtaskTypeText:function(){this.taskTypeTextArray={task_restore_list:{finishText:_TT("SYNO.SDS.AV.Instance","quarantine","finish_restore"),progressText:_TT("SYNO.SDS.AV.Instance","quarantine","processing_restore_selected"),btnText:_TT("SYNO.SDS.AV.Instance","quarantine","restoring")},task_delete_list:{finishText:_TT("SYNO.SDS.AV.Instance","quarantine","finish_delete"),progressText:_TT("SYNO.SDS.AV.Instance","quarantine","processing_delete_selected"),btnText:_TT("SYNO.SDS.AV.Instance","quarantine","deleting")},task_restore_all:{finishText:_TT("SYNO.SDS.AV.Instance","quarantine","finish_restore"),progressText:_TT("SYNO.SDS.AV.Instance","quarantine","processing_restore_selected"),btnText:_TT("SYNO.SDS.AV.Instance","quarantine","restoring_all")},task_delete_all:{finishText:_TT("SYNO.SDS.AV.Instance","quarantine","finish_delete"),progressText:_TT("SYNO.SDS.AV.Instance","quarantine","processing_delete_selected"),btnText:_TT("SYNO.SDS.AV.Instance","quarantine","deleting_all")}}},onActivate:function(){this.skipShowProgress=true;this.getPagingToolbar().doRefresh();this.resumeTask()},onDeactivate:function(){this.stopPolling()},resumeTask:function(){this.pollList({task_id_prefix:"SYNO_AntiVirus_Quarantine_Task",extra_group_tasks:["admin"],scope:this,callback:function(b,a){if(!b){if(a&&a.code){this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),_TT("SYNO.SDS.AV.Instance","quarantine","failed_get_task_status"))}}else{if(a.admin&&a.admin.length&&(0<a.admin.length)){this.taskId=a.admin[0];this.startPolling()}else{this.stopTask()}}}})},stopTask:function(){if(!this.taskId){return}this.stopPolling();this.view.el.unmask();this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.Quarantine",version:1,method:"task_stop",params:{task_id:this.taskId},callback:function(d,a,c,b){this.getEl().unmask();if(d){this.taskId=null;this.taskType=null;this.getPagingToolbar().doRefresh();this.setUiState()}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}},scope:this})},startPolling:function(){if(this.pollId||!this.taskId){return}this.setUiState();if(!this.skipShowProgress){this.showProgressMsgBox()}this.pollId=this.pollReg({scope:this,webapi:{api:"SYNO.AntiVirus.Quarantine",version:1,method:"task_status",params:{task_id:this.taskId}},interval:5,immediate:true,status_callback:function(d,a){if(!d||!a){if(a&&a.code){this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),_TT("SYNO.SDS.AV.Instance","quarantine","failed_get_task_status"))}this.stopTask()}else{this.updateProgressMsgBox(a);if(a.finish){var b=a.data;this.app.getMsgBox().getDialog().fbButtons.cancel.hide();this.app.getMsgBox().getDialog().fbButtons.ok.setText(_TT("SYNO.SDS.AV.Instance","common","close"));this.app.getMsgBox().updateProgress(1,"100%",this.taskTypeTextArray[this.taskType].finishText);this.stopTask();if(0<b.failCount){this.onCloseMsgBox();var c=new SYNO.SDS.AV.AVQuarantineShowProcessResultWindow({owner:this.app,mainPanel:this,respObj:b});c.open()}}}}})},stopPolling:function(){if(!this.pollId){return}this.pollUnreg(this.pollId);this.pollId=null},showProgressMsgBox:function(){this.app.getMsgBox().show({msg:_TT("SYNO.SDS.AV.Instance","common","processing"),progress:true,buttons:{cancel:_TT("SYNO.SDS.AV.Instance","common","hide"),ok:_TT("SYNO.SDS.AV.Instance","scanning","stop")},scope:this,fn:function(a){if("ok"===a){this.onCloseMsgBox();if(this.taskId){this.stopTask()}}else{if("cancel"===a){this.onCloseMsgBox()}}}})},onCloseMsgBox:function(){var a=this.app.getMsgBox().getDialog();a.doClose()},setTaskType:function(a){if(Ext.isDefined(a.info.method)){switch(a.info.method){case"task_restore_list":Ext.getCmp(this.deleteButtonID).disable();Ext.getCmp(this.restoreButtonID).enable();Ext.getCmp(this.massiveProcessButtonID).disable();Ext.getCmp(this.restoreButtonID).addClass("syno-av-quarantine-restoring");Ext.getCmp(this.restoreButtonID).setText(this.taskTypeTextArray[a.info.method].btnText);break;case"task_delete_list":Ext.getCmp(this.deleteButtonID).enable();Ext.getCmp(this.restoreButtonID).disable();Ext.getCmp(this.massiveProcessButtonID).disable();Ext.getCmp(this.deleteButtonID).addClass("syno-av-quarantine-deleting");Ext.getCmp(this.deleteButtonID).setText(this.taskTypeTextArray[a.info.method].btnText);break;case"task_restore_all":case"task_delete_all":Ext.getCmp(this.deleteButtonID).disable();Ext.getCmp(this.restoreButtonID).disable();Ext.getCmp(this.massiveProcessButtonID).enable();Ext.getCmp(this.massiveProcessButtonID).addClass("syno-av-quarantine-editing-all");Ext.getCmp(this.massiveProcessButtonID).setText(this.taskTypeTextArray[a.info.method].btnText);break;default:return false}this.taskType=a.info.method;return true}else{return false}},updateProgressMsgBox:function(b){if(b&&b.data&&!isNaN(parseInt(b.data.progress,10))){var a="";if(!this.taskType&&!this.setTaskType(b)){this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),_TT("SYNO.SDS.AV.Instance","quarantine","failed_get_task_status"));return}a=this.taskTypeTextArray[this.taskType].progressText;this.app.getMsgBox().updateProgress(b.data.progress*0.01,b.data.progress+"%",a)}},setUiState:function(){if(this.taskId&&!this.taskType){Ext.getCmp(this.massiveProcessButtonID).disable();Ext.getCmp(this.deleteButtonID).disable();Ext.getCmp(this.restoreButtonID).disable();this.getSelectionModel().lock();this.getPagingToolbar().el.mask();if(this.view){this.view.el.mask()}}else{if(!this.taskId){Ext.getCmp(this.restoreButtonID).removeClass("syno-av-quarantine-restoring");Ext.getCmp(this.restoreButtonID).setText(Ext.getCmp(this.restoreButtonID).initialConfig.text);Ext.getCmp(this.deleteButtonID).removeClass("syno-av-quarantine-deleting");Ext.getCmp(this.deleteButtonID).setText(Ext.getCmp(this.deleteButtonID).initialConfig.text);Ext.getCmp(this.massiveProcessButtonID).removeClass("syno-av-quarantine-editing-all");Ext.getCmp(this.massiveProcessButtonID).setText(Ext.getCmp(this.massiveProcessButtonID).initialConfig.text);var a=this.getSelectionModel().getSelections();if(0===a.length){Ext.getCmp(this.deleteButtonID).disable();Ext.getCmp(this.restoreButtonID).disable()}else{Ext.getCmp(this.deleteButtonID).enable();Ext.getCmp(this.restoreButtonID).enable()}if(0===this.quarantineStore.getTotalCount()){Ext.getCmp(this.massiveProcessButtonID).disable()}else{Ext.getCmp(this.massiveProcessButtonID).enable()}if(this.getSelectionModel().isLocked()){this.getSelectionModel().unlock();this.getPagingToolbar().el.unmask();this.view.el.unmask()}}}},getPagingToolbar:function(){if(!this.pagingToolbar){this.pagingToolbar=new SYNO.ux.PagingToolbar({store:this.quarantineStore,pageSize:this.QUARANTINE_ITEM_PER_PAGE,showRefreshBtn:true,displayInfo:true})}return this.pagingToolbar},createStore:function(a){return new SYNO.API.JsonStore({appWindow:a.app,api:"SYNO.AntiVirus.Quarantine",method:"load",version:1,baseParams:{start:0,limit:this.QUARANTINE_ITEM_PER_PAGE},paramNames:{start:"start",limit:"limit"},totalProperty:"quarantineCount",root:"quarantineArray",fields:[{name:"originalPath"},{name:"quarantineTime"},{name:"threat"},{name:"volumePath"},{name:"sharePath"}],listeners:{datachanged:function(){var b=this.view.el.query(".contentwrapper");if(0===this.quarantineStore.getCount()){b[0].style.height="100%"}else{b[0].style.height=""}},scope:this,load:this.onLoadQuarantineHandler},autoLoad:true,autoDestroy:true,remoteSort:false})},createColumnModel:function(){return new Ext.grid.ColumnModel([{header:_TT("SYNO.SDS.AV.Instance","common","filename"),dataIndex:"filename",hideable:false,width:120,renderer:this.filenameRenderer,scope:this},{header:_TT("SYNO.SDS.AV.Instance","common","file_path"),dataIndex:"originalPath",width:270,renderer:this.filepathRenderer,scope:this},{header:_TT("SYNO.SDS.AV.Instance","quarantine","quarantine_date"),dataIndex:"quarantineTime",width:150,renderer:SYNO.SDS.AV.AVDateRenderer},{header:_TT("SYNO.SDS.AV.Instance","quarantine","threat_detected"),dataIndex:"threat",width:200}])},filenameRenderer:function(d,c,a){var b=a.get("originalPath").split("/");return Ext.util.Format.htmlEncode(b[b.length-1])},filepathRenderer:function(g,e,b){var f=b.get("originalPath");var a=b.get("volumePath");var c=b.get("sharePath");if(0!==c.length){f=f.substring(a.length,f.length);f=c+f}else{if(0!==a.length){f=f.substring(f.indexOf("/",1)+1,f.length)}}var d=Ext.util.Format.htmlEncode(f.substring(0,f.lastIndexOf("/")));return'<div ext:qtip="'+Ext.util.Format.htmlEncode(d)+'">'+d+"</div>"},selectionChangeHandler:function(){this.setUiState()},onClickMassiveProcess:function(){if(this.taskId){this.showProgressMsgBox()}else{var a=new SYNO.SDS.AV.AVQuarantineMassiveProcessWindow({owner:this.app,mainPanel:this});a.open()}},onLoadQuarantineHandler:function(){this.setUiState()},confirmDeleteFile:function(){if(this.taskId){this.showProgressMsgBox()}else{this.getMsgBox().confirmDelete(_TT("SYNO.SDS.AV.Instance","quarantine","delete_quarantine_file"),_TT("SYNO.SDS.AV.Instance","quarantine","ask_for_delete_file"),function(a){if("yes"===a){this.doDeleteFile()}},this)}},getMsgBox:function(){if(!this.msgBox||this.msgBox.isDestroyed){this.msgBox=new SYNO.SDS.MessageBoxV5({owner:this.app})}return this.msgBox.getWrapper()},doDeleteFile:function(){this.skipShowProgress=false;var d=this.getSelectionModel().getSelections();var c=[];var b=[];for(var a=0;a<d.length;a++){c.push(d[a].json.renamedName);b.push(d[a].json.volumePath)}this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.Quarantine",version:1,method:"task_delete_list",params:{volumes:b,deleteNames:c},callback:function(h,e,g,f){this.getEl().unmask();if(h){this.resumeTask()}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(e.code))}},scope:this})},confirmRestoreFile:function(){if(this.taskId){this.showProgressMsgBox()}else{var b=this.getSelectionModel().getSelections();var a=new SYNO.SDS.AV.AVQuarantineRestoreWindow({owner:this.app,selectedRows:b,thisPanel:this});a.open()}},onClickRestore:function(b){var e=this.getSelectionModel().getSelections();var c=[];var d=[];for(var a=0;a<e.length;a++){c.push(e[a].json.renamedName);d.push(e[a].json.volumePath)}if(b.addWhiteList===true){this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.WhiteList",version:1,method:"add_quarantined",params:{volumes:d,whiteList:c},callback:function(i,f,h,g){if(i){this.doRestoreFile(d,c)}else{this.getEl().unmask();this.owner.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(f.code))}},scope:this})}else{this.doRestoreFile(d,c)}},doRestoreFile:function(b,a){this.skipShowProgress=false;this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.Quarantine",version:1,method:"task_restore_list",params:{volumes:b,restoreNames:a},callback:function(f,c,e,d){this.getEl().unmask();if(f){this.resumeTask()}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(c.code))}},scope:this})},doRestoreAllFile:function(a){this.skipShowProgress=false;this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.Quarantine",version:1,method:"task_restore_all",params:{addToWhiteList:a},callback:function(e,b,d,c){this.getEl().unmask();if(e){this.resumeTask()}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(b.code))}},scope:this})},doDeleteAllFile:function(){this.skipShowProgress=false;this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.Quarantine",version:1,method:"task_delete_all",callback:function(d,a,c,b){this.getEl().unmask();if(d){this.resumeTask()}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}},scope:this})}});Ext.define("SYNO.SDS.AV.AVQuarantineRestoreWindow",{extend:"SYNO.SDS.ModalWindow",owner:null,selectedRows:null,thisPanel:null,checkboxID:null,constructor:function(a){this.owner=a.owner;this.selectedRows=a.selectedRows;this.thisPanel=a.thisPanel;this.callParent([Ext.apply(a,SYNO.LayoutConfig.fill({title:_TT("SYNO.SDS.AV.Instance","quarantine","restore_quarantine"),plain:true,layout:"form",width:550,height:180,padding:"20px 20px 20px 20px",items:[{xtype:"syno_displayfield",value:String.format(_TT("SYNO.SDS.AV.Instance","quarantine","ask_for_restore_file"),this.selectedRows.length)},{xtype:"syno_checkbox",boxLabel:_TT("SYNO.SDS.AV.Instance","quarantine","add_to_white_list"),id:this.checkboxID=Ext.id()}],buttons:[{text:_T("common","cancel"),scope:this,handler:function(){this.close()}},{text:_TT("SYNO.SDS.AV.Instance","quarantine","restore"),btnStyle:"blue",scope:this,handler:function(){var b=Ext.getCmp(this.checkboxID).getValue();this.thisPanel.onClickRestore({addWhiteList:b});this.close()}}]}))])}});Ext.define("SYNO.SDS.AV.AVQuarantineMassiveProcessWindow",{extend:"SYNO.SDS.ModalWindow",owner:null,parentPanel:null,constructor:function(a){this.owner=a.owner;this.parentPanel=a.mainPanel;this.callParent([Ext.apply(a,SYNO.LayoutConfig.fill({title:_TT("SYNO.SDS.AV.Instance","quarantine","edit_all"),cls:"syno-av syno-av-quarantine-batch-edit-window",width:600,height:247,resizable:false,layout:"vbox",layoutConfig:{align:"stretch",pack:"start"},padding:"15px 20px 15px 20px",items:[{xtype:"syno_displayfield",height:48,margins:"0 0 6 0",value:_TT("SYNO.SDS.AV.Instance","quarantine","massive_process_desc")},{xtype:"syno_compositefield",height:28,margins:"0 0 6 0",hideLabel:true,items:[{xtype:"syno_radio",height:28,id:this.actionRadioID=Ext.id(),name:"action",inputValue:"restore",flex:2,boxLabel:_TT("SYNO.SDS.AV.Instance","quarantine","restore"),checked:true,handler:this.onClickActionRadioBox,scope:this},{xtype:"syno_checkbox",height:28,id:this.addToWhiteListCheckboxID=Ext.id(),flex:5,boxLabel:_TT("SYNO.SDS.AV.Instance","quarantine","add_to_white_list"),hideLabel:true,handler:null,scope:this}]},{xtype:"syno_radio",name:"action",height:28,margins:"0 0 6 0",inputValue:"delete",boxLabel:_TT("SYNO.SDS.AV.Instance","quarantine","delete_file"),handler:this.onClickActionRadioBox,scope:this}],buttons:[{text:_T("common","cancel"),handler:this.onClickCancel,scope:this},{text:_T("common","ok"),btnStyle:"blue",handler:this.onClickOK,scope:this}]}))])},onClickCancel:function(){this.close()},onClickOK:function(){var a=_TT("SYNO.SDS.AV.Instance","quarantine","confirm_delete_all");var b=Ext.getCmp(this.actionRadioID).getGroupValue();if("restore"==b){a=_TT("SYNO.SDS.AV.Instance","quarantine","confirm_restore_all")}this.getMsgBox().confirm(_TT("SYNO.SDS.AV.Instance","app","app_name"),a,function(c){if("yes"===c){if("restore"==b){this.parentPanel.doRestoreAllFile(Ext.getCmp(this.addToWhiteListCheckboxID).getValue())}else{this.parentPanel.doDeleteAllFile()}this.close()}},this)},onClickActionRadioBox:function(){if("restore"==Ext.getCmp(this.actionRadioID).getGroupValue()){Ext.getCmp(this.addToWhiteListCheckboxID).enable()}else{Ext.getCmp(this.addToWhiteListCheckboxID).disable();Ext.getCmp(this.addToWhiteListCheckboxID).setValue(false)}}});Ext.define("SYNO.SDS.AV.AVQuarantineShowProcessResultWindow",{extend:"SYNO.SDS.ModalWindow",owner:null,failedFileStore:null,failedFileColumeModel:null,failedFileSelectionModel:null,constructor:function(b){this.owner=b.owner;this.mainPanel=b.mainPanel;this.failedFileStore=new Ext.data.JsonStore({autoDestroy:true,root:"failArray",totalProperty:"failCount",fields:["originalPath","quarantineTime","threat","volumePath","sharePath","reason"]});this.failedFileStore.loadData(b.respObj);var a={title:_TT("SYNO.SDS.AV.Instance","quarantine","error_processing"),width:600,height:400,resizable:true,layout:"vbox",layoutConfig:{align:"stretch",pack:"start"},padding:0,items:[this.createFailedFileGridPanel()],buttons:[{text:_T("common","ok"),btnStyle:"blue",handler:this.onClickOK,scope:this}]};Ext.apply(a,b);this.callParent([a])},createDescriptionPanel:function(){return SYNO.LayoutConfig.fill({xtype:"syno_panel",hideLabel:true,border:false,height:50,padding:"10pt 15pt 10pt 15pt",baseCls:"x-toolbar-cell",items:[{xtype:"syno_displayfield",value:_TT("SYNO.SDS.AV.Instance","quarantine","error_processing_desc")}]})},createFailedFileGridPanel:function(){return{xtype:"syno_gridpanel",header:false,border:false,frame:false,flex:1,ds:this.failedFileStore,cm:this.failedFileColumeModel=this.createFailedFileColumnModel(),sm:this.failedFileSelectionModel=new Ext.grid.RowSelectionModel({singleSelect:false}),viewConfig:{forceFit:true},loadMask:true,stripeRows:true,tbar:{items:[this.createDescriptionPanel()]},bbar:{}}},createFailedFileColumnModel:function(){return new Ext.grid.ColumnModel([{header:_TT("SYNO.SDS.AV.Instance","common","filename"),dataIndex:"filename",width:120,renderer:this.mainPanel.filenameRenderer,scope:this},{header:_TT("SYNO.SDS.AV.Instance","common","file_path"),dataIndex:"originalPath",width:210,renderer:this.mainPanel.filepathRenderer,scope:this},{header:_TT("SYNO.SDS.AV.Instance","quarantine","error_processing_reason"),dataIndex:"reason",width:210,renderer:this.reasonRenderer,scope:this}])},onClickOK:function(){this.close()},reasonRenderer:function(e,d,a){var b=["no_error","unknown","dest_dir_not_found","src_file_missing","move_fail","remove_fail","database_error","dest_path_exist","error_no_enough_space"];var c=_TT("SYNO.SDS.AV.Instance","qerror",b[parseInt(e,10)]);return'<div ext:qtip="'+Ext.util.Format.htmlEncode(c)+'">'+c+"</div>"}});Ext.define("SYNO.SDS.AV.AVPanelConfig",{extend:"SYNO.ux.Panel",mainPanel:null,constructor:function(a){this.app=a.appWin;var b={border:false,itemId:"config",layout:"fit",items:[this.mainPanel=this.createConfigPanel()]};this.callParent([b])},createConfigPanel:function(){return new SYNO.SDS.AV.AVConfigContainerPanel({app:this.app})},isDirty:function(){return this.mainPanel.getForm().isDirty()},onPageActivate:function(){this.mainPanel.onActivate();this.mainPanel.onClickEnableExtension()}});Ext.define("SYNO.SDS.AV.AVSmartScanCheckbox",{extend:"SYNO.ux.Checkbox",xtype:"synoav_smartscan_checkbox",constructor:function(){this.callParent(arguments)},onClick:function(){if(SYNO.SDS.AV.hasRecommendedMemSize()||!this.getValue()){this.callParent()}else{var a=String.format(_TT("SYNO.SDS.AV.Instance","ui_message","disable_smartscan_confirm"),_T("common","ok"));this.scope.app.getMsgBox().confirm(_TT("SYNO.SDS.AV.Instance","app","app_name"),a,function(b){if("ok"==b){this.superclass().onClick.call(this)}},this,Ext.MessageBox.OKCANCEL,{width:480})}}});Ext.define("SYNO.SDS.AV.AVConfigContainerPanel",{extend:"SYNO.ux.FormPanel",defaultBehaviorFieldSet:null,fileBehaviorFieldSet:null,buttonApplyId:null,app:null,constructor:function(a){this.app=a.app;var b=this.getContainerConfig();this.callParent([b])},getContainerConfig:function(){this.defaultBehaviorFieldSet=this.createDefaultBehaviorFieldSet();this.fileBehaviorFieldSet=this.createFileBehaviorFieldSet();this.UpdaterBehaviorFieldSet=this.createUpdaterBehaviorFieldSet();var a=this.createApplyButtons();var b={labelAlign:"left",border:false,itemId:"config",autoScroll:true,trackResetOnLoad:true,buttons:a,items:[this.defaultBehaviorFieldSet,this.fileBehaviorFieldSet,this.UpdaterBehaviorFieldSet]};return b},createDefaultBehaviorFieldSet:function(){var a={labelWidth:72,title:_TT("SYNO.SDS.AV.Instance","config","default_behavior"),items:[{xtype:"syno_displayfield",value:_TT("SYNO.SDS.AV.Instance","config","what_to_do_when_infected")},{xtype:"syno_radio",name:"virusAction",id:this.virusActionRadioID=Ext.id(),inputValue:"quarantine_it",boxLabel:_TT("SYNO.SDS.AV.Instance","config","quarantine_it"),checked:true},{xtype:"syno_radio",name:"virusAction",inputValue:"do_nothing",boxLabel:_TT("SYNO.SDS.AV.Instance","config","do_nothing")}]};return new SYNO.ux.FieldSet(SYNO.LayoutConfig.fill(a))},createFileBehaviorFieldSet:function(){var a={labelWidth:300,title:_TT("SYNO.SDS.AV.Instance","config","default_target"),items:[{xtype:"syno_checkbox",name:"enableWhitelist",id:this.enableWhitelistID=Ext.id(),boxLabel:_TT("SYNO.SDS.AV.Instance","config","enable_whitelist"),hideLabel:true,handler:this.onClickEnableWhitelist,scope:this},{xtype:"syno_displayfield",indent:1,id:this.whitelistDescID=Ext.id(),hideLabel:true,value:_TT("SYNO.SDS.AV.Instance","config","white_list_description")},{xtype:"syno_button",indent:1,id:this.whitelistButtonID=Ext.id(),text:_TT("SYNO.SDS.AV.Instance","config","manage_list"),scope:this,handler:this.onClickWhiteList},{xtype:"syno_displayfield",value:""},{xtype:"syno_checkbox",name:"scanExtensionOnly",id:this.scanExtensionCheckboxID=Ext.id(),boxLabel:_TT("SYNO.SDS.AV.Instance","config","only_scan_specific_extension"),hideLabel:true,handler:this.onClickEnableExtension,scope:this},{xtype:"syno_displayfield",indent:1,id:this.extensionDescID=Ext.id(),hideLabel:true,value:_TT("SYNO.SDS.AV.Instance","config","extension_list_desc")},{xtype:"syno_button",indent:1,id:this.extensionButtonID=Ext.id(),text:_TT("SYNO.SDS.AV.Instance","config","manage_list"),scope:this,handler:this.onClickExtensionList},{xtype:"syno_displayfield",value:""},{xtype:"synoav_smartscan_checkbox",name:"smartScan",id:this.smartScanID=Ext.id(),boxLabel:_TT("SYNO.SDS.AV.Instance","config","enable_smart_scan"),hideLabel:true,scope:this},{xtype:"syno_displayfield",indent:1,hideLabel:true,value:_TT("SYNO.SDS.AV.Instance","config","smart_scan_desc")}]};return new SYNO.ux.FieldSet(SYNO.LayoutConfig.fill(a))},createUpdaterBehaviorFieldSet:function(){var a={labelWidth:300,title:_TT("SYNO.SDS.AV.Instance","updater","update_config_title"),items:[{xtype:"syno_checkbox",name:"updateBeforeScan",boxLabel:_TT("SYNO.SDS.AV.Instance","updater","update_before_scan"),hideLabel:true}]};return new SYNO.ux.FieldSet(SYNO.LayoutConfig.fill(a))},createApplyButtons:function(){return[{xtype:"syno_button",btnStyle:"grey",text:_TT("SYNO.SDS.AV.Instance","config","restore_default"),scope:this,handler:this.onClickRestoreDefault},{xtype:"syno_button",btnStyle:"blue",text:_T("common","commit"),scope:this,id:this.buttonApplyId=Ext.id(),handler:this.onClickCommit}]},onClickRestoreDefault:function(){this.app.getMsgBox().confirm(_TT("SYNO.SDS.AV.Instance","config","restore_default"),_TT("SYNO.SDS.AV.Instance","config","ask_confirm_restore_default"),function(a){if("yes"===a){this.doRestoreDefault()}},this);return false},onClickCommit:function(){this.doCommitSetting()},onClickWhiteList:function(){var a=new SYNO.SDS.AV.AVConfigWhiteListWindow({owner:this.app});a.open()},onClickExtensionList:function(){var a=new SYNO.SDS.AV.AVConfigExtensionWindow({owner:this.app});a.open()},onClickEnableWhitelist:function(){if(true===Ext.getCmp(this.enableWhitelistID).getValue()){Ext.getCmp(this.whitelistDescID).enable();Ext.getCmp(this.whitelistButtonID).enable()}else{Ext.getCmp(this.whitelistDescID).disable();Ext.getCmp(this.whitelistButtonID).disable()}},onClickEnableExtension:function(){if(true===Ext.getCmp(this.scanExtensionCheckboxID).getValue()){Ext.getCmp(this.extensionDescID).enable();Ext.getCmp(this.extensionButtonID).enable()}else{Ext.getCmp(this.extensionDescID).disable();Ext.getCmp(this.extensionButtonID).disable()}},doRestoreDefault:function(){this.getEl().mask(_T("common","saving"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.Config",version:1,method:"restore_default",callback:function(d,a,c,b){this.getEl().unmask();if(d){this.loadConfig()}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}},scope:this})},doCommitSetting:function(){var e=this.getForm().findField("virusAction").getGroupValue();var f=this.getForm().findField("enableWhitelist").getValue();var c=this.getForm().findField("scanExtensionOnly").getValue();var a=this.getForm().findField("smartScan").getValue();var b=this.getForm().findField("updateBeforeScan").getValue();var d={enableWhitelist:f,virusAction:e,scanExtensionOnly:c,smartScan:a,updateBeforeScan:b};this.getEl().mask(_T("common","saving"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.Config",version:1,method:"set",params:{config:d},callback:function(j,g,i,h){if(j){this.form.setValues({enableWhitelist:f,virusAction:e,scanExtensionOnly:c,smartScan:a,updateBeforeScan:b});this.getEl().unmask()}else{this.getEl().unmask();this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(g.code))}},scope:this})},loadConfig:function(){this.getEl().mask(_T("common","loading"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.Config",version:1,method:"get",callback:function(d,a,c,b){if(d){this.form.setValues({enableWhitelist:a.enableWhitelist,virusAction:a.virusAction,scanExtensionOnly:a.scanExtensionOnly,smartScan:a.smartScan,updateBeforeScan:a.updateBeforeScan});this.getEl().unmask()}else{this.getEl().unmask();this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}},scope:this})},onActivate:function(){this.loadConfig()}});Ext.define("SYNO.SDS.AV.AVConfigWhiteListWindow",{extend:"SYNO.SDS.ModalWindow",owner:null,constructor:function(a){this.owner=a.owner;this.callParent([Ext.apply(a,{title:_TT("SYNO.SDS.AV.Instance","config","white_list"),width:740,height:375,layout:"fit",items:[new SYNO.SDS.AV.AVConfigWhiteListGrid({owner:this})],buttons:[{text:_T("common","close"),scope:this,handler:function(){this.close()}}]})])}});Ext.define("SYNO.SDS.AV.AVConfigWhiteListGrid",{extend:"SYNO.ux.GridPanel",WHITELIST_ITEM_PER_PAGE:10,whiteListStore:null,whitelistColumeModel:null,pagingToolbar:null,deleteButtonID:null,selectionModel:null,displayNum:this.WHITELIST_ITEM_PER_PAGE,constructor:function(b){this.owner=b.owner;this.selectionModel=new Ext.grid.RowSelectionModel();var a={header:false,border:false,frame:false,ds:this.whiteListStore=this.createStore(b),cm:this.whitelistColumeModel=this.createColumnModel(),sm:this.selectionModel,viewConfig:{forceFit:true},loadMask:true,stripeRows:true,enableHdMenu:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:false}),tbar:{items:[{xtype:"syno_button",text:_TT("SYNO.SDS.AV.Instance","config","add_to_whitelist"),itemId:"add",id:this.addButtonID=Ext.id(),scope:this,handler:this.addWhiteListItem},{xtype:"syno_button",text:_TT("SYNO.SDS.AV.Instance","config","remove_from_whitelist"),itemId:"delete",id:this.deleteButtonID=Ext.id(),scope:this,handler:this.deleteWhiteListItem}]},bbar:this.getPagingToolbar()};Ext.apply(a,b);SYNO.LayoutConfig.fill(a);this.callParent([a]);this.getSelectionModel().on("selectionchange",this.selectionChangeHandler,this);this.getSelectionModel().fireEvent("selectionchange")},getPagingToolbar:function(){if(!this.pagingToolbar){this.pagingToolbar=new SYNO.ux.PagingToolbar({store:this.whiteListStore,pageSize:this.WHITELIST_ITEM_PER_PAGE,showRefreshBtn:true,displayInfo:true})}return this.pagingToolbar},createStore:function(a){return new SYNO.API.JsonStore({appWindow:a.owner,api:"SYNO.AntiVirus.WhiteList",method:"load",version:1,baseParams:{start:0,limit:this.WHITELIST_ITEM_PER_PAGE},paramNames:{start:"start",limit:"limit"},totalProperty:"itemCount",root:"whiteList",fields:[{name:"ID"},{name:"filepath"}],autoLoad:true,autoDestroy:true,remoteSort:false})},createColumnModel:function(){return new Ext.grid.ColumnModel([{header:_TT("SYNO.SDS.AV.Instance","common","file_path"),dataIndex:"filepath",hideable:false,menuDisabled:true,renderer:SYNO.SDS.AV.AVPlainTextRenderer,width:100}])},selectionChangeHandler:function(d,b,f,a){var e=this.getSelectionModel().getSelections();if(0===e.length){Ext.getCmp(this.deleteButtonID).disable()}else{Ext.getCmp(this.deleteButtonID).enable()}},addWhiteListItem:function(){var a=new SYNO.SDS.AV.AVConfigWhiteListTreeWindow({owner:this.owner,caller:this});this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.Core.File",method:"list",version:1,params:{folder_path:"/",superuser:false,type:"dir"},scope:this,callback:function(e,b,d,c){if(e){if(Ext.isDefined(b.length)&&(0!==b.length)){a.open()}else{this.owner.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),_TT("SYNO.SDS.AV.Instance","common","no_share_folder_to_select"))}}else{this.owner.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(b.code))}this.getEl().unmask()}})},deleteWhiteListItem:function(){var b=this.getSelectionModel().getSelections();var c=[];for(var a=0;a<b.length;a++){c.push(b[a].json.filepath)}this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.WhiteList",version:1,method:"delete",params:{listToBeDelete:c},callback:function(g,d,f,e){this.getEl().unmask();if(g){this.getPagingToolbar().doRefresh()}else{this.caller.owner.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(d.code))}},scope:this})}});Ext.define("SYNO.SDS.AV.AVConfigExtensionWindow",{extend:"SYNO.SDS.ModalWindow",owner:null,constructor:function(a){this.owner=a.owner;this.callParent([Ext.apply(a,{title:_TT("SYNO.SDS.AV.Instance","config","extension_list"),width:740,height:375,layout:"fit",items:[new SYNO.SDS.AV.AVConfigExtensionGrid({owner:this.owner})],buttons:[{text:_T("common","close"),scope:this,handler:function(){this.close()}}]})])}});Ext.define("SYNO.SDS.AV.AVConfigExtensionGrid",{extend:"SYNO.ux.GridPanel",EXTENSION_ITEM_PER_PAGE:10,extensionStore:null,extensionColumeModel:null,pagingToolbar:null,deleteButtonID:null,selectionModel:null,addExtensionFieldID:null,displayNum:this.EXTENSION_ITEM_PER_PAGE,constructor:function(b){this.owner=b.owner;this.selectionModel=new Ext.grid.RowSelectionModel();var a={header:false,border:false,frame:false,ds:this.extensionStore=this.createStore(b),cm:this.extensionColumeModel=this.createColumnModel(),sm:this.selectionModel,viewConfig:{forceFit:true},loadMask:true,stripeRows:true,enableHdMenu:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:false}),tbar:{items:[{xtype:"syno_button",text:_T("common","delete"),id:this.deleteButtonID=Ext.id(),scope:this,handler:this.deleteExtensionItem},"->",{xtype:"syno_textfield",hideLabel:true,style:"margin-right: 6px",maxLength:5,minLength:1,vtype:"alphanum",enableKeyEvents:true,id:this.addExtensionFieldID=Ext.id(),value:""},{xtype:"syno_button",text:_T("common","add"),scope:this,id:this.addExtensionButtonID=Ext.id(),handler:this.addExtensionItem}]},bbar:this.getPagingToolbar()};Ext.apply(a,b);SYNO.LayoutConfig.fill(a);this.callParent([a]);this.getSelectionModel().on("selectionchange",this.selectionChangeHandler,this);this.getSelectionModel().fireEvent("selectionchange")},getPagingToolbar:function(){if(!this.pagingToolbar){this.pagingToolbar=new SYNO.ux.PagingToolbar({store:this.extensionStore,pageSize:this.EXTENSION_ITEM_PER_PAGE,showRefreshBtn:true,displayInfo:true})}return this.pagingToolbar},createStore:function(a){return new SYNO.API.JsonStore({appWindow:a.owner,api:"SYNO.AntiVirus.FileExt",method:"load",version:1,baseParams:{start:0,limit:this.EXTENSION_ITEM_PER_PAGE},paramNames:{start:"start",limit:"limit"},totalProperty:"itemCount",root:"extensionList",fields:[{name:"ID"},{name:"extension"}],autoLoad:true,autoDestroy:true,remoteSort:false})},createColumnModel:function(){return new Ext.grid.ColumnModel([{header:_TT("SYNO.SDS.AV.Instance","config","file_extension"),dataIndex:"extension",hideable:false,menuDisabled:true,renderer:SYNO.SDS.AV.AVPlainTextRenderer,width:100}])},selectionChangeHandler:function(d,b,f,a){var e=this.getSelectionModel().getSelections();if(0===e.length){Ext.getCmp(this.deleteButtonID).disable()}else{Ext.getCmp(this.deleteButtonID).enable()}},deleteExtensionItem:function(){var c=this.getSelectionModel().getSelections();var b=[];for(var a=0;a<c.length;a++){b.push(c[a].json.extension)}this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.FileExt",version:1,method:"delete",params:{extensionToBeDelete:b},callback:function(g,d,f,e){this.getEl().unmask();if(g){this.getPagingToolbar().doRefresh()}else{this.owner.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(d.code))}},scope:this})},addExtensionItem:function(){var b=Ext.getCmp(this.addExtensionFieldID);if(!b.isValid()){return}if(b.getValue()===""){b.markInvalid(_TT("SYNO.SDS.AV.Instance","common","error_empty_input"));return}var a=b.getValue();this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.FileExt",version:1,method:"add",params:{extension:a},callback:function(f,c,e,d){this.getEl().unmask();if(f){b.setValue("");this.getPagingToolbar().doRefresh();if(0===c.recordEffected){this.owner.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","config","extension_list"),_TT("SYNO.SDS.AV.Instance","config","duplicated_extension"))}}else{this.owner.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(c.code))}},scope:this})}});Ext.define("SYNO.SDS.AV.AVConfigWhiteListTreeWindow",{extend:"SYNO.SDS.ModalWindow",owner:null,treePanel:null,OkButtonId:Ext.id(),constructor:function(a){this.owner=a.owner;this.caller=a.caller;this.callParent([Ext.apply(a,{title:_TT("SYNO.SDS.AV.Instance","scanning","select_for_custom_scan"),height:570,width:506,layout:{type:"vbox",align:"stretch",pack:"start"},items:[{xtype:"syno_panel",cls:"syno-av-overview-custom-filechooser-card",flex:1,margins:"16 20 12 20",layout:{type:"fit"},items:[this.treePanel=new SYNO.SDS.AV.AVCustomScanTreePanel({okBtnID:this.OkButtonId,preCheckFolder:[]})]}],buttons:[{text:_T("common","cancel"),scope:this,handler:this.onClickClose},{text:_T("common","apply"),id:this.OkButtonId,btnStyle:"blue",scope:this,handler:this.onClickOk}]})])},onClickClose:function(){this.close()},onClickOk:function(){var a=this.treePanel.getChecked();var c=[];for(var b=0;b<a.length;b++){c.push(a[b].realPath)}this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.WhiteList",version:1,method:"add",params:{listToBeAdd:c},callback:function(g,d,f,e){this.getEl().unmask();if(g){this.caller.getPagingToolbar().doRefresh()}else{this.owner.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(d.code))}},scope:this});this.close()}});Ext.define("SYNO.SDS.AV.AVPanelEventReport",{extend:"SYNO.ux.Panel",constructor:function(a){this.app=a.appWin;var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){var b={border:false,layout:"fit",itemId:"eventreport",items:[this.mainPanel=this.createEventReportPanel()]};return b},createEventReportPanel:function(){return new SYNO.SDS.AV.AVEventReportListPanel({app:this.app})},onPageActivate:function(){this.mainPanel.onActivate()}});Ext.define("SYNO.SDS.AV.AVEventReportListPanel",{extend:"SYNO.ux.GridPanel",REPORT_ITEM_PER_PAGE:100,categoryArray:["warning","error","info","detected"],categoryStyleClass:["syno-av-event-category-warning","syno-av-event-category-error","syno-av-event-category-info","syno-av-event-category-detected"],moduleArray:["updater","scanner"],categoryCheckBoxID:null,moduleCheckBoxID:null,reportStore:null,reportColumeModel:null,reportSelectionModel:null,categoryButtonID:null,moduleButtonID:null,deleteSplitButtonID:null,exportButtonID:null,pagingToolbar:null,deleteSelectedButtonID:null,deleteAdvancedButtonID:null,displayNum:this.REPORT_ITEM_PER_PAGE,constructor:function(b){this.app=b.app;this.reportSelectionModel=new Ext.grid.RowSelectionModel();this.categoryCheckBoxID=new Array(this.categoryArray.length);this.moduleCheckBoxID=new Array(this.moduleArray.length);var a={header:false,border:false,frame:false,cls:"syno-av-event-panel",ds:this.reportStore=this.createStore(b),cm:this.reportColumeModel=this.createColumnModel(),sm:this.reportSelectionModel,viewConfig:{forceFit:true,emptyText:['<div class="syno-dataview">','<div class="empty-text-wrap">','<div class="empty-text-inner-wrap">','<div class="empty-text-icon"></div>','<div class="empty-text">',_JSLIBSTR("extlang","pagenodata"),"</div>","</div>","</div>","</div>"].join("")},loadMask:true,stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:false}),tbar:{items:[{xtype:"syno_splitbutton",text:_TT("SYNO.SDS.AV.Instance","report","clear_record"),id:this.deleteSplitButtonID=Ext.id(),handler:function(){if(Ext.getCmp(this.deleteSplitButtonID).menu.isVisible()){Ext.getCmp(this.deleteSplitButtonID).hideMenu()}else{Ext.getCmp(this.deleteSplitButtonID).showMenu()}},scope:this,menu:{defaults:{scope:this,hideOnClick:true},items:[{text:_TT("SYNO.SDS.AV.Instance","common","all"),id:this.deleteAllButtonID=Ext.id(),handler:this.onClickClearAll},{text:_TT("SYNO.SDS.AV.Instance","report","selected"),id:this.deleteSelectedButtonID=Ext.id(),handler:this.deleteReport},{text:_TT("SYNO.SDS.AV.Instance","report","advanced"),id:this.deleteAdvancedButtonID=Ext.id(),handler:this.onClickMassiveClear}]}},{xtype:"syno_button",text:_TT("SYNO.SDS.AV.Instance","report","export_report"),id:this.exportButtonID=Ext.id(),scope:this,handler:this.exportReport},{xtype:"syno_splitbutton",text:_TT("SYNO.SDS.AV.Instance","report","filter_splitbutton"),id:this.filterSplitButtonID=Ext.id(),handler:function(){if(Ext.getCmp(this.filterSplitButtonID).menu.isVisible()){Ext.getCmp(this.filterSplitButtonID).hideMenu()}else{Ext.getCmp(this.filterSplitButtonID).showMenu()}},scope:this,menu:{items:[{text:_TT("SYNO.SDS.AV.Instance","report","category"),menu:{xtype:"syno_menu",defaults:{checked:true,checkHandler:this.reportFilter,scope:this,hideOnClick:false},items:[{text:_TT("SYNO.SDS.AV.Instance","report","category_alert"),id:this.getCategoryID("warning")},{text:_TT("SYNO.SDS.AV.Instance","report","category_err"),id:this.getCategoryID("error")},{text:_TT("SYNO.SDS.AV.Instance","report","category_info"),id:this.getCategoryID("info")},{text:_TT("SYNO.SDS.AV.Instance","report","category_detect"),id:this.getCategoryID("detected")}]}},{text:_TT("SYNO.SDS.AV.Instance","report","module"),menu:{xtype:"syno_menu",defaults:{checked:true,checkHandler:this.reportFilter,scope:this,hideOnClick:false},items:[{text:_TT("SYNO.SDS.AV.Instance","report","mod_updater"),id:this.getModuleID("updater")},{text:_TT("SYNO.SDS.AV.Instance","report","mod_scanner"),id:this.getModuleID("scanner")}]}}]}}]},bbar:this.getPagingToolbar()};this.initString();Ext.apply(a,b);SYNO.LayoutConfig.fill(a);this.callParent([a]);this.getSelectionModel().on("selectionchange",this.selectionChangeHandler,this);this.getSelectionModel().fireEvent("selectionchange");this.getSelectionModel().fireEvent("datachanged");this.reportFilter()},initString:function(){this.categoryString=[_TT("SYNO.SDS.AV.Instance","report","category_alert"),_TT("SYNO.SDS.AV.Instance","report","category_err"),_TT("SYNO.SDS.AV.Instance","report","category_info"),_TT("SYNO.SDS.AV.Instance","report","category_detect")];this.moduleString=[_TT("SYNO.SDS.AV.Instance","report","mod_updater"),_TT("SYNO.SDS.AV.Instance","report","mod_scanner")]},getPagingToolbar:function(){if(!this.pagingToolbar){this.pagingToolbar=new SYNO.ux.PagingToolbar({store:this.reportStore,pageSize:this.REPORT_ITEM_PER_PAGE,showRefreshBtn:true,displayInfo:true})}return this.pagingToolbar},createStore:function(a){return new SYNO.API.JsonStore({appWindow:a.app,api:"SYNO.AntiVirus.Log",method:"load",version:1,paramNames:this.storeParam={start:"start",limit:"limit",sort:"sort",dir:"dir"},totalProperty:"reportCount",root:"reportArray",fields:[{name:"category"},{name:"module"},{name:"eventContent"},{name:"date"}],listeners:{scope:this,datachanged:this.dataChangedHandler,load:this.onLoadReportHandler,beforeload:this.onBeforeStoreLoad},autoLoad:false,autoDestroy:true,remoteSort:true})},createColumnModel:function(){return new Ext.grid.ColumnModel({columns:[{header:_TT("SYNO.SDS.AV.Instance","report","category"),dataIndex:"category",renderer:this.categoryContentRenderer,scope:this,width:100},{header:_TT("SYNO.SDS.AV.Instance","report","module"),dataIndex:"module",renderer:this.moduleContentRenderer,scope:this,width:100},{header:_TT("SYNO.SDS.AV.Instance","report","event_content"),dataIndex:"eventContent",renderer:this.reportContentRenderer,hideable:false,sortable:false,scope:this,width:240},{header:_TT("SYNO.SDS.AV.Instance","report","date"),dataIndex:"date",renderer:SYNO.SDS.AV.AVDateRenderer,scope:this,resizable:false,width:150}],defaults:{sortable:true}})},onClickClearAll:function(){this.app.getMsgBox().confirmDelete(_TT("SYNO.SDS.AV.Instance","app","app_name"),_TT("SYNO.SDS.AV.Instance","report","confirm_clear_all"),function(a){if("yes"===a){this.massiveDeleteReport(this.categoryArray,this.moduleArray)}},this,{yes:{text:_T("common","clean"),btnStyle:"red"},cancel:{text:Ext.MessageBox.buttonText.cancel}})},onClickMassiveClear:function(){var a=new SYNO.SDS.AV.AVEventReportMassiveProcessWindow({owner:this.app,mainPanel:this});a.open()},getCategoryID:function(a){return this.getTypeID(this.categoryArray,a,this.categoryCheckBoxID)},getModuleID:function(a){return this.getTypeID(this.moduleArray,a,this.moduleCheckBoxID)},getTypeID:function(d,c,a){for(var b=0;b<d.length;b++){if(d[b]==c){a[b]=Ext.id();return a[b]}}SYNO.Debug("unexpected type:",c);return Ext.id()},categoryContentRenderer:function(d,c,a){for(var b=0;b<this.categoryArray.length;b++){if(this.categoryArray[b]==d){return'<span class="'+this.categoryStyleClass[b]+'">'+this.categoryString[b]+"</span>"}}SYNO.Debug("unexpected category:",d);return"unknown"},moduleContentRenderer:function(d,c,a){for(var b=0;b<this.moduleArray.length;b++){if(this.moduleArray[b]==d){return this.moduleString[b]}}SYNO.Debug("unexpected module:",d);return"unknown"},reportContentRenderer:function(d,c,a){var b=Ext.util.Format.htmlEncode(d);return'<div ext:qtip="'+Ext.util.Format.htmlEncode(b)+'">'+b+"</div>"},selectionChangeHandler:function(){var a=this.getSelectionModel().getSelections();if(0===a.length){Ext.getCmp(this.deleteSelectedButtonID).disable()}else{Ext.getCmp(this.deleteSelectedButtonID).enable()}},dataChangedHandler:function(){var a=this.view.el.query(".contentwrapper");if(0===this.reportStore.getCount()){Ext.getCmp(this.exportButtonID).disable();a[0].style.height="100%"}else{Ext.getCmp(this.exportButtonID).enable();a[0].style.height=""}},onLoadReportHandler:function(){if(0===this.reportStore.getTotalCount()){Ext.getCmp(this.deleteSplitButtonID).disable()}else{Ext.getCmp(this.deleteSplitButtonID).enable()}},onBeforeStoreLoad:function(a,b){Ext.apply(b.params,{modules:this.getCheckedModule(),categories:this.getCheckedCategory()})},deleteReport:function(){var b=this.getSelectionModel().getSelections();var c=[];for(var a=0;a<b.length;a++){c.push(b[a].json.ID)}this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.Log",version:1,method:"delete",params:{data:c},callback:function(g,d,f,e){this.getEl().unmask();if(g){this.getPagingToolbar().doRefresh()}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.SDS.AV.getErrorString(d.code))}},scope:this})},massiveDeleteReport:function(a,b){this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.AntiVirus.Log",version:1,method:"delete_advanced",params:{modules:b,categories:a},callback:function(f,c,e,d){this.getEl().unmask();if(f){this.getPagingToolbar().doRefresh()}else{this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.SDS.AV.getErrorString(c.code))}},scope:this})},getCheckedCategory:function(){return this.getCheckedCheckboxes(this.categoryCheckBoxID,this.categoryArray)},reportFilter:function(){this.storeParam.modules=Ext.encode(this.getCheckedModule());this.storeParam.categories=Ext.encode(this.getCheckedCategory());this.getPagingToolbar().doRefresh()},getCheckedModule:function(){return this.getCheckedCheckboxes(this.moduleCheckBoxID,this.moduleArray)},getCheckedCheckboxes:function(c,d){var a=[];for(var b=0;b<d.length;b++){if(true===Ext.getCmp(c[b]).checked){a.push(d[b])}}return a},exportReport:function(){this.downloadWebAPI({webapi:{api:"SYNO.AntiVirus.Log",version:1,method:"export",callback:function(e,a,d,c){if(e){}else{var b=_T("common","error_system");if(a.code){b=this.utils.getError(a.code)}this.appWin.getMsgBox().alert(this.title,b)}this.refreshStore()}},scope:this})},onActivate:function(){this.getPagingToolbar().doRefresh()}});Ext.define("SYNO.SDS.AV.AVEventReportMassiveProcessWindow",{extend:"SYNO.SDS.ModalWindow",owner:null,isCheckboxHandling:false,parentPanel:null,deleteCategoryCheckBoxIDArray:null,deleteModuleCheckBoxIDArray:null,constructor:function(a){this.owner=a.owner;this.parentPanel=a.mainPanel;this.deleteCategoryCheckBoxIDArray=new Array(this.parentPanel.categoryArray.length);this.deleteModuleCheckBoxIDArray=new Array(this.parentPanel.moduleArray.length);this.callParent([Ext.apply(a,SYNO.LayoutConfig.fill({title:_TT("SYNO.SDS.AV.Instance","report","clear_data_window_title"),width:500,height:420,resizable:false,layout:"vbox",layoutConfig:{align:"stretch",pack:"start"},padding:20,items:[this.createDescriptionPanel(),this.createRulesPanel()],buttons:[{text:_T("common","cancel"),handler:this.onClickCancel,scope:this},{text:_T("common","ok"),btnStyle:"blue",id:this.okButtonID=Ext.id(),handler:this.onClickCommitClear,scope:this}]}))]);this.nothingCheckedChecker()},createDescriptionPanel:function(){return{xtype:"syno_panel",hideLabel:true,layout:"fit",border:false,padding:"0px 5px 5px 5px",height:41,items:[{xtype:"syno_displayfield",value:_TT("SYNO.SDS.AV.Instance","report","massive_report_clear_desc")}]}},createRulesPanel:function(){return{xtype:"syno_panel",hideLabel:true,layout:"vbox",layoutConfig:{align:"stretch",pack:"start",defaultMargins:{top:5,right:0,bottom:5,left:0}},border:false,flex:1,items:[this.createCategoryPanel(),this.createModulePanel()]}},createCategoryPanel:function(){return{xtype:"syno_fieldset",title:_TT("SYNO.SDS.AV.Instance","report","category"),layout:"column",padding:"0px 10px 0px 10px",defaults:{columnWidth:0.5},flex:5,cls:"syno-av-clear-category",items:[{xtype:"syno_checkbox",boxLabel:_TT("SYNO.SDS.AV.Instance","common","all"),id:this.cat_allID=Ext.id(),columnWidth:1,hideLabel:true,handler:this.onClickCheckAllCategoryCheckbox,scope:this},{xtype:"syno_checkbox",boxLabel:_TT("SYNO.SDS.AV.Instance","report","category_alert"),id:this.getDeleteCategoryID("warning"),hideLabel:true,handler:this.onClickCheckCategoryCheckbox,scope:this},{xtype:"syno_checkbox",boxLabel:_TT("SYNO.SDS.AV.Instance","report","category_err"),id:this.getDeleteCategoryID("error"),hideLabel:true,handler:this.onClickCheckCategoryCheckbox,scope:this},{xtype:"syno_checkbox",boxLabel:_TT("SYNO.SDS.AV.Instance","report","category_info"),id:this.getDeleteCategoryID("info"),hideLabel:true,handler:this.onClickCheckCategoryCheckbox,scope:this},{xtype:"syno_checkbox",boxLabel:_TT("SYNO.SDS.AV.Instance","report","category_detect"),id:this.getDeleteCategoryID("detected"),hideLabel:true,handler:this.onClickCheckCategoryCheckbox,scope:this}]}},createModulePanel:function(){return{xtype:"syno_fieldset",title:_TT("SYNO.SDS.AV.Instance","report","module"),layout:"column",padding:"0px 10px 0px 10px",defaults:{columnWidth:0.5},flex:4,items:[{xtype:"syno_checkbox",boxLabel:_TT("SYNO.SDS.AV.Instance","common","all"),id:this.mod_allID=Ext.id(),columnWidth:1,hideLabel:true,handler:this.onClickCheckAllModuleCheckbox,scope:this},{xtype:"syno_checkbox",boxLabel:_TT("SYNO.SDS.AV.Instance","report","mod_updater"),id:this.getDeleteModuleID("updater"),hideLabel:true,handler:this.onClickCheckModuleCheckbox,scope:this},{xtype:"syno_checkbox",boxLabel:_TT("SYNO.SDS.AV.Instance","report","mod_scanner"),id:this.getDeleteModuleID("scanner"),hideLabel:true,handler:this.onClickCheckModuleCheckbox,scope:this}]}},getDeleteCategoryID:function(a){return this.parentPanel.getTypeID(this.parentPanel.categoryArray,a,this.deleteCategoryCheckBoxIDArray)},getDeleteModuleID:function(a){return this.parentPanel.getTypeID(this.parentPanel.moduleArray,a,this.deleteModuleCheckBoxIDArray)},onClickCommitClear:function(){this.parentPanel.massiveDeleteReport(this.getCheckedDeleteCategory(),this.getCheckedDeleteModule());this.close()},onClickCancel:function(){this.close()},onClickCheckCategoryCheckbox:function(){this.checkboxCheckHandler(this.deleteCategoryCheckBoxIDArray,this.cat_allID);this.nothingCheckedChecker()},onClickCheckAllCategoryCheckbox:function(){this.checkboxCheckAllHandler(this.deleteCategoryCheckBoxIDArray,this.cat_allID);this.nothingCheckedChecker()},onClickCheckModuleCheckbox:function(){this.checkboxCheckHandler(this.deleteModuleCheckBoxIDArray,this.mod_allID);this.nothingCheckedChecker()},onClickCheckAllModuleCheckbox:function(){this.checkboxCheckAllHandler(this.deleteModuleCheckBoxIDArray,this.mod_allID);this.nothingCheckedChecker()},getCheckedDeleteCategory:function(){return this.parentPanel.getCheckedCheckboxes(this.deleteCategoryCheckBoxIDArray,this.parentPanel.categoryArray)},getCheckedDeleteModule:function(){return this.parentPanel.getCheckedCheckboxes(this.deleteModuleCheckBoxIDArray,this.parentPanel.moduleArray)},checkboxCheckHandler:function(d,b){var a=true;if(!this.isCheckboxHandling){this.isCheckboxHandling=true;for(var c=0;c<d.length;c++){if(false===Ext.getCmp(d[c]).getValue()){a=false}}if(true===a){Ext.getCmp(b).setValue(true)}else{Ext.getCmp(b).setValue(false)}this.isCheckboxHandling=false}},isNothingChecked:function(b){var c=true;for(var a=0;a<b.length;a++){if(true===Ext.getCmp(b[a]).getValue()){c=false;break}}return c},nothingCheckedChecker:function(){var b=this.isNothingChecked(this.deleteCategoryCheckBoxIDArray);var a=this.isNothingChecked(this.deleteModuleCheckBoxIDArray);if(b||a){Ext.getCmp(this.okButtonID).disable()}else{Ext.getCmp(this.okButtonID).enable()}},checkboxCheckAllHandler:function(d,a){var c=false;if(!this.isCheckboxHandling){this.isCheckboxHandling=true;c=Ext.getCmp(a).getValue();for(var b=0;b<d.length;b++){Ext.getCmp(d[b]).setValue(c)}this.isCheckboxHandling=false}}});Ext.define("SYNO.SDS.AV.AVPanelScheduleScan",{extend:"SYNO.ux.Panel",constructor:function(a){this.app=a.appWin;var b=this.fillConfig(a);this.callParent([b])},getGridPanel:function(){return new SYNO.SDS.AV.AVPanelScheduleScanGrid({app:this.app})},fillConfig:function(a){var b={border:false,itemId:"schedulescan",layout:"fit",items:[this.panel=this.getGridPanel()]};return b},onPageActivate:function(){this.panel.onActivate()}});Ext.define("SYNO.SDS.AV.AVPanelScheduleScanGrid",{extend:"SYNO.ux.EditorGridPanel",scheduleStore:null,cm:null,enableColumn:null,constructor:function(b){this.app=b.app;this.scheduleStore=this.createStore(b);this.enableColumn=new SYNO.ux.EnableColumn({header:_TT("SYNO.SDS.AV.Instance","schedule_scan","activated"),dataIndex:"activated",width:80,hideable:false,menuDisabled:true,align:"center"});this.cm=this.createColumnModel();var a={header:false,border:false,frame:false,itemId:"editorGridPanel",ds:this.scheduleStore,cm:this.cm,cls:"without-dirty-red-grid",plugins:[this.enableColumn],enableHdMenu:false,viewConfig:{forceFit:true,emptyText:['<div class="syno-dataview">','<div class="empty-text-wrap">','<div class="empty-text-inner-wrap">','<div class="empty-text-icon"></div>','<div class="empty-text">',_JSLIBSTR("extlang","pagenodata"),"</div>","</div>","</div>","</div>"].join("")},loadMask:true,stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:false}),tbar:{defaults:{xtype:"syno_button"},items:[{text:_TT("SYNO.SDS.AV.Instance","schedule_scan","add_job"),itemId:"add",id:this.addJobButtonID=Ext.id(),scope:this,handler:this.onClickAddJob},{text:_TT("SYNO.SDS.AV.Instance","schedule_scan","edit_job"),itemId:"edit",id:this.editJobButtonID=Ext.id(),scope:this,handler:this.onClickEditJob},{text:_TT("SYNO.SDS.AV.Instance","schedule_scan","delete_job"),itemId:"delete",id:this.deleteJobButtonID=Ext.id(),scope:this,handler:this.onClickDeleteJob}]}};Ext.apply(a,b);SYNO.LayoutConfig.fill(a);this.callParent([a]);this.getSelectionModel().on("selectionchange",this.selectionChangeHandler,this);this.getSelectionModel().fireEvent("selectionchange")},createStore:function(a){return new SYNO.API.JsonStore({appWindow:a.app,api:"SYNO.AntiVirus.Schedule",method:"load",version:1,totalProperty:"jobCount",root:"scheduleScanJobs",fields:[{name:"activated"},{name:"triggerTime"},{name:"scanType"},{name:"scanTarget"}],listeners:{update:this.dataUpdateHandler,datachanged:this.contentWrapperResize,scope:this},autoLoad:true,autoDestroy:true,remoteSort:false})},createColumnModel:function(){return new Ext.grid.ColumnModel([this.enableColumn,{header:_TT("SYNO.SDS.AV.Instance","schedule_scan","trigger_time"),dataIndex:"triggerTime",hideable:false,menuDisabled:true,width:250,renderer:this.getTriggerTimeRenderer(),scope:this},{header:_TT("SYNO.SDS.AV.Instance","schedule_scan","job_type"),dataIndex:"scanType",hideable:false,menuDisabled:true,width:120,renderer:this.getScanTypeRenderer(),scope:this}])},getScanTypeRenderer:function(){var a=function(b){if(b=="fullScan"){return _TT("SYNO.SDS.AV.Instance","overview","full_scan")}else{if(b=="sysScan"){return _TT("SYNO.SDS.AV.Instance","overview","sys_scan")}else{if(b=="customScan"){return _TT("SYNO.SDS.AV.Instance","overview","custom_scan")}else{return"error scan"}}}};return a},getTriggerTimeRenderer:function(){var b=function(d){var c="";var e=[];if(d=="0,1,2,3,4,5,6"){c=_T("schedule","schedule_daily")}else{if(d=="0,6"){c=_T("schedule","schedule_weekend")}else{if(d=="1,2,3,4,5"){c=_T("schedule","schedule_weekdays")}else{c=d;c=c.replace("0",_T("schedule","schedule_sun"));c=c.replace("1",_T("schedule","schedule_mon"));c=c.replace("2",_T("schedule","schedule_tue"));c=c.replace("3",_T("schedule","schedule_wed"));c=c.replace("4",_T("schedule","schedule_thu"));c=c.replace("5",_T("schedule","schedule_fri"));c=c.replace("6",_T("schedule","schedule_sat"));e=c.split(",");c=e.join(", ")}}}return c};var a=function(h,f){var c="";var e=h.split(":");var d=String.format("{0}:{1}",this.Convert2Digits(e[1]),this.Convert2Digits(e[2]));var g=SYNO.SDS.DateTimeFormatter(Date.parseDate(d,"H:i"),{type:"time"});c=String.format("{0} {1}",b(e[0]),g);return c};return a},onClickAddJob:function(){var a=new SYNO.SDS.AV.AVScheduleScanEditorWindow({owner:this.app,ds:this.scheduleStore,caller:this});a.open()},onClickEditJob:function(){var a=this.getSelectionModel().getSelections();var c=a[0];var b=new SYNO.SDS.AV.AVScheduleScanEditorWindow({owner:this.app,ds:this.scheduleStore,caller:this,rec:c});b.open()},onClickDeleteJob:function(){var a=this.getSelectionModel().getSelections();for(var b=0;b<a.length;b++){this.scheduleStore.remove(a[b])}this.applyChange()},applyChange:function(){this.contentWrapperResize();var a=[];var b=this.scheduleStore.data.items;for(var c=0;c<b.length;c++){a.push(b[c].data)}this.scheduleStore.commitChanges();this.sendWebAPI({api:"SYNO.AntiVirus.Schedule",version:1,method:"save",params:{scanJobArray:a},callback:function(g,d,f,e){},scope:this})},Convert2Digits:function(a){if(a<10){return"0"+a.toString()}else{return a.toString()}},dataUpdateHandler:function(){this.applyChange()},selectionChangeHandler:function(){var a=this.getSelectionModel().getSelections();if(0===a.length){Ext.getCmp(this.editJobButtonID).disable();Ext.getCmp(this.deleteJobButtonID).disable()}else{if(1===a.length){Ext.getCmp(this.editJobButtonID).enable();Ext.getCmp(this.deleteJobButtonID).enable()}else{Ext.getCmp(this.editJobButtonID).disable();Ext.getCmp(this.deleteJobButtonID).enable()}}},onActivate:function(){this.scheduleStore.load();this.scheduleStore.commitChanges();this.scheduleStore.fireEvent("save")},contentWrapperResize:function(){var a=this.view.el.query(".contentwrapper");if(0===this.scheduleStore.getCount()){a[0].style.height="100%"}else{a[0].style.height=""}}});Ext.define("SYNO.SDS.AV.AVScheduleScanEditorWindow",{extend:"SYNO.SDS.ModalWindow",owner:null,parentStore:null,formPanelID:null,dayComboID:null,hourComboID:null,minComboID:null,refStoreIndex:null,handleRecord:null,scanTarget:"",FIRST_COLUMN_WIDTH:220,constructor:function(a){this.parentStore=a.ds;this.owner=a.owner;this.caller=a.caller;this.panel=SYNO.LayoutConfig.fill(this.createPanel(a.rec));this.callParent([Ext.apply(a,{title:_TT("SYNO.SDS.AV.Instance","schedule_scan","schedule_editor_title"),cls:"synoav-schedule-scan-editorwindow",width:470,autoHeight:true,padding:"16px 20px 16px 20px",resizable:false,layout:"fit",closeAction:"onClickClose",items:[this.panel],buttons:[{text:_T("common","cancel"),scope:this,handler:this.onClickClose},{text:_T("common","apply"),btnStyle:"blue",id:this.okButtonID=Ext.id(),scope:this,handler:this.onClickApply}]})]);if(!Ext.isEmpty(a.rec)){this.handleRecord=a.rec;this.scanTarget=this.handleRecord.get("scanTarget");Ext.getCmp(this.selectTargetButtonID).setText(_TT("SYNO.SDS.AV.Instance","scanning","reselect_directory"))}else{this.handleRecord=null;Ext.getCmp(this.selectTargetButtonID).setText(_TT("SYNO.SDS.AV.Instance","scanning","select_directory"))}this.onSelectScanTypeRadio()},createPanel:function(b){var a=Ext.isEmpty(b)?"fullScan":b.get("scanType");var c={xtype:"syno_formpanel",cls:"synoav-schedule-scan-editorwindow-formpanel",border:false,trackResetOnLoad:true,id:this.formPanelID=Ext.id(),layout:"vbox",layoutConfig:{align:"stretch",pack:"start"},items:[{xtype:"syno_radio",name:"scanType",cls:"synoav-schedule-scan-editorwindow-fullscan",itemId:"fullScan",inputValue:"fullScan",boxLabel:_TT("SYNO.SDS.AV.Instance","overview","full_scan"),checked:("fullScan"==a),handler:this.onSelectScanTypeRadio,scope:this},{xtype:"syno_radio",name:"scanType",cls:"synoav-schedule-scan-editorwindow-sysscan",itemId:"sysScan",inputValue:"sysScan",boxLabel:_TT("SYNO.SDS.AV.Instance","overview","sys_scan"),checked:("sysScan"==a),handler:this.onSelectScanTypeRadio,scope:this},this.createCustomScanPanel(b),this.createScanDatePanel(b),this.createScanTimePanel(b)]};if(!SYNO.SDS.AV.hasRecommendedMemSize()){c.items.push({xtype:"syno_compositefield",items:[{xtype:"syno_displayfield",cls:"synoav-note-label",value:_T("common","note")+_T("common","colon")},{xtype:"syno_displayfield",flex:1,autoHeight:true,value:_TT("SYNO.SDS.AV.Instance","ui_message","schedule_note")}]})}return c},createCustomScanPanel:function(b){var a=Ext.isEmpty(b)?"fullScan":b.get("scanType");return{xtype:"panel",cls:"synoav-schedule-scan-editorwindow-customscan",border:false,layout:"column",items:[{xtype:"syno_radio",name:"scanType",itemId:"customScan",inputValue:"customScan",width:this.FIRST_COLUMN_WIDTH,boxLabel:_TT("SYNO.SDS.AV.Instance","overview","custom_scan"),checked:("customScan"==a),handler:this.onSelectScanTypeRadio,scope:this},{xtype:"syno_button",text:_TT("SYNO.SDS.AV.Instance","scanning","select_directory"),width:200,id:this.selectTargetButtonID=Ext.id(),handler:this.onClickSelectTarget,scope:this}]}},createScanDatePanel:function(a){var b=Ext.isEmpty(a)?"0,1,2,3,4,5,6":a.get("triggerTime").split(":")[0];return{xtype:"panel",border:false,layout:"column",cls:"synoav-schedule-scan-editorwindow-scandate",items:[{xtype:"syno_displayfield",width:this.FIRST_COLUMN_WIDTH,value:_TT("SYNO.SDS.AV.Instance","scanning","schedule_date")},new SYNO.ux.ScheduleField({name:"date",fieldLabel:_T("time","time_date"),id:this.dayComboID=Ext.id(),width:200,value:b,allowBlank:false,editable:false})]}},createScanTimePanel:function(a){var b=Ext.isEmpty(a)?[0,0]:a.get("triggerTime").split(":").slice(1);return{xtype:"panel",border:false,layout:"column",cls:"synoav-schedule-scan-editorwindow-scantime",items:[{xtype:"syno_displayfield",width:this.FIRST_COLUMN_WIDTH,value:_TT("SYNO.SDS.AV.Instance","scanning","schedule_time")},{xtype:"syno_combobox",name:"hour",id:this.hourComboID=Ext.id(),width:95,displayField:"display",valueField:"value",value:b[0],store:SYNO.SDS.AV.Tools.createTimeItemStore("hour")},{xtype:"syno_displayfield",width:10,style:"text-align: center;",value:":"},{xtype:"syno_combobox",name:"minute",id:this.minComboID=Ext.id(),width:95,displayField:"display",valueField:"value",value:b[1],store:SYNO.SDS.AV.Tools.createTimeItemStore("min")}]}},onClickApply:function(){var b=Ext.getCmp(this.formPanelID).getForm().findField("scanType").getGroupValue();var e=Ext.getCmp(this.dayComboID).getValue();var d=Ext.getCmp(this.hourComboID).getValue();var f=Ext.getCmp(this.minComboID).getValue();var a={activated:true,triggerTime:e+":"+d+":"+f,scanType:b,scanTarget:this.scanTarget};if(b!="customScan"){a.scanTarget=""}else{if(0===this.scanTarget.length){this.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),_TT("SYNO.SDS.AV.Instance","schedule_scan","empty_scantarget"));return}}if(false===this.isAnyScheduleOverlapped(this.parentStore,a,this.handleRecord)){if(null===this.handleRecord){var c=new this.parentStore.recordType(a);var g=this.parentStore.getCount();this.parentStore.insert(g,c);this.caller.applyChange()}else{this.handleRecord.beginEdit();this.handleRecord.set("triggerTime",a.triggerTime);this.handleRecord.set("scanType",a.scanType);this.handleRecord.set("scanTarget",a.scanTarget);this.handleRecord.endEdit()}this.close()}else{this.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),_TT("SYNO.SDS.AV.Instance","schedule_scan","duplicated_schedule"));return}},onClickClose:function(){var c=(Ext.isEmpty(this.handleRecord))?(this.scanTarget!==""):(this.scanTarget!=this.handleRecord.get("scanTarget"));var b=Ext.getCmp(this.formPanelID).getForm().isDirty();var a=c||b;if(!a){this.close();return}this.confirmLostChangePromise({save:this.onClickApply,dontSave:this.close,cancel:Ext.emptyFn},this)},onClickSelectTarget:function(){var a=this.scanTarget.split(";");var b=new SYNO.SDS.AV.AVCustomScanWindow({owner:this,caller:this,preCheckFolder:a});this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.sendWebAPI({api:"SYNO.Core.File",method:"list",version:1,params:{folder_path:"/",superuser:false,type:"dir"},scope:this,callback:function(f,c,e,d){if(f){if(Ext.isDefined(c.length)&&(0!==c.length)){b.open()}else{this.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),_TT("SYNO.SDS.AV.Instance","common","no_share_folder"))}}else{this.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(c.code))}this.getEl().unmask()}})},onSelectScanTypeRadio:function(){if("customScan"!=Ext.getCmp(this.formPanelID).getForm().findField("scanType").getGroupValue()){Ext.getCmp(this.selectTargetButtonID).disable()}else{Ext.getCmp(this.selectTargetButtonID).enable()}this.okButtonEnableChecker()},okButtonEnableChecker:function(){if("customScan"!=Ext.getCmp(this.formPanelID).getForm().findField("scanType").getGroupValue()){Ext.getCmp(this.okButtonID).enable()}else{if(""===this.scanTarget){Ext.getCmp(this.okButtonID).disable()}else{Ext.getCmp(this.okButtonID).enable()}}},onBeforeScanTargetSelectorWinClosed:function(){this.okButtonEnableChecker();if(""===this.scanTarget){Ext.getCmp(this.selectTargetButtonID).setText(_TT("SYNO.SDS.AV.Instance","scanning","select_directory"))}else{Ext.getCmp(this.selectTargetButtonID).setText(_TT("SYNO.SDS.AV.Instance","scanning","reselect_directory"))}},isAnyScheduleOverlapped:function(b,d,e){for(var c=0;c<b.getCount();c++){var a=b.getAt(c);if(a!=e){if(this.isScheduleOverlapped(a,d)){return true}}}return false},isScheduleOverlapped:function(g,k){var e=g.get("triggerTime").split(":");var h=e[0].split(",");var n=e[1];var d=e[2];var l=k.triggerTime.split(":");var m=l[0].split(",");var b=l[1];var a=l[2];if(n==b&&d==a){for(var f=0;f<h.length;f++){for(var c=0;c<m.length;c++){if(h[f]==m[c]){return true}}}}return false},commitCustomScanTarget:function(a){this.scanTarget="";for(var b=0;b<a.length;b++){this.scanTarget=this.scanTarget+a[b]+";"}this.scanTarget=this.scanTarget.substring(0,this.scanTarget.length-1)}});Ext.define("SYNO.SDS.AV.AVPanelVirusCodeUpdate",{extend:"SYNO.ux.FormPanel",updateStatusIconCSS:["syno-av-updater-icon-secure","syno-av-updater-icon-updating","syno-av-updater-icon-scanning","syno-av-updater-icon-warning","syno-av-updater-icon-checkupdatefail","syno-av-updater-icon-network-blocked","syno-av-updater-icon-volume-no-space","syno-av-updater-icon-update-network-blocked","syno-av-updater-icon-update-volume-no-space","syno-av-updater-icon-local-update-failed"],updateStatusIndex:["latest","updating","scanning","obsolete_dsm7","checkupdatefail","network_blocked","volume_no_space","update_network_blocked","update_volume_no_space","local_update_failed"],pollUpdateId:null,constructor:function(a){this.app=a.appWin;var b=this.fillConfig(a);this.callParent([b])},fillConfig:function(a){var b={xtype:"syno_panel",border:false,itemId:"viruscodeupdate",layout:"hbox",cls:"syno-av-updater-panel",layoutConfig:{align:"top",pack:"start"},items:[this.createUpdateIcon(),this.createUpdateMessagePanelConfig(),this.createUpdateButtonPanel()],listeners:{beforedestroy:function(){if(this.uploadDialog){this.uploadDialog.destroy()}},resize:function(){this.doLayout()}}};return SYNO.LayoutConfig.fill(b)},createUpdateMessagePanelConfig:function(){return{xtype:"syno_panel",border:false,layout:"vbox",cls:"syno-av-updater-msg-panel",padding:0,flex:1,margins:"20 0 0 0",layoutConfig:{align:"stretch",pack:"start"},items:[{xtype:"syno_displayfield",hideLabel:true,cls:"syno-av-updater-title-texts",id:this.updateStatusTitleID=Ext.id(),margins:"0 0 4 0",baseCls:"",autoHeight:true,value:_TT("SYNO.SDS.AV.Instance","updater","processing_in_progress")},{xtype:"syno_displayfield",hideLabel:true,cls:"syno-av-updater-normal-texts",id:this.updateDescriptionMessageID=Ext.id(),boxMinHeight:20,autoHeight:true,htmlEncode:false,value:String.format(_TT("SYNO.SDS.AV.Instance","updater","normal_updater_instruction_dsm7"),'<span class="syno-av-updater-normal-update-instruction">',"</span>")},{xtype:"syno_displayfield",hideLabel:true,cls:"syno-av-updater-normal-texts",id:this.patchDateTextID=Ext.id(),boxMinHeight:20,autoHeight:true,value:""}]}},createUpdateButtonPanel:function(){var a=[{xtype:"syno_button",margins:"10 12 0 0",text:_TT("SYNO.SDS.AV.Instance","updater","update_now"),scope:this,handler:this.onClickUpdateNow}];if(SYNO.SDS.AV.ENGTYPE=="ClamAV"){a.push({xtype:"syno_button",margins:"10 12 0 0",text:_TT("SYNO.SDS.AV.Instance","updater","manual_upload"),scope:this,handler:this.onClickManualUpload})}return{xtype:"syno_panel",border:false,layout:"vbox",id:this.updateButtonPanelID=Ext.id(),layoutConfig:{align:"stretchmax",pack:"start"},items:a}},createUpdateIcon:function(){return{xtype:"syno_panel",itemId:"iconPanel",cls:"syno-av-updater-icon",padding:0,margins:"22 20 0 0",id:this.updateStatusIconID=Ext.id(),hideLabel:true,border:false,height:48,width:48}},onClickUpdateNow:function(){this.stopPolling();this.setStatusUpdating();this.sendWebAPI({api:"SYNO.AntiVirus.General",version:1,method:"update",callback:function(d,a,c,b){this.startPolling(true);if(!d){this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(a.code))}},scope:this})},onClickManualUpload:function(){this.uploadDialog=new SYNO.SDS.AV.AVDialogManualUpload({});this.mon(this.uploadDialog,"close",function(a){if(a.isUpdatingWhenClosed){this.setStatusUpdating()}this.startPolling()},this,{single:true});this.uploadDialog.open();this.stopPolling()},setStatusUpdating:function(){Ext.getCmp(this.updateButtonPanelID).disable();Ext.getCmp(this.updateStatusTitleID).setValue(_TT("SYNO.SDS.AV.Instance","updater","updating"));Ext.getCmp(this.updateDescriptionMessageID).setValue(_TT("SYNO.SDS.AV.Instance","updater","no_update_while_updating"));this.setObjectStyle(Ext.getCmp(this.updateStatusIconID),"updating",this.updateStatusIconCSS)},setObjectStyle:function(d,b,a){var c=0;for(c=0;c<this.updateStatusIndex.length;c++){if(this.updateStatusIndex[c]!=b){d.removeClass(a[c])}else{d.addClass(a[c])}}},onPageActivate:function(){this.getEl().mask(_TT("SYNO.SDS.AV.Instance","common","processing"),"x-mask-loading");this.startPolling()},onPageDeactivate:function(){this.stopPolling()},startPolling:function(){if(this.pollUpdateId){return}this.pollUpdateId=this.app.pollReg({scope:this,webapi:{api:"SYNO.AntiVirus.General",version:1,method:"get_sys_info"},interval:3,immediate:true,status_callback:function(e,b,d,a){if(e){if("Unknown"!==b.releaseDate){var c=SYNO.SDS.DateTimeFormatter(Date.parseDate(b.releaseDate,"Y-n-d H:i"));Ext.getCmp(this.patchDateTextID).update(String.format(_TT("SYNO.SDS.AV.Instance","overview","release_date"),('<span class="syno-av-updater-release-date">'+c+"</span>")))}switch(b.sysStatus){case"updating":this.setStatusUpdating();break;case"preparing":case"scanning":Ext.getCmp(this.updateButtonPanelID).disable();Ext.getCmp(this.updateStatusTitleID).setValue(_TT("SYNO.SDS.AV.Instance","updater","scanning_in_progress"));Ext.getCmp(this.updateDescriptionMessageID).setValue(_TT("SYNO.SDS.AV.Instance","updater","no_update_while_scanning"));this.setObjectStyle(Ext.getCmp(this.updateStatusIconID),"scanning",this.updateStatusIconCSS);break;case"reprocessing":Ext.getCmp(this.updateButtonPanelID).disable();Ext.getCmp(this.updateStatusTitleID).setValue(_TT("SYNO.SDS.AV.Instance","updater","processing_in_progress"));Ext.getCmp(this.updateDescriptionMessageID).setValue(_TT("SYNO.SDS.AV.Instance","updater","no_update_while_processing"));this.setObjectStyle(Ext.getCmp(this.updateStatusIconID),"scanning",this.updateStatusIconCSS);break;case"installvirusdef":case"licenseexpired":case"licenseinvalid":case"mydserror":case"timeerror":case"infected":case"scan_failed":case"completed":case"danger":case"secure":case"update_failed":Ext.getCmp(this.updateButtonPanelID).enable();if("checkupdatefail"===b.updaterStatus||"network_blocked"===b.updaterStatus||"volume_no_space"===b.updaterStatus){Ext.getCmp(this.updateDescriptionMessageID).setValue(_TT("SYNO.SDS.AV.Instance","status_message",b.updaterStatus))}else{if("update_network_blocked"===b.updaterStatus||"update_volume_no_space"===b.updaterStatus){Ext.getCmp(this.updateDescriptionMessageID).setValue(String.format(_TT("SYNO.SDS.AV.Instance","status_message",b.updaterStatus),'<span class="syno-av-updater-normal-update-instruction">',"</span>"))}else{Ext.getCmp(this.updateDescriptionMessageID).setValue(String.format(_TT("SYNO.SDS.AV.Instance","updater","normal_updater_instruction_dsm7"),'<span class="syno-av-updater-normal-update-instruction">',"</span>"))}}Ext.getCmp(this.updateStatusTitleID).setValue(_TT("SYNO.SDS.AV.Instance","status",b.updaterStatus));this.setObjectStyle(Ext.getCmp(this.updateStatusIconID),b.updaterStatus,this.updateStatusIconCSS);break;case"local_update_failed":Ext.getCmp(this.updateButtonPanelID).enable();Ext.getCmp(this.updateStatusTitleID).setValue(_TT("SYNO.SDS.AV.Instance","status","updater_local_update_failed"));Ext.getCmp(this.updateDescriptionMessageID).setValue(_TT("SYNO.SDS.AV.Instance","status_message","updater_local_update_failed"));this.setObjectStyle(Ext.getCmp(this.updateStatusIconID),"local_update_failed",this.updateStatusIconCSS);break;default:SYNO.Debug("undefined system status");break}this.doLayout();this.getEl().unmask()}else{this.getEl().unmask();this.app.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(b.code))}}})},stopPolling:function(){if(!this.pollUpdateId){return}this.app.pollUnreg(this.pollUpdateId);this.pollUpdateId=null}});Ext.define("SYNO.SDS.AV.AVPurchaseWaitPanel",{extend:"SYNO.ux.Panel",caller:null,constructor:function(a){this.caller=a.caller;this.callParent([Ext.apply(a,{cls:"syno-av-purchasewindow",layout:"hbox",layoutConfig:{align:"middle",pack:"center"},border:false,items:[{xtype:"container",cls:"syno-av-purchase-connect",html:'<div class=\'\' style=\'display:table-cell;vertical-align:middle;\'><table cellspacing="0" style="width: auto;margin: auto;"><tbody><tr><td><div class="syno-av-connect-icon"></div></td><td>'+_TT("SYNO.SDS.AV.Instance","purchase","connecting")+"</td></tr></tbody></table></div>"}]})])}});Ext.define("SYNO.SDS.AV.AVPurchaseListPanel",{extend:"SYNO.ux.Panel",caller:null,radioGroupName:"synoav-purchaseList",constructor:function(a){this.caller=a.caller;this.callParent([Ext.apply(a,{cls:"syno-av-purchasewindow",itemId:"syno-av-purchaselist",layout:"vbox",border:false,layoutConfig:{align:"stretch",pack:"start"},items:[this.createTopDialogPanel(),this.createItemListPanel(),this.createPurchaseButtonPanel()]})])},createTopDialogPanel:function(){return{xtype:"syno_panel",border:false,height:60,id:this.TopDialogPanel=Ext.id(),cls:"syno-av-overview-purchasewindow-topdialog",html:_TT("SYNO.SDS.AV.Instance","purchase","purchase_desc")}},createItemListPanel:function(){var a={xtype:"syno_panel",border:false,flex:1,autoScroll:true,items:[{xtype:"syno_panel",border:false,layout:"fit",hidden:true,id:this.itemListPanel=Ext.id(),items:[{xtype:"radiogroup",hideLabel:true,cls:"syno-av-overview-purchasewindow-radiogroup",id:this.itemListRadioGroup=Ext.id(),border:false,items:[{labelWidth:200,labelPad:-200,columns:1,items:[]}]}]}]};return SYNO.LayoutConfig.fill(a)},createPurchaseButtonPanel:function(){return{xtype:"syno_panel",border:false,autoHeight:true,hidden:true,layout:"hbox",height:28,layoutConfig:{align:"middle",pack:"end"},id:this.PurchaseButtonPanel=Ext.id(),items:[{xtype:"syno_button",cls:"syno-av-purchase-button",text:_TT("SYNO.SDS.AV.Instance","purchase","btn_buynow"),btnStyle:"blue",scope:this,handler:this.doBuyButton}]}},doBuyButton:function(){this.caller.onNext(Ext.getCmp(this.itemListRadioGroup).items.get(0)[0].getGroupValue())},doPurchaseListLayout:function(b){if(!b){return}Ext.getCmp(this.TopDialogPanel).update(_TT("SYNO.SDS.AV.Instance","purchase","purchase_desc"));var a=Ext.util.JSON.decode(b.itemlist);var e=[];for(var c=0;c<a.item.length;c++){var g;g="<table><tbody><tr><td><div class='synoav-normalsale'>USD $"+a.item[c].price+"</div></td></tr></tbody></table>";var d={xtype:"syno_radio",boxLabel:a.item[c].name,fieldLabel:g,hideLabel:false,labelHtmlEncode:false,labelSeparator:"",width:438,checked:(0===c),inputValue:a.item[c].identify,name:this.radioGroupName};e.push(d)}var f=Ext.getCmp(this.itemListRadioGroup).panel.getComponent(0).add(e);Ext.getCmp(this.itemListRadioGroup).items.add(f);Ext.getCmp(this.itemListRadioGroup).syncSize();Ext.getCmp(this.itemListPanel).setHeight(a.item.length*35);Ext.getCmp(this.itemListPanel).setVisible(true);Ext.getCmp(this.PurchaseButtonPanel).setVisible(true);this.doLayout()},onGetPurchaseList:function(){this.sendWebAPI({api:"SYNO.AntiVirus.Purchase",version:1,method:"get_list",callback:function(d,a,c,b){if(d){this.ownerCt.layout.setActiveItem(this.ownerCt.get("syno-av-purchaselist"));this.doPurchaseListLayout(a)}else{Ext.getCmp(this.TopDialogPanel).update(_TT("SYNO.SDS.AV.Instance","purchase","connect_myds_failed"))}},scope:this})}});Ext.ns("SYNO.SDS.AV");SYNO.SDS.AV.RECOMMENDED_MEM_SIZE=1024;SYNO.SDS.AV.SYSTEM_MEM_SIZE=0;SYNO.SDS.AV.initSystemMemSize=function(){SYNO.API.Request({api:"SYNO.Core.System",version:1,method:"info",callback:function(d,a,c,b){if(d){SYNO.SDS.AV.SYSTEM_MEM_SIZE=a.ram_size}}})};SYNO.SDS.AV.hasRecommendedMemSize=function(){return(SYNO.SDS.AV.SYSTEM_MEM_SIZE>=SYNO.SDS.AV.RECOMMENDED_MEM_SIZE)};SYNO.SDS.AV.initSystemMemSize();SYNO.SDS.AV.MAINWINDOW_DEFAULT_WIDTH=990;SYNO.SDS.AV.MAINWINDOW_DEFAULT_HEIGHT=542;SYNO.SDS.AV.AVPlainTextRenderer=function(a){return Ext.util.Format.htmlEncode(a)};SYNO.SDS.AV.AVDateRenderer=function(a){return SYNO.SDS.DateTimeFormatter(Date.parseDate(a,"Y-n-d H:i:s"),{type:"datetimesec"})};SYNO.SDS.AV.AVGetPageStore=function(){var a=new Ext.data.SimpleStore({fields:["value","display"],data:[[20,20],[40,40],[60,60],[80,80],[100,100],[150,150],[200,200],[300,300],[400,400]]});return a};SYNO.SDS.AV.AVGetSmallPageStore=function(){var a=new Ext.data.SimpleStore({fields:["value","display"],data:[[10,10],[20,20],[40,40],[60,60],[80,80],[100,100],[200,200]]});return a};SYNO.SDS.AV.getErrorString=function(a){if(!Ext.isDefined(a)){return""}else{if(SYNO.API.Errors.minCustomeError>a){return SYNO.API.getErrorString(a)}else{if(401===a){return _TT("SYNO.SDS.AV.Instance","qerror","error_no_enough_space")}else{return _T("error","error_unknown_desc")}}}};Ext.ns("SYNO.SDS.AV.Tools");SYNO.SDS.AV.Tools.createTimeItemStore=function(e){var a=[];var c={hour:24,min:60,sec:60};if(e in c){for(var d=0;d<c[e];d++){a.push([d,String.leftPad(String(d),2,"0")])}var b=new Ext.data.SimpleStore({id:0,fields:["value","display"],data:a});return b}return null};SYNO.SDS.AV.TriTreeNodeUI_CHECKSTATE=2;SYNO.SDS.AV.TriTreeNodeUI_UNCHECKSTATE=1;SYNO.SDS.AV.TriTreeNodeUI_GRAYSTATE=0;SYNO.SDS.AV.TriTreeNodeUI_ARIATRISTATE=["mixed","false","true"];Ext.define("SYNO.SDS.AV.TriTreeNodeUI",{extend:"Ext.tree.TreeNodeUI",values:[null,false,true],checkedCls:["x-checkbox-grayed",null,"x-checkbox-checked"],checkboxCls:"x-checkbox",expanded:false,err:-1,constructor:function(){this.callParent(arguments)},initEvents:function(){this.callParent(arguments);this.node.on("expand",this.onTriTreeNodeExpand,this);if(this.checkbox){Ext.EventManager.on(this.checkbox,"click",this.toggleCheck,this);this.wrap.setAttribute("aria-checked",(this.checkbox.checked==="gray")?"mixed":this.checkbox.checked)}},destroy:function(){if(this.checkbox){Ext.EventManager.un(this.checkbox,"click",this.toggleCheck,this)}this.callParent(arguments)},getCheckIndex:function(b){for(var a=0;a<this.values.length;a++){if(b.getUI()&&b.getUI().checkbox&&b.getUI().checkbox.checked===this.values[a]){return a}}return this.err},clearCheck:function(){if(true===this.node.disabled){return}this.onCheckChange(SYNO.SDS.AV.TriTreeNodeUI_UNCHECKSTATE)},onCheckChange:function(a){this.checkbox.checked=this.values[a];this.checkbox.className=this.checkedCls[a];if(this.node.firstChild){this.updateChild(this.node.firstChild,a)}if(this.node.parentNode!=this.root){this.updateParent(this.node.parentNode,a)}var b=this.checkbox.checked;this.node.attributes.checked=b;this.wrap.setAttribute("aria-checked",this.checkbox.checked);this.fireEvent("checkchange",this.node,b)},toggleCheck:function(){if(true===this.node.disabled){return}var a=this.getCheckIndex(this.node);a=(a===SYNO.SDS.AV.TriTreeNodeUI_UNCHECKSTATE)?SYNO.SDS.AV.TriTreeNodeUI_CHECKSTATE:SYNO.SDS.AV.TriTreeNodeUI_UNCHECKSTATE;this.onCheckChange(a)},updateChild:function(b,a){var c=b;do{if(c.disabled){c=c.nextSibling;continue}if(c.getUI()&&c.getUI().checkbox){c.getUI().checkbox.checked=this.values[a];c.getUI().checkbox.className=this.checkedCls[a];c.getUI().wrap.setAttribute("aria-checked",SYNO.SDS.AV.TriTreeNodeUI_ARIATRISTATE[a])}if(c.firstChild){this.updateChild(c.firstChild,a)}c=c.nextSibling}while(c)},updateParent:function(d,a){var c=this.getCheckIndex(d);if(a!=c){var b=this.checkchildstate(d);if(d.getUI()&&d.getUI().checkbox){d.getUI().checkbox.checked=this.values[b];d.getUI().checkbox.className=this.checkedCls[b];d.getUI().wrap.setAttribute("aria-checked",SYNO.SDS.AV.TriTreeNodeUI_ARIATRISTATE[b])}if(d.parentNode!=this.root){this.updateParent(d.parentNode,b)}}},checkchildstate:function(b){var a=b.firstChild;if(!a){return this.err}while(a){if(SYNO.SDS.AV.TriTreeNodeUI_UNCHECKSTATE!==this.getCheckIndex(a)){return SYNO.SDS.AV.TriTreeNodeUI_GRAYSTATE}a=a.nextSibling}return SYNO.SDS.AV.TriTreeNodeUI_UNCHECKSTATE},renderElements:function(i,c,h,b){this.indentMarkup=i.parentNode?i.parentNode.ui.getChildIndent():"";var g,d=c.href?c.href:Ext.isGecko?"":"#",e=['<li class="x-tree-node"><div ext:tree-node-id="',Ext.util.Format.htmlEncode(i.id),'" class="x-tree-node-el x-tree-node-leaf x-unselectable ',c.cls,'" unselectable="on">','<span class="x-tree-node-indent">',this.indentMarkup,"</span>",'<img alt="" src="',this.emptyIcon,'" class="x-tree-ec-icon x-tree-elbow" />','<img alt="" src="',c.icon||this.emptyIcon,'" class="x-tree-node-icon',(c.icon?" x-tree-node-inline-icon":""),(c.iconCls?" "+c.iconCls:""),'" unselectable="on" />','<span><img alt="" src="'+this.emptyIcon+'" style="margin:0 2px 0 2px;" class="x-checkbox" /></span>','<a hidefocus="on" class="x-tree-node-anchor" href="',d,'" tabIndex="-1" ',c.hrefTarget?' target="'+c.hrefTarget+'"':"",'><span unselectable="on">',i.text,"</span></a></div>",'<ul class="x-tree-node-ct" style="display:none;"></ul>',"</li>"].join("");if(b!==true&&i.nextSibling&&(g=i.nextSibling.ui.getEl())){this.wrap=Ext.DomHelper.insertHtml("beforeBegin",g,e)}else{this.wrap=Ext.DomHelper.insertHtml("beforeEnd",h,e)}this.elNode=this.wrap.childNodes[0];this.ctNode=this.wrap.childNodes[1];var f=this.elNode.childNodes;this.indentNode=f[0];this.ecNode=f[1];this.iconNode=f[2];this.checkbox=f[3];if(c.checked==="checked"){this.checkbox.checked=this.values[SYNO.SDS.AV.TriTreeNodeUI_CHECKSTATE];this.checkbox.className=this.checkedCls[SYNO.SDS.AV.TriTreeNodeUI_CHECKSTATE]}else{if(c.checked==="gray"){this.checkbox.checked=this.values[SYNO.SDS.AV.TriTreeNodeUI_GRAYSTATE];this.checkbox.className=this.checkedCls[SYNO.SDS.AV.TriTreeNodeUI_GRAYSTATE]}else{this.checkbox.checked=this.values[SYNO.SDS.AV.TriTreeNodeUI_UNCHECKSTATE];this.checkbox.className=this.checkedCls[SYNO.SDS.AV.TriTreeNodeUI_UNCHECKSTATE]}}this.anchor=f[4];this.textNode=f[4].firstChild},onTriTreeNodeExpand:function(b){var a=this.getCheckIndex(b);if(a===SYNO.SDS.AV.TriTreeNodeUI_CHECKSTATE&&this.getCheckIndex(b.firstChild)!==SYNO.SDS.AV.TriTreeNodeUI_CHECKSTATE){this.updateChild(b.firstChild,a)}}});Ext.define("SYNO.SDS.AV.AVDialogManualUpload",{extend:"SYNO.SDS.ModalWindow",fileButtonID:null,passiveFileButtonID:null,isUpdatingWhenClosed:false,constructor:function(a){var b=Ext.apply({dsmStyle:"v5",title:_TT("SYNO.SDS.AV.Instance","updater","upload_dialog_title"),resizable:false,closable:true,width:600,height:350,useStatusBar:true,padding:"16px 20px 0px 20px",items:this.getItems(),layout:{type:"vbox",align:"stretch"},buttons:[{text:_T("common","cancel"),scope:this,handler:function(){this.close()}},{text:_T("common","apply"),scope:this,btnStyle:"blue",handler:this.onSubmit}]},a);this.callParent([b])},getItems:function(){var a=[];a.push(this.createUploadForm());a.push({xtype:"box",flex:1});a.push({xtype:"syno_displayfield",htmlEncode:false,value:_TT("SYNO.SDS.AV.Instance","updater","upload_dialog_learn_more")});a.push({xtype:"syno_displayfield",htmlEncode:false,value:String.format(_TT("SYNO.SDS.AV.Instance","updater","upload_dialog_notice"),'<font class="note-font"><b>',"</b></font> ")});return a},createUploadForm:function(){var a=this;var c=function(f){if(f===""){return}var e=this.fieldLabel.split(".").pop().toLowerCase();var d=f.split(".").pop().toLowerCase();if(e!=d){a.getMsgBox().alert("",_TT("SYNO.SDS.AV.Instance","updater","upload_dialog_alert_wrong_file_name"));this.reset()}};var b=new SYNO.SDS.Utils.FormPanel({itemId:"upload_form",fileUpload:true,trackResetOnLoad:true,frame:false,border:false,padding:"0px",webapi:{api:"SYNO.AntiVirus.General",method:"upload",version:1},items:[{xtype:"syno_displayfield",htmlEncode:false,value:_TT("SYNO.SDS.AV.Instance","updater","upload_dialog_instruction")},{xtype:"syno_filebutton",fieldLabel:"bytecode.cvd",id:this.bytecodeFileButtonID=Ext.id(),name:"bytecodeFile",listeners:{change:c}},{xtype:"syno_filebutton",fieldLabel:"daily.cvd",id:this.dailyFileButtonID=Ext.id(),name:"dailyFile",listeners:{change:c}},{xtype:"syno_filebutton",fieldLabel:"main.cvd",id:this.mainFileButtonID=Ext.id(),name:"mainFile",listeners:{change:c}}],onApiSuccess:Ext.createDelegate(this.onUploadSuccess,this),onApiFailure:Ext.createDelegate(this.onUploadFailed,this)});return b},onSubmit:function(){var a=this.get("upload_form");if(!a.get(this.bytecodeFileButtonID).getValue().startsWith("C:\\fakepath\\")||!a.get(this.dailyFileButtonID).getValue().startsWith("C:\\fakepath\\")||!a.get(this.mainFileButtonID).getValue().startsWith("C:\\fakepath\\")){this.getMsgBox().alert("",_TT("SYNO.SDS.AV.Instance","updater","upload_dialog_alert_missing_file"));return}this.setStatusBusy({text:_TT("SYNO.SDS.AV.Instance","updater","upload_dialog_status_uploading")});a.upload()},onUploadSuccess:function(d,c,b){var a=this;a.isUpdatingWhenClosed=true;a.clearStatusBusy();a.close()},onUploadFailed:function(d,c,b){var a=this;a.clearStatusBusy();a.getMsgBox().alert(_TT("SYNO.SDS.AV.Instance","app","app_name"),SYNO.API.getErrorString(c.code),function(){a.close()})}});