From: donghyuk.yang Date: Tue, 2 Sep 2014 06:16:12 +0000 (+0900) Subject: LAUNCH: Select SCP or SDB to push package files in windows X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8acd3dcc970c68c53c5bdf768b0de5d7b268c873;p=sdk%2Fide%2Fnativeplatform-eplugin.git LAUNCH: Select SCP or SDB to push package files in windows In windows, target uses scp tool to get package files as default. But, some targets do not has scp tool. So, IDE supports sdb tool also. Now, user can select scp or sdb tool to push package files. Change-Id: I45a377baea3e242d4375ed90208fb030f858885a Signed-off-by: donghyuk.yang --- diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java index 469a7a4..917aaaf 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java @@ -45,23 +45,23 @@ public interface IPkgCommander { } PackageManagerOutputReceiver getOutputReceiver(); - + void actionBeforeUsingZypper(); void setHttpProxy(String proxy); - + String getArchFromRemoteFile(String filePath); String getNameFromRemoteFile(String filePath); - String getVerFromRemoteFile(String filePath); + String getVerFromRemoteFile(String filePath); String getArchFromFile(String filePath); String getNameFromFile(String filePath); String getVerFromFile(String filePath); - + String[] getInfoFromFile(String filePath); String[] getArch(String pkg); @@ -79,7 +79,7 @@ public interface IPkgCommander { ICommandStatus installLocalPkg(String[] files, boolean isEfl, IProgressMonitor monitor); ICommandStatus installLocalPkg(String[] files, IProgressMonitor monitor); - + ICommandStatus installLocalPkg(String file, boolean isEfl, IProgressMonitor monitor); ICommandStatus installLocalPkg(String file, IProgressMonitor monitor); @@ -91,10 +91,14 @@ public interface IPkgCommander { ICommandStatus uninstallPkg(String[] pkgs, IProgressMonitor monitor); ICommandStatus uninstallPkg(String pkg, IProgressMonitor monitor); - - ICommandStatus downloadFilesFromRemote(String[] fileList); - - ICommandStatus downlaodFileFromRemote(String src, String dst); + + ICommandStatus downloadRemoteFiles(String[] fileList); + + ICommandStatus downloadRemoteFiles(String[] fileList, boolean useSdb); + + ICommandStatus downloadRemoteFile(String src, String dst, boolean useSdb); + + ICommandStatus downloadRemoteFile(String src, String dst); ICommandStatus copyFilesToTmpDir(String[] fileList); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/deb/DebCommanderHost.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/deb/DebCommanderHost.java index e600325..3464f99 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/deb/DebCommanderHost.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/deb/DebCommanderHost.java @@ -326,15 +326,6 @@ public class DebCommanderHost implements IPkgCommander { return null; } - @Override - public ICommandStatus downloadFilesFromRemote(String[] fileList) { - return null; - } - - public ICommandStatus downlaodFileFromRemote(String src, String dst) { - return null; - } - @Override public void actionBeforeUsingZypper() { } @@ -353,4 +344,24 @@ public class DebCommanderHost implements IPkgCommander { public ICommandStatus installLocalPkg(String file, boolean isEfl, IProgressMonitor monitor) { return null; } + + @Override + public ICommandStatus downloadRemoteFiles(String[] fileList) { + return null; + } + + @Override + public ICommandStatus downloadRemoteFiles(String[] fileList, boolean useSdb) { + return null; + } + + @Override + public ICommandStatus downloadRemoteFile(String src, String dst, boolean useSdb) { + return null; + } + + @Override + public ICommandStatus downloadRemoteFile(String src, String dst) { + return null; + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java index d13211b..75a1ec3 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java @@ -164,11 +164,19 @@ public abstract class RpmCommanderCommon implements IPkgCommander { } } - public ICommandStatus downloadFilesFromRemote(String[] fileList) { + public ICommandStatus downloadRemoteFiles(String[] fileList) { return null; } - public ICommandStatus downlaodFileFromRemote(String src, String dst) { + public ICommandStatus downloadRemoteFiles(String[] fileList, boolean useSdb) { + return null; + } + + public ICommandStatus downloadRemoteFile(String src, String dst) { + return null; + } + + public ICommandStatus downloadRemoteFile(String src, String dst, boolean useSdb) { return null; } @@ -630,13 +638,6 @@ public abstract class RpmCommanderCommon implements IPkgCommander { origStatus.setInstalledVer(version); origStatus.setInstallInfo(PkgInstallTypes.INSTALLED); } - /* - * Package pkg = pkgMap.get(name); if (pkg == null) { - * pkgMap.put(name, new Package(name, version, - * Package.INSTALLINFO.INSTALLED, "", arch)); } else { - * pkg.setInstalledVersion(version); - * pkg.setInstallInfo(Package.INSTALLINFO.INSTALLED); } - */ } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java index a71ea29..3c83c2e 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java @@ -37,6 +37,10 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; +import org.eclipse.ptp.remotetools.core.IRemoteCopyTools; +import org.eclipse.ptp.remotetools.exception.CancelException; +import org.eclipse.ptp.remotetools.exception.RemoteConnectionException; +import org.eclipse.ptp.remotetools.exception.RemoteOperationException; import org.tizen.common.TizenPlatformConstants; import org.tizen.common.util.FilenameUtil; import org.tizen.common.util.OSChecker; @@ -50,8 +54,10 @@ 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.pkgmgr.PackageManagerOutputReceiver; +import org.tizen.nativeplatform.preferences.DevicePreferencesManager; import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager; import org.tizen.nativeplatform.types.CmdTargetTypes; +import org.tizen.nativeplatform.util.PlatformFileUtil; import org.tizen.nativeplatform.util.PlatformLaunchUtil; import org.tizen.nativeplatform.util.PlatformUserInteraction; import org.tizen.nativeplatform.util.SSHUtil; @@ -104,7 +110,40 @@ public class RpmCommanderDevice extends RpmCommanderCommon { return new CommandStatus(IStatus.OK, value, null); } - public ICommandStatus downlaodFileFromRemote(String src, String dst) { + public ICommandStatus downloadRemoteFile(String src, String dst, boolean useSdb) { + if (useSdb) { + return downloadRemoteFileWithSDB(src, dst); + } else { + return downloadRemoteFileWithSCP(src, dst); + } + } + + public ICommandStatus downloadRemoteFile(String src, String dst) { + return downloadRemoteFileWithSDB(src, dst); + } + + private ICommandStatus downloadRemoteFileWithSDB(String src, String dst) { + String filename = FilenameUtil.getFilename(src); + String tmpdir = PlatformFileUtil.getTmpDir(); + String downloadPath = new Path(tmpdir).append(filename).toOSString(); + IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool(); + try { + copytool.downloadFileToFile(src, downloadPath); + } catch (RemoteConnectionException e) { + e.printStackTrace(); + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } catch (RemoteOperationException e) { + e.printStackTrace(); + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } catch (CancelException e) { + e.printStackTrace(); + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } + + return copyFile(downloadPath, dst); + } + + private ICommandStatus downloadRemoteFileWithSCP(String src, String dst) { String keyPath = SSHUtil.getDeviceSshPrivateKeyPath(); String host = RemoteConnectionManager.getRemoteTools().getHost(); String user = RemoteConnectionManager.getRemoteTools().getUser(); @@ -120,7 +159,49 @@ public class RpmCommanderDevice extends RpmCommanderCommon { return status; } - public ICommandStatus downloadFilesFromRemote(String[] fileList) { + private ICommandStatus downloadRemoteFilesWithSDB(String[] fileList) { + List value = new ArrayList(); + List targetPaths = new ArrayList(); + IPath pathOnDevice = new Path(TMP_DIR); + for (String remotePath : fileList) { + String filename = FilenameUtil.getFilename(remotePath); + String tmpdir = PlatformFileUtil.getTmpDir(); + String downloadPath = new Path(tmpdir).append(filename).toOSString(); + IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool(); + try { + copytool.downloadFileToFile(remotePath, downloadPath); + value.add(downloadPath); + targetPaths.add(pathOnDevice.append(filename).toString()); + } catch (RemoteConnectionException e) { + e.printStackTrace(); + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } catch (RemoteOperationException e) { + e.printStackTrace(); + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } catch (CancelException e) { + e.printStackTrace(); + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } + } + SyncService syncService; + try { + syncService = device.getSyncService(); + } catch (TimeoutException e) { + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } catch (SdbCommandRejectedException e) { + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } catch (IOException e) { + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } + SyncResult syncResult = syncService.push(value.toArray(new String[0]), + device.getFileEntry(pathOnDevice.toString()));// Fixxed + if (!syncResult.isOk()) { + return new CommandStatus(IStatus.ERROR, "", syncResult.getMessage(), null); + } + return new CommandStatus(IStatus.OK, targetPaths, null); + } + + private ICommandStatus downloadRemoteFilesWithSCP(String[] fileList) { List value = new ArrayList(); String files = ""; StringBuffer list = new StringBuffer(); @@ -128,6 +209,21 @@ public class RpmCommanderDevice extends RpmCommanderCommon { if (fileList.length == 1) { files = fileList[0]; String filename = FilenameUtil.getFilename(files); + String tmpdir = PlatformFileUtil.getTmpDir(); + String downloadPath = new Path(tmpdir).append(filename).toOSString(); + IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool(); + try { + copytool.downloadFileToFile(files, downloadPath); + } catch (RemoteConnectionException e) { + e.printStackTrace(); + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } catch (RemoteOperationException e) { + e.printStackTrace(); + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } catch (CancelException e) { + e.printStackTrace(); + return new CommandStatus(IStatus.ERROR, "", e.getMessage(), e); + } String pathOnDevice = new Path(TMP_DIR).append(filename).toString(); value.add(pathOnDevice); } else { @@ -156,6 +252,18 @@ public class RpmCommanderDevice extends RpmCommanderCommon { return status; } + public ICommandStatus downloadRemoteFiles(String[] fileList, boolean useSdb) { + if (useSdb) { + return downloadRemoteFilesWithSDB(fileList); + } else { + return downloadRemoteFilesWithSCP(fileList); + } + } + + public ICommandStatus downloadRemoteFiles(String[] fileList) { + return downloadRemoteFilesWithSDB(fileList); + } + public ICommandStatus copyFilesToTmpDir(String[] fileList) { List value = new ArrayList(); for (String filePath : fileList) { @@ -210,7 +318,8 @@ public class RpmCommanderDevice extends RpmCommanderCommon { UserLogger.start(PlatformUserInteraction.COPY_PKG); ICommandStatus status = null; if (OSChecker.isWindows()) { - status = downloadFilesFromRemote(files); + boolean useSDB = DevicePreferencesManager.isTransferToolSDB(); + status = downloadRemoteFiles(files, useSDB); } else { status = copyFilesToTmpDir(files); } @@ -624,4 +733,4 @@ public class RpmCommanderDevice extends RpmCommanderCommon { public CmdTargetTypes getCommandType() { return CMD_TYPE; } -} +} \ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/DevicePreferencesManager.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/DevicePreferencesManager.java index 078d6f7..3260c15 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/DevicePreferencesManager.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/DevicePreferencesManager.java @@ -1,7 +1,9 @@ package org.tizen.nativeplatform.preferences; public class DevicePreferencesManager extends PreferencesManager { - + public static final String TRANSFER_TOOL_SDB = "sdb"; + public static final String TRANSFER_TOOL_SCP = "scp"; + public static final String DEVICE_PKG_TRANSFER = "device.pkg.transfer"; public static final String DEVICE_LOCAL_PKG_INSTALL_TOOL = "device.local.pkg.install.tool"; public static final String DEVICE_LOCAL_PKG_INSTALL_OP = "device.local.pkg.install.op"; @@ -9,46 +11,75 @@ public class DevicePreferencesManager extends PreferencesManager { public static final String DEVICE_REMOTE_PKG_INSTALL_OP = "device.remote.pkg.install.op"; public static final String DEVICE_EFL_INSTALL_TOOL = "device.efl.install.tool"; public static final String DEVICE_EFL_INSTALL_OP = "devie.efl.install.op"; - + public static void setDevicePkgTransferDefault(String value) { prefStore.setDefault(DEVICE_PKG_TRANSFER, value); } + public static void setDeviceLocalPkgInstallToolDefault(String value) { prefStore.setDefault(DEVICE_LOCAL_PKG_INSTALL_TOOL, value); } + public static void setDeviceLocalPkgInstallOpDefault(String value) { prefStore.setDefault(DEVICE_LOCAL_PKG_INSTALL_OP, value); } + public static void setDeviceRemotePkgInstallToolDefault(String value) { prefStore.setDefault(DEVICE_REMOTE_PKG_INSTALL_TOOL, value); } + public static void setDeviceRemotePkgInstallOpDefault(String value) { prefStore.setDefault(DEVICE_REMOTE_PKG_INSTALL_OP, value); } + public static void setDeviceEflInstallToolDefault(String value) { prefStore.setDefault(DEVICE_EFL_INSTALL_TOOL, value); } + public static void setDeviceEflInstallOpDefault(String value) { prefStore.setDefault(DEVICE_EFL_INSTALL_OP, value); } + public static String getDevicePkgTransfer() { return prefStore.getString(DEVICE_PKG_TRANSFER); } + + public static boolean isTransferToolSCP() { + if (getDevicePkgTransfer().equals(TRANSFER_TOOL_SCP)) { + return true; + } else { + return false; + } + } + + public static boolean isTransferToolSDB() { + if (getDevicePkgTransfer().equals(TRANSFER_TOOL_SDB)) { + return true; + } else { + return false; + } + } + public static String getDeviceLocalPkgInstallTool() { return prefStore.getString(DEVICE_LOCAL_PKG_INSTALL_TOOL); } + public static String getDeviceLocalPkgInstallOp() { return prefStore.getString(DEVICE_LOCAL_PKG_INSTALL_OP); } + public static String getDeviceRemotePkgInstallTool() { return prefStore.getString(DEVICE_REMOTE_PKG_INSTALL_TOOL); } + public static String getDeviceRemotePkgInstallOp() { return prefStore.getString(DEVICE_REMOTE_PKG_INSTALL_OP); } + public static String getDeviceEflInstallTool() { return prefStore.getString(DEVICE_EFL_INSTALL_TOOL); } + public static String getDeviceEflInstallOp() { return prefStore.getString(DEVICE_EFL_INSTALL_OP); } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/PreferenceInitializer.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/PreferenceInitializer.java index 43d450e..9fe7f7f 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/PreferenceInitializer.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/PreferenceInitializer.java @@ -9,17 +9,22 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { @Override public void initializeDefaultPreferences() { - //DevicePreferencesManager.setDevicePkgTransferDefault("ssh"); + DevicePreferencesManager + .setDevicePkgTransferDefault(DevicePreferencesManager.TRANSFER_TOOL_SCP); DevicePreferencesManager.setDeviceEflInstallToolDefault(PkgcmdTool.NAME); DevicePreferencesManager.setDeviceEflInstallOpDefault(PkgcmdTool.getInstallCommandFormat()); DevicePreferencesManager.setDeviceLocalPkgInstallToolDefault(RpmTool.NAME); - DevicePreferencesManager.setDeviceLocalPkgInstallOpDefault(RpmTool.getInstallCommandFormat()); + DevicePreferencesManager.setDeviceLocalPkgInstallOpDefault(RpmTool + .getInstallCommandFormat()); DevicePreferencesManager.setDeviceRemotePkgInstallToolDefault(ZypperTool.NAME); - DevicePreferencesManager.setDeviceRemotePkgInstallOpDefault(ZypperTool.getRemoteInstallCommandFormat()); + DevicePreferencesManager.setDeviceRemotePkgInstallOpDefault(ZypperTool + .getRemoteInstallCommandFormat()); RootstrapPreferencesManager.setRootstrapLocalPkgInstallToolDefault(RpmTool.NAME); - RootstrapPreferencesManager.setRootstrapLocalPkgInstallOpDefault(RpmTool.getInstallCommandFormat()); + RootstrapPreferencesManager.setRootstrapLocalPkgInstallOpDefault(RpmTool + .getInstallCommandFormat()); RootstrapPreferencesManager.setRootstrapRemotePkgInstallToolDefault(ZypperTool.NAME); - RootstrapPreferencesManager.setRootstrapRemotePkgInstallOpDefault(ZypperTool.getRemoteInstallCommandFormat()); + RootstrapPreferencesManager.setRootstrapRemotePkgInstallOpDefault(ZypperTool + .getRemoteInstallCommandFormat()); } -} +} \ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/ui/DevicePreferencePage.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/ui/DevicePreferencePage.java index 7cb9e11..24e3e91 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/ui/DevicePreferencePage.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/ui/DevicePreferencePage.java @@ -11,6 +11,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import org.tizen.common.util.OSChecker; import org.tizen.common.util.SWTUtil; import org.tizen.nativeplatform.pkg.tools.PkgcmdTool; import org.tizen.nativeplatform.pkg.tools.RpmTool; @@ -18,12 +19,13 @@ import org.tizen.nativeplatform.pkg.tools.ZypperTool; import org.tizen.nativeplatform.preferences.PreferencesManager; import org.tizen.nativeplatform.preferences.DevicePreferencesManager; -public class DevicePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { +public class DevicePreferencePage extends FieldEditorPreferencePage implements + IWorkbenchPreferencePage { private StringFieldEditor eflInstallOpField; private StringFieldEditor localPkgInstallOpField; private StringFieldEditor remotePkgInstallOpField; - + @Override public void init(IWorkbench workbench) { IPreferenceStore store = PreferencesManager.getPreferenceStore(); @@ -44,68 +46,71 @@ public class DevicePreferencePage extends FieldEditorPreferencePage implements I data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; composite.setLayoutData(data); - //SWTUtil.createSpacer(composite, 1); - //createTransferMethodComposite(composite); + SWTUtil.createSpacer(composite, 1); createEFLPackageToolComposite(composite); SWTUtil.createSpacer(composite, 1); createLocalPackageToolComposite(composite); SWTUtil.createSpacer(composite, 1); createRemotePackageToolComposite(composite); + if (OSChecker.isWindows()) { + SWTUtil.createSpacer(composite, 1); + createTransferMethodComposite(composite); + } } - + private void createTransferMethodComposite(Composite parent) { Composite comp = SWTUtil.createGroup(parent, "Package Transfer Method", 1); - Composite formatComposite = SWTUtil.createCompositeEx(comp, 2, GridData.FILL_HORIZONTAL); - RadioGroupFieldEditor transferField = new RadioGroupFieldEditor(DevicePreferencesManager.DEVICE_PKG_TRANSFER, - "Choose package transfer method:", 2, - new String[][] { { "SDB", "sdb" }, - { "SSH", "ssh" } }, formatComposite); + Composite formatComposite = SWTUtil.createCompositeEx(comp, 1, GridData.FILL_HORIZONTAL); + RadioGroupFieldEditor transferField = new RadioGroupFieldEditor( + DevicePreferencesManager.DEVICE_PKG_TRANSFER, "", 2, new String[][] { + { "SDB", DevicePreferencesManager.TRANSFER_TOOL_SDB }, + { "SCP", DevicePreferencesManager.TRANSFER_TOOL_SCP } }, formatComposite); addField(transferField); } - + private void createEFLPackageToolComposite(Composite parent) { Composite comp = SWTUtil.createGroup(parent, "EFL Package Install Command", 1); Composite formatComposite = SWTUtil.createCompositeEx(comp, 1, GridData.FILL_HORIZONTAL); - RadioGroupFieldEditor pkgToolField = new RadioGroupFieldEditor(DevicePreferencesManager.DEVICE_EFL_INSTALL_TOOL, - "Tool:", 2, - new String[][] { { "PKGCMD", PkgcmdTool.NAME }, - { "RPM", RpmTool.NAME } }, formatComposite); + RadioGroupFieldEditor pkgToolField = new RadioGroupFieldEditor( + DevicePreferencesManager.DEVICE_EFL_INSTALL_TOOL, "Tool:", 2, new String[][] { + { "PKGCMD", PkgcmdTool.NAME }, { "RPM", RpmTool.NAME } }, formatComposite); addField(pkgToolField); - eflInstallOpField = new StringFieldEditor(DevicePreferencesManager.DEVICE_EFL_INSTALL_OP, + eflInstallOpField = new StringFieldEditor(DevicePreferencesManager.DEVICE_EFL_INSTALL_OP, "Install option:", formatComposite); addField(eflInstallOpField); } - + private void createLocalPackageToolComposite(Composite parent) { Composite comp = SWTUtil.createGroup(parent, "Local Package Install Command", 1); Composite formatComposite = SWTUtil.createCompositeEx(comp, 1, GridData.FILL_HORIZONTAL); - RadioGroupFieldEditor pkgToolField = new RadioGroupFieldEditor(DevicePreferencesManager.DEVICE_LOCAL_PKG_INSTALL_TOOL, - "Tool:", 2, - new String[][] { { "ZYPPER", ZypperTool.NAME }, - { "RPM", RpmTool.NAME } }, formatComposite); + RadioGroupFieldEditor pkgToolField = new RadioGroupFieldEditor( + DevicePreferencesManager.DEVICE_LOCAL_PKG_INSTALL_TOOL, "Tool:", 2, new String[][] { + { "ZYPPER", ZypperTool.NAME }, { "RPM", RpmTool.NAME } }, formatComposite); addField(pkgToolField); - localPkgInstallOpField = new StringFieldEditor(DevicePreferencesManager.DEVICE_LOCAL_PKG_INSTALL_OP, - "Install option:", formatComposite); + localPkgInstallOpField = new StringFieldEditor( + DevicePreferencesManager.DEVICE_LOCAL_PKG_INSTALL_OP, "Install option:", + formatComposite); addField(localPkgInstallOpField); } - + private void createRemotePackageToolComposite(Composite parent) { Composite comp = SWTUtil.createGroup(parent, "Remote Package Install Command", 1); Composite formatComposite = SWTUtil.createCompositeEx(comp, 1, GridData.FILL_HORIZONTAL); - RadioGroupFieldEditor pkgToolField = new RadioGroupFieldEditor(DevicePreferencesManager.DEVICE_REMOTE_PKG_INSTALL_TOOL, - "Tool:", 2, + RadioGroupFieldEditor pkgToolField = new RadioGroupFieldEditor( + DevicePreferencesManager.DEVICE_REMOTE_PKG_INSTALL_TOOL, "Tool:", 2, new String[][] { { "ZYPPER", ZypperTool.NAME } }, formatComposite); addField(pkgToolField); - remotePkgInstallOpField = new StringFieldEditor(DevicePreferencesManager.DEVICE_REMOTE_PKG_INSTALL_OP, - "Install option:", formatComposite); + remotePkgInstallOpField = new StringFieldEditor( + DevicePreferencesManager.DEVICE_REMOTE_PKG_INSTALL_OP, "Install option:", + formatComposite); addField(remotePkgInstallOpField); } @Override public void propertyChange(PropertyChangeEvent event) { if (event.getSource() instanceof FieldEditor) { - FieldEditor editor = (FieldEditor)event.getSource(); + FieldEditor editor = (FieldEditor) event.getSource(); String prefName = editor.getPreferenceName(); if (prefName.equals(DevicePreferencesManager.DEVICE_EFL_INSTALL_TOOL)) { if (event.getNewValue().equals(RpmTool.NAME)) { @@ -117,10 +122,11 @@ public class DevicePreferencePage extends FieldEditorPreferencePage implements I if (event.getNewValue().equals(RpmTool.NAME)) { localPkgInstallOpField.setStringValue(RpmTool.getInstallCommandFormat()); } else if (event.getNewValue().equals(ZypperTool.NAME)) { - localPkgInstallOpField.setStringValue(ZypperTool.getLocalInstallCommandFormat()); + localPkgInstallOpField + .setStringValue(ZypperTool.getLocalInstallCommandFormat()); } - } + } } super.propertyChange(event); } -} +} \ No newline at end of file diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rds/RemoteRpmRapidDeployer.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rds/RemoteRpmRapidDeployer.java index f1481bf..096f854 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rds/RemoteRpmRapidDeployer.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rds/RemoteRpmRapidDeployer.java @@ -9,11 +9,9 @@ import java.util.Map.Entry; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import org.eclipse.ptp.remotetools.core.IRemoteCopyTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.tizen.common.util.FileUtil; -import org.tizen.common.util.FilenameUtil; import org.tizen.nativeplatform.command.launcher.CommandUtil; import org.tizen.nativeplatform.command.launcher.LocalCommandUtil; import org.tizen.nativeplatform.command.launcher.RemoteCommandUtil; @@ -21,7 +19,7 @@ import org.tizen.nativeplatform.launch.PlatformLaunchMessages; import org.tizen.nativeplatform.pkg.commander.ICommandStatus; import org.tizen.nativeplatform.pkg.commander.IPkgCommander; import org.tizen.nativeplatform.pkg.model.IPackage; -import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager; +import org.tizen.nativeplatform.preferences.DevicePreferencesManager; import org.tizen.nativeplatform.types.CmdTargetTypes; import org.tizen.nativeplatform.util.PlatformLaunchUtil; import org.tizen.nativeplatform.util.RootstrapUtil; @@ -37,15 +35,16 @@ public class RemoteRpmRapidDeployer { this.project = project; this.commander = commander; for (IPackage pkg : pkgs) { - String path = pkg.getPath(); - String[] segments = new Path(path).segments(); - String configNamae = segments[segments.length - 2]; - String fileNamae = segments[segments.length - 1]; - String remoteWorkspacePath = RootstrapUtil.getUserSyncWorkspacePath(project.getName()); - String remotePkgPath = new Path(remoteWorkspacePath).append(configNamae).append(fileNamae).toString(); - IPackage newPkg = pkg.clonePkg(); - newPkg.setPath(remotePkgPath); - packages.add(newPkg); + String path = pkg.getPath(); + String[] segments = new Path(path).segments(); + String configNamae = segments[segments.length - 2]; + String fileNamae = segments[segments.length - 1]; + String remoteWorkspacePath = RootstrapUtil.getUserSyncWorkspacePath(project.getName()); + String remotePkgPath = new Path(remoteWorkspacePath).append(configNamae) + .append(fileNamae).toString(); + IPackage newPkg = pkg.clonePkg(); + newPkg.setPath(remotePkgPath); + packages.add(newPkg); } this.cmdType = commander.getCommandType(); } @@ -92,7 +91,8 @@ public class RemoteRpmRapidDeployer { if (!addList.isEmpty()) { return false; } - // If copied files are more than 20, install packages normally. It might be better. + // If copied files are more than 20, install packages normally. It + // might be better. if (copyList.size() > 20) { return false; } @@ -104,9 +104,9 @@ public class RemoteRpmRapidDeployer { return false; } } - LocalCommandUtil.clearCachingDir(); - String cachingDir = LocalCommandUtil.getCachingDir(project); - FileUtil.createDirectory(cachingDir); + LocalCommandUtil.clearCachingDir(); + String cachingDir = LocalCommandUtil.getCachingDir(project); + FileUtil.createDirectory(cachingDir); if (!processCopiedFiles(copyList)) { return false; @@ -133,9 +133,11 @@ public class RemoteRpmRapidDeployer { logger.error(String.format("Failed to get cashing directory")); return false; } - String remoteFilepath = new Path(cachingDir).append(file).toString(); - String targetFilePath = new Path(file).removeFirstSegments(1).toString(); - ICommandStatus status = commander.downlaodFileFromRemote(remoteFilepath, targetFilePath); + String remoteFilepath = new Path(cachingDir).append(file).toString(); + String targetFilePath = new Path(file).removeFirstSegments(1).toString(); + boolean useSDB = DevicePreferencesManager.isTransferToolSDB(); + ICommandStatus status = commander.downloadRemoteFile(remoteFilepath, + targetFilePath, useSDB); if (status == null || !status.isOk()) { logger.error(String.format("Failed to copy files [%s]", remoteFilepath)); return false; @@ -143,8 +145,9 @@ public class RemoteRpmRapidDeployer { } } else if (isRootstrapCommander()) { for (final String file : fileList) { - String remoteFilePath = new Path(RemoteCommandUtil.getCachingDir(project)).append(file).toString(); - String filePath = new Path(file).removeFirstSegments(1).toString(); + String remoteFilePath = new Path(RemoteCommandUtil.getCachingDir(project)).append( + file).toString(); + String filePath = new Path(file).removeFirstSegments(1).toString(); commander.copyFile(remoteFilePath, filePath); } } @@ -153,13 +156,15 @@ public class RemoteRpmRapidDeployer { private boolean processAddedFiles(List fileList, Map smackInfo) { if (isDeviceCommander()) { - // RDS can not add files to device because of setting smack information. - // How set smack information for a new file ? + // RDS can not add files to device because of setting smack + // information. + // How set smack information for a new file ? } else if (isRootstrapCommander()) { for (String file : fileList) { IPath filePath = new Path(file); String targetFilePath = filePath.removeFirstSegments(1).toString(); - String targetPath = filePath.removeFirstSegments(1).removeLastSegments(1).toString(); + String targetPath = filePath.removeFirstSegments(1).removeLastSegments(1) + .toString(); String cachingDir = CommandUtil.getCachingDir(project); if (cachingDir == null) { logger.error(String.format("Failed to get cashing directory")); @@ -185,21 +190,18 @@ public class RemoteRpmRapidDeployer { // Nothing will be removed because source files should be in target // FIXME: /* - for (String file : fileList) { - ICommandStatus status = commander.removeFile(file); - if (status == null || !status.isOk()) { - logger.error(String.format("Failed to remove files [%s]", file)); - return false; - } - } - */ + * for (String file : fileList) { ICommandStatus status = + * commander.removeFile(file); if (status == null || !status.isOk()) { + * logger.error(String.format("Failed to remove files [%s]", file)); + * return false; } } + */ return true; } private boolean isDeviceCommander() { return (cmdType == CmdTargetTypes.DEVICE); } - + private boolean isRootstrapCommander() { return (cmdType == CmdTargetTypes.ROOTSTRAP); } @@ -228,14 +230,16 @@ public class RemoteRpmRapidDeployer { return true; } - // compare source data and target data. divide all files into four list parts. + // compare source data and target data. divide all files into four list + // parts. private String groupFiles(Map sourceChecksums, Map targetChecksums, List copyList, List addList, List remainList, List removeList) { StringBuffer sbCopyFiles = new StringBuffer(); for (Entry entry : sourceChecksums.entrySet()) { - // key = aul-0.0.280-1.i586.rpm_d986faacda139c2d2d9c19c792ef07bc/etc/init.d/launchpad_run + // key = + // aul-0.0.280-1.i586.rpm_d986faacda139c2d2d9c19c792ef07bc/etc/init.d/launchpad_run String key = entry.getKey(); // s_value = 50155d2eaed43a6cbf2632b38dd37242 String s_value = entry.getValue(); @@ -244,18 +248,21 @@ public class RemoteRpmRapidDeployer { if (targetChecksums.containsKey(target_key)) { // d_value = 50155d2eaed43a6cbf2632b38dd37242 String d_value = targetChecksums.get(target_key); - // As comparing keys, divide files into 2 parts (copy list, remain list) + // As comparing keys, divide files into 2 parts (copy list, + // remain list) if (!s_value.equals(d_value)) { copyList.add(key); sbCopyFiles.append("\"" + target_key + "\" "); } else { remainList.add(key); } - // if targetChecksums contains source key, remove the key from targetChecksums. + // if targetChecksums contains source key, remove the key from + // targetChecksums. // it is for removing unused files on device later. targetChecksums.remove(target_key); } else { - // if targetChecksums does not contains source key, it should be copied. + // if targetChecksums does not contains source key, it should be + // copied. if (!key.equals("-")) { addList.add(key); } @@ -316,5 +323,5 @@ public class RemoteRpmRapidDeployer { result.put(key, v[0]); } return result; - } + } }