[Esbox-commits] r2232 - in branches/work_Ed: org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware

eswartz at garage.maemo.org eswartz at garage.maemo.org
Fri Sep 25 18:53:15 EEST 2009


Author: eswartz
Date: 2009-09-25 18:53:14 +0300 (Fri, 25 Sep 2009)
New Revision: 2232

Modified:
   branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java
   branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java
   branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachine.java
   branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineConfiguration.java
   branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java
Log:
-- Don't show "Launch machine" option for Manual Virtual machine
-- Compare machine configurations better, accounting for leftover and unused keys
-- Faster check for alive machines (because it's very slow in VMware/Windows)
-- Fix bug not detecting VMware running on Windows

Modified: branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java	2009-09-25 14:35:44 UTC (rev 2231)
+++ branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java	2009-09-25 15:53:14 UTC (rev 2232)
@@ -978,6 +978,7 @@
 	public void forceShutdown(IProgressMonitor monitor) throws MicaException {
 		monitor.beginTask("", 2);
 		
+		monitor.subTask("Killing Scratchbox sessions...");
 		try {
 			killSessions();
 		} catch (MicaException e) {

Modified: branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachine.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachine.java	2009-09-25 14:35:44 UTC (rev 2231)
+++ branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachine.java	2009-09-25 15:53:14 UTC (rev 2232)
@@ -36,11 +36,14 @@
 	 */
 	@Override
 	public boolean isAlive() {
+		if (!super.isAlive())
+			return false;
+		
 		if (getMachineController() instanceof BaseLaunchableVirtualMachineController) {
 			boolean isVMRunning = ((BaseLaunchableVirtualMachineController) getMachineController()).isMachineRunning();
 			if (!isVMRunning)
 				return false;
 		}
-		return super.isAlive();
+		return true;
 	}
 }

Modified: branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineConfiguration.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineConfiguration.java	2009-09-25 14:35:44 UTC (rev 2231)
+++ branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineConfiguration.java	2009-09-25 15:53:14 UTC (rev 2232)
@@ -14,9 +14,15 @@
 import java.io.IOException;
 import java.io.StringWriter;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Comparator;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.eclipse.jface.dialogs.IDialogSettings;
 import org.maemo.esbox.internal.api.vm.core.URIQueryParser.IURIQueryDecoder;
@@ -71,9 +77,19 @@
 			// ignore the section name, since it's not predictable
 			fullString = fullString.replaceAll("name=\"[^\"]+\"", "name=\"temp\"");
 			
-			// the lines are not necessarily sorted...
-			String[] lines1 = fullString.split("\n");
-			Arrays.sort(lines1,
+			// the lines are not necessarily sorted and may include obsolete prefs...
+			List<String> lines = new ArrayList<String>(Arrays.asList(fullString.split("\n")));
+			Pattern itemPattern = Pattern.compile("key=\"([^\"]*)\"");
+			Set<String> registeredKeys = CorePreferenceManager.getInstance().getRegisteredKeys();
+			for (Iterator<String> iterator = lines.iterator(); iterator.hasNext();) {
+				String string = iterator.next();
+				Matcher matcher = itemPattern.matcher(string);
+				if (matcher.find()) {
+					if (!registeredKeys.contains(matcher.group(1)))
+						iterator.remove();
+				}
+			}
+			Collections.sort(lines,
 					new Comparator<String>() {
 
 						public int compare(String o1, String o2) {
@@ -84,7 +100,7 @@
 						}
 				
 			});
-			return TextUtils.catenateStrings(lines1, "\n");
+			return TextUtils.catenateStrings(lines.toArray(), "\n");
 		}
 		return "";
 	}

Modified: branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java	2009-09-25 14:35:44 UTC (rev 2231)
+++ branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java	2009-09-25 15:53:14 UTC (rev 2232)
@@ -220,6 +220,26 @@
 			final boolean launchRet[] = { false, false };
 			Display.getDefault().syncExec(new Runnable() {
 				public void run() {
+					String[] choices;
+					int launchIndex;
+					int retryIndex;
+					if (BaseVirtualMachineController.this instanceof BaseLaunchableVirtualMachineController) {
+						choices = new String[] { 
+							"Launch now",
+							"I launched it",
+							IDialogConstants.CANCEL_LABEL
+							};
+						launchIndex = 0;
+						retryIndex = 1;
+					} else {
+						choices = new String[] { 
+							"I launched it",
+							IDialogConstants.CANCEL_LABEL
+						};
+						launchIndex = -1;
+						retryIndex = 0;
+					}
+					
 					LaunchVirtualMachineDialog dialog = new LaunchVirtualMachineDialog(
 							null, "Virtual Machine Needed", null,
 							message,
@@ -230,20 +250,17 @@
 								getLookAtNetworkPrefs(),
 								getLookAtMaemoVMWare()
 							},
-							new String[] { 
-									"Launch now",
-									"I launched it",
-									IDialogConstants.CANCEL_LABEL
-									},
-						    0
+							choices,
+						    launchIndex >= 0 ? launchIndex : retryIndex
 					);
 					
 					if (likelyNetworkIssue) {
 						dialog.setHelpExpanded(true);
 					}
 					int ret = dialog.open();
-					launchRet[0] = ret == 0;		
-					launchRet[1] = ret == 1;		
+					launchRet[0] = ret == launchIndex;		
+					launchRet[1] = ret == retryIndex;
+					// else, cancel
 				}
 			});
 			doLaunch = launchRet[0];

Modified: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java	2009-09-25 14:35:44 UTC (rev 2231)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java	2009-09-25 15:53:14 UTC (rev 2232)
@@ -105,7 +105,7 @@
 
 		IVMwareConfiguration config = (IVMwareConfiguration) machineConfiguration;
 		File vmx = new File(config.getVmxPath());
-		File exe = new File(config.getInstallPath());
+		File exe = getExecutablePath(config).toFile();
 		
 		if (HostUtils.isWindows()) {
 			IProcess[] runningVMwares = getRunningVMwareVMXInstances(exe, vmx);
@@ -122,10 +122,12 @@
 				}
 			}
 		}
-		
-		if (HostUtils.isWindows()) {
-			// we tested above that it's running; assume it is
-			return true;
+		else {
+			if (HostUtils.isWindows()) {
+				// we can't really tell by the command line, but tested above that the 
+				// process was running; assume it is
+				return true;
+			}
 		}
 		return false;
 	}
@@ -266,7 +268,6 @@
 	@Override
 	protected IStatus doStopVirtualMachine(IProgressMonitor monitor) {
 		
-		// don't waste time if not running
 		try {
 			doHaltMachine(monitor);
 		} catch (MachineException e) {



More information about the Esbox-commits mailing list