[Title] add debug tools's extenstion
authorYoonKi Park <yoonki.park@samsung.com>
Fri, 2 Dec 2011 16:34:08 +0000 (01:34 +0900)
committerYoonKi Park <yoonki.park@samsung.com>
Fri, 2 Dec 2011 16:34:08 +0000 (01:34 +0900)
com.samsung.tizen.common.connection/plugin.xml
com.samsung.tizen.common.connection/schema/tools.exsd [new file with mode: 0644]
com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/ConnectionPlugin.java
com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/DebugTool.java [new file with mode: 0644]
com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/Messages.java [new file with mode: 0644]
com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/ToolsInstall.java [moved from com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/PackageInstaller.java with 61% similarity]
com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/messages.properties [new file with mode: 0644]
com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerPanel.java

index 2b6c848..ee11062 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.4"?>
 <plugin>
+   <extension-point id="com.samsung.tizen.common.connection.tools" name="tools" schema="schema/tools.exsd"/>
                <extension
                point="org.eclipse.ui.views">
                <category
          </viewShortcut>
       </perspectiveExtension> 
    </extension>   
-   </plugin>
\ No newline at end of file
+   </plugin>
diff --git a/com.samsung.tizen.common.connection/schema/tools.exsd b/com.samsung.tizen.common.connection/schema/tools.exsd
new file mode 100644 (file)
index 0000000..a6101a6
--- /dev/null
@@ -0,0 +1,121 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="tools" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="tools" id="com.samsung.tizen.common.connection.tools" name="Tizen SDK Debug Tools Installation"/>
+      </appinfo>
+      <documentation>
+         This extension allows specification of a tizen sdk debug tools to be installed when launching application under the SDB.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="tools"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="tools">
+      <complexType>
+         <attribute name="binaryname" type="string" use="required">
+            <annotation>
+               <documentation>
+                  the name of tar file named &quot;packagename_version_architecture.tar&quot;.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="sourcepath" type="string" use="required">
+            <annotation>
+               <documentation>
+                  the source directory path from tizen sdk install path.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="description" type="string">
+            <annotation>
+               <documentation>
+                  the tool descriptions
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         1.0.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         &lt;extension
+           point=&quot;com.samsung.tizen.common.connection.tools&quot;&gt;
+     &lt;tools
+           binaryname=&quot;oprofile_armel.tar&quot;
+           sourcepath=&quot;/SDK/develop-tool&quot;
+           architecture=&quot;armel&quot;
+           compressed=&quot;true&quot;
+           description=&quot;oprofile library&quot;&gt;
+&lt;/extension&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
index aef7cc1..fc19f66 100644 (file)
@@ -1,11 +1,16 @@
 package com.samsung.tizen.common.connection;
 
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Properties;
 
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.RegistryFactory;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
 
+import com.samsung.tizen.common.connection.debugtools.DebugTool;
 import com.samsung.tizen.sdblib.FileListingService.FileEntry;
 import com.samsung.tizen.sdblib.IDevice;
 import com.samsung.tizen.sdblib.Log;
