[Esbox-commits] r2033 - in branches/work_Raul: org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware

raul at garage.maemo.org raul at garage.maemo.org
Thu Aug 27 22:32:52 EEST 2009


Author: raul
Date: 2009-08-27 22:32:52 +0300 (Thu, 27 Aug 2009)
New Revision: 2033

Modified:
   branches/work_Raul/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/AfSbInitMaemoLauncherAdapter.java
   branches/work_Raul/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java
   branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java
Log:
Merged revs 2022:2032 from trunk

Modified: branches/work_Raul/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/AfSbInitMaemoLauncherAdapter.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/AfSbInitMaemoLauncherAdapter.java	2009-08-27 19:23:54 UTC (rev 2032)
+++ branches/work_Raul/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/AfSbInitMaemoLauncherAdapter.java	2009-08-27 19:32:52 UTC (rev 2033)
@@ -25,13 +25,17 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.console.MessageConsole;
 import org.maemo.esbox.internal.maemosdk.core.Activator;
 import org.maemo.esbox.maemosdk.core.MaemoEnvironmentUtils;
 import org.maemo.esbox.maemosdk.core.MaemoPreferenceConstants;
+import org.maemo.mica.common.core.HostUtils;
 import org.maemo.mica.common.core.MicaException;
 import org.maemo.mica.common.core.console.ConsoleStreamMonitor;
 import org.maemo.mica.common.core.console.CoreConsoleManager;
@@ -39,6 +43,8 @@
 import org.maemo.mica.common.core.machine.IMachine;
 import org.maemo.mica.common.core.machine.IProcess;
 import org.maemo.mica.common.core.machine.ProcessFilterCmdLineRegexp;
+import org.maemo.mica.common.core.preferences.CorePreferenceConstants;
+import org.maemo.mica.common.core.preferences.CorePreferenceManager;
 import org.maemo.mica.common.core.process.CommandLineArguments;
 import org.maemo.mica.common.core.process.IProcessLauncher;
 import org.maemo.mica.common.core.process.IProcessLauncherFactory;
@@ -47,29 +53,35 @@
 import org.maemo.mica.common.core.process.ProcessLauncherUtils;
 import org.maemo.mica.common.core.process.StreamLineMonitorAdapter;
 import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.maemosdk.core.IMaemoSDKPlatform;
 import org.maemo.mica.maemosdk.core.IMaemoSDKTarget;
 
 import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
 
 /**
  * Launch the Maemo AF using the "af-sb-init.sh" script.
+ * 
  * @author baranov
- *
+ * 
  */
