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;
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;
}
return smackInfo;
}
-
+
public static IPkgCommander.TOOL getDeviceEflPkgTool() {
String tool = DevicePreferencesManager.getDeviceEflInstallTool();
if (tool.equals(PkgcmdTool.NAME)) {
}
return IPkgCommander.TOOL.PKGCMD;
}
-
+
public static IPkgCommander.TOOL getDeviceLocalPkgTool() {
String tool = DevicePreferencesManager.getDeviceLocalPkgInstallTool();
if (tool.equals(ZypperTool.NAME)) {
}
return IPkgCommander.TOOL.RPM;
}
-
+
public static IPkgCommander.TOOL getDeviceRemotePkgTool() {
String tool = DevicePreferencesManager.getDeviceRemotePkgInstallTool();
if (tool.equals(ZypperTool.NAME)) {
}
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)) {
}
return IPkgCommander.TOOL.ZYPPER;
}
-
+
public static IPkgCommander.TOOL getRootstrapRemotePkgTool() {
String tool = RootstrapPreferencesManager.getRootstrapRemotePkgInstallTool();
if (tool.equals(ZypperTool.NAME)) {
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 "";
+ }
}
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;
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;
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;
}
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());
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() {
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.");
UserLogger.end(PlatformUserInteraction.CONNECT_SSH);
if (!connected) {
DialogUtil.openMessageDialog(getShell(), "Failed to connect");
+ return;
} else {
if (!SSHUtil.isSetAuthorizedKey(publicKey)) {
if (SSHUtil.registerAuthorizedKey(publicKey)) {
} else {
DialogUtil.openErrorDialog(getShell(), "Error",
"Failed to register public key");
+ return;
}
}
}
return;
}
+ PreferencesManager.setHostIp(hostIp);
super.okPressed();
}
}