/*----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is Fever Framework code. The Initial Developer of the Original Code is Romain Ecarnot. Portions created by Initial Developer are Copyright (C) 2006 the Initial Developer. All Rights Reserved. Contributor(s): Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------------*/ import fever.core.client.ClientPlatform; import fever.core.client.ClientPlayer; import fever.core.client.ClientScreen; /** * Wrapper for Flash {@code System.capabilities} properties and more. * *
Uses to retrieve Flash Player version, screen resolution and * client platform. * *
Example * {@code * var client : ClientContext = Fever.client; * FeverDebug.INFO( client.player ); * FeverDebug.INFO( "Flash 8 compliant : " + ( client.player.major >= 8 ) ); * * FeverDebug.INFO( "Is standAlone player : " + ( client.player.type == ClientPlayerType.STANDALONE ) ); * FeverDebug.INFO( "Is Windows OS : " + ( client.platform == ClientPlatform.WINDOWS ) ); * * FeverDebug.INFO( "Screen size : " + client.screen ); * } * * @see fever.core.client.ClientPlatform * @see fever.core.client.ClientPlayer * @see fever.core.client.ClientPlayerType * @see fever.core.client.ClientScreen * * @author Romain Ecarnot */ class fever.core.client.ClientContext { //------------------------------------------------------------------------- // Private properties //------------------------------------------------------------------------- private static var _instance : ClientContext; private var _screen : ClientScreen; private var _player : ClientPlayer; private var _platform : Number; //------------------------------------------------------------------------- // Public Properties //------------------------------------------------------------------------- /** * A Boolean value that specifies whether access to the user's camera * and microphone has been administratively prohibited (true) or * allowed (false). */ public function get avHardwareDisable () : Boolean { return System.capabilities.avHardwareDisable; } /** * A Boolean value that is true if the player is running in an environment * that supports communication between Flash Player and accessibility aids; * false otherwise. */ public function get hasAccessibility () : Boolean { return System.capabilities.hasAccessibility; } /** * Specifies if the system has audio capabilities. * A Boolean value that is true if the player is running on a system that * has audio capabilities; false otherwise. */ public function get hasAudio () : Boolean { return System.capabilities.hasAudio; } /** * Specifies if the system has a MP3 decoder. A Boolean value that is true if * the player is running on a system that has an MP3 decoder; * false otherwise */ public function get hasMP3 () : Boolean { return System.capabilities.hasMP3; } /** * A Boolean value that is true if the player is running on a system that * supports printing; false otherwise. */ public function get hasPrinting () : Boolean { return System.capabilities.hasPrinting; } /** * Indicates the language of the system on which the player is running. */ public function get language() : String { return (System.capabilities.language); } /** * A Boolean value that indicates whether read access to the user's hard disk * has been administratively prohibited (true) or allowed (false). */ public function get localFileReadDisable () : Boolean { return System.capabilities.localFileReadDisable; } /** Returns {@link fever.core.client.ClientPlayer} object. */ public function get player() : ClientPlayer { return _player; } /** Returns {@link fever.core.client.ClientScreen} object. */ public function get screen () : ClientScreen { return _screen; } public function set screen ( o : ClientScreen ) : Void { _screen = o; } /** Returns client platform ID. */ public function get platform () : Number { return _platform; } //------------------------------------------------------------------------- // Public API //------------------------------------------------------------------------- /** * Returns {@link ClientContext} instance. * *
Always return the same instance. */ public static function getInstance() : ClientContext { if( _instance == undefined ) _instance = new ClientContext(); return _instance; } //------------------------------------------------------------------------- // Private implementation //------------------------------------------------------------------------- /** * Constructor. */ private function ClientContext( ) { _player = new ClientPlayer(); _screen = new ClientScreen(); _checkPlatform(); } private function _checkPlatform() : Void { var s : String = System.capabilities.os; if( s.indexOf( "Windows" ) > - 1 ) { _platform = ClientPlatform.WINDOWS; } else if( s.indexOf( "Linux") > -1 ) { _platform = ClientPlatform.LINUX; } else if( s.indexOf( "MacOS" ) > -1 ) { _platform = ClientPlatform.MACOS; } else { _platform = ClientPlatform.UNKNOW; } } }