VIEW: ROOTSTRAP: Added host ip text control to remote connection dialog.
authordonghyuk.yang <donghyuk.yang@samsung.com>
Mon, 12 May 2014 05:38:10 +0000 (14:38 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Mon, 12 May 2014 05:38:10 +0000 (14:38 +0900)
If host has multiple IP address, user should set an IP address. The ip
address is used by gdb when debugging a platform project on windows.

Change-Id: I2272c1fa6e07884f4dd7e94a38ce1fcb4da499d6
Signed-off-by: donghyuk.yang <donghyuk.yang@samsung.com>
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/PreferencesManager.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PlatformLaunchUtil.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RemoteConnectionDialog.java

index 3a02fd5..7702bc2 100644 (file)
@@ -800,9 +800,9 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         // FIX: device.isEmulator() is not working
         // if (device.isEmulator()) {
         if (ip == null) {
-            InetAddress hostIp = InetAddress.getLocalHost();
-            wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST,
-                    hostIp.getHostAddress());
+            //InetAddress hostIp = InetAddress.getLocalHost();
+            String hostIp = PlatformLaunchUtil.getHostIp();
+            wc.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, hostIp);
             gdbserverPort = Integer.parseInt(config.getAttribute(
                     TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT,
                     TizenLaunchConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT));
index 5b220b0..2ac02e2 100644 (file)
@@ -45,6 +45,7 @@ import org.tizen.nativeplatform.Activator;
 public class PreferencesManager {
 
     public static final String PASSWORD_KEY = "sudo.password";
+    public static final String HOST_IP = "host.ip";
 
     private static final String GIT_ACTIVE_CONFIG = "git.active.config";
     private static final String GIT_CONFIG_NAME = "site.config.name";
@@ -82,6 +83,14 @@ public class PreferencesManager {
         prefStore.setValue(PASSWORD_KEY, p);
     }
 
+    public static void setHostIp(String value) {
+        prefStore.setValue(HOST_IP, value);
+    }
+
+    public static String getHostIp() {
+        return prefStore.getString(HOST_IP);
+    }
+
     public static boolean isProxyUsed() {
         return isSystemProxyUsed();
     }
index 094ca24..2a7b169 100644 (file)
@@ -34,6 +34,8 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -75,6 +77,7 @@ import org.tizen.nativeplatform.pkg.tools.PkgcmdTool;
 import org.tizen.nativeplatform.pkg.tools.RpmTool;
 import org.tizen.nativeplatform.pkg.tools.ZypperTool;
 import org.tizen.nativeplatform.preferences.DevicePreferencesManager;
+import org.tizen.nativeplatform.preferences.PreferencesManager;
 import org.tizen.nativeplatform.preferences.RootstrapPreferencesManager;
 import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
 import org.tizen.nativeplatform.types.CmdTargetTypes;
@@ -466,7 +469,7 @@ public class PlatformLaunchUtil {
         }
         return smackInfo;
     }
