# -*- coding: UTF-8 -*- from setuphelpers import * import json from cryptography.fernet import Fernet import os from jinja2 import Environment, FileSystemLoader uninstallkey = [] variables = { 'sogo_server': 'mail.server.local' } # Read local variables file if available if isfile(makepath(programfiles32,'wapt','private','symetric.txt')) and isfile(makepath(programfiles32,'wapt','private','variables.txt')): print('Reading local encrypted variables file') f = Fernet(open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read()) variables.update(json.loads(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read()))) def install(): connector_version = control['version'].split('-',1)[0] integrator_version = connector_version for extension in ['connector','integrator']: if isdir(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-%s@inverse.ca' % extension)): remove_tree(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-%s@inverse.ca' % extension)) mkdirs(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-%s@inverse.ca' % extension)) # connector can be extracted as is unzip('sogo-connector-%s.xpi' % connector_version, makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-connector@inverse.ca')) # Integrator must be customized, so first extract it unzip('sogo-integrator-%s-sogo-demo.xpi' % integrator_version, makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-integrator@inverse.ca')) # And replace the extensions.rdf content jinja2 = Environment( loader=FileSystemLoader(os.path.dirname(os.path.abspath(__file__))), trim_blocks=True ) open(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-integrator@inverse.ca','chrome','content','extensions.rdf'),'w').write( jinja2.get_template('extensions.rdf.j2').render( sogo_server = variables['sogo_server'] ) ) # Also remove custom settings os.unlink(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-integrator@inverse.ca','defaults','preferences','site.js')) def uninstall(): print('Removing SOGo extensions for Thunderbird') for extension in ['connector','integrator']: remove_tree(makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-%s@inverse.ca' % extension)) def audit(): connector_version = control['version'].split('-',1)[0] integrator_version = connector_version try: run('type "%s" | find /I "em:version=" | find "%s"' % (makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-connector@inverse.ca','install.rdf'), connector_version)) except: print('SOGO connector version check failed') return "ERROR" try: run('type "%s" | find /I "em:version=" | find "%s"' % (makepath(programfiles,'Mozilla Thunderbird','distribution','extensions','sogo-integrator@inverse.ca','install.rdf'), integrator_version)) except: print('SOGO integrator version check failed') return "ERROR" return "OK"