[Title] remove --vms option and make .user.lock file in the build script
authorjihye kim <jihye1128.kim@samsung.com>
Fri, 7 Sep 2012 02:56:13 +0000 (11:56 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Fri, 7 Sep 2012 02:56:13 +0000 (11:56 +0900)
[Type] work
[Module] emulator manager
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

package/emulator-manager.install.linux
package/emulator-manager.install.windows
src/org/tizen/emulator/manager/EmulatorManager.java
src/org/tizen/emulator/manager/tool/FilePath.java
src/org/tizen/emulator/manager/vms/EmulatorVMs.java
supplement/emulator-manager.c

index 164fe24..54e7ecf 100755 (executable)
@@ -1,5 +1,10 @@
 #!/bin/sh
 
+## make $USERNAME.lock file
+tizen_vms_path="${HOME}/tizen-sdk-data"
+echo $tizen_vms_path
+echo $tizen_vms_path > $TIZEN_SDK_INSTALL_PATH/tools/emulator/bin/.$USER.lock
+
 ## User Define for desktop menu
 currentPath=`pwd`
 desktoppath=~/.local/share/applications
@@ -38,3 +43,4 @@ ${MAKESHORTCUT_PATH} \
                -i "$iconpath/$em_iconfile" \
                -n "$em_name" \
                -c "$em_comment"
+
index a97e1f4..588f5f4 100755 (executable)
@@ -1,4 +1,5 @@
 @ECHO OFF\r
+:: make shortcut menu ::::::::::::::::::::::::::::::::::::::::::::::\r
 set em_shortcut_name=Emulator Manager\r
 set execute_path=tools\emulator\bin\r
 set em_execute_file=emulator-manager.exe\r
@@ -14,4 +15,11 @@ echo Setting shortcut...
 wscript.exe %MAKESHORTCUT_PATH% /shortcut:"%em_shortcut_name%" /target:"%program_path%\%em_execute_file%" /icon:"%desktop_menu_icon_path%\%em_icon_file%"\r
 echo Setting registry\r
 reg add "hklm\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"  /f /v %program_path%\%em_execute_file% /t REG_SZ /d RUNASADMIN\r
-echo COMPLETE\r
+\r
+:: make %username%.lock file :::::::::::::::::::::::::::::::::::::::::\r
+FOR /F "skip=2 tokens=2,3,*", %%A IN ('REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Local AppData"') DO (\r
+    set config_path=%%C\r
+)\r
+set tizen_vms_path=%config_path%\tizen-sdk-data\r
+echo %tizen_vms_path% > %program_path%\.%USERNAME%.lock\r
+echo COMPLETE
\ No newline at end of file
index 3c021b8..452527c 100755 (executable)
@@ -60,12 +60,9 @@ public class EmulatorManager {
        private ArrayList<Platform> platformList = null;
 
        private static CommandLineParser processor = null;
-       private static boolean isConsoleMode = false;
-       private static int vmsPathIndex = -1;
+       private static boolean isConsoleMode = true;
        // for multi touch
        private static boolean isInhoseMode  = true;
-       // for windows
-       private static String emulatorVMsPath = null;
 
        public static EmulatorManager getInstance() {
                return instance;
@@ -112,13 +109,10 @@ public class EmulatorManager {
 
        static void checkConsoleMode(String[] args) {
                if (args.length > 0) {
-                       String s = null;
-                       for (int i = 0; i < args.length; i++) {
-                               s = args[i];
+                       for (String s : args) {
                                // workspace
                                if (s.startsWith("--w") || s.startsWith("-w")) {
                                        isConsoleMode = false;
-                                       ++i;
                                        break;
                                }
                                // inhouse
@@ -126,15 +120,6 @@ public class EmulatorManager {
                                        isConsoleMode = false;
                                        break;
                                }
-                               // vms path for windows
-                               else if (s.startsWith("--vms")) {
-                                       //isConsoleMode = false;
-                                       vmsPathIndex = i;
-                                       emulatorVMsPath = args[++i];
-                               }
-                               else {
-                                       isConsoleMode = true;
-                               }
                        }
                } else {
                        isConsoleMode = false;
@@ -169,8 +154,6 @@ public class EmulatorManager {
                                        }
                                } else if (args[i].equals("--inhouse")) {
                                        isInhoseMode = true;
-                               } else if (args[i].equals("--vms")) {
-                                       ++i;
                                } else {
                                        isArgsError = true;
                                }
@@ -200,19 +183,6 @@ public class EmulatorManager {
                checkConsoleMode(args);
 
                if (isConsoleMode) {
-                       String[] args2 = null;
-                       if (vmsPathIndex != -1) {
-                args2 = new String[args.length-2];
-                               int j = 0;
-                               for (int i = 0; i < args.length; i++) {
-                    if (i == vmsPathIndex) {
-                        ++i;
-                        continue;
-                    }
-                                       args2[j++] = args[i];
-                               }
-                               args = args2;
-                       }
 
                        EMLogger.getInstance().initConsoleLogger();
                        try {
@@ -230,30 +200,10 @@ public class EmulatorManager {
                        }
 
                        SelectWorkspace.getWorkspace(isConsoleMode);
-                       /*
-                       if (!SelectWorkspace.getWorkspace(isConsoleMode)) {
-                               exitEmulatorManager(-1);
-                       }
-                       */
 
                        processor = new CommandLineParser();
                        processor.parseArgs(args);
 
-                       instance = new EmulatorManager(isInhoseMode ? ManagerModeType.INHOUSE_MODE
-                                                                                                               : ManagerModeType.PUBLIC_MODE);
-
-                       // check hax or kvm
-                       CheckVirtualization.getInstance().check();
-                       CheckSDCard.CheckSwapDir();
-                       try {
-                               EmulatorVMs.getInstance().loadProperties();
-                       } catch (Exception e) {
-                               EMLogger.getLogger().log(Level.WARNING, e.getMessage());
-                       }
-                       instance.makePlatformList();
-
-                       instance.startConsoleProcessor();
-
                } else {
 
                        EMLogger.getInstance().initLogger();
@@ -273,30 +223,35 @@ public class EmulatorManager {
                        }
 
                        parseArgs(args);
-                       instance = new EmulatorManager(isInhoseMode ? ManagerModeType.INHOUSE_MODE
-                                                                                                               : ManagerModeType.PUBLIC_MODE);
+               }
+               instance = new EmulatorManager(isInhoseMode ? ManagerModeType.INHOUSE_MODE
+                                                                                                       : ManagerModeType.PUBLIC_MODE);
 
-                       EMLogger.getLogger().log(Level.INFO, "Start Emulator Manager!!\n");
+               // check hax or kvm
+               CheckVirtualization.getInstance().check();
 
-                       // check hax or kvm
-                       CheckVirtualization.getInstance().check();
+               // check SD Card folder
+               CheckSDCard.CheckSDCardDir();
+               CheckSDCard.CheckSwapDir();
 
-                       // check SD Card folder
-                       CheckSDCard.CheckSDCardDir();
-                       CheckSDCard.CheckSwapDir();
+               try {
+                       EmulatorVMs.getInstance().loadProperties();
+               } catch (Exception e) {
+                       EMLogger.getLogger().log(Level.WARNING, e.getMessage());
+               }
 
-                       try {
-                               EmulatorVMs.getInstance().loadProperties();
-                       } catch (Exception e) {
-                               EMLogger.getLogger().log(Level.WARNING, e.getMessage());
-                       }
-                       instance.makePlatformList();
+               instance.makePlatformList();
+
+               if (isConsoleMode) {
+                       instance.startConsoleProcessor();
+               } else {
+                       EMLogger.getLogger().log(Level.INFO, "Start Emulator Manager!!\n");
 
                        instance.preare();
                        instance.DrawUI();
                        instance.dispose();
-
                }
+
                } catch (Exception e) {
                        e.printStackTrace();
 
@@ -329,10 +284,6 @@ public class EmulatorManager {
                }
        }
 
-       public static String getEmulatorVMsPath() {
-               return emulatorVMsPath;
-       }
-
        public enum ManagerModeType {
                PUBLIC_MODE("public"),
                INHOUSE_MODE("inhouse");
index b78bf32..8850f65 100644 (file)
@@ -32,6 +32,7 @@ package org.tizen.emulator.manager.tool;
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
 import java.net.URISyntaxException;
@@ -103,14 +104,39 @@ public class FilePath {
                }
 
                // tizen_sdk path
+                String tizenSDKDataPath = "";
                {
                        File f = null;
-                       if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
-                               f = new File(EmulatorVMs.getInstance().getTizenSdkDataPath() + File.separator + "tizensdkpath");
+                       File lockFile = new File(currentPath + File.separator
+                                       + "." + System.getProperty("user.name") + ".lock");
+                       if (lockFile.exists()) {
+                               BufferedReader in = null;
+                               try {
+                                       in = new BufferedReader(new FileReader(lockFile));
+                               } catch (FileNotFoundException e) {
+                                       e.printStackTrace();
+                               }
+                               if (in != null) {
+                                       try {
+                                               tizenSDKDataPath = in.readLine();
+                                       } catch (IOException e) {
+                                               //e.printStackTrace();
+                                       } finally {
+                                               try {
+                                                       in.close();
+                                               } catch (IOException e) {
+                                                       e.printStackTrace();
+                                               }
+                                       }
+                               }
+                       }
+                       if (tizenSDKDataPath != null && !tizenSDKDataPath.equals("")) {
+                               f = new File(tizenSDKDataPath + File.separator + "tizensdkpath");
                        } else {
                                String home = System.getProperty("user.home");
                                f = new File(home + File.separator + "tizen-sdk-data" + File.separator + "tizensdkpath");
                        }
+
                        if (f.exists()) {
                                try {
                                        BufferedReader in = new BufferedReader(new FileReader(f));
@@ -123,7 +149,6 @@ public class FilePath {
                                                }
                                        }
                                } catch (IOException e) {
-                                       // TODO Auto-generated catch block
                                        e.printStackTrace();
                                }
                        }
@@ -167,9 +192,9 @@ public class FilePath {
                {
                        String sdb_suffix;
                        if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1)
-                               sdb_suffix = toolsPath + File.separator + "sdb.exe";
+                               sdb_suffix = File.separator + "sdb.exe";
                        else
-                               sdb_suffix = toolsPath + File.separator + "sdb";
+                               sdb_suffix = File.separator + "sdb";
 
                        sdbPath = toolsPath + sdb_suffix;
                }
@@ -191,7 +216,9 @@ public class FilePath {
                vmsPath = EmulatorVMs.getInstance().getVMsConfigDirectory();
                swapPath = workspacePath + File.separator + swap_suffix;
 
-               //testPrintPath();
+               EmulatorVMs.makeSDKDataPath(tizenSDKDataPath);
+               setVMSPath();
+               testPrintPath();
        }
 
        public static void setVMSPath() {
index 4d52922..e68a6ac 100644 (file)
@@ -44,13 +44,9 @@ import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.stream.StreamSource;
 
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.tizen.emulator.manager.EmulatorManager;
 import org.tizen.emulator.manager.logging.EMLogger;
 import org.tizen.emulator.manager.tool.FilePath;
 import org.tizen.emulator.manager.tool.StringResource;
-import org.tizen.emulator.manager.ui.MessageDialog;
 import org.tizen.emulator.manager.vms.xml.EmulatorConfiguration;
 import org.tizen.emulator.manager.vms.xml.ObjectFactory;
 
@@ -67,28 +63,23 @@ public class EmulatorVMs {
        static String tizenSdkDataPath="";
        static String vmsBaseDirectoryName = "";
        static String vmsConfigDirectory   = "";
-       static {
-               if (EmulatorManager.getEmulatorVMsPath() != null
-                               && !EmulatorManager.getEmulatorVMsPath().isEmpty()) {
-                       tizenSdkDataPath =  EmulatorManager.getEmulatorVMsPath()
-                                                       + File.separator + "tizen-sdk-data";
-               } else {
-                       if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
-                               String error = "Start EmulatorManager without emulator-manager.exe\n" +
-                                               "EmulatorManager's workspace be changed. Please check workspace path.\n";
-                               if (!EmulatorManager.isConsoleMode()) {
-                                       new MessageDialog(new Shell(Display.getCurrent()))
-                                       .openInfoDialog(error + "Click about menu!");
-                               }
-                               EMLogger.getLogger().warning(error);
-                       }
+
+       public static void makeSDKDataPath(String sdkDataPath) {
+               if (sdkDataPath == null || sdkDataPath.equals("")) {
                        tizenSdkDataPath = System.getProperty("user.home")
                                        + File.separator + "tizen-sdk-data";
+               } else {
+                       tizenSdkDataPath = sdkDataPath;
                }
 
                vmsBaseDirectoryName = tizenSdkDataPath
                                                                + File.separator + "emulator-vms";
                vmsConfigDirectory = vmsBaseDirectoryName + File.separator + "vms";
+
+               File vmsFolder = new File (vmsConfigDirectory);
+               if (!vmsFolder.exists()) {
+                       vmsFolder.mkdirs();
+               }
        }
 
        List<VMsProperty> propertiesList = new ArrayList<VMsProperty>();
index 8feb3c9..6ff0d5b 100644 (file)
@@ -173,9 +173,11 @@ int main(int argc, char* argv[])
                strcat(strCommand, "\"");\r
        }\r
 \r
+       /*\r
        strcat(strCommand, " --vms \"");\r
        strcat(strCommand, strLocalAppDataPath);\r
        strcat(strCommand, "\"");\r
+       */\r
 \r
        if(argc > 0) {\r
                for(i = 1; i < argc; i++) {\r