[Esbox-commits] r2267 - in trunk: org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware

eswartz at garage.maemo.org eswartz at garage.maemo.org
Tue Oct 6 06:16:46 EEST 2009


Author: eswartz
Date: 2009-10-06 06:16:45 +0300 (Tue, 06 Oct 2009)
New Revision: 2267

Added:
   trunk/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/ILaunchableMachineController.java
   trunk/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/LaunchedMachineInfo.java
Removed:
   trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/LaunchedMachineInfo.java
Modified:
   trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BaseMachinePreferencePage.java
   trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BuildMachinePreferencePage.java
   trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/SharedFolderTreeViewer.java
   trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/SharedFoldersPreferencePage.java
   trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachineController.java
   trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuPreferencePage.java
   trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachineController.java
   trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxPreferencePage.java
   trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java
   trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java
   trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java
   trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseLaunchableVirtualMachineController.java
   trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java
   trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/AddressFieldEditor.java
   trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java
   trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachinePreferencePage.java
Log:
Merge revs 2263:2266 from work_Ed branch

Copied: trunk/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/ILaunchableMachineController.java (from rev 2266, branches/work_Ed/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/ILaunchableMachineController.java)
===================================================================
--- trunk/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/ILaunchableMachineController.java	                        (rev 0)
+++ trunk/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/ILaunchableMachineController.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Nokia Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core;
+
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.process.IProcessLauncher;
+
+/**
+ * This interface identifies a machine controller whose machine can be launched as a process
+ * (e.g. a virtual machine or emulator) without explicitly acquiring the machine or trying to
+ * access it over the network.  It is currently used by the ESbox > Build Machines
+ * page.
+ * @author eswartz
+ *
+ */
+public interface ILaunchableMachineController {
+	/**
+	 * Tell if the virtual machine or engine is running.  This either detects
+	 * existing instances of the machine running on the host, or verifies
+	 * that a previously launched instance via {@link #startMachine(IProgressMonitor)} 
+	 * is still valid.
+	 * <p>
+	 * This check uses cached information that remains "true" for a long time
+	 * after the machine is detected.  Use {@link #scheduleProbe()} to reset.
+	 * @return true if it is likely running, false if we either don't know
+	 * or if it is not running.  If unsure, return false.
+	 */
+	boolean isMachineRunning();
+	
+	/**
+	 * Launch the machine and return an {@link IProcessLauncher} to track it.
+	 * The launcher is not quite ready upon return -- you need to call {@link LaunchedMachineStatus#monitor#runBlocking()}
+	 * or {@link LaunchedMachineStatus#monitor#runNonBlocking()}.
+	 * @return status of launch, which can be used to track the process
+	 * @throws MicaException if process launch fails (i.e. program not found) 
+	 */
+	LaunchedMachineInfo launchMachine() throws MicaException;
+
+}
\ No newline at end of file

Copied: trunk/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/LaunchedMachineInfo.java (from rev 2266, branches/work_Ed/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/LaunchedMachineInfo.java)
===================================================================
--- trunk/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/LaunchedMachineInfo.java	                        (rev 0)
+++ trunk/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/LaunchedMachineInfo.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Nokia Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.core;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.maemo.esbox.internal.maemosdk.core.Activator;
+import org.maemo.mica.common.core.Policy;
+import org.maemo.mica.common.core.process.IProcessLauncher;
+import org.maemo.mica.common.core.process.IProcessMonitor;
+import org.maemo.mica.common.core.process.StringBuilderStreamTextMonitor;
+import org.maemo.mica.common.core.process.ProcessLauncherUtils.LaunchResults;
+
+public class LaunchedMachineInfo {
+	public LaunchedMachineInfo(
+			IProcessLauncher processLauncher) {
+		this.launcher = processLauncher;
+		this.monitor = processLauncher.createProcessMonitor();
+		this.streamGrabber = new StringBuilderStreamTextMonitor(false);
+		this.monitor.addMonitor(streamGrabber);
+	}
+	public LaunchedMachineInfo(IStatus failedStatus) {
+		this.failedStatus = failedStatus;
+	}
+
+	public IProcessLauncher launcher;
+	public IProcessMonitor monitor;
+	public StringBuilderStreamTextMonitor streamGrabber;
+	private IStatus failedStatus;
+	
+	public boolean isAlive() {
+		if (monitor == null)
+			return false;
+		
+		return !monitor.isCompleted();
+	}
+	
+	/**
+	 * Return an status describing the output if the machine died.
+	 * @return IStatus
+	 */
+	public IStatus checkAlive() {
+		if (isAlive())
+			return Status.OK_STATUS;
+
+		String msg;
+		if (launcher != null) {
+			LaunchResults results = new LaunchResults(launcher.getLastCreatedProcess().exitValue(),
+					streamGrabber.stdout.toString(),
+					streamGrabber.stderr.toString());
+			msg = results.reportResults("Virtual machine died unexpectedly");
+			return Activator.createErrorStatus(msg, null);
+		} else {
+			return failedStatus != null ? failedStatus : 
+				Activator.createErrorStatus("The machine was never launched", null);
+		}
+	}
+
+	/**
+	 * @return the failed
+	 */
+	public boolean isFailed() {
+		return failedStatus != null;
+	}
+	
+	/**
+	 * Indicate that this launch failed
+	 * @param status 
+	 */
+	public void setFailed(IStatus status) {
+		if (this.failedStatus == null)
+			this.failedStatus = status;
+	}
+	/**
+	 * @return the failedStatus
+	 */
+	public IStatus getFailedStatus() {
+		return failedStatus;
+	}
+	/**
+	 * 
+	 */
+	public void cancel() {
+		setFailed(Policy.getCancelStatus(Activator.getDefault()));
+
+		// don't cancel anything else here... we can't distinguish explicit user cancel from 
+		// a nested cancellation (e.g. refresh SDKs launches machine, then the refresh is canceled).
+		// This can result in killing a perfectly fine machine
+	}
+}
\ No newline at end of file

