<?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script minSpecVersion='1'>
    <script>
var	PrivateFrameworksPath	= "/System/Library/PrivateFrameworks/";

var iLMBPath			= PrivateFrameworksPath + "iLifeMediaBrowser.framework";
var	iLMBMinVersion		= "0";
var iLMBMaxVersion		= "2.1.5";

var iLMBFolderPluginPath		= "/Library/Application Support/iLifeMediaBrowser/Plug-Ins/iLMBFolderPlugin.ilmbplugin";
var	iLMBFolderPluginMinVersion	= "0";
var	iLMBFolderPluginMaxVersion	= "2.1.5";

var iLSSPath			= PrivateFrameworksPath + "iLifeSlideshow.framework";
var iLSSMinVersion		= "1.0";
var iLSSMaxVersion		= "1.1";
</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='none' alignment='left'/>
    <options customize="never" rootVolumeOnly="true" hostArchitectures='ppc,i386'/>
    <platforms>
        <client arch="ppc,i386"/>
        <server arch="ppc,i386"/>
    </platforms>
    <!-- Software Update package layout -->
    <choices-outline ui='SoftwareUpdate'>
        <line choice='su'/>
    </choices-outline>
    <!-- This choice doesn't install anything, it just shows up if an update is needed. -->
    <choice id='su' title='SU_TITLE' versStr='SU_VERS' description='SU_DESCRIPTION' description-mime-type='text/html' secondaryDescription='SU_SERVERCOMMENT' suDisabledGroupID='iLifeSupport902' visible='needsILMBUpdate() || needsUpdate(iLSSPath,iLSSMinVersion,iLSSMaxVersion)'/>
    <!-- Software Update "tag along" package layout -->
    <choices-outline ui='invisible'>
        <line choice='iLMBsu'/>
        <line choice='iLMBsuSL'/>
        <line choice='iLSSsu'/>
        <line choice='iLSSsuSL'/>
    </choices-outline>
    <choice id="iLMBsu" selected="needsILMBUpdate() &amp;&amp; !isSnowLeopard() &amp;&amp; (typeof(choices.su) != &quot;undefined&quot;)">
        <pkg-ref id='iLMBsu' auth='Root' onConclusion="RequireRestart">iLifeMediaBrowser_215.pkg</pkg-ref>
    </choice>
    <choice id="iLMBsuSL" selected="needsILMBUpdate() &amp;&amp; isSnowLeopard() &amp;&amp; (typeof(choices.su) != &quot;undefined&quot;)">
        <pkg-ref id='iLMBsuSL' auth='Root'>iLifeMediaBrowser_215.pkg</pkg-ref>
    </choice>
    <choice id="iLSSsu" selected="needsUpdate(iLSSPath,iLSSMinVersion,iLSSMaxVersion) &amp;&amp; !isSnowLeopard() &amp;&amp; (typeof(choices.su) != &quot;undefined&quot;)">
        <pkg-ref id='iLSSsu' auth='Root' onConclusion="RequireRestart">iLifeSlideshow_11.pkg</pkg-ref>
    </choice>
    <choice id="iLSSsuSL" selected="needsUpdate(iLSSPath,iLSSMinVersion,iLSSMaxVersion) &amp;&amp; isSnowLeopard() &amp;&amp; (typeof(choices.su) != &quot;undefined&quot;)">
        <pkg-ref id='iLSSsuSL' auth='Root'>iLifeSlideshow_11.pkg</pkg-ref>
    </choice>
    <!-- Manual package layout -->
    <choices-outline>
        <line choice='iLMBman'/>
        <line choice='iLMBmanSL'/>
        <line choice='iLSSman'/>
        <line choice='iLSSmanSL'/>
    </choices-outline>
    <choice id="iLMBman" title="iLife Media Browser" selected="canHasUpdate(iLMBPath,iLMBMinVersion,iLMBMaxVersion) &amp;&amp; !isSnowLeopard()" enabled='false'>
        <pkg-ref id='iLMBman' auth='Root' onConclusion="RequireRestart">#iLifeMediaBrowser_215.pkg</pkg-ref>
    </choice>
    <choice id="iLMBmanSL" title="iLife Media Browser" selected="canHasUpdate(iLMBPath,iLMBMinVersion,iLMBMaxVersion) &amp;&amp; isSnowLeopard()" enabled='false'>
        <pkg-ref id='iLMBmanSL' auth='Root'>#iLifeMediaBrowser_215.pkg</pkg-ref>
    </choice>
    <choice id="iLSSman" title="iLife Slideshow" selected="canHasUpdate(iLSSPath,iLSSMinVersion,iLSSMaxVersion) &amp;&amp; !isSnowLeopard()" enabled='false'>
        <pkg-ref id='iLSSman' auth='Root' onConclusion="RequireRestart">#iLifeSlideshow_11.pkg</pkg-ref>
    </choice>
    <choice id="iLSSmanSL" title="iLife Slideshow" selected="canHasUpdate(iLSSPath,iLSSMinVersion,iLSSMaxVersion) &amp;&amp; isSnowLeopard()" enabled='false'>
        <pkg-ref id='iLSSmanSL' auth='Root'>#iLifeSlideshow_11.pkg</pkg-ref>
    </choice>
    <!-- SCRIPT stuff -->
    <installation-check script="InstallationCheck()"/>
    <script>
