skin: using a skin information file
authorgiwoong.kim <giwoong.kim@samsung.com>
Tue, 30 Oct 2012 12:06:23 +0000 (21:06 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Tue, 30 Oct 2012 12:06:23 +0000 (21:06 +0900)
The Emulator read information of skin from skin/info.ini file.

Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkinMain.java
tizen/src/skin/client/src/org/tizen/emulator/skin/config/EmulatorConfig.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java

index 3b40175..1ea69d1 100644 (file)
@@ -47,6 +47,7 @@ import org.tizen.emulator.skin.comm.sock.SocketCommunicator;
 import org.tizen.emulator.skin.config.EmulatorConfig;
 import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
 import org.tizen.emulator.skin.config.EmulatorConfig.ConfigPropertiesConstants;
+import org.tizen.emulator.skin.config.EmulatorConfig.SkinInfoConstants;
 import org.tizen.emulator.skin.config.EmulatorConfig.SkinPropertiesConstants;
 import org.tizen.emulator.skin.dbi.EmulatorUI;
 import org.tizen.emulator.skin.exception.JaxbException;
@@ -64,7 +65,7 @@ import org.tizen.emulator.skin.util.SwtUtil;
  *
  */
 public class EmulatorSkinMain {
-
+       public static final String SKIN_INFO_FILE_NAME = "info.ini";
        public static final String SKIN_PROPERTIES_FILE_NAME = ".skin.properties";
        public static final String CONFIG_PROPERTIES_FILE_NAME = ".skinconfig.properties";
        public static final String DBI_FILE_NAME = "default.dbi";
@@ -100,6 +101,7 @@ public class EmulatorSkinMain {
 
                try {
 
+                       /* get vm path from startup argument */
                        String vmPath = getVmPath( args );
                        if ( StringUtil.isEmpty( vmPath ) ) {
                                throw new IllegalArgumentException( ArgsConstants.VM_PATH + " in arguments is null." );
@@ -111,7 +113,43 @@ public class EmulatorSkinMain {
                        logger.info( "!!! Start Emualtor Skin !!!" );
 
                        /* startup arguments parsing */
-                       Map<String, String> argsMap = parsArgs( args );
+                       Map<String, String> argsMap = parsArgs(args);
+
+                       /* emulator resolution */
+                       int resolutionW = Integer.parseInt(
+                                       argsMap.get(ArgsConstants.RESOLUTION_WIDTH));
+                       int resolutionH = Integer.parseInt(
+                                       argsMap.get(ArgsConstants.RESOLUTION_HEIGHT));
+
+                       /* get skin path from startup argument */
+                       String skinPath = ImageRegistry.getSkinPath(
+                                       (String) argsMap.get(ArgsConstants.SKIN_PATH), resolutionW, resolutionH);
+
+                       /* set skin information */
+                       String skinInfoFilePath = skinPath + File.separator + SKIN_INFO_FILE_NAME;
+                       Properties skinInfo = loadProperties(skinInfoFilePath, false);
+                       if (null == skinInfo) {
+                               logger.severe("Fail to load skin information file.");
+
+                               Shell temp = new Shell(Display.getDefault());
+                               MessageBox messageBox = new MessageBox( temp, SWT.ICON_ERROR );
+                               messageBox.setText("Emulator");
+                               messageBox.setMessage("Fail to load \"" + SKIN_INFO_FILE_NAME + "\" file\n" +
+                                               "Check if the file is corrupted or missing from the following path.\n" +
+                                               skinPath);
+                               messageBox.open();
+                               temp.dispose();
+
+                               System.exit(-1);
+                       } else {
+                               logger.info("skin info:" + skinInfo);
+                       }
+
+                       SkinMode skinMode = SkinMode.STANDARD;
+                       if (skinInfo.getProperty(SkinInfoConstants.RESOLUTION_WIDTH).equalsIgnoreCase("all") ||
+                                       skinInfo.getProperty(SkinInfoConstants.RESOLUTION_HEIGHT).equalsIgnoreCase("all")) {
+                               skinMode = SkinMode.GENERAL;
+                       }
 
                        /* set emulator window skin property */
                        String skinPropFilePath = vmPath + File.separator + SKIN_PROPERTIES_FILE_NAME;
@@ -133,30 +171,17 @@ public class EmulatorSkinMain {
                        EmulatorConfig.validateSkinProperties(skinProperties);
                        EmulatorConfig.validateSkinConfigProperties(configProperties);
 
-                       /* emulator resolution */
-                       int resolutionW = Integer.parseInt(
-                                       argsMap.get(ArgsConstants.RESOLUTION_WIDTH));
-                       int resolutionH = Integer.parseInt(
-                                       argsMap.get(ArgsConstants.RESOLUTION_HEIGHT));
-
-                       /* get skin path from startup argument */
-                       String argSkinPath = (String) argsMap.get(ArgsConstants.SKIN_PATH);
-
-                       /* determine skin mode */
-                       SkinMode skinMode = SkinMode.getValue(argsMap.get(ArgsConstants.SKIN_MODE));
-                       logger.info("skin mode is " + skinMode);
-
                        /* load dbi file */
-                       EmulatorUI dbiContents = loadDbi(argSkinPath, skinMode, resolutionW, resolutionH);
+                       EmulatorUI dbiContents = loadDbi(skinPath);
                        if ( null == dbiContents ) {
                                logger.severe( "Fail to load dbi file." );
 
-                               Shell temp = new Shell( Display.getDefault());
+                               Shell temp = new Shell(Display.getDefault());
                                MessageBox messageBox = new MessageBox( temp, SWT.ICON_ERROR );
                                messageBox.setText( "Emulator" );
                                messageBox.setMessage( "Fail to load \"" + DBI_FILE_NAME + "\" file\n" +
                                                "Check if the file is corrupted or missing from the following path.\n" +
-                                               argSkinPath );
+                                               skinPath);
                                messageBox.open();
                                temp.dispose();
 
@@ -345,19 +370,16 @@ public class EmulatorSkinMain {
 
        }
 
-       private static EmulatorUI loadDbi(String argSkinPath, SkinMode skinMode,
-                       int resolutionW, int resolutionH) {
-               String skinPath =
-                               ImageRegistry.getSkinPath(argSkinPath, skinMode, resolutionW, resolutionH) +
-                               File.separator + DBI_FILE_NAME;
-               logger.info("load dbi file from " + skinPath);
+       private static EmulatorUI loadDbi(String skinPath) {
+               String dbiPath = skinPath + File.separator + DBI_FILE_NAME;
+               logger.info("load dbi file from " + dbiPath);
 
                FileInputStream fis = null;
                EmulatorUI emulatorUI = null;
 
                try {
                        
-                       fis = new FileInputStream( skinPath );
+                       fis = new FileInputStream(dbiPath);
                        logger.info( "============ dbi contents ============" );
                        byte[] bytes = IOUtil.getBytes( fis );
                        logger.info( new String( bytes, "UTF-8" ) );
index dab1dd0..8c107df 100644 (file)
@@ -73,7 +73,12 @@ public class EmulatorConfig {
                public static final String LOG_LEVEL = "log.level";
                public static final String NET_BASE_PORT = "net.baseport";
                public static final String SKIN_PATH = "skin.path";
-               public static final String SKIN_MODE = "skin.mode";
+       }
+
+       public interface SkinInfoConstants {
+               public static final String SKIN_NAME = "skin.name";
+               public static final String RESOLUTION_WIDTH = "resolution.width";
+               public static final String RESOLUTION_HEIGHT = "resolution.height";
        }
 
        public interface SkinPropertiesConstants {
index 7ce9b9d..2eccc4c 100644 (file)
@@ -61,8 +61,8 @@ public class ImageRegistry {
        
        private Logger logger = SkinLogger.getSkinLogger( ImageRegistry.class ).getLogger();
 
-       public static final String SKIN_FOLDER = "skins";
-       public static final String IMAGE_FOLDER_PREFIX = "emul-";
+       public static final String SKINS_FOLDER = "skins";
+       public static final String GENERAL_FOLDER = "emul-general";
        public static final String ICON_FOLDER = "icons";
        
        public enum ImageType {
@@ -151,15 +151,12 @@ public class ImageRegistry {
 
        }
 
-       public static String getSkinPath(String argSkinPath, SkinMode skinMode,
+       public static String getSkinPath(String argSkinPath,
                        int resolutionX, int resolutionY) {
                /* When emulator has a invalid skin path,
                 emulator uses default skin path instead of it */
-               String defaultSkinPath =
-                               ".." + File.separator + SKIN_FOLDER + File.separator +
-                               ((skinMode == SkinMode.GENERAL) ?
-                                       "emul-general" :
-                                       IMAGE_FOLDER_PREFIX + resolutionX + "x" + resolutionY);
+               String defaultSkinPath = ".." + //TODO:
+                               File.separator + SKINS_FOLDER + File.separator + GENERAL_FOLDER;
 
                if (argSkinPath == null) {
                        return defaultSkinPath;
@@ -207,7 +204,7 @@ public class ImageRegistry {
                                return null;
                        }
 
-                       String skinPath = getSkinPath(argSkinPath, null, resolutionWidth, resolutionHeight);
+                       String skinPath = getSkinPath(argSkinPath, resolutionWidth, resolutionHeight);
                        logger.info("get image data of skin from " + skinPath);
 
                        RotationType targetRotation = SkinRotation.getRotation( id );