Modified: trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BaseMachinePreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BaseMachinePreferencePage.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BaseMachinePreferencePage.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -11,6 +11,8 @@
 
 package org.maemo.esbox.internal.api.maemosdk.ui.preferences;
 
+import java.net.InetAddress;
+
 import org.maemo.mica.common.core.machine.IMachine;
 import org.maemo.mica.common.ui.preferences.ComposedPreferencePage;
 
@@ -39,5 +41,11 @@
 	public void validationFinished(IMachine machine) {
 		
 	}
-
-}
\ No newline at end of file
+	
+	/**
+	 * Tell if the address is provided by the machine.
+	 * @param address
+	 * @return
+	 */
+	public abstract boolean isSpecialHostAddress(InetAddress address);
+}

Modified: trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BuildMachinePreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BuildMachinePreferencePage.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BuildMachinePreferencePage.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -23,6 +23,7 @@
 
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.core.runtime.jobs.Job;
@@ -48,22 +49,32 @@
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.NewWizardAction;
+import org.maemo.esbox.internal.api.maemosdk.core.ILaunchableMachineController;
 import org.maemo.esbox.internal.maemosdk.ui.IHelpID;
 import org.maemo.esbox.internal.maemosdk.ui.UIActivator;
+import org.maemo.mica.common.core.MicaException;
 import org.maemo.mica.common.core.NetworkUtils;
 import org.maemo.mica.common.core.machine.IBuildMachine;
 import org.maemo.mica.common.core.machine.IComposablePreferencePage;
 import org.maemo.mica.common.core.machine.ILocalMachine;
 import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.IMachineController;
 import org.maemo.mica.common.core.machine.MachineManager;
 import org.maemo.mica.common.core.machine.MachineRegistry;
+import org.maemo.mica.common.ui.MicaStockUIConstants;
 import org.maemo.mica.common.ui.dialogs.DialogUtils;
 import org.maemo.mica.common.ui.dialogs.StyledTextProgressDialog;
+import org.maemo.mica.internal.api.common.core.machine.IMachineImpl;
 import org.maemo.mica.internal.api.common.core.sdk.SDKManagerInternal;
-import org.maemo.mica.internal.api.common.ui.utils.PixelConverter;
+import org.maemo.mica.internal.api.common.core.ui.GridLayoutWrappedTextUtils;
+import org.osgi.framework.Bundle;
 
 import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
 
@@ -88,10 +99,12 @@
 	private Map<String, IComposablePreferencePage> machineConfigPages;
 	protected Map<String, IBuildMachine> machineMap;
 	private Label noMachineConfigUI;
-	private Button applyAndValidateButton;
+	private Button validateButton;
 
 	private IComposablePreferencePage selectedMachinePage;
 	private IMachine lastValidatedMachine;
