Progress : show progress. 38/11738/1
authorShihyun.kim <shihyun.kim@samsung.com>
Mon, 4 Nov 2013 07:07:53 +0000 (16:07 +0900)
committerShihyun.kim <shihyun.kim@samsung.com>
Mon, 4 Nov 2013 07:07:53 +0000 (16:07 +0900)
Add size of installation to progress bar
remove unnecessary "System.out"

Change-Id: I6df6d7f7ba5e1648b4f20534eef5facc7804af15
Signed-off-by: Shihyun.kim <shihyun.kim@samsung.com>
InstallManager_java/src/org/tizen/installmanager/core/InstallManager.java
InstallManager_java/src/org/tizen/installmanager/core/Installer.java
InstallManager_java/src/org/tizen/installmanager/lib/linux/LinuxSDKPackageFormat.java
InstallManager_java/src/org/tizen/installmanager/lib/linux/LinuxShellInstalledListParser.java
InstallManager_java/src/org/tizen/installmanager/ui/page/InstallingPage.java

index c82b7a2..1973829 100644 (file)
@@ -602,7 +602,7 @@ public class InstallManager {
                removeMissingPackages(monitor);\r
 \r
                for (Package pkg : installablePackages) {\r
-                       if (!install2(pkg, targetDir, monitor)) {\r
+                       if (!install(pkg, targetDir, monitor)) {\r
                                return false;\r
                        }\r
                }\r
@@ -675,7 +675,7 @@ public class InstallManager {
                return totalSize;\r
        }\r
 \r
-       private boolean install2(final Package pkg, final String targetDir,\r
+       private boolean install(final Package pkg, final String targetDir,\r
                        final InstallProgressMonitor monitor) throws IMExitException,\r
                        IMNetworkException {\r
                Log.log("Install package => " + pkg.getPackageName());\r
index 0344f50..58050c5 100644 (file)
@@ -114,10 +114,10 @@ public class Installer {
                                        ErrorCode.CANNOT_MOVE_FILE_TO_TARGET_DIRECTORY);\r
                }\r
 \r
-               List<File> missingFiles = findMissingFiles(pack);\r
+               List<File> missingFiles = findMissingFiles(pack, monitor);\r
                if (missingFiles.size() > 0) {\r
                        Log.err("Some files are not moved properly: " + missingFiles);\r
-//                     throw new IMFatalException(ErrorCode.FIND_MISSING_FILES);\r
+                       throw new IMFatalException(ErrorCode.FIND_MISSING_FILES);\r
                } else {\r
                        Log.log("All files moved properly.");\r
                }\r
@@ -200,8 +200,17 @@ public class Installer {
         * @param pack\r
         * @return list of files which are not moved normally\r
         */\r
-       private List<File> findMissingFiles(Package pack) {\r
+       private List<File> findMissingFiles(Package pack, IIMProgressMonitor monitor) {\r
                LinkedList<File> missingFiles = new LinkedList<File>();\r
+               \r
+               if (pack == null) {\r
+                       return missingFiles;\r
+               }\r
+               \r
+               if (monitor != null) {\r
+                       monitor.workedInstallProgress("Verify that the file exists", 0);\r
+               }\r
+               \r
                File listFile = new File(getInstalledFileListPath(pack));\r
                InputStream is = null;\r
                BufferedReader in = null;\r
index 62eb494..fa1e5f3 100644 (file)
@@ -1,30 +1,30 @@
 /*\r
-*  InstallManager\r
-*\r
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
-*\r
-* Contact: \r
-* Wooyoung Cho <wooyoung1.cho@samsung.com>\r
-* Shihyun Kim <shihyun.kim@samsung.com>\r
-* Taeyoung Son <taeyoung2.son@samsung.com>\r
-* Yongsung kim <yongsung1.kim@samsung.com>\r
-* \r
+ *  InstallManager\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>\r
+ * Shihyun Kim <shihyun.kim@samsung.com>\r
+ * Taeyoung Son <taeyoung2.son@samsung.com>\r
+ * Yongsung kim <yongsung1.kim@samsung.com>\r
+ \r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
-* you may not use this file except in compliance with the License.\r
-* You may obtain a copy of the License at\r
-*\r
-* http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*\r
-* Contributors:\r
-* - S-Core Co., Ltd\r
-*\r
-*/ \r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ *\r
+ */\r
 \r
 package org.tizen.installmanager.lib.linux;\r
 \r
@@ -36,75 +36,77 @@ import org.tizen.installmanager.lib.Log;
 import org.tizen.installmanager.lib.SDKPackageFormat;\r
 import org.tizen.installmanager.lib.ErrorController.ErrorCode;\r
 import org.tizen.installmanager.util.IMShellCommandFail;\r
-import org.tizen.installmanager.util.PathUtil;\r
 import org.tizen.installmanager.util.ShellUtil;\r
 \r
-\r
 /**\r
  * Manages to unpack package of tizen sdk for linux.\r
+ * \r
  * @author Shihyun Kim <shihyun.kim@samsung.com>\r
- *\r
+ * \r
  */\r
-public class LinuxSDKPackageFormat extends SDKPackageFormat{\r
+public class LinuxSDKPackageFormat extends SDKPackageFormat {\r
        private PackageType checkExtension;\r
-    \r
-    @Override\r
-    public long unZip(File fileFullPath, File targetDir, IIMProgressMonitor monitor) {\r
-        Log.log("Unpack "+fileFullPath+" to "+targetDir);\r
-        \r
-        checkExtension = getPackageType(fileFullPath.getAbsolutePath());\r
-        \r
-        if (!fileFullPath.exists()) {\r
-               Log.err("Package file is not exsisting");\r
-               return ERROR;\r
-        } else if (checkExtension == PackageType.ELSE) {\r
-               Log.err("Package extension is not '.zip' or '.tar.gz'");\r
-               return ERROR;\r
-        }\r
-        \r
-        if (targetDir == null || !targetDir.isAbsolute()) {\r
-               return ERROR;\r
-        }\r
 \r
-        if (!targetDir.exists()) {\r
-               if (targetDir.mkdirs()) {\r
-                       Log.log("Success to create directory ==> " + targetDir);\r
-               } else {\r
-                       Log.err("Fail to create directory ==> " + targetDir);\r
-               }\r
-        }\r
+       @Override\r
+       public long unZip(File fileFullPath, File targetDir,\r
+                       IIMProgressMonitor monitor) {\r
+               Log.log("Unpack " + fileFullPath + " to " + targetDir);\r
+\r
+               checkExtension = getPackageType(fileFullPath.getAbsolutePath());\r
+\r
+               if (!fileFullPath.exists()) {\r
+                       Log.err("Package file is not exsisting");\r
+                       return ERROR;\r
+               } else if (checkExtension == PackageType.ELSE) {\r
+                       Log.err("Package extension is not '.zip' or '.tar.gz'");\r
+                       return ERROR;\r
+               }\r
 \r
-        int exitValue;\r
-        \r
-       try {\r
-               if (checkExtension == PackageType.ZIP) {\r
-                       exitValue = sendCommand( "unzip -o "+ fileFullPath.getAbsolutePath() + " -d " + targetDir.getAbsolutePath(),\r
-                                       fileFullPath.getAbsolutePath(), PackageType.ZIP, monitor);\r
-                       unzipReturnValue(exitValue);\r
-               } else if (checkExtension == PackageType.TAR_GZ) {\r
-                       exitValue = sendCommand( "tar xvf "+ fileFullPath.getAbsolutePath() + " -C " + targetDir.getAbsolutePath(),\r
-                                       fileFullPath.getAbsolutePath(), PackageType.TAR_GZ, monitor);\r
-                       tarReturnValue(exitValue);\r
-               } else {\r
-                       throw new IMFatalException(ErrorCode.UNKNOWN_PACKAGE_EXTENSION);\r
-               }\r
+               if (targetDir == null || !targetDir.isAbsolute()) {\r
+                       return ERROR;\r
+               }\r
+\r
+               if (!targetDir.exists()) {\r
+                       if (targetDir.mkdirs()) {\r
+                               Log.log("Success to create directory ==> " + targetDir);\r
+                       } else {\r
+                               Log.err("Fail to create directory ==> " + targetDir);\r
+                       }\r
+               }\r
+\r
+               int exitValue = ERROR;\r
+\r
+               try {\r
+                       if (checkExtension == PackageType.ZIP) {\r
+                               exitValue = sendCommand(\r
+                                               "unzip -o " + fileFullPath.getAbsolutePath() + " -d "\r
+                                                               + targetDir.getAbsolutePath(),\r
+                                               fileFullPath.getAbsolutePath(), PackageType.ZIP,\r
+                                               monitor);\r
+                               unzipReturnValue(exitValue);\r
+                       } else if (checkExtension == PackageType.TAR_GZ) {\r
+                               exitValue = sendCommand(\r
+                                               "tar xvf " + fileFullPath.getAbsolutePath() + " -C "\r
+                                                               + targetDir.getAbsolutePath(),\r
+                                               fileFullPath.getAbsolutePath(), PackageType.TAR_GZ,\r
+                                               monitor);\r
+                               tarReturnValue(exitValue);\r
+                       } else {\r
+                               throw new IMFatalException(ErrorCode.UNKNOWN_PACKAGE_EXTENSION);\r
+                       }\r
                } catch (IMShellCommandFail e) {\r
+                       Log.ExceptionLog(e);\r
                        return ERROR;\r
                }\r
-       \r
-       if (monitor != null) {\r
-               monitor.workedDownloadProgress("", 0);\r
-       }\r
 \r
-        return SUCCESS;\r
-    }\r
-    \r
-    private int sendCommand(String command, String path, PackageType type, IIMProgressMonitor monitor) throws IMShellCommandFail {\r
-       LinuxShellInstalledListParser parser = null;\r
-       String fileName = PathUtil.getFileName(path);\r
+               return SUCCESS;\r
+       }\r
+\r
+       private int sendCommand(String command, String path, PackageType type, IIMProgressMonitor monitor) throws IMShellCommandFail {\r
+       LinuxShellInstalledListParser parser = null;\r
        \r
        if (mFileOutput != null) {\r
-               parser = new LinuxShellInstalledListParser(fileName, type);\r
+                parser = new LinuxShellInstalledListParser(type);\r
                parser.setFileOutputStream(mFileOutput);\r
                parser.setProgress(monitor);\r
        }\r
@@ -113,39 +115,43 @@ public class LinuxSDKPackageFormat extends SDKPackageFormat{
        \r
        return exitValue;\r
     }\r
-    \r
-    /**\r
-     * extract tar error case.\r
-     * @param exitValue\r
-     * @return\r
-     * @throws IMShellCommandFail\r
-     */\r
-       private static boolean tarReturnValue(int exitValue) throws IMShellCommandFail {\r
+\r
+       /**\r
+        * extract tar error case.\r
+        * \r
+        * @param exitValue\r
+        * @return\r
+        * @throws IMShellCommandFail\r
+        */\r
+       private static boolean tarReturnValue(int exitValue)\r
+                       throws IMShellCommandFail {\r
                if (exitValue == 0) {\r
                        return true;\r
                } else {\r
                        throw new IMShellCommandFail();\r
                }\r
        }\r
-    \r
-    /**\r
-     * extract zip error case.\r
-     * @param exitValue\r
-     * @return\r
-     * @throws IMShellCommandFail\r
-     */\r
-       private static boolean unzipReturnValue(int exitValue) throws IMShellCommandFail {\r
-               switch(exitValue) {\r
+\r
+       /**\r
+        * extract zip error case.\r
+        * \r
+        * @param exitValue\r
+        * @return\r
+        * @throws IMShellCommandFail\r
+        */\r
+       private static boolean unzipReturnValue(int exitValue)\r
+                       throws IMShellCommandFail {\r
+               switch (exitValue) {\r
                case 0:\r
                        return true;\r
                case 1:\r
-                       Log.err("one or more warning errors were encountered, but processing completed  successfully  anyway." +\r
-                                       "This  includes  zipfiles  where one or more files was skipped due to unsupported compression " +\r
-                                       "method or encryption with an unknown password.");\r
+                       Log.err("one or more warning errors were encountered, but processing completed  successfully  anyway."\r
+                                       + "This  includes  zipfiles  where one or more files was skipped due to unsupported compression "\r
+                                       "method or encryption with an unknown password.");\r
                        throw new IMShellCommandFail();\r
                case 2:\r
-                       Log.err("a generic error in the zipfile format was detected.  Processing may have completed" +\r
-                                       "successfully anyway; some broken zipfiles created by other archivers have simple work-arounds.");\r
+                       Log.err("a generic error in the zipfile format was detected.  Processing may have completed"\r
+                                       "successfully anyway; some broken zipfiles created by other archivers have simple work-arounds.");\r
                        throw new IMShellCommandFail();\r
                case 3:\r
                        Log.err("a severe error in the zipfile format was detected.  Processing probably failed immediately.");\r
@@ -187,8 +193,8 @@ public class LinuxSDKPackageFormat extends SDKPackageFormat{
                        Log.err("testing or extraction of one or more files failed due to unsupported compression methods  or unsupported decryption.");\r
                        throw new IMShellCommandFail();\r
                case 82:\r
-                       Log.err("no  files  were  found due to bad decryption password(s).  (If even one file is successfully" +\r
-                     "processed, however, the exit status is 1.)");\r
+                       Log.err("no  files  were  found due to bad decryption password(s).  (If even one file is successfully"\r
+                                       + "processed, however, the exit status is 1.)");\r
                        throw new IMShellCommandFail();\r
                default:\r
                        Log.err("Unknown exit value");\r
index 56d5caa..36b3145 100644 (file)
@@ -1,30 +1,30 @@
 /*\r
-*  InstallManager\r
-*\r
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
-*\r
-* Contact: \r
-* Wooyoung Cho <wooyoung1.cho@samsung.com>\r
-* Shihyun Kim <shihyun.kim@samsung.com>\r
-* Taeyoung Son <taeyoung2.son@samsung.com>\r
-* Yongsung kim <yongsung1.kim@samsung.com>\r
-* \r
+ *  InstallManager\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>\r
+ * Shihyun Kim <shihyun.kim@samsung.com>\r
+ * Taeyoung Son <taeyoung2.son@samsung.com>\r
+ * Yongsung kim <yongsung1.kim@samsung.com>\r
+ \r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
-* you may not use this file except in compliance with the License.\r
-* You may obtain a copy of the License at\r
-*\r
-* http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
-*\r
-* Contributors:\r
-* - S-Core Co., Ltd\r
-*\r
-*/ \r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ *\r
+ */\r
 \r
 package org.tizen.installmanager.lib.linux;\r
 \r
@@ -46,24 +46,21 @@ import org.tizen.installmanager.lib.ErrorController.ErrorCode;
 import org.tizen.installmanager.lib.SDKPackageFormat.PackageType;\r
 import org.tizen.installmanager.util.PathUtil;\r
 \r
-\r
 /**\r
  * Parsing standard out message and save installed file list.\r
+ * \r
  * @author Shihyun Kim <shihyun.kim@samsung.com>\r
- *\r
+ * \r
  */\r
 public class LinuxShellInstalledListParser extends ShellParser {\r
-       \r
 \r
        IIMProgressMonitor mMonitor = null;\r
        FileOutputStream mFileOut = null;\r
-       \r
+\r
        public static final String FILE_PATH_SEPARATOR = ":";\r
-       private String fileName;\r
        private PackageType extension;\r
-       \r
-       LinuxShellInstalledListParser(String name, PackageType type) {\r
-               fileName = name;\r
+\r
+       LinuxShellInstalledListParser(PackageType type) {\r
                extension = type;\r
        }\r
 \r
@@ -73,188 +70,204 @@ public class LinuxShellInstalledListParser extends ShellParser {
 \r
                BufferedReader br = null;\r
                try {\r
-            InputStreamReader isr = new InputStreamReader(input, Platform.CURRENT_CHARSET);\r
-            br = new BufferedReader(isr);\r
-            \r
-            setMonitorFile();\r
-            \r
-            String line;\r
-            while ( (line = br.readLine()) != null) {\r
-                print(line);\r
-            }\r
-            \r
-            closeFileOutputStream();\r
-        } catch (IOException ioe) {\r
-               Log.err("Cannot parse shell input stream.");\r
-        }finally{\r
-               if (br != null) {\r
-                               try {                                   \r
+                       InputStreamReader isr = new InputStreamReader(input,\r
+                                       Platform.CURRENT_CHARSET);\r
+                       br = new BufferedReader(isr);\r
+\r
+                       String line;\r
+                       while ((line = br.readLine()) != null) {\r
+                               print(line);\r
+                       }\r
+\r
+                       closeFileOutputStream();\r
+               } catch (IOException ioe) {\r
+                       Log.err("Cannot parse shell input stream.");\r
+               } finally {\r
+                       if (br != null) {\r
+                               try {\r
                                        br.close();\r
                                } catch (IOException e) {\r
                                        // TODO Auto-generated catch block\r
                                        Log.err("LinuxShellInstalledListParser fail to close fileoutput");\r
-                               } \r
+                               }\r
                        }\r
-        }\r
-       }\r
-       \r
-       private void setMonitorFile() {\r
-       if (mMonitor != null) {\r
-               mMonitor.workedInstallProgress(fileName, 0);\r
-       }               \r
+               }\r
        }\r
-       \r
+\r
        private void print(String line) {\r
-               printToProgressBar(line);\r
-       printToFile(line);\r
-    }\r
-    \r
-    private void printToProgressBar(String line) {     \r
-       if (mMonitor != null) {\r
-               String name = PathUtil.getFileName(line);\r
-               \r
-               mMonitor.workedInstallProgress(name, 0);\r
-       }\r
-    }\r
-    \r
-    private void printToFile(String line) {\r
-       if (mFileOut == null) {\r
-               return;\r
-       }\r
-       \r
-       String filePath = "";\r
-       if (extension == PackageType.ZIP) {\r
-               filePath = getFilePathFromValue(line);                  \r
-       } else if (extension == PackageType.TAR_GZ) {\r
-               filePath = PathUtil.getFromInstalledPath(Config.TEMP_DIRECTORY, line);\r
-       }\r
-\r
-       try {                   \r
-               String dataDir = PathUtil.getFromInstalledPath(Config.TEMP_DIRECTORY, Config.DATA_DIRECTORY); \r
-               if (filePath.length() <= dataDir.length() || filePath.indexOf(dataDir) < 0) {\r
-                       return;\r
-               }\r
-               \r
-               int index = dataDir.length() + 1;\r
-\r
-               filePath = filePath.substring(index).trim();  \r
-               if (!filePath.equals("")) {\r
-                       filePath = filePath + "\n";\r
-                       mFileOut.write(filePath.getBytes());\r
-               }\r
+               String filePath = getFilePathFromValue(line);\r
+               \r
+               //package file\r
+               if (filePath.startsWith(Config.getInstance().getDownloadDirPath())) {\r
+                       return;\r
+               } else { //unzipped file\r
+                       printToProgressBar(filePath);\r
+                       printToFile(filePath);\r
+               }\r
+       }\r
+\r
+       private void printToProgressBar(String filePath) {\r
+               if (mMonitor != null) {\r
+                       File unzippedFile = new File(filePath);\r
+\r
+                       if (unzippedFile.exists()) {\r
+                               mMonitor.workedInstallSize(unzippedFile.length());\r
+                       }\r
+               }\r
+       }\r
+\r
+       private void printToFile(String filePath) {\r
+               if (mFileOut == null) {\r
+                       return;\r
+               }\r
+\r
+               try {\r
+                       String dataDir = PathUtil.getFromInstalledPath(\r
+                                       Config.TEMP_DIRECTORY, Config.DATA_DIRECTORY);\r
+                       if (filePath.length() <= dataDir.length()\r
+                                       || filePath.indexOf(dataDir) < 0) {\r
+                               return;\r
+                       }\r
+\r
+                       int index = dataDir.length() + 1;\r
+\r
+                       filePath = filePath.substring(index).trim();\r
+                       if (!filePath.equals("")) {\r
+                               filePath = filePath + "\n";\r
+                               mFileOut.write(filePath.getBytes());\r
+                       }\r
                } catch (IOException e) {\r
                        // TODO Auto-generated catch block\r
                        Log.err("File write failure(" + filePath + ")");\r
                        Log.err(e.getMessage());\r
                        throw new IMFatalException("File write failure(" + filePath + ")");\r
                }\r
-    }\r
-    \r
-    private String getFilePathFromValue(String line) {\r
-       String value = getValue(line);\r
-       \r
-       if (value.length() <= 0) {\r
-               return "";\r
-       }\r
-       \r
-       String seperator = "";\r
-       if (isCreatingFile(line)) {\r
-               return value.trim();\r
-       } else if (isLinkingFile(line)) {\r
-               seperator = "->";\r
-       } else {\r
-               seperator = "[";\r
-       }\r
-       \r
-       int index = value.lastIndexOf(seperator);\r
-       \r
-       if (index < 0) {\r
-               return value.trim();\r
-       }\r
-       \r
-       return value.substring(0, index).trim();\r
-    }\r
-    \r
-    private String getKey(String line) {\r
-       int index = line.indexOf(FILE_PATH_SEPARATOR);\r
-       \r
-       if (index < 0 ){\r
-               return "";\r
-       }\r
-       \r
-       return line.substring(0, index).trim();\r
-    }\r
-    \r
-    private String getValue(String line) {     \r
-       int index = line.indexOf(FILE_PATH_SEPARATOR);\r
-       \r
-       if (index < 0 ){\r
-               return "";\r
-       }\r
-       \r
-       return line.substring(index+1).trim();\r
-    }\r
-    \r
-    /**\r
-     * set file output for saving installed list\r
-     * @param path\r
-     */\r
-    public void setFileOutputStream(String path) {\r
-       setFileOutputStream(new File(path));\r
-    }\r
-    \r
-    /**\r
-     * set file output for saving installed list\r
-     * @param filePath\r
-     */\r
-    public void setFileOutputStream(File filePath) {\r
-       File parentFile = filePath.getParentFile();\r
-       \r
-       if (!parentFile.exists()) {\r
-               if (parentFile.mkdirs()) {\r
-                       Log.log("Success to create directory ==> " + parentFile);\r
-               } else {\r
-                       Log.err("Fail to create directory ==> " + parentFile);\r
-               }\r
-       }\r
-       \r
-       if (filePath.exists()) {\r
-               if (filePath.delete()) {\r
-                       Log.log("Success to delete directory ==> " + filePath);\r
-               } else {\r
-                       Log.err("Fail to delete directory ==> " + filePath);\r
-               }\r
-       }\r
-       \r
-       \r
+       }\r
+\r
+       private String getFilePathFromValue(String line) {\r
+               if (extension == PackageType.ZIP) {\r
+                       return getFilePathFromUnzipCommand(line);\r
+               } else if (extension == PackageType.TAR_GZ) {\r
+                       return getFilePathFromTarCommand(line);\r
+               } else {\r
+                       return null;\r
+               }\r
+       }\r
+       \r
+       private String getFilePathFromUnzipCommand(String line) {\r
+               String value = getValue(line);\r
+\r
+               if (value.length() <= 0) {\r
+                       return "";\r
+               }\r
+\r
+               String seperator = "";\r
+               if (isCreatingFile(line)) {\r
+                       return value.trim();\r
+               } else if (isLinkingFile(line)) {\r
+                       seperator = "->";\r
+               } else {\r
+                       seperator = "[";\r
+               }\r
+\r
+               int index = value.lastIndexOf(seperator);\r
+\r
+               if (index < 0) {\r
+                       return value.trim();\r
+               }\r
+\r
+               return value.substring(0, index).trim();\r
+       }\r
+       \r
+       private String getFilePathFromTarCommand(String line) {\r
+               return PathUtil.getFromInstalledPath(Config.TEMP_DIRECTORY,\r
+                               line);\r
+       }\r
+\r
+       private String getKey(String line) {\r
+               int index = line.indexOf(FILE_PATH_SEPARATOR);\r
+\r
+               if (index < 0) {\r
+                       return "";\r
+               }\r
+\r
+               return line.substring(0, index).trim();\r
+       }\r
+\r
+       private String getValue(String line) {\r
+               int index = line.indexOf(FILE_PATH_SEPARATOR);\r
+\r
+               if (index < 0) {\r
+                       return "";\r
+               }\r
+\r
+               return line.substring(index + 1).trim();\r
+       }\r
+\r
+       /**\r
+        * set file output for saving installed list\r
+        * \r
+        * @param path\r
+        */\r
+       public void setFileOutputStream(String path) {\r
+               setFileOutputStream(new File(path));\r
+       }\r
+\r
+       /**\r
+        * set file output for saving installed list\r
+        * \r
+        * @param filePath\r
+        */\r
+       public void setFileOutputStream(File filePath) {\r
+               File parentFile = filePath.getParentFile();\r
+\r
+               if (!parentFile.exists()) {\r
+                       if (parentFile.mkdirs()) {\r
+                               Log.log("Success to create directory ==> " + parentFile);\r
+                       } else {\r
+                               Log.err("Fail to create directory ==> " + parentFile);\r
+                       }\r
+               }\r
+\r
+               if (filePath.exists()) {\r
+                       if (filePath.delete()) {\r
+                               Log.log("Success to delete directory ==> " + filePath);\r
+                       } else {\r
+                               Log.err("Fail to delete directory ==> " + filePath);\r
+                       }\r
+               }\r
+\r
                try {\r
                        filePath.createNewFile();\r
                } catch (IOException e) {\r
-                       Log.err("Cannot create install list => " + filePath.getAbsolutePath());\r
+                       Log.err("Cannot create install list => "\r
+                                       + filePath.getAbsolutePath());\r
                        throw new IMFatalException(ErrorCode.CANNOT_CREATE_INSTALL_LIST);\r
                }\r
-       \r
-       try {\r
+\r
+               try {\r
                        mFileOut = new FileOutputStream(filePath);\r
                } catch (FileNotFoundException e) {\r
-                       Log.err("Cannot create install list => " + filePath.getAbsolutePath());\r
+                       Log.err("Cannot create install list => "\r
+                                       + filePath.getAbsolutePath());\r
                        throw new IMFatalException(ErrorCode.CANNOT_CREATE_INSTALL_LIST);\r
                }\r
-    }\r
-       \r
-    /**\r
-     * set file output for saving installed list\r
-     * @param fOut\r
-     */\r
+       }\r
+\r
+       /**\r
+        * set file output for saving installed list\r
+        * \r
+        * @param fOut\r
+        */\r
        public void setFileOutputStream(FileOutputStream fOut) {\r
                mFileOut = fOut;\r
        }\r
-       \r
+\r
        /**\r
         * close FileOutput instance.\r
         */\r
        public void closeFileOutputStream() {\r
-               if(mFileOut != null) {\r
+               if (mFileOut != null) {\r
                        try {\r
                                mFileOut.close();\r
                                mFileOut = null;\r
@@ -264,25 +277,26 @@ public class LinuxShellInstalledListParser extends ShellParser {
                        }\r
                }\r
        }\r
-       \r
+\r
        /**\r
         * If you set this, you can get file name to UI.\r
+        * \r
         * @param monitor\r
         */\r
        public void setProgress(IIMProgressMonitor monitor) {\r
                mMonitor = monitor;\r
        }\r
-       \r
+\r
        private boolean isLinkingFile(String line) {\r
                String key = getKey(line);\r
-               \r
+\r
                return key.equals("linking");\r
        }\r
-       \r
+\r
        private boolean isCreatingFile(String line) {\r
                String key = getKey(line);\r
-               \r
+\r
                return key.equals("creating");\r
        }\r
-       \r
+\r
 }\r
index ac0ff53..b01b6ed 100644 (file)
@@ -357,7 +357,6 @@ public class InstallingPage extends PageTemplate {
                                @Override\r
                                public void run() {\r
                                        if (!cancelRequested) {\r
-                                               System.out.println("cancel");\r
                                                mainWindow.setCancelBtnEnabled(false);\r
 //                                             downloadSpeedLabel.setVisible(false);\r
                                                retContinue = true;\r
@@ -571,7 +570,6 @@ public class InstallingPage extends PageTemplate {
                                                }\r
                                        }\r
 \r
-                                       System.out.println(downloadVelocityStr);\r
                                        downloadSpeedLabel.setText("speed : "\r
                                                        + downloadVelocityStr);\r
                                        downloadProgressBar\r