"""
Copyright (c) 2018-2021 VMware, Inc.  All rights reserved. -- VMware Confidential

Dummy vmware-horizon-html5mmr component.
"""

class VMwareHorizonHTML5MultiMediaRedirection(Installer):
   def InitializeQuestions(self, old, new, upgrade):
      if self.GetAnswer('html5mmrEnable'):
         qlevel = 'CUSTOM'
      else:
         qlevel = 'REGULAR'

      self.AddMultiChoiceQuestion('YesNo',
                                  key='html5mmrEnable',
                                  text='HTML5 Multimedia Redirection (HTML5MMR)',
                                  required=True,
                                  default='yes',
                                  footer='With html5 multimedia redirection (HTML5MMR), the html5 multimedia stream is processed on the client system.',
                                  level=qlevel)

   def InitializeInstall(self, old, new, upgrade):
      if self.GetAnswer('html5mmrEnable') == 'yes':
          self.AddTarget('File', 'lib/*', LIBDIR)
          self.SetPermission(LIBDIR/'vmware/view/html5mmr/*', BINARY)
          self.SetPermission(LIBDIR/'vmware/view/html5mmr/chrome-sandbox', SETUID)

      if (CONFDIR/'abortInstall').exists():
         raise InstallError('View abort install')

   def InitializeUninstall(self, old, new, upgrade):
      if (CONFDIR/'abortUninstall').exists():
         raise InstallError('View aborting uninstall')
      self.RunCommand('true', ignoreErrors=True)

   def PostInstall(self, old, new, upgrade):
      self.SetConfig('html5mmrComponent', 'test')
      if self.GetAnswer('html5mmrEnable') == 'yes':
         self.AddScanFile(LIBDIR/'vmware/view/html5mmr/HTML5VideoPlayer')

   def PostUninstall(self, old, new, upgrade):
      self.DelConfig('html5mmrComponent')
      self.DelConfig('html5Component')