+
+	private Button launchButton;
 	
 	/**
 	 * 
@@ -171,13 +184,31 @@
 		composite.setLayout(layout);
 		composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
 		
-		Text descr = new Text(composite, SWT.READ_ONLY + SWT.MULTI + SWT.WRAP);
-		descr.setText("Select the build machine for ESbox.  The machine determines where scratchbox is found.\nIf the host is not Linux/x86 you must select and configure a virtual machine.");
-		GridData msgLayoutData = new GridData(SWT.LEFT, SWT.TOP, true, false);
-		msgLayoutData.heightHint = new PixelConverter(getControl()).convertHeightInCharsToPixels(3);
-		descr.setLayoutData(msgLayoutData);
-		descr.setBackground(parent.getBackground());
+		Link descr = new Link(composite, SWT.WRAP);
+		String message = "Select the build machine for ESbox.  "
+				+"The machine determines where Scratchbox is found, "
+				+"where builds are performed and applications are launched locally.";
 		
+		// HACK, we shouldn't know about this plugin :)
+		Bundle bundle = Platform.getBundle("org.maemo.esbox.vm.vmware");
+		if (bundle != null) {
+			message += "\n \n"
+					+ "If the host is not Linux/x86 you must select and configure a virtual machine.  "
+					+ "<a href=\"install\">Click here for Maemo installers.</a>";
+			
+			
+			descr.addSelectionListener(new SelectionAdapter() {
+				@Override
+				public void widgetSelected(SelectionEvent e) {
+					runNewWizard(getShell());
+				}
+			});
+		}
+		
+		descr.setText(message);
+		GridLayoutWrappedTextUtils.setupLabel(parent, descr, 
+				new GridData(SWT.LEFT, SWT.TOP, true, false));
+		
 		Label sep = new Label(composite, SWT.SEPARATOR + SWT.HORIZONTAL);
 		sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 		
@@ -191,6 +222,21 @@
 	}
 
 	/**
+	 * @param shell
+	 */
+	protected void runNewWizard(Shell shell) {
+		IWorkbenchWindow workbenchWindow = null;
+		IWorkbench workbench = PlatformUI.getWorkbench();
+		workbenchWindow = workbench.getActiveWorkbenchWindow();
+		if (workbenchWindow == null)
+			workbenchWindow = workbench.getWorkbenchWindows()[0];
+		
+		NewWizardAction action = new NewWizardAction(workbenchWindow);
+		action.setCategoryId(MicaStockUIConstants.MAEMO_TARGET_WIZARD_CATEGORY_ID);
+		action.run();
+	}
+
+	/**
 	 * @param parent
 	 */
 	private void createBuildMachineSelectorUI(Composite parent) {
@@ -257,8 +303,7 @@
 		// then add the pre-sorted entries
 		for (IBuildMachine machine : availableBuildMachines) {
 			IComposablePreferencePage page = machine.createPreferencePage();
-			machineConfigPages.put(machine.getName(), 
-					page);
+			machineConfigPages.put(machine.getName(), page);
 			page.setOwner(this);
 			machineMap.put(machine.getName(), machine);
 		}
@@ -295,8 +340,10 @@
 			machineConfigStackLayout.topControl = noMachineConfigUI;
 			selectedMachine = null;
 			selectedMachinePage = null;
+			launchButton.setEnabled(false);
+
 			setErrorMessage(null);
-			setMessage(null, INFORMATION);
+			setMessage(null, NONE);
 			setValid(true);
 		}
 		machineConfigComposite.layout();
@@ -329,6 +376,9 @@
 	 */
 	@Override
 	public boolean isValid() {
+		if (launchButton != null)
+			launchButton.setEnabled(false);
+		
 		if (!super.isValid())
 			return false;
 		
@@ -337,6 +387,12 @@
 			if (page != null && !page.isValid())
 				return false;
 		}		
+		
+		if (launchButton != null) {
+			IMachineController machineController = ((IMachineImpl) selectedMachine).getMachineController();
+			launchButton.setEnabled(machineController instanceof ILaunchableMachineController);
+		}
+
 		return true;
 	}
 	
@@ -346,8 +402,8 @@
 	@Override
 	protected void updateApplyButton() {
 		super.updateApplyButton();
-		if (applyAndValidateButton != null)
-			applyAndValidateButton.setEnabled(isValid());
+		if (validateButton != null)
+			validateButton.setEnabled(isValid());
 	}
 	
 	/* (non-Javadoc)
@@ -474,7 +530,7 @@
 			final IMachine[] currentMachines = currentMachines_;
 			boolean doit;
 			String message;
-			if (selectedMachine.getName().equals(current.getName())) {
+			if (selectedMachine.getClass().equals(current.getClass())) {
 				// the same machine, different message
 				message = MessageFormat.format(
 						"You have changed virtual machine settings for ''{0}''.  The virtual machine is still running, however.\n \n"+
@@ -578,9 +634,9 @@
 	
 	@Override
 	protected void contributeButtons(Composite parent) {
-		applyAndValidateButton = new Button(parent, SWT.PUSH);
-		applyAndValidateButton.setText("&Validate Machine");
-		applyAndValidateButton.addSelectionListener(new SelectionAdapter() {
+		launchButton = new Button(parent, SWT.PUSH);
+		launchButton.setText("&Launch Machine");
+		launchButton.addSelectionListener(new SelectionAdapter() {
 			@Override
 			public void widgetSelected(SelectionEvent ev) {
 				
@@ -588,6 +644,29 @@
 					Display.getDefault().asyncExec(new Runnable() {
 
 						public void run() {
+							launchMachine();
+						}
+
+						
+					});
+				}
+			}
+		});
+		launchButton.setEnabled(false);
+		
+		((GridLayout) parent.getLayout()).numColumns++;
+
+		
+		validateButton = new Button(parent, SWT.PUSH);
+		validateButton.setText("&Validate Machine");
+		validateButton.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent ev) {
+				
+				if (selectedMachine != null) {
+					Display.getDefault().asyncExec(new Runnable() {
+
+						public void run() {
 							validateMachine();
 						}
 
@@ -634,6 +713,56 @@
 	}
 
 	/**
+	 * Launch the machine (only).  This is called on the UI thread.
+	 */
+	protected void launchMachine() {
+		final IMachine machineToValidate = getCurrentMachine();
+		
+		IMachineController machineController = ((IMachineImpl)machineToValidate).getMachineController();
+		if (!(machineController instanceof ILaunchableMachineController)) {
+			DialogUtils.showWarningDialog(getShell(), "Cannot Launch", "This machine cannot be launched.");
+			return;
+		}
+		final ILaunchableMachineController controller = (ILaunchableMachineController) machineController;
+		
+		if (controller.isMachineRunning()) {
+			DialogUtils.showWarningDialog(getShell(), "Already Running", 
+					"This machine is already running.");
+			return;
+		}
+		
+
+		shutDownMachinesBeforeSwitchingTo(machineToValidate);
+
+		ProgressMonitorDialog dialog = new ProgressMonitorDialog(
+				getShell());
+		try {
+			dialog.run(true, true, new IRunnableWithProgress() {
+
+				public void run(IProgressMonitor monitor)
+						throws InvocationTargetException, InterruptedException {
+					try {
+						controller.launchMachine();
+					} catch (MicaException e) {
+						throw new InvocationTargetException(e);
+					}
+				}
+				
+			});
+		} catch (InterruptedException e) {
+			// ignore
+		} catch (InvocationTargetException e) {
+			UIActivator.getErrorLogger().logAndShowError("Unexpected exception running tests", e.getCause());
+		} catch (Exception e) {
+			UIActivator.getErrorLogger().logAndShowError("Unexpected exception running tests", e);
+		}
+		
+		lastValidatedMachine = machineToValidate;
+		if (selectedMachinePage instanceof BaseMachinePreferencePage)
+			((BaseMachinePreferencePage) selectedMachinePage).validationFinished(lastValidatedMachine);
+	}
+
+	/**
 	 * Get the machine that is being configured.
 	 * @return IMachine
 	 */