function InstallationCheck()
{
	return (goodOS() &amp;&amp; canUpdateStuff());
}

function goodOS()
{
	// If we don't have 10.5, give an error
	if (system.compareVersions(system.version.ProductVersion, "10.5") &lt; 0) 
	{
		my.result.title = system.localizedStringWithFormat('TITLE_OS_Tiger');
		my.result.message = system.localizedStringWithFormat('ERROR_OS_Tiger');
		my.result.type = 'Fatal';
		return false;
	}
	
	// If have 10.5 but not 10.5.6, suggest Software Update
	if (system.compareVersions(system.version.ProductVersion, "10.5.6") &lt; 0) 
	{
		my.result.title = system.localizedStringWithFormat('TITLE_OS_Leopard');
		my.result.message = system.localizedStringWithFormat('ERROR_OS_Leopard');
		my.result.type = 'Fatal';
		return false;
	}	
	
	// 10.5.6 or better is good. 
	return true;
}

function isSnowLeopard()
{
	return (system.compareVersions(system.version.ProductVersion, "10.6") >= 0);
}

function needsILMBUpdate()
{
	return (needsUpdate(iLMBPath,iLMBMinVersion,iLMBMaxVersion) ||
			needsUpdate(iLMBFolderPluginPath,iLMBFolderPluginMinVersion,iLMBFolderPluginMaxVersion));
}

function canHasILMBUpdate()
{
	return (canHasUpdate(iLMBPath,iLMBMinVersion,iLMBMaxVersion) ||
			canHasUpdate(iLMBFolderPluginPath,iLMBFolderPluginMinVersion,iLMBFolderPluginMaxVersion));
}

function canUpdateStuff()
{
	// if either update can be done, return true. No error.
	if (canHasILMBUpdate() || 
		canHasUpdate(iLSSPath,iLSSMinVersion,iLSSMaxVersion))
		return true;
	
	// Neither update can be applied. So we have to come up with a good error.
	
	// All too old
	if ((system.compareVersions(PathGetShortVersion(iLMBPath),iLMBMinVersion) &lt; 0) &amp;&amp;
		(system.compareVersions(PathGetShortVersion(iLMBFolderPluginPath),iLMBFolderPluginMinVersion) &lt; 0) &amp;&amp;
		(system.compareVersions(PathGetShortVersion(iLSSPath),iLSSMinVersion) &lt; 0))
	{
		my.result.title = system.localizedStringWithFormat('TITLE_tooOld');
		my.result.message = system.localizedStringWithFormat('ERROR_tooOld');
		my.result.type = 'Fatal';
		return false;
	}
		
	// All too new
	if ((system.compareVersions(PathGetShortVersion(iLMBPath),iLMBMaxVersion) > 0) &amp;&amp;
		(system.compareVersions(PathGetShortVersion(iLMBFolderPluginPath),iLMBFolderPluginMaxVersion) > 0) &amp;&amp;
		(system.compareVersions(PathGetShortVersion(iLSSPath),iLSSMaxVersion) > 0))
	{
		my.result.title = system.localizedStringWithFormat('TITLE_tooNew');
		my.result.message = system.localizedStringWithFormat('ERROR_tooNew');
		my.result.type = 'Fatal';
		return false;
	}
		
	// else mixed
	my.result.title = system.localizedStringWithFormat('TITLE_mixedFail');
	my.result.message = system.localizedStringWithFormat('ERROR_mixedFail');
	my.result.type = 'Fatal';
	return false;
}

function canHasUpdate(bundlePath, minVersionString, maxVersionString)
{
	return ((system.compareVersions(PathGetShortVersion(bundlePath),minVersionString) >= 0) &amp;&amp;
			(system.compareVersions(PathGetShortVersion(bundlePath),maxVersionString) &lt;= 0));
}

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 "0.0.0";
		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(".");
	}
</script>
    <localization>
        <strings language="pl"><![CDATA["SU_TITLE"			= "Obsługa iLife";
"SU_VERS"			= "9.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>
Zawiera zasoby systemowe, które są wykorzystywane w programach pakietu iLife oraz innych. 
To uaktualnienie poprawia ogólną stabilność Przeglądarki multimediów oraz pokazów slajdów iPhoto. 
Poprawia także zgodność Przeglądarki multimediów z programem Aperture 3. 
</p><p>
To uaktualnienie jest zalecane dla wszystkich użytkowników programów iLife ’09, iWork ’09 oraz Aperture.
</P>
</FONT> 
</BODY>
</HTML>
';
]]></strings>
    </localization>

	<pkg-ref id='iLMBsu' installKBytes='7864' version='2.1.5.1.1220381056'/>
	<pkg-ref id='iLMBsuSL' installKBytes='7864' version='2.1.5.1.1220381056'/>
	<pkg-ref id='iLSSsu' installKBytes='79781' version='1.1.1.1220381056'/>
	<pkg-ref id='iLSSsuSL' installKBytes='79781' version='1.1.1.1220381056'/>
</installer-gui-script>