<?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script authoringTool="Packages" authoringToolVersion="1.2.10" authoringToolBuild="732" minSpecVersion="1.0">
    <options rootVolumeOnly="true" customize="never" hostArchitectures="x86_64" allow-external-scripts="true"/>
    <installation-check script="installation_check()"/>
    <volume-check script="volume_check()"/>
    <!--+==========================+
        |       Presentation       |
        +==========================+-->
    <title>DISTRIBUTION_TITLE</title>
    <background file="background" uti="public.png" scaling="proportional" alignment="bottomleft"/>
    <background-darkAqua file="background" uti="public.png" scaling="proportional" alignment="bottomleft"/>
    <license file="license.rtf"/>
    <!--+==========================+
        |         Installer        |
        +==========================+-->
    <choices-outline>
        <line choice="installer_choice_1"/>
    </choices-outline>
    <choice id="installer_choice_1" start_visible="false" start_enabled="false" start_selected="true" title="VoicemodApp" description="">
        <pkg-ref id="net.voicemod.desktop"/>
    </choice>
    <!--+==========================+
        |    Package References    |
        +==========================+-->
    <pkg-ref id="net.voicemod.desktop" version="1.2.1" auth="Root" installKBytes="15736">#VoicemodApp.pkg</pkg-ref>
    <!--+==========================+
        |    JavaScript Scripts    |
        +==========================+-->
    <script>

	const __IC_FLAT_DISTRIBUTION__=true;
	const IC_COMPARATOR_IS_EQUAL=0;
	const IC_COMPARATOR_IS_GREATER=1;
	const IC_COMPARATOR_IS_NOT_EQUAL=2;
	const IC_COMPARATOR_IS_LESS=-1;

	function IC_CheckScriptReturnValue(inScriptPath,inArguments,inComparator,inReturnValue)
	{
		var tReturnValue;
	
		if (inScriptPath.charAt(0)=='/')
		{
			/* Check Absolute Path Existence */
			
			if (system.files.fileExistsAtPath(inScriptPath)==false)
			{
				return false;
			}
		}
		else
		{
			if (__IC_FLAT_DISTRIBUTION__==true &amp;&amp; system.compareVersions(system.version.ProductVersion, '10.6.0')&lt;0)
			{
				system.log("[WARNING] Embedded scripts are not supported in Flat distribution format on Mac OS X 10.5");
          
				return true;
			}
		}
		
		if (inArguments.length&gt;0)
		{
			var tMethodCall;
			var tStringArguments=[];
			
			for(var i=0;i&lt;inArguments.length;i++)
			{
				tStringArguments[i]='inArguments['+i+']';
			}
			
			tMethodCall='system.run(inScriptPath,'+tStringArguments.join(',')+');';
			
			tReturnValue=eval(tMethodCall);
		}
		else
		{
			tReturnValue=system.run(inScriptPath);
		}
		
		if (tReturnValue==undefined)
		{
			return false;
		}
		
		if (inComparator==IC_COMPARATOR_IS_EQUAL)
		{
			return (tReturnValue==inReturnValue);
		}
		else if (inComparator==IC_COMPARATOR_IS_GREATER)
		{
			return (tReturnValue&gt;inReturnValue);
		}
		else if (inComparator==IC_COMPARATOR_IS_LESS)
		{
			return (tReturnValue&lt;inReturnValue);
		}
		else if (inComparator==IC_COMPARATOR_IS_NOT_EQUAL)
		{
			return (tReturnValue!=inReturnValue);
		}
		
		return false;
	}

	function installation_check()
	{
		var tResult;

		var tScriptArguments0=new Array('1.2.1');

		tResult=IC_CheckScriptReturnValue('check-avx.sh',tScriptArguments0,IC_COMPARATOR_IS_EQUAL,0);

		if (tResult==false)
		{
			my.result.title = system.localizedString('REQUIREMENT_FAILED_MESSAGE_INSTALLATION_CHECK_1');
			my.result.message = system.localizedString('REQUIREMENT_FAILED_DESCRIPTION_INSTALLATION_CHECK_1');
			my.result.type = 'Fatal';
		}

		if (tResult==true)
		{
			var tScriptArguments1=new Array('Intel',
			                             '1.2.1');

			tResult=IC_CheckScriptReturnValue('check-right-arch.sh',tScriptArguments1,IC_COMPARATOR_IS_EQUAL,0);

			if (tResult==false)
			{
				my.result.title = system.localizedString('REQUIREMENT_FAILED_MESSAGE_INSTALLATION_CHECK_2');
				my.result.message = system.localizedString('REQUIREMENT_FAILED_DESCRIPTION_INSTALLATION_CHECK_2');
				my.result.type = 'Fatal';
			}

			if (tResult==true)
			{
				var tScriptArguments2=new Array('1.2.1');

				tResult=IC_CheckScriptReturnValue('notifyOpen.sh',tScriptArguments2,IC_COMPARATOR_IS_EQUAL,0);

				if (tResult==false)
				{
					my.result.title = system.localizedStandardStringWithFormat('InstallationCheckError', system.localizedString('DISTRIBUTION_TITLE'));
					my.result.message = ' ';
					my.result.type = 'Warn';
				}
			}
		}

		return tResult;
	}

	function volume_check()
	{
		var tResult;

		var tScriptArguments0=new Array('1.2.1');

		tResult=IC_CheckScriptReturnValue('check-osx.sh',tScriptArguments0,IC_COMPARATOR_IS_EQUAL,0);

		if (tResult==false)
		{
			my.result.message = system.localizedString('REQUIREMENT_FAILED_MESSAGE_VOLUME_CHECK_3');
			my.result.type = 'Fatal';
		}

		return tResult;
	}

    </script>
</installer-gui-script>