<?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script minSpecVersion='1'>
    <title>SU_TITLE</title>
    <options hostArchitectures='ppc,i386' customize='never' rootVolumeOnly='true'/>
    <platforms>
        <client arch="ppc,i386"/>
        <server arch="ppc,i386"/>
    </platforms>
    <choices-outline>
        <line choice='manual'/>
    </choices-outline>
    <choices-outline ui='SoftwareUpdate'>
        <line choice='su'/>
    </choices-outline>
    <choice id='manual' title='SU_TITLE' versStr='SU_VERS'>
        <pkg-ref auth='Root' id='manual'>#BluetoothFirmwareUpdate2.0.1.pkg</pkg-ref>
    </choice>
    <choice id='su' suDisabledGroupID='BluetoothFirmwareUpdate2.0.1'>
        <pkg-ref auth='Root' id='com.apple.pkg.BluetoothFirmwareUpdate2.0.1'>BluetoothFirmwareUpdate2.0.1.pkg</pkg-ref>
    </choice>
    <choice id='su' visible='VisibleCheck()'/>
    <choice id='su' start_selected='true'/>
    <choice id='su' title='SU_TITLE' versStr='SU_VERS'/>
    <choice id='su' description='SU_DESCRIPTION' description-mime-type='text/html'/>
    <installation-check script='InstallationCheck()'/>
    <volume-check script='VolumeCheck()'/>
    <script>
	
	function InstallationCheck()
	{
		if( !isValidBTFirmware() )
		{
		    my.result.message = system.localizedStringWithFormat('ERR_HW');
		    my.result.type = 'Fatal';
		    return false;	       
		}
        
        	return true;	   
	}
	
	function VolumeCheck()
	{
		if( system.env.OS_INSTALL == 1 )
		{
		    return true;
		}

		if( !hasOS() || !hasOSVer() )
		{
		    my.result.message = system.localizedStringWithFormat('ERR_OS');
		    my.result.type = 'Fatal';
		    return false;	       
		}
		
		if( !isNotDowngrade() )
		{
		    my.result.message = system.localizedStringWithFormat('ERR_HW');
		    my.result.type = 'Fatal';
		    return false;	       
		}
		
		return true;
	}

    function VisibleCheck()
    {
        return ( isValidBTFirmwareUpdate() );
    }

    function hasOS()
    {
        return (system.files.fileExistsAtPath(my.target.mountpoint + "/System/Library/CoreServices/SystemVersion.plist"));
    }

    function hasOSVer()
    {
        if( -1 == system.compareVersions(my.target.systemVersion.ProductVersion, '10.5.7') )
	{
            return false;
        }
        return true;
    }
    
    function isValidBTFirmware()
    {
		var reg = system.ioregistry.matchingClass("IOUSBDevice")
		
		if( reg )
		{
			for( var i = 0; i &lt; reg.length; i++ )
			{
				var productID = reg[i].idProduct;
				var vendorID = reg[i].idVendor;
				var bcdDev = reg[i].bcdDevice;
				
				if(     (vendorID == 0x5AC) &amp;&amp; 
					( (productID == 0x8210 &amp;&amp; bcdDev &lt;= 0x180) ||
					 (productID == 0x820F &amp;&amp; bcdDev &lt;= 0x180 ) ||
					 (productID == 0x8212 &amp;&amp; bcdDev &lt;= 0x180) ||
					 (productID == 0x8213 &amp;&amp; bcdDev &lt;= 0x180) ||
					 (productID == 0x8215 &amp;&amp; bcdDev &lt;= 0x180 ) ||
					 (productID == 0x8216 &amp;&amp; bcdDev &lt;= 0x180) ||
					 (productID == 0x8217 &amp;&amp; bcdDev &lt;= 0x180 ) )
				  )
				{
					return true;
				}
			}
		}

        return false;
    }

    function isValidBTFirmwareUpdate()
    {
		var reg = system.ioregistry.matchingClass("IOUSBDevice")
		
		if( reg )
		{
			for( var i = 0; i &lt; reg.length; i++ )
			{
				var productID = reg[i].idProduct;
				var vendorID = reg[i].idVendor;
				var bcdDev = reg[i].bcdDevice;
				
				if(     (vendorID == 0x5AC) &amp;&amp; 
					( (productID == 0x8210 &amp;&amp; bcdDev &lt; 0x180) ||
					 (productID == 0x820F &amp;&amp; bcdDev &lt; 0x180 ) ||
					 (productID == 0x8212 &amp;&amp; bcdDev &lt; 0x180) ||
					 (productID == 0x8213 &amp;&amp; bcdDev &lt; 0x180) ||
					 (productID == 0x8215 &amp;&amp; bcdDev &lt; 0x180 ) ||
					 (productID == 0x8216 &amp;&amp; bcdDev &lt; 0x180) ||
					 (productID == 0x8217 &amp;&amp; bcdDev &lt; 0x180 ) )
				  )
				{
					return true;
				}
			}
		}

        return false;
    }
	   
    function isNotDowngrade()
    {
        var action = null;
        if( choices.manual )
		{
            action = choices.manual.packageUpgradeAction;
        }
        else
		{
            action = choices.su.packageUpgradeAction;
        }
        
        if( (action == 'downgrade') || (action == 'mixed') )
		{
            return false;
        }
        
        return true;
    }
	
	</script>
    <conclusion file="Conclusion.rtf"/>
    <welcome file="SUDescription.html"/>
    <license file="License.rtf" sla="EA0325"/>
    <background file="background.tif"/>
    <localization>
        <strings language="pl"><![CDATA["SU_TITLE" = "Uaktualnienie oprogramowania sprzętowego Bluetooth";
"SU_VERS" = "2.0.1";
"SU_SERVERCOMMENT" = "Dla komputerów klienckich i 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 problemy i poprawia zgodność myszy Apple Wireless Mighty Mouse oraz klawiatury Apple Wireless Keyboard. Można je instalować na wszystkich komputerach Macintosh z Bluetooth bazującym na zestawie układów Broadcom.
</P>
</FONT>
</BODY>
</HTML>
';
]]></strings>
    </localization>

	<pkg-ref id='com.apple.pkg.BluetoothFirmwareUpdate2.0.1' installKBytes='3670' version='2.0.1.1.1249082827'/>
</installer-gui-script>