@@ -23,6 +28,8 @@ public class ConnectionPlugin extends AbstractUIPlugin {
        public static final String PLUGIN_ID = "com.samsung.tizen.common.connection"; //$NON-NLS-1$
        public static final String ID_LOGS_VIEW= "com.samsung.tizen.common.connection.ui.LogView"; //$NON-NLS-1$
        public static final String ID_CONNECTION_VIEW= "com.samsung.tizen.common.connection.ui.ConnectionExplorer";
+       public static String ID_DEBUGTOOLS_EXTENSION = "com.samsung.tizen.common.connection.tools"; //$NON-NLS-1$
+       
        // The shared instance
        private static ConnectionPlugin plugin;
        
@@ -81,7 +88,27 @@ public class ConnectionPlugin extends AbstractUIPlugin {
                
                
        }
+       public static synchronized  List<DebugTool> getDebugTools() {
+               List<DebugTool> toolLists = new ArrayList<DebugTool>();
+               
+               IExtensionRegistry x = RegistryFactory.getRegistry();
+               IConfigurationElement[] ces = x.getConfigurationElementsFor(ID_DEBUGTOOLS_EXTENSION);
+               for (int i = 0; i < ces.length; ++i) {
+                       IConfigurationElement ce = ces[i];
+                       if (ce.getName().equals("tools")) { 
+                               String binaryname = ce.getAttribute("binaryname"); 
+                               String sourcepath = ce.getAttribute("sourcepath"); 
+                               String description = ce.getAttribute("description"); 
 
+                               DebugTool dt = new DebugTool();
+                               dt.setBinaryname(binaryname);
+                               dt.setSourcepath(sourcepath);
+                               dt.setDescription(description);
+                               toolLists.add(dt);
+                       }
+               }
+               return toolLists;
+       }
        /*
         * (non-Javadoc)
         * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/DebugTool.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/DebugTool.java
new file mode 100644 (file)
index 0000000..e682edb
--- /dev/null
@@ -0,0 +1,57 @@
+package com.samsung.tizen.common.connection.debugtools;
+
+public class DebugTool {
+       final public static String CONTROL_EXTENSION = ".control";
+       private String binaryname; 
+       private String packagename;
+       private String sourcepath; 
+       private String architecture; 
+       private String description;
+       private String controlfile;
+       private String version;
+       public DebugTool() { 
+               
+       }
+       public String getBinaryname() {
+               return binaryname;
+       }
+       public String getControlFile() { 
+               return this.controlfile;
+       }
+       public String getVersion() {
+               return this.version;
+       }
+       public void setBinaryname(String binaryname) {
+               this.binaryname = binaryname;
+               // om.samsung.dev1-customize_1.0.0_i386.deb
+               String[] filename = this.binaryname.split("_");
+               this.packagename = filename[0];
+               this.version = filename[1];             
+               String[] arch = filename[2].split("\\.");
+               this.architecture = arch[0];
+               this.controlfile = "."+filename[0] + CONTROL_EXTENSION;
+               
+       }
+       public String getPackagename() {
+               return this.packagename;
+       }
+       public String getSourcepath() {
+               return sourcepath;
+       }
+       public void setSourcepath(String sourcepath) {
+               this.sourcepath = sourcepath;
+       }
+       public String getArchitecture() {
+               return architecture;
+       }
+       public void setArchitecture(String architecture) {
+               this.architecture = architecture;
+       }
+       public String getDescription() {
+               return description;
+       }
+       public void setDescription(String description) {
+               this.description = description;
+       }
+       
+}
diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/Messages.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/Messages.java
new file mode 100644 (file)
index 0000000..0a838f7
--- /dev/null
@@ -0,0 +1,126 @@
+/*\r
+ * Messages.java\r
+ *\r
+ * Copyright (C) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * YoonKi Park <yoonki.park@samsung.com>\r
+ * Hoon Kang <h245.kang@samsung.com>\r
+ *\r
+ * This program and the accompanying materials are made available\r
+ * under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ *\r
+ */\r
+package com.samsung.tizen.common.connection.debugtools;\r
+\r
+import java.util.MissingResourceException;\r
+import java.util.ResourceBundle;\r
+\r
+public class Messages {\r
+       private static final String BUNDLE_NAME = "com.samsung.tizen.common.connection.debugtools.messages"; //$NON-NLS-1$\r
+\r
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle\r
+                       .getBundle(BUNDLE_NAME);\r
+\r
+       private Messages() {\r
+       }\r
+       \r
+       public static String getString(String key) {\r
+               // TODO Auto-generated method stub\r
+               try {\r
+                       return RESOURCE_BUNDLE.getString(key);\r
+               } catch (MissingResourceException e) {\r
+                       return '!' + key + '!';\r
+               }\r
+       }\r
+       \r
+       public static String getString(String key, Object binding) {\r
+               // TODO Auto-generated method stub\r
+               try {\r
+                       return RESOURCE_BUNDLE.getString(key);\r
+               } catch (MissingResourceException e) {\r
+                       return '!' + key + '!';\r
+               }\r
+       }\r
+       private static String messageBind(String message, Object[] args, String argZero, String argOne) {\r
+               int length = message.length();\r
+               //estimate correct size of string buffer to avoid growth\r
+               int bufLen = length + (args.length * 5);\r
+               if (argZero != null)\r
+                       bufLen += argZero.length() - 3;\r
+               if (argOne != null)\r
+                       bufLen += argOne.length() - 3;\r
+               StringBuffer buffer = new StringBuffer(bufLen < 0 ? 0 : bufLen);\r
+               for (int i = 0; i < length; i++) {\r
+                       char c = message.charAt(i);\r
+                       switch (c) {\r
+                               case '{' :\r
+                                       int index = message.indexOf('}', i);\r
+                                       // if we don't have a matching closing brace then...\r
+                                       if (index == -1) {\r
+                                               buffer.append(c);\r
+                                               break;\r
+                                       }\r
+                                       i++;\r
+                                       if (i >= length) {\r
+                                               buffer.append(c);\r
+                                               break;\r
+                                       }\r
+                                       // look for a substitution\r
+                                       int number = -1;\r
+                                       try {\r
+                                               number = Integer.parseInt(message.substring(i, index));\r
+                                       } catch (NumberFormatException e) {\r
+                                               throw (IllegalArgumentException) new IllegalArgumentException().initCause(e);\r
+                                       }\r
+                                       if (number == 0 && argZero != null)\r
+                                               buffer.append(argZero);\r
+                                       else if (number == 1 && argOne != null)\r
+                                               buffer.append(argOne);\r
+                                       else {\r
+                                               if (number >= args.length || number < 0) {\r
+                                                       buffer.append("<missing argument>"); //$NON-NLS-1$\r
+                                                       i = index;\r
+                                                       break;\r
+                                               }\r
+                                               buffer.append(args[number]);\r
+                                       }\r
+                                       i = index;\r
+                                       break;\r
+                               case '\'' :\r
+                                       // if a single quote is the last char on the line then skip it\r
+                                       int nextIndex = i + 1;\r
+                                       if (nextIndex >= length) {\r
+                                               buffer.append(c);\r
+                                               break;\r
+                                       }\r
+                                       char next = message.charAt(nextIndex);\r
+                                       // if the next char is another single quote then write out one\r
+                                       if (next == '\'') {\r
+                                               i++;\r
+                                               buffer.append(c);\r
+                                               break;\r
+                                       }\r
+                                       // otherwise we want to read until we get to the next single quote\r
+                                       index = message.indexOf('\'', nextIndex);\r
+                                       // if there are no more in the string, then skip it\r
+                                       if (index == -1) {\r
+                                               buffer.append(c);\r
+                                               break;\r
+                                       }\r
+                                       // otherwise write out the chars inside the quotes\r
+                                       buffer.append(message.substring(nextIndex, index));\r
+                                       i = index;\r
+                                       break;\r
+                               default :\r
+                                       buffer.append(c);\r
+                       }\r
+               }\r
+               return buffer.toString();\r
+       }\r
+}\r
@@ -1,10 +1,11 @@
-package com.samsung.tizen.common.connection.explorer;
+package com.samsung.tizen.common.connection.debugtools;
 
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
@@ -13,6 +14,7 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 
+import com.samsung.tizen.common.connection.ConnectionPlugin;
 import com.samsung.tizen.common.properties.InstallPathConfig;
 import com.samsung.tizen.sdblib.IDevice;
 import com.samsung.tizen.sdblib.SdbCommandRejectedException;
@@ -32,10 +34,8 @@ class PackageInstallMonitorDialog extends ProgressMonitorDialog {
 
 class InstallProgress implements IRunnableWithProgress {
 
-       final private String DEVELOPER_PATH = "/home/developer/";
-       final private String TOOLS_TARGET_PATH = "/home/developer/sdk_tools/";
-       final private String TOOLS_HOST_PATH = InstallPathConfig.getSDKPath()
-                       + "/SDK/develop-tool/";
+       final private String TOOLS_TARGET_PATH = "/home/developer/sdk_tools";
+       final private String TOOLS_HOST_PATH = InstallPathConfig.getSDKPath();
        final private String CMD_RESULT_CHECK = "; echo $?";
 
        private IDevice device = null;
@@ -67,7 +67,7 @@ class InstallProgress implements IRunnableWithProgress {
                boolean makeResult = false;
                SdbShellProcess lsProc;
                try {
-                       lsProc = device.executeShellCommand("mkdir " + dir
+                       lsProc = device.executeShellCommand("mkdir -p -m 755 " + dir
                                        + CMD_RESULT_CHECK);
                        BufferedReader br = new BufferedReader(new InputStreamReader(
                                        lsProc.getInputStream()));
@@ -86,45 +86,42 @@ class InstallProgress implements IRunnableWithProgress {
                return makeResult;
        }
 
-       private ArrayList<String> getPackageList() {
-               ArrayList<String> packageList = new ArrayList<String>();
-               try {
-                       Process lsProc = Runtime.getRuntime().exec(
-                                       "ls " + TOOLS_HOST_PATH + " -1");
-                       BufferedReader br = new BufferedReader(new InputStreamReader(
-                                       lsProc.getInputStream()));
-
-                       String lsMsg = null;
-                       while (null != (lsMsg = br.readLine())) {
-                               if (lsMsg.contains(".tar") && lsMsg.contains("_")) {
-                                       packageList.add(lsMsg);
-                               }
-                       }
-                       br.close();
-                       return packageList;
-
-               } catch (IOException e) {
-                       return packageList;
-               }
-       }
-
-       private boolean isInstalled(String packageFile) {
+       private boolean isInstalled(DebugTool dt) {
                boolean ret = false;
                try {
-                       SdbShellProcess lsProc = device.executeShellCommand("ls "
-                                       + TOOLS_TARGET_PATH + "."
-                                       + getPackageNameFromFileName(packageFile) + ".txt"
-                                       + CMD_RESULT_CHECK);
+                       
+                       SdbShellProcess echoProc = device
+                                       .executeShellCommand("cat "
+                                                       + TOOLS_TARGET_PATH + "/" + dt.getControlFile() + CMD_RESULT_CHECK);
                        BufferedReader br = new BufferedReader(new InputStreamReader(
-                                       lsProc.getInputStream()));
+                                       echoProc.getInputStream()));
+                       
                        String lsOut = null;
                        String lastOut = null;
+                       String oldVersion = null;
                        while (null != (lsOut = br.readLine())) {
+                               //version:0.0.0                         
+                               if (lsOut.toLowerCase().startsWith("version:")) {
+                                       oldVersion = lsOut.split(":")[1];
+                               }                                       
                                lastOut = lsOut;
                        }
-                       if (null != lastOut && lastOut.equals("0")) {
-                               ret = true;
-                       }
+                       if (null != lastOut) {
+                               if (lastOut.equals("0")) {
+                                       String v1 = normalisedVersion(oldVersion,".",4);
+                                       String v2 = normalisedVersion(dt.getVersion(),".",4);
+                                       if (v2.compareTo(v1) > 0) { 
+                                               //TODO : do install and save!
+                                               removeOldPackage(dt.getPackagename());
+                                               ret = false;
+                                       } else {//same version
+                                               ret = true;
+                                       }
+                               }
+                               else 
+                                       ret = false;                                            
+                       } else 
+                               ret = false;            
                        br.close();
                } catch (IOException e) {
                        return true;
@@ -132,13 +129,28 @@ class InstallProgress implements IRunnableWithProgress {
                return ret;
 
        }
-
-       private boolean copyPackage(String packageFile) {
+       private String normalisedVersion (String version, String sep, int maxWidth) {
+               String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
+               StringBuilder sb = new StringBuilder();         
+               for (String s : split) {             
+                       sb.append(String.format("%" + maxWidth + 's', s));        
+               }        
+               return sb.toString();    
+       }
+       private void removeOldPackage(String packagename) {
+               try {
+                       SdbShellProcess echoProc = device.executeShellCommand("rm -rf " + TOOLS_TARGET_PATH + "/" + packagename);
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+               
+       }
+       private boolean copyPackage(String source, String destination) {
                boolean pushResult = false;
                try {
                        SyncService syncService = device.getSyncService();
-                       SyncResult pushSyncResult = syncService.pushFile(TOOLS_HOST_PATH
-                                       + packageFile, TOOLS_TARGET_PATH + packageFile,
+                       SyncResult pushSyncResult = syncService.pushFile(source, destination,
                                        SyncService.getNullProgressMonitor());
                        if (SyncService.RESULT_OK == pushSyncResult.getCode()) {
                                pushResult = true;
@@ -166,12 +178,12 @@ class InstallProgress implements IRunnableWithProgress {
                }
        }
 
-       private void makeInstallFile(String packageName) {
+       private void saveControlfile(String controlFile,String version) {
 
                try {
                        SdbShellProcess echoProc = device
-                                       .executeShellCommand("echo installed > "
-                                                       + TOOLS_TARGET_PATH + "." + packageName + ".txt");
+                                       .executeShellCommand("echo 'version:"+version+ "' >"
+                                                       + TOOLS_TARGET_PATH + "/" + controlFile );
                        BufferedReader br = new BufferedReader(new InputStreamReader(
                                        echoProc.getInputStream()));
                        while (null != br.readLine()) {
@@ -184,8 +196,9 @@ class InstallProgress implements IRunnableWithProgress {
 
        private void removeTar(String packageFile) {
                try {
-                       SdbShellProcess echoProc = device.executeShellCommand("rm "
-                                       + TOOLS_TARGET_PATH + packageFile);
+                       SdbShellProcess echoProc = device.executeShellCommand("cd "
+                                       + TOOLS_TARGET_PATH + " && rm " + packageFile);
+                       
                        BufferedReader br = new BufferedReader(new InputStreamReader(
                                        echoProc.getInputStream()));
                        while (null != br.readLine()) {
@@ -195,75 +208,73 @@ class InstallProgress implements IRunnableWithProgress {
                }
        }
 
-       final private void installPackage(String packageFile) {
-               String packageName = getPackageNameFromFileName(packageFile);
-               boolean isCopied = copyPackage(packageFile);
+       final private void installPackage(DebugTool tool) {
+               String local = TOOLS_HOST_PATH+"/"+tool.getSourcepath() + "/" + tool.getBinaryname();
+               String remote = TOOLS_TARGET_PATH + "/" + tool.getBinaryname();
+               
+               // delete old version
+               try {
+                       SdbShellProcess echoProc = device.executeShellCommand("cd "
+                                       + TOOLS_TARGET_PATH + " && rm " + tool.getControlFile());
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+               
+               
+               boolean isCopied = copyPackage(local, remote);
                monitor.worked(5);
                if (isCopied) {
-                       unzipPackage(packageFile);
+                       unzipPackage( tool.getBinaryname());
                        monitor.worked(2);
-                       makeInstallFile(packageName);
+                       saveControlfile( tool.getControlFile(),tool.getVersion());
                        monitor.worked(1);
-                       removeTar(packageFile);
+                       removeTar(tool.getBinaryname());
                        monitor.worked(1);
                }
        }
 
-       private String getPackageNameFromFileName(String fileName) {
-               String packageName = null;
-               String[] packageElement = fileName.split("_");
-               if (null != packageElement && packageElement.length > 1) {
-                       packageName = packageElement[0];
-               }
-               return packageName;
-       }
-
        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException,
                        InterruptedException {
 
-               // mkdir /home/developer/sdk_tools/
                final IProgressMonitor fmonitor = monitor;
                this.monitor = monitor;
-               monitor.beginTask("Package Install Progress", 100);
-               monitor.subTask("Prepare install");
-               // make derectory
-               if (!checkDirectory(TOOLS_TARGET_PATH)) {
-                       if (checkDirectory(DEVELOPER_PATH)) {
-                               // mkdir 'home/developer/sdk_tools'
-                               makeDirectory(TOOLS_TARGET_PATH);
-                       } else {
-                               // mkdir 'home/developer'
-                               makeDirectory(DEVELOPER_PATH);
-                               // mkdir 'home/developer/sdk_tools'
-                               makeDirectory(TOOLS_TARGET_PATH);
-                       }
-               }
-
-               // if (!checkDirectory(TOOLS_TARGET_PATH)) {
-               // makeDirectory(TOOLS_TARGET_PATH);
-               // }
+               
+               monitor.beginTask(Messages.getString("debugtools.initilize"), 100);
+               //monitor.subTask("Prepare install");
+               
+               // check directory exist
+               if (!checkDirectory(TOOLS_TARGET_PATH)) 
+                       makeDirectory(TOOLS_TARGET_PATH);
 
                monitor.worked(10);
 
                // get package list to install
-               final ArrayList<String> packageList = getPackageList();
+               final List<DebugTool>  debugTools = ConnectionPlugin.getDebugTools();
                monitor.worked(15);
 
                // install loop (cp, tar)
-               int packageCnt = packageList.size();
-               for (int i = 0; i < packageCnt; i++) {
-                       final boolean isInstalled = isInstalled(packageList.get(i));
-                       monitor.subTask("Install "
-                                       + getPackageNameFromFileName(packageList.get(i)));
-                       monitor.worked(1);
-                       final int index = i;
+               for (int i=0 ; i<debugTools.size(); i++) {
+                       final DebugTool dt = (DebugTool)debugTools.get(i);
+                       
+                       if (device.isEmulator()) {
+                               if (!dt.getArchitecture().equals("i386"))
+                                       continue;
+                       }
+                       else {
+                               if (!dt.getArchitecture().equals("armel"))
+                                       continue;
+                       }
+                       
+                       final boolean isInstalled = isInstalled(dt);
+                       
                        Thread thread = new Thread(null, new Runnable() {
 
                                @Override
                                public void run() {
                                        if (!isInstalled) {
-                                               installPackage(packageList.get(index));
+                                               installPackage(dt);
                                        } else {
                                                fmonitor.worked(7);
                                        }
@@ -280,38 +291,18 @@ class InstallProgress implements IRunnableWithProgress {
 
 }
 
-public class PackageInstaller {
+public class ToolsInstall {
 
        public static void installPackages(IDevice device) {
                final IDevice tDevice = device;
 
-               if (device.isEmulator()) {
+               if (tDevice.isOffline()) {
                        return;
                }
 
                Display.getDefault().asyncExec(new Runnable() {
-
-                       private void delay() {
-                               if (tDevice.isOffline()) {
-                                       for (int i = 0; i < 30; i++) {
-                                               try {
-                                                       Thread.sleep(50);
-                                               } catch (InterruptedException e) {
-                                                       e.printStackTrace();
-                                               }
-                                               if (tDevice.isOnline()) {
-                                                       break;
-                                               }
-                                       }
-                               }
-                       }
-
                        @Override
                        public void run() {
-                               delay();
-                               if (tDevice.isOffline()) {
-                                       return;
-                               }
                                final PackageInstallMonitorDialog installDialog = new PackageInstallMonitorDialog(
                                                Display.getDefault().getActiveShell());
                                try {
@@ -323,7 +314,6 @@ public class PackageInstaller {
                                } catch (InterruptedException e) {
                                        return;
                                }
-
                        }
                });
 
diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/messages.properties b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/debugtools/messages.properties
new file mode 100644 (file)
index 0000000..982fa4b
--- /dev/null
@@ -0,0 +1,2 @@
+\r
+debugtools.initilize=Connection Explorer is initializing now. It might take few minutes. \r
index 3e6a486..247a90b 100644 (file)
@@ -54,6 +54,7 @@ import com.samsung.tizen.common.connection.ddmuilib.Panel;
 import com.samsung.tizen.common.connection.ddmuilib.SyncProgressMonitor;
 import com.samsung.tizen.common.connection.ddmuilib.TableHelper;
 import com.samsung.tizen.common.connection.ddmuilib.console.DdmConsole;
+import com.samsung.tizen.common.connection.debugtools.ToolsInstall;
 import com.samsung.tizen.common.connection.sdblib.dnd.FileEntryTransfer;
 import com.samsung.tizen.sdblib.FileListingService;
 import com.samsung.tizen.sdblib.FileListingService.FileEntry;
@@ -1007,6 +1008,7 @@ public class ConnectionExplorerPanel extends Panel
        }
 
        /**
+<<<<<<< Updated upstream
         * Sent when the a device is connected to the {@link SmartDevelopmentBridge}
         * .
         * <p/>
@@ -1020,6 +1022,19 @@ public class ConnectionExplorerPanel extends Panel
        public void deviceConnected(IDevice device) {
 //             PackageInstaller.installPackages(device);
                if (device.isOffline())
+=======
+     * Sent when the a device is connected to the {@link SmartDevelopmentBridge}.
+     * <p/>
+     * This is sent from a non UI thread.
+     * @param device the new device.
+     *
+     * @see IDeviceChangeListener#deviceConnected(IDevice)
+     */
+       public void deviceConnected(IDevice device)
+       {
+               ToolsInstall.installPackages(device);
+               if( device.isOffline())
+>>>>>>> Stashed changes
                        return;
                mDevicesList.add(device);
                exec(new Runnable() {