Modified: trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/SharedFolderTreeViewer.java
===================================================================
--- trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/SharedFolderTreeViewer.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/SharedFolderTreeViewer.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -22,6 +22,7 @@
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.viewers.BaseLabelProvider;
 import org.eclipse.jface.viewers.CellEditor;
@@ -52,6 +53,7 @@
 import org.maemo.mica.common.core.filesystem.SharedFolderManager;
 import org.maemo.mica.common.core.filesystem.SharedFolderState;
 import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineManager;
 import org.maemo.mica.common.core.machine.MachineRegistry;
 import org.maemo.mica.common.ui.CommonUIImages;
 import org.maemo.mica.common.ui.TextAndDialogCellEditor;
@@ -622,7 +624,11 @@
 			SharedFolderState state;
 			boolean retry = false;
 			do {
+				MachineRegistry.getInstance().getLocalMachine().getFileSystemAccess().refresh();
 				remoteMachine.getFileSystemAccess().refresh();
+
+				// probe machine so we detect a launched one
+				MachineManager.getInstance().probeMachine(remoteMachine, new SubProgressMonitor(monitor, 0));
 				
 				state = SharedFolderManager.getInstance().analyzeSharedFolderState(
 						MachineRegistry.getInstance().getLocalMachine(),

Modified: trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/SharedFoldersPreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/SharedFoldersPreferencePage.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/SharedFoldersPreferencePage.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -14,14 +14,12 @@
 import java.text.MessageFormat;
 import java.util.List;
 
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.preference.BooleanFieldEditor;
 import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
@@ -73,7 +71,6 @@
 	private final String preferenceName;
 	private IMachine remoteMachine;
 	private final BaseMachinePreferencePage machinePreferencePage;
-	private IPropertyChangeListener scanFoldersListener;
 	
 	public SharedFoldersPreferencePage(BaseMachinePreferencePage machinePreferencePage, IPreferenceStore store, String preferenceName) {
 		super();
@@ -192,7 +189,7 @@
 
 		final Button scanFoldersButton = new Button(tableComposite, SWT.CHECK);
 		scanFoldersButton.setSelection(scanFolders);
-		scanFoldersButton.setText("Dynamically update shared folder status");
+		scanFoldersButton.setText("Check shared folder status while editing");
 		scanFoldersButton.addSelectionListener(new SelectionAdapter() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
@@ -322,7 +319,7 @@
 			return;
 		
 		setErrorMessage(null);
-		setMessage(null, INFORMATION);
+		setMessage(null, NONE);
 		
 		// only check quick stuff here
 		for (ISharedFolder share : model) {
@@ -341,17 +338,20 @@
 				return;
 			}		
 			
-			/*
 			if (share.isHostProvidedShare()) {
 				IPath path = share.getSharePath();
 				if (!path.toFile().exists()) {
 					setErrorMessage(MessageFormat.format(
-							"The shared folder ''{0}'' does not exist on this machine.",
+							"The shared folder ''{0}'' does not exist on the host.",
 							path.toOSString()));
 					setValid(false);
 					return;
 				}
-			} else {				
+			} 
+			/*
+			 // do this when validating
+			  
+			 else {				
 				IPath path = share.getMountPath();
 				if (!path.toFile().exists()) {
 					if (!path.isRoot()) {
@@ -365,6 +365,7 @@
 					}
 				}
 			}*/
+			
 		}
 		
 		setValid(true);

Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseLaunchableVirtualMachineController.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseLaunchableVirtualMachineController.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseLaunchableVirtualMachineController.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -20,6 +20,8 @@
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
+import org.maemo.esbox.internal.api.maemosdk.core.ILaunchableMachineController;
+import org.maemo.esbox.internal.api.maemosdk.core.LaunchedMachineInfo;
 import org.maemo.esbox.internal.vm.Activator;
 import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
 import org.maemo.mica.common.core.MicaCanceledException;
@@ -51,7 +53,7 @@
  *
  */
 public abstract class BaseLaunchableVirtualMachineController 
-	extends BaseVirtualMachineController  {
+	extends BaseVirtualMachineController implements ILaunchableMachineController  {
 	
 	protected LaunchedMachineInfo launchInfo;
 
@@ -110,14 +112,10 @@
 	 */
 	abstract protected ProcessLauncherParameters constructLaunchParameters();
 
-	/**
-	 * Launch the machine and return an {@link IProcessLauncher} to track it.
-	 * The launcher is not quite ready upon return -- you need to call {@link LaunchedMachineStatus#monitor#runBlocking()}
-	 * or {@link LaunchedMachineStatus#monitor#runNonBlocking()}.
-	 * @return status of launch, which can be used to track the process
-	 * @throws MicaException if process launch fails (i.e. program not found) 
+	/* (non-Javadoc)
+	 * @see org.maemo.esbox.internal.api.vm.core.ILaunchableMachineController#launchMachine()
 	 */
-	protected LaunchedMachineInfo launchMachine() throws MicaException {
+	public LaunchedMachineInfo launchMachine() throws MicaException {
 		
 		ProcessLauncherParameters parameters = constructLaunchParameters();
 		List<String> cmdLine = parameters.getCommandLine();
@@ -129,7 +127,7 @@
 		final IProcessLauncher processLauncher = processLauncherFactory.createProcessLauncher(parameters);
 		processLauncher.createProcess(null);
 		
-		LaunchedMachineInfo status = new LaunchedMachineInfo(machineConfiguration, processLauncher);
+		LaunchedMachineInfo status = new LaunchedMachineInfo(processLauncher);
 		
 		
 		return status;

Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -28,6 +28,7 @@
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.maemo.esbox.internal.api.maemosdk.core.LaunchedMachineInfo;
 import org.maemo.esbox.internal.api.maemosdk.ui.preferences.BuildMachinePreferencePage;
 import org.maemo.esbox.internal.api.vm.ui.LaunchVirtualMachineDialog;
 import org.maemo.esbox.internal.api.vm.ui.SlowVirtualMachineLaunchMonitorDialog;

Deleted: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/LaunchedMachineInfo.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/LaunchedMachineInfo.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/LaunchedMachineInfo.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Nokia Corporation
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Ed Swartz (Nokia) - initial API and implementation
- *******************************************************************************/
-
-package org.maemo.esbox.internal.api.vm.core;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.maemo.esbox.internal.vm.Activator;
-import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
-import org.maemo.mica.common.core.process.IProcessLauncher;
-import org.maemo.mica.common.core.process.IProcessMonitor;
-import org.maemo.mica.common.core.process.StringBuilderStreamTextMonitor;
-import org.maemo.mica.common.core.process.ProcessLauncherUtils.LaunchResults;
-
-public class LaunchedMachineInfo {
-	public LaunchedMachineInfo(
-			IVirtualMachineConfiguration configuration,
-			IProcessLauncher processLauncher) {
-		this.configuration = configuration;
-		this.launcher = processLauncher;
-		this.monitor = processLauncher.createProcessMonitor();
-		this.streamGrabber = new StringBuilderStreamTextMonitor(false);
-		this.monitor.addMonitor(streamGrabber);
-	}
-	public LaunchedMachineInfo(IStatus failedStatus) {
-		this.failedStatus = failedStatus;
-	}
-
-	public IProcessLauncher launcher;
-	public IProcessMonitor monitor;
-	public StringBuilderStreamTextMonitor streamGrabber;
-	public IVirtualMachineConfiguration configuration;
-	private IStatus failedStatus;
-	
-	public boolean isAlive() {
-		if (monitor == null)
-			return false;
-		
-		return !monitor.isCompleted();
-	}
-	
-	/**
-	 * Return an status describing the output if the machine died.
-	 * @return IStatus
-	 */
-	public IStatus checkAlive() {
-		if (isAlive())
-			return Status.OK_STATUS;
-
-		String msg;
-		if (launcher != null) {
-			LaunchResults results = new LaunchResults(launcher.getLastCreatedProcess().exitValue(),
-					streamGrabber.stdout.toString(),
-					streamGrabber.stderr.toString());
-			msg = results.reportResults("Virtual machine died unexpectedly");
-			return Activator.createErrorStatus(msg, null);
-		} else {
-			return failedStatus != null ? failedStatus : 
-				Activator.createErrorStatus("The machine was never launched", null);
-		}
-	}
-
-	/**
-	 * @return the failed
-	 */
-	public boolean isFailed() {
-		return failedStatus != null;
-	}
-	
-	/**
-	 * Indicate that this launch failed
-	 * @param status 
-	 */
-	public void setFailed(IStatus status) {
-		if (this.failedStatus == null)
-			this.failedStatus = status;
-	}
-	/**
-	 * @return the failedStatus
-	 */
-	public IStatus getFailedStatus() {
-		return failedStatus;
-	}
-	/**
-	 * 
-	 */
-	public void cancel() {
-		setFailed(BaseLaunchableVirtualMachineController.CANCEL_STATUS);
-
-		// don't cancel anything else here... we can't distinguish explicit user cancel from 
-		// a nested cancellation (e.g. refresh SDKs launches machine, then the refresh is canceled).
-		// This can result in killing a perfectly fine machine
-	}
-}
\ No newline at end of file

Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/AddressFieldEditor.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/AddressFieldEditor.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/AddressFieldEditor.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -83,6 +83,7 @@
 	private boolean isValid;
 	private boolean allowNetworkAddress;
 	private String oldValue;
+	private boolean allowEmptyAddress;
 
 	//private Button button;
 	
@@ -159,7 +160,24 @@
 	public boolean isAllowNetworkAddress() {
 		return allowNetworkAddress;
 	}
+
+	/**
+	 * Tell whether a blank or empty address is allowed
+	 * @param allow
+	 */
+	public void allowEmptyAddress(boolean allow) {
+		this.allowEmptyAddress = allow;
+	}
 	
+	/**
+	 * 
+	 * Tell whether a blank or empty address is allowed
+	 * @return the allowEmptyAddress
+	 */
+	public boolean isAllowEmptyAddress() {
+		return allowEmptyAddress;
+	}
+	
 	/* (non-Javadoc)
 	 * @see org.eclipse.jface.preference.FieldEditor#isValid()
 	 */
@@ -171,7 +189,7 @@
 		isValid = checkState();
 	}
 	
-	private boolean checkState() {
+	protected boolean checkState() {
 		String address = getComboViewer().getCombo().getText();
 		
 		String label = getLabelText().trim();
@@ -179,6 +197,9 @@
 			label = label.substring(0, label.length() - 1);
 		
 		if (address == null || address.length() == 0) {
+			if (allowEmptyAddress) {
+				return true;
+			}
 			showErrorMessage("Invalid address in " + label);
 			return false;
 		} 
@@ -188,14 +209,30 @@
 			}
 			return true;
 		}
+		
 		if (getPage() != null) {
-			getPage().setMessage(null, IMessageProvider.WARNING);
+			getPage().setMessage(null, IMessageProvider.NONE);
 		}
 		clearErrorMessage();
+
+		if (!customValidate(address, label))
+			return false;
+		
 		return true;
 	}
 
-    protected void valueChanged() {
+    /**
+     * Override to perform custom validation of the address.
+     * If an error occurs, use getPage()#set[Error]Message().
+	 * @param address current address
+	 * @param label label of field
+	 * @return true if valid, false otherwise.  
+	 */
+	protected boolean customValidate(String address, String label) {
+		return true;
+	}
+
+	protected void valueChanged() {
         setPresentsDefaultValue(false);
         boolean oldState = isValid;
         refreshValidState();

Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -13,8 +13,10 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.IMessageProvider;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.preference.IPreferenceStore;
@@ -34,6 +36,7 @@
 import org.maemo.esbox.internal.vm.Activator;
 import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
 import org.maemo.esbox.vm.core.VirtualMachinePreferenceConstants;
+import org.maemo.mica.common.core.NetworkUtils;
 import org.maemo.mica.common.core.PasswordStorage;
 import org.maemo.mica.common.ui.StyledTextProgressReporter;
 import org.maemo.mica.common.ui.dialogs.StyledTextProgressDialog;
@@ -220,7 +223,31 @@
 		feSshHostAddr = new AddressFieldEditor(
 				VirtualMachinePreferenceConstants.VM_SSH_HOST_ADDR,
 				"Host address:",
-				getFieldEditorParent());
+				getFieldEditorParent()) {
+			/* (non-Javadoc)
+			 * @see org.maemo.esbox.internal.api.vm.ui.preferences.AddressFieldEditor#customValidate(java.lang.String, java.lang.String)
+			 */
+			@Override
+			protected boolean customValidate(String address,
+					String label) {
+				try {
+					InetAddress addr = InetAddress.getByName(address);
+					if (NetworkUtils.isLocalAddress(addr))
+						return true;
+					if (basePrefPage.isSpecialHostAddress(addr))
+						return true;
+					if (getPage() != null)
+						getPage().setMessage(
+								"The address " + addr + " does not match a local interface in " + label,
+								IMessageProvider.WARNING);
+					return true;
+				} catch (UnknownHostException e) {
+					if (getPage() != null)
+						getPage().setErrorMessage("Unknown host in " + label + ": " + e.getMessage());
+					return false;
+				}
+			}
+		};
 		addField(feSshHostAddr);
 		control = feSshHostAddr.getViewerControl();
 		control.setToolTipText("Specify the address of the host as seen from the machine.");
@@ -358,4 +385,5 @@
 			config.setHostPort(22);
 		}
 	}
+	
 }

Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachinePreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachinePreferencePage.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachinePreferencePage.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -11,6 +11,8 @@
 
 package org.maemo.esbox.internal.vm;
 
+import java.net.InetAddress;
+
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jface.dialogs.DialogSettings;
 import org.eclipse.jface.preference.IPreferenceStore;
@@ -87,4 +89,12 @@
 			
 		};
 	}
+	
+	/* (non-Javadoc)
+	 * @see org.maemo.esbox.internal.api.maemosdk.ui.preferences.BaseMachinePreferencePage#isSpecialHostAddress(java.net.InetAddress)
+	 */
+	@Override
+	public boolean isSpecialHostAddress(InetAddress address) {
+		return false;
+	}
 }

