Author: jerome
Date: 2009-01-22 18:33:16 +0100 (Thu, 22 Jan 2009)
New Revision: 3518

Modified:
   
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcCommons.java
   
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
   
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/Settings.java
   
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/XMLReader.java
   
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/XMLWriter.java
Log:
* Fixed language bug, locale stuff. ( not tested yet )

Modified: 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcCommons.java
===================================================================
--- 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcCommons.java
       2009-01-21 15:56:35 UTC (rev 3517)
+++ 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcCommons.java
       2009-01-22 17:33:16 UTC (rev 3518)
@@ -80,7 +80,6 @@
        public static File MyTuxTools;
        public static File TuxDroidSettingsDirectory;
        public static File TuxDroidSettingsFile;
-       public static File TuxDroidSettingsBackup;
        public static File TuxHelpFiles;
        
        //Temporaries files.
@@ -154,7 +153,6 @@
                MyTuxTools = new File(MyTuxDirectory.getAbsolutePath() + 
File.separator + "MyTuxTools");
                TuxDroidSettingsFile = new 
File(TuxDroidSettingsDirectory.getAbsolutePath() + File.separator + 
"settings.xml");
                TuxHelpFiles = InstallerPaths.directoryControlCenterHelps;
-               TuxDroidSettingsBackup = new 
File(TuxDroidSettingsDirectory.getAbsolutePath() + File.separator + 
"settings.xml.bak");
                
                //Temporaries files.
                GdgTempDirectory = new 
File(System.getProperty("java.io.tmpdir") + File.separator + "MyTux/gdgTmp");

Modified: 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
===================================================================
--- 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
     2009-01-21 15:56:35 UTC (rev 3517)
+++ 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/CcInterface.java
     2009-01-22 17:33:16 UTC (rev 3518)
@@ -1936,8 +1936,8 @@
                                                        
                                                }
                                        }
+                                       
                                });
