1  //!-- UTF8
     2  /*
     3  Oregano Multiuser Server - Version 1.2.0 - January 4th, 2005
     4   
     5  	Web:  www.oregano-server.org
     6  	Mail: info@oregano-server.org
     7   
     8  	Copyright 2003 - 2004 - 2004 Jens Halm / Cologne, Germany
     9   
    10   This library is free software; you can redistribute it and/or
    11   modify it under the terms of the GNU Lesser General Public
    12   License as published by the Free Software Foundation; either
    13   version 2.1 of the License, or (at your option) any later version.
    14   
    15   This library is distributed in the hope that it will be useful,
    16   but WITHOUT ANY WARRANTY; without even the implied warranty of
    17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    18   Lesser General Public License for more details.
    19   
    20   You should have received a copy of the GNU Lesser General Public
    21   License along with this library; if not, write to the Free Software
    22   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23   */
    24  
    25  /*
    26  -------------------------------------------
    27  	Classe ClientInfo
    28  
    29  	@description :
    30  	Propriétés du client.
    31  	Sert pour les logs et le debuggage.
    32  
    33  
    34  	@author Jens Halm copyright http://www.spicefactory.org/
    35  	@author erixtekila copyleft http://www.v-i-a.net  
    36  -------------------------------------------
    37  	version history :
    38  	1.2.0 : 18/01/05
    39  			- Portage en actionscript 2 pour le
    40  			compile time type checking
    41  			18/08/05
    42  			- Remplacment de getVersion par System.capabilities.version (MTASC compatible)
    43  -------------------------------------------
    44  */
    45  
    46  
    47  
    48  /**
    49   *	Gestion des propriétés du poste client.
    50   *
    51   *	@author Jens Halm copyright http://www.spicefactory.org/
    52   *	@author erixtekila copyleft http://www.v-i-a.net 
    53   *	@version 1.2.0
    54   */
    55  class org.omus.util.ClientInfo
    56  {
    57  	//--------------------
    58  	// PROPRIETES
    59  	//--------------------
    60  	/**
    61  	 *	Système utilisé.
    62  	 */
    63  	public var clientOS:String;
    64  	
    65  	/**
    66  	 *	Version du plug-in Flash.
    67  	 */
    68  	public var clientVersion:String;
    69  	
    70  	/**
    71  	 *	Une référence vers le cookie client.
    72  	 */
    73  	public var so:SharedObject;
    74  	
    75  	/**
    76  	 *	Un identifiant du poste client.
    77  	 *	(-1 lorsque nouvel utilisateur)
    78  	 */
    79  	public var machineID:Number;
    80  	
    81  	//--------------------
    82  	// CONSTRUCTEUR
    83  	//--------------------
    84  	/**
    85  	 *	TODO
    86  	 */
    87  	public function ClientInfo()
    88  	{
    89  		// Propriétés
    90  		// os and version
    91  		var v = System.capabilities.version;
    92  		
    93  		var va = v.split(" ");
    94  		clientOS = va[0];
    95  		clientVersion = va[1];
    96  		
    97  		// machineID
    98  		if (typeof(_global) == "object") 
    99  		{
   100  			so = SharedObject.getLocal("machineID");
   101  			machineID = so.data.machineID;
   102  			if (machineID == undefined) machineID = -1;
   103  		} else
   104  		{
   105  			// Flash 5 - no cookie
   106  			machineID = 0;
   107  		}
   108  		
   109  		// trace(this+ " installé.");
   110  	}
   111  	
   112  	//--------------------
   113  	// METHODES PUBLIQUES
   114  	//--------------------
   115  	/**
   116  	 *	Utilisé dans un contexte littéral
   117  	 *
   118  	 *	@return	Une chaine définissant l'objet
   119  	 */
   120  	public function toString():String
   121  	{
   122  		return "[Object ClientInfo]";
   123  	}
   124  	
   125  	/**
   126  	 *	Rajoute les informations client à un message.
   127  	 *
   128  	 *	@param attach		Fichier joint du message.
   129  	 */
   130  	public function insert (attach:Object):Void
   131  	{
   132  		attach.clientOS = clientOS;
   133  		attach.clientVersion = clientVersion;
   134  		attach.machineID = machineID;
   135  	}
   136  	
   137  	/**
   138  	 *	Sauvegarde l'identifiant du poste client dans le cookie.
   139  	 *
   140  	 *	@param machineID		Identifiant de le machine.
   141  	 */
   142  	public function save (machineID:Number) {
   143  		so.data.machineID = machineID;
   144  		so.flush();
   145  	}
   146  	
   147  	//--------------------
   148  	// METHODES PRIVEES
   149  	//--------------------
   150  	
   151  	//--------------------
   152  	// METHODES STATIQUES
   153  	//--------------------
   154  	/**
   155  	 *	Utilisé dans un contexte littéral
   156  	 *	@return	Une chaine définissant l'objet
   157  	 */
   158  	public static function toLog():String
   159  	{
   160  		return "[Object ClientInfo]";
   161  	}
   162  }
   163