Modified: trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachineController.java
===================================================================
--- trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachineController.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachineController.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -22,8 +22,8 @@
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
+import org.maemo.esbox.internal.api.maemosdk.core.LaunchedMachineInfo;
 import org.maemo.esbox.internal.api.vm.core.BaseLaunchableVirtualMachineController;
-import org.maemo.esbox.internal.api.vm.core.LaunchedMachineInfo;
 import org.maemo.esbox.vm.core.IVirtualMachine;
 import org.maemo.esbox.vm.qemu.IQemuConfiguration;
 import org.maemo.mica.common.core.MicaException;

Modified: trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuPreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuPreferencePage.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuPreferencePage.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -40,6 +40,11 @@
 public class QemuPreferencePage extends BaseVirtualMachinePreferencePage {
 
 	/**
+	 * 
+	 */
+	private static final String BASE_DHCP_ADDRESS = "10.0.2.2";
+
+	/**
 	 * @param settings
 	 */
 	public QemuPreferencePage(IVirtualMachineConfiguration config) {
@@ -80,7 +85,7 @@
 					 */
 					@Override
 					protected void addCustomAddresses(Set<String> addrs) {
-						addrs.add("10.0.2.2");
+						addrs.add(BASE_DHCP_ADDRESS);
 						super.addCustomAddresses(addrs);
 					}
 				};
@@ -129,7 +134,7 @@
 				commonPrefPage.getSSHHostPort().setStringValue(hostPort);
 				reporter.logInfo("Setting SSH Host Port to " + hostPort);
 				
-				String host = "10.0.2.2";
+				String host = BASE_DHCP_ADDRESS;
 				try {
 					commonPrefPage.getSSHHostAddr().setAddress(
 							InetAddress.getByName(host));
@@ -143,4 +148,14 @@
 		};
 	}
 	
