# -*- coding: utf-8 -*-
from setuphelpers import *

path = '/Applications/TeamViewer.app'
name = 'TeamViewer'

def install():
    install_dmg("TeamViewer.dmg")
    install_pkg("/Applications/Install TeamViewer.app/Contents/Resources/Install TeamViewer.pkg",key="pkgid:com.teamviewer.teamviewer",min_version=control.get_software_version())
    shutil.rmtree("/Applications/Install TeamViewer.app")


def uninstall():
    uninstall_pkg("com.teamviewer.teamviewerAgent")
    uninstall_pkg("com.teamviewer.teamviewer")
    uninstall_pkg("com.teamviewer.teamviewerPriviledgedHelper")
    uninstall_pkg("com.teamviewer.remoteaudiodriver")
    uninstall_pkg("com.teamviewer.teamviewerRestarter")
    uninstall_pkg("com.teamviewer.AuthorizationPlugin")
    uninstall_pkg("com.teamviewer.teamviewerEnforceUIVersion")
    uninstall_pkg("com.teamviewer.teamviewerUninstallerHelper")
    uninstall_pkg("TeamViewerUninstaller")
    uninstall_pkg("com.teamviewer.AuthorizationResources")
    uninstall_pkg("com.teamviewer.teamviewerUninstallerApp")

    shutil.rmtree("/Applications/TeamViewer.app")

def audit():
    if not isfile(f"{path}/Contents/MacOS/{name}"):
        print("erreur file not found")
        return "ERROR"
    else:
        return "OK"