[Esbox-commits] r2139 - in branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware: . META-INF src/org/maemo/esbox/internal/api/vm/vmware src/org/maemo/esbox/internal/vm/vmware src/org/maemo/esbox/internal/vm/vmware/ui/wizards src/org/maemo/esbox/vm/vmware
eswartz at garage.maemo.org
eswartz at garage.maemo.org
Thu Sep 10 02:20:36 EEST 2009
Author: eswartz
Date: 2009-09-10 02:20:35 +0300 (Thu, 10 Sep 2009)
New Revision: 2139
Modified:
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/META-INF/MANIFEST.MF
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/about.html
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/build.properties
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/plugin.xml
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DownloadExecution.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DownloadProgressMonitor.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/RandomFileOutputStream.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/Activator.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareBuildMachineFactory.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareConfiguration.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachine.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineFactory.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferenceConstants.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferenceConstantsPrivate.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferenceMigrator.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareTargetInterfaceAddressProvider.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareUtils.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallationWorkPage.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMLicenseWizardPage.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/NewMaemoSDKVMWizard.java
branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/vm/vmware/IVMwareConfiguration.java
Log:
Merge rev 2138 from trunk (svn:eol-style changes)
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/about.html
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/build.properties
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/build.properties 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/build.properties 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,9 +1,9 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml,\
- conf/,\
- about_files/,\
- about.html,\
- icons/
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ conf/,\
+ about_files/,\
+ about.html,\
+ icons/
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/build.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/plugin.xml
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/plugin.xml 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/plugin.xml 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,43 +1,43 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.2"?>
-<plugin>
- <extension
- point="org.maemo.mica.common.core.build_machine_factory">
- <build_machine_factory
- class="org.maemo.esbox.internal.vm.vmware.VMwareBuildMachineFactory">
- </build_machine_factory>
- </extension>
-
- <extension
- point="org.maemo.mica.common.core.preference_set_provider">
- <preferenceSetProvider
- defaultsXMLFile="conf/vmware_prefs.xml"
- preferenceConstantsClass="org.maemo.esbox.internal.vm.vmware.VMwarePreferenceConstants"
- preferenceMigratorClass="org.maemo.esbox.internal.vm.vmware.VMwarePreferenceMigrator"
- preferenceStoreBundle="org.maemo.esbox.vm.vmware"
- version="1">
- </preferenceSetProvider>
- </extension>
- <extension
- point="org.maemo.mica.common.core.machine_factory">
- <machineFactory scheme="vmware+ssh"
- class="org.maemo.esbox.internal.vm.vmware.VMwareMachineFactory">
- </machineFactory>
- </extension>
- <extension
- point="org.eclipse.ui.newWizards">
- <wizard
- canFinishEarly="false"
- category="org.maemo.mica.maemosdk.ui.maemo_installer_wizard"
- class="org.maemo.esbox.internal.vm.vmware.ui.wizards.NewMaemoSDKVMWizard"
- hasPages="true"
- icon="icons/full/etool16/virtual_machine.png"
- id="org.maemo.esbox.vm.maemovm_installer"
- name="Maemo SDK Virtual Image">
- <description>
- Installs Maemo SDK Virtual Image to be used with ESbox to build and launch applications.
- </description>
- </wizard>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.maemo.mica.common.core.build_machine_factory">
+ <build_machine_factory
+ class="org.maemo.esbox.internal.vm.vmware.VMwareBuildMachineFactory">
+ </build_machine_factory>
+ </extension>
+
+ <extension
+ point="org.maemo.mica.common.core.preference_set_provider">
+ <preferenceSetProvider
+ defaultsXMLFile="conf/vmware_prefs.xml"
+ preferenceConstantsClass="org.maemo.esbox.internal.vm.vmware.VMwarePreferenceConstants"
+ preferenceMigratorClass="org.maemo.esbox.internal.vm.vmware.VMwarePreferenceMigrator"
+ preferenceStoreBundle="org.maemo.esbox.vm.vmware"
+ version="1">
+ </preferenceSetProvider>
+ </extension>
+ <extension
+ point="org.maemo.mica.common.core.machine_factory">
+ <machineFactory scheme="vmware+ssh"
+ class="org.maemo.esbox.internal.vm.vmware.VMwareMachineFactory">
+ </machineFactory>
+ </extension>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ canFinishEarly="false"
+ category="org.maemo.mica.maemosdk.ui.maemo_installer_wizard"
+ class="org.maemo.esbox.internal.vm.vmware.ui.wizards.NewMaemoSDKVMWizard"
+ hasPages="true"
+ icon="icons/full/etool16/virtual_machine.png"
+ id="org.maemo.esbox.vm.maemovm_installer"
+ name="Maemo SDK Virtual Image">
+ <description>
+ Installs Maemo SDK Virtual Image to be used with ESbox to build and launch applications.
+ </description>
+ </wizard>
+ </extension>
+
+</plugin>
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/plugin.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DownloadExecution.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DownloadProgressMonitor.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,111 +1,111 @@
-/*******************************************************************************
- * Copyright (c) 2009 INdT, (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:
- * Raul Herbster (INdT) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.api.vm.vmware;
-
-/**
- * @author raulherbster
- *
- */
-public class MaemoSDKVMDescription implements Comparable<MaemoSDKVMDescription> {
-
- private static final String LINE_SEPARATOR = System.getProperty("line.separator");
-
- public static final String SERVER_IMAGE_DESCRIPTION = "This is a virtual disk image usable as a Build Machine in ESbox. This does not have X installed." + LINE_SEPARATOR +
- "Scratchbox and the Maemo SDK are not installed by default, but the wizard can install these for you.";
-
- public static final String DESKTOP_IMAGE_DESCRIPTION = "This is a virtual disk image which has X and ESbox installed by default." + LINE_SEPARATOR +
- "It may also be used as a Build Machine in ESbox, but is intended for standalone usage. Scratchbox and the Maemo SDK are installed by default";
-
- private boolean isServerImage;
-
- private String name;
-
- private String version;
-
- private String description;
-
- private String licenseText;
-
- /**
- * Constructor
- *
- * @param isServerImage
- * @param name
- * @param description
- */
- public MaemoSDKVMDescription(boolean isServerImage, String name,
- String version, String description, String licenseText) {
- this.isServerImage = isServerImage;
- this.name = name;
- this.version = version;
- this.description = description;
- this.licenseText = licenseText;
- }
-
- public MaemoSDKVMDescription() {
- this(true,"","","","");
- }
-
- /**
- * @return the isServerImage
- */
- public boolean isServerImage() {
- return isServerImage;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return the version
- */
- public String getVersion() {
- return version;
- }
-
- /**
- * @return the description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @return the license of the virtual machine
- */
- public String getLicense() {
- return licenseText;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null)
- return false;
- if (obj.getClass() != this.getClass())
- return false;
- MaemoSDKVMDescription descriptor = (MaemoSDKVMDescription)obj;
- return descriptor.getName().equals(this.getName());
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(MaemoSDKVMDescription o) {
- if (o == null)
- return 1;
- return (-1) * (getVersion() + (isServerImage() ? "server" : "desktop")).compareTo(o.getVersion() + (o.isServerImage() ? "server" : "desktop"));
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 INdT, (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:
+ * Raul Herbster (INdT) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.api.vm.vmware;
+
+/**
+ * @author raulherbster
+ *
+ */
+public class MaemoSDKVMDescription implements Comparable<MaemoSDKVMDescription> {
+
+ private static final String LINE_SEPARATOR = System.getProperty("line.separator");
+
+ public static final String SERVER_IMAGE_DESCRIPTION = "This is a virtual disk image usable as a Build Machine in ESbox. This does not have X installed." + LINE_SEPARATOR +
+ "Scratchbox and the Maemo SDK are not installed by default, but the wizard can install these for you.";
+
+ public static final String DESKTOP_IMAGE_DESCRIPTION = "This is a virtual disk image which has X and ESbox installed by default." + LINE_SEPARATOR +
+ "It may also be used as a Build Machine in ESbox, but is intended for standalone usage. Scratchbox and the Maemo SDK are installed by default";
+
+ private boolean isServerImage;
+
+ private String name;
+
+ private String version;
+
+ private String description;
+
+ private String licenseText;
+
+ /**
+ * Constructor
+ *
+ * @param isServerImage
+ * @param name
+ * @param description
+ */
+ public MaemoSDKVMDescription(boolean isServerImage, String name,
+ String version, String description, String licenseText) {
+ this.isServerImage = isServerImage;
+ this.name = name;
+ this.version = version;
+ this.description = description;
+ this.licenseText = licenseText;
+ }
+
+ public MaemoSDKVMDescription() {
+ this(true,"","","","");
+ }
+
+ /**
+ * @return the isServerImage
+ */
+ public boolean isServerImage() {
+ return isServerImage;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @return the license of the virtual machine
+ */
+ public String getLicense() {
+ return licenseText;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null)
+ return false;
+ if (obj.getClass() != this.getClass())
+ return false;
+ MaemoSDKVMDescription descriptor = (MaemoSDKVMDescription)obj;
+ return descriptor.getName().equals(this.getName());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(MaemoSDKVMDescription o) {
+ if (o == null)
+ return 1;
+ return (-1) * (getVersion() + (isServerImage() ? "server" : "desktop")).compareTo(o.getVersion() + (o.isServerImage() ? "server" : "desktop"));
+ }
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,601 +1,601 @@
-/*******************************************************************************
- * Copyright (c) 2009 INdT, (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:
- * Raul Herbster (INdT) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.api.vm.vmware;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.CookieHandler;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.text.DecimalFormat;
-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.Path;
-import org.eclipse.core.runtime.Status;
-import org.maemo.esbox.internal.vm.vmware.Activator;
-import org.maemo.mica.common.core.MicaException;
-import org.maemo.mica.common.core.Policy;
-import org.maemo.mica.common.ui.dialogs.DialogUtils;
-import org.maemo.mica.internal.api.common.core.filesystem.FilesystemUtils;
-import org.maemo.mica.internal.api.common.core.http.connection.CopyProgressMonitor;
-import org.maemo.mica.internal.api.common.core.http.connection.DownloadingThread;
-import org.maemo.mica.internal.api.common.core.http.connection.SessionHandler;
-
-import com.nokia.cpp.internal.api.utils.core.Tuple;
-
-/**
- * @author raulherbster
- *
- */
-public class MaemoSDKVMDownloader {
-
- private MaemoSDKVMInfo downloadFile;
- private IProgressMonitor monitor;
-
- /**
- * Construtor.
- * @param downloadFile
- * @param monitor
- */
- protected MaemoSDKVMDownloader(MaemoSDKVMInfo downloadFile, IProgressMonitor monitor) {
- this.downloadFile = downloadFile;
- this.monitor = monitor;
- }
-
- /**
- * Get URL and size of remote file.
- * @param nPart the number of the part to get info, null if it not is a multipart file
- * @return URL and size of remote file.
- * @throws MicaException
- * @throws IOException
- */
- private Tuple getRemoteFileInfo(Integer nPart) throws MicaException, IOException {
- URL connectionURL = null;
- try {
- connectionURL = new URL(MaemoSDKVMInfo.DOWNLOAD_PAGE);
- } catch (MalformedURLException e1) {
- throw new MicaException("Cannot define URL for Maemo SDK virtual image");
- }
-
- monitor.subTask("Retrieving information from " + connectionURL.getHost());
-
- // Get the download page so links can be properly obtained
- String downloadPage = openDownloadPage();
- URL remoteURL;
- int fileSize = 0;
- try {
- remoteURL = getLinkFor(downloadPage, downloadFile.getDescriptor().getName());
-
- if (remoteURL == null) {
- throw new MicaException("Cannot locate ''" + downloadFile.getDescriptor().getName()
- + "'' on " + MaemoSDKVMInfo.DOWNLOAD_PAGE);
- }
-
- if(downloadFile.isMultipart() && nPart != null){
- String url = remoteURL.toExternalForm();
- int i = url.lastIndexOf('.');
- if(i != -1)
- url = url.substring(0,i);
- DecimalFormat df = new DecimalFormat( "000");
- String part = df.format(nPart);
- remoteURL = new URL(url + '.' + part);
- }
-
- HttpURLConnection conn = (HttpURLConnection) remoteURL.openConnection();
- fileSize = conn.getContentLength();
- } catch (MalformedURLException e) {
- throw new MicaException("Invalid file URL on " + MaemoSDKVMInfo.DOWNLOAD_PAGE, e);
- }
-
- return new Tuple(remoteURL, fileSize);
- }
-
- /**
- * Return the download page.
- *
- * @return the download page.
- */
- private String openDownloadPage() {
- String responsePage = null;
- HttpURLConnection connection = null;
-
- try {
- connection = connectWithPostMethod(new URL(
- MaemoSDKVMInfo.DOWNLOAD_PAGE));
- responsePage = getResponse(connection);
- if (responsePage == null) {
- throw new MicaException("Response page is empty"); //$NON-NLS-1$
- }
- } catch (Exception e) {
- Activator.getErrorLogger().logAndShowError(
- "Cannot connect with " + MaemoSDKVMInfo.DOWNLOAD_PAGE, e);
- return null;
- } finally {
-
- if (connection != null)
- connection.disconnect();
-
- }
- return responsePage;
- }
-
- /**
- * Connect with post method on download page.
- *
- * @param connectionUrl
- * @return
- * @throws MicaException
- */
- private HttpURLConnection connectWithPostMethod(URL connectionUrl) throws MicaException {
- // TODO refactor flasher on Mica so methods can be reused here.
- OutputStreamWriter out = null;
- HttpURLConnection conn = null;
- try {
- conn = (HttpURLConnection) connectionUrl.openConnection();
- conn.setRequestMethod("POST"); //$NON-NLS-1$
- conn.setDoOutput(true);
- conn.setDoInput(true);
- conn.setRequestProperty("Content-Type",
- "application/x-www-form-urlencoded");
- out = new OutputStreamWriter(conn.getOutputStream());
- out.write("agree=I accept");
- out.flush();
- return conn;
- } catch (MalformedURLException e) {
- throw new MicaException("Malformed URL", e); //$NON-NLS-1$
- } catch (IOException e) {
- throw new MicaException("Cannot connect to " + connectionUrl, e);
- } finally {
- Policy.close(out);
- }
- }
-
- /**
- *
- * @param conn
- * @return
- * @throws MicaException
- */
- private String getResponse(HttpURLConnection conn) throws MicaException {
- // TODO refactor flasher on Mica so methods can be reused here.
- if (conn == null) {
- throw new MicaException(new IllegalArgumentException(
- "Connection cannot be null"));
- }
- BufferedReader bufReader = null;
- try {
- bufReader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- } catch (Exception e) {
- throw new MicaException("Cannot get input from server", e);
- }
- StringBuffer buffer = new StringBuffer();
- if (bufReader != null) {
- String inputLine;
- try {
- while ((inputLine = bufReader.readLine()) != null) {
- buffer.append(inputLine);
- buffer.append("\n"); //$NON-NLS-1$
- }
- } catch (IOException e) {
- throw new MicaException("Cannot read data from server", e);
- }
- }
- if (buffer.length() > 0) {
- return buffer.toString();
- } else {
- return null;
- }
- }
-
-
-
- /**
- * Get the links for a certain download file. It the file consists of more
- * than 1 file, its parts will be properly obtained.
- *
- * @param htmlPage
- * @param downloadFileDescription
- * @return
- * @throws MalformedURLException
- */
- private URL getLinkFor(String htmlPage, String downloadFileDescription) throws MalformedURLException {
- final String DOWNLOAD_FILE_PATTERN = "<tr>\\s*<td class=\"filename\">(.*?)</td>\\s*</tr>";
- final String LINK_PATTERN = "<a href=\"(.*?)\">";
- Pattern fileEntryPattern = Pattern.compile(DOWNLOAD_FILE_PATTERN,
- Pattern.DOTALL | Pattern.UNIX_LINES);
- Matcher matcher = fileEntryPattern.matcher(htmlPage);
- while (matcher.find()) {
- String fileInfo = matcher.group(0);
- if (fileInfo.contains(downloadFileDescription)) {
- Pattern hrefPattern = Pattern.compile(LINK_PATTERN,
- Pattern.DOTALL | Pattern.UNIX_LINES);
- Matcher matcherLink = hrefPattern.matcher(fileInfo);
- if (matcherLink.find()) {
- String link = matcherLink.group(1);
- return (new URL(MaemoSDKVMInfo.DOWNLOAD_PAGE
- + (link.contains("?")?link.substring(link.indexOf("?")): link)));
- }
- }
-
- }
- return null;
- }
-
-
- /**
- * Get local file to download file
- *
- * @param remoteURL
- * @param installLocation
- * @return the name of file to be saved locally
- */
- private File getLocalFile(URL remoteURL, URL installLocation) {
- String fileName = (new Path(remoteURL.getFile())).lastSegment();
- fileName = fileName.substring(fileName.lastIndexOf("=") + 1);
- return new File ((new Path(installLocation.getFile())).append(fileName).toOSString());
- }
-
- /**
- * Get the size of previously downloaded file.
- * @param localFileName
- * @return
- */
- private long getPreviousDownloadSize(File localFile) {
- if (localFile.exists()) {
- boolean canResumeDownload = DialogUtils.showQuestionDialog(DialogUtils.getShell(),
- "Previous download file founded", "The file " + localFile + " already exists. Would you like to resume download?");
- if (canResumeDownload) {
- return localFile.length();
- } else {
- localFile.delete();
- return 0L;
- }
- }
- return 0L;
- }
-
- /**
- * Download a Maemo SDK virtual image.
- * @return the status reported from this operation.
- * @throws IOException
- * @throws MicaException
- */
- private IStatus fileDownloader() throws IOException, MicaException {
- // Check if file was downloaded before
- monitor.subTask("Checking information about file to be downloaded ...");
-
- if(downloadFile.isMultipart()){
- //download multipar file
- return downloadMultiple();
- }else{
- //download single file
- return downloadSingle();
- }
- }
-
- protected IStatus downloadMultiple() throws MicaException, IOException {
-
- for(int nPart = 1; nPart <= downloadFile.getNumParts(); nPart++){
- Tuple remoteFileInfo = getRemoteFileInfo(nPart);
- URL remoteURL = (URL) remoteFileInfo.get(0);
-
- // Get link of remote file
- File localFile = getLocalFile(remoteURL, downloadFile.getInstallLocation());
- if(nPart ==1)
- downloadFile.setFileName(localFile.getName());
-
- downloadFile.setDownloadedSize(getPreviousDownloadSize(localFile));
- Integer remoteFileSize = (Integer) remoteFileInfo.get(1);;
-
- if (downloadFile.getDownloadedSize() == remoteFileSize.intValue()){
-
- if(nPart == downloadFile.getNumParts()){
- downloadFile.complete();
- return Activator.createStatus(Status.OK, "Maemo SDK virtual image is already downloaded.");
- }else
- continue; //check next part
- }
-
- HttpURLConnection connection = null;
- RandomFileOutputStream out = null;
- InputStream in = null;
-
- try {
-
- // Open connection to URL.
- monitor.subTask("Establishing connection with " + remoteURL.getHost());
- connection = (HttpURLConnection) remoteURL.openConnection();
-
- // Specify what portion of file to download
- connection.setRequestProperty("Range", "bytes=" + downloadFile.getDownloadedSize() + "-");
-
- // Connect to server
- connection.connect();
- monitor.subTask("Connected with " + remoteURL.getHost());
-
- IStatus connectionStatus = validateConnection(connection);
- if (!connectionStatus.isOK()) {
- cancelDownload(downloadFile,monitor);
- return errorStatus(connectionStatus.getMessage());
- }
-
- int contentLength = connection.getContentLength();
- if (!haveEnoughtFreeSpace(contentLength/1024, localFile)) {
- cancelDownload(downloadFile, monitor);
- return errorStatus("There is not enought space to save Maemo SDK virtual machine in your computer.");
- }
-
- // set the size for this download if it hasn't been already set.
- if (downloadFile.getSize() == -1) {
- downloadFile.setSize(contentLength);
- }
-
- CopyProgressMonitor progressMonitor = new CopyProgressMonitor(
- "Downloading Maemo SDK virtual image", remoteFileSize, monitor);
- progressMonitor.setExistingSize(downloadFile.getDownloadedSize());
- progressMonitor.start();
-
- out = new RandomFileOutputStream(localFile,true);
- out.setFilePointer(downloadFile.getDownloadedSize());
- in = connection.getInputStream();
-
- // create and start to download
- monitor.beginTask(remoteURL.getFile(), remoteFileSize != 0 ? remoteFileSize : IProgressMonitor.UNKNOWN);
- monitor.worked((int)downloadFile.getDownloadedSize());
-
- int bufferSize = 64*1024;//64KB
- DownloadingThread thread = new DownloadingThread(in, out,bufferSize , progressMonitor, monitor);
- thread.start();
-
- while (!thread.isInterrupted() && thread.isAlive() ) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- continue;
- }
-
- if (monitor.isCanceled()) {
- thread.stopDownloading();
- downloadFile.cancel();
- return Status.CANCEL_STATUS;
- }
-
- if(downloadFile.getStatus() == MaemoSDKVMInfo.Status.PAUSED){
- thread.doPause();
- }
-
- if(downloadFile.getStatus() == MaemoSDKVMInfo.Status.DOWNLOADING){
- if(thread.isPaused()) thread.doResume();
- }
- }
-
- if (thread.isCompleted() && nPart == downloadFile.getNumParts()) {
- downloadFile.complete();
- }
-
- if (thread.getErrorMessage() != null) {
- downloadFile.error();
- throw new IOException(thread.getErrorMessage());
- }
- } finally {
-
- // Close connection to server.
- if (in != null) {
- in.close();
- }
-
- if (connection != null)
- connection.disconnect();
- }
- }
- return Status.OK_STATUS;
- }
-
- protected IStatus downloadSingle() throws MicaException, IOException {
- Tuple remoteFileInfo = getRemoteFileInfo(null);
- URL remoteURL = (URL) remoteFileInfo.get(0);
-
- // Get link of remote file
- File localFile = getLocalFile(remoteURL, downloadFile.getInstallLocation());
- downloadFile.setFileName(localFile.getName());
-
- downloadFile.setDownloadedSize(getPreviousDownloadSize(localFile));
- Integer remoteFileSize = (Integer) remoteFileInfo.get(1);
-
- if (downloadFile.getDownloadedSize() == remoteFileSize.intValue()){
- downloadFile.complete();
- return Activator.createStatus(Status.OK,
- "Maemo SDK virtual image is already downloaded.");
- }
-
- HttpURLConnection connection = null;
- RandomFileOutputStream out = null;
- InputStream in = null;
-
- try {
-
- // Open connection to URL.
- monitor.subTask("Establishing connection with "
- + remoteURL.getHost());
- connection = (HttpURLConnection) remoteURL.openConnection();
-
- // Specify what portion of file to download
- connection.setRequestProperty("Range", "bytes="
- + downloadFile.getDownloadedSize() + "-");
-
- // Connect to server
- connection.connect();
- monitor.subTask("Connected with " + remoteURL.getHost());
-
- IStatus connectionStatus = validateConnection(connection);
- if (!connectionStatus.isOK()) {
- cancelDownload(downloadFile, monitor);
- return errorStatus(connectionStatus.getMessage());
- }
-
- int contentLength = connection.getContentLength();
- if (!haveEnoughtFreeSpace(contentLength / 1024, localFile)) {
- cancelDownload(downloadFile, monitor);
- return errorStatus("There is not enought space to save Maemo SDK virtual machine in your computer.");
- }
-
- // set the size for this download if it hasn't been already set.
- if (downloadFile.getSize() == -1) {
- downloadFile.setSize(contentLength);
- }
-
- CopyProgressMonitor progressMonitor = new CopyProgressMonitor(
- "Downloading Maemo SDK virtual image", remoteFileSize,
- monitor);
- progressMonitor.setExistingSize(downloadFile.getDownloadedSize());
- progressMonitor.start();
-
- out = new RandomFileOutputStream(localFile, true);
- out.setFilePointer(downloadFile.getDownloadedSize());
- in = connection.getInputStream();
-
- // create and start to download
- monitor.beginTask(remoteURL.getFile(),
- remoteFileSize != 0 ? remoteFileSize
- : IProgressMonitor.UNKNOWN);
- monitor.worked((int) downloadFile.getDownloadedSize());
-
- int bufferSize = 64 * 1024;// 64KB
- DownloadingThread thread = new DownloadingThread(in, out,
- bufferSize, progressMonitor, monitor);
- thread.start();
-
- while (!thread.isInterrupted() && thread.isAlive()) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- continue;
- }
-
- if (monitor.isCanceled()) {
- thread.stopDownloading();
- downloadFile.cancel();
- return Status.CANCEL_STATUS;
- }
-
- if (downloadFile.getStatus() == MaemoSDKVMInfo.Status.PAUSED) {
- thread.doPause();
- }
-
- if (downloadFile.getStatus() == MaemoSDKVMInfo.Status.DOWNLOADING) {
- thread.doResume();
- }
- }
-
- if (thread.isCompleted()) {
- downloadFile.complete();
- }
-
- if (thread.getErrorMessage() != null) {
- downloadFile.error();
- throw new IOException(thread.getErrorMessage());
- }
- } finally {
-
- // Close connection to server.
- if (in != null) {
- in.close();
- }
-
- if (connection != null)
- connection.disconnect();
- }
- return Status.OK_STATUS;
- }
-
- /**
- * Creates an error status based with the given message.
- * @param message
- * @return
- */
- private static IStatus errorStatus(String message) {
- return Activator.createStatus(IStatus.ERROR, message);
- }
-
- /**
- * Cancel download.
- * @param fileDownload
- * @param monitor
- */
- private static void cancelDownload(MaemoSDKVMInfo fileDownload, IProgressMonitor monitor) {
- fileDownload.error();
- monitor.setCanceled(true);
- monitor.done();
- }
-
- /**
- * Check if there is enough space to uncompress the Maemo SDK virtual image.
- * @param fileSize the size of file (in Kbytes)
- * @param localURL the destination path to uncompress the Maemo SDK virtual image.
- * @return boolean if there is enough space to uncompress the Maemo SDK virtual image (if the free space
- * available on disk is bigger than the size of uncompressed Maemo SDK virtual image); false, otherwise.
- */
- private static boolean haveEnoughtFreeSpace(int fileSize, File localFile) throws IOException {
- long freeSpace = FilesystemUtils.freeSpaceOS(new Path(localFile.getAbsolutePath()),true);
- return freeSpace > fileSize;
- }
-
- /**
- * Validate the http connection.
- * @param connection the connection to be validated.
- * @return an IStatus as result.
- * @throws IOException
- */
- private static IStatus validateConnection(HttpURLConnection connection) throws IOException {
- // Make sure response code is in the 200 range
- if (connection.getResponseCode() / 100 != 2) {
- return errorStatus("Invalid response from connection.");
- }
-
- // Check for valid content length
- if (connection.getContentLength() < 1) {
- return errorStatus("Invalid content length.");
- }
-
- return Status.OK_STATUS;
- }
-
- /**
- * Download the Maemo SDK virtual image.
- * @param downloadFile the file to be downloaded.
- * @param progressMonitor the progress monitor.
- * @return the status as result of installation process.
- * @throws MicaException
- */
- public IStatus downloadMaemoSDKImageTool() throws MicaException {
- try {
- CookieHandler.setDefault(new SessionHandler());
-
- try {
- return fileDownloader();
- } catch (IOException e) {
- throw new MicaException("Cannot download Maemo SDK virtual image", e);
- }
-
- } finally {
- CookieHandler.setDefault(null);
- }
-
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 INdT, (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:
+ * Raul Herbster (INdT) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.api.vm.vmware;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.CookieHandler;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.DecimalFormat;
+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.Path;
+import org.eclipse.core.runtime.Status;
+import org.maemo.esbox.internal.vm.vmware.Activator;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.Policy;
+import org.maemo.mica.common.ui.dialogs.DialogUtils;
+import org.maemo.mica.internal.api.common.core.filesystem.FilesystemUtils;
+import org.maemo.mica.internal.api.common.core.http.connection.CopyProgressMonitor;
+import org.maemo.mica.internal.api.common.core.http.connection.DownloadingThread;
+import org.maemo.mica.internal.api.common.core.http.connection.SessionHandler;
+
+import com.nokia.cpp.internal.api.utils.core.Tuple;
+
+/**
+ * @author raulherbster
+ *
+ */
+public class MaemoSDKVMDownloader {
+
+ private MaemoSDKVMInfo downloadFile;
+ private IProgressMonitor monitor;
+
+ /**
+ * Construtor.
+ * @param downloadFile
+ * @param monitor
+ */
+ protected MaemoSDKVMDownloader(MaemoSDKVMInfo downloadFile, IProgressMonitor monitor) {
+ this.downloadFile = downloadFile;
+ this.monitor = monitor;
+ }
+
+ /**
+ * Get URL and size of remote file.
+ * @param nPart the number of the part to get info, null if it not is a multipart file
+ * @return URL and size of remote file.
+ * @throws MicaException
+ * @throws IOException
+ */
+ private Tuple getRemoteFileInfo(Integer nPart) throws MicaException, IOException {
+ URL connectionURL = null;
+ try {
+ connectionURL = new URL(MaemoSDKVMInfo.DOWNLOAD_PAGE);
+ } catch (MalformedURLException e1) {
+ throw new MicaException("Cannot define URL for Maemo SDK virtual image");
+ }
+
+ monitor.subTask("Retrieving information from " + connectionURL.getHost());
+
+ // Get the download page so links can be properly obtained
+ String downloadPage = openDownloadPage();
+ URL remoteURL;
+ int fileSize = 0;
+ try {
+ remoteURL = getLinkFor(downloadPage, downloadFile.getDescriptor().getName());
+
+ if (remoteURL == null) {
+ throw new MicaException("Cannot locate ''" + downloadFile.getDescriptor().getName()
+ + "'' on " + MaemoSDKVMInfo.DOWNLOAD_PAGE);
+ }
+
+ if(downloadFile.isMultipart() && nPart != null){
+ String url = remoteURL.toExternalForm();
+ int i = url.lastIndexOf('.');
+ if(i != -1)
+ url = url.substring(0,i);
+ DecimalFormat df = new DecimalFormat( "000");
+ String part = df.format(nPart);
+ remoteURL = new URL(url + '.' + part);
+ }
+
+ HttpURLConnection conn = (HttpURLConnection) remoteURL.openConnection();
+ fileSize = conn.getContentLength();
+ } catch (MalformedURLException e) {
+ throw new MicaException("Invalid file URL on " + MaemoSDKVMInfo.DOWNLOAD_PAGE, e);
+ }
+
+ return new Tuple(remoteURL, fileSize);
+ }
+
+ /**
+ * Return the download page.
+ *
+ * @return the download page.
+ */
+ private String openDownloadPage() {
+ String responsePage = null;
+ HttpURLConnection connection = null;
+
+ try {
+ connection = connectWithPostMethod(new URL(
+ MaemoSDKVMInfo.DOWNLOAD_PAGE));
+ responsePage = getResponse(connection);
+ if (responsePage == null) {
+ throw new MicaException("Response page is empty"); //$NON-NLS-1$
+ }
+ } catch (Exception e) {
+ Activator.getErrorLogger().logAndShowError(
+ "Cannot connect with " + MaemoSDKVMInfo.DOWNLOAD_PAGE, e);
+ return null;
+ } finally {
+
+ if (connection != null)
+ connection.disconnect();
+
+ }
+ return responsePage;
+ }
+
+ /**
+ * Connect with post method on download page.
+ *
+ * @param connectionUrl
+ * @return
+ * @throws MicaException
+ */
+ private HttpURLConnection connectWithPostMethod(URL connectionUrl) throws MicaException {
+ // TODO refactor flasher on Mica so methods can be reused here.
+ OutputStreamWriter out = null;
+ HttpURLConnection conn = null;
+ try {
+ conn = (HttpURLConnection) connectionUrl.openConnection();
+ conn.setRequestMethod("POST"); //$NON-NLS-1$
+ conn.setDoOutput(true);
+ conn.setDoInput(true);
+ conn.setRequestProperty("Content-Type",
+ "application/x-www-form-urlencoded");
+ out = new OutputStreamWriter(conn.getOutputStream());
+ out.write("agree=I accept");
+ out.flush();
+ return conn;
+ } catch (MalformedURLException e) {
+ throw new MicaException("Malformed URL", e); //$NON-NLS-1$
+ } catch (IOException e) {
+ throw new MicaException("Cannot connect to " + connectionUrl, e);
+ } finally {
+ Policy.close(out);
+ }
+ }
+
+ /**
+ *
+ * @param conn
+ * @return
+ * @throws MicaException
+ */
+ private String getResponse(HttpURLConnection conn) throws MicaException {
+ // TODO refactor flasher on Mica so methods can be reused here.
+ if (conn == null) {
+ throw new MicaException(new IllegalArgumentException(
+ "Connection cannot be null"));
+ }
+ BufferedReader bufReader = null;
+ try {
+ bufReader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+ } catch (Exception e) {
+ throw new MicaException("Cannot get input from server", e);
+ }
+ StringBuffer buffer = new StringBuffer();
+ if (bufReader != null) {
+ String inputLine;
+ try {
+ while ((inputLine = bufReader.readLine()) != null) {
+ buffer.append(inputLine);
+ buffer.append("\n"); //$NON-NLS-1$
+ }
+ } catch (IOException e) {
+ throw new MicaException("Cannot read data from server", e);
+ }
+ }
+ if (buffer.length() > 0) {
+ return buffer.toString();
+ } else {
+ return null;
+ }
+ }
+
+
+
+ /**
+ * Get the links for a certain download file. It the file consists of more
+ * than 1 file, its parts will be properly obtained.
+ *
+ * @param htmlPage
+ * @param downloadFileDescription
+ * @return
+ * @throws MalformedURLException
+ */
+ private URL getLinkFor(String htmlPage, String downloadFileDescription) throws MalformedURLException {
+ final String DOWNLOAD_FILE_PATTERN = "<tr>\\s*<td class=\"filename\">(.*?)</td>\\s*</tr>";
+ final String LINK_PATTERN = "<a href=\"(.*?)\">";
+ Pattern fileEntryPattern = Pattern.compile(DOWNLOAD_FILE_PATTERN,
+ Pattern.DOTALL | Pattern.UNIX_LINES);
+ Matcher matcher = fileEntryPattern.matcher(htmlPage);
+ while (matcher.find()) {
+ String fileInfo = matcher.group(0);
+ if (fileInfo.contains(downloadFileDescription)) {
+ Pattern hrefPattern = Pattern.compile(LINK_PATTERN,
+ Pattern.DOTALL | Pattern.UNIX_LINES);
+ Matcher matcherLink = hrefPattern.matcher(fileInfo);
+ if (matcherLink.find()) {
+ String link = matcherLink.group(1);
+ return (new URL(MaemoSDKVMInfo.DOWNLOAD_PAGE
+ + (link.contains("?")?link.substring(link.indexOf("?")): link)));
+ }
+ }
+
+ }
+ return null;
+ }
+
+
+ /**
+ * Get local file to download file
+ *
+ * @param remoteURL
+ * @param installLocation
+ * @return the name of file to be saved locally
+ */
+ private File getLocalFile(URL remoteURL, URL installLocation) {
+ String fileName = (new Path(remoteURL.getFile())).lastSegment();
+ fileName = fileName.substring(fileName.lastIndexOf("=") + 1);
+ return new File ((new Path(installLocation.getFile())).append(fileName).toOSString());
+ }
+
+ /**
+ * Get the size of previously downloaded file.
+ * @param localFileName
+ * @return
+ */
+ private long getPreviousDownloadSize(File localFile) {
+ if (localFile.exists()) {
+ boolean canResumeDownload = DialogUtils.showQuestionDialog(DialogUtils.getShell(),
+ "Previous download file founded", "The file " + localFile + " already exists. Would you like to resume download?");
+ if (canResumeDownload) {
+ return localFile.length();
+ } else {
+ localFile.delete();
+ return 0L;
+ }
+ }
+ return 0L;
+ }
+
+ /**
+ * Download a Maemo SDK virtual image.
+ * @return the status reported from this operation.
+ * @throws IOException
+ * @throws MicaException
+ */
+ private IStatus fileDownloader() throws IOException, MicaException {
+ // Check if file was downloaded before
+ monitor.subTask("Checking information about file to be downloaded ...");
+
+ if(downloadFile.isMultipart()){
+ //download multipar file
+ return downloadMultiple();
+ }else{
+ //download single file
+ return downloadSingle();
+ }
+ }
+
+ protected IStatus downloadMultiple() throws MicaException, IOException {
+
+ for(int nPart = 1; nPart <= downloadFile.getNumParts(); nPart++){
+ Tuple remoteFileInfo = getRemoteFileInfo(nPart);
+ URL remoteURL = (URL) remoteFileInfo.get(0);
+
+ // Get link of remote file
+ File localFile = getLocalFile(remoteURL, downloadFile.getInstallLocation());
+ if(nPart ==1)
+ downloadFile.setFileName(localFile.getName());
+
+ downloadFile.setDownloadedSize(getPreviousDownloadSize(localFile));
+ Integer remoteFileSize = (Integer) remoteFileInfo.get(1);;
+
+ if (downloadFile.getDownloadedSize() == remoteFileSize.intValue()){
+
+ if(nPart == downloadFile.getNumParts()){
+ downloadFile.complete();
+ return Activator.createStatus(Status.OK, "Maemo SDK virtual image is already downloaded.");
+ }else
+ continue; //check next part
+ }
+
+ HttpURLConnection connection = null;
+ RandomFileOutputStream out = null;
+ InputStream in = null;
+
+ try {
+
+ // Open connection to URL.
+ monitor.subTask("Establishing connection with " + remoteURL.getHost());
+ connection = (HttpURLConnection) remoteURL.openConnection();
+
+ // Specify what portion of file to download
+ connection.setRequestProperty("Range", "bytes=" + downloadFile.getDownloadedSize() + "-");
+
+ // Connect to server
+ connection.connect();
+ monitor.subTask("Connected with " + remoteURL.getHost());
+
+ IStatus connectionStatus = validateConnection(connection);
+ if (!connectionStatus.isOK()) {
+ cancelDownload(downloadFile,monitor);
+ return errorStatus(connectionStatus.getMessage());
+ }
+
+ int contentLength = connection.getContentLength();
+ if (!haveEnoughtFreeSpace(contentLength/1024, localFile)) {
+ cancelDownload(downloadFile, monitor);
+ return errorStatus("There is not enought space to save Maemo SDK virtual machine in your computer.");
+ }
+
+ // set the size for this download if it hasn't been already set.
+ if (downloadFile.getSize() == -1) {
+ downloadFile.setSize(contentLength);
+ }
+
+ CopyProgressMonitor progressMonitor = new CopyProgressMonitor(
+ "Downloading Maemo SDK virtual image", remoteFileSize, monitor);
+ progressMonitor.setExistingSize(downloadFile.getDownloadedSize());
+ progressMonitor.start();
+
+ out = new RandomFileOutputStream(localFile,true);
+ out.setFilePointer(downloadFile.getDownloadedSize());
+ in = connection.getInputStream();
+
+ // create and start to download
+ monitor.beginTask(remoteURL.getFile(), remoteFileSize != 0 ? remoteFileSize : IProgressMonitor.UNKNOWN);
+ monitor.worked((int)downloadFile.getDownloadedSize());
+
+ int bufferSize = 64*1024;//64KB
+ DownloadingThread thread = new DownloadingThread(in, out,bufferSize , progressMonitor, monitor);
+ thread.start();
+
+ while (!thread.isInterrupted() && thread.isAlive() ) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ continue;
+ }
+
+ if (monitor.isCanceled()) {
+ thread.stopDownloading();
+ downloadFile.cancel();
+ return Status.CANCEL_STATUS;
+ }
+
+ if(downloadFile.getStatus() == MaemoSDKVMInfo.Status.PAUSED){
+ thread.doPause();
+ }
+
+ if(downloadFile.getStatus() == MaemoSDKVMInfo.Status.DOWNLOADING){
+ if(thread.isPaused()) thread.doResume();
+ }
+ }
+
+ if (thread.isCompleted() && nPart == downloadFile.getNumParts()) {
+ downloadFile.complete();
+ }
+
+ if (thread.getErrorMessage() != null) {
+ downloadFile.error();
+ throw new IOException(thread.getErrorMessage());
+ }
+ } finally {
+
+ // Close connection to server.
+ if (in != null) {
+ in.close();
+ }
+
+ if (connection != null)
+ connection.disconnect();
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+ protected IStatus downloadSingle() throws MicaException, IOException {
+ Tuple remoteFileInfo = getRemoteFileInfo(null);
+ URL remoteURL = (URL) remoteFileInfo.get(0);
+
+ // Get link of remote file
+ File localFile = getLocalFile(remoteURL, downloadFile.getInstallLocation());
+ downloadFile.setFileName(localFile.getName());
+
+ downloadFile.setDownloadedSize(getPreviousDownloadSize(localFile));
+ Integer remoteFileSize = (Integer) remoteFileInfo.get(1);
+
+ if (downloadFile.getDownloadedSize() == remoteFileSize.intValue()){
+ downloadFile.complete();
+ return Activator.createStatus(Status.OK,
+ "Maemo SDK virtual image is already downloaded.");
+ }
+
+ HttpURLConnection connection = null;
+ RandomFileOutputStream out = null;
+ InputStream in = null;
+
+ try {
+
+ // Open connection to URL.
+ monitor.subTask("Establishing connection with "
+ + remoteURL.getHost());
+ connection = (HttpURLConnection) remoteURL.openConnection();
+
+ // Specify what portion of file to download
+ connection.setRequestProperty("Range", "bytes="
+ + downloadFile.getDownloadedSize() + "-");
+
+ // Connect to server
+ connection.connect();
+ monitor.subTask("Connected with " + remoteURL.getHost());
+
+ IStatus connectionStatus = validateConnection(connection);
+ if (!connectionStatus.isOK()) {
+ cancelDownload(downloadFile, monitor);
+ return errorStatus(connectionStatus.getMessage());
+ }
+
+ int contentLength = connection.getContentLength();
+ if (!haveEnoughtFreeSpace(contentLength / 1024, localFile)) {
+ cancelDownload(downloadFile, monitor);
+ return errorStatus("There is not enought space to save Maemo SDK virtual machine in your computer.");
+ }
+
+ // set the size for this download if it hasn't been already set.
+ if (downloadFile.getSize() == -1) {
+ downloadFile.setSize(contentLength);
+ }
+
+ CopyProgressMonitor progressMonitor = new CopyProgressMonitor(
+ "Downloading Maemo SDK virtual image", remoteFileSize,
+ monitor);
+ progressMonitor.setExistingSize(downloadFile.getDownloadedSize());
+ progressMonitor.start();
+
+ out = new RandomFileOutputStream(localFile, true);
+ out.setFilePointer(downloadFile.getDownloadedSize());
+ in = connection.getInputStream();
+
+ // create and start to download
+ monitor.beginTask(remoteURL.getFile(),
+ remoteFileSize != 0 ? remoteFileSize
+ : IProgressMonitor.UNKNOWN);
+ monitor.worked((int) downloadFile.getDownloadedSize());
+
+ int bufferSize = 64 * 1024;// 64KB
+ DownloadingThread thread = new DownloadingThread(in, out,
+ bufferSize, progressMonitor, monitor);
+ thread.start();
+
+ while (!thread.isInterrupted() && thread.isAlive()) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ continue;
+ }
+
+ if (monitor.isCanceled()) {
+ thread.stopDownloading();
+ downloadFile.cancel();
+ return Status.CANCEL_STATUS;
+ }
+
+ if (downloadFile.getStatus() == MaemoSDKVMInfo.Status.PAUSED) {
+ thread.doPause();
+ }
+
+ if (downloadFile.getStatus() == MaemoSDKVMInfo.Status.DOWNLOADING) {
+ thread.doResume();
+ }
+ }
+
+ if (thread.isCompleted()) {
+ downloadFile.complete();
+ }
+
+ if (thread.getErrorMessage() != null) {
+ downloadFile.error();
+ throw new IOException(thread.getErrorMessage());
+ }
+ } finally {
+
+ // Close connection to server.
+ if (in != null) {
+ in.close();
+ }
+
+ if (connection != null)
+ connection.disconnect();
+ }
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * Creates an error status based with the given message.
+ * @param message
+ * @return
+ */
+ private static IStatus errorStatus(String message) {
+ return Activator.createStatus(IStatus.ERROR, message);
+ }
+
+ /**
+ * Cancel download.
+ * @param fileDownload
+ * @param monitor
+ */
+ private static void cancelDownload(MaemoSDKVMInfo fileDownload, IProgressMonitor monitor) {
+ fileDownload.error();
+ monitor.setCanceled(true);
+ monitor.done();
+ }
+
+ /**
+ * Check if there is enough space to uncompress the Maemo SDK virtual image.
+ * @param fileSize the size of file (in Kbytes)
+ * @param localURL the destination path to uncompress the Maemo SDK virtual image.
+ * @return boolean if there is enough space to uncompress the Maemo SDK virtual image (if the free space
+ * available on disk is bigger than the size of uncompressed Maemo SDK virtual image); false, otherwise.
+ */
+ private static boolean haveEnoughtFreeSpace(int fileSize, File localFile) throws IOException {
+ long freeSpace = FilesystemUtils.freeSpaceOS(new Path(localFile.getAbsolutePath()),true);
+ return freeSpace > fileSize;
+ }
+
+ /**
+ * Validate the http connection.
+ * @param connection the connection to be validated.
+ * @return an IStatus as result.
+ * @throws IOException
+ */
+ private static IStatus validateConnection(HttpURLConnection connection) throws IOException {
+ // Make sure response code is in the 200 range
+ if (connection.getResponseCode() / 100 != 2) {
+ return errorStatus("Invalid response from connection.");
+ }
+
+ // Check for valid content length
+ if (connection.getContentLength() < 1) {
+ return errorStatus("Invalid content length.");
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * Download the Maemo SDK virtual image.
+ * @param downloadFile the file to be downloaded.
+ * @param progressMonitor the progress monitor.
+ * @return the status as result of installation process.
+ * @throws MicaException
+ */
+ public IStatus downloadMaemoSDKImageTool() throws MicaException {
+ try {
+ CookieHandler.setDefault(new SessionHandler());
+
+ try {
+ return fileDownloader();
+ } catch (IOException e) {
+ throw new MicaException("Cannot download Maemo SDK virtual image", e);
+ }
+
+ } finally {
+ CookieHandler.setDefault(null);
+ }
+
+ }
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/RandomFileOutputStream.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/RandomFileOutputStream.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/RandomFileOutputStream.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,171 +1,171 @@
-/*******************************************************************************
- * Copyright (c) 2009 INdT, (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:
- * Raul Herbster (INdT) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.api.vm.vmware;
-
-/**
- * Class that combines a RandonAccessFile and an OutputStream
- * so it can be used by other methods to download the file.
- * @author raulherbster
- *
- */
-import java.io.*;
-
-public class RandomFileOutputStream extends OutputStream {
-
- protected RandomAccessFile randomFile;
- protected boolean sync;
-
- /**
- * Constructor.
- * @param fileName the name of file
- * @throws IOException
- */
- public RandomFileOutputStream(String fileName) throws IOException {
- this(fileName, false);
- }
-
- /**
- * Constructor.
- * @param fileName the name of file
- * @param syn
- * @throws IOException
- */
- public RandomFileOutputStream(String fileName, boolean syn) throws IOException {
- this(new File(fileName), syn);
- }
-
- /**
- * Constructor.
- * @param fileName the name of file
- * @throws IOException
- */
- public RandomFileOutputStream(File fileName) throws IOException {
- this(fileName, false);
- }
-
- /**
- * Constructor.
- * @param fileName the name of file
- * @param syn
- * @throws IOException
- */
- public RandomFileOutputStream(File fileName, boolean syn) throws IOException {
- super();
-
- fileName = fileName.getAbsoluteFile();
-
- File par; // parent file
-
- if ((par = fileName.getParentFile()) != null) {
- par.mkdir();
- }
-
- randomFile = new RandomAccessFile(fileName, "rw");
- sync = syn;
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.OutputStream#write(int)
- */
- public void write(int val) throws IOException {
- randomFile.write(val);
- if (sync) {
- randomFile.getFD().sync();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.OutputStream#write(byte[])
- */
- public void write(byte[] val) throws IOException {
- randomFile.write(val);
- if (sync) {
- randomFile.getFD().sync();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- public void write(byte[] val, int off, int len) throws IOException {
- randomFile.write(val, off, len);
- if (sync) {
- randomFile.getFD().sync();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.OutputStream#flush()
- */
- public void flush() throws IOException {
- if (sync) {
- randomFile.getFD().sync();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.OutputStream#close()
- */
- public void close() throws IOException {
- randomFile.close();
- }
-
- /**
- * Get the position of file pointer.
- * @return the position of file pointer.
- * @throws IOException
- */
- public long getFilePointer() throws IOException {
- return randomFile.getFilePointer();
- }
-
- /**
- * Set the position of file pointer.
- * @param pos the position of file pointer.
- * @throws IOException
- */
- public void setFilePointer(long pos) throws IOException {
- randomFile.seek(pos);
- }
-
- /**
- * Get the size of this stream.
- * @return the size of this stream.
- * @throws IOException
- */
- public long getFileSize() throws IOException {
- return randomFile.length();
- }
-
- /**
- * Set the size of this stream.
- * @param len the new size of this stream
- * @throws IOException
- */
- public void setFileSize(long len) throws IOException {
- randomFile.setLength(len);
- }
-
- /**
- * Get the file descriptor of this stream.
- * @return the file descriptor of this stream.
- * @throws IOException
- */
- public FileDescriptor getFD() throws IOException {
- return randomFile.getFD();
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009 INdT, (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:
+ * Raul Herbster (INdT) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.api.vm.vmware;
+
+/**
+ * Class that combines a RandonAccessFile and an OutputStream
+ * so it can be used by other methods to download the file.
+ * @author raulherbster
+ *
+ */
+import java.io.*;
+
+public class RandomFileOutputStream extends OutputStream {
+
+ protected RandomAccessFile randomFile;
+ protected boolean sync;
+
+ /**
+ * Constructor.
+ * @param fileName the name of file
+ * @throws IOException
+ */
+ public RandomFileOutputStream(String fileName) throws IOException {
+ this(fileName, false);
+ }
+
+ /**
+ * Constructor.
+ * @param fileName the name of file
+ * @param syn
+ * @throws IOException
+ */
+ public RandomFileOutputStream(String fileName, boolean syn) throws IOException {
+ this(new File(fileName), syn);
+ }
+
+ /**
+ * Constructor.
+ * @param fileName the name of file
+ * @throws IOException
+ */
+ public RandomFileOutputStream(File fileName) throws IOException {
+ this(fileName, false);
+ }
+
+ /**
+ * Constructor.
+ * @param fileName the name of file
+ * @param syn
+ * @throws IOException
+ */
+ public RandomFileOutputStream(File fileName, boolean syn) throws IOException {
+ super();
+
+ fileName = fileName.getAbsoluteFile();
+
+ File par; // parent file
+
+ if ((par = fileName.getParentFile()) != null) {
+ par.mkdir();
+ }
+
+ randomFile = new RandomAccessFile(fileName, "rw");
+ sync = syn;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.OutputStream#write(int)
+ */
+ public void write(int val) throws IOException {
+ randomFile.write(val);
+ if (sync) {
+ randomFile.getFD().sync();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[])
+ */
+ public void write(byte[] val) throws IOException {
+ randomFile.write(val);
+ if (sync) {
+ randomFile.getFD().sync();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ public void write(byte[] val, int off, int len) throws IOException {
+ randomFile.write(val, off, len);
+ if (sync) {
+ randomFile.getFD().sync();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.OutputStream#flush()
+ */
+ public void flush() throws IOException {
+ if (sync) {
+ randomFile.getFD().sync();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.io.OutputStream#close()
+ */
+ public void close() throws IOException {
+ randomFile.close();
+ }
+
+ /**
+ * Get the position of file pointer.
+ * @return the position of file pointer.
+ * @throws IOException
+ */
+ public long getFilePointer() throws IOException {
+ return randomFile.getFilePointer();
+ }
+
+ /**
+ * Set the position of file pointer.
+ * @param pos the position of file pointer.
+ * @throws IOException
+ */
+ public void setFilePointer(long pos) throws IOException {
+ randomFile.seek(pos);
+ }
+
+ /**
+ * Get the size of this stream.
+ * @return the size of this stream.
+ * @throws IOException
+ */
+ public long getFileSize() throws IOException {
+ return randomFile.length();
+ }
+
+ /**
+ * Set the size of this stream.
+ * @param len the new size of this stream
+ * @throws IOException
+ */
+ public void setFileSize(long len) throws IOException {
+ randomFile.setLength(len);
+ }
+
+ /**
+ * Get the file descriptor of this stream.
+ * @return the file descriptor of this stream.
+ * @throws IOException
+ */
+ public FileDescriptor getFD() throws IOException {
+ return randomFile.getFD();
+ }
+
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/RandomFileOutputStream.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/Activator.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/Activator.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/Activator.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,175 +1,175 @@
-/*******************************************************************************
- * 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.vm.vmware;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.maemo.mica.common.core.ErrorLogger;
-import org.maemo.mica.common.core.MicaException;
-import org.maemo.mica.common.core.Policy;
-import org.osgi.framework.BundleContext;
-
-import java.io.*;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.maemo.esbox.vm.vmware";
-
- public static ImageDescriptor MAEMO_VM_WIZBAN_DESCRIPTOR = getImageDescriptor("./icons/full/wizban/virtual_machine_wiz.png");
- public static ImageDescriptor MAEMO_VM_DESCRIPTOR = getImageDescriptor("./icons/full/etool16/virtual_machine.png");
-
- public static final int BUFFER_SIZE = 4096; // 4 KB
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /**
- * @param object
- * @param e
- * @return
- */
- public static IStatus createErrorStatus(String msg, Throwable t) {
- return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
- }
-
- /**
- * @param warning
- * @param format
- * @param e
- * @return
- */
- public static IStatus createStatus(int severity, String msg,
- Throwable t) {
- return new Status(severity, PLUGIN_ID, msg, t);
- }
-
- /**
- * @param warning
- * @param string
- * @return
- */
- public static IStatus createStatus(int severity, String string) {
- return new Status(severity, PLUGIN_ID, string);
- }
-
- /**
- * Return the error logger instance of this plug-in.
- *
- * @return the error logger instance of this plug-in.
- */
- public static ErrorLogger getErrorLogger() {
- class CoreErrorLogger extends ErrorLogger {
-
- @Override
- public String getPluginID() {
- return PLUGIN_ID;
- }
- @Override
- public Plugin getPlugin() {
- return Activator.getDefault();
- }
-
- }
-
- return new CoreErrorLogger();
- }
-
- /**
- * Find a file relative to the plugin, either in a running
- * workspace or a standalone unit test (assumed to run relative
- * to a plugin)
- * @param path
- */
- public static InputStream getPluginRelativeInputStream(String path) throws IOException {
- if (getDefault() != null) {
- return FileLocator.openStream(getDefault().getBundle(), new Path(path), false);
- } else {
- return new FileInputStream("../" + path);
- }
- }
-
- /**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path.
- *
- * @param path the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path) {
- return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-
- /**
- * Read resource file
- *
- * @param resouce
- * file name
- * @return content of resource file
- * @throws MicaException
- */
- public static String readResourceFile(String resouce) throws MicaException {
- InputStream in = null;
- try {
- in = getPluginRelativeInputStream(resouce);
- StringBuffer buf = new StringBuffer();
- byte[] byteBuf = new byte[BUFFER_SIZE];
- for (int n; (n = in.read(byteBuf)) > 0;) {
- buf.append(new String(byteBuf, 0, n));
- }
- return buf.toString();
-
- } catch (IOException e) {
- throw new MicaException(e.getMessage(), e);
- } finally {
- Policy.close(in);
- }
- }
-
-
-}
+/*******************************************************************************
+ * 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.vm.vmware;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.maemo.mica.common.core.ErrorLogger;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.Policy;
+import org.osgi.framework.BundleContext;
+
+import java.io.*;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.maemo.esbox.vm.vmware";
+
+ public static ImageDescriptor MAEMO_VM_WIZBAN_DESCRIPTOR = getImageDescriptor("./icons/full/wizban/virtual_machine_wiz.png");
+ public static ImageDescriptor MAEMO_VM_DESCRIPTOR = getImageDescriptor("./icons/full/etool16/virtual_machine.png");
+
+ public static final int BUFFER_SIZE = 4096; // 4 KB
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * @param object
+ * @param e
+ * @return
+ */
+ public static IStatus createErrorStatus(String msg, Throwable t) {
+ return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
+ }
+
+ /**
+ * @param warning
+ * @param format
+ * @param e
+ * @return
+ */
+ public static IStatus createStatus(int severity, String msg,
+ Throwable t) {
+ return new Status(severity, PLUGIN_ID, msg, t);
+ }
+
+ /**
+ * @param warning
+ * @param string
+ * @return
+ */
+ public static IStatus createStatus(int severity, String string) {
+ return new Status(severity, PLUGIN_ID, string);
+ }
+
+ /**
+ * Return the error logger instance of this plug-in.
+ *
+ * @return the error logger instance of this plug-in.
+ */
+ public static ErrorLogger getErrorLogger() {
+ class CoreErrorLogger extends ErrorLogger {
+
+ @Override
+ public String getPluginID() {
+ return PLUGIN_ID;
+ }
+ @Override
+ public Plugin getPlugin() {
+ return Activator.getDefault();
+ }
+
+ }
+
+ return new CoreErrorLogger();
+ }
+
+ /**
+ * Find a file relative to the plugin, either in a running
+ * workspace or a standalone unit test (assumed to run relative
+ * to a plugin)
+ * @param path
+ */
+ public static InputStream getPluginRelativeInputStream(String path) throws IOException {
+ if (getDefault() != null) {
+ return FileLocator.openStream(getDefault().getBundle(), new Path(path), false);
+ } else {
+ return new FileInputStream("../" + path);
+ }
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ /**
+ * Read resource file
+ *
+ * @param resouce
+ * file name
+ * @return content of resource file
+ * @throws MicaException
+ */
+ public static String readResourceFile(String resouce) throws MicaException {
+ InputStream in = null;
+ try {
+ in = getPluginRelativeInputStream(resouce);
+ StringBuffer buf = new StringBuffer();
+ byte[] byteBuf = new byte[BUFFER_SIZE];
+ for (int n; (n = in.read(byteBuf)) > 0;) {
+ buf.append(new String(byteBuf, 0, n));
+ }
+ return buf.toString();
+
+ } catch (IOException e) {
+ throw new MicaException(e.getMessage(), e);
+ } finally {
+ Policy.close(in);
+ }
+ }
+
+
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/Activator.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareBuildMachineFactory.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareBuildMachineFactory.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareBuildMachineFactory.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,44 +1,44 @@
-/*******************************************************************************
- * Copyright (c) 2008-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.vm.vmware;
-
-import org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineConfiguration;
-import org.maemo.mica.common.core.machine.IBuildMachineFactory;
-import org.maemo.mica.internal.api.common.core.machine.IBuildMachineImpl;
-
-/**
- * This factory creates virtual build machines hosted on VMware.
- * We support only one such machine at a time, using preferences to store its settings.
- * @author eswartz
- *
- */
-public class VMwareBuildMachineFactory implements IBuildMachineFactory {
-
- public final static String NAME = "VMware Linux Build Machine";
- public VMwareBuildMachineFactory() {
- }
-
-
- /* (non-Javadoc)
- * @see org.maemo.mica.common.core.machine.IMachineFactory#createMachine(java.lang.String)
- */
- public synchronized IBuildMachineImpl[] getMachines() {
- // for now, one global VMware settings block
- IBuildMachineImpl machine = new VMwareMachine(NAME,
- new VMwareConfiguration(
- BaseVirtualMachineConfiguration.getChildSettings(
- BaseVirtualMachineConfiguration.getVMSettings(),
- "vmware")
- ));
- return new IBuildMachineImpl[] { machine };
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2008-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.vm.vmware;
+
+import org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineConfiguration;
+import org.maemo.mica.common.core.machine.IBuildMachineFactory;
+import org.maemo.mica.internal.api.common.core.machine.IBuildMachineImpl;
+
+/**
+ * This factory creates virtual build machines hosted on VMware.
+ * We support only one such machine at a time, using preferences to store its settings.
+ * @author eswartz
+ *
+ */
+public class VMwareBuildMachineFactory implements IBuildMachineFactory {
+
+ public final static String NAME = "VMware Linux Build Machine";
+ public VMwareBuildMachineFactory() {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.maemo.mica.common.core.machine.IMachineFactory#createMachine(java.lang.String)
+ */
+ public synchronized IBuildMachineImpl[] getMachines() {
+ // for now, one global VMware settings block
+ IBuildMachineImpl machine = new VMwareMachine(NAME,
+ new VMwareConfiguration(
+ BaseVirtualMachineConfiguration.getChildSettings(
+ BaseVirtualMachineConfiguration.getVMSettings(),
+ "vmware")
+ ));
+ return new IBuildMachineImpl[] { machine };
+ }
+
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareBuildMachineFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareConfiguration.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareConfiguration.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareConfiguration.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,118 +1,118 @@
-/*******************************************************************************
- * Copyright (c) 2008-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.vm.vmware;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineConfiguration;
-import org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineURIQueryDecoder;
-import org.maemo.esbox.internal.api.vm.core.URIQueryParser.IURIQueryDecoder;
-import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
-import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
-import org.maemo.mica.common.core.MicaException;
-import org.maemo.mica.common.core.filesystem.ISharedFilesystemProvider;
-
-import java.net.URI;
-
-/**
- * @author eswartz
- *
- */
-public class VMwareConfiguration extends BaseVirtualMachineConfiguration implements IVMwareConfiguration {
-
- protected VMwareConfiguration(IDialogSettings settings) {
- super(settings);
- }
-
- /**
- * @param settings
- * @param uri
- * @param sharedFilesystemProvider
- * @throws MicaException
- */
- public VMwareConfiguration(IDialogSettings settings,
- URI uri, ISharedFilesystemProvider sharedFilesystemProvider)
- throws MicaException {
- super(settings, uri, sharedFilesystemProvider);
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.core.BasePreferenceVirtualMachineConfiguration#initializeDefaults()
- */
- @Override
- protected void initializeDefaults() {
- super.initializeDefaults();
- initializeKeysForClass(VMwarePreferenceConstants.class);
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.core.BaseCustomVirtualMachineConfiguration#setupDefaults()
- */
- @Override
- protected void applySettingsFrom(IVirtualMachineConfiguration baseConfig) {
- super.applySettingsFrom(baseConfig);
- if (baseConfig instanceof IVMwareConfiguration) {
- applySettingsForKeysForClass(baseConfig, VMwarePreferenceConstants.class);
- }
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.core.BaseCustomVirtualMachineConfiguration#getURIQueryDecoder()
- */
- @Override
- protected IURIQueryDecoder getURIQueryDecoder() {
- return new BaseVirtualMachineURIQueryDecoder(this) {
- private static final String VMX_PATH = "vmxPath";
- private static final String COMMAND_LAUNCH_PATTERN = "commandLaunchPattern";
- private static final String EXECUTABLE = "executable";
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineURIQueryDecoder#decode(java.lang.String, java.lang.String)
- */
- @Override
- public boolean decode(String key, String value) {
- if (super.decode(key, value))
- return true;
-
- if (key.equals(VMX_PATH)) {
- getSettings().put(VMwarePreferenceConstants.VMWARE_VMX_PATH, value);
- } else if (key.equals(COMMAND_LAUNCH_PATTERN)) {
- getSettings().put(VMwarePreferenceConstants.VMWARE_LAUNCH_PATTERN, value);
- } else if (key.equals(EXECUTABLE)) {
- getSettings().put(VMwarePreferenceConstants.VMWARE_EXE_NAME, value);
- } else {
- return false;
- }
- return true;
- }
- };
- }
-
- public String getVmxPath() {
- return getPreference(VMwarePreferenceConstants.VMWARE_VMX_PATH);
- }
-
- public void setVmxPath(String vmx) {
- setPreference(VMwarePreferenceConstants.VMWARE_VMX_PATH, vmx);
- }
- public String getExecutable() {
- return getPreference(VMwarePreferenceConstants.VMWARE_EXE_NAME);
- }
- public void setExecutable(String exe) {
- setPreference(VMwarePreferenceConstants.VMWARE_EXE_NAME, exe);
- }
-
- public String getCommandLaunchPattern() {
- return getPreference(VMwarePreferenceConstants.VMWARE_LAUNCH_PATTERN);
- }
- public void setCommandLaunchPattern(String pattern) {
- setPreference(VMwarePreferenceConstants.VMWARE_LAUNCH_PATTERN, pattern);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2008-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.vm.vmware;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineConfiguration;
+import org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineURIQueryDecoder;
+import org.maemo.esbox.internal.api.vm.core.URIQueryParser.IURIQueryDecoder;
+import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
+import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.filesystem.ISharedFilesystemProvider;
+
+import java.net.URI;
+
+/**
+ * @author eswartz
+ *
+ */
+public class VMwareConfiguration extends BaseVirtualMachineConfiguration implements IVMwareConfiguration {
+
+ protected VMwareConfiguration(IDialogSettings settings) {
+ super(settings);
+ }
+
+ /**
+ * @param settings
+ * @param uri
+ * @param sharedFilesystemProvider
+ * @throws MicaException
+ */
+ public VMwareConfiguration(IDialogSettings settings,
+ URI uri, ISharedFilesystemProvider sharedFilesystemProvider)
+ throws MicaException {
+ super(settings, uri, sharedFilesystemProvider);
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.core.BasePreferenceVirtualMachineConfiguration#initializeDefaults()
+ */
+ @Override
+ protected void initializeDefaults() {
+ super.initializeDefaults();
+ initializeKeysForClass(VMwarePreferenceConstants.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.core.BaseCustomVirtualMachineConfiguration#setupDefaults()
+ */
+ @Override
+ protected void applySettingsFrom(IVirtualMachineConfiguration baseConfig) {
+ super.applySettingsFrom(baseConfig);
+ if (baseConfig instanceof IVMwareConfiguration) {
+ applySettingsForKeysForClass(baseConfig, VMwarePreferenceConstants.class);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.core.BaseCustomVirtualMachineConfiguration#getURIQueryDecoder()
+ */
+ @Override
+ protected IURIQueryDecoder getURIQueryDecoder() {
+ return new BaseVirtualMachineURIQueryDecoder(this) {
+ private static final String VMX_PATH = "vmxPath";
+ private static final String COMMAND_LAUNCH_PATTERN = "commandLaunchPattern";
+ private static final String EXECUTABLE = "executable";
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineURIQueryDecoder#decode(java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean decode(String key, String value) {
+ if (super.decode(key, value))
+ return true;
+
+ if (key.equals(VMX_PATH)) {
+ getSettings().put(VMwarePreferenceConstants.VMWARE_VMX_PATH, value);
+ } else if (key.equals(COMMAND_LAUNCH_PATTERN)) {
+ getSettings().put(VMwarePreferenceConstants.VMWARE_LAUNCH_PATTERN, value);
+ } else if (key.equals(EXECUTABLE)) {
+ getSettings().put(VMwarePreferenceConstants.VMWARE_EXE_NAME, value);
+ } else {
+ return false;
+ }
+ return true;
+ }
+ };
+ }
+
+ public String getVmxPath() {
+ return getPreference(VMwarePreferenceConstants.VMWARE_VMX_PATH);
+ }
+
+ public void setVmxPath(String vmx) {
+ setPreference(VMwarePreferenceConstants.VMWARE_VMX_PATH, vmx);
+ }
+ public String getExecutable() {
+ return getPreference(VMwarePreferenceConstants.VMWARE_EXE_NAME);
+ }
+ public void setExecutable(String exe) {
+ setPreference(VMwarePreferenceConstants.VMWARE_EXE_NAME, exe);
+ }
+
+ public String getCommandLaunchPattern() {
+ return getPreference(VMwarePreferenceConstants.VMWARE_LAUNCH_PATTERN);
+ }
+ public void setCommandLaunchPattern(String pattern) {
+ setPreference(VMwarePreferenceConstants.VMWARE_LAUNCH_PATTERN, pattern);
+ }
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareConfiguration.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachine.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachine.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachine.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,67 +1,67 @@
-/*******************************************************************************
- * Copyright (c) 2008-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.vm.vmware;
-
-import java.net.URI;
-
-import org.eclipse.core.runtime.Platform;
-import org.maemo.esbox.internal.api.vm.core.BaseVirtualBuildMachine;
-import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
-import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
-import org.maemo.mica.common.core.machine.IComposablePreferencePage;
-import org.maemo.mica.internal.api.common.core.filesystem.BaseSharedFilesystemProvider;
-
-
-/**
- * This is a build machine running under QEMU.
- * @author eswartz
- *
- */
-public class VMwareMachine extends BaseVirtualBuildMachine {
-
- public final static String ID = Activator.PLUGIN_ID + ".vmware_machine";
- //
- private IVMwareConfiguration configuration;
-
- public VMwareMachine(String name, IVMwareConfiguration configuration) {
- super(ID, name, Platform.OS_LINUX, Platform.ARCH_X86,
- new VMwareMachineController(configuration),
- configuration.getSSHConfiguration(),
- new BaseSharedFilesystemProvider(configuration.getSharedFolders()));
- this.configuration = configuration;
- }
-
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.vm.core.IVirtualMachine#createPreferencePage(org.eclipse.swt.widgets.Composite)
- */
- public IComposablePreferencePage createPreferencePage() {
- return new VMwarePreferencePage(configuration);
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.vm.core.IVirtualMachine#getConfiguration()
- */
- public IVirtualMachineConfiguration getConfiguration() {
- return configuration;
- }
-
- /* (non-Javadoc)
- * @see org.maemo.mica.internal.api.protocol.ssh.SSHMachineBackend#getURI()
- */
- @Override
- public URI getURI() {
- return URI.create("vmware+ssh://"
- + getSshConfiguration().getTargetAddress()
- + ":"
- + getSshConfiguration().getTargetPort());
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2008-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.vm.vmware;
+
+import java.net.URI;
+
+import org.eclipse.core.runtime.Platform;
+import org.maemo.esbox.internal.api.vm.core.BaseVirtualBuildMachine;
+import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
+import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
+import org.maemo.mica.common.core.machine.IComposablePreferencePage;
+import org.maemo.mica.internal.api.common.core.filesystem.BaseSharedFilesystemProvider;
+
+
+/**
+ * This is a build machine running under QEMU.
+ * @author eswartz
+ *
+ */
+public class VMwareMachine extends BaseVirtualBuildMachine {
+
+ public final static String ID = Activator.PLUGIN_ID + ".vmware_machine";
+ //
+ private IVMwareConfiguration configuration;
+
+ public VMwareMachine(String name, IVMwareConfiguration configuration) {
+ super(ID, name, Platform.OS_LINUX, Platform.ARCH_X86,
+ new VMwareMachineController(configuration),
+ configuration.getSSHConfiguration(),
+ new BaseSharedFilesystemProvider(configuration.getSharedFolders()));
+ this.configuration = configuration;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.vm.core.IVirtualMachine#createPreferencePage(org.eclipse.swt.widgets.Composite)
+ */
+ public IComposablePreferencePage createPreferencePage() {
+ return new VMwarePreferencePage(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.vm.core.IVirtualMachine#getConfiguration()
+ */
+ public IVirtualMachineConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.mica.internal.api.protocol.ssh.SSHMachineBackend#getURI()
+ */
+ @Override
+ public URI getURI() {
+ return URI.create("vmware+ssh://"
+ + getSshConfiguration().getTargetAddress()
+ + ":"
+ + getSshConfiguration().getTargetPort());
+ }
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachine.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,193 +1,193 @@
-/*******************************************************************************
- * Copyright (c) 2008-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.vm.vmware;
-
-
-import java.io.File;
-import java.util.List;
-
-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.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.maemo.esbox.internal.api.vm.core.BaseLaunchableVirtualMachineController;
-import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
-import org.maemo.mica.common.core.HostUtils;
-import org.maemo.mica.common.core.MicaException;
-import org.maemo.mica.common.core.machine.IProcess;
-import org.maemo.mica.common.core.machine.MachineException;
-import org.maemo.mica.common.core.process.CommandLineArguments;
-import org.maemo.mica.common.core.process.ProcessLauncherParameters;
-import org.maemo.mica.common.core.process.ShellTemplateSubstitutor;
-
-/**
- * This is the basic implementation of a QEMU machine
- * @author eswartz
- *
- */
-public class VMwareMachineController extends BaseLaunchableVirtualMachineController {
- /**
- * @param name
- * @param configuration
- */
- public VMwareMachineController(IVMwareConfiguration configuration) {
- super("VMware", configuration);
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.core.IVirtualMachineController#isMachineRunning()
- */
- public boolean isMachineRunning() {
- // we can't tell if the machine stopped running just based on the process stopping
- // (VMware may have used another instance to host the machine)
- if (launchInfo != null && launchInfo.isAlive()) {
- return true;
- }
-
- try {
- // TODO: check the product and use vmrun if possible (or not... that utility
- // is not available widely enough to be of any use)
- IVMwareConfiguration config = (IVMwareConfiguration) machineConfiguration;
-
- File exe = new File(config.getExecutable());
- IProcess[] runningVMwares = getRunningProcesses(exe, null);
- if (runningVMwares.length == 0)
- return false;
-
- if (!HostUtils.isWindows()) {
- // we can't tell anything on Windows
- File vmx = new File(config.getVmxPath());
- IProcess[] runningExactInstances = getRunningProcesses(exe, vmx);
- return runningExactInstances.length > 0;
- } else {
- return true;
- }
- } catch (MicaException e) {
- Activator.getErrorLogger().logError("Can't check running VMWare processes", e);
- return false;
- }
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineController#constructLaunchParameters()
- */
- @Override
- protected ProcessLauncherParameters constructLaunchParameters() {
- IVMwareConfiguration vmwareConfiguration = (IVMwareConfiguration) machineConfiguration;
-
- String launchPattern = vmwareConfiguration.getCommandLaunchPattern();
- ShellTemplateSubstitutor substitutor = new ShellTemplateSubstitutor();
-
- IPath launchPath = new Path(vmwareConfiguration.getExecutable());
- substitutor.define("VMWARE", launchPath.toOSString());
- substitutor.define("VMX_PATH", new Path(vmwareConfiguration.getVmxPath()).toOSString());
-
- launchPattern = substitutor.substitute(launchPattern);
- List<String> cmdLine = CommandLineArguments.createFromHostCommandLine(launchPattern);
-
- return ProcessLauncherParameters.create(cmdLine);
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineController#doStartMachineImpl(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected IStatus doStartVirtualMachine(IProgressMonitor monitor)
- throws MachineException {
-
- monitor.beginTask("Starting VMware...", 10);
- monitor.subTask("Checking existing VMware instances...");
-
- // first, see if we recognize any other VMware instances
- IVMwareConfiguration config = (IVMwareConfiguration) machineConfiguration;
- File exe = new File(config.getExecutable());
- IProcess[] runningEngines;
- try {
- runningEngines = getRunningProcesses(exe, null);
- } catch (MicaException e) {
- runningEngines = new IProcess[0];
- }
- monitor.worked(1);
-
- IStatus status;
- try {
- launchInfo = launchMachine();
- } catch (MicaException e) {
- throw new MachineException("Failed to launch VMware", e);
- }
-
- launchInfo.monitor.runNonBlocking();
-
- // depending on whether others were running, it's either important or not
- // if the subsequent launch succeeds
- LaunchedMachineInfo watchStatus = null;
- if (runningEngines.length == 0)
- watchStatus = launchInfo;
-
- status = probeUntilConnect(
- watchStatus,
- new SubProgressMonitor(monitor, 8));
-
- if (monitor.isCanceled() || status.getSeverity() == IStatus.CANCEL) {
- launchInfo.cancel();
- return CANCEL_STATUS;
- }
-
- if (!status.isOK()) {
- launchInfo.setFailed(status);
- return status;
- }
-
- return status;
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineController#doStopMachineImpl(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected IStatus doStopVirtualMachine(IProgressMonitor monitor) {
-
- // don't waste time if not running
- try {
- doHaltMachine(monitor);
- } catch (MachineException e) {
- return Activator.createErrorStatus(null, e);
- }
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
-
- // then be mean if we launched it ourselves
- if (launchInfo != null) {
-
- Process process = launchInfo.launcher.getLastCreatedProcess();
- if (process != null)
- process.destroy();
- launchInfo = null;
- }
- return Status.OK_STATUS;
- }
-
- /* (non-Javadoc)
- * @see org.maemo.mica.internal.api.protocol.ssh.SSHMachineControllerBase#doProbeMachine(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected synchronized IStatus doProbeMachine(IProgressMonitor monitor) {
- if (launchInfo != null && !launchInfo.isAlive()) {
- // re-check if things might be fishy
- scheduleProbe();
- }
- IStatus status = super.doProbeMachine(monitor);
- return status;
-
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2008-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.vm.vmware;
+
+
+import java.io.File;
+import java.util.List;
+
+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.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.maemo.esbox.internal.api.vm.core.BaseLaunchableVirtualMachineController;
+import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
+import org.maemo.mica.common.core.HostUtils;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.machine.IProcess;
+import org.maemo.mica.common.core.machine.MachineException;
+import org.maemo.mica.common.core.process.CommandLineArguments;
+import org.maemo.mica.common.core.process.ProcessLauncherParameters;
+import org.maemo.mica.common.core.process.ShellTemplateSubstitutor;
+
+/**
+ * This is the basic implementation of a QEMU machine
+ * @author eswartz
+ *
+ */
+public class VMwareMachineController extends BaseLaunchableVirtualMachineController {
+ /**
+ * @param name
+ * @param configuration
+ */
+ public VMwareMachineController(IVMwareConfiguration configuration) {
+ super("VMware", configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.core.IVirtualMachineController#isMachineRunning()
+ */
+ public boolean isMachineRunning() {
+ // we can't tell if the machine stopped running just based on the process stopping
+ // (VMware may have used another instance to host the machine)
+ if (launchInfo != null && launchInfo.isAlive()) {
+ return true;
+ }
+
+ try {
+ // TODO: check the product and use vmrun if possible (or not... that utility
+ // is not available widely enough to be of any use)
+ IVMwareConfiguration config = (IVMwareConfiguration) machineConfiguration;
+
+ File exe = new File(config.getExecutable());
+ IProcess[] runningVMwares = getRunningProcesses(exe, null);
+ if (runningVMwares.length == 0)
+ return false;
+
+ if (!HostUtils.isWindows()) {
+ // we can't tell anything on Windows
+ File vmx = new File(config.getVmxPath());
+ IProcess[] runningExactInstances = getRunningProcesses(exe, vmx);
+ return runningExactInstances.length > 0;
+ } else {
+ return true;
+ }
+ } catch (MicaException e) {
+ Activator.getErrorLogger().logError("Can't check running VMWare processes", e);
+ return false;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineController#constructLaunchParameters()
+ */
+ @Override
+ protected ProcessLauncherParameters constructLaunchParameters() {
+ IVMwareConfiguration vmwareConfiguration = (IVMwareConfiguration) machineConfiguration;
+
+ String launchPattern = vmwareConfiguration.getCommandLaunchPattern();
+ ShellTemplateSubstitutor substitutor = new ShellTemplateSubstitutor();
+
+ IPath launchPath = new Path(vmwareConfiguration.getExecutable());
+ substitutor.define("VMWARE", launchPath.toOSString());
+ substitutor.define("VMX_PATH", new Path(vmwareConfiguration.getVmxPath()).toOSString());
+
+ launchPattern = substitutor.substitute(launchPattern);
+ List<String> cmdLine = CommandLineArguments.createFromHostCommandLine(launchPattern);
+
+ return ProcessLauncherParameters.create(cmdLine);
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineController#doStartMachineImpl(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IStatus doStartVirtualMachine(IProgressMonitor monitor)
+ throws MachineException {
+
+ monitor.beginTask("Starting VMware...", 10);
+ monitor.subTask("Checking existing VMware instances...");
+
+ // first, see if we recognize any other VMware instances
+ IVMwareConfiguration config = (IVMwareConfiguration) machineConfiguration;
+ File exe = new File(config.getExecutable());
+ IProcess[] runningEngines;
+ try {
+ runningEngines = getRunningProcesses(exe, null);
+ } catch (MicaException e) {
+ runningEngines = new IProcess[0];
+ }
+ monitor.worked(1);
+
+ IStatus status;
+ try {
+ launchInfo = launchMachine();
+ } catch (MicaException e) {
+ throw new MachineException("Failed to launch VMware", e);
+ }
+
+ launchInfo.monitor.runNonBlocking();
+
+ // depending on whether others were running, it's either important or not
+ // if the subsequent launch succeeds
+ LaunchedMachineInfo watchStatus = null;
+ if (runningEngines.length == 0)
+ watchStatus = launchInfo;
+
+ status = probeUntilConnect(
+ watchStatus,
+ new SubProgressMonitor(monitor, 8));
+
+ if (monitor.isCanceled() || status.getSeverity() == IStatus.CANCEL) {
+ launchInfo.cancel();
+ return CANCEL_STATUS;
+ }
+
+ if (!status.isOK()) {
+ launchInfo.setFailed(status);
+ return status;
+ }
+
+ return status;
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.core.BaseVirtualMachineController#doStopMachineImpl(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IStatus doStopVirtualMachine(IProgressMonitor monitor) {
+
+ // don't waste time if not running
+ try {
+ doHaltMachine(monitor);
+ } catch (MachineException e) {
+ return Activator.createErrorStatus(null, e);
+ }
+ if (monitor.isCanceled())
+ return Status.CANCEL_STATUS;
+
+ // then be mean if we launched it ourselves
+ if (launchInfo != null) {
+
+ Process process = launchInfo.launcher.getLastCreatedProcess();
+ if (process != null)
+ process.destroy();
+ launchInfo = null;
+ }
+ return Status.OK_STATUS;
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.mica.internal.api.protocol.ssh.SSHMachineControllerBase#doProbeMachine(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected synchronized IStatus doProbeMachine(IProgressMonitor monitor) {
+ if (launchInfo != null && !launchInfo.isAlive()) {
+ // re-check if things might be fishy
+ scheduleProbe();
+ }
+ IStatus status = super.doProbeMachine(monitor);
+ return status;
+
+ }
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineFactory.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineFactory.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineFactory.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,55 +1,55 @@
-/*******************************************************************************
- * Copyright (c) 2008-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.vm.vmware;
-
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
-import org.maemo.mica.common.core.MicaException;
-import org.maemo.mica.common.core.filesystem.ISharedFilesystemProvider;
-import org.maemo.mica.common.core.machine.*;
-
-import java.net.URI;
-
-/**
- * This factory creates VMware virtual machines.
- * @author eswartz
- *
- */
-public class VMwareMachineFactory implements IMachineFactory {
-
- /**
- * Scheme for VMware
- */
- private static final String VMWARE_SCHEME = "vmware+ssh";
-
- /* (non-Javadoc)
- * @see org.maemo.mica.common.core.machine.IMachineFactory#createMachine(java.net.URI)
- */
- public IMachine createMachine(String name, URI uri, ISharedFilesystemProvider sharedFilesystemProvider) throws MicaException {
- if (!uri.getScheme().equals(VMWARE_SCHEME))
- return null;
-
- IVMwareConfiguration qemuConfig = new VMwareConfiguration(
- new DialogSettings("Custom"),
- uri,
- sharedFilesystemProvider);
- return new VMwareMachine(name, qemuConfig);
- }
-
- /* (non-Javadoc)
- * @see org.maemo.mica.common.core.machine.IMachineFactory#getScheme()
- */
- public String getScheme() {
- return VMWARE_SCHEME;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2008-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.vm.vmware;
+
+import org.eclipse.jface.dialogs.DialogSettings;
+import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.filesystem.ISharedFilesystemProvider;
+import org.maemo.mica.common.core.machine.*;
+
+import java.net.URI;
+
+/**
+ * This factory creates VMware virtual machines.
+ * @author eswartz
+ *
+ */
+public class VMwareMachineFactory implements IMachineFactory {
+
+ /**
+ * Scheme for VMware
+ */
+ private static final String VMWARE_SCHEME = "vmware+ssh";
+
+ /* (non-Javadoc)
+ * @see org.maemo.mica.common.core.machine.IMachineFactory#createMachine(java.net.URI)
+ */
+ public IMachine createMachine(String name, URI uri, ISharedFilesystemProvider sharedFilesystemProvider) throws MicaException {
+ if (!uri.getScheme().equals(VMWARE_SCHEME))
+ return null;
+
+ IVMwareConfiguration qemuConfig = new VMwareConfiguration(
+ new DialogSettings("Custom"),
+ uri,
+ sharedFilesystemProvider);
+ return new VMwareMachine(name, qemuConfig);
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.mica.common.core.machine.IMachineFactory#getScheme()
+ */
+ public String getScheme() {
+ return VMWARE_SCHEME;
+ }
+
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferenceConstants.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferenceConstants.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferenceConstants.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,45 +1,45 @@
-/*******************************************************************************
- * Copyright (c) 2008-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.vm.vmware;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.maemo.esbox.vm.core.IVirtualMachine;
-
-/**
- * This class encapsulates the keys for preference constants for VMware configuration.
- * <p>
- * NOTE: use {@link IVirtualMachine#getConfiguration()} to access the values
- * for an actual VM configuration, not CorePreferenceManager, which stores only
- * defaults.
- * @author eswartz
- *
- */
-public class VMwarePreferenceConstants {
- public static final int VERSION_MAJOR = 1;
- public static final int VERSION_MINOR = 1;
-
- public static final String VMWARE_EXE_NAME = "VMWARE_EXE_NAME";
- public static final String VMWARE_LAUNCH_PATTERN = "VMWARE_LAUNCH_PATTERN";
- public static final String VMWARE_VMX_PATH = "VMWARE_VMX_PATH";
-
- /** product type, see VMwareUtils */
- public static final String VMWARE_PRODUCT = "VMWARE_PRODUCT";
-
- static final Class<?> privateKeysClass = VMwarePreferenceConstantsPrivate.class;
-
- /**
- * Return <code>null</code>. We store preferences in {@link IVirtualMachine#getConfiguration()}
- * and provide this method to make CorePreferenceManager happy.
- * @return null
- */
- public static IPreferenceStore getPreferenceStore() { return null; }
-}
+/*******************************************************************************
+ * Copyright (c) 2008-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.vm.vmware;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.maemo.esbox.vm.core.IVirtualMachine;
+
+/**
+ * This class encapsulates the keys for preference constants for VMware configuration.
+ * <p>
+ * NOTE: use {@link IVirtualMachine#getConfiguration()} to access the values
+ * for an actual VM configuration, not CorePreferenceManager, which stores only
+ * defaults.
+ * @author eswartz
+ *
+ */
+public class VMwarePreferenceConstants {
+ public static final int VERSION_MAJOR = 1;
+ public static final int VERSION_MINOR = 1;
+
+ public static final String VMWARE_EXE_NAME = "VMWARE_EXE_NAME";
+ public static final String VMWARE_LAUNCH_PATTERN = "VMWARE_LAUNCH_PATTERN";
+ public static final String VMWARE_VMX_PATH = "VMWARE_VMX_PATH";
+
+ /** product type, see VMwareUtils */
+ public static final String VMWARE_PRODUCT = "VMWARE_PRODUCT";
+
+ static final Class<?> privateKeysClass = VMwarePreferenceConstantsPrivate.class;
+
+ /**
+ * Return <code>null</code>. We store preferences in {@link IVirtualMachine#getConfiguration()}
+ * and provide this method to make CorePreferenceManager happy.
+ * @return null
+ */
+ public static IPreferenceStore getPreferenceStore() { return null; }
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferenceConstants.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferenceConstantsPrivate.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferenceMigrator.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,249 +1,249 @@
-/*******************************************************************************
- * Copyright (c) 2008-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.vm.vmware;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.maemo.esbox.internal.api.vm.ui.preferences.AddressProvider;
-import org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage;
-import org.maemo.esbox.internal.api.vm.ui.preferences.HostInterfaceAddressProvider;
-import org.maemo.esbox.internal.api.vm.ui.preferences.IHostTargetAddressReconciler;
-import org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineAddressConfigurator;
-import org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineSettingsPreferencePage;
-import org.maemo.esbox.internal.api.vm.ui.preferences.SameSubnetHostTargetAddressConciler;
-import org.maemo.esbox.vm.core.IVirtualMachine;
-import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
-import org.maemo.mica.common.core.MicaException;
-import org.maemo.mica.common.core.ui.IProgressReporter;
-import org.maemo.mica.internal.api.common.core.IPNetmaskFilter;
-
-/**
- * Configure VMware preferences. This page is NOT registered at the top level
- * of preference page UI but is nested inside the ESbox Build Machine preference UI.
- * @author eswartz
- *
- */
-public class VMwarePreferencePage extends BaseVirtualMachinePreferencePage {
-
- private VMwareSettingsPreferencePage settingsPage;
-
- /**
- * @param settings
- */
- public VMwarePreferencePage(IVMwareConfiguration config) {
- super(config);
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createMachine()
- */
- @Override
- protected IVirtualMachine createMachine() {
- IVMwareConfiguration config = new VMwareConfiguration(new DialogSettings("temp"));
- commonPrefPage.saveTo(config);
- config.setSharedFolders(sharedFoldersPrefPage.getSharedFolders());
- vmPrefPage.saveTo(config);
- return new VMwareMachine("Test VMWare Machine", config);
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createVirtualMachinePreferencePage()
- */
- @Override
- protected IVirtualMachineSettingsPreferencePage createVirtualMachinePreferencePage(IPreferenceStore store) {
- settingsPage = new VMwareSettingsPreferencePage(store, this);
- return settingsPage;
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createAddressConfigurator()
- */
- @Override
- protected IVirtualMachineAddressConfigurator createAddressConfigurator() {
- return new IVirtualMachineAddressConfigurator() {
-
- public AddressProvider getDefaultHostAddressProvider() {
- return new HostInterfaceAddressProvider();
- }
-
- public AddressProvider getDefaultTargetAddressProvider() {
- return new VMwareTargetInterfaceAddressProvider();
- }
-
- public IHostTargetAddressReconciler getHostTargetAddressReconciler() {
- return new SameSubnetHostTargetAddressConciler();
- }
-
- public void configureNetworkSettings(IProgressReporter reporter) {
- initializeNetworkDefaults(reporter);
- }
-
- };
- }
-
- /**
- * Set up default values for the network/machine access based on the VMX file.
- * @return IStatus
- */
- protected void initializeNetworkDefaults(IProgressReporter reporter) {
- String vmnet = null;
-
- // get real info from the VMX
- String vmx = settingsPage.getVMXPath();
- String networkType = null;
- boolean isNAT = false;
-
- try {
- //String vmx = store.getString(VMwarePreferenceConstants.VMWARE_VMX_PATH);
- Map<String, String> config = VMwareUtils.readVMXFile(
- vmx);
-
- reporter.logInfo("Reading settings from " + vmx + "...");
-
- networkType = VMwareUtils.getNetworkConfig(config);
- if (networkType.equals(VMwareUtils.NETWORK_CONFIG_NAT)) {
- vmnet = "vmnet8";
- reporter.logInfo("Configuring for NAT networking.");
- isNAT = true;
- }
- else if (networkType.equals(VMwareUtils.NETWORK_CONFIG_HOSTONLY)) {
- vmnet = "vmnet1";
- reporter.log(Activator.createStatus(IStatus.ERROR,
- "This VM is configured for host-only networking, which usually means it cannot be contacted from the host, nor access the Internet. Please reconfigure it for NAT or Bridged networking if problems occur."));
- } else if (networkType.equals(VMwareUtils.NETWORK_CONFIG_BRIDGED)) {
- reporter.logInfo("Configuring for bridged networking.");
- } else {
- reporter.log(Activator.createStatus(IStatus.WARNING,
- "Unknown or custom networking; assuming bridged networking. Please manually verify the settings."));
- }
- } catch (CoreException e) {
- // keep guesses
- reporter.log(Activator.createErrorStatus(
- "Failed to read the VMX file " + vmx + "; please ensure it exists first.",
- e));
- return;
- }
-
- String port = "22";
- if (isNAT) {
- port = "2222";
- reporter.logInfo("Set SSH Target Port to the default recommendation for NAT ("+port+").");
- reporter.logInfo("If you're using Port Forwarding and NAT, this may need to be edited.");
- } else {
- reporter.logInfo("Set SSH Target Port to the default ("+port+").");
- }
- commonPrefPage.getSSHTargetPort().setStringValue(port);
-
- port = "22";
- commonPrefPage.getSSHHostPort().setStringValue(port);
- reporter.logInfo("Set SSH Host Port to the default ("+port+").");
-
- InetAddress hostAddr = null;
- InetAddress targetAddr = null;
-
- if (vmnet == null) {
- // the host is the default in non-NAT, non-bridged modes
- try {
- hostAddr = InetAddress.getLocalHost();
- commonPrefPage.getSSHHostAddr().setAddress(hostAddr);
-
- reporter.logInfo("Set Host Address to LAN address " + hostAddr);
-
- // Dunno target -- it's DHCP. Reset the low byte if it's not on the same subnet.
- targetAddr = commonPrefPage.getSSHTargetAddr().getAddress();
- if (targetAddr instanceof Inet4Address) {
- IPNetmaskFilter filter;
- try {
- filter = new IPNetmaskFilter(hostAddr);
- if (!filter.accept(targetAddr))
- targetAddr = null;
- } catch (MicaException e) {
- targetAddr = null;
- }
- }
-
- if (targetAddr == null) {
- targetAddr = InetAddress.getLocalHost();
- if (targetAddr instanceof Inet4Address) {
- byte[] addrBytes = targetAddr.getAddress();
- addrBytes[3] = 0;
- targetAddr = InetAddress.getByAddress(addrBytes);
- }
- commonPrefPage.getSSHTargetAddr().setAddress(targetAddr);
- reporter.logInfo("Set Target Address to LAN address " + targetAddr + " (please edit)");
- }
- reporter.log(Activator.createStatus(IStatus.WARNING,
- "You will need to manually edit the Target Address after the VM boots, by inspecting the output of 'sudo dhclient3' or '/sbin/ifconfig'."));
- } catch (UnknownHostException e) {
- // dunno!
- reporter.log(Activator.createErrorStatus(
- "Could not construct the local host address",
- e));
- }
-
- } else {
- // configure based on the network in use
- Map<String, InetAddress> vmnets = VMwareUtils.getVMNetMappings();
- hostAddr = vmnets.get(vmnet);
- if (hostAddr != null) {
- try {
- // the network is *.1, but the endpoint is *.2
- byte[] addr = hostAddr.getAddress();
- if (addr.length == 4 && addr[3] == 1) {
- addr[3] = 2;
- hostAddr = Inet4Address.getByAddress(addr);
- }
- } catch (UnknownHostException e) {
- reporter.log(Activator.createErrorStatus(
- "Could not correct the local host address",
- e));
- }
- commonPrefPage.getSSHHostAddr().setAddress(hostAddr);
-
- reporter.logInfo("Set Host Address to " + vmnet + " endpoint address " + hostAddr);
-
- if (isNAT) {
- try {
- targetAddr = Inet4Address.getByAddress(new byte[] { 127, 0, 0, 1});
- } catch (UnknownHostException e) {
- // unlikely
- }
- }
- if (targetAddr == null) {
- // guess the target address
- targetAddr = VMwareUtils.convertToLikelyDHCPAddress(hostAddr);
- }
-
- if (targetAddr != null) {
- commonPrefPage.getSSHTargetAddr().setAddress(targetAddr);
-
- reporter.logInfo("Set Target Address to likely " + vmnet + " DHCP address " + targetAddr);
- reporter.log(Activator.createStatus(IStatus.WARNING,
- "You may need to manually edit the Target Address after the VM boots, by inspecting the output of 'sudo dhclient3' or '/sbin/ifconfig'."));
-
- }
- } else {
- reporter.log(Activator.createStatus(IStatus.WARNING,
- "Could not find the address of the " + vmnet + " interface. The VMX file may be referencing a missing, misconfigured, or unknown interface."));
- }
- }
-
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2008-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.vm.vmware;
+
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.DialogSettings;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.maemo.esbox.internal.api.vm.ui.preferences.AddressProvider;
+import org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage;
+import org.maemo.esbox.internal.api.vm.ui.preferences.HostInterfaceAddressProvider;
+import org.maemo.esbox.internal.api.vm.ui.preferences.IHostTargetAddressReconciler;
+import org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineAddressConfigurator;
+import org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineSettingsPreferencePage;
+import org.maemo.esbox.internal.api.vm.ui.preferences.SameSubnetHostTargetAddressConciler;
+import org.maemo.esbox.vm.core.IVirtualMachine;
+import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.ui.IProgressReporter;
+import org.maemo.mica.internal.api.common.core.IPNetmaskFilter;
+
+/**
+ * Configure VMware preferences. This page is NOT registered at the top level
+ * of preference page UI but is nested inside the ESbox Build Machine preference UI.
+ * @author eswartz
+ *
+ */
+public class VMwarePreferencePage extends BaseVirtualMachinePreferencePage {
+
+ private VMwareSettingsPreferencePage settingsPage;
+
+ /**
+ * @param settings
+ */
+ public VMwarePreferencePage(IVMwareConfiguration config) {
+ super(config);
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createMachine()
+ */
+ @Override
+ protected IVirtualMachine createMachine() {
+ IVMwareConfiguration config = new VMwareConfiguration(new DialogSettings("temp"));
+ commonPrefPage.saveTo(config);
+ config.setSharedFolders(sharedFoldersPrefPage.getSharedFolders());
+ vmPrefPage.saveTo(config);
+ return new VMwareMachine("Test VMWare Machine", config);
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createVirtualMachinePreferencePage()
+ */
+ @Override
+ protected IVirtualMachineSettingsPreferencePage createVirtualMachinePreferencePage(IPreferenceStore store) {
+ settingsPage = new VMwareSettingsPreferencePage(store, this);
+ return settingsPage;
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createAddressConfigurator()
+ */
+ @Override
+ protected IVirtualMachineAddressConfigurator createAddressConfigurator() {
+ return new IVirtualMachineAddressConfigurator() {
+
+ public AddressProvider getDefaultHostAddressProvider() {
+ return new HostInterfaceAddressProvider();
+ }
+
+ public AddressProvider getDefaultTargetAddressProvider() {
+ return new VMwareTargetInterfaceAddressProvider();
+ }
+
+ public IHostTargetAddressReconciler getHostTargetAddressReconciler() {
+ return new SameSubnetHostTargetAddressConciler();
+ }
+
+ public void configureNetworkSettings(IProgressReporter reporter) {
+ initializeNetworkDefaults(reporter);
+ }
+
+ };
+ }
+
+ /**
+ * Set up default values for the network/machine access based on the VMX file.
+ * @return IStatus
+ */
+ protected void initializeNetworkDefaults(IProgressReporter reporter) {
+ String vmnet = null;
+
+ // get real info from the VMX
+ String vmx = settingsPage.getVMXPath();
+ String networkType = null;
+ boolean isNAT = false;
+
+ try {
+ //String vmx = store.getString(VMwarePreferenceConstants.VMWARE_VMX_PATH);
+ Map<String, String> config = VMwareUtils.readVMXFile(
+ vmx);
+
+ reporter.logInfo("Reading settings from " + vmx + "...");
+
+ networkType = VMwareUtils.getNetworkConfig(config);
+ if (networkType.equals(VMwareUtils.NETWORK_CONFIG_NAT)) {
+ vmnet = "vmnet8";
+ reporter.logInfo("Configuring for NAT networking.");
+ isNAT = true;
+ }
+ else if (networkType.equals(VMwareUtils.NETWORK_CONFIG_HOSTONLY)) {
+ vmnet = "vmnet1";
+ reporter.log(Activator.createStatus(IStatus.ERROR,
+ "This VM is configured for host-only networking, which usually means it cannot be contacted from the host, nor access the Internet. Please reconfigure it for NAT or Bridged networking if problems occur."));
+ } else if (networkType.equals(VMwareUtils.NETWORK_CONFIG_BRIDGED)) {
+ reporter.logInfo("Configuring for bridged networking.");
+ } else {
+ reporter.log(Activator.createStatus(IStatus.WARNING,
+ "Unknown or custom networking; assuming bridged networking. Please manually verify the settings."));
+ }
+ } catch (CoreException e) {
+ // keep guesses
+ reporter.log(Activator.createErrorStatus(
+ "Failed to read the VMX file " + vmx + "; please ensure it exists first.",
+ e));
+ return;
+ }
+
+ String port = "22";
+ if (isNAT) {
+ port = "2222";
+ reporter.logInfo("Set SSH Target Port to the default recommendation for NAT ("+port+").");
+ reporter.logInfo("If you're using Port Forwarding and NAT, this may need to be edited.");
+ } else {
+ reporter.logInfo("Set SSH Target Port to the default ("+port+").");
+ }
+ commonPrefPage.getSSHTargetPort().setStringValue(port);
+
+ port = "22";
+ commonPrefPage.getSSHHostPort().setStringValue(port);
+ reporter.logInfo("Set SSH Host Port to the default ("+port+").");
+
+ InetAddress hostAddr = null;
+ InetAddress targetAddr = null;
+
+ if (vmnet == null) {
+ // the host is the default in non-NAT, non-bridged modes
+ try {
+ hostAddr = InetAddress.getLocalHost();
+ commonPrefPage.getSSHHostAddr().setAddress(hostAddr);
+
+ reporter.logInfo("Set Host Address to LAN address " + hostAddr);
+
+ // Dunno target -- it's DHCP. Reset the low byte if it's not on the same subnet.
+ targetAddr = commonPrefPage.getSSHTargetAddr().getAddress();
+ if (targetAddr instanceof Inet4Address) {
+ IPNetmaskFilter filter;
+ try {
+ filter = new IPNetmaskFilter(hostAddr);
+ if (!filter.accept(targetAddr))
+ targetAddr = null;
+ } catch (MicaException e) {
+ targetAddr = null;
+ }
+ }
+
+ if (targetAddr == null) {
+ targetAddr = InetAddress.getLocalHost();
+ if (targetAddr instanceof Inet4Address) {
+ byte[] addrBytes = targetAddr.getAddress();
+ addrBytes[3] = 0;
+ targetAddr = InetAddress.getByAddress(addrBytes);
+ }
+ commonPrefPage.getSSHTargetAddr().setAddress(targetAddr);
+ reporter.logInfo("Set Target Address to LAN address " + targetAddr + " (please edit)");
+ }
+ reporter.log(Activator.createStatus(IStatus.WARNING,
+ "You will need to manually edit the Target Address after the VM boots, by inspecting the output of 'sudo dhclient3' or '/sbin/ifconfig'."));
+ } catch (UnknownHostException e) {
+ // dunno!
+ reporter.log(Activator.createErrorStatus(
+ "Could not construct the local host address",
+ e));
+ }
+
+ } else {
+ // configure based on the network in use
+ Map<String, InetAddress> vmnets = VMwareUtils.getVMNetMappings();
+ hostAddr = vmnets.get(vmnet);
+ if (hostAddr != null) {
+ try {
+ // the network is *.1, but the endpoint is *.2
+ byte[] addr = hostAddr.getAddress();
+ if (addr.length == 4 && addr[3] == 1) {
+ addr[3] = 2;
+ hostAddr = Inet4Address.getByAddress(addr);
+ }
+ } catch (UnknownHostException e) {
+ reporter.log(Activator.createErrorStatus(
+ "Could not correct the local host address",
+ e));
+ }
+ commonPrefPage.getSSHHostAddr().setAddress(hostAddr);
+
+ reporter.logInfo("Set Host Address to " + vmnet + " endpoint address " + hostAddr);
+
+ if (isNAT) {
+ try {
+ targetAddr = Inet4Address.getByAddress(new byte[] { 127, 0, 0, 1});
+ } catch (UnknownHostException e) {
+ // unlikely
+ }
+ }
+ if (targetAddr == null) {
+ // guess the target address
+ targetAddr = VMwareUtils.convertToLikelyDHCPAddress(hostAddr);
+ }
+
+ if (targetAddr != null) {
+ commonPrefPage.getSSHTargetAddr().setAddress(targetAddr);
+
+ reporter.logInfo("Set Target Address to likely " + vmnet + " DHCP address " + targetAddr);
+ reporter.log(Activator.createStatus(IStatus.WARNING,
+ "You may need to manually edit the Target Address after the VM boots, by inspecting the output of 'sudo dhclient3' or '/sbin/ifconfig'."));
+
+ }
+ } else {
+ reporter.log(Activator.createStatus(IStatus.WARNING,
+ "Could not find the address of the " + vmnet + " interface. The VMX file may be referencing a missing, misconfigured, or unknown interface."));
+ }
+ }
+
+ }
+
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,127 +1,127 @@
-/*******************************************************************************
- * Copyright (c) 2008-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.vm.vmware;
-
-import java.text.MessageFormat;
-
-import org.eclipse.jface.preference.FileFieldEditor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.StringFieldEditor;
-import org.eclipse.swt.widgets.Text;
-import org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage;
-import org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineSettingsPreferencePage;
-import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
-import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
-import org.maemo.mica.common.core.HostUtils;
-import org.maemo.mica.common.ui.preferences.BaseComposableFieldEditorPreferencePage;
-import org.maemo.mica.common.ui.preferences.NonValidatingFileFieldEditor;
-
-/**
- * Configure VMware preferences. This page is NOT registered at the top level
- * of preference page UI but is nested inside the ESbox Build Machine preference UI.
- * @author eswartz
- *
- */
-public class VMwareSettingsPreferencePage extends BaseComposableFieldEditorPreferencePage implements IVirtualMachineSettingsPreferencePage {
-
- private FileFieldEditor feVmxPath;
- private StringFieldEditor feVMWAREExeName;
- private StringFieldEditor feVMWARELaunchPattern;
- /*private*/ final BaseVirtualMachinePreferencePage vmPrefPage;
-
- /**
- * @param preferenceStore
- * @param vmPrefPage
- *
- */
- public VMwareSettingsPreferencePage(IPreferenceStore preferenceStore, BaseVirtualMachinePreferencePage vmPrefPage) {
- this.vmPrefPage = vmPrefPage;
- setTitle("VMware Options");
- setPreferenceStore(preferenceStore);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
- */
- @Override
- protected void createFieldEditors() {
- Text text;
-
- /*
- feVMWAREPath = new NonValidatingDirectoryFieldEditor(
- VMwarePreferenceConstants.VMWARE_INSTALL_PATH,
- "Installation directory:", getFieldEditorParent());
- addField(feVMWAREPath);
- text = feVMWAREPath.getTextControl(getFieldEditorParent());
- text.setToolTipText(
- "Specify the full path to a VMware installation.");
- */
-
- feVMWAREExeName = new FileFieldEditor(
- VMwarePreferenceConstants.VMWARE_EXE_NAME,
- "Executable:", getFieldEditorParent());
- addField(feVMWAREExeName);
- text = feVMWAREExeName.getTextControl(getFieldEditorParent());
- text.setToolTipText(MessageFormat.format(
- "Specify the VMware executable to launch{0}.\n\nIf the program lives in the installation directory or on the PATH, provide a bare filename.\n\nOtherwise, provide a full path to the executable.",
- HostUtils.isOSX() ? "" : " (Player, Server, or Workstation)"));
-
- feVMWARELaunchPattern = new StringFieldEditor(
- VMwarePreferenceConstants.VMWARE_LAUNCH_PATTERN,
- "Command pattern:",
- 48,
- getFieldEditorParent());
- addField(feVMWARELaunchPattern);
- text = feVMWARELaunchPattern.getTextControl(getFieldEditorParent());
- text.setToolTipText(
- "Specify the specific command pattern to use to launch the virtual machine.");
-
- feVmxPath = new NonValidatingFileFieldEditor(
- VMwarePreferenceConstants.VMWARE_VMX_PATH,
- "VMX path:", getFieldEditorParent());
- addField(feVmxPath);
- text = feVmxPath.getTextControl(getFieldEditorParent());
- text.setToolTipText(
- "Specify the full path to the VMX file for the machine.");
-
- /* don't do this here... it's invasive
- feVmxPath.getTextControl(getFieldEditorParent()).addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- // reinitialize network defaults when VMX changes
- String oldVmx = getPreferenceStore().getString(VMwarePreferenceConstants.VMWARE_VMX_PATH);
- String newVmx = feVmxPath.getStringValue();
- if (!newVmx.equals(oldVmx) && new File(newVmx).exists()) {
- vmPrefPage.promptConfigureNetwork();
- }
- }
- });
- */
-
- }
-
- /**
- * Get the current (uncommitted) VMX path
- * @return
- */
- public String getVMXPath() {
- return feVmxPath.getStringValue();
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineSettingsPreferencePage#saveTo(org.maemo.esbox.vm.core.IVirtualMachineConfiguration)
- */
- public void saveTo(IVirtualMachineConfiguration config) {
- config.setCommandLaunchPattern(feVMWARELaunchPattern.getStringValue());
- config.setExecutable(feVMWAREExeName.getStringValue());
- ((IVMwareConfiguration) config).setVmxPath(feVmxPath.getStringValue());
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2008-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.vm.vmware;
+
+import java.text.MessageFormat;
+
+import org.eclipse.jface.preference.FileFieldEditor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.widgets.Text;
+import org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage;
+import org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineSettingsPreferencePage;
+import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
+import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
+import org.maemo.mica.common.core.HostUtils;
+import org.maemo.mica.common.ui.preferences.BaseComposableFieldEditorPreferencePage;
+import org.maemo.mica.common.ui.preferences.NonValidatingFileFieldEditor;
+
+/**
+ * Configure VMware preferences. This page is NOT registered at the top level
+ * of preference page UI but is nested inside the ESbox Build Machine preference UI.
+ * @author eswartz
+ *
+ */
+public class VMwareSettingsPreferencePage extends BaseComposableFieldEditorPreferencePage implements IVirtualMachineSettingsPreferencePage {
+
+ private FileFieldEditor feVmxPath;
+ private StringFieldEditor feVMWAREExeName;
+ private StringFieldEditor feVMWARELaunchPattern;
+ /*private*/ final BaseVirtualMachinePreferencePage vmPrefPage;
+
+ /**
+ * @param preferenceStore
+ * @param vmPrefPage
+ *
+ */
+ public VMwareSettingsPreferencePage(IPreferenceStore preferenceStore, BaseVirtualMachinePreferencePage vmPrefPage) {
+ this.vmPrefPage = vmPrefPage;
+ setTitle("VMware Options");
+ setPreferenceStore(preferenceStore);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
+ */
+ @Override
+ protected void createFieldEditors() {
+ Text text;
+
+ /*
+ feVMWAREPath = new NonValidatingDirectoryFieldEditor(
+ VMwarePreferenceConstants.VMWARE_INSTALL_PATH,
+ "Installation directory:", getFieldEditorParent());
+ addField(feVMWAREPath);
+ text = feVMWAREPath.getTextControl(getFieldEditorParent());
+ text.setToolTipText(
+ "Specify the full path to a VMware installation.");
+ */
+
+ feVMWAREExeName = new FileFieldEditor(
+ VMwarePreferenceConstants.VMWARE_EXE_NAME,
+ "Executable:", getFieldEditorParent());
+ addField(feVMWAREExeName);
+ text = feVMWAREExeName.getTextControl(getFieldEditorParent());
+ text.setToolTipText(MessageFormat.format(
+ "Specify the VMware executable to launch{0}.\n\nIf the program lives in the installation directory or on the PATH, provide a bare filename.\n\nOtherwise, provide a full path to the executable.",
+ HostUtils.isOSX() ? "" : " (Player, Server, or Workstation)"));
+
+ feVMWARELaunchPattern = new StringFieldEditor(
+ VMwarePreferenceConstants.VMWARE_LAUNCH_PATTERN,
+ "Command pattern:",
+ 48,
+ getFieldEditorParent());
+ addField(feVMWARELaunchPattern);
+ text = feVMWARELaunchPattern.getTextControl(getFieldEditorParent());
+ text.setToolTipText(
+ "Specify the specific command pattern to use to launch the virtual machine.");
+
+ feVmxPath = new NonValidatingFileFieldEditor(
+ VMwarePreferenceConstants.VMWARE_VMX_PATH,
+ "VMX path:", getFieldEditorParent());
+ addField(feVmxPath);
+ text = feVmxPath.getTextControl(getFieldEditorParent());
+ text.setToolTipText(
+ "Specify the full path to the VMX file for the machine.");
+
+ /* don't do this here... it's invasive
+ feVmxPath.getTextControl(getFieldEditorParent()).addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ // reinitialize network defaults when VMX changes
+ String oldVmx = getPreferenceStore().getString(VMwarePreferenceConstants.VMWARE_VMX_PATH);
+ String newVmx = feVmxPath.getStringValue();
+ if (!newVmx.equals(oldVmx) && new File(newVmx).exists()) {
+ vmPrefPage.promptConfigureNetwork();
+ }
+ }
+ });
+ */
+
+ }
+
+ /**
+ * Get the current (uncommitted) VMX path
+ * @return
+ */
+ public String getVMXPath() {
+ return feVmxPath.getStringValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineSettingsPreferencePage#saveTo(org.maemo.esbox.vm.core.IVirtualMachineConfiguration)
+ */
+ public void saveTo(IVirtualMachineConfiguration config) {
+ config.setCommandLaunchPattern(feVMWARELaunchPattern.getStringValue());
+ config.setExecutable(feVMWAREExeName.getStringValue());
+ ((IVMwareConfiguration) config).setVmxPath(feVmxPath.getStringValue());
+ }
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareTargetInterfaceAddressProvider.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareUtils.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,219 +1,219 @@
-/*******************************************************************************
- * Copyright (c) 2009 INdT, (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:
- * Raul Herbster (INdT) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.vm.vmware.ui.wizards;
-
-import java.io.File;
-import java.net.MalformedURLException;
-
-import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMInfo;
-import org.maemo.esbox.internal.vm.vmware.Activator;
-
-/**
- * This is a wrapper that contains information about Maemo SDK virtual image
- * installation process.
- *
- * @author raulherbster
- *
- */
-public class MaemoSDKVMInstallData {
-
- private MaemoSDKVMInfo fileToDownload;
- private boolean usePreviousInstallation;
- private String installationPath;
- private String pathOfExistentVM;
- private String uncompressToolPath;
- private boolean licenseTermsAgreed;
- private boolean installSbox;
- private boolean installTargets;
- private boolean installCppEnv;
- private boolean installPythonEnv;
-
- /**
- * Constructor.
- */
- public MaemoSDKVMInstallData() {
- fileToDownload = new MaemoSDKVMInfo();
- }
-
- /**
- * Set the file to download.
- *
- * @param downloadFile
- */
- public void setFileToDownload(MaemoSDKVMInfo downloadFile) {
- if (downloadFile == null)
- return;
- this.fileToDownload = downloadFile;
- if (fileToDownload.getInstallLocation() == null && installationPath != null)
- try {
- fileToDownload.setInstallLocation(new File(installationPath).toURL());
- } catch (MalformedURLException e) {
- Activator.getErrorLogger().logAndShowError(
- "Cannot get location for file "
- + downloadFile.getDescriptor(), e);
- }
- }
-
- /**
- * Return the file to download.
- *
- * @return
- */
- public MaemoSDKVMInfo getFileToDownload() {
- return fileToDownload;
- }
-
- /**
- * @return the usePreviousInstallation
- */
- public boolean canUsePreviousInstallation() {
- return usePreviousInstallation;
- }
-
- /**
- * @param usePreviousInstallation
- * the usePreviousInstallation to set
- */
- public void setUsePreviousInstallation(boolean usePreviousInstallation) {
- this.usePreviousInstallation = usePreviousInstallation;
- }
-
- /**
- * @return the installationPath
- */
- public String getInstallationPath() {
- return installationPath;
- }
-
- /**
- * @param installationPath
- * the installationPath to set
- */
- public void setInstallationPath(String installationPath) {
- this.installationPath = installationPath;
- try {
- fileToDownload.setInstallLocation(new File(installationPath).toURL());
- } catch (MalformedURLException e) {
- Activator.getErrorLogger().logAndShowError(
- "Cannot get location for file "
- + fileToDownload.getDescriptor(), e);
- }
-
- }
-
- /**
- * @return the pathOfExistentVM
- */
- public String getPathOfExistentVM() {
- return pathOfExistentVM;
- }
-
- /**
- * @return the path of uncompress tool to be used.
- */
- public String getUncompressToolPath() {
- return uncompressToolPath;
- }
-
- /**
- * @param pathOfExistentVM
- * the pathOfExistentVM to set
- */
- public void setPathOfExistentVM(String pathOfExistentVM) {
- this.pathOfExistentVM = pathOfExistentVM;
- }
-
- /**
- * @return the installSbox
- */
- public boolean canInstallSbox() {
- return installSbox;
- }
-
- /**
- * @param installSbox
- * the installSbox to set
- */
- public void setInstallSbox(boolean installSbox) {
- this.installSbox = installSbox;
- }
-
- /**
- * @return the installTargets
- */
- public boolean canInstallTargets() {
- return installTargets;
- }
-
- /**
- * @param installTargets
- * the installTargets to set
- */
- public void setInstallTargets(boolean installTargets) {
- this.installTargets = installTargets;
- }
-
- /**
- * @return true, if it is necessary to install Python programming
- * environment; false, otherwise.
- */
- public boolean canInstallPythonEnv() {
- return installPythonEnv;
- }
-
- /**
- * @param installTargets
- * the installTargets to set
- */
- public void setInstallPythonEnv(boolean installPythonEnv) {
- this.installPythonEnv = installPythonEnv;
- }
-
- /**
- *
- * @return true, if it is necessary to install CPP programming environment;
- * false, otherwise.
- */
- public boolean canInstallCppEnv() {
- return installCppEnv;
- }
-
- /**
- * @param installCppEnv
- * the installTargets to set
- */
- public void setInstallCppEnv(boolean installCppEnv) {
- this.installCppEnv = installCppEnv;
- }
-
- /**
- * @return true, if license terms were agreed; false, otherwise.
- */
- public boolean isLicenseTermsAgreed() {
- return licenseTermsAgreed;
- }
-
- /**
- * @param licenseTermsAgreed
- * the licenseTermsAgreed to set
- */
- public void setLicenseTermsAgreed(boolean licenseTermsAgreed) {
- this.licenseTermsAgreed = licenseTermsAgreed;
- }
-
- /**
- * @param path the path of the uncompress tool to be used during virtual image uncompressing.
- */
- public void setUncompressToolPath(String path) {
- this.uncompressToolPath = path;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009 INdT, (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:
+ * Raul Herbster (INdT) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.vm.vmware.ui.wizards;
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMInfo;
+import org.maemo.esbox.internal.vm.vmware.Activator;
+
+/**
+ * This is a wrapper that contains information about Maemo SDK virtual image
+ * installation process.
+ *
+ * @author raulherbster
+ *
+ */
+public class MaemoSDKVMInstallData {
+
+ private MaemoSDKVMInfo fileToDownload;
+ private boolean usePreviousInstallation;
+ private String installationPath;
+ private String pathOfExistentVM;
+ private String uncompressToolPath;
+ private boolean licenseTermsAgreed;
+ private boolean installSbox;
+ private boolean installTargets;
+ private boolean installCppEnv;
+ private boolean installPythonEnv;
+
+ /**
+ * Constructor.
+ */
+ public MaemoSDKVMInstallData() {
+ fileToDownload = new MaemoSDKVMInfo();
+ }
+
+ /**
+ * Set the file to download.
+ *
+ * @param downloadFile
+ */
+ public void setFileToDownload(MaemoSDKVMInfo downloadFile) {
+ if (downloadFile == null)
+ return;
+ this.fileToDownload = downloadFile;
+ if (fileToDownload.getInstallLocation() == null && installationPath != null)
+ try {
+ fileToDownload.setInstallLocation(new File(installationPath).toURL());
+ } catch (MalformedURLException e) {
+ Activator.getErrorLogger().logAndShowError(
+ "Cannot get location for file "
+ + downloadFile.getDescriptor(), e);
+ }
+ }
+
+ /**
+ * Return the file to download.
+ *
+ * @return
+ */
+ public MaemoSDKVMInfo getFileToDownload() {
+ return fileToDownload;
+ }
+
+ /**
+ * @return the usePreviousInstallation
+ */
+ public boolean canUsePreviousInstallation() {
+ return usePreviousInstallation;
+ }
+
+ /**
+ * @param usePreviousInstallation
+ * the usePreviousInstallation to set
+ */
+ public void setUsePreviousInstallation(boolean usePreviousInstallation) {
+ this.usePreviousInstallation = usePreviousInstallation;
+ }
+
+ /**
+ * @return the installationPath
+ */
+ public String getInstallationPath() {
+ return installationPath;
+ }
+
+ /**
+ * @param installationPath
+ * the installationPath to set
+ */
+ public void setInstallationPath(String installationPath) {
+ this.installationPath = installationPath;
+ try {
+ fileToDownload.setInstallLocation(new File(installationPath).toURL());
+ } catch (MalformedURLException e) {
+ Activator.getErrorLogger().logAndShowError(
+ "Cannot get location for file "
+ + fileToDownload.getDescriptor(), e);
+ }
+
+ }
+
+ /**
+ * @return the pathOfExistentVM
+ */
+ public String getPathOfExistentVM() {
+ return pathOfExistentVM;
+ }
+
+ /**
+ * @return the path of uncompress tool to be used.
+ */
+ public String getUncompressToolPath() {
+ return uncompressToolPath;
+ }
+
+ /**
+ * @param pathOfExistentVM
+ * the pathOfExistentVM to set
+ */
+ public void setPathOfExistentVM(String pathOfExistentVM) {
+ this.pathOfExistentVM = pathOfExistentVM;
+ }
+
+ /**
+ * @return the installSbox
+ */
+ public boolean canInstallSbox() {
+ return installSbox;
+ }
+
+ /**
+ * @param installSbox
+ * the installSbox to set
+ */
+ public void setInstallSbox(boolean installSbox) {
+ this.installSbox = installSbox;
+ }
+
+ /**
+ * @return the installTargets
+ */
+ public boolean canInstallTargets() {
+ return installTargets;
+ }
+
+ /**
+ * @param installTargets
+ * the installTargets to set
+ */
+ public void setInstallTargets(boolean installTargets) {
+ this.installTargets = installTargets;
+ }
+
+ /**
+ * @return true, if it is necessary to install Python programming
+ * environment; false, otherwise.
+ */
+ public boolean canInstallPythonEnv() {
+ return installPythonEnv;
+ }
+
+ /**
+ * @param installTargets
+ * the installTargets to set
+ */
+ public void setInstallPythonEnv(boolean installPythonEnv) {
+ this.installPythonEnv = installPythonEnv;
+ }
+
+ /**
+ *
+ * @return true, if it is necessary to install CPP programming environment;
+ * false, otherwise.
+ */
+ public boolean canInstallCppEnv() {
+ return installCppEnv;
+ }
+
+ /**
+ * @param installCppEnv
+ * the installTargets to set
+ */
+ public void setInstallCppEnv(boolean installCppEnv) {
+ this.installCppEnv = installCppEnv;
+ }
+
+ /**
+ * @return true, if license terms were agreed; false, otherwise.
+ */
+ public boolean isLicenseTermsAgreed() {
+ return licenseTermsAgreed;
+ }
+
+ /**
+ * @param licenseTermsAgreed
+ * the licenseTermsAgreed to set
+ */
+ public void setLicenseTermsAgreed(boolean licenseTermsAgreed) {
+ this.licenseTermsAgreed = licenseTermsAgreed;
+ }
+
+ /**
+ * @param path the path of the uncompress tool to be used during virtual image uncompressing.
+ */
+ public void setUncompressToolPath(String path) {
+ this.uncompressToolPath = path;
+ }
+
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallationWorkPage.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,271 +1,271 @@
-/*******************************************************************************
- * Copyright (c) 2009 INdT, (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:
- * Raul Herbster (INdT) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.vm.vmware.ui.wizards;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.swt.graphics.Image;
-import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMDescription;
-import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMInfo;
-import org.maemo.esbox.internal.vm.vmware.Activator;
-import org.maemo.mica.internal.api.common.ui.LazyLoadingThreadTableContentProvider;
-
-import com.nokia.cpp.internal.api.utils.core.FileUtils;
-
-/**
- * Content and label provider for table that shows available Maemo SDK virtual
- * images.
- *
- * @author raulherbster
- *
- */
-public class MaemoSDKVMInstallerContentLabelProvider extends
- LazyLoadingThreadTableContentProvider {
-
- /**
- * Thread to access information about available Maemo SDK virtual images on
- * website.
- *
- * @author raulherbster
- *
- */
- protected class MaemoVMInstallScriptFetcherThread extends Thread {
- protected Object newInput;
-
- /**
- * Construtor.
- *
- * @param newInput
- */
- public MaemoVMInstallScriptFetcherThread(Object newInput) {
- this.newInput = newInput;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Thread#run()
- */
- public void run() {
- doFetchScripts();
-
- contents.remove(LOADING_LABEL);
- doFireContentChanged();
- }
-
- /**
- * Implement by querying the input and/or calling fetchScriptsFromUrl()
- * and adding them to contents.
- */
- protected void doFetchScripts() {
- List<MaemoSDKVMDescription> virtualImagesNames = fetchVMNamesFromUrl(MaemoSDKVMInfo.DOWNLOAD_PAGE);
- for (MaemoSDKVMDescription maemoSDKVM : virtualImagesNames) {
- MaemoSDKVMInfo downloadFile = new MaemoSDKVMInfo();
- downloadFile.setDescriptor(maemoSDKVM);
- if (!contents.contains(downloadFile))
- contents.add(downloadFile);
- else {
- int indexOfExistingDownloadFile = contents
- .indexOf(downloadFile);
- MaemoSDKVMInfo info = ((MaemoSDKVMInfo) contents.get(indexOfExistingDownloadFile));
- info.setNumberOfParts(info.getNumParts() +1);
- }
- }
- }
-
- /**
- * Get available Maemo SDK virtual image from given URL.
- *
- * @param urlString
- * the url of website that contains information about
- * available Maemo SDK virtual images.
- * @return a list with the names of available Maemo SDK virtual images.
- */
- protected List<MaemoSDKVMDescription> fetchVMNamesFromUrl(String urlString) {
- URL url;
- try {
- url = new URL(urlString);
- } catch (MalformedURLException e) {
- Activator.getErrorLogger().logAndShowError(
- "Invalid URL: " + urlString, e);
- return Collections.emptyList();
- }
-
- List<MaemoSDKVMDescription> virtualImagesDescriptors = new ArrayList<MaemoSDKVMDescription>();
- try {
-
- URLConnection connection = url.openConnection();
- connection.setConnectTimeout(1000 * 10);
- connection.connect();
-
- // apparently this fetches the HTML...
- String content = new String(FileUtils.readInputStreamContents(
- connection.getInputStream(), "UTF-8"));
-
- /*
- * The names of virtual images are on
- * http://tablets-dev.nokia.com/maemo-dev-env-downloads.php
- * (front-page). Basically, they list have the following format:
- * Maemo ANY_WORD Virtual ANY_WORD Image ANY_WORD Also, we
- * filter duplicated entries, for example, files split into two
- * parts.
- */
- String license = getLicense(content);
-
- Pattern maemoVMPattern = Pattern
- .compile("Maemo(\\s)+SDK(\\s)+Virtual(\\s)+Image(\\s)+with(\\s)+Ubuntu(\\s)+(\\w)+(\\s)+([\\d]*\\.[\\d]*)(\\s)+(Server|Desktop)(\\s\\-(Part)\\s\\d)?");
- Matcher matcher = maemoVMPattern.matcher(content);
- while (matcher.find()) {
- String virtualImageName = matcher.group(0);
- String version = matcher.group(9);
- virtualImageName = processVirtualImageName(virtualImageName);
- boolean isServer = virtualImageName.toLowerCase().contains("server");
- String virtualImageDescription = isServer ? MaemoSDKVMDescription.SERVER_IMAGE_DESCRIPTION : MaemoSDKVMDescription.DESKTOP_IMAGE_DESCRIPTION;
- virtualImagesDescriptors.add(new MaemoSDKVMDescription(isServer,virtualImageName,version,virtualImageDescription,license));
- }
- } catch (Exception e) {
- if (e instanceof InterruptedException)
- return virtualImagesDescriptors;
-
- if (!isInterrupted())
- Activator.getErrorLogger().logAndShowError(
- "Could not fetch listing from " + url, e);
- }
-
- return virtualImagesDescriptors;
- }
-
- /**
- * Process the description of Maemo SDK virtual image and only returns
- * the main description.
- *
- * @param virtualImageName
- * the complete description of a certain Maemo SDK virtual
- * image.
- * @return the main description of a certain Maemo SDK virtual image.
- */
- private String processVirtualImageName(String virtualImageName) {
- int indexOfPar = virtualImageName.indexOf("(");
- if (indexOfPar < 0)
- return virtualImageName;
- return virtualImageName.substring(0, indexOfPar).trim();
- }
-
- /**
- * Get license from virtual images website.
- * @param content
- * @return
- */
- private String getLicense(String content) {
- final String LICENSE_PATTERN = "IMPORTANT:\\s*READ\\s*CAREFULLY\\s*BEFORE\\s*INSTALLING,\\s*DOWNLOADING,\\s*OR\\s*USING\\s*THE\\s*SOFTWARE(.*?)PLEASE\\s*SUBMIT\\s*ANY\\s*ACCOMPANYING\\s*REGISTRATION\\s*FORMS\\s*TO\\s*RECEIVE\\s*REGISTRATION\\s*BENEFITS\\s*WHERE\\s*APPLICABLE";
- Pattern licensePattern = Pattern.compile(LICENSE_PATTERN,Pattern.DOTALL | Pattern.UNIX_LINES);
- Matcher matcher = licensePattern.matcher(content);
- String license = "";
- while (matcher.find()) {
- license = matcher.group(0);
- }
- return license;
- }
- }
-
- private Image vmImage;
-
- /**
- * Construtor.
- */
- public MaemoSDKVMInstallerContentLabelProvider() {
- super();
- vmImage = Activator.MAEMO_VM_DESCRIPTOR.createImage();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.maemo.mica.common.ui.common.LazyLoadingThreadTableContentProvider
- * #createContentFetchThread(java.lang.Object)
- */
- @Override
- protected Thread createContentFetchThread(Object newInput) {
- return new MaemoVMInstallScriptFetcherThread(newInput);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.
- * Object)
- */
- public Object[] getChildren(Object parentElement) {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object
- * )
- */
- public Object getParent(Object element) {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.
- * Object)
- */
- public boolean hasChildren(Object element) {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- public String getColumnText(Object element, int column) {
- if (element == LOADING_LABEL)
- return super.getColumnText(element, column);
-
- if (element instanceof MaemoSDKVMInfo) {
- MaemoSDKVMInfo data = (MaemoSDKVMInfo) element;
- if (column == 0)
- return data.getDescriptor().getName();
- }
- return "";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
- */
- public Image getColumnImage(Object element, int column) {
- if (element instanceof MaemoSDKVMInfo) {
- if (column == 0)
- return vmImage;
- }
- return null;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009 INdT, (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:
+ * Raul Herbster (INdT) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.vm.vmware.ui.wizards;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.swt.graphics.Image;
+import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMDescription;
+import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMInfo;
+import org.maemo.esbox.internal.vm.vmware.Activator;
+import org.maemo.mica.internal.api.common.ui.LazyLoadingThreadTableContentProvider;
+
+import com.nokia.cpp.internal.api.utils.core.FileUtils;
+
+/**
+ * Content and label provider for table that shows available Maemo SDK virtual
+ * images.
+ *
+ * @author raulherbster
+ *
+ */
+public class MaemoSDKVMInstallerContentLabelProvider extends
+ LazyLoadingThreadTableContentProvider {
+
+ /**
+ * Thread to access information about available Maemo SDK virtual images on
+ * website.
+ *
+ * @author raulherbster
+ *
+ */
+ protected class MaemoVMInstallScriptFetcherThread extends Thread {
+ protected Object newInput;
+
+ /**
+ * Construtor.
+ *
+ * @param newInput
+ */
+ public MaemoVMInstallScriptFetcherThread(Object newInput) {
+ this.newInput = newInput;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Thread#run()
+ */
+ public void run() {
+ doFetchScripts();
+
+ contents.remove(LOADING_LABEL);
+ doFireContentChanged();
+ }
+
+ /**
+ * Implement by querying the input and/or calling fetchScriptsFromUrl()
+ * and adding them to contents.
+ */
+ protected void doFetchScripts() {
+ List<MaemoSDKVMDescription> virtualImagesNames = fetchVMNamesFromUrl(MaemoSDKVMInfo.DOWNLOAD_PAGE);
+ for (MaemoSDKVMDescription maemoSDKVM : virtualImagesNames) {
+ MaemoSDKVMInfo downloadFile = new MaemoSDKVMInfo();
+ downloadFile.setDescriptor(maemoSDKVM);
+ if (!contents.contains(downloadFile))
+ contents.add(downloadFile);
+ else {
+ int indexOfExistingDownloadFile = contents
+ .indexOf(downloadFile);
+ MaemoSDKVMInfo info = ((MaemoSDKVMInfo) contents.get(indexOfExistingDownloadFile));
+ info.setNumberOfParts(info.getNumParts() +1);
+ }
+ }
+ }
+
+ /**
+ * Get available Maemo SDK virtual image from given URL.
+ *
+ * @param urlString
+ * the url of website that contains information about
+ * available Maemo SDK virtual images.
+ * @return a list with the names of available Maemo SDK virtual images.
+ */
+ protected List<MaemoSDKVMDescription> fetchVMNamesFromUrl(String urlString) {
+ URL url;
+ try {
+ url = new URL(urlString);
+ } catch (MalformedURLException e) {
+ Activator.getErrorLogger().logAndShowError(
+ "Invalid URL: " + urlString, e);
+ return Collections.emptyList();
+ }
+
+ List<MaemoSDKVMDescription> virtualImagesDescriptors = new ArrayList<MaemoSDKVMDescription>();
+ try {
+
+ URLConnection connection = url.openConnection();
+ connection.setConnectTimeout(1000 * 10);
+ connection.connect();
+
+ // apparently this fetches the HTML...
+ String content = new String(FileUtils.readInputStreamContents(
+ connection.getInputStream(), "UTF-8"));
+
+ /*
+ * The names of virtual images are on
+ * http://tablets-dev.nokia.com/maemo-dev-env-downloads.php
+ * (front-page). Basically, they list have the following format:
+ * Maemo ANY_WORD Virtual ANY_WORD Image ANY_WORD Also, we
+ * filter duplicated entries, for example, files split into two
+ * parts.
+ */
+ String license = getLicense(content);
+
+ Pattern maemoVMPattern = Pattern
+ .compile("Maemo(\\s)+SDK(\\s)+Virtual(\\s)+Image(\\s)+with(\\s)+Ubuntu(\\s)+(\\w)+(\\s)+([\\d]*\\.[\\d]*)(\\s)+(Server|Desktop)(\\s\\-(Part)\\s\\d)?");
+ Matcher matcher = maemoVMPattern.matcher(content);
+ while (matcher.find()) {
+ String virtualImageName = matcher.group(0);
+ String version = matcher.group(9);
+ virtualImageName = processVirtualImageName(virtualImageName);
+ boolean isServer = virtualImageName.toLowerCase().contains("server");
+ String virtualImageDescription = isServer ? MaemoSDKVMDescription.SERVER_IMAGE_DESCRIPTION : MaemoSDKVMDescription.DESKTOP_IMAGE_DESCRIPTION;
+ virtualImagesDescriptors.add(new MaemoSDKVMDescription(isServer,virtualImageName,version,virtualImageDescription,license));
+ }
+ } catch (Exception e) {
+ if (e instanceof InterruptedException)
+ return virtualImagesDescriptors;
+
+ if (!isInterrupted())
+ Activator.getErrorLogger().logAndShowError(
+ "Could not fetch listing from " + url, e);
+ }
+
+ return virtualImagesDescriptors;
+ }
+
+ /**
+ * Process the description of Maemo SDK virtual image and only returns
+ * the main description.
+ *
+ * @param virtualImageName
+ * the complete description of a certain Maemo SDK virtual
+ * image.
+ * @return the main description of a certain Maemo SDK virtual image.
+ */
+ private String processVirtualImageName(String virtualImageName) {
+ int indexOfPar = virtualImageName.indexOf("(");
+ if (indexOfPar < 0)
+ return virtualImageName;
+ return virtualImageName.substring(0, indexOfPar).trim();
+ }
+
+ /**
+ * Get license from virtual images website.
+ * @param content
+ * @return
+ */
+ private String getLicense(String content) {
+ final String LICENSE_PATTERN = "IMPORTANT:\\s*READ\\s*CAREFULLY\\s*BEFORE\\s*INSTALLING,\\s*DOWNLOADING,\\s*OR\\s*USING\\s*THE\\s*SOFTWARE(.*?)PLEASE\\s*SUBMIT\\s*ANY\\s*ACCOMPANYING\\s*REGISTRATION\\s*FORMS\\s*TO\\s*RECEIVE\\s*REGISTRATION\\s*BENEFITS\\s*WHERE\\s*APPLICABLE";
+ Pattern licensePattern = Pattern.compile(LICENSE_PATTERN,Pattern.DOTALL | Pattern.UNIX_LINES);
+ Matcher matcher = licensePattern.matcher(content);
+ String license = "";
+ while (matcher.find()) {
+ license = matcher.group(0);
+ }
+ return license;
+ }
+ }
+
+ private Image vmImage;
+
+ /**
+ * Construtor.
+ */
+ public MaemoSDKVMInstallerContentLabelProvider() {
+ super();
+ vmImage = Activator.MAEMO_VM_DESCRIPTOR.createImage();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.maemo.mica.common.ui.common.LazyLoadingThreadTableContentProvider
+ * #createContentFetchThread(java.lang.Object)
+ */
+ @Override
+ protected Thread createContentFetchThread(Object newInput) {
+ return new MaemoVMInstallScriptFetcherThread(newInput);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.
+ * Object)
+ */
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object
+ * )
+ */
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.
+ * Object)
+ */
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ public String getColumnText(Object element, int column) {
+ if (element == LOADING_LABEL)
+ return super.getColumnText(element, column);
+
+ if (element instanceof MaemoSDKVMInfo) {
+ MaemoSDKVMInfo data = (MaemoSDKVMInfo) element;
+ if (column == 0)
+ return data.getDescriptor().getName();
+ }
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+ */
+ public Image getColumnImage(Object element, int column) {
+ if (element instanceof MaemoSDKVMInfo) {
+ if (column == 0)
+ return vmImage;
+ }
+ return null;
+ }
+
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMLicenseWizardPage.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/NewMaemoSDKVMWizard.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/vm/vmware/IVMwareConfiguration.java
===================================================================
--- branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/vm/vmware/IVMwareConfiguration.java 2009-09-09 23:00:00 UTC (rev 2138)
+++ branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/vm/vmware/IVMwareConfiguration.java 2009-09-09 23:20:35 UTC (rev 2139)
@@ -1,38 +1,38 @@
-/*******************************************************************************
- * Copyright (c) 2008-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.vm.vmware;
-
-import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
-
-/**
- * This interface, implemented by clients, provides settings needed
- * to launch and communicate with a virtual machine using VMware.
- * <p>
- * The stock implementation for VMware machines created by IBuildMachineProvider
- * reads the corresponding settings dynamically from VMwarePreferenceConstants.
- * @author eswartz
- *
- */
-public interface IVMwareConfiguration extends IVirtualMachineConfiguration {
-
- /** Get the VMX path
- * @return full path to *.vmx file
- */
- String getVmxPath();
-
- /**
- * Set the VMX path
- * @param path full path to *.vmx file
- */
- void setVmxPath(String path);
-
-}
+/*******************************************************************************
+ * Copyright (c) 2008-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.vm.vmware;
+
+import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
+
+/**
+ * This interface, implemented by clients, provides settings needed
+ * to launch and communicate with a virtual machine using VMware.
+ * <p>
+ * The stock implementation for VMware machines created by IBuildMachineProvider
+ * reads the corresponding settings dynamically from VMwarePreferenceConstants.
+ * @author eswartz
+ *
+ */
+public interface IVMwareConfiguration extends IVirtualMachineConfiguration {
+
+ /** Get the VMX path
+ * @return full path to *.vmx file
+ */
+ String getVmxPath();
+
+ /**
+ * Set the VMX path
+ * @param path full path to *.vmx file
+ */
+ void setVmxPath(String path);
+
+}
Property changes on: branches/2.0.0-prefinal/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/vm/vmware/IVMwareConfiguration.java
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Esbox-commits
mailing list