+	/* (non-Javadoc)
+	 * @see org.maemo.esbox.internal.api.maemosdk.ui.preferences.BaseMachinePreferencePage#isSpecialHostAddress(java.net.InetAddress)
+	 */
+	@Override
+	public boolean isSpecialHostAddress(InetAddress address) {
+		if (!(address instanceof Inet4Address))
+			return false;
+		byte[] addr = address.getAddress();
+		return addr[0] == 10 && addr[1] == 0;
+	}
 }

Modified: trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachineController.java
===================================================================
--- trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachineController.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachineController.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -26,8 +26,8 @@
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
+import org.maemo.esbox.internal.api.maemosdk.core.LaunchedMachineInfo;
 import org.maemo.esbox.internal.api.vm.core.BaseLaunchableVirtualMachineController;
-import org.maemo.esbox.internal.api.vm.core.LaunchedMachineInfo;
 import org.maemo.esbox.vm.core.IVirtualMachine;
 import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
 import org.maemo.esbox.vm.virtualbox.IVirtualBoxConfiguration;

Modified: trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxPreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxPreferencePage.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxPreferencePage.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -47,6 +47,12 @@
  */
 public class VirtualBoxPreferencePage extends BaseVirtualMachinePreferencePage {
 
+	/**
+	 * 
+	 */
+	private static final String BASE_DHCP_ADDRESS = "10.0.2.2";
+
+
 	public VirtualBoxPreferencePage(IVirtualMachineConfiguration config) {
 		super(config);
 	}
@@ -86,7 +92,7 @@
 					 */
 					@Override
 					protected void addCustomAddresses(Set<String> addrs) {
-						addrs.add("10.0.2.2");
+						addrs.add(BASE_DHCP_ADDRESS);
 						super.addCustomAddresses(addrs);
 					}
 				};