-                               
                        
                                test.addMouseListener(new 
java.awt.event.MouseAdapter(){
                                        ImageIcon icon = new 
ImageIcon(CcCommons.targetClass.getResource("images/buttons/btn-test.png"));

Modified: 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/Settings.java
===================================================================
--- 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/Settings.java
       2009-01-21 15:56:35 UTC (rev 3517)
+++ 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/Settings.java
       2009-01-22 17:33:16 UTC (rev 3518)
@@ -23,7 +23,6 @@
 package com.tuxdroid.cc.settings;
 
 import java.io.BufferedReader;
-import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -34,7 +33,6 @@
 import com.kysoh.tuxdroid.gadget.framework.container.GadgetInstance;
 import com.kysoh.tuxdroid.gadget.framework.container.GadgetInstanceParameters;
 import com.tuxdroid.cc.CcCommons;
-import com.tuxdroid.cc.Utils.FileUtils;
 import com.tuxdroid.cc.gadget.GadgetObject;
 
 public class Settings {
@@ -45,89 +43,7 @@
        /** Reader object **/
        public static XMLReader reader;
        /** Writer object **/
-       public static XMLWriter writer;
-       
-       /** Backup file **/
-       public static File backup = CcCommons.TuxDroidSettingsBackup;
-       
-       /**
-        * Backup settings.xml file.
-        */
-       public static boolean backup()
-       {
-               //File exists then create backup.
-               if(CcCommons.TuxDroidSettingsFile.exists())
-               {
-                       CcCommons.logger.append("Creating backup file", true);
-                       Settings.backup = new 
File(CcCommons.TuxDroidSettingsDirectory.getAbsolutePath() 
-                                                                  + 
File.separator + "settings.xml.bak");
-                       try 
-                       {
-                               CcCommons.logger.append("Copying datas to the 
backup file.", true);
-                               FileUtils.copy(CcCommons.TuxDroidSettingsFile, 
Settings.backup);
-                               //Force to parse settings file.
-                               XMLReader.edited = true;
-                               CcCommons.logger.append("Backup done!", true);
-                               return true;
-                       } 
-                       catch (IOException e) 
-                       {
-                               CcCommons.logger.append("Cannot create backup 
file.", true);
-                       }
-               }
-               else
-               {
-                       CcCommons.logger.append("Settings file doesn't exists, 
can not create a backup file", true);
-               }
-               return false;
-       }
-       
-       
-       /**
-        * Restor settings .xml file.
-        */
-       public static boolean restore()
-       {
-               
-               //File exists then restore backup.
-               if((Settings.backup != null) && (Settings.backup.exists()))
-               {
-                       CcCommons.logger.append("Restore settings.", true);
-                       if(CcCommons.TuxDroidSettingsFile.exists())
-                       {
-                               CcCommons.logger.append("Deleting old 
settings", true);
-                               CcCommons.TuxDroidSettingsFile.delete();
-                       }
-                       
-                       CcCommons.logger.append("Creating a new settings file", 
true);
-                       CcCommons.TuxDroidSettingsFile = new 
File(CcCommons.TuxDroidSettingsDirectory.getAbsolutePath()+
-                                                                               
                          File.separator + "settings.xml");
-                       
-                       try 
-                       {
-                               CcCommons.logger.append("Copying datas from 
backup to new settings file.", true);
-                               FileUtils.copy(Settings.backup, 
CcCommons.TuxDroidSettingsFile);
-                               //Now the settings file has changed, force to 
parse again the new settings file.
-                               XMLReader.edited = true;
-                               CcCommons.logger.append("Restore completed.", 
true);
-                               return true;
-                       } 
-                       
-                       catch (IOException e) 
-                       {
-                               //Cannot restor backup from file, so quit 
application, a new settings file will be
-                               //created at cc startup.
-                               CcCommons.logger.append("Cannot restore from 
backup file.", true);
-                               System.exit(-1);
-                               e.printStackTrace();
-                       }
-               }
-               else
-               {
-                       CcCommons.logger.append("No backup file was found.", 
true);
-               }
-               return false;
-       }
+       public static XMLWriter writer;
        
        /**
         * This class create an object how manage control center settings.
@@ -162,8 +78,7 @@
                }
                
                //Before parsing file, verifying encoding.
-               this.verifyEncoding();
-               
+               this.verifyEncoding();
                this.getWriter();
                this.getReader();
        }

Modified: 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/XMLReader.java
===================================================================
--- 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/XMLReader.java
      2009-01-21 15:56:35 UTC (rev 3517)
+++ 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/XMLReader.java
      2009-01-22 17:33:16 UTC (rev 3518)
@@ -71,20 +71,14 @@
                catch (ParserConfigurationException e) 
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
-                       this.getDocument();
                } 
                catch (SAXException e) 
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
-                       this.getDocument();
                } 
                catch (IOException e) 
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
-                       this.getDocument();
                }
        }
        
@@ -107,8 +101,7 @@
                    }
                    catch(Exception except)
                    {
-                       Settings.restore();
-                       this.parse();
+                       except.printStackTrace();
                    }
                }
        }
@@ -135,20 +128,14 @@
                        catch (ParserConfigurationException e) 
                        {
                                CcCommons.logger.appendError(e.getStackTrace());
-                               Settings.restore();
-                               return this.getDocument();
-                       } 
+                       }
                        catch (SAXException e) 
                        {
                                CcCommons.logger.appendError(e.getStackTrace());
-                               Settings.restore();
-                               return this.getDocument();
                        } 
                        catch (IOException e) 
                        {
                                CcCommons.logger.appendError(e.getStackTrace());
-                               Settings.restore();
-                               return this.getDocument();
                        }
                        return this.document;
                }
@@ -170,9 +157,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
-                       this.getDocument();
-                       return this.getLanguage();
                }
                return lang;
        }
@@ -193,9 +177,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
-                       this.getDocument();
-                       return this.getPitch();
                }
                return Integer.valueOf(pitch).intValue();
        }
@@ -217,9 +198,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
-                       this.getDocument();
-                       return this.getCountry();
                }
                return country;
        }
@@ -241,9 +219,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
-                       this.getDocument();
-                       return this.getSpeaker();
                }
                return speaker;
        }
@@ -265,9 +240,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
-                       this.getDocument();
-                       return this.getIP();
                }
                return ipadress;
        }
@@ -306,10 +278,8 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
-                       this.getDocument();
-                       return this.getPlaylistDatas(tagName);
                }
+               return null;
        }
        
        

Modified: 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/XMLWriter.java
===================================================================
--- 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/XMLWriter.java
      2009-01-21 15:56:35 UTC (rev 3517)
+++ 
software_suite_v2/software/control_center/trunk/control_center/sources/com/tuxdroid/cc/settings/XMLWriter.java
      2009-01-22 17:33:16 UTC (rev 3518)
@@ -156,8 +156,6 @@
         * @param document : Complete modified document.
         */
        private void registerChanges(Document document){
-               CcCommons.logger.append("Creating a backup from settings 
file.", true);
-               Settings.backup();
                CcCommons.logger.append("Registering settings changes", true);
                try {
             // Create Dom source.
@@ -181,9 +179,7 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-            CcCommons.logger.append(" -->> ERROR: An error occured trying to 
register changes.", true);
-            CcCommons.logger.append("Trying to restore from a previous backup 
file.", true);
-            Settings.restore();
+            CcCommons.logger.append(" -->> ERROR: An error occured trying to 
register changes.", true);
         }
        }
        
@@ -224,10 +220,28 @@
         if(LangUtils.getInstallerLanguage() != null){
                String l = LangUtils.getInstallerLanguage();
                lang.setTextContent(l);
-               if(l.equalsIgnoreCase("fr")) country.setTextContent("FR");
-               else if(l.equalsIgnoreCase("en")) country.setTextContent("US");
-               else if(l.equals("nl")) country.setTextContent("NL");
-        }else{
+               if(l.equalsIgnoreCase("fr")) 
+                       country.setTextContent("FR");
+               
+               else if(l.equalsIgnoreCase("en")) 
+                       country.setTextContent("US");
+               
+               else if(l.equals("nl")) 
+                       country.setTextContent("NL");
+               
+               else if (l.equalsIgnoreCase("it"))
+                       country.setTextContent("IT");
+               
+               else if(l.equalsIgnoreCase("es"))
+                       country.setTextContent("ES");
+               else
+               {
+                       lang.setTextContent("en");
+                       country.setTextContent("US");
+               }
+        }
+        else
+        {
                lang.setTextContent("en");
                country.setTextContent("US");
         }
@@ -293,7 +307,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
 
@@ -314,7 +327,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -334,7 +346,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -357,7 +368,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -401,7 +411,6 @@
                {
                        locked = false;
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -423,7 +432,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -466,7 +474,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
                
        }
@@ -496,7 +503,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -521,7 +527,7 @@
        public void writeAlertConfiguration(int index, Object[] config)
        {
                try
-               {
+               {       
                        CcCommons.logger.append("Writing basic alert 
configuration", true);
                        Node attElem = 
Settings.reader.getDocument().getElementsByTagName("alert").item(index);
                        //Create new configuration.
@@ -547,8 +553,9 @@
                }
                catch(Exception e)
                {
-                       CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
+                       //CcCommons.logger.appendError(e.getStackTrace());
+                       //Settings.restore();
+                       e.printStackTrace();
                }
        }
        
@@ -589,7 +596,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -613,7 +619,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -636,7 +641,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -684,7 +688,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -758,7 +761,6 @@
                {
                        e.printStackTrace();
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -826,7 +828,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -906,7 +907,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -976,7 +976,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -999,7 +998,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
        
@@ -1031,7 +1029,6 @@
                catch(Exception e)
                {
                        CcCommons.logger.appendError(e.getStackTrace());
-                       Settings.restore();
                }
        }
 }


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to