// Path: baggle-datagrams/src/inouire/utils/Utils.java
// public class Utils {
//     
//     
//     public static String createRandomPassword(){
//         Random r=new Random();
//         int nb_letters=r.nextInt(5)+5;
//         String password="";
//         for(int k=0;k<nb_letters;k++){
//             password+=r.nextInt(10)+"";
//         }
//         return password;
//     }
//     
//     public static int getIntValue(String string_value, int default_value){
//         int int_value;
//         try{
//             int_value=Integer.parseInt(string_value);
//         }catch(NumberFormatException nfe){
//             int_value=default_value;
//             System.err.println("Impossible to cast "+string_value+" to integer");
//         }
//         return int_value;
//     }
//     
//     public static boolean getBoolValue(String string_value, boolean default_value){
//         boolean bool_value;
//         try{
//             bool_value=Boolean.parseBoolean(string_value);
//         }catch(NumberFormatException nfe){
//             bool_value=default_value;
//             System.err.println("Impossible to cast "+string_value+" to boolean");
//         }
//         return bool_value;
//     }
//     
//     public static void setBestLookAndFeelAvailable(){
//         String system_lf = UIManager.getSystemLookAndFeelClassName().toLowerCase();
//         if(system_lf.contains("metal")){
//             try {
//                 UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
//             }catch (Exception e) {}
//         }else{
//             try {
//                 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//             }catch (Exception e) {}
//         }
//     }
// }


import inouire.basics.SimpleLog;
import java.io.*;
import inouire.utils.Utils;
     * Load the configuration from file
     */
    public void loadFromFile(){
        FileInputStream in;
        try {
            in = new FileInputStream(CONFIG_FILE);
        } catch (FileNotFoundException ex) {
            SimpleLog.logger.error("Impossible to open file at "+CONFIG_FILE.getAbsolutePath());
            return;
        }
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        try{
            String line="";
            String[] arg;
            ConfigKey key;
            String value;

            while((line = reader.readLine()) != null ){
                arg= line.split("=");
                if(arg.length==2){
                    key=ConfigKey.valueOf(arg[0].trim().toUpperCase());
                    value=arg[1].trim();
                    switch(key){
                        case NAME:
                            NAME=value;
                            break;
                        case AVATAR:
                            AVATAR=value.toLowerCase();
                            break;
                        case POSX:
// Path: baggle-datagrams/src/inouire/utils/Utils.java
// public class Utils {
//     
//     
//     public static String createRandomPassword(){
//         Random r=new Random();
//         int nb_letters=r.nextInt(5)+5;
//         String password="";
//         for(int k=0;k<nb_letters;k++){
//             password+=r.nextInt(10)+"";
//         }
//         return password;
//     }
//     
//     public static int getIntValue(String string_value, int default_value){
//         int int_value;
//         try{
//             int_value=Integer.parseInt(string_value);
//         }catch(NumberFormatException nfe){
//             int_value=default_value;
//             System.err.println("Impossible to cast "+string_value+" to integer");
//         }
//         return int_value;
//     }
//     
//     public static boolean getBoolValue(String string_value, boolean default_value){
//         boolean bool_value;
//         try{
//             bool_value=Boolean.parseBoolean(string_value);
//         }catch(NumberFormatException nfe){
//             bool_value=default_value;
//             System.err.println("Impossible to cast "+string_value+" to boolean");
//         }
//         return bool_value;
//     }
//     
//     public static void setBestLookAndFeelAvailable(){
//         String system_lf = UIManager.getSystemLookAndFeelClassName().toLowerCase();
//         if(system_lf.contains("metal")){
//             try {
//                 UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
//             }catch (Exception e) {}
//         }else{
//             try {
//                 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//             }catch (Exception e) {}
//         }
//     }
// }


// Path: baggle-client/src/inouire/baggle/client/UserConfiguration.java
import inouire.basics.SimpleLog;
import java.io.*;
import inouire.utils.Utils;

     * Load the configuration from file
     */
    public void loadFromFile(){
        FileInputStream in;
        try {
            in = new FileInputStream(CONFIG_FILE);
        } catch (FileNotFoundException ex) {
            SimpleLog.logger.error("Impossible to open file at "+CONFIG_FILE.getAbsolutePath());
            return;
        }
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        try{
            String line="";
            String[] arg;
            ConfigKey key;
            String value;

            while((line = reader.readLine()) != null ){
                arg= line.split("=");
                if(arg.length==2){
                    key=ConfigKey.valueOf(arg[0].trim().toUpperCase());
                    value=arg[1].trim();
                    switch(key){
                        case NAME:
                            NAME=value;
                            break;
                        case AVATAR:
                            AVATAR=value.toLowerCase();
                            break;
                        case POSX:
                            POSX=Utils.getIntValue(value, -1);