@@ -123,7 +129,7 @@
 				String target = "127.0.0.1";
 				String targetPort = "2222";
 				String hostPort = "22";
-				String host = "10.0.2.2";
+				String host = BASE_DHCP_ADDRESS;
  
 				Map<String, String> machineInfo = VirtualBoxUtils.getVirtualMachineInfo(configuration);
 				
@@ -301,4 +307,16 @@
 			IPreferenceStore preferenceStore) {
 		return new VirtualBoxSettingsPreferencePage(preferenceStore);
 	}
+
+
+	/* (non-Javadoc)
+	 * @see org.maemo.esbox.internal.api.maemosdk.ui.preferences.BaseMachinePreferencePage#isSpecialHostAddress(java.net.InetAddress)
+	 */
+	@Override
+	public boolean isSpecialHostAddress(InetAddress address) {
+		if (!(address instanceof Inet4Address))
+			return false;
+		byte[] addr = address.getAddress();
+		return addr[0] == 10 && addr[1] == 0;
+	}
 }

Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -21,8 +21,8 @@
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
+import org.maemo.esbox.internal.api.maemosdk.core.LaunchedMachineInfo;
 import org.maemo.esbox.internal.api.vm.core.BaseLaunchableVirtualMachineController;
-import org.maemo.esbox.internal.api.vm.core.LaunchedMachineInfo;
 import org.maemo.esbox.vm.core.IVirtualMachine;
 import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
 import org.maemo.mica.common.core.HostUtils;

Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -202,7 +202,7 @@
 			}
 		}
 		
-		if (vmnet != null) {
+		if (vmnet != null && hostAddr != null) {
 			setupForVMnet(reporter, vmnet, hostAddr);
 		} else {
 			setupForUnknownNetwork(reporter, isNAT);	
@@ -353,4 +353,12 @@
 		}
 	}
 
+
+	/* (non-Javadoc)
+	 * @see org.maemo.esbox.internal.api.maemosdk.ui.preferences.BaseMachinePreferencePage#isSpecialHostAddress(java.net.InetAddress)
+	 */
+	@Override
+	public boolean isSpecialHostAddress(InetAddress address) {
+		return false;
+	}
 }

Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java	2009-10-05 22:47:24 UTC (rev 2266)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java	2009-10-06 03:16:45 UTC (rev 2267)
@@ -39,7 +39,7 @@
 	//private StringFieldEditor feVMWAREExeName;
 	//private StringFieldEditor feVMWARELaunchPattern;
 	/*private*/ final BaseMachinePreferencePage vmPrefPage;
-	private RadioGroupFieldEditor feVMwareProductType;
+	private RadioGroupFieldEditor feVMwareProductType;	// may be null
 	private DirectoryFieldEditor feVMWAREPath;
 
 	/**
@@ -60,28 +60,29 @@
 	protected void createFieldEditors() {
 		Text text;
 		
-		String[][] namesAndValues;
 		if (HostUtils.isOSX()) {
-			namesAndValues = new String[][] {
-					{ "Fusion", IVMwareConfiguration.PRODUCT_FUSION }
-			};
+			// don't show radio button with only one choice
+			//namesAndValues = new String[][] {
+			//		{ "Fusion", IVMwareConfiguration.PRODUCT_FUSION }
+			//};
 		} else {
+			String[][] namesAndValues;
 			namesAndValues = new String[][] {
 					{ "Player", IVMwareConfiguration.PRODUCT_PLAYER },
 					{ "Workstation", IVMwareConfiguration.PRODUCT_WORKSTATION },
 					{ "Server", IVMwareConfiguration.PRODUCT_SERVER },
 			};
+			feVMwareProductType = new RadioGroupFieldEditor(
+					VMwarePreferenceConstants.VMWARE_PRODUCT,
+					"Product Type:",
+					3, namesAndValues,
+					getFieldEditorParent());
+			
+			Composite radioBoxControl = feVMwareProductType.getRadioBoxControl(getFieldEditorParent());
+			radioBoxControl.setToolTipText("Set the VMware product type to use.");
+			addField(feVMwareProductType);
 		}
-		feVMwareProductType = new RadioGroupFieldEditor(
-				VMwarePreferenceConstants.VMWARE_PRODUCT,
-				"Product Type:",
-				3, namesAndValues,
-				getFieldEditorParent());
 		
-		Composite radioBoxControl = feVMwareProductType.getRadioBoxControl(getFieldEditorParent());
-		radioBoxControl.setToolTipText("Set the VMware product type to use.");
-		addField(feVMwareProductType);
-		
 		/*
 		feVMWAREExeName = new FileFieldEditor(
 				VMwarePreferenceConstants.VMWARE_EXE_NAME,
@@ -160,15 +161,20 @@
 	 * @return
 	 */
 	private String getCurrentProductName() {
-		// horrible horrible private fields
-		Field field;
-		try {
-			field = RadioGroupFieldEditor.class.getDeclaredField("value");
-			field.setAccessible(true);
-			
-			return (String) field.get(feVMwareProductType);
-		} catch (Exception e) {
-			return null;
+		if (feVMwareProductType != null) {
+			// horrible horrible private fields
+			Field field;
+			try {
+				field = RadioGroupFieldEditor.class.getDeclaredField("value");
+				field.setAccessible(true);
+				
+				return (String) field.get(feVMwareProductType);
+			} catch (Exception e) {
+				return null;
+			}
+		} else {
+			// OS X
+			return IVMwareConfiguration.PRODUCT_FUSION;
 		}
 	}
 }



More information about the Esbox-commits mailing list