-    
+
     public static IPkgCommander.TOOL getDeviceEflPkgTool() {
         String tool = DevicePreferencesManager.getDeviceEflInstallTool();
         if (tool.equals(PkgcmdTool.NAME)) {
@@ -476,7 +479,7 @@ public class PlatformLaunchUtil {
         }
         return IPkgCommander.TOOL.PKGCMD;
     }
-    
+
     public static IPkgCommander.TOOL getDeviceLocalPkgTool() {
         String tool = DevicePreferencesManager.getDeviceLocalPkgInstallTool();
         if (tool.equals(ZypperTool.NAME)) {
@@ -486,7 +489,7 @@ public class PlatformLaunchUtil {
         }
         return IPkgCommander.TOOL.RPM;
     }
-    
+
     public static IPkgCommander.TOOL getDeviceRemotePkgTool() {
         String tool = DevicePreferencesManager.getDeviceRemotePkgInstallTool();
         if (tool.equals(ZypperTool.NAME)) {
@@ -496,19 +499,19 @@ public class PlatformLaunchUtil {
         }
         return IPkgCommander.TOOL.ZYPPER;
     }
-    
+
     public static String getDeviceEflPkgInstallOp() {
         return DevicePreferencesManager.getDeviceEflInstallOp();
     }
-    
+
     public static String getDeviceLocalPkgInstallOp() {
         return DevicePreferencesManager.getDeviceLocalPkgInstallOp();
     }
-    
+
     public static String getDeviceRemotePkgInstallOp() {
         return DevicePreferencesManager.getDeviceRemotePkgInstallOp();
     }
-    
+
     public static IPkgCommander.TOOL getRootstrapLocalPkgTool() {
         String tool = RootstrapPreferencesManager.getRootstrapLocalPkgInstallTool();
         if (tool.equals(ZypperTool.NAME)) {
@@ -518,7 +521,7 @@ public class PlatformLaunchUtil {
         }
         return IPkgCommander.TOOL.ZYPPER;
     }
-    
+
     public static IPkgCommander.TOOL getRootstrapRemotePkgTool() {
         String tool = RootstrapPreferencesManager.getRootstrapRemotePkgInstallTool();
         if (tool.equals(ZypperTool.NAME)) {
@@ -532,8 +535,23 @@ public class PlatformLaunchUtil {
     public static String getRootstrapLocalPkgInstallOp() {
         return RootstrapPreferencesManager.getRootstrapLocalPkgInstallOp();
     }
-    
+
     public static String getRootstrapRemotePkgInstallOp() {
         return RootstrapPreferencesManager.getRootstrapRemotePkgInstallOp();
     }
+
+    public static String getHostIp() {
+        String prefIp = PreferencesManager.getHostIp();
+        if (!prefIp.isEmpty()) {
+            return prefIp;
+        } else {
+            try {
+                InetAddress hostIp = InetAddress.getLocalHost();
+                return hostIp.getHostAddress();
+            } catch (UnknownHostException e) {
+                e.printStackTrace();
+            }
+        }
+        return "";
+    }
 }
index d5a9ffa..db7c13c 100644 (file)
@@ -49,13 +49,16 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 import org.tizen.common.util.DialogUtil;
 import org.tizen.common.util.log.UserLogger;
+import org.tizen.nativeplatform.preferences.PreferencesManager;
 import org.tizen.nativeplatform.preferences.RemoteServerPreferencesManager;
 import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager;
+import org.tizen.nativeplatform.util.PlatformLaunchUtil;
 import org.tizen.nativeplatform.util.PlatformUserInteraction;
 import org.tizen.nativeplatform.util.SSHUtil;
 
@@ -68,11 +71,12 @@ public class RemoteConnectionDialog extends Dialog {
     private Text passText;
     private Text sshPrivateText;
     private Text sshPublicText;
+    private Text hostIpText;
 
     private int x = 0;
     private int y = 0;
     private int width = 400;
-    private int height = 300;
+    private int height = 400;
 
     private boolean connected = false;
 
@@ -115,16 +119,32 @@ public class RemoteConnectionDialog extends Dialog {
         composite.setLayout(new GridLayout(1, false));
 
         createGuideComposite(composite);
+        createHostComposite(composite);
         createConnectionComposite(composite);
         createSshComposite(composite);
-        return null;
+        hostText.setFocus();
+        return composite;
     }
 
-    private void createSshComposite(Composite parent) {
+    private void createHostComposite(Composite parent) {
         Composite composite = new Composite(parent, SWT.NONE);
+        composite.setLayout(new GridLayout(2, false));
+        GridData gridData = new GridData(GridData.FILL_BOTH);
+        composite.setLayoutData(gridData);
+        Label hostIplabel = new Label(composite, SWT.NONE);
+        hostIplabel.setText("Your IP address:");
+        hostIpText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+        hostIpText.setLayoutData(gridData);
+        hostIpText.setText(PlatformLaunchUtil.getHostIp());
+        Label space = new Label(composite, SWT.NONE);
+    }
+
+    private void createSshComposite(Composite parent) {
+        Group composite = new Group(parent, SWT.NONE);        
         composite.setLayout(new GridLayout(3, false));
         GridData gridData = new GridData(GridData.FILL_BOTH);
         composite.setLayoutData(gridData);
+        composite.setText("SSH keys");
 
         gridData = new GridData(GridData.FILL_HORIZONTAL);
         gridData.minimumHeight = 0;
@@ -211,16 +231,17 @@ public class RemoteConnectionDialog extends Dialog {
     }
 
     private void createConnectionComposite(Composite parent) {
-        Composite composite = new Composite(parent, SWT.NONE);
+        Group composite = new Group(parent, SWT.NONE);
         composite.setLayout(new GridLayout(2, false));
         GridData gridData = new GridData(GridData.FILL_BOTH);
         composite.setLayoutData(gridData);
+        composite.setText("Remote server");
 
         gridData = new GridData(GridData.FILL_HORIZONTAL);
         gridData.minimumHeight = 0;
 
         Label hostLabel = new Label(composite, SWT.NONE);
-        hostLabel.setText("Host:");
+        hostLabel.setText("IP address:");
         hostText = new Text(composite, SWT.SINGLE | SWT.BORDER);
         hostText.setLayoutData(gridData);
         hostText.setText(RemoteServerPreferencesManager.getRemoteServerHost());
@@ -234,6 +255,7 @@ public class RemoteConnectionDialog extends Dialog {
         passText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
         passText.setLayoutData(gridData);
         // passText.setText(PreferencesManager.getRemoteServerPasswd());
+        Label space = new Label(composite, SWT.NONE);
     }
 
     public boolean connected() {
@@ -247,9 +269,10 @@ public class RemoteConnectionDialog extends Dialog {
         final String pass = passText.getText();
         final String privateKey = sshPrivateText.getText();
         final String publicKey = sshPublicText.getText();
+        final String hostIp = hostIpText.getText();
 
         boolean isNotOk = host.isEmpty() || user.isEmpty() || pass.isEmpty()
-                || privateKey.isEmpty() || publicKey.isEmpty();
+                || privateKey.isEmpty() || publicKey.isEmpty() || hostIp.isEmpty();
 
         if (isNotOk) {
             DialogUtil.openErrorDialog("Please input all connection information.");
@@ -270,6 +293,7 @@ public class RemoteConnectionDialog extends Dialog {
                         UserLogger.end(PlatformUserInteraction.CONNECT_SSH);
                         if (!connected) {
                             DialogUtil.openMessageDialog(getShell(), "Failed to connect");
+                            return;
                         } else {
                             if (!SSHUtil.isSetAuthorizedKey(publicKey)) {
                                 if (SSHUtil.registerAuthorizedKey(publicKey)) {
@@ -279,6 +303,7 @@ public class RemoteConnectionDialog extends Dialog {
                                 } else {
                                     DialogUtil.openErrorDialog(getShell(), "Error",
                                             "Failed to register public key");
+                                    return;
                                 }
                             }
                         }
@@ -291,6 +316,7 @@ public class RemoteConnectionDialog extends Dialog {
             return;
         }
 
+        PreferencesManager.setHostIp(hostIp);
         super.okPressed();
     }
 }