-public class AfSbInitMaemoLauncherAdapter implements IMaemoLauncherAdapter{
+public class AfSbInitMaemoLauncherAdapter implements IMaemoLauncherAdapter {
+	private static final String ADD_EXTENSION_MIT_SHM = " -extension MIT-SHM";
+	private static final String ADD_LESSPOINTER_OPTION = "-lesspointer";
+	private static final String ADD_SWCURSOR_OPTION = "-swcursor";
+
 	private static final QualifiedName WARN_ARMEL_TARGET_EXECUTION = new QualifiedName(
 			Activator.PLUGIN_ID, "WARN_ARMEL_TARGET_EXECUTION");
 
 	private static final String MAEMO_LAUNCHER_APP = "maemo-launcher";
 	private static final String HILDON_DESKTOP_APP = "hildon-desktop";
-	
+	private static final int DEFAULT_COLOR_DEPTH = 16;
 	private final ISDKTarget target;
 	private final MaemoCommand command;
-	
+
 	/**
 	 * @param target
 	 */
-	public AfSbInitMaemoLauncherAdapter(ISDKTarget target){
+	public AfSbInitMaemoLauncherAdapter(ISDKTarget target) {
 		this.target = target;
 		this.command = new MaemoCommand(target);
 	}
@@ -81,8 +93,7 @@
 				+ "which may trigger unexpected bugs in otherwise correct programs.\n\n"
 				+ "We recommend using an X86 target for normal development activities.";
 
-		if (target.getArchitecture().equals(
-				IMaemoSDKTarget.ARCHITECTURE_ARMEL)) {
+		if (target.getArchitecture().equals(IMaemoSDKTarget.ARCHITECTURE_ARMEL)) {
 
 			Boolean oneTimeWarn = null;
 			IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
@@ -92,8 +103,8 @@
 			} catch (CoreException e1) {
 				Activator.getErrorLogger().logError(null, e1);
 			}
-			
-			if(oneTimeWarn != null && !oneTimeWarn.booleanValue())
+
+			if (oneTimeWarn != null && !oneTimeWarn.booleanValue())
 				return;
 
 			try {
@@ -101,7 +112,7 @@
 			} catch (CoreException e1) {
 				Activator.getErrorLogger().logError(null, e1);
 			}
-			
+
 			Display.getDefault().asyncExec(new Runnable() {
 				public void run() {
 					MessageDialog.openWarning(shell, "Warning", msg);
@@ -140,7 +151,7 @@
 		} catch (IOException e) {
 			throw new MicaException("Could not kill " + MAEMO_LAUNCHER_APP, e);
 		}
-		
+
 	}
 
 	/* (non-Javadoc)
@@ -150,11 +161,11 @@
 		if (monitor == null)
 			monitor = new NullProgressMonitor();
 		monitor.beginTask("", 10);
-		
+
 		ensureCorrectXRunning(new SubProgressMonitor(monitor, 1));
 		if (monitor.isCanceled())
 			return;
-		command.performCommand(MaemoPreferenceConstants.MAEMO_RESTART_ACTION, 
+		command.performCommand(MaemoPreferenceConstants.MAEMO_RESTART_ACTION,
 				new SubProgressMonitor(monitor, 9));
 		monitor.done();
 	}
@@ -166,32 +177,201 @@
 		if (monitor == null)
 			monitor = new NullProgressMonitor();
 		monitor.beginTask("", 10);
-		
+
 		ensureCorrectXRunning(new SubProgressMonitor(monitor, 1));
 		if (monitor.isCanceled())
 			return;
-		
+
 		Shell shell = WorkbenchUtils.getSafeShell();
 		warnIfArmelTarget(shell);
-		
-		command.performCommand(MaemoPreferenceConstants.MAEMO_START_ACTION, 
+
+		command.performCommand(MaemoPreferenceConstants.MAEMO_START_ACTION,
 				new SubProgressMonitor(monitor, 9));
 		monitor.done();
 	}
 
 	/**
-	 * @param subProgressMonitor
-	 * @throws MicaException 
+	 * Ensure that correct X is running and restart if required.
+	 * 
+	 * @param monitor the progress monitor
+	 * @throws MicaException
 	 */
-	private void ensureCorrectXRunning(IProgressMonitor monitor) throws MicaException {
+	private void ensureCorrectXRunning(IProgressMonitor monitor)
+			throws MicaException {
+		final boolean[] restart = { false };
+		
+		if (HostUtils.isOSX()
+				&& target.getPlatform().getVersion().compareTo(
+						IMaemoSDKPlatform.FREMANTLE.getVersion()) >= 0
+				&& !XLauncher.getInstance().hasDisabledExtension(target,
+						"MIT-SHM")) {
+			final String warningKey = CorePreferenceConstants.SUPPRESS_MIT_SHM_WARNING;
+			final IPreferenceStore store = CorePreferenceManager.getInstance()
+					.getPreferenceStore(warningKey);
+
+			String value = store.getString(warningKey);
+
+			if (value == null || value.equals("")
+					|| value.equals(MessageDialogWithToggle.PROMPT)) {
+				Display.getDefault().syncExec(new Runnable() {
+					public void run() {
+                        final String message =
+                            "Due to some design limitations, Fremantle applications will not render " +
+                            "correctly when X is running with the MIT-SHM extension enabled. " +
+                            "Do you want to disable the extension and restart X?";
+						MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(
+										null, "Warning", message,
+										"Do not show this warning in the future",
+										false, store, warningKey);
+						restart[0] = dialog.getReturnCode() == IDialogConstants.YES_ID;
+					}
+				});
+			} else if (value.equals(MessageDialogWithToggle.ALWAYS)) {
+				restart[0] = true;
+			}
+		}
+
+		if (restart[0]) {
+			IPreferenceStore store = CorePreferenceManager.getInstance()
+					.getPreferenceStore(
+							MaemoPreferenceConstants.DISPLAY_X_COMMAND);
+			String command = store
+					.getString(MaemoPreferenceConstants.DISPLAY_X_COMMAND);
+
+			if (!command.contains(ADD_EXTENSION_MIT_SHM)) {
+				store.setValue(MaemoPreferenceConstants.DISPLAY_X_COMMAND,
+						command + ADD_EXTENSION_MIT_SHM);
+			}
+
+			XLauncher x = XLauncher.getInstance();
+
+			if (x.isXServerStarted(target)) {
+				x.stopX(target, monitor);
+			}
+			x.startX(target, monitor);
+		}
+
 		if (!XLauncher.getInstance().isCorrectXServerRunning(target)) {
-			// usability: if X is not running, be sure any Maemo environment in that
+			// usability: if X is not running, be sure any Maemo environment in
+			// that
 			// server is also killed, or else if the user tries to restart
 			// the Maemo AF, it will still appear to be running for a while
 			// until all the processes die from the X server socket timeout.
 			killMaemo();
 			XLauncher.getInstance().startXIfNeeded(target, monitor);
 		}
+
+		if (HostUtils.isWindows()
+				&& target.getPlatform().getVersion().compareTo(
+						IMaemoSDKPlatform.FREMANTLE.getVersion()) >= 0) {
+
+			final int depth = XLauncher.getInstance().getDisplayDepth(target);
+			final boolean[] depthSupported = { true };
+			if (depth != -1 && depth != DEFAULT_COLOR_DEPTH) {
+				depthSupported[0] = false;
+			}
+			final boolean[] optionsSupported = { true };
+
+			if (XLauncher.getInstance().hasOption(target,
+					ADD_LESSPOINTER_OPTION)
+					|| XLauncher.getInstance().hasOption(target,
+							ADD_SWCURSOR_OPTION)) {
+				optionsSupported[0] = false;
+			}
+			if (!depthSupported[0] || !optionsSupported[0]) {
+
+				if (!depthSupported[0] && optionsSupported[0]) {
+					final String warningKey = CorePreferenceConstants.SUPPRESS_COLOR_DEPTH_WARNING;
+					final IPreferenceStore store = CorePreferenceManager
+							.getInstance().getPreferenceStore(warningKey);
+					String value = store.getString(warningKey);
+					if (value == null || value.equals("")
+							|| value.equals(MessageDialogWithToggle.PROMPT)) {
+
+						Display.getDefault().syncExec(new Runnable() {
+							public void run() {
+								String messageDepth;
+								if (depth == 24 || depth == 32) {
+									messageDepth = "32/24";
+								} else {
+									messageDepth = Integer.toString(depth);
+								}
+								final String message = MessageFormat.format(
+										"Your display uses {0} bit color depth.  Fremantle applications will " +
+										"not render correctly unless the display uses {1} bit color depth.",
+												messageDepth,
+												DEFAULT_COLOR_DEPTH);
+
+								MessageDialogWithToggle.openWarning(
+												null, "Warning", message,
+												"Do not show this warning in the future",
+												false, store, warningKey);
+							}
+						});
+					}
+				} else {
+					final String warningKey = CorePreferenceConstants.SUPPRESS_MOUSE_CURSOR_WARNING;
+					final IPreferenceStore store = CorePreferenceManager
+							.getInstance().getPreferenceStore(warningKey);
+
+					String value = store.getString(warningKey);
+
+					if (value == null || value.equals("")
+							|| value.equals(MessageDialogWithToggle.PROMPT)) {
+						Display.getDefault().syncExec(new Runnable() {
+							public void run() {
+								String question = "";
+								if (depthSupported[0]) {
+									question = "Due to some design limitations, Fremantle applications will not " +
+											"show mouse cursor correctly when X is started with the lesspointer " +
+											"or the swcursor options.  Do you want to remove the options and " +
+											"restart X?";
+
+								} else if (!depthSupported[0]) {
+									question = "Due to some design limitations, Fremantle applications will not " +
+											"render correctly when X is running in 24/32 bit mode and the " +
+											"lesspointer or the swcursor options are used. Do you want to " +
+											"remove the options and restart X? Note: The display depth needs to be " +
+											"change manually to 16 bit from the display options.";
+								}
+								MessageDialogWithToggle dialog = MessageDialogWithToggle
+										.openYesNoQuestion(
+												null,
+												"Warning",
+												question,
+												"Do not show this warning in the future",
+												false, store, warningKey);
+								restart[0] = dialog.getReturnCode() == IDialogConstants.YES_ID;
+							}
+						});
+					} else if (value.equals(MessageDialogWithToggle.ALWAYS)) {
+						restart[0] = true;
+					}
+					if (restart[0]) {
+						IPreferenceStore storeXCommand = CorePreferenceManager
+								.getInstance()
+								.getPreferenceStore(
+										MaemoPreferenceConstants.DISPLAY_X_COMMAND);
+						String command = storeXCommand
+								.getString(MaemoPreferenceConstants.DISPLAY_X_COMMAND);
+						command = command.replace(" " + ADD_LESSPOINTER_OPTION,
+								"");
+						command = command
+								.replace(" " + ADD_SWCURSOR_OPTION, "");
+						storeXCommand.setValue(
+								MaemoPreferenceConstants.DISPLAY_X_COMMAND,
+								command.trim());
+
+						XLauncher x = XLauncher.getInstance();
+
+						if (x.isXServerStarted(target)) {
+							x.stopX(target, monitor);
+						}
+						x.startX(target, monitor);
+					}
+				}
+			}
+		}
 	}
 
 	/* (non-Javadoc)
@@ -201,8 +381,8 @@
 		if (monitor == null)
 			monitor = new NullProgressMonitor();
 		monitor.beginTask("", 10);
-		
-		command.performCommand(MaemoPreferenceConstants.MAEMO_STOP_ACTION, 
+
+		command.performCommand(MaemoPreferenceConstants.MAEMO_STOP_ACTION,
 				new SubProgressMonitor(monitor, 9));
 		try {
 			XLauncher.getInstance().stopX(target, new SubProgressMonitor(monitor, 1));
@@ -234,7 +414,7 @@
 								"|" + HILDON_DESKTOP_APP + ")\\b"));
 		return runningProcesses;
 	}
-	
+
 	static public class MaemoCommand {
 
 		private ISDKTarget sdkTarget;
@@ -247,19 +427,19 @@
 			List<String> params = getParamList(command);
 			performCommand(params, monitor);
 		}
-		
+
 		private void performCommand(List<String> params, final IProgressMonitor monitor) throws MicaException {
 			String maemoCommand = sdkTarget.getPreferenceValue(
 					MaemoPreferenceConstants.MAEMO_COMMAND);
-			maemoCommand = this.replaceActions(maemoCommand,params.get(0));
-			
+			maemoCommand = this.replaceActions(maemoCommand, params.get(0));
+
 			IProcessLauncherFactory processLauncherFactory = sdkTarget
 					.getProcessLauncherFactory();
 
 			IEnvironmentModifierBlock envBlock = processLauncherFactory
 					.getDefaultEnvironmentModifierBlock();
 			MaemoEnvironmentUtils.defineEmulatorXDisplayVariable(
-					sdkTarget.getMachine(), envBlock);
+				sdkTarget.getMachine(), envBlock);
 
 			IProcessLauncher processLauncher = processLauncherFactory.createProcessLauncher(
 					ProcessLauncherParameters.create(
@@ -286,7 +466,7 @@
 					});
 				}
 			};
-			
+
 			processLauncher.queueStreamMonitor(consoleMonitor);
 
 			// And watch for errors and termination
@@ -298,9 +478,9 @@
 						throws InterruptedException {
 					// REMOVED: error checking -- there are so many spurious
 					// errors that it's useless to report them
-					
+
 					if (text.contains("Starting") &&
-							(text.contains("Hildon Desktop") || text.contains("hildon-desktop"))) {
+							(text.contains("Hildon Desktop") || text.contains("hildon-desktop"))) {				
 						// we need to stop after this or else the launch
 						// just hangs forever (waiting for input?)... dunno why.
 						// This happened at least as far back as 2.0.0M1 but
@@ -316,7 +496,7 @@
 								procMonitor.terminate();
 								return Status.OK_STATUS;
 							}
-							
+
 						};
 						job.setSystem(true);
 						job.setUser(false);

Modified: branches/work_Raul/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java	2009-08-27 19:23:54 UTC (rev 2032)
+++ branches/work_Raul/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java	2009-08-27 19:32:52 UTC (rev 2033)
@@ -12,20 +12,24 @@
 
 package org.maemo.esbox.internal.api.maemosdk.core.tools;
 
+import java.io.File;
 import java.io.IOException;
 import java.net.Socket;
 import java.text.MessageFormat;
 import java.util.List;
+import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.core.runtime.jobs.Job;
 import org.maemo.esbox.internal.maemosdk.core.Activator;
 import org.maemo.esbox.maemosdk.core.MaemoPreferenceConstants;
+import org.maemo.mica.common.core.HostUtils;
 import org.maemo.mica.common.core.MicaException;
 import org.maemo.mica.common.core.Policy;
 import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
@@ -40,8 +44,10 @@
 import org.maemo.mica.common.core.process.IProcessLauncher;
 import org.maemo.mica.common.core.process.IProcessLauncherFactory;
 import org.maemo.mica.common.core.process.IProcessMonitor;
+import org.maemo.mica.common.core.process.IStreamMonitor;
 import org.maemo.mica.common.core.process.ProcessLauncherParameters;
 import org.maemo.mica.common.core.process.ProcessLauncherUtils;
+import org.maemo.mica.common.core.process.StreamLineMonitorAdapter;
 import org.maemo.mica.common.core.sdk.ISDKTarget;
 import org.maemo.mica.maemosdk.core.IMaemoSDKPlatform;
 
@@ -70,6 +76,9 @@
 	 */
 	private static final String FREMANTLE_X_SERVER_RESOLUTION = "800x480x16";
 	
+	private static final Pattern DEPTHS_PATTERN = Pattern
+			.compile("^\\s*depths\\s+\\(.*\\):\\s*(\\d+),.*$");
+	
 	/**
 	 * @author eswartz
 	 *
@@ -506,7 +515,12 @@
 		if (sdkTarget != null
 				&& sdkTarget.getPlatform().getVersion().compareTo(
 						IMaemoSDKPlatform.FREMANTLE.getVersion()) >= 0) {
-			return FREMANTLE_X_SERVER_PLATFORM_PARAMETERS;
+			 if(HostUtils.isWindows()){
+				 return "";
+			 }else{
+				 return FREMANTLE_X_SERVER_PLATFORM_PARAMETERS;
+			 }
+			
 		}
 		return DEFAULT_X_SERVER_PLATFORM_PARAMETERS;
 	}
@@ -568,4 +582,118 @@
 		return (IProcess[]) processes.toArray(new IProcess[processes.size()]);
 	}
 
+	/**
+	 * Check if given extension is disabled at command line.
+	 * 
+	 * @param prefProvider the preference provider
+	 * @param extension the extension to check
+	 * @return true if extension is disable at command line
+	 */
+	public boolean hasDisabledExtension(IPreferenceProvider prefProvider, String extension) {
+		List<String> commandLine = null;
+		if (previousCommandLine == null) {
+			commandLine = getDisplayXServerCommand(prefProvider);
+		} else {
+			commandLine = previousCommandLine;
+		}
+		
+		int index = commandLine.indexOf(extension);
+		if (index < 1) {
+			return false;
+		} else {
+			return commandLine.get(index - 1).equals("-extension");
+		}
+	}
+	
+	/**
+	 * Check if given option exists at command line.
+	 * 
+	 * @param prefProvider the preference provider
+	 * @param option the option to check
+	 * @return true if option exists at command line
+	 */
+	public boolean hasOption(IPreferenceProvider prefProvider, String option) {
+		List<String> commandLine = null;
+		if (previousCommandLine == null) {
+			commandLine = getDisplayXServerCommand(prefProvider);
+		} else {
+			commandLine = previousCommandLine;
+		}
+		
+		int index = commandLine.indexOf(option);
+		if (index < 1) {
+			return false;
+		} else {
+			return true;
+		}
+	}
+	
+	/**
+	 * Get System color depth
+	 * 
+	 * @param prefProvider
+	 *            instance of the IPreferenceProvider
+	 * @return System color depth if an error occurred <code>-1</code> is
+	 *         returned
+	 */
+	public int getDisplayDepth(IPreferenceProvider prefProvider) {
+		if (prefProvider == null) {
+			return -1;
+		}
+		IMachine machine = MachineRegistry.getInstance().getLocalMachine();
+		List<String> list = CommandLineArguments
+				.createFromCommandLine(prefProvider
+						.getPreferenceValue(MaemoPreferenceConstants.DISPLAY_X_COMMAND));
+		if (list.size() < 0 || list.get(0) == null) {
+			return -1;
+		}
+		String commandBase = new File(list.get(0)).getParent();
+		if (commandBase == null) {
+			commandBase = "";
+		}else{
+			commandBase += File.separator;
+			commandBase = new Path(commandBase).toString();
+		}
+		String commandSkeleton = commandBase + "xdpyinfo -display ${DISPLAY}";
+
+		String display = prefProvider
+				.getPreferenceValue(MaemoPreferenceConstants.X_DISPLAY);
+
+		// add display variable into commandSkeleton and add path for process
+		// launcher
+		IProcessLauncherFactory factory = machine.getProcessLauncherFactory();
+		IEnvironmentModifierBlock envBlock = factory
+				.getDefaultEnvironmentModifierBlock();
+
+		ProcessLauncherParameters params = ProcessLauncherParameters.create(
+				CommandLineArguments.createFromCommandLine(commandSkeleton
+						.replaceAll("\\$\\{DISPLAY\\}", display)), envBlock);
+		String path = prefProvider
+				.getPreferenceValue(MaemoPreferenceConstants.X_PATH);
+		if (path != null && path.length() > 0) {
+			MachineUtils.adjustLaunchParametersForPath(machine, factory,
+					params, path);
+		}
+
+		final int[] depth = new int[1];
+		depth[0] = -1;
+		try {
+			ProcessLauncherUtils.launchAndMonitorStandardStreams(machine
+					.getProcessLauncherFactory().createProcessLauncher(params),
+					new IStreamMonitor[] { new StreamLineMonitorAdapter() {
+						public void handleLine(String line, boolean errorStream)
+								throws InterruptedException {
+							Matcher matcher = DEPTHS_PATTERN.matcher(line);
+							if (matcher.matches()) {
+								depth[0] = Integer.parseInt(matcher.group(1));
+							}
+						}
+					} }, null);
+		} catch (MicaException e) {
+			Activator.getErrorLogger().logError(e.getMessage(), e);
+			return -1;
+		}
+		return depth[0];
+	}
+	
 }
\ No newline at end of file

Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java	2009-08-27 19:23:54 UTC (rev 2032)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java	2009-08-27 19:32:52 UTC (rev 2033)
@@ -80,10 +80,14 @@
 			fileSize = getSizeFor(downloadPage, downloadFile.getDescriptor().getName());
 			remoteURL = getLinkFor(downloadPage, downloadFile.getDescriptor().getName());
 		} catch (MalformedURLException e) {
-			Activator.getErrorLogger().logAndShowError("Invalid file URL", e);
-			return null;
+			throw new MicaException("Invalid file URL on " + MaemoSDKVMInfo.DOWNLOAD_PAGE, e);
 		}
 				
+		if (remoteURL == null) {
+			throw new MicaException("Cannot locate ''" + downloadFile.getDescriptor().getName() 
+					+ "'' on " + MaemoSDKVMInfo.DOWNLOAD_PAGE);
+		}
+		
 		return new Tuple(remoteURL, fileSize);
 	}
 	
@@ -336,8 +340,9 @@
 				downloadFile.setSize(contentLength);
 			}
 			
-			CopyProgressMonitor progressMonitor = new CopyProgressMonitor("Downloading Maemo SDK virtual image",remoteFileSize, monitor);
-			progressMonitor.addProgress(downloadFile.getDownloadedSize());
+			CopyProgressMonitor progressMonitor = new CopyProgressMonitor(
+					"Downloading Maemo SDK virtual image", remoteFileSize, monitor);
+			progressMonitor.setExistingSize(downloadFile.getDownloadedSize());
 			progressMonitor.start();
 	
 			out = new RandomFileOutputStream(fileName,true);
@@ -348,7 +353,8 @@
 			monitor.beginTask(remoteURL.getFile(), remoteFileSize != 0 ? remoteFileSize : IProgressMonitor.UNKNOWN);
 			monitor.worked((int)downloadFile.getDownloadedSize());
 			
-			DownloadingThread thread = new DownloadingThread(in, out,Activator.BUFFER_SIZE, progressMonitor, monitor);
+			int bufferSize = 64*1024;//64KB
+			DownloadingThread thread = new DownloadingThread(in, out,bufferSize , progressMonitor, monitor);
 			thread.start();
 
 			while (!thread.isInterrupted() && thread.isAlive() ) {



More information about the Esbox-commits mailing list