<?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script minSpecVersion='1'>
    <script>
var	iDVDPath		= "/Applications/iDVD.app";
var iDVDMinVersion	= "7.0";
var iDVDMaxVersion	= "7.0.4";
</script>
    <!-- Installer UI-ey stuff -->
    <title>SU_TITLE</title>
    <welcome file="SUDescription.html"/>
    <license auto='false' file="License.rtf" sla="EA0502"/>
    <background file="background.tif" scaling="proportional" alignment="upperleft"/>
    <options customize="never" rootVolumeOnly="true" hostArchitectures='ppc,i386'/>
    <platforms>
        <client arch="i386,ppc"/>
        <server arch="i386,ppc"/>
    </platforms>
    <!-- Manual Install package layout -->
    <choices-outline>
        <line choice='manual'/>
    </choices-outline>
    <choice id='manual'>
        <pkg-ref auth='Root' id='manual'>.</pkg-ref>
    </choice>
    <choice id='manual' title='MANUAL_TITLE' versStr='SU_VERS'/>
    <!-- Software Update package layout -->
    <choices-outline ui='SoftwareUpdate'>
        <line choice='su'/>
    </choices-outline>
    <choice id='su' visible='needsUpdate(iDVDPath,iDVDMinVersion,iDVDMaxVersion)' start_selected='true' suDisabledGroupID='iDVD704' title='SU_TITLE' versStr='SU_VERS' description='SU_DESCRIPTION' description-mime-type='text/html' secondaryDescription='SU_SERVERCOMMENT'>
        <pkg-ref auth='Root' id='auto'>iDVD_704.pkg</pkg-ref>
    </choice>
    <!-- Installer logic -->
    <installation-check script="InstallationCheck()"/>
    <script>
	function InstallationCheck()
	{
		return (hasNoTier3() &amp;&amp; 
				hasGoodSSW() &amp;&amp; 
				hasGoodQT() &amp;&amp;
				canHasUpdateWithErrors(iDVDPath,iDVDMinVersion,iDVDMaxVersion,'noAppToUpdate','isDowngrade')
				);
	}

	function hasGoodSSW()
	{
		var sysVersion = system.version;
		
		if (!sysVersion || (1 == system.compareVersions("10.4.11",sysVersion.ProductVersion))) 
		{
			my.result.message = system.localizedStringWithFormat('systemTooOld');
			my.result.type = 'Fatal';
			return false;
		}
		
		if (1 == system.compareVersions("10.5",sysVersion.ProductVersion))
		{
			return true;
		}
		
		if (1 == system.compareVersions("10.5.6",sysVersion.ProductVersion))
		{
			my.result.message = system.localizedStringWithFormat('systemTooOld');
			my.result.type = 'Fatal';
			return false;
		}

		return true;
	}

	function hasNoTier3()
	{
		var path = "/var/db/.AppleTier3Language";
		if (!system.files.fileExistsAtPath(path) || ( system.compareVersions(system.version.ProductVersion, "10.5") >= 0))
			return true;
			
		my.result.message = system.localizedStringWithFormat('volumeHasTier3');
		my.result.type = 'Fatal';
		return false;
	}
		
	function hasGoodQT()
	{
        var path = "/System/Library/Frameworks/QuickTime.framework";
		var bundle = system.files.bundleAtPath(path);
		var version = BundleGetCompositeVersion5(bundle);
		
		if (!version || (system.compareVersions(version, "7.5.0.0.0") == -1))
		{
			my.result.message = system.localizedStringWithFormat('QTTooOld');
			my.result.type = 'Fatal';
			return false;
		}
				
		return true;
	}
	
	function canHasUpdateWithErrors(bundlePath, minVersionString, maxVersionString, minErrString, maxErrString)
	{
		var bundleVersion = PathGetShortVersion(bundlePath);
		if (!bundleVersion &amp;&amp; minVersionString &amp;&amp; (minVersionString != 0))
		{
			my.result.title = system.localizedStringWithFormat('TITLE_' + minErrString);
			my.result.message = system.localizedStringWithFormat('ERROR_' + minErrString);
			my.result.type = 'Fatal';
			return false;
		}
		
		if (system.compareVersions(bundleVersion,minVersionString) == -1)
		{
			my.result.title = system.localizedStringWithFormat('TITLE_' + minErrString);
			my.result.message = system.localizedStringWithFormat('ERROR_' + minErrString);
			my.result.type = 'Fatal';
			return false;
		}
		
		if (system.compareVersions(bundleVersion,maxVersionString) == 1)
		{
			my.result.title = system.localizedStringWithFormat('TITLE_' + maxErrString);
			my.result.message = system.localizedStringWithFormat('ERROR_' + maxErrString);
			my.result.type = 'Fatal';
			return false;
		}
		
		return true;
	}

	function needsUpdate(bundlePath, minVersionString, maxVersionString)
	{
		return ((system.compareVersions(PathGetShortVersion(bundlePath),minVersionString) >= 0)  &amp;&amp;
				(system.compareVersions(PathGetShortVersion(bundlePath),maxVersionString) &lt; 0));
	}
	</script>
    <!-- Common include -->
    <script>
	
	function PathGetShortVersion(path)
	{
		var bundle = system.files.bundleAtPath(path);
		if (bundle == null)
			return null;
		var shortVers = bundle.CFBundleShortVersionString;
		shortVers = _PadVersionString(shortVers, 3);
		return shortVers;
	}

	function _PadVersionString(version, tupleCount)
	{
		if (version == null)
			version = "0";
		var components = version.split(".");
		if (components.length > tupleCount)
			components = components.slice(0, tupleCount);
		else
			for (; components.length&lt;tupleCount; )
				components.push("0");
		return components.join(".");
	}

	function BundleGetCompositeVersion5(bundle)
	{
		if (bundle == null)
			return null;
		var shortVers = bundle.CFBundleShortVersionString;
		shortVers = _PadVersionString(shortVers, 3);
		var sourceVers = bundle.SourceVersion;
		sourceVers = _PadVersionString(sourceVers, 1);
		var buildVers = bundle.BuildVersion;
		buildVers = _PadVersionString(buildVers, 1);
		var fiveTupleVers = shortVers + "." + sourceVers + "." + buildVers;
		return fiveTupleVers;
	}

	function CheckNameRegistry(path, property, value)
	{
		try
		{
			var obj = system.ioregistry.fromPath(path);
			if (obj == null)
				return false;

			var propObj = obj[property];
			if (propObj == null)
				return false;

			if (typeof(propObj) == "string")	// string
			{
				return (propObj == value);
			}
			else if (typeof(propObj) == "object")	// array contains
			{
				for (var i=0; i&lt;propObj.length; i++)
					if (propObj[i] == value)
						return true;
			}
		}
		catch (e) {}

		return false;
	}
	</script>
    <localization>
        <strings language="pl"><![CDATA["SU_TITLE" = "Uaktualnienie iDVD";
"SU_VERS" = "7.0.4";
"SU_SERVERCOMMENT" = "Dla komputerów klienckich oraz serwerów.";

"SU_DESCRIPTION"='<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"></meta></HEAD>
<BODY><FONT FACE="Lucida Grande">
<P>
To uaktualnienie rozwiązuje ogólne zagadnienie zgodności oraz naprawia błąd polegający na niemożliwości dodania tytułu lub komentarza do obrazu na liście opisu obrazu..

To uaktualnienie jest zalecane dla wszystkich użytkowników iDVD 7.
</P>
</FONT></BODY></HTML>
';
]]></strings>
    </localization>
</installer-gui-script>