Ext.namespace("Zarafa.plugins.mdm");
Zarafa.plugins.mdm.MDM=Ext.extend(Zarafa.core.Plugin,{constructor:function(a){a=a||{};Zarafa.plugins.mdm.MDM.superclass.constructor.call(this,a);Zarafa.core.ModuleNames["IPM.MDM"]={list:"pluginmdmmodule",item:"pluginmdmmodule"}},initPlugin:function(){this.registerInsertionPoint("context.settings.categories",this.createSettingCategory,this);this.registerInsertionPoint("settings.versioninformation",this.createVersionInfo,this);Zarafa.core.data.SharedComponentType.addProperty("mdm.dialog.mdmdevicecontentpanel");Zarafa.core.data.SharedComponentType.addProperty("mdm.dialog.mdmmanagesharedfoldercontentpanel");
Zarafa.plugins.mdm.MDM.superclass.initPlugin.apply(this,arguments)},bidSharedComponent:function(a,b){var c=-1;switch(a){case Zarafa.core.data.SharedComponentType["mdm.dialog.mdmdevicecontentpanel"]:c=1;break;case Zarafa.core.data.SharedComponentType["mdm.dialog.mdmmanagesharedfoldercontentpanel"]:c=1}return c},getSharedComponent:function(a,b){var c;switch(a){case Zarafa.core.data.SharedComponentType["mdm.dialog.mdmdevicecontentpanel"]:c=Zarafa.plugins.mdm.dialogs.MDMDeviceContentPanel;break;case Zarafa.core.data.SharedComponentType["mdm.dialog.mdmmanagesharedfoldercontentpanel"]:c=
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel}return c},createSettingCategory:function(){return[{xtype:"Zarafa.plugins.mdm.mdmsettingscategory"}]},createVersionInfo:function(){var a=container.getSettingsModel().get("zarafa/v1/plugins/mdm/zpush-server-version",!0);return{fieldLabel:_("Z-Push","plugin_mdm"),value:a}}});Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"mdm",displayName:_("Mobile device management","plugin_mdm"),pluginConstructor:Zarafa.plugins.mdm.MDM}))});
Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.JsonDeviceFolderReader=Ext.extend(Zarafa.core.data.JsonReader,{customObjectType:Zarafa.core.data.RecordCustomObjectType.MDM_Device_Folder,constructor:function(a,b){a=Ext.applyIf(a||{},{id:"folderid",idProperty:"folderid",dynamicRecord:!1});Ext.isDefined(b)||(b=Zarafa.core.data.RecordFactory.getRecordClassByCustomType(a.customObjectType||this.customObjectType));Zarafa.plugins.mdm.data.JsonDeviceFolderReader.superclass.constructor.call(this,a,b)}});Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.JsonCertificateReader=Ext.extend(Zarafa.core.data.JsonReader,{constructor:function(a,b){a=Ext.applyIf(a||{},{dynamicRecord:!1});b=Zarafa.core.data.RecordFactory.getRecordClassByMessageClass("IPM.MDM");Zarafa.plugins.mdm.data.JsonCertificateReader.superclass.constructor.call(this,a,b)}});Ext.namespace("Zarafa.plugins.mdm");
Zarafa.plugins.mdm.data.MDMDeviceFolderRecordFields=[{name:"store",type:"string"},{name:"folderid",type:"string"},{name:"name",type:"string"},{name:"type",type:"int"},{name:"flags",type:"int"},{name:"entryid",type:"string"}];Zarafa.core.data.RecordCustomObjectType.addProperty("MDM_Device_Folder");Zarafa.core.data.RecordFactory.addFieldToCustomType(Zarafa.core.data.RecordCustomObjectType.MDM_Device_Folder,Zarafa.plugins.mdm.data.MDMDeviceFolderRecordFields);
Zarafa.core.data.RecordFactory.setBaseClassToCustomType(Zarafa.core.data.RecordCustomObjectType.MDM_Device_Folder,Zarafa.core.data.MAPIRecord);Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMDeviceFolderStore=Ext.extend(Zarafa.core.data.MAPISubStore,{constructor:function(a){a=a||{};Ext.applyIf(a,{autoLoad:!0,remoteSort:!1,reader:new Zarafa.plugins.mdm.data.JsonDeviceFolderReader,writer:new Zarafa.plugins.mdm.data.MDMDeviceFolderWriter,proxy:new Zarafa.core.data.IPMProxy({listModuleName:"pluginmdmmodule",itemModuleName:"pluginmdmmodule"})});Zarafa.plugins.mdm.data.MDMDeviceFolderStore.superclass.constructor.call(this,a)},addFolder:function(a){a=Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.MDM_Device_Folder,
{entryid:a.get("entryid")});this.add(a)},removeFolder:function(a){var b=this.findBy(function(b){return Zarafa.core.EntryId.compareEntryIds(b.get("entryid"),a.get("entryid"))});0<=b&&this.removeAt(b)}});Ext.reg("mdm.devicefolderstore",Zarafa.plugins.mdm.data.MDMDeviceFolderStore);Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMDeviceFolderWriter=Ext.extend(Zarafa.core.data.JsonWriter,{toPropHash:function(a){var b=a.getSubStore("sharedfolders");a={};if(!Ext.isDefined(b))return a;var c=b.getModifiedRecords(),b=b.getRemovedRecords();c.length&&(a.sharedfolders={},a.sharedfolders.add=c.map(function(a){return a.data}));b.length&&(a.sharedfolders=a.sharedfolders||{},a.sharedfolders.remove=b.map(function(a){return a.data}));return a}});Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMDeviceProxy=Ext.extend(Zarafa.core.data.MAPIProxy,{constructor:function(a){a=a||{};Ext.applyIf(a,{listModuleName:"pluginmdmmodule",itemModuleName:"pluginmdmmodule"});Zarafa.plugins.mdm.data.MDMDeviceProxy.superclass.constructor.call(this,a)},getResponseHandlerForRequest:function(a,b,c,e,d,f,k,g,h){return new Zarafa.plugins.mdm.data.MDMDeviceResponseHandler({proxy:this,action:c,reader:f,sendRecords:e,options:h,callback:k,scope:g})}});Ext.namespace("Zarafa.plugins.mdm");
Zarafa.plugins.mdm.data.MDMDeviceRecordFields=[{name:"entryid",type:"string"},{name:"devicetype",type:"string"},{name:"deviceos",type:"string"},{name:"devicefriendlyname",type:"string"},{name:"useragent",type:"string"},{name:"asversion",type:"string"},{name:"firstsynctime",type:"date",dateFormat:"timestamp"},{name:"lastsynctime",type:"date",dateFormat:"timestamp"},{name:"lastupdatetime",type:"date",dateFormat:"timestamp"},{name:"wipestatus",type:"string"},{name:"policyname",type:"string"},{name:"sharedfolders",
type:"string"},{name:"shortfolderids",type:"string"},{name:"synchronizedfolders",type:"string",defaultValue:"0"},{name:"emailsfolder",type:"string",defaultValue:"0"},{name:"contactsfolder",type:"string",defaultValue:"0"},{name:"tasksfolder",type:"string",defaultValue:"0"},{name:"calendarsfolder",type:"string",defaultValue:"0"},{name:"notesfolder",type:"string",defaultValue:"0"},{name:"koeversion",type:"string"},{name:"koebuild",type:"string"},{name:"koebuilddate",type:"date",dateFormat:"timestamp"},
{name:"message_class",type:"string",defaultValue:"IPM.MDM"}];Zarafa.plugins.mdm.data.MDMDeviceRecord=Ext.extend(Zarafa.core.data.IPMRecord,{});Zarafa.core.data.RecordFactory.addFieldToMessageClass("IPM.MDM",Zarafa.plugins.mdm.data.MDMDeviceRecordFields);Zarafa.core.data.RecordFactory.setBaseClassToMessageClass("IPM.MDM",Zarafa.plugins.mdm.data.MDMDeviceRecord);Zarafa.core.data.RecordFactory.setSubStoreToMessageClass("IPM.MDM","sharedfolders",Zarafa.plugins.mdm.data.MDMDeviceFolderStore);Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMDeviceResponseHandler=Ext.extend(Zarafa.core.data.ProxyResponseHandler,{doOpen:function(a){this.receivedRecords=this.readRecordsFromResponse(a,"item")},doList:function(a){this.receivedRecords=this.readRecordsFromResponse(a,"item")}});Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMDeviceStore=Ext.extend(Zarafa.core.data.ListModuleStore,{constructor:function(a){a=a||{};Ext.applyIf(a,{autoLoad:!0,remoteSort:!1,reader:new Zarafa.plugins.mdm.data.JsonCertificateReader,writer:new Zarafa.core.data.JsonWriter,proxy:new Zarafa.plugins.mdm.data.MDMDeviceProxy});Zarafa.plugins.mdm.data.MDMDeviceStore.superclass.constructor.call(this,a)}});Ext.reg("mdm.devicestore",Zarafa.plugins.mdm.data.MDMDeviceStore);Ext.namespace("Zarafa.hierarchy.data");
Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader=Ext.extend(Zarafa.hierarchy.data.HierarchyTreeLoader,{constructor:function(a){Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader.superclass.constructor.call(this,a)},createNode:function(a){var b=a.folder;b&&("rootfolder"===a.nodeType&&(a.extendedDisplayName=this.tree.hasFilter()),a.leaf=!b.get("has_subfolder"),a.uiProvider=Zarafa.plugins.mdm.ui.MDMFolderNodeUI,a.expanded=this.tree.isFolderOpened(b),a.allowDrag=!b.isDefaultFolder());return Zarafa.hierarchy.data.HierarchyTreeLoader.superclass.createNode.apply(this,
arguments)}});Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.MDMResponseHandler=Ext.extend(Zarafa.core.data.AbstractResponseHandler,{successCallback:Ext.emptyFn,failureCallback:Ext.emptyFn,doInfo:function(a){this.successCallback(a)},doRemove:function(a){a.remove&&this.successCallback()},doWipe:function(a){!0===a.wipe?container.getNotifier().notify("info.mdm",_("Mobile Device Manager"),_("Wiping device","plugin_mdm")):container.getNotifier().notify("info.mdm",_("Mobile Device Manager"),_("Password incorrect","plugin_mdm"))},doResync:function(a){!0===
a.resync&&container.getNotifier().notify("info.mdm",_("Mobile Device Manager"),_("Full resync in progress","plugin_mdm"))}});Ext.reg("mdm.responsehandler",Zarafa.plugins.mdm.data.MDMResponseHandler);Ext.namespace("Zarafa.plugins.mdm.data");
Zarafa.plugins.mdm.data.ProvisioningStatus=Zarafa.core.Enum.create({NOT_APPLICABLE:0,OK:1,WIPE_PENDING:2,WIPE_REQUESTED:4,WIPE_EXECUTED:8,getDisplayName:function(a){switch(a){case Zarafa.plugins.mdm.data.ProvisioningStatus.NOT_APPLICABLE:return _("Not Applicable","plugin_mdm");case Zarafa.plugins.mdm.data.ProvisioningStatus.OK:return _("Ok","plugin_mdm");case Zarafa.plugins.mdm.data.ProvisioningStatus.WIPE_PENDING:return _("Wipe Pending","plugin_mdm");case Zarafa.plugins.mdm.data.ProvisioningStatus.WIPE_REQUESTED:return _("Wipe Requested",
"plugin_mdm");case Zarafa.plugins.mdm.data.ProvisioningStatus.WIPE_EXECUTED:return _("Wipe Executed","plugin_mdm");default:return _("Not Available","plugin_mdm")}}});Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMDeviceContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};var b=a.record&&a.record.get("koeversion")?!0:!1;Ext.applyIf(a,{xtype:"mdmplugin.devicecontentpanel",modal:!0,title:dgettext("plugin_mdm",a.record.get("devicetype")),recordComponentPluginConfig:Ext.applyIf(a.recordComponentPluginConfig||{},{allowWrite:!0,useShadowStore:!0}),layout:"fit",stateful:!1,showInfoMask:!1,showLoadMask:!1,width:b?440:405,height:b?450:420,items:[{xtype:"mdmplugin.mdmdevicepanel",
record:a.record,isKoe:b,buttons:[{text:_("Ok"),handler:this.onOk,scope:this}]}]});Zarafa.plugins.mdm.dialogs.MDMDeviceContentPanel.superclass.constructor.call(this,a)},onOk:function(){this.close()}});Ext.reg("mdmplugin.devicecontentpanel",Zarafa.plugins.mdm.dialogs.MDMDeviceContentPanel);Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMDeviceDetailsTab=Ext.extend(Ext.form.FormPanel,{isKoe:!1,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"mdmplugin.mdmdevicedetailstab",cls:"tab-device",border:!1,labelAlign:"left",defaults:{border:!1,xtype:"panel",layout:"form",labelWidth:150},plugins:["zarafa.recordcomponentupdaterplugin"],items:[this.createDeviceInfoPanel(a.isKoe),this.createVersionInfoPanel(a.isKoe)]});a.isKoe&&a.items.push(this.createKOEInfoPanel(a.record));Zarafa.plugins.mdm.dialogs.MDMDeviceDetailsTab.superclass.constructor.call(this,
a)},createDeviceInfoPanel:function(a){return{cls:"mdm-device-panel",defaultType:"displayfield",defaults:{disabled:!0},items:[{cls:"mdm-display-name",value:dgettext("plugin_mdm","Device"),hideLabel:!0,disabled:!1},{fieldLabel:dgettext("plugin_mdm","Type"),name:"devicetype"},{fieldLabel:dgettext("plugin_mdm","Operating System"),hidden:a,name:"deviceos"},{fieldLabel:dgettext("plugin_mdm","ID"),name:"entryid"},{fieldLabel:dgettext("plugin_mdm","User Agent"),name:"useragent"}]}},createVersionInfoPanel:function(a){return{defaultType:"displayfield",
defaults:{disabled:!0},cls:"mdm-device-panel mdm-field-sep",items:[{cls:"mdm-display-name",value:dgettext("plugin_mdm","MDM Plugin"),htmlEncode:!0,hideLabel:!0,disabled:!1},{fieldLabel:dgettext("plugin_mdm","Active Sync Version"),name:"asversion"},{fieldLabel:dgettext("plugin_mdm","Z-Push Version"),value:container.getSettingsModel().get("zarafa/v1/plugins/mdm/zpush-server-version",!0)},{fieldLabel:dgettext("plugin_mdm","Short folder Ids"),name:"shortfolderids"},{fieldLabel:dgettext("plugin_mdm","Policy name"),
hidden:a,name:"policyname"}]}},createKOEInfoPanel:function(a){return{cls:"mdm-device-panel mdm-field-sep",defaults:{disabled:!0},defaultType:"displayfield",items:[{cls:"mdm-display-name",value:dgettext("plugin_mdm","Kopano Outlook Extension"),htmlEncode:!0,hideLabel:!0,disabled:!1},{fieldLabel:dgettext("plugin_mdm","Version"),name:"koeversion"},{fieldLabel:dgettext("plugin_mdm","Build"),name:"koebuild"},{fieldLabel:dgettext("plugin_mdm","Last updated"),value:String.format("{0}",(new Date(a.get("koebuilddate"))).format(_("d F Y, H:i")))}]}},
update:function(a,b){this.getForm().loadRecord(a)}});Ext.reg("mdmplugin.mdmdevicedetailstab",Zarafa.plugins.mdm.dialogs.MDMDeviceDetailsTab);Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMDeviceGeneralTab=Ext.extend(Ext.form.FormPanel,{isKoe:!1,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"mdmplugin.mdmdevicegeneraltab",cls:"tab-general",border:!1,labelAlign:"left",defaults:{border:!1,xtype:"panel",layout:"form",labelWidth:150,cls:"mdm-device-panel"},plugins:["zarafa.recordcomponentupdaterplugin"],items:[this.createDeviceInfoPanel(a),this.createFolderInfoPanel()]});Zarafa.plugins.mdm.dialogs.MDMDeviceGeneralTab.superclass.constructor.call(this,
a)},createDeviceInfoPanel:function(a){return{cls:"mdm-device-panel",defaultType:"displayfield",defaults:{disabled:!0},items:[{cls:"mdm-display-name",value:dgettext("plugin_mdm",a.record.get("devicetype")),htmlEncode:!0,disabled:!1,hideLabel:!0},{fieldLabel:dgettext("plugin_mdm","Connected since"),value:String.format("{0}",(new Date(a.record.get("firstsynctime"))).format(_("d F Y")))},{fieldLabel:dgettext("plugin_mdm","Last updated"),value:String.format(_("{0}"),(new Date(a.record.get("lastupdatetime"))).format(_("d F Y, H:i")))},
{fieldLabel:dgettext("plugin_mdm","Status"),hidden:a.isKoe,listeners:{afterrender:this.onAfterRenderStatus,scope:this}}]}},createFolderInfoPanel:function(){return{cls:"mdm-device-panel mdm-field-sep",defaultType:"displayfield",items:[{cls:"mdm-display-name",value:dgettext("plugin_mdm","Synchronize"),htmlEncode:!0,hideLabel:!0},{fieldLabel:dgettext("plugin_mdm","Folders"),disabled:!0,name:"synchronizedfolders"},{xtype:"fieldset",layout:"form",labelWidth:140,cls:"mdm-synchronize-panel",defaultType:"displayfield",
defaults:{labelSeparator:"",value:"0",disabled:!0},items:[{fieldLabel:_("Email"),name:"emailsfolder"},{fieldLabel:_("Calendar"),name:"calendarsfolder"},{fieldLabel:_("Contacts"),name:"contactsfolder"},{fieldLabel:_("Notes"),name:"notesfolder"},{fieldLabel:_("Tasks"),name:"tasksfolder"},this.createSharedFolderInfoPanel()]}]}},createSharedFolderInfoPanel:function(){return{xtype:"panel",border:!1,cls:"mdm-synchronize-shared-panel",height:50,disabled:!1,layout:{type:"hbox",align:"stretch",pack:"start"},
items:[{layout:"form",border:!1,items:[{xtype:"displayfield",fieldLabel:"Shared Folders",disabled:!0,name:"sharedfolders"}],flex:1},{xtype:"button",text:dgettext("plugin_mdm","Managed shared Folders"),cls:"mdm-managesharedfolder-button",listeners:{click:this.onClickManageSharedFolder,scope:this}}]}},update:function(a,b){this.getForm().loadRecord(a)},onAfterRenderStatus:function(a){var b=parseInt(this.record.get("wipestatus"));a.setValue(Zarafa.plugins.mdm.data.ProvisioningStatus.getDisplayName(b))},
onClickManageSharedFolder:function(){this.dialog.record.opened=!1;Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["mdm.dialog.mdmmanagesharedfoldercontentpanel"],void 0,{manager:Ext.WindowMgr,record:this.dialog.record})}});Ext.reg("mdmplugin.mdmdevicegeneraltab",Zarafa.plugins.mdm.dialogs.MDMDeviceGeneralTab);Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMDevicePanel=Ext.extend(Ext.Panel,{isKoe:!1,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"mdmplugin.mdmdevicepanel",cls:"mdm-devicepanel tabpanel-container",border:!1,deferredRender:!1,items:[{xtype:"tabpanel",border:!1,activeTab:0,layoutOnTabChange:!0,items:[{xtype:"mdmplugin.mdmdevicegeneraltab",record:a.record,title:dgettext("plugin_mdm","General"),isKoe:a.isKoe},{xtype:"mdmplugin.mdmdevicedetailstab",record:a.record,title:dgettext("plugin_mdm","Details"),isKoe:a.isKoe}]}]});
Zarafa.plugins.mdm.dialogs.MDMDevicePanel.superclass.constructor.call(this,a)}});Ext.reg("mdmplugin.mdmdevicepanel",Zarafa.plugins.mdm.dialogs.MDMDevicePanel);Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel=Ext.extend(Zarafa.core.ui.RecordContentPanel,{constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"mdm.managesharedfoldercontentpanel",layout:"fit",title:dgettext("plugin_mdm","Manage Shared Folder"),modal:!0,stateful:!1,showInfoMask:!1,showLoadMask:!1,closeOnSave:!0,width:300,height:350,items:[{xtype:"mdm.managesharedfolderpanel"}]});Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel.superclass.constructor.call(this,a)}});
Ext.reg("mdm.managesharedfoldercontentpanel",Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel);Ext.namespace("Zarafa.plugins.mdm.dialogs");
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel=Ext.extend(Ext.Panel,{sharedFoldersStore:void 0,record:null,constructor:function(a){a=a||{};Ext.applyIf(a,{xtype:"mdm.managesharedfolderpanel",layout:{type:"fit",align:"stretch"},border:!1,header:!1,items:[this.createTreePanel()],buttonAlign:"right",plugins:["zarafa.recordcomponentupdaterplugin"],buttons:[{text:_("Apply"),handler:this.onApply,cls:"zarafa-action",scope:this},{text:_("Cancel"),handler:this.onCancel,scope:this}]});Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel.superclass.constructor.call(this,
a)},createTreePanel:function(){return{xtype:"panel",layout:"form",defaults:{cls:"mdm-create-tree-panel-item"},border:!1,flex:1,items:[{xtype:"displayfield",hideLabel:!0,value:dgettext("plugin_mdm","Select folders to sync on your device")},{xtype:"mdm.hierarchytree",autoScroll:!0,hideOwnTree:!0,nodeConfig:{checked:!1},multiSelect:!0,hideShowAllFolders:!0,border:!0,treeSorter:!0,bbarConfig:{hidden:!0},enableDD:!1,anchor:"100% 90%",ref:"../hierarchyTree"}]}},initEvents:function(){Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel.superclass.initEvents.apply(this,
arguments);this.mon(this.hierarchyTree,{expandnode:this.onTreeNodeExpand,checkchange:this.onTreeNodeCheckChange,click:this.onTreeNodeClick,scope:this})},onTreeNodeExpand:function(){if(!this.record.isOpened())return!1;this.updateHierarchy()},update:function(a,b){this.record=a;this.sharedFoldersStore=a.getSubStore("sharedfolders");this.updateHierarchy()},updateHierarchy:function(){this.sharedFoldersStore.getRange().forEach(function(a){a=this.hierarchyTree.getNodeById(a.get("entryid"));Ext.isDefined(a)&&
(a.hasChildNodes()&&a.expand(),a.isNodeSelected=!0,a.getUI().toggleCheck(!0))},this)},onTreeNodeClick:function(a){var b=a.getUI();if(b.checkbox.checked&&a.isNodeSelected)return b.toggleCheck(!1),!1;a.isNodeSelected=!0;this.sharedFoldersStore.addFolder(a.getFolder());b.toggleCheck(!0)},onTreeNodeCheckChange:function(a,b){if(!b)a.isNodeSelected=!1,this.sharedFoldersStore.removeFolder(a.getFolder());else if(b&&!a.isNodeSelected)this.onTreeNodeClick(a)},onApply:function(){this.record.save()},onCancel:function(){this.dialog.close()}});
Ext.reg("mdm.managesharedfolderpanel",Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel);Ext.namespace("Zarafa.plugins.mdm.settings");Zarafa.plugins.mdm.settings.MDMSettingsCategory=Ext.extend(Zarafa.settings.ui.SettingsCategory,{constructor:function(a){a=a||{};Ext.applyIf(a,{title:_("MDM","plugin_mdm"),iconCls:"icon_mdm_settings",items:[{xtype:"Zarafa.plugins.mdm.mdmsettingswidget"}]});Zarafa.plugins.mdm.settings.MDMSettingsCategory.superclass.constructor.call(this,a)}});
Ext.reg("Zarafa.plugins.mdm.mdmsettingscategory",Zarafa.plugins.mdm.settings.MDMSettingsCategory);Ext.namespace("Zarafa.plugins.mdm.settings");
Zarafa.plugins.mdm.settings.MDMSettingsWidget=Ext.extend(Zarafa.settings.ui.SettingsWidget,{constructor:function(a){a=a||{};var b=new Zarafa.plugins.mdm.data.MDMDeviceStore;Ext.applyIf(a,{title:_("Mobile Devices","plugin_mdm"),items:[{xtype:"container",layout:"fit",items:[{xtype:"grid",name:_("Devices","plugin_mdm"),ref:"../deviceGrid",height:400,store:b,viewConfig:{forceFit:!0,deferEmptyText:!1,emptyText:'<div class="emptytext">'+_("No devices connected to your account","plugin_mdm")+"</div>"},columns:[{dataIndex:"devicetype",
header:_("Device","plugin_mdm"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"useragent",header:_("User Agent","plugin_mdm"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"wipestatus",header:_("Provisioning Status","plugin_mdm"),renderer:Zarafa.plugins.mdm.ui.Renderers.provisioningStatus},{dataIndex:"lastupdatetime",header:_("Last Update","plugin_mdm"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"entryid",header:_("Device ID","plugin_mdm"),renderer:Ext.util.Format.htmlEncode},{dataIndex:"deviceos",
header:_("Device OS","plugin_mdm"),hidden:!0,renderer:Ext.util.Format.htmlEncode},{dataIndex:"devicefriendlyname",header:_("Device Info","plugin_mdm"),hidden:!0,renderer:Ext.util.Format.htmlEncode},{dataIndex:"firstsynctime",header:_("First Sync time","plugin_mdm"),hidden:!0,renderer:Ext.util.Format.htmlEncode}],buttons:[{text:_("Wipe Device","plugin_mdm"),ref:"../../../wipeBtn",handler:this.onWipeBtn,scope:this},{text:_("Full resync","plugin_mdm"),ref:"../../../resyncBtn",handler:this.onFullResync,
scope:this},{text:_("Remove device","plugin_mdm"),ref:"../../../removeBtn",handler:this.onRemoveDevice,scope:this},{text:_("Refresh","plugin_mdm"),ref:"../../../refresh",handler:this.onRefresh,scope:this}],listeners:{rowdblclick:this.onRowDblClick,rowclick:this.onRowClick,scope:this}}]}]});Zarafa.plugins.mdm.settings.MDMSettingsWidget.superclass.constructor.call(this,a)},onWipeBtn:function(){Ext.MessageBox.show({title:_("Kopano WebApp","plugin_mdm"),msg:_("Do you really want to wipe your device?\n Enter your password to confirm.",
"plugin_mdm"),inputType:"password",icon:Ext.MessageBox.WARNING,buttons:Ext.MessageBox.YESNO,fn:this.onWipeDevice,prompt:!0,scope:this.deviceGrid}).getDialog().body.child("input").dom.type="password"},onWipeDevice:function(a,b){if("yes"===a){var c=this.getSelectionModel().getSelected();c&&container.getRequest().singleRequest("pluginmdmmodule","wipe",{deviceid:c.get("entryid"),password:b},new Zarafa.plugins.mdm.data.MDMResponseHandler)}},onFullResync:function(){var a=this.deviceGrid.getSelectionModel().getSelected();
a&&container.getRequest().singleRequest("pluginmdmmodule","resync",{deviceid:a.get("entryid")},new Zarafa.plugins.mdm.data.MDMResponseHandler)},onRemoveDevice:function(){var a=this.deviceGrid.getSelectionModel().getSelected();a&&container.getRequest().singleRequest("pluginmdmmodule","remove",{deviceid:a.get("entryid")},new Zarafa.plugins.mdm.data.MDMResponseHandler({successCallback:this.removeDone.createDelegate(this,[a],!0)}))},removeDone:function(a){a.getStore().remove(a)},onRefresh:function(){this.deviceGrid.getStore().load()},
onRowDblClick:function(a,b){var c=a.getStore().getAt(b);c.opened=!1;Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["mdm.dialog.mdmdevicecontentpanel"],void 0,{manager:Ext.WindowMgr,record:c})},onRowClick:function(a,b){var c=a.getStore().getAt(b);this.wipeBtn.setDisabled(!Ext.isDefined(c.get("wipestatus")))}});Ext.reg("Zarafa.plugins.mdm.mdmsettingswidget",Zarafa.plugins.mdm.settings.MDMSettingsWidget);Ext.namespace("Zarafa.plugins.mdm.ui");
Zarafa.plugins.mdm.ui.MDMFolderNodeUI=Ext.extend(Zarafa.hierarchy.ui.FolderNodeUI,{renderElements:function(a,b,c,e){this.indentMarkup=a.parentNode?a.parentNode.ui.getChildIndent():"";var d,f=Ext.isBoolean(b.checked),k=b.folder.isCalendarFolder(),g="";k&&(d=a.getOwnerTree().model,d||(d=container.getContextByName("calendar").getModel(),a.getOwnerTree().model=d),(d=d.getColorScheme(b.folder.get("entryid")))&&d.base&&(g='<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="15" height="13" viewBox="0 0 15 13" style="color:'+
d.base+'; position:relative; top:2px;"><g><g class="icbg" style="fill:currentColor;stroke:none"><rect width="15" height="12" x="0" y="1" /><rect width="1" height="1" x="2" y="0" /><rect width="1" height="1" x="7" y="0" /><rect width="1" height="1" x="12" y="0" /></g><path class="icgr" d="M 2.5,6.5 h 10 v 4 h -10 v -4.5 M 4.5,6.5 v 4 M 6.5,6.5 v 4 M 8.5,6.5 v 4 M 10.5,6.5 v 4 M 2.5,8.5 h 9.5" style="fill:currentColor;stroke:#ffffff;stroke-width:1;stroke-linejoin=miter" /></g></svg>'));d='<img src="'+
(b.icon||this.emptyIcon)+'" class="x-tree-node-icon" unselectable="on" />';var h,g='<li class="x-tree-node"><div ext:tree-node-id="'+a.id+'" class="x-tree-node-el x-tree-node-leaf x-unselectable zarafa-hierarchy-node" unselectable="on"><span class="x-tree-node-indent">'+this.indentMarkup+'</span><img src="'+this.emptyIcon+'" class="x-tree-ec-icon x-tree-elbow" />'+(f?'<input class="x-tree-node-cb zarafa-hierarchy-node-cb" type="checkbox" '+(b.checked?'checked="checked" />':"/>"):"")+(k?g:d)+'<a hidefocus="on" class="x-tree-node-anchor zarafa-hierarchy-node-anchor" href="'+
(b.href?b.href:Ext.isGecko?"":"#")+'" tabIndex="1" '+(b.hrefTarget?' target="'+b.hrefTarget+'"':"")+'><span unselectable="on">'+(a.tpl?a.tpl.apply(b):a.text)+'</span><span class="zarafa-hierarchy-node-counter" unselectable="on"></span><span class="zarafa-hierarchy-node-owner" unselectable="on"></span></a></div><ul class="x-tree-node-ct" style="display:none;"></ul></li>';!0!==e&&a.nextSibling&&(h=a.nextSibling.ui.getEl())?this.wrap=Ext.DomHelper.insertHtml("beforeBegin",h,g):this.wrap=Ext.DomHelper.insertHtml("beforeEnd",
c,g);this.elNode=this.wrap.childNodes[0];this.ctNode=this.wrap.childNodes[1];c=this.elNode.childNodes;this.indentNode=c[0];this.ecNode=c[1];this.iconNode=c[2];e=3;f&&(this.checkbox=c[2],this.iconNode=c[3],f=this.iconNode.childNodes[0],Ext.isDefined(f)&&(this.calendarSVGIconChilds=[f.childNodes[0].childNodes[0],f.childNodes[1]]),e++);this.anchor=c[e];this.textNode=c[e].firstChild;this.counterNode=c[e].firstChild.nextSibling;this.folderOwnerNode=this.counterNode.nextSibling;f=Ext.get(this.elNode);c=
Ext.get(this.iconNode);e=Ext.get(this.wrap);h=Ext.get(this.textNode);k&&h.addClass("zarafa-hierarchy-node-color");Ext.isEmpty(b.cls)||f.addClass(b.cls);b.icon&&c.addClass("x-tree-node-inline-icon");b.iconCls&&c.addClass(b.iconCls);Ext.isEmpty(b.containerCls)||e.addClass(b.containerCls);this.updateCounter(a);this.showFolderOwner(a)}});Ext.namespace("Zarafa.plugins.mdm.ui");
Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel=Ext.extend(Zarafa.hierarchy.ui.Tree,{constructor:function(a){Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel.superclass.constructor.call(this,a)},initComponent:function(){this.loader||(this.loader=new Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader({tree:this,store:this.store,nodeConfig:this.nodeConfig,deferredLoading:this.deferredLoading}));Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel.superclass.initComponent.apply(this,arguments)},nodeFilter:function(a){var b=
Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel.superclass.nodeFilter.apply(this,arguments);b&&this.hideOwnTree&&(b=!a.getMAPIStore().isDefaultStore());return b}});Ext.reg("mdm.hierarchytree",Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel);Ext.namespace("Zarafa.plugins.mdm.ui");Zarafa.plugins.mdm.ui.Renderers={provisioningStatus:function(a,b,c){return Zarafa.plugins.mdm.data.ProvisioningStatus.getDisplayName(parseInt(a))}};//# sourceMappingURL=